From b96df6f14fdf9fc7c86649f49a7bd248eddb3335 Mon Sep 17 00:00:00 2001 From: munja Date: Mon, 7 Mar 2022 14:25:05 +0000 Subject: [PATCH] fix: mp_replace and mv_getjobcode were not ingesting periods correctly --- all.sas | 34 +++++++++++++++---------- base/mp_replace.sas | 2 +- tests/crossplatform/mp_replace.test.sas | 30 ++++++++++++++++++++++ viya/mv_getgroups.sas | 8 +++--- viya/mv_getjobcode.sas | 23 +++++++++++------ 5 files changed, 69 insertions(+), 28 deletions(-) diff --git a/all.sas b/all.sas index dcc57a6..ff90df7 100644 --- a/all.sas +++ b/all.sas @@ -9693,7 +9693,7 @@ filename &inref &infile lrecl=1 recfm=n; data &ds1; infile &inref; - input sourcechar $ 1. @@; + input sourcechar $char1. @@; format sourcechar hex2.; run; @@ -21527,7 +21527,7 @@ filename &fname1 clear; ,grant_type=sas_services ,outds=work.viyagroups ); -%local oauth_bearer; +%local oauth_bearer base_uri fname1 libref1; %if &grant_type=detect %then %do; %if %symexist(&access_token_var) %then %let grant_type=authorization_code; %else %let grant_type=sas_services; @@ -21545,11 +21545,10 @@ filename &fname1 clear; ) options noquotelenmax; -%local base_uri; /* location of rest apis */ +/* location of rest apis */ %let base_uri=%mf_getplatform(VIYARESTAPI); /* fetching folder details for provided path */ -%local fname1; %let fname1=%mf_getuniquefileref(); %let libref1=%mf_getuniquelibref(); @@ -21573,12 +21572,12 @@ data &outds; run; - /* clear refs */ filename &fname1 clear; libname &libref1 clear; -%mend mv_getgroups;/** +%mend mv_getgroups; +/** @file @brief Extract the source code from a SAS Viya Job @details Extracts the SAS code from a Job into a fileref or physical file. @@ -21625,7 +21624,7 @@ libname &libref1 clear; ); %local dbg bufsize varcnt fname1 fname2 errmsg; %if &mdebug=1 %then %do; - %put &sysmacroname entry vars:; + %put &sysmacroname local entry vars:; %put _local_; %end; %else %let dbg=*; @@ -21692,14 +21691,21 @@ proc http method='GET' out=&fname1 &oauth_bearer %end; ; run; -%if &SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201 %then -%do; - data _null_;infile &fname1;input;putlog _infile_;run; - %mp_abort(mac=&sysmacroname - ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE) - ) + +%if &mdebug=1 %then %do; + data _null_; + infile &fname1; + input; + putlog _infile_; + run; %end; +%mp_abort( + iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201) + ,mac=&sysmacroname + ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE) +) + %let fname2=%mf_getuniquefileref(); filename &fname2 temp ; @@ -21708,7 +21714,7 @@ filename &fname2 temp ; data _null_; file &fname2 recfm=n; infile &fname1 lrecl=1 recfm=n; - input sourcechar $ 1. @@; + input sourcechar $char1. @@; format sourcechar hex2.; retain startwrite 0; if startwrite=0 and sourcechar='"' then do; diff --git a/base/mp_replace.sas b/base/mp_replace.sas index c702f16..a989e9e 100644 --- a/base/mp_replace.sas +++ b/base/mp_replace.sas @@ -70,7 +70,7 @@ filename &inref &infile lrecl=1 recfm=n; data &ds1; infile &inref; - input sourcechar $ 1. @@; + input sourcechar $char1. @@; format sourcechar hex2.; run; diff --git a/tests/crossplatform/mp_replace.test.sas b/tests/crossplatform/mp_replace.test.sas index 802f74d..2c0d1b7 100644 --- a/tests/crossplatform/mp_replace.test.sas +++ b/tests/crossplatform/mp_replace.test.sas @@ -63,3 +63,33 @@ run; desc=Checking second replace 3rd row, outds=work.test_results ) + + +%let test3="&sasjswork/file3.txt"; +%let str=%str(replace.string.with.dots ); +%let rep=%str( more.dots); +data _null_; + file &test3; + put 'blahblah'; + put "blahblah&str.blah&str. replace &str.X"; + put "blahbreplacewith&str.spacesahblah"; +run; +%mp_replace(&test3, findvar=str, replacevar=rep) + +data _null_; + infile &test3; + input; + if _n_=2 then call symputx('test3resulta',_infile_); + if _n_=3 then call symputx('test3resultb',_infile_); +run; + +%mp_assert( + iftrue=("&test3resulta" = "blahblah&rep.blah&rep. replace &rep.X"), + desc=Checking third replace 2nd row (dots), + outds=work.test_results +) +%mp_assert( + iftrue=("&test3resultb" = "blahbreplacewith&rep.spacesahblah"), + desc=Checking third replace 3rd row (dots), + outds=work.test_results +) diff --git a/viya/mv_getgroups.sas b/viya/mv_getgroups.sas index 8a46775..bb74a40 100644 --- a/viya/mv_getgroups.sas +++ b/viya/mv_getgroups.sas @@ -32,7 +32,7 @@ ,grant_type=sas_services ,outds=work.viyagroups ); -%local oauth_bearer; +%local oauth_bearer base_uri fname1 libref1; %if &grant_type=detect %then %do; %if %symexist(&access_token_var) %then %let grant_type=authorization_code; %else %let grant_type=sas_services; @@ -50,11 +50,10 @@ ) options noquotelenmax; -%local base_uri; /* location of rest apis */ +/* location of rest apis */ %let base_uri=%mf_getplatform(VIYARESTAPI); /* fetching folder details for provided path */ -%local fname1; %let fname1=%mf_getuniquefileref(); %let libref1=%mf_getuniquelibref(); @@ -78,9 +77,8 @@ data &outds; run; - /* clear refs */ filename &fname1 clear; libname &libref1 clear; -%mend mv_getgroups; \ No newline at end of file +%mend mv_getgroups; diff --git a/viya/mv_getjobcode.sas b/viya/mv_getjobcode.sas index 40b1509..b7e347e 100644 --- a/viya/mv_getjobcode.sas +++ b/viya/mv_getjobcode.sas @@ -45,7 +45,7 @@ ); %local dbg bufsize varcnt fname1 fname2 errmsg; %if &mdebug=1 %then %do; - %put &sysmacroname entry vars:; + %put &sysmacroname local entry vars:; %put _local_; %end; %else %let dbg=*; @@ -112,14 +112,21 @@ proc http method='GET' out=&fname1 &oauth_bearer %end; ; run; -%if &SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201 %then -%do; - data _null_;infile &fname1;input;putlog _infile_;run; - %mp_abort(mac=&sysmacroname - ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE) - ) + +%if &mdebug=1 %then %do; + data _null_; + infile &fname1; + input; + putlog _infile_; + run; %end; +%mp_abort( + iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201) + ,mac=&sysmacroname + ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE) +) + %let fname2=%mf_getuniquefileref(); filename &fname2 temp ; @@ -128,7 +135,7 @@ filename &fname2 temp ; data _null_; file &fname2 recfm=n; infile &fname1 lrecl=1 recfm=n; - input sourcechar $ 1. @@; + input sourcechar $char1. @@; format sourcechar hex2.; retain startwrite 0; if startwrite=0 and sourcechar='"' then do;