Proxy Log in PI: Convert BAPI Message to Proxy Message is SAP PI or when using ESR (Entreprise Service Repository) is helpful to provide the consumer of the proxy/ service important about the processing of the request (especially in Synchronous mode). In case of errors, the BAPI Return gives a business error message explaining the issue.
Table of Contents
Proxy Log Structure in XI
In order to be transferred to outside SAP system, you must convert theBAPIRET2 message to Proxy log format.
The Structure of SAP Proxy Log / Message in ESR is:
BusinessDocumetProcessingResultCode
Give the type of return of the whole call to proxy: Success, error or warning.
It is the equivalent for Message Type in BAPI Message.
The conversion for Message type in Proxy Message XI is:
Processing Code | SAP | XI |
Error | ?’E’ | ?’3′ |
Fatal | ?’X’ | ?’3′ |
Abort | ?’A’ | ?’3′ |
warning | ?’W’ | ?’2′ |
Info | ?’I’ | ?’1′ |
Success | ?’S’ | ?’1′ |
Note that Error, Fatal and Abort are converted to 3 (the highest level)
Warning is set to 2. Info and Success should be converted to the same level Processing Result Code in XI to 1.
MaximumLogItemSeverityCode
It is a calculated field: it represents the highest level of Processing Result Code on all Items in the log message.
The formula is: MAX (Log-item[]-SeverityCode )
The Format of MaximumLogItemSeverityCode is the same as BusinessDocumetProcessingResultCode ( 1, 2 and 3 for Error )
Proxy Log Item
Proxy log Item corresponds au a line in BAPI Message ( line of BAPIRET2 for exemple).
It describes the business message generated by the call of the proxy.
You can have multiple Items in the same Log.
The Proxy Log Item is composed by:
- TypeId : The message Class ? BAPIRET2-MESID
- SeverityCode: the type of message ? conversion of BAPIRET2-MESTYP
- Note: the text for the message ? BAPIRET2-Message suffixed by the message number.
Method to fill PI Proxy Log
In order to convert the BAPI return messages and fill the PI proxy Log, you can use the standard class CL_SAPPLCO_SC_PROCY_HELPER with the static metho FILL_LOG.
The input will be
- IT_RETURN : The BAPI Message: table of BAPIRET2
And the Ouput is:
- CS_LOG : the Log Structure for Proxy Message
CALL?METHOD?cl_sapplco_sc_proxy_helper=>fill_log EXPORTING it_return?=?gt_return CHANGING cs_log????=?gs_log.
As bonus:
Method to Retrieve Return Text
In order to retrieve a message text with 2 parameters for a Message Class and a message number you can call the standard BAPI : BALW_BAPIRETURN_GET2.
The type can have these values: ?A?, ?E?, ?X?,? ?W?, ?I? and ?S?.
CALL?FUNCTION?'BALW_BAPIRETURN_GET2' EXPORTING type???=?'S' cl?????=?'SD' number?=?'001' par1???=?lv_par1 par2???=?lv_par2 IMPORTING return?=?ls_bapiret2. APPEND??ls_bapiret2?TO?et_return.