@sasjs/core 4.18.17 → 4.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mf_getuniquefileref.sas +5 -3
- package/base/mf_isint.sas +4 -1
- package/base/mp_chop.sas +194 -0
- package/base/mp_createwebservice.sas +13 -2
- package/base/mp_gsubfile.sas +1 -1
- package/base/mp_jsonout.sas +1 -1
- package/base/mp_replace.sas +4 -2
- package/base/mp_testservice.sas +24 -3
- package/lua/ml_gsubfile.sas +8 -0
- package/lua/ml_json.sas +8 -0
- package/meta/mm_createwebservice.sas +20 -20
- package/package.json +1 -1
- package/server/mfs_httpheader.sas +2 -1
- package/server/ms_createfile.sas +12 -5
- package/server/ms_createuser.sas +144 -0
- package/server/ms_createwebservice.sas +532 -0
- package/server/ms_deletefile.sas +14 -1
- package/server/ms_getfile.sas +14 -5
- package/server/ms_getusers.sas +107 -0
- package/server/ms_runstp.sas +130 -9
- package/server/ms_testservice.sas +152 -0
- package/server/ms_webout.sas +9 -8
- package/viya/mv_createwebservice.sas +20 -20
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Fetches the list of users from SASjs Server
|
|
4
|
+
@details Fetches the list of users from SASjs Server and writes them to an
|
|
5
|
+
output dataset.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
|
|
9
|
+
%ms_getusers(outds=userlist)
|
|
10
|
+
|
|
11
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
12
|
+
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
|
13
|
+
list of user accounts. Format:
|
|
14
|
+
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
|
15
|
+
|---|---|---|
|
|
16
|
+
|`Super Admin `|`secretuser `|`1`|
|
|
17
|
+
|`Sabir Hassan`|`sabir`|`2`|
|
|
18
|
+
|`Mihajlo Medjedovic `|`mihajlo `|`3`|
|
|
19
|
+
|`Ivor Townsend `|`ivor `|`4`|
|
|
20
|
+
|`New User `|`newuser `|`5`|
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<h4> SAS Macros </h4>
|
|
25
|
+
@li mf_getuniquefileref.sas
|
|
26
|
+
@li mf_getuniquelibref.sas
|
|
27
|
+
@li mp_abort.sas
|
|
28
|
+
|
|
29
|
+
<h4> Related Files </h4>
|
|
30
|
+
@li ms_createuser.sas
|
|
31
|
+
@li ms_getusers.test.sas
|
|
32
|
+
|
|
33
|
+
**/
|
|
34
|
+
|
|
35
|
+
%macro ms_getusers(
|
|
36
|
+
outds=work.ms_getusers
|
|
37
|
+
,mdebug=0
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
%mp_abort(
|
|
41
|
+
iftrue=(&syscc ne 0)
|
|
42
|
+
,mac=ms_getusers.sas
|
|
43
|
+
,msg=%str(syscc=&syscc on macro entry)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
%local fref0 fref1 libref optval rc msg;
|
|
47
|
+
%let fref0=%mf_getuniquefileref();
|
|
48
|
+
%let fref1=%mf_getuniquefileref();
|
|
49
|
+
%let libref=%mf_getuniquelibref();
|
|
50
|
+
|
|
51
|
+
/* avoid sending bom marker to API */
|
|
52
|
+
%let optval=%sysfunc(getoption(bomfile));
|
|
53
|
+
options nobomfile;
|
|
54
|
+
|
|
55
|
+
data _null_;
|
|
56
|
+
file &fref0 lrecl=1000;
|
|
57
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
58
|
+
input;
|
|
59
|
+
put "Authorization: Bearer " _infile_;
|
|
60
|
+
put "accept: application/json";
|
|
61
|
+
run;
|
|
62
|
+
|
|
63
|
+
%if &mdebug=1 %then %do;
|
|
64
|
+
data _null_;
|
|
65
|
+
infile &fref0;
|
|
66
|
+
input;
|
|
67
|
+
put _infile_;
|
|
68
|
+
run;
|
|
69
|
+
%end;
|
|
70
|
+
|
|
71
|
+
proc http method='GET' headerin=&fref0 out=&fref1
|
|
72
|
+
url="&_sasjs_apiserverurl/SASjsApi/user";
|
|
73
|
+
%if &mdebug=1 %then %do;
|
|
74
|
+
debug level=1;
|
|
75
|
+
%end;
|
|
76
|
+
run;
|
|
77
|
+
|
|
78
|
+
%mp_abort(
|
|
79
|
+
iftrue=(&syscc ne 0)
|
|
80
|
+
,mac=ms_getusers.sas
|
|
81
|
+
,msg=%str(Issue submitting GET query to SASjsApi/user)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
libname &libref JSON fileref=&fref1;
|
|
85
|
+
|
|
86
|
+
data &outds;
|
|
87
|
+
set &libref..root;
|
|
88
|
+
drop ordinal_root;
|
|
89
|
+
run;
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
%mp_abort(
|
|
93
|
+
iftrue=(&syscc ne 0)
|
|
94
|
+
,mac=ms_getusers.sas
|
|
95
|
+
,msg=%str(Issue reading response JSON)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
/* reset options */
|
|
99
|
+
options &optval;
|
|
100
|
+
|
|
101
|
+
%if &mdebug=1 %then %do;
|
|
102
|
+
filename &fref0 clear;
|
|
103
|
+
filename &fref1 clear;
|
|
104
|
+
libname &libref clear;
|
|
105
|
+
%end;
|
|
106
|
+
|
|
107
|
+
%mend ms_getusers;
|
package/server/ms_runstp.sas
CHANGED
|
@@ -15,48 +15,154 @@
|
|
|
15
15
|
parameter)
|
|
16
16
|
@param [in] debug= (131) The value to supply to the _debug URL parameter
|
|
17
17
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
18
|
+
@param [in] inputparams=(_null_) A dataset containing name/value pairs in the
|
|
19
|
+
following format:
|
|
20
|
+
|name:$32|value:$10000|
|
|
21
|
+
|---|---|
|
|
22
|
+
|stpmacname|some value|
|
|
23
|
+
|mustbevalidname|can be anything, oops, %abort!!|
|
|
24
|
+
@param [in] inputfiles= (_null_) A dataset containing fileref/name/filename in
|
|
25
|
+
the following format:
|
|
26
|
+
|fileref:$8|name:$32|filename:$256|
|
|
27
|
+
|---|---|--|
|
|
28
|
+
|someref|some_name|some_filename.xls|
|
|
29
|
+
|fref2|another_file|zyx_v2.csv|
|
|
30
|
+
|
|
18
31
|
@param [out] outref= (outweb) The output fileref to contain the response JSON
|
|
19
32
|
(will be created using temp engine)
|
|
33
|
+
@param [out] outlogds= (_null_) Set to the name of a dataset to contain the
|
|
34
|
+
log. Table format:
|
|
35
|
+
|line:$2000|
|
|
36
|
+
|---|
|
|
37
|
+
|log line 1|
|
|
38
|
+
|log line 2|
|
|
20
39
|
|
|
21
40
|
<h4> SAS Macros </h4>
|
|
22
41
|
@li mf_getuniquefileref.sas
|
|
42
|
+
@li mf_getuniquelibref.sas
|
|
23
43
|
@li mp_abort.sas
|
|
24
44
|
|
|
25
45
|
**/
|
|
26
46
|
|
|
27
47
|
%macro ms_runstp(pgm
|
|
28
48
|
,debug=131
|
|
49
|
+
,inputparams=_null_
|
|
50
|
+
,inputfiles=_null_
|
|
29
51
|
,outref=outweb
|
|
52
|
+
,outlogds=_null_
|
|
30
53
|
,mdebug=0
|
|
31
54
|
);
|
|
32
|
-
%local dbg
|
|
55
|
+
%local dbg mainref authref boundary;
|
|
56
|
+
%let mainref=%mf_getuniquefileref();
|
|
57
|
+
%let authref=%mf_getuniquefileref();
|
|
58
|
+
%let boundary=%mf_getuniquename();
|
|
59
|
+
%if &inputparams=0 %then %let inputparams=_null_;
|
|
60
|
+
|
|
33
61
|
%if &mdebug=1 %then %do;
|
|
34
62
|
%put &sysmacroname entry vars:;
|
|
35
63
|
%put _local_;
|
|
36
64
|
%end;
|
|
37
65
|
%else %let dbg=*;
|
|
38
|
-
|
|
66
|
+
|
|
39
67
|
|
|
40
68
|
%mp_abort(iftrue=("&pgm"="")
|
|
41
69
|
,mac=&sysmacroname
|
|
42
70
|
,msg=%str(Program not provided)
|
|
43
71
|
)
|
|
44
72
|
|
|
73
|
+
/* avoid sending bom marker to API */
|
|
74
|
+
%local optval;
|
|
75
|
+
%let optval=%sysfunc(getoption(bomfile));
|
|
76
|
+
options nobomfile;
|
|
77
|
+
|
|
78
|
+
/* add params */
|
|
45
79
|
data _null_;
|
|
46
|
-
file &
|
|
47
|
-
|
|
80
|
+
file &mainref termstr=crlf lrecl=32767 mod;
|
|
81
|
+
length line $1000 name $32 value $32767;
|
|
82
|
+
if _n_=1 then call missing(of _all_);
|
|
83
|
+
set &inputparams;
|
|
84
|
+
put "--&boundary";
|
|
85
|
+
line=cats('Content-Disposition: form-data; name="',name,'"');
|
|
86
|
+
put line;
|
|
87
|
+
put ;
|
|
88
|
+
put value;
|
|
89
|
+
run;
|
|
90
|
+
|
|
91
|
+
/* parse input file list */
|
|
92
|
+
%local webcount;
|
|
93
|
+
%let webcount=0;
|
|
94
|
+
data _null_;
|
|
95
|
+
set &inputfiles end=last;
|
|
96
|
+
length fileref $8 name $32 filename $256;
|
|
97
|
+
call symputx(cats('webref',_n_),fileref,'l');
|
|
98
|
+
call symputx(cats('webname',_n_),name,'l');
|
|
99
|
+
call symputx(cats('webfilename',_n_),filename,'l');
|
|
100
|
+
if last then do;
|
|
101
|
+
call symputx('webcount',_n_);
|
|
102
|
+
call missing(of _all_);
|
|
103
|
+
end;
|
|
104
|
+
run;
|
|
105
|
+
|
|
106
|
+
/* write out the input files */
|
|
107
|
+
%local i;
|
|
108
|
+
%do i=1 %to &webcount;
|
|
109
|
+
data _null_;
|
|
110
|
+
file &mainref termstr=crlf lrecl=32767 mod;
|
|
111
|
+
infile &&webref&i lrecl=32767;
|
|
112
|
+
if _n_ = 1 then do;
|
|
113
|
+
length line $32767;
|
|
114
|
+
line=cats(
|
|
115
|
+
'Content-Disposition: form-data; name="'
|
|
116
|
+
,"&&webname&i"
|
|
117
|
+
,'"; filename="'
|
|
118
|
+
,"&&webfilename&i"
|
|
119
|
+
,'"'
|
|
120
|
+
);
|
|
121
|
+
put "--&boundary";
|
|
122
|
+
put line;
|
|
123
|
+
put "Content-Type: text/plain";
|
|
124
|
+
put ;
|
|
125
|
+
end;
|
|
126
|
+
input;
|
|
127
|
+
put _infile_; /* add the actual file to be sent */
|
|
128
|
+
run;
|
|
129
|
+
%end;
|
|
130
|
+
|
|
131
|
+
data _null_;
|
|
132
|
+
file &mainref termstr=crlf mod;
|
|
133
|
+
put "--&boundary--";
|
|
134
|
+
run;
|
|
135
|
+
|
|
136
|
+
data _null_;
|
|
137
|
+
file &authref lrecl=1000;
|
|
138
|
+
infile "&_sasjs_tokenfile" lrecl=1000;
|
|
48
139
|
input;
|
|
49
|
-
put 'Authorization: Bearer' _infile_;
|
|
140
|
+
put 'Authorization: Bearer ' _infile_;
|
|
141
|
+
put "Content-Type: multipart/form-data; boundary=&boundary";
|
|
50
142
|
run;
|
|
51
143
|
|
|
52
|
-
|
|
144
|
+
%if &mdebug=1 %then %do;
|
|
145
|
+
data _null_;
|
|
146
|
+
infile &authref;
|
|
147
|
+
input;
|
|
148
|
+
put _infile_;
|
|
149
|
+
data _null_;
|
|
150
|
+
infile &mainref;
|
|
151
|
+
input;
|
|
152
|
+
put _infile_;
|
|
153
|
+
run;
|
|
154
|
+
%end;
|
|
53
155
|
|
|
156
|
+
filename &outref temp lrecl=32767;
|
|
54
157
|
/* prepare request*/
|
|
55
|
-
proc http method='POST' headerin=&
|
|
158
|
+
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
|
56
159
|
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
|
160
|
+
%if &mdebug=1 %then %do;
|
|
161
|
+
debug level=2;
|
|
162
|
+
%end;
|
|
57
163
|
run;
|
|
58
164
|
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
|
59
|
-
|
|
165
|
+
%then %do;
|
|
60
166
|
data _null_;infile &outref;input;putlog _infile_;run;
|
|
61
167
|
%end;
|
|
62
168
|
%mp_abort(
|
|
@@ -65,6 +171,20 @@ run;
|
|
|
65
171
|
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
|
66
172
|
)
|
|
67
173
|
|
|
174
|
+
/* reset options */
|
|
175
|
+
options &optval;
|
|
176
|
+
|
|
177
|
+
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
|
178
|
+
%local dumplib;
|
|
179
|
+
%let dumplib=%mf_getuniquelibref();
|
|
180
|
+
libname &dumplib json (&outref);
|
|
181
|
+
data &outlogds;
|
|
182
|
+
set &dumplib..log;
|
|
183
|
+
%if &mdebug=1 %then %do;
|
|
184
|
+
putlog line=;
|
|
185
|
+
%end;
|
|
186
|
+
run;
|
|
187
|
+
%end;
|
|
68
188
|
|
|
69
189
|
%if &mdebug=1 %then %do;
|
|
70
190
|
%put &sysmacroname exit vars:;
|
|
@@ -72,6 +192,7 @@ run;
|
|
|
72
192
|
%end;
|
|
73
193
|
%else %do;
|
|
74
194
|
/* clear refs */
|
|
75
|
-
filename &
|
|
195
|
+
filename &authref;
|
|
196
|
+
filename &mainref;
|
|
76
197
|
%end;
|
|
77
198
|
%mend ms_runstp;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Will execute a SASjs web service on SASjs Server
|
|
4
|
+
@details Prepares the input files and retrieves the resulting datasets from
|
|
5
|
+
the response JSON.
|
|
6
|
+
|
|
7
|
+
@param [in] program The Stored Program endpoint to test
|
|
8
|
+
@param [in] inputfiles=(0) A list of space seperated fileref:filename pairs as
|
|
9
|
+
follows:
|
|
10
|
+
inputfiles=inref:filename inref2:filename2
|
|
11
|
+
@param [in] inputdatasets= (0) All datasets in this space seperated list are
|
|
12
|
+
converted into SASJS-formatted CSVs (see mp_ds2csv.sas) files and added to
|
|
13
|
+
the list of `inputfiles` for ingestion. The dataset will be sent with the
|
|
14
|
+
same name (no need for a colon modifier).
|
|
15
|
+
@param [in] inputparams=(0) A dataset containing name/value pairs in the
|
|
16
|
+
following format:
|
|
17
|
+
|name:$32|value:$1000|
|
|
18
|
+
|---|---|
|
|
19
|
+
|stpmacname|some value|
|
|
20
|
+
|mustbevalidname|can be anything, oops, %abort!!|
|
|
21
|
+
|
|
22
|
+
@param [in] debug= (131) Provide the _debug value to pass to the STP
|
|
23
|
+
@param [in] mdebug= (0) Set to 1 to provide macro debugging (this macro)
|
|
24
|
+
@param [out] outlib= (0) Output libref to contain the final tables. Set to
|
|
25
|
+
0 if the service output is not in JSON format.
|
|
26
|
+
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
|
27
|
+
response.
|
|
28
|
+
@param [out] outlogds= (_null_) Set to the name of a dataset to contain the
|
|
29
|
+
log. Table format:
|
|
30
|
+
|line:$2000|
|
|
31
|
+
|---|
|
|
32
|
+
|log line 1|
|
|
33
|
+
|log line 2|
|
|
34
|
+
|
|
35
|
+
<h4> SAS Macros </h4>
|
|
36
|
+
@li mf_getuniquefileref.sas
|
|
37
|
+
@li mf_getuniquename.sas
|
|
38
|
+
@li mp_abort.sas
|
|
39
|
+
@li mp_binarycopy.sas
|
|
40
|
+
@li mp_chop.sas
|
|
41
|
+
@li mp_ds2csv.sas
|
|
42
|
+
@li ms_runstp.sas
|
|
43
|
+
|
|
44
|
+
<h4> Related Programs </h4>
|
|
45
|
+
@li mp_testservice.test.sas
|
|
46
|
+
|
|
47
|
+
@version 9.4
|
|
48
|
+
@author Allan Bowe
|
|
49
|
+
|
|
50
|
+
**/
|
|
51
|
+
|
|
52
|
+
%macro ms_testservice(program,
|
|
53
|
+
inputfiles=0,
|
|
54
|
+
inputdatasets=0,
|
|
55
|
+
inputparams=0,
|
|
56
|
+
debug=0,
|
|
57
|
+
mdebug=0,
|
|
58
|
+
outlib=0,
|
|
59
|
+
outref=0,
|
|
60
|
+
outlogds=_null_
|
|
61
|
+
)/*/STORE SOURCE*/;
|
|
62
|
+
%local dbg fref1 chopout1 chopout2;
|
|
63
|
+
%if &mdebug=1 %then %do;
|
|
64
|
+
%put &sysmacroname entry vars:;
|
|
65
|
+
%put _local_;
|
|
66
|
+
%end;
|
|
67
|
+
%else %let dbg=*;
|
|
68
|
+
|
|
69
|
+
/* convert inputdatasets to filerefs */
|
|
70
|
+
%if "&inputdatasets" ne "0" %then %do;
|
|
71
|
+
%if %quote(&inputfiles)=0 %then %let inputfiles=;
|
|
72
|
+
%do i=1 %to %sysfunc(countw(&inputdatasets,%str( )));
|
|
73
|
+
%let var=%scan(&inputdatasets,&i,%str( ));
|
|
74
|
+
%local dsref&i;
|
|
75
|
+
%let dsref&i=%mf_getuniquefileref();
|
|
76
|
+
%mp_ds2csv(&var,outref=&&dsref&i,headerformat=SASJS)
|
|
77
|
+
%let inputfiles=&inputfiles &&dsref&i:%scan(&var,-1,.);
|
|
78
|
+
%end;
|
|
79
|
+
%end;
|
|
80
|
+
|
|
81
|
+
/* parse the filerefs - convert to a dataset */
|
|
82
|
+
%let ds1=%mf_getuniquename();
|
|
83
|
+
data &ds1;
|
|
84
|
+
length fileref $8 name $32 filename $256 var $300;
|
|
85
|
+
webcount=countw("&inputfiles");
|
|
86
|
+
do i=1 to webcount;
|
|
87
|
+
var=scan("&inputfiles",i,' ');
|
|
88
|
+
fileref=scan(var,1,':');
|
|
89
|
+
name=scan(var,2,':');
|
|
90
|
+
filename=cats(name,'.csv');
|
|
91
|
+
output;
|
|
92
|
+
end;
|
|
93
|
+
run;
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
/* execute the STP */
|
|
97
|
+
%let fref1=%mf_getuniquefileref();
|
|
98
|
+
|
|
99
|
+
%ms_runstp(&program
|
|
100
|
+
,debug=&debug
|
|
101
|
+
,inputparams=&inputparams
|
|
102
|
+
,inputfiles=&ds1
|
|
103
|
+
,outref=&fref1
|
|
104
|
+
,mdebug=&mdebug
|
|
105
|
+
,outlogds=&outlogds
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/* SASjs services have the _webout embedded in wrapper JSON */
|
|
110
|
+
/* Files can also be very large - so use a dedicated macro to chop it out */
|
|
111
|
+
%local matchstr1 matchstr2 ;
|
|
112
|
+
%let matchstr1={"status":"success","_webout":{;
|
|
113
|
+
%let matchstr2=},"log":[{;
|
|
114
|
+
%let chopout1=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop1);
|
|
115
|
+
%let chopout2=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop2);
|
|
116
|
+
|
|
117
|
+
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
|
118
|
+
,matchvar=matchstr1
|
|
119
|
+
,keep=LAST
|
|
120
|
+
,matchpoint=END
|
|
121
|
+
,offset=-1
|
|
122
|
+
,outfile="&chopout1"
|
|
123
|
+
,mdebug=&mdebug
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
%mp_chop("&chopout1"
|
|
127
|
+
,matchvar=matchstr2
|
|
128
|
+
,keep=FIRST
|
|
129
|
+
,matchpoint=START
|
|
130
|
+
,offset=1
|
|
131
|
+
,outfile="&chopout2"
|
|
132
|
+
,mdebug=&mdebug
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
%if &outlib ne 0 %then %do;
|
|
136
|
+
libname &outlib json "&chopout2";
|
|
137
|
+
%end;
|
|
138
|
+
%if &outref ne 0 %then %do;
|
|
139
|
+
filename &outref "&chopout2";
|
|
140
|
+
%end;
|
|
141
|
+
|
|
142
|
+
%if &mdebug=0 %then %do;
|
|
143
|
+
filename &webref clear;
|
|
144
|
+
filename &fref1 clear;
|
|
145
|
+
filename &fref2 clear;
|
|
146
|
+
%end;
|
|
147
|
+
%else %do;
|
|
148
|
+
%put &sysmacroname exit vars:;
|
|
149
|
+
%put _local_;
|
|
150
|
+
%end;
|
|
151
|
+
|
|
152
|
+
%mend ms_testservice;
|
package/server/ms_webout.sas
CHANGED
|
@@ -67,13 +67,14 @@
|
|
|
67
67
|
%let _webin_name1=&_webin_name;
|
|
68
68
|
%end;
|
|
69
69
|
data _null_;
|
|
70
|
-
infile &&_webin_fileref&i termstr=crlf;
|
|
70
|
+
infile &&_webin_fileref&i termstr=crlf lrecl=32767;
|
|
71
71
|
input;
|
|
72
72
|
call symputx('input_statement',_infile_);
|
|
73
73
|
putlog "&&_webin_name&i input statement: " _infile_;
|
|
74
74
|
stop;
|
|
75
75
|
data &&_webin_name&i;
|
|
76
|
-
infile &&_webin_fileref&i firstobs=2 dsd termstr=crlf encoding='utf-8'
|
|
76
|
+
infile &&_webin_fileref&i firstobs=2 dsd termstr=crlf encoding='utf-8'
|
|
77
|
+
lrecl=32767;
|
|
77
78
|
input &input_statement;
|
|
78
79
|
%if %str(&_debug) ge 131 %then %do;
|
|
79
80
|
if _n_<20 then putlog _infile_;
|
|
@@ -84,14 +85,14 @@
|
|
|
84
85
|
%end;
|
|
85
86
|
|
|
86
87
|
%else %if &action=OPEN %then %do;
|
|
87
|
-
/* fix encoding */
|
|
88
|
-
OPTIONS NOBOMFILE;
|
|
88
|
+
/* fix encoding and ensure enough lrecl */
|
|
89
|
+
OPTIONS NOBOMFILE lrecl=32767;
|
|
89
90
|
|
|
90
91
|
/* set the header */
|
|
91
92
|
%mfs_httpheader(Content-type,application/json)
|
|
92
93
|
|
|
93
|
-
/* setup json
|
|
94
|
-
data _null_;file &fref encoding='utf-8' termstr=lf;
|
|
94
|
+
/* setup json. */
|
|
95
|
+
data _null_;file &fref encoding='utf-8' termstr=lf ;
|
|
95
96
|
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
96
97
|
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
97
98
|
run;
|
|
@@ -135,12 +136,12 @@
|
|
|
135
136
|
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
136
137
|
put "}";
|
|
137
138
|
%end;
|
|
138
|
-
data _null_; file &fref mod encoding='utf-8' termstr=lf
|
|
139
|
+
data _null_; file &fref mod encoding='utf-8' termstr=lf;
|
|
139
140
|
put "}";
|
|
140
141
|
run;
|
|
141
142
|
%end;
|
|
142
143
|
/* close off json */
|
|
143
|
-
data _null_;file &fref mod encoding='utf-8' termstr=lf;
|
|
144
|
+
data _null_;file &fref mod encoding='utf-8' termstr=lf lrecl=32767;
|
|
144
145
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
|
145
146
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
|
146
147
|
put ",""MF_GETUSER"" : ""%mf_getuser()"" ";
|
|
@@ -247,7 +247,7 @@ data _null_;
|
|
|
247
247
|
put ' ';
|
|
248
248
|
put '%if &action=OPEN %then %do; ';
|
|
249
249
|
put ' options nobomfile; ';
|
|
250
|
-
put ' data _null_;file &jref encoding=''utf-8'' ; ';
|
|
250
|
+
put ' data _null_;file &jref encoding=''utf-8'' lrecl=200; ';
|
|
251
251
|
put ' put ''{"PROCESSED_DTTM" : "'' "%sysfunc(datetime(),E8601DT26.6)" ''"''; ';
|
|
252
252
|
put ' run; ';
|
|
253
253
|
put '%end; ';
|
|
@@ -458,6 +458,25 @@ data _null_;
|
|
|
458
458
|
put ' run; ';
|
|
459
459
|
put '%end; ';
|
|
460
460
|
put '%mend mp_jsonout; ';
|
|
461
|
+
put ' ';
|
|
462
|
+
put '%macro mf_getuser(type=META ';
|
|
463
|
+
put ')/*/STORE SOURCE*/; ';
|
|
464
|
+
put ' %local user metavar; ';
|
|
465
|
+
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
466
|
+
put ' %else %let metavar=_metaperson; ';
|
|
467
|
+
put ' ';
|
|
468
|
+
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
|
469
|
+
put ' %else %if %symexist(&metavar) %then %do; ';
|
|
470
|
+
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
|
471
|
+
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
|
472
|
+
put ' /* but be sure to quote in case of usernames with commas */ ';
|
|
473
|
+
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
|
474
|
+
put ' %end; ';
|
|
475
|
+
put ' %else %let user=&sysuserid; ';
|
|
476
|
+
put ' ';
|
|
477
|
+
put ' %quote(&user) ';
|
|
478
|
+
put ' ';
|
|
479
|
+
put '%mend mf_getuser; ';
|
|
461
480
|
put '%macro mv_webout(action,ds,fref=_mvwtemp,dslabel=,fmt=Y,stream=Y,missing=NULL ';
|
|
462
481
|
put ' ,showmeta=NO ';
|
|
463
482
|
put '); ';
|
|
@@ -632,25 +651,6 @@ data _null_;
|
|
|
632
651
|
put '%end; ';
|
|
633
652
|
put ' ';
|
|
634
653
|
put '%mend mv_webout; ';
|
|
635
|
-
put ' ';
|
|
636
|
-
put '%macro mf_getuser(type=META ';
|
|
637
|
-
put ')/*/STORE SOURCE*/; ';
|
|
638
|
-
put ' %local user metavar; ';
|
|
639
|
-
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
640
|
-
put ' %else %let metavar=_metaperson; ';
|
|
641
|
-
put ' ';
|
|
642
|
-
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
|
643
|
-
put ' %else %if %symexist(&metavar) %then %do; ';
|
|
644
|
-
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
|
645
|
-
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
|
646
|
-
put ' /* but be sure to quote in case of usernames with commas */ ';
|
|
647
|
-
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
|
648
|
-
put ' %end; ';
|
|
649
|
-
put ' %else %let user=&sysuserid; ';
|
|
650
|
-
put ' ';
|
|
651
|
-
put ' %quote(&user) ';
|
|
652
|
-
put ' ';
|
|
653
|
-
put '%mend mf_getuser; ';
|
|
654
654
|
/* WEBOUT END */
|
|
655
655
|
put '/* if calling viya service with _job param, _program will conflict */';
|
|
656
656
|
put '/* so it is provided by SASjs instead as __program */';
|