Having SAS job exiting with code 8 is not the same as having batch file exiting with that exit code. In your case 24x7 runs the batch file and checks the exit code of the called process (which is exit code of "cmd.exe") not the exit code of child processes invoked fro mthe batch. Therfore if you don't make the batch file to "save" somewhere SAS exit code you cannot capture it in 24x7. To remedy that use the ERRORLEVEL variable in your batch file to detect SAS exit code and pass it back using an environment variable. You can add the following lines in your batch file after invoking SAS: ... run sas command here ... if NOT errorlevel 0 goto abort SAS_RET_CODE=0 exit :abort set SAS_RET_CODE=%errorlevel% Now, convert your program type job in 24x7 to a JAL script type job and paste the followng litle script Dim( process_id, number ) Dim( sas_success, boolean ) RunAndWait( "c:\prodexec\prodexec.bat", "", 0, process_id ) IsEqual( 0, @V"env:SAS_RET_CODE", sas_success ) If( sas_success, HANDLE_SUCCESS, HANDLE_FAILURE ) HANDLE_SUCCESS: //... code here what you want to do on success Exit HANDLE_FAILURE: //... code here what you want to do on failure, for example RaiseError "SAS process completed with exit code @V"env:SAS_RET_CODE"" Hope this helps. By the way, why do you need a batch file to run SAS, why not to run it directly? : Hi, : 1. I am trying to setup a SAS job as : a Program Type job. : 2. I used the NEW Job 24x7 dialog to setup my job: ( run program or document : file ) : 3. In the Command Line Text Box I specified: c:\prodexec\prodexec.bat comscat : smb test001 : The prodexec.bat batch file calls the SAS program : TEST001 and passes it several parameters. The batch : file allows me to start the SAS program with : minimal parameters as they are inside the batch file. : 4. In the Successful Exit Code text box, I specified: 0 ( Zero! ) : 5. I forced the SAS program to abort with a return : code of 8. : data _null_; : abort return 8; : run; : 6. I ran the job and looked at the job statistics : and the exit code was 0. : Questions: 1. Does the Successful exit code field not work? : 2. Can I not use the run Program option If I specify : a batch file in the command line? : 3. How can I capture the exit code from a SAS program : that is called from a batch file? : Thanks Vic : What am I doing wrings ca
|