Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dlw_primus with upi/transactionid #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Stata/plus/d/dlw_primus.ado
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ program define dlw_primus, rclass
qui do "`persdir'datalibweb/`=upper("`type'")'.do"
}

local user = upper(c(username))
local user = subinstr("`user'","WB","",.)
local user = subinstr("`user'","C","",.)
local user = subinstr("`user'","S","",.)
local user = subinstr("`user'","D","",.)

local opt 9

//get the list or specific files from pending transactions in PRIMUS
Expand All @@ -28,7 +34,7 @@ program define dlw_primus, rclass
if "``cstr''"=="" local s_`cstr'
else local s_`cstr' "&`cstr'=``cstr''"
}
local dlibapi "Server=$rootname&Country=`country'&Year=`year'&Collection=$type&`s_collection'`s_folder'`s_token'`s_filename'`s_para1'`s_para2'`s_para3'`s_para4'`s_ext'"
local dlibapi "Upi=`user'&Server=$rootname&Country=`country'&Year=`year'&Collection=$type&TransactionId=`tranxid'&`s_collection'`s_folder'`s_token'`s_filename'`s_para1'`s_para2'`s_para3'`s_para4'`s_ext'"
*noi dis `"dlw_api, option(9) outfile(`primusout') query("`dlibapi'")"'
dlw_api, option(9) outfile(`primusout') query("`dlibapi'")
if `dlibrc'==0 {
Expand All @@ -37,7 +43,7 @@ program define dlw_primus, rclass
noi dis "File list is loaded"
}
else { //different filenames
if "`=lower(`dlibType')'"=="dta" { // only one file matched/subscribed - load the file
if "`=lower("`dlibType'")'"=="dta" { // only one file matched/subscribed - load the file
cap use `primusout', clear //load the data
if _rc==0 {
noi dis "Data file is loaded"
Expand All @@ -48,7 +54,7 @@ program define dlw_primus, rclass
error 1
}
} // dta type
else if "`=lower(`dlibType')'"=="do" { // only one file matched/subscribed - load the file
else if "`=lower("`dlibType'")'"=="do" { // only one file matched/subscribed - load the file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is prompt to errors. It is better to use double compound quotes. Like the following

``"=lower("dlibType'")'"'==`"dta"' ` // (there is an extra (`) in this code because of the formatting, but it should not go there).

cap doedit "`tmppath'\`dlibFileName'"
if _rc==0 {
noi dis as text in yellow `"{p 4 4 2}The dofile (`dlibFileName') is loaded.{p_end}"'
Expand Down