9.4.5 adshjoberr command (reports an error to a job and job step)
Syntax
adshjoberr return-code
Description
An error can be reported from the specified job and job step error. Behavior of the command if the specified position is within the job step or outside the job step is as follows:
- If you specify the command within the job step:
-
The succeeding process of the job step normal block is not executed regardless of the onError attribute of the job step. Therefore, the command is executed if the job step error block is defined and the job step finishes with an error.
- If you specify the command outside the job step:
-
If the subsequent job step in which the run attribute is abnormal or always is defined, the command is executed and the job finishes with an error.
Arguments
- return-code ~ <integer>((0 to 255))
-
Define the return code to be reported to a job or job step.
Return codes
Return code |
Meaning |
---|---|
0 to 255 |
Termination with an error This command reports the return code specified for argument of the adshjoberr command to the job or job step. |
1 |
Termination with an error Fatal error occurred. |
200 |
Termination with an error Specification of the command line is wrong. |
Notes
-
If you execute the adshjoberr command as another process, an error might not be reported to the job and job step of the calling script. Do not execute the adshjoberr command as another process.
-
If you define and execute the adshjoberr command in the child job, an error is reported to the child job and the job step in the child job, Error is not reported to the job or job step of the calling child job.
-
If you execute the adshjoberr command within the action of the trap command, an error is reported to the job if the execution timing is outside the job step and an error is reported to the job step if the execution timing is within the job step.
-
If you define FUNCTION for the operand of the CMDRC_CMDGRP_CHECK parameter, the command in the function is outside the target of error check. Therefore, the adshjoberr command specified in the function does not report an error to the job and job step of the calling script. If you specify FUNCTION for the operand of the CMDRC_CMDGRP_CHECK parameter, do not define the adshjoberr command in the function.
-
You cannot define the adshjoberr command in an .env file or initialization script file.
Examples
If the file does not exist, forcibly terminate the job step with the return code 1.
- Job definition script
-
#-adsh_job J01 #-adsh_step_start S01 cmd1 if [[ ! -a /tmp/tempfile ]]; then echo "tempfile not found" adshjoberr 1 fi #-adsh_step_end
- Results
-
******** JOB CONTROLLER MESSAGE ******** 17:01:22 046276 KNAX0091-I J01 The job started. 17:01:22 046276 KNAX7901-I The job controller will wait for all asynchronous processes at the end of the job. 17:01:22 046276 KNAX7902-I The job controller will run in tty stdin mode. 17:01:22 046276 KNAX0092-I J01.S01 step started. 17:01:22 046276 KNAX6116-I Execution of the command ./cmd1 (line=4) finished successfully. exit status=0 execution time=0.001s CPU time=0.000s 17:01:22 046276 KNAX6112-I Execution of the command [[ (line=5) finished successfully. exit status=0 execution time=0.000s CPU time=0.000s 17:01:22 046276 KNAX6112-I Execution of the command echo (line=6) finished successfully. exit status=0 execution time=0.000s CPU time=0.000s 17:01:22 046276 KNAX6150-E An error was reported to "step". (exit status=1, line 7) 17:01:22 046276 KNAX6596-E J01.S01 step failed. exit status=1 execution time=0.002s CPU time=0.000s 17:01:22 046276 KNAX0101-E J01 An error occurred during execution of the job. 17:01:22 046276 KNAX0098-I J01 The job ended. exit status=1 execution time=0.004s CPU time=0.000s