@sasjs/core 4.31.0 → 4.31.1
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/mp_abort.sas +200 -200
- package/package.json +1 -1
package/base/mp_abort.sas
CHANGED
|
@@ -63,236 +63,236 @@
|
|
|
63
63
|
, mode=REGULAR
|
|
64
64
|
)/*/STORE SOURCE*/;
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc sasjsprocessmode;
|
|
67
|
+
%local fref fid i;
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
%if not(%eval(%unquote(&iftrue))) %then %return;
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
%put NOTE: /// mp_abort macro executing //;
|
|
72
|
+
%if %length(&mac)>0 %then %put NOTE- called by &mac;
|
|
73
|
+
%put NOTE - &msg;
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
|
76
|
+
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
|
77
|
+
and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
|
78
|
+
%then %do;
|
|
79
|
+
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
|
80
|
+
data &errds;
|
|
81
|
+
iftrue='1=1';
|
|
82
|
+
length mac $100 msg $5000;
|
|
83
|
+
mac=symget('mac');
|
|
84
|
+
msg=symget('msg');
|
|
85
|
+
run;
|
|
86
|
+
data _null_;
|
|
87
|
+
abort cancel FILE;
|
|
88
|
+
run;
|
|
89
|
+
%return;
|
|
90
|
+
%end;
|
|
91
|
+
%end;
|
|
92
|
+
|
|
93
|
+
/* Web App Context */
|
|
94
|
+
%if %symexist(_PROGRAM)
|
|
95
|
+
or %superq(SYSPROCESSNAME) = %str(Compute Server)
|
|
96
|
+
or &mode=INCLUDE
|
|
97
|
+
%then %do;
|
|
98
|
+
options obs=max replace mprint;
|
|
99
|
+
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
|
|
78
100
|
%then %do;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
msg=symget('msg');
|
|
85
|
-
run;
|
|
101
|
+
options nosyntaxcheck;
|
|
102
|
+
%end;
|
|
103
|
+
|
|
104
|
+
%if &mode=INCLUDE %then %do;
|
|
105
|
+
%if %sysfunc(exist(&errds))=1 %then %do;
|
|
86
106
|
data _null_;
|
|
87
|
-
|
|
107
|
+
set &errds;
|
|
108
|
+
call symputx('iftrue',iftrue,'l');
|
|
109
|
+
call symputx('mac',mac,'l');
|
|
110
|
+
call symputx('msg',msg,'l');
|
|
111
|
+
putlog (_all_)(=);
|
|
88
112
|
run;
|
|
113
|
+
%if (&iftrue)=0 %then %return;
|
|
114
|
+
%end;
|
|
115
|
+
%else %do;
|
|
116
|
+
%put &sysmacroname: No include errors found;
|
|
89
117
|
%return;
|
|
90
118
|
%end;
|
|
91
119
|
%end;
|
|
92
120
|
|
|
93
|
-
/*
|
|
94
|
-
%
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
%
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
%put &sysmacroname: No include errors found;
|
|
117
|
-
%return;
|
|
118
|
-
%end;
|
|
119
|
-
%end;
|
|
120
|
-
|
|
121
|
-
/* extract log errs / warns, if exist */
|
|
122
|
-
%local logloc logline;
|
|
123
|
-
%global logmsg; /* capture global messages */
|
|
124
|
-
%if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
|
|
125
|
-
%else %let logloc=%qsysfunc(getoption(LOG));
|
|
126
|
-
proc printto log=log;run;
|
|
127
|
-
%let logline=0;
|
|
128
|
-
%if %length(&logloc)>0 %then %do;
|
|
121
|
+
/* extract log errs / warns, if exist */
|
|
122
|
+
%local logloc logline;
|
|
123
|
+
%global logmsg; /* capture global messages */
|
|
124
|
+
%if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
|
|
125
|
+
%else %let logloc=%qsysfunc(getoption(LOG));
|
|
126
|
+
proc printto log=log;run;
|
|
127
|
+
%let logline=0;
|
|
128
|
+
%if %length(&logloc)>0 %then %do;
|
|
129
|
+
data _null_;
|
|
130
|
+
infile &logloc lrecl=5000;
|
|
131
|
+
input; putlog _infile_;
|
|
132
|
+
i=1;
|
|
133
|
+
retain logonce 0;
|
|
134
|
+
if (
|
|
135
|
+
_infile_=:"%str(WARN)ING" or _infile_=:"%str(ERR)OR"
|
|
136
|
+
) and logonce=0 then
|
|
137
|
+
do;
|
|
138
|
+
call symputx('logline',_n_);
|
|
139
|
+
logonce+1;
|
|
140
|
+
end;
|
|
141
|
+
run;
|
|
142
|
+
/* capture log including lines BEFORE the err */
|
|
143
|
+
%if &logline>0 %then %do;
|
|
129
144
|
data _null_;
|
|
130
145
|
infile &logloc lrecl=5000;
|
|
131
|
-
input;
|
|
146
|
+
input;
|
|
132
147
|
i=1;
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
logonce+1;
|
|
148
|
+
stoploop=0;
|
|
149
|
+
if _n_ ge &logline-15 and stoploop=0 then do until (i>22);
|
|
150
|
+
call symputx('logmsg',catx('\n',symget('logmsg'),_infile_));
|
|
151
|
+
input;
|
|
152
|
+
i+1;
|
|
153
|
+
stoploop=1;
|
|
140
154
|
end;
|
|
155
|
+
if stoploop=1 then stop;
|
|
141
156
|
run;
|
|
142
|
-
/* capture log including lines BEFORE the err */
|
|
143
|
-
%if &logline>0 %then %do;
|
|
144
|
-
data _null_;
|
|
145
|
-
infile &logloc lrecl=5000;
|
|
146
|
-
input;
|
|
147
|
-
i=1;
|
|
148
|
-
stoploop=0;
|
|
149
|
-
if _n_ ge &logline-15 and stoploop=0 then do until (i>22);
|
|
150
|
-
call symputx('logmsg',catx('\n',symget('logmsg'),_infile_));
|
|
151
|
-
input;
|
|
152
|
-
i+1;
|
|
153
|
-
stoploop=1;
|
|
154
|
-
end;
|
|
155
|
-
if stoploop=1 then stop;
|
|
156
|
-
run;
|
|
157
|
-
%end;
|
|
158
157
|
%end;
|
|
158
|
+
%end;
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
%end;
|
|
166
|
-
%else %do;
|
|
167
|
-
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
168
|
-
name="_webout.json" lrecl=999999 mod;
|
|
169
|
-
%end;
|
|
160
|
+
%if %symexist(SYS_JES_JOB_URI) %then %do;
|
|
161
|
+
/* setup webout for Viya */
|
|
162
|
+
options nobomfile;
|
|
163
|
+
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
|
|
164
|
+
filename _webout temp lrecl=999999 mod;
|
|
170
165
|
%end;
|
|
171
|
-
%else %
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
%let fid=%sysfunc(fopen(&fref,A));
|
|
175
|
-
%if &fid=0 %then %do;
|
|
176
|
-
%put %str(ERR)OR: %sysfunc(sysmsg());
|
|
177
|
-
%return;
|
|
178
|
-
%end;
|
|
179
|
-
%let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
|
|
180
|
-
%let rc=%sysfunc(fwrite(&fid));
|
|
181
|
-
%let rc=%sysfunc(fclose(&fid));
|
|
182
|
-
%let rc=%sysfunc(filename(&fref));
|
|
166
|
+
%else %do;
|
|
167
|
+
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
168
|
+
name="_webout.json" lrecl=999999 mod;
|
|
183
169
|
%end;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
|
|
170
|
+
%end;
|
|
171
|
+
%else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
|
|
172
|
+
options nobomfile;
|
|
173
|
+
/* set up http header for SASjs Server */
|
|
174
|
+
%let fid=%sysfunc(fopen(&fref,A));
|
|
175
|
+
%if &fid=0 %then %do;
|
|
176
|
+
%put %str(ERR)OR: %sysfunc(sysmsg());
|
|
177
|
+
%return;
|
|
193
178
|
%end;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
msg=compress(msg,,'kw');
|
|
200
|
-
/* quote without quoting the quotes (which are escaped instead) */
|
|
201
|
-
msg=cats('"',msg,'"');
|
|
202
|
-
if symexist('_debug') then debug=quote(trim(symget('_debug')));
|
|
203
|
-
else debug='""';
|
|
204
|
-
if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
|
|
205
|
-
if mode ne 'SASJS' then put '>>weboutBEGIN<<';
|
|
206
|
-
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
207
|
-
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
208
|
-
put ',"sasjsAbort" : [{';
|
|
209
|
-
put ' "MSG":' msg ;
|
|
210
|
-
put ' ,"MAC": "' "&mac" '"}]';
|
|
211
|
-
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
|
212
|
-
put ',"_DEBUG":' debug ;
|
|
213
|
-
if symexist('_metauser') then do;
|
|
214
|
-
_METAUSER=quote(trim(symget('_METAUSER')));
|
|
215
|
-
put ",""_METAUSER"": " _METAUSER;
|
|
216
|
-
_METAPERSON=quote(trim(symget('_METAPERSON')));
|
|
217
|
-
put ',"_METAPERSON": ' _METAPERSON;
|
|
218
|
-
end;
|
|
219
|
-
if symexist('SYS_JES_JOB_URI') then do;
|
|
220
|
-
SYS_JES_JOB_URI=quote(trim(symget('SYS_JES_JOB_URI')));
|
|
221
|
-
put ',"SYS_JES_JOB_URI": ' SYS_JES_JOB_URI;
|
|
222
|
-
end;
|
|
223
|
-
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
|
224
|
-
put ',"_PROGRAM" : ' _PROGRAM ;
|
|
225
|
-
put ",""SYSCC"" : ""&syscc"" ";
|
|
226
|
-
syserrortext=quote(trim(symget('syserrortext')));
|
|
227
|
-
put ",""SYSERRORTEXT"" : " syserrortext;
|
|
228
|
-
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
|
229
|
-
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
|
230
|
-
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
|
231
|
-
put ",""SYSSITE"" : ""&syssite"" ";
|
|
232
|
-
sysvlong=quote(trim(symget('sysvlong')));
|
|
233
|
-
put ',"SYSVLONG" : ' sysvlong;
|
|
234
|
-
syswarningtext=quote(trim(symget('syswarningtext')));
|
|
235
|
-
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
|
236
|
-
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
|
237
|
-
put "}" ;
|
|
238
|
-
if mode ne 'SASJS' then put '>>weboutEND<<';
|
|
239
|
-
run;
|
|
179
|
+
%let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
|
|
180
|
+
%let rc=%sysfunc(fwrite(&fid));
|
|
181
|
+
%let rc=%sysfunc(fclose(&fid));
|
|
182
|
+
%let rc=%sysfunc(filename(&fref));
|
|
183
|
+
%end;
|
|
240
184
|
|
|
241
|
-
|
|
185
|
+
/* send response in SASjs JSON format */
|
|
186
|
+
data _null_;
|
|
187
|
+
file _webout mod lrecl=32000 encoding='utf-8';
|
|
188
|
+
length msg syswarningtext syserrortext $32767 mode $10 ;
|
|
189
|
+
sasdatetime=datetime();
|
|
190
|
+
msg=symget('msg');
|
|
191
|
+
%if &logline>0 %then %do;
|
|
192
|
+
msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
|
|
193
|
+
%end;
|
|
194
|
+
/* escape the escapes */
|
|
195
|
+
msg=tranwrd(msg,'\','\\');
|
|
196
|
+
/* escape the quotes */
|
|
197
|
+
msg=tranwrd(msg,'"','\"');
|
|
198
|
+
/* ditch the CRLFs as chrome complains */
|
|
199
|
+
msg=compress(msg,,'kw');
|
|
200
|
+
/* quote without quoting the quotes (which are escaped instead) */
|
|
201
|
+
msg=cats('"',msg,'"');
|
|
202
|
+
if symexist('_debug') then debug=quote(trim(symget('_debug')));
|
|
203
|
+
else debug='""';
|
|
204
|
+
if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
|
|
205
|
+
if mode ne 'SASJS' then put '>>weboutBEGIN<<';
|
|
206
|
+
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
207
|
+
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
208
|
+
put ',"sasjsAbort" : [{';
|
|
209
|
+
put ' "MSG":' msg ;
|
|
210
|
+
put ' ,"MAC": "' "&mac" '"}]';
|
|
211
|
+
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
|
212
|
+
put ',"_DEBUG":' debug ;
|
|
213
|
+
if symexist('_metauser') then do;
|
|
214
|
+
_METAUSER=quote(trim(symget('_METAUSER')));
|
|
215
|
+
put ",""_METAUSER"": " _METAUSER;
|
|
216
|
+
_METAPERSON=quote(trim(symget('_METAPERSON')));
|
|
217
|
+
put ',"_METAPERSON": ' _METAPERSON;
|
|
218
|
+
end;
|
|
219
|
+
if symexist('SYS_JES_JOB_URI') then do;
|
|
220
|
+
SYS_JES_JOB_URI=quote(trim(symget('SYS_JES_JOB_URI')));
|
|
221
|
+
put ',"SYS_JES_JOB_URI": ' SYS_JES_JOB_URI;
|
|
222
|
+
end;
|
|
223
|
+
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
|
224
|
+
put ',"_PROGRAM" : ' _PROGRAM ;
|
|
225
|
+
put ",""SYSCC"" : ""&syscc"" ";
|
|
226
|
+
syserrortext=quote(trim(symget('syserrortext')));
|
|
227
|
+
put ",""SYSERRORTEXT"" : " syserrortext;
|
|
228
|
+
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
|
229
|
+
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
|
230
|
+
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
|
231
|
+
put ",""SYSSITE"" : ""&syssite"" ";
|
|
232
|
+
sysvlong=quote(trim(symget('sysvlong')));
|
|
233
|
+
put ',"SYSVLONG" : ' sysvlong;
|
|
234
|
+
syswarningtext=quote(trim(symget('syswarningtext')));
|
|
235
|
+
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
|
236
|
+
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
|
237
|
+
put "}" ;
|
|
238
|
+
if mode ne 'SASJS' then put '>>weboutEND<<';
|
|
239
|
+
run;
|
|
242
240
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* endsas kills 9.4m3 deployments by orphaning multibridges.
|
|
258
|
-
* Abort variants are ungraceful (non zero return code)
|
|
259
|
-
* This approach lets SAS run silently until the end :-)
|
|
260
|
-
* Caution - fails when called within a %include within a macro
|
|
261
|
-
* Use mp_include() to handle this.
|
|
262
|
-
*/
|
|
263
|
-
filename skip temp;
|
|
264
|
-
data _null_;
|
|
265
|
-
file skip;
|
|
266
|
-
put '%macro skip();';
|
|
267
|
-
comment '%mend skip; -> fix lint ';
|
|
268
|
-
put '%macro skippy();';
|
|
269
|
-
comment '%mend skippy; -> fix lint ';
|
|
270
|
-
run;
|
|
271
|
-
%inc skip;
|
|
272
|
-
%end;
|
|
241
|
+
%put _all_;
|
|
242
|
+
|
|
243
|
+
%if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
|
|
244
|
+
data _null_;
|
|
245
|
+
putlog 'stpsrvset program err and syscc';
|
|
246
|
+
rc=stpsrvset('program error', 0);
|
|
247
|
+
call symputx("syscc",0,"g");
|
|
248
|
+
run;
|
|
249
|
+
%if &sysscp=WIN
|
|
250
|
+
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
|
251
|
+
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
|
252
|
+
/* skip approach (below) does not work in windows m6+ envs */
|
|
253
|
+
endsas;
|
|
273
254
|
%end;
|
|
274
|
-
%else %
|
|
275
|
-
|
|
255
|
+
%else %do;
|
|
256
|
+
/**
|
|
257
|
+
* endsas kills 9.4m3 deployments by orphaning multibridges.
|
|
258
|
+
* Abort variants are ungraceful (non zero return code)
|
|
259
|
+
* This approach lets SAS run silently until the end :-)
|
|
260
|
+
* Caution - fails when called within a %include within a macro
|
|
261
|
+
* Use mp_include() to handle this.
|
|
262
|
+
*/
|
|
263
|
+
filename skip temp;
|
|
276
264
|
data _null_;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
iftrue=symget('iftrue');
|
|
283
|
-
put (_all_)(/=);
|
|
284
|
-
call symputx('syscc',0);
|
|
285
|
-
abort cancel nolist;
|
|
265
|
+
file skip;
|
|
266
|
+
put '%macro skip();';
|
|
267
|
+
comment '%mend skip; -> fix lint ';
|
|
268
|
+
put '%macro skippy();';
|
|
269
|
+
comment '%mend skippy; -> fix lint ';
|
|
286
270
|
run;
|
|
271
|
+
%inc skip;
|
|
287
272
|
%end;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
273
|
+
%end;
|
|
274
|
+
%else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
|
|
275
|
+
/* endsas kills the session making it harder to fetch results */
|
|
276
|
+
data _null_;
|
|
277
|
+
syswarningtext=symget('syswarningtext');
|
|
278
|
+
syserrortext=symget('syserrortext');
|
|
279
|
+
abort_msg=symget('msg');
|
|
280
|
+
syscc=symget('syscc');
|
|
281
|
+
sysuserid=symget('sysuserid');
|
|
282
|
+
iftrue=symget('iftrue');
|
|
283
|
+
put (_all_)(/=);
|
|
284
|
+
call symputx('syscc',0);
|
|
285
|
+
abort cancel nolist;
|
|
286
|
+
run;
|
|
291
287
|
%end;
|
|
292
288
|
%else %do;
|
|
293
|
-
%put _all_;
|
|
294
289
|
%abort cancel;
|
|
295
290
|
%end;
|
|
291
|
+
%end;
|
|
292
|
+
%else %do;
|
|
293
|
+
%put _all_;
|
|
294
|
+
%abort cancel;
|
|
295
|
+
%end;
|
|
296
296
|
%mend mp_abort;
|
|
297
297
|
|
|
298
298
|
/** @endcond */
|
package/package.json
CHANGED