PI/PO Payload message XML table

For this example I want to get the XML of PI/PO Payload, this information is storaged in the database in binary. There a few tables involved, I will show a direct way considering that i have already the id of the Payload wich is on the left side on XML Message folder (85CD290A93341FD09295EB983E9F4A13)

You can get it going to SXMSCLUR table passing the id message on MSGGUID field.

And easy way to get it is to using the FM SXMB_GET_MESSAGE_PAYLOAD, this FM recive the id of the XML and get it. Now you can conver it or use the file as you need, for example download using a BAPI, convert the XML into XML String or any other action, in the following example I show you how to get it and convert to string.

DATA: ls_msgkey   TYPE SXMSMKEY,
      lv_msgbytes TYPE XSTRING.

*DATA DE BAPI 2
DATA:  lv_xstring TYPE xstring,
       lt_xmlt    TYPE TABLE OF smum_xmltb,
       lt_bapret2 TYPE TABLE OF bapiret2.

*ls_msgkey-msgid = '85CD290A93341FD092959B36045187C3'.



ls_msgkey-msgid = '85CD290A93341FD09295EB983E9F4A13'.
ls_msgkey-pid = 'SENDER'.



CALL FUNCTION 'SXMB_GET_MESSAGE_PAYLOAD'
  EXPORTING
    im_msgkey            = ls_msgkey
*   IM_ARCHIVE           =
*   IM_VERSION           =
 IMPORTING
   EX_MSG_BYTES         = lv_msgbytes
 EXCEPTIONS
   NOT_AUTHORIZED       = 1
   NO_MESSAGE           = 2
   INTERNAL_ERROR       = 3
   NO_PAYLOAD           = 4
   OTHERS               = 5
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

****************************
data: lv_string TYPE string.

CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
  EXPORTING
    im_xstring        = lv_msgbytes
*   IM_ENCODING       = 'UTF-8'
 IMPORTING
   EX_STRING         = lv_string.
          .

**************************

  lv_xstring = lv_msgbytes.

 CALL FUNCTION 'SMUM_XML_PARSE'
      EXPORTING
        xml_input =  lv_xstring
      TABLES
        xml_table = lt_xmlt
        return    = lt_bapret2.
 BREAK-POINT.

Leave a Reply

Your email address will not be published. Required fields are marked *

Go up