cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the XML message from Xi stored in XML format from a abap program.

Former Member
0 Kudos

Hi Gurus,

My requirement here is to read the data that will be coming from Xi from my custom abap program and updating 2 data base tables. The method is after the data mapping is done a class is generated in abap proxy in which a method is available. Inside the method i am writing the code for getting the Xi data stored as a payload message which can be seen in the transaction SXMB_MONI. My code is given below.

***begin code***

method ZII_PAYROLL_HEADER_IN~PAYROLL_HEADER_IN.

      • **** INSERT IMPLEMENTATION HERE **** ***

data: ln type i.

DATA: i_items TYPE TABLE OF ZPAYLOAD_WRAPPER_EMPLOYEE_REC3.

*DATA: wa_items type ZPAYLOAD_WRAPPER_EMPLOYEE_TAB5.

data: wa_items type ZPAYLOAD_WRAPPER_EMPLOYEE_REC3.

DATA:PERNR TYPE STRING.

*data: it_ZPAYLOAD_WRAPPER16 TYPE ZPAYLOAD_WRAPPER16.

I_ITEMS[] = INPUT-PAYLOAD_WRAPPER-BODY-XMLDOC-PAYROLL_PERIOD_OVERVIEW-EMPLOYEE_RECORD[].

*I_ITEMS = INPUT-payloadWrapper-Body-XMLDOC-PayrollPeriodOverview-EmployeeRecord.

describe table i_items[] lines ln.

endmethod.

**End code***

As per the logic the data stored in the XML message should be avaialble in INPUT-payloadWrapper-Body-XMLDOC-PayrollPeriodOverview-EmployeeRecord which i am assigning to a local internal table in the class.

But in my case there is no data coming in

INPUT-payloadWrapper-Body-XMLDOC-PayrollPeriodOverview-EmployeeRecord.

But i can see the data transffered from XI in the transaction SXMB_MONI->XML message->inbound message->payload.

Is there any way to read the data stored in the XML message in the transaction SXMB_MONI.

Also why the data is not coming in

INPUT-payloadWrapper-Body-XMLDOC-PayrollPeriodOverview-EmployeeRecord inside the class.

If there is any solution for this problem please post it.

Accepted Solutions (0)

Answers (1)

Answers (1)

udo_martens
Active Contributor
0 Kudos

Hi Sudharsan,

you should have the message values (seen in SXMB_MONI) inside your container INPUT. May be you access it wrong. It is a deep structure, where you need to loop if a part of the structure is a table. But you can debug with Stefans Blog:

[XI: Debug your inbound ABAP Proxy implementation|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/4098] [original link is broken] [original link is broken] [original link is broken];

Regards,

Udo

Former Member
0 Kudos

Hi Udo,

Thanks for your reply, but it i will elobrately explain the problem now.

The requirement here is, 2 files will be sent from XI to R/3 system. OPnce they have sent the files we are able to view them in SXMB_MONI transaction. In the transaction after selecting the XML message there is a option 'Inbound message' and under that 'payload' inside which the main document is there. If i double click on the main document the contents of the file is displayed and it can also be saved to local system. Now i want to access these contents from this message in my abap program.

So far what i have done is there is a message id for each XML message and this is stored in a table 'SXMSPMAST'. I am retereiving the message id from this table. Is there any method of retereivng the contents of the message belonging to that message id. There are two tables SXMSCLUP, SXMSCLUR containing the message id and clusters which they say contains the actual message. But how can i retereive the actual contents of the message from these tables too.

Is there any other way for reteriving the contents of the XML message.

Former Member
0 Kudos

You can use function module SXMB_GET_MESSAGE_PAYLOAD.

Code snippet:

DATA: ls_mast      TYPE sxmspmast,
      ls_msgkey    TYPE sxmsmkey,
      lv_bin_xml   TYPE xstring,
      lv_str_xml   TYPE string.

* select sxmspmast into ls_mast

* ....

  ls_msgkey-msgid  = ls_mast-msgguid.
  ls_msgkey-pid    = 'RECEIVER'.


  CALL FUNCTION 'SXMB_GET_MESSAGE_PAYLOAD'
    EXPORTING
      im_msgkey      = ls_msgkey
      im_archive     = ' '
      im_version     = ls_mast-vers
    IMPORTING
      ex_msg_bytes   = lv_bin_xml
    EXCEPTIONS
      not_authorized = 1
      no_message     = 2
      internal_error = 3
      no_payload     = 4
      OTHERS         = 5.

  IF sy-subrc EQ 0.
      lv_str_xml = cl_soap_moni_helper=>convert_xstring_to_string( xstring_in = lv_bin_xml ).
  ENDIF.

former_member229310
Active Participant
0 Kudos

Hello,

put a break point at server proxy and execute the interface from SPROXY. The debugger should stop at your method.

Also as per your method it looks like the data type should be

Header

Recordset

Field1

Field2

Filed3

CHeck the nested structure. It should have the data. Always try to define a Function module for server proxy so that change in the proxy data type would not affect your code much.