Knowledge Base > Automation Engine and Target Systems > SAP > Evaluating the Application Return Code of SAP Steps

Evaluating the Application Return Code of SAP Steps

A SAP jobAn Automation Engine object type for a process that runs on a target system. step can also have an applicationAn application is a software which helps a user to fulfill specific tasks. In the context of ARA see also: Application entity. return codeThe value that represents the result of tasks and script functions..

You can access it as described below:

Via a Script Element

R3_GET_APPLICATION_RC can be used to check the application return code of one or several job steps and cancel the AE job if required.

Via the Step List Report

This specific report type contains information about the steps plus the application return code. The return code can be read using the XML script elements.

Example:

:SET &xmlreport# = XML_OPEN(REPORT,,SSTP) 

! Reading the first element
:SET &job# = XML_GET_FIRST_CHILD(&xmlreport#)
:SET &name# = XML_GET_NODE_NAME(&job#)
:PRINT "First element: &name#"
! Reading the second element
:SET &childA subordinate task (such as a task that runs in a workflow).# = XML_GET_FIRST_CHILD(&step#)
! Reading the step's children
:WHILE &child# <> ""
:SET &name# = XML_GET_NODE_NAME(&child#)
! Reading the application return code
:IF &name# = "RC"
: SET &applrc# = XML_GET_NODE_TEXT(&child#)
: PRINT "Applicationreturncode: &applrc#"
:ENDIF
:SET &child# = XML_GET_NEXTSIBLING(&child#)
:ENDWHILE

:XML_CLOSE

Via the Report

Information about SAP job steps is logged in the job reportA report provides more detailed information about a task's execution or a component.. This report also informs about the application return code if you use the AE interface.

"Appl-RC n/a" is written to the job report if a step has no application return code.

Use 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 to read and further process application return codes.

In the following example, the ABAP ZZ_TEST_APPL_RC is called in a job once. Its application return code should be read.

! Select the line containing ABAP and the application return code.
:
SET &HND# = PREP_PROCESS_REPORT(,,REP,"*ZZ_TEST_APPL_RC*Appl-RC*")
:
PROCESS &HND#
:   
SET &ZEILE# = GET_PROCESS_LINE(&HND#)
!   Find the exact position in a line where the "Appl RC" starts.

:   
SET &POS_STR# = STR_FIND(&ZEILE#,"Appl-RC")
!   The application return code is located after 8 characters.

:   
SET &POS_ARC# = ADD(&POS_STR#,8)
!   Read the application return code.

:   
SET &ARC# = STR_CUT(&ZEILE#,&POS_ARC#)
!   Check if the step really supplies an application return code.

:   
IF &ARC# <> "n/a"
!      The read value is a string and must therefore be converted to a number.

:      
SET &ARC# = CINT(&ARC#)
!      Beyond this point there are any script statements which further process the application return code.

:      
PRINT &ARC#
:   
ENDIF
:
ENDPROCESS

The application return code is not available with the XBP interface.

 

 


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

Copyright © 2016 Automic Software GmbH