1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-07 09:30:06 +00:00

feat: adding sysvlong to the webout macros, also updating documentation and adding tests. Closes #33

This commit is contained in:
Allan Bowe
2021-05-20 11:23:10 +03:00
parent 76b1b951c0
commit c9ad38ee98
5 changed files with 109 additions and 23 deletions

View File

@@ -26,7 +26,8 @@
@param action Either FETCH, OPEN, ARR, OBJ or CLOSE @param action Either FETCH, OPEN, ARR, OBJ or CLOSE
@param ds The dataset to send back to the frontend @param ds The dataset to send back to the frontend
@param dslabel= value to use instead of the real name for sending to JSON @param dslabel= value to use instead of the real name for sending to JSON
@param fmt= set to N to send back unformatted values @param fmt=(Y) Set to N to send back unformatted values
@param fref=(_webout) The fileref to which to write the JSON
@version 9.3 @version 9.3
@author Allan Bowe @author Allan Bowe
@@ -91,7 +92,7 @@
%end; %end;
%else %if &action=ARR or &action=OBJ %then %do; %else %if &action=ARR or &action=OBJ %then %do;
%mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt %mp_jsonout(&action,&ds,dslabel=&dslabel,fmt=&fmt,jref=&fref
,engine=DATASTEP,dbg=%str(&_debug) ,engine=DATASTEP,dbg=%str(&_debug)
) )
%end; %end;
@@ -150,6 +151,8 @@
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSJOBID"" : ""&sysjobid"" "; put ",""SYSJOBID"" : ""&sysjobid"" ";
put ",""SYSSITE"" : ""&syssite"" "; put ",""SYSSITE"" : ""&syssite"" ";
sysvlong=quote(trim(symget('sysvlong')));
put ',"SYSVLONG" : ' sysvlong;
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" '; put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
put "}" @; put "}" @;
@@ -159,4 +162,4 @@
run; run;
%end; %end;
%mend; %mend mm_webout;

View File

@@ -5,7 +5,8 @@
"meta", "meta",
"metax", "metax",
"viya", "viya",
"lua" "lua",
"tests/base"
], ],
"docConfig": { "docConfig": {
"displayMacroCore": false, "displayMacroCore": false,
@@ -16,6 +17,13 @@
"readMe": "../../README.md" "readMe": "../../README.md"
} }
}, },
"testConfig": {
"initProgram": "tests/testinit.sas",
"termProgram": "tests/testterm.sas",
"macroVars": {
"mcTestAppLoc": "/Public/temp/macrocore"
}
},
"defaultTarget": "viya", "defaultTarget": "viya",
"targets": [ "targets": [
{ {
@@ -27,22 +35,18 @@
"deployServicePack": true "deployServicePack": true
}, },
"macroFolders": [ "macroFolders": [
"base",
"meta",
"metax",
"viya",
"lua",
"tests/base",
"tests/viya" "tests/viya"
], ],
"contextName": "SAS Job Execution compute context", "contextName": "SAS Job Execution compute context"
"testConfig": { },
"initProgram": "tests/testinit.sas", {
"termProgram": "tests/testterm.sas", "name": "sas9",
"macroVars": { "serverUrl": "https://sas.analytium.co.uk:8343",
"mcTestAppLoc": "/Public/temp/macrocore" "serverType": "SAS9",
} "appLoc": "/Shared Data/temp/macrocore",
} "macroFolders": [
"tests/meta"
]
} }
] ]
} }

View File

@@ -0,0 +1,35 @@
/**
@file
@brief Testing mm_webout macro
<h4> SAS Macros </h4>
@li mf_getuniquefileref.sas
@li mm_webout.sas
@li mp_assert.sas
**/
%let fref=%mf_getuniquefileref();
%global _metaperson;
data some datasets;
x=1;
run;
%mm_webout(OPEN,fref=&fref)
%mm_webout(ARR,some,fref=&fref)
%mm_webout(OBJ,datasets,fref=&fref)
%mm_webout(CLOSE,fref=&fref)
libname test JSON (&fref);
data root;
set test.root;
call symputx('checkval',sysvlong);
run;
data alldata;
set test.alldata;
run;
%mp_assert(
iftrue=(%str(&checkval)=%str(&sysvlong)),
desc=Check if the sysvlong value was created
)

View File

@@ -0,0 +1,41 @@
/**
@file
@brief Testing mm_webout macro
<h4> SAS Macros </h4>
@li mf_getuniquefileref.sas
@li mv_webout.sas
@li mp_assert.sas
**/
%let fref=%mf_getuniquefileref();
%global _metaperson;
data some datasets;
x=1;
run;
%mv_webout(OPEN,fref=&fref,stream=N)
%mv_webout(ARR,some,fref=&fref,stream=N)
%mv_webout(OBJ,datasets,fref=&fref,stream=N)
%mv_webout(CLOSE,fref=&fref,stream=N)
data _null_;
infile &fref;
input;
putlog _infile_;
run;
libname test JSON (&fref);
data root;
set test.root;
call symputx('checkval',sysvlong);
run;
data alldata;
set test.alldata;
run;
%mp_assert(
iftrue=(%str(&checkval)=%str(&sysvlong)),
desc=Check if the sysvlong value was created
)

View File

@@ -23,9 +23,10 @@
@param action Either OPEN, ARR, OBJ or CLOSE @param action Either OPEN, ARR, OBJ or CLOSE
@param ds The dataset to send back to the frontend @param ds The dataset to send back to the frontend
@param _webout= fileref for returning the json @param _webout= fileref for returning the json
@param fref= temp fref @param fref=(_mvwtemp) Temp fileref to which to write the output
@param dslabel= value to use instead of the real name for sending to JSON @param dslabel= value to use instead of the real name for sending to JSON
@param fmt= change to N to strip formats from output @param fmt=(Y) change to N to strip formats from output
@param stream=(Y) Change to N if not streaming to _webout
<h4> SAS Macros </h4> <h4> SAS Macros </h4>
@li mp_jsonout.sas @li mp_jsonout.sas
@@ -35,7 +36,7 @@
@author Allan Bowe, source: https://github.com/sasjs/core @author Allan Bowe, source: https://github.com/sasjs/core
**/ **/
%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y); %macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y);
%global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name %global _webin_file_count _webin_fileuri _debug _omittextlog _webin_name
sasjs_tables SYS_JES_JOB_URI; sasjs_tables SYS_JES_JOB_URI;
%if %index("&_debug",log) %then %let _debug=131; %if %index("&_debug",log) %then %let _debug=131;
@@ -214,14 +215,16 @@
put ",""SYSERRORTEXT"" : ""&syserrortext"" "; put ",""SYSERRORTEXT"" : ""&syserrortext"" ";
put ",""SYSHOSTNAME"" : ""&syshostname"" "; put ",""SYSHOSTNAME"" : ""&syshostname"" ";
put ",""SYSSITE"" : ""&syssite"" "; put ",""SYSSITE"" : ""&syssite"" ";
sysvlong=quote(trim(symget('sysvlong')));
put ',"SYSVLONG" : ' sysvlong;
put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" "; put ",""SYSWARNINGTEXT"" : ""&syswarningtext"" ";
put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" '; put ',"END_DTTM" : "' "%sysfunc(datetime(),datetime20.3)" '" ';
put "}"; put "}";
%if %upcase(&fref) ne _WEBOUT %then %do; %if %upcase(&fref) ne _WEBOUT and &stream=Y %then %do;
data _null_; rc=fcopy("&fref","_webout");run; data _null_; rc=fcopy("&fref","_webout");run;
%end; %end;
%end; %end;
%mend; %mend mv_webout;