Setting End Status Depending on the Report's Content

Objective: The report of a job should be searched for particular contents with the end status depending on the result of this search.

Objects used: Job

ScriptEigener Objekttyp in der Automation Engine elements used: :CLOSE_PROCESS, :ENDPROCESS, GET_PROCESS_LINE, :MODIFY_STATE, PREP_PROCESS_REPORT, :PRINT and :PROCESS


Example

It can occur in particular cases, that a job is processed in the AE system without any problems (agent is active, login data is correct ...). Although the job ends error-free, the purpose of the process can still not be met (e.g. error in the JCL). The Post-Process tab can here be used for reading the report and adjusting the end status accordingly.

JobVerarbeitung auf einem Zielsystem. Auch ein eigener Objekttyp in der Automation Engine.

In the following example, a job is used for transferring data by means of FTP. The Process tab contains the following line:

ftp -s:branch15.ftp

The ftp file "branch15.ftp" contains the commands for the files that are to be transferred. It can happen that one or more files are not found. In this case, the script function PREP_PROCESS_REPORT can be used to search for possible FTP error messages that are shown in the report.

The result of the script function PREP_PROCESS_REPORT consists of all report lines to which the specified filter applies. It is then evaluated line by line in a PROCESS loop. Get the content of a line with GET_PROCESS_LINE.

If no line is found in the report, there is no PROCESS loop.

If an error message is found in the report (such as "File not found"), you can react to it by specifying the status text which is to be shown in the detail window of the statistics record with MODIFY_STATE. You can also modify the return code of the job, which influences its end status.

Note that the number range for a job ending on the status ENDED_OK can be specified in the Runtime tab of the particular job.

Example:
Definition for ENDED_OK: Return code <= 0

:MODIFY_STATE RETCODE = 0

Job ends ENDED_OK

:MODIFY_STATE RETCODE = 5

Job ends ENDED_NOT_OK

The script for the whole procedure mentioned above is described below:

!Checking the report for one or more files that were to be transferred but not found.

!Searching for lines containing the text "File not found".

:
SET &hnd# = PREP_PROCESS_REPORT(,,REP, '*File not found*')

!Each retrieved line is written in the post-processing report.

:
PROCESS &hnd#
:  
SET &line# = GET_PROCESS_LINE(&hnd#)
:  
PRINT '&line#'
!Additionally, the end status of the job is modified.

:  
MODIFY_STATE RETCODE = 11
:  
MODIFY_STATE STATUS_TEXT = 'File(s) not found!'
:
ENDPROCESS

If not all files that are to be transferred are available, the following statistics record is displayed. The job ends "ENDED_NOT_OK - aborted with the return code 11.