50%macro ms_triggerstp(pgm
55 ,outds=work.ms_triggerstp
58 %local dbg mainref authref boundary libref triggered_sid;
59 %let mainref=%mf_getuniquefileref();
60 %let authref=%mf_getuniquefileref();
61 %let boundary=%mf_getuniquename();
62 %
if &inputparams=0 %then %let inputparams=_null_;
64 %
if &mdebug=1 %then %
do;
65 %put &sysmacroname entry vars:;
71 %mp_abort(iftrue=(
"&pgm"=
"")
73 ,msg=%str(Program not provided)
75 %mp_abort(iftrue=(
"&outds"=
"")
77 ,msg=%str(Output dataset not provided)
82 %let optval=%sysfunc(getoption(bomfile));
87 file &mainref termstr=crlf lrecl=32767 mod;
88 length line $1000 name $32 value $32767;
89 if _n_=1 then call missing(of _all_);
92 line=cats(
'Content-Disposition: form-data; name="',name,
'"');
102 set &inputfiles end=last;
103 length fileref $8 name $32 filename $256;
104 call symputx(cats(
'webref',_n_),fileref,
'l');
105 call symputx(cats(
'webname',_n_),name,
'l');
106 call symputx(cats(
'webfilename',_n_),filename,
'l');
108 call symputx(
'webcount',_n_);
109 call missing(of _all_);
115 %
do i=1 %to &webcount;
117 file &mainref termstr=crlf lrecl=32767 mod;
118 infile &&webref&i lrecl=32767;
122 'Content-Disposition: form-data; name="'
130 put
"Content-Type: text/plain";
140 file &mainref termstr=crlf mod;
141 put /
"--&boundary--";
145 file &authref lrecl=1000;
146 infile
"&_sasjs_tokenfile" lrecl=1000;
148 if _n_=1 then put
"Content-Type: multipart/form-data; boundary=&boundary";
152 %
if &mdebug=1 %then %
do;
154 if _n_ eq 1 then putlog
"NOTE: ***** authref=&authref content *****";
159 if _n_ eq 1 then putlog
"NOTE: ***** mainref=&mainref content *****";
166 %local resp_path outref;
167 %let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
168 %let outref=%mf_getuniquefileref();
169 filename &outref
"&resp_path" lrecl=32767;
172 proc http method=
'POST' headerin=&authref in=&mainref out=&outref
173 url=
"&_sasjs_apiserverurl/SASjsApi/stp/trigger?%trim(
174 )_program=&pgm%str(&)_debug=131%str(&)expiresAfterMins=&expiresaftermins";
175 %
if &mdebug=1 %then %
do;
180 %
if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
184 if _n_ eq 1 then putlog
"NOTE: ***** outref=&outref content *****";
191 iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200
192 and &SYS_PROCHTTP_STATUS_CODE ne 201)
194 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
200 %let libref=%mf_getuniquelibref();
201 libname &libref JSON fileref=&outref;
202 %let triggered_sid=%mf_getuniquename(prefix=triggered_sid_);
204 data work.&triggered_sid (keep=sessionid);
207 %
if &mdebug=1 %then %
do;
212 %
if %mf_nobs(work.&triggered_sid)>0 %then %
do;
213 proc append base=&outds data=work.&triggered_sid;
217 %
if &mdebug=1 %then %
do;
218 %put &sysmacroname exit vars:;
226 libname &libref clear;
228 %mp_dropmembers(&triggered_sid,libref=work);