Skip to Content

Intro
When we exchange data from ECC to PI by using an outbound abap proxy (client proxy), it could be interesting to get the Message ID (e.g E10A22C2D64615F1AA9C005056B30E73) generated by ECC. By this way, we can manage traceability, display this info in a log, and after that to be able to find easily the message in SXMB_MONI of ECC, and/or…

The solution is to use the method “Get_Protocol” of Abap Proxy with constant “MESSAGE_ID”.

Note: Under proxy Protocol, SAP provides other constants like:

  • • ASYNC_MESSAGING
    • ROUTING
    • ATTACHMENTS
    • XI_HEADER
    • WS_HEADER
    • PAYLOAD
    • MESSAGE_ID
    • SESSION
    • SEQUENCE
    • SAP_ADDRESSING
    • LUW_CONTROL

See more details in SAP help: SAP Help – PI 7.11 – Protocols ; SAP Help – PI 7.11 – Accessing the Message ID

Note: This blog does not treat on how to create/generate an abap proxy in ECC.

  

Example
In PI, I defined an asynchronous outbound Service Interface on which I changed its Operation name:

  • Service Interface = SI_SalesContract_OB
  • Operation name = SendContracts

After that, in ECC, I generated the following proxy (Tcode SPROXY):

  •  Proxy Class = ZPI_CO_SI_SALES_CONTRACT_OB
  •  Method = SEND_CONTRACTS

abap proxy

The standard SAP methods, plus mine (SEND_CONTRACTS) which corresponds to my Service Interface’s Operation (“SendContracts”) defined in PI.

 

Abap code
I assume that everybody know how to extract data from SAP tables… so here, I just give the part where we call our proxy method in order to send the collected data (e.g out_msg) to PI, and how to use the other method to get the generated message ID.

Note: as it’s an asynchronous message, we have only an output (request) and no input (response).

 

* Proxy for this interface    (GENERATED by Abap proxy activation)
DATA:
  lo_clientProxy  TYPE REF TO  ZPI_CO_SI_SALES_CONTRACT_OB, ” Proxy name ó Service Interface
  lo_method       TYPE string VALUE ‘SEND_CONTRACTS’,  ” Method ó Operation
  out_msg         TYPE ZPI_MT_SALES_CONTRACT,          ” Data è Message Type

DATA:
  lo_payload_protocol    TYPE REF TO if_wsprotocol_payload,
  lo_protocol_messageid  TYPE REF TO if_wsprotocol_message_id,
  lo_payload             TYPE REF TO if_ws_payload,  “cf. result of method “get_sent_request_payload”
  l_message_id           TYPE SXMSGUID,              “cf. result of method “get_message_id”
  l_xml_string           TYPE STRING.                “cf. result of method “get_xml_text”

 

 TRY.
    CREATE OBJECT lo_clientProxy.

 * Get Protocol Class of parameter: Message_ID

    lo_protocol_messageid ?= lo_clientProxy->get_protocol( if_wsprotocol=>message_id ).  ” or ( ‘IF_WSPROTOCOL_MESSAGE_ID’ )

*   Call our abap proxy to send data to PI…
    CALL METHOD lo_clientProxy->(lo_method)
        EXPORTING
          output = out_msg.
     COMMIT WORK.   ” Do not forget it

*    Use Protocol Methods to get the sent Message ID
     l_message_id  = lo_protocol_messageid->get_message_id( ).

  CATCH …


  ENDTRY.

 

 Tips

In ECC, the message is sent by using pipeline “SENDER”, so to have some details relating to this message (including its status), we can do a select in ECC table SXMSPMAST with this l_message_id and pip = “SENDER”.

See also function module “SXMB_GET_ICON_FOR_MSG_STAT” to retrieve the icon status.

 

Message life

 

In ECC – Log at the end of my abap program

ecc prog

 

In ECC – SXMB_MONI 

ecc moni

Note: Pipeline is “SENDER”.

 

In PI – SXMB_MONI

pi moni

Note: In PI, the MessageID is exactly the same than this one that we have in ECC !

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply