/******************************************************************************
 * Programme : Test of the ms_triggerstp macro
 * Reference : TESTOFEC65
 * Source    : https://www.wearecas.eu/en/sampleCode/TESTOFEC65
 ******************************************************************************/

/* --- BLOC 1 --- */
filename stpcode1 temp;
data _null_;
  file stpcode1;
  put '%put hello world;';
  put '%put _all_;';
  put 'data _null_; file _webout1; put "triggerstp test 1";run;';
run;
filename stpcode2 temp;
/* ... creation stpcode2 ... */

/* --- BLOC 2 --- */
%let fname1=%mf_getuniquename();
%let fname2=%mf_getuniquename();

%ms_createfile(/sasjs/tests/&fname1..sas
  ,inref=stpcode1
  ,mdebug=1
)
%ms_createfile(/sasjs/tests/&fname2..sas
  ,inref=stpcode2
)

/* --- BLOC 3 --- */
%mp_assertscope(SNAPSHOT)
  %ms_triggerstp(/sasjs/tests/&fname1
    ,debug=131
    ,outds=work.mySessions
  )
  %ms_triggerstp(/sasjs/tests/&fname2
    ,outds=work.mySessions
  )
%mp_assertscope(COMPARE...)

/* --- BLOC 4 --- */
%mp_assert(iftrue=%str(%mf_existds(work.mySessions)=1)...)
%mp_assertdsobs(work.mySessions, test=EQUALS 2...)
%mp_assertcols(work.mySessions, cols=sessionid...)

/* --- BLOC 5 --- */
data _null_;
  retain contentCheck 1;
  set work.mySessions end=last;
  if missing(sessionID) then contentCheck = 0;
  if last then do;
    call symputx("contentCheck",contentCheck,"l");
  end;
run;

/* --- BLOC 6 --- */
%ms_deletefile(/sasjs/tests/&fname1..sas)
%ms_deletefile(/sasjs/tests/&fname2..sas)

