Vous êtes sur la page 1sur 2

options compress = no;

options noquotelenmax;
options mprint symbolgen mlogic;

/*Connecting To Metadata Server*/

options metapass="foxpro12" metaport=8561 metaprotocol=bridge


metarepository="Foundation"
metaserver="sat1lsmap013.ally.corp" metauser="sasadm@saspw";

/* Cleanup */
Libname trg "/aml_out/autoload/trigger";

data _null_;
call system ('rm /aml_out/autoload/trigger/*.*');
run;

%macro delete_done (ds=);


%if %sysfunc(exist(&ds)) %then %do;
proc datasets lib=trg;
delete &ds;
run;
%end;
%mend delete_done;

%delete_done(ds=ok_1);
%delete_done(ds=ok_2);
%delete_done(ds=ok_3);
%delete_done(ds=ok_4);

/* Code to check for Done files */


%global counter max;
%let counter=0;
%let max=120; /* minutes to check */
%macro done_check(ds=,msg=,msg2=);
%if %sysfunc(exist(&ds))=0 %then %do;
%do %until (%sysfunc(exist(&ds))=1 or (&counter+0 > &max+0));
*** Let SAS sleep for a minute ***;
data _null_;
put "Note: &msg failed or still running.Trigger of &msg2 will wait";
sleep_time=sleep(60,1);
run;
%let counter=%eval(&counter.+1);
%end;
%end;

*** Stop program if time out ***;


%if &counter+0 > &max+0 %then endsas;

data _null_;
put "Note: &msg completed and &msg2 to start";
run;
%mend done_check;
run;

/* Create a separate task for each AutoLoad Files */


systask command "'/aml_out/autoload/1_edap_to_va_compute.sh'" wait taskname =
EDAP_to_VA status = EDAP_to_VA;
%done_check(ds=trg.ok_1,msg=edap to va compute,msg2=autoload);
systask command "'/aml_out/autoload/2_autoload_va_compute_to_lasr.sh'" wait
taskname = VA_to_LASR status = VA_to_LASR;
%done_check(ds=trg.ok_2,msg=Autoload,msg2=cleanup metadata);
systask command "'/aml_out/autoload/3_clean_metadata.sh'" wait taskname =
Cleanup_Metadata status = Cleanup_Metadata;
%done_check(ds=trg.ok_3,msg=cleanup metadata,msg2=clean_autoloader_dropzones);
systask command "'/aml_out/autoload/4_clean_autoloader_dropzones.sh'" wait taskname
= Dropzone status = Dropzone;

/* Restore the QUOTELENMAX option */

options quotelenmax;

%PUT &EDAP_to_VA;
%PUT &VA_to_LASR;
%PUT &Cleanup_Metadata;
%PUT &Dropzone;

Vous aimerez peut-être aussi