Sample Collection Guide > Setting End Status depending on the Report's Content

Setting End Status Depending on the Report's Content

Objective: The reportA report provides more detailed information about a task's execution or a component. of a jobAn Automation Engine object type for a process that runs on a target system. should be searched for particular contents with the end statusThis represents the condition of a task (such as active, blocked, generating). depending on the result of this search.

Objects used: Job

Script 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 (agentA program that enables the de-centralized execution of processes (such as deployments) on target systems (computers or business solutions) or a service that provides connectivity to a target system (such as for databases or middleware). An agent is also an object type in the Automation Engine. [Formerly called "Executor."] See also: host is active, loginAn Automation Engine object type that stores account credentials used by agents on target systems. 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.

Job

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 scriptA particular Automation Engine object type. functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… 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 statisticsThis is a list of a task's previous runs. record with MODIFY_STATE. You can also modify the return codeThe value that represents the result of tasks and script functions. 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.

 


Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support

Copyright © 2016 Automic Software GmbH