/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Macro's usage Note: When Having a lot of programs to run unattended, a polling process is a solution. There are three main steps: 1- start programs when all blocking conditions are solved 2- monitor the running programs. 3- when a block of jobs is ready, advanced then all to a next moment (calendar based) During the polling the log/output of this program will grow having the messages of what is going on. Make this polling program run in background process. --> use a sas batch program to start up: %xwr_start (wrapploc=....,wrdataloc=....) ; Notes: - _WRCode (fileref) Must have all code for this tools - _WRjbloc (libref) is the location for all control data during the polling. - A planned timed restart for fully unattended processing is to consider. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* * * xwr_start the polling process stepping through control phases * * * */ /* * * Filename _WRCode * * * */ /* * * wrapploc must be defined having the other WR code * * * */ /* * * There is no check programs are really present * * * */ /* * * Libname _XBjbloc * * * */ /* * * wrdataloc must be defiied having the data and monitor files controlled programs * * * */ /* * * jbloc is an alternative sublocations for support addtional versions / systems * * * */ /* * * The controldataset having all job and conditions defined must be there * * * */ /* * * Time parameters set are adjustable. * * * */ /* * * Idea isrunning programs having a duration of about 40 sec * * * */ %macro xwr_start (wrapploc=,wrdataloc=,jbloc=,jbdata=XWR_workcontrol,xbsleep=60,xbwaitmsg=10,xblatemsg=10,xbclndr=60) ; %local loopcond; %global batch_loop_RC batch_loop_msg ; %let batch_loop_RC=0 ; options lrecl=32767 linesize=max ; options nodate nonumber; %if ( not %sysfunc(fileexist(&wrdataloc/&jbloc) ) ) %then %do; %let batch_loop_RC=-4 ; %let batch_loop_msg= Error jbloc: &wrdataloc/&jbloc storage location data doesn't exist; %end; %else %do; libname _WRjbloc "&wrdataloc/&jbloc" ; %if ( not %sysfunc(exist(xb_jbloc.&jbdata) ) ) %then %do; %let batch_loop_RC=-4 ; %let batch_loop_msg= Error jbloc: xb_jbloc.&jbdata workcontrol dataset doesn't exist ; %end; %end; %if ( not %sysfunc(fileexist(&wrapploc) ) ) %then %do; %let batch_loop_RC=-4 ; %let batch_loop_msg= Error jbloc: &wrapploc storage location code doesn't exist; %end; %else %do; FILEname _WRCode "&wrapploc" ; %end; %if ( %sysfunc(fileexist(&wrdataloc/&jbloc/&jbdata._STOP) ) ) %then %do; data _null_ ; /* the stop condition is just a file with a special name, cleanup */ jbstprst="jbstprst"; rc=filename(jbstprst,"&wrdataloc/&jbloc/&jbdata._STOP"); rc=fdelete(jbstprst); rc=filename(jbstprst); run; %end; %if ( &batch_loop_RC ge 0 ) %then %do; %let xbstart_cntr=1; %do %while (&xbstart_cntr ge 1 & &sysrc=0 ) ; %include _WRCode(xwr_jbinit) ; %let temp = %sysfunc( sleep(20,1) ) ; %xbatch_jobstat(xbstart in polling loop sleep=&xbsleep no &xbstart_cntr , opt=pid ) ; %include _WRCode(xwr_jbstrun) ; %include _WRCode(xwr_jbclndr) ; %put %sysfunc( sleep(%eval(&xbsleep-20),1) ) wait some time .... ; %let xbstart_cntr=%eval(&xbstart_cntr +1 ); %if ( %sysfunc(fileexist(&wrdataloc/&jbloc/&jbdata._STOP) ) ) %then %let xbstart_cntr=0; %end; %end; %else %do; data _null_ ; /* every poll a write to the output of the time as marker */ file print ; put "WR status:&batch_loop_RC %sysfunc( putn( %sysfunc( datetime() ) , datetime. ) )"; put " &batch_loop_msg"; run; %end; libname _WRjbloc clear ; filename _WRCode clear ; %mend;