Errorlevel is an internal error code that is maintained by the JCL module. Normally the Errorlevel will be zero if all function calls have completed successfully. The sys_get_errorlevel function allows you to examine the current state of the Errorlevel variable.
The current Errorlevel.
This example shows how you might obtain the current Errorlevel while your job is running.
my $errlvl = sys_get_errorlevel(); log_info( "Errorlevel: $errlvl ); # or log_info( 'Errorlevel: ' . sys_get_errorlevel() );
Normally you should end all jobs with a call to this function so the operating system receives an indication of the job’s completion status.
sys_end(); exit sys_get_errorlevel();
It is good practice to end your job with a call to this function so the operating system can be notified of the job’s exit status. Notice the call to sys_end immediately prior to the call to sys_get_errorlevel. This is a best practice for JCL jobs.