@sasjs/core 7.0.1 → 7.0.3
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/package.json +1 -1
- package/xplatform/mx_execute.sas +57 -8
package/package.json
CHANGED
package/xplatform/mx_execute.sas
CHANGED
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
viyaresult=WEBOUT_JSON,
|
|
78
78
|
viyacontext=SAS Job Execution compute context
|
|
79
79
|
);
|
|
80
|
-
%local dbg pcnt fref1 fref2 webref webrefpath i webcount var platform jobds respref clearmeref
|
|
80
|
+
%local dbg pcnt fref1 fref2 webref webrefpath i webcount var platform jobds respref clearmeref
|
|
81
|
+
msgref abortmsg;
|
|
81
82
|
%if &mdebug=1 %then %do;
|
|
82
83
|
%put &sysmacroname entry vars:;
|
|
83
84
|
%put _local_;
|
|
@@ -310,7 +311,7 @@ filename &webref "&webrefpath";
|
|
|
310
311
|
/* the outcome, before the flow table goes away */
|
|
311
312
|
%if "&outstatus" ne "0" %then %do;
|
|
312
313
|
data &outstatus;
|
|
313
|
-
length state $20 uri $256 errmsg $
|
|
314
|
+
length state $20 uri $256 errmsg $32767 platform $10;
|
|
314
315
|
platform='SASVIYA';
|
|
315
316
|
errmsg='';
|
|
316
317
|
set &jobds(keep=state uri);
|
|
@@ -320,13 +321,55 @@ filename &webref "&webrefpath";
|
|
|
320
321
|
proc datasets lib=work nolist nowarn;
|
|
321
322
|
delete &jobds;
|
|
322
323
|
quit;
|
|
324
|
+
/* the abort message is not in the job state, it is in the result - so a
|
|
325
|
+
* result file is needed to read it even when the caller did not ask for one */
|
|
326
|
+
%let msgref=&outref;
|
|
327
|
+
%if "&outstatus" ne "0" and "&outref"="0" %then %do;
|
|
328
|
+
%let msgref=%mf_getuniquefileref();
|
|
329
|
+
%let clearmeref=1;
|
|
330
|
+
%end;
|
|
323
331
|
/* fetch results from webout.json */
|
|
324
332
|
%mv_getjobresult(uri=&uri,
|
|
325
333
|
result=&viyaresult,
|
|
326
|
-
outref=&
|
|
334
|
+
outref=&msgref,
|
|
327
335
|
outlib=&outlib,
|
|
328
336
|
mdebug=&mdebug
|
|
329
337
|
)
|
|
338
|
+
/* a job that did not complete carries the abort message in its result, so
|
|
339
|
+
* errmsg is filled from there rather than left blank */
|
|
340
|
+
%if "&outstatus" ne "0" %then %do;
|
|
341
|
+
%let abortmsg=;
|
|
342
|
+
data _null_;
|
|
343
|
+
length line $32767 msg $32767;
|
|
344
|
+
retain found 0;
|
|
345
|
+
set &outstatus(keep=state);
|
|
346
|
+
if state ne 'completed' then do;
|
|
347
|
+
infile &msgref end=eof lrecl=32767;
|
|
348
|
+
do while(not eof);
|
|
349
|
+
input;
|
|
350
|
+
if found=0 and index(_infile_,'"MSG"')>0 then do;
|
|
351
|
+
line=tranwrd(_infile_,'\"','"');
|
|
352
|
+
if prxmatch('/"MSG" *: *"(.*)"/',line) then do;
|
|
353
|
+
msg=prxchange('s/.*"MSG" *: *"(.*)".*/$1/',-1,line);
|
|
354
|
+
found=1;
|
|
355
|
+
end;
|
|
356
|
+
end;
|
|
357
|
+
end;
|
|
358
|
+
end;
|
|
359
|
+
if found then call symputx('abortmsg',msg,'l');
|
|
360
|
+
run;
|
|
361
|
+
%if %superq(abortmsg) ne %then %do;
|
|
362
|
+
data &outstatus;
|
|
363
|
+
modify &outstatus;
|
|
364
|
+
errmsg=symget('abortmsg');
|
|
365
|
+
replace;
|
|
366
|
+
end;
|
|
367
|
+
%end;
|
|
368
|
+
%end;
|
|
369
|
+
/* only a ref created here may be cleared */
|
|
370
|
+
%if %length(&clearmeref)>0 %then %do;
|
|
371
|
+
filename &msgref clear;
|
|
372
|
+
%end;
|
|
330
373
|
|
|
331
374
|
%end;
|
|
332
375
|
%else %if &platform=SASJS %then %do;
|
|
@@ -350,7 +393,8 @@ filename &webref "&webrefpath";
|
|
|
350
393
|
)
|
|
351
394
|
%if "&outstatus" ne "0" %then %do;
|
|
352
395
|
data &outstatus;
|
|
353
|
-
length state $20 uri $256 errmsg $
|
|
396
|
+
length state $20 uri $256 errmsg $32767 platform $10;
|
|
397
|
+
length line $32767;
|
|
354
398
|
retain state 'completed' uri '' errmsg '' platform 'SASJS' abortseen 0;
|
|
355
399
|
infile &respref end=eof lrecl=32767;
|
|
356
400
|
/* scan the whole response - the abort block is not always on the first
|
|
@@ -363,10 +407,15 @@ filename &webref "&webrefpath";
|
|
|
363
407
|
abortseen=1;
|
|
364
408
|
end;
|
|
365
409
|
if abortseen=1 and errmsg='' and index(_infile_,'"MSG"')>0 then do;
|
|
366
|
-
/*
|
|
367
|
-
*
|
|
368
|
-
|
|
369
|
-
|
|
410
|
+
/* a quote inside the message arrives escaped, and the capture below
|
|
411
|
+
* used to stop at it, returning the part before the first \" and
|
|
412
|
+
* dropping the rest. The escaped pairs are unescaped first, so the
|
|
413
|
+
* value is captured whole: the match is greedy and runs to the
|
|
414
|
+
* closing quote of the value rather than to the first quote after
|
|
415
|
+
* the field name. */
|
|
416
|
+
line=tranwrd(_infile_,'\"','"');
|
|
417
|
+
if prxmatch('/"MSG" *: *"(.*)"/',line) then
|
|
418
|
+
errmsg=prxchange('s/.*"MSG" *: *"(.*)".*/$1/',-1,line);
|
|
370
419
|
end;
|
|
371
420
|
end;
|
|
372
421
|
/* one row, whatever the response contained */
|