Skip to Content

I recommend readers to go through the blog by Alessandro Guarneri The specified item was not found. before proceeding. These kinds of super monitors are often required in an integration landscape.Good news is that we can search messages based on the payload from SP15 via TREX in XI. Do we really need to wait until our servers are upgraded to SP15? Is there a way out to search without using RWB? I am very impatient. Is there any way to do it ASAP?

Yes. We can search the incoming or outgoing messages based on the payload.

Just give the XPATH and XVALUE for searching the messages based on payload as explained in Alessandro’s blog. Additionally we need to provide start and end dates to select the messages for avoiding performance overhead.

Usage

I don’t delve into the details for creating this report as any ABAP’er should be able to do it.
Sample Snapshots:
Inbound Message:
XML Format:
Inbound-XML Format
I need to search the inbound messages where the Age1 equals dsf10 within a week.
Input Parameters for the Report:
Input Parameters-Inbound
Outbound Message:
XML Format:
Outbound-XML Format
I need to search the inbound messages where the Flag equals dsf10 within a week.
Input Parameters for the Report:
Input Parameters-Outbound

Ahhhhhhhh! I am able to search the messages in XI based on payload content using this report and the blog is the result of a challenge by Alessandro who provoked me for writing this one here. I definitely need to thank him for that.

Point to Note: Report is tested in my system and it works excellently for me. It is just a prototype and whoever so using the report can customize and enhance it to address the specific needs of the project. Report can be tuned for its performance for better results.

To report this post you need to login first.

17 Comments

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

  1. Michal Krawczyk
    you’ve specified 7 days message search in your example how fast was it? did you test
    on real data (a few k a day at least?)
    maybe you can compare it with trex?

    >>>I definitely need to thank her for that.

    her?:)

    Regards,
    michal
    Regards,
    michal

    (0) 
      1. Former Member
        I make some changes for search a string into Payload
        REPORT  YBUSQUEDA.

        DATA persist TYPE REF TO cl_xms_persist.
        DATA xms_msg TYPE REF TO if_xms_message.
        DATA xmb_msg TYPE REF TO cl_xms_message_xmb.
        DATA content TYPE xstring.
        DATA content_string TYPE string.
        DATA :pid LIKE sxmspmast-pid.
        DATA vers LIKE sxmspmast-vers.
        DATA payload TYPE sxms_mmfpayloads.
        DATA wa_payload TYPE LINE OF sxms_mmfpayloads.
        DATA: ixmlfactory TYPE REF TO if_ixml,
                 iparser TYPE REF TO if_ixml_parser,
                 streamfactory TYPE REF TO if_ixml_stream_factory,
                 istream TYPE REF TO if_ixml_istream,
                 idocument TYPE REF TO if_ixml_document,
                 lv_xpath TYPE string,
                 root TYPE REF TO if_ixml_element,
                 el   TYPE REF TO if_ixml_element,
                 vl   TYPE string.
        DATA msg_tab1 TYPE sxmsmsgtab.
        DATA msg_tab TYPE sxmsmsgtab.
        DATA wa TYPE LINE OF sxmsmsgtab.
        DATA p_mesg LIKE sxmspmast-msgguid.
        DATA : range_tab  LIKE RANGE OF sxmspmast-msgguid,
        range_line LIKE LINE OF range_tab.

        ********Seleccion por tipo de informacion ******************

        PARAMETERS xpath TYPE text256 no-display.
        PARAMETERS: xvalue TYPE text256 obligatory.
        PARAMETERS :p_stdt TYPE sy-datum obligatory.
        parameters : p_htdt type sy-uzeit no-display.
        PARAMETERS :p_endt TYPE sy-datum obligatory.
        parameters : p_int type  INT4 no-display.
        SELECTION-SCREEN BEGIN OF LINE.
        SELECTION-SCREEN COMMENT (29) FOR FIELD oifname.
        PARAMETERS: oifname LIKE sxmsitf-itfnameo.
        SELECTION-SCREEN END OF LINE.
        SELECTION-SCREEN BEGIN OF LINE.
        SELECTION-SCREEN COMMENT (29) FOR FIELD oifns.
        PARAMETERS: oifns LIKE sxmsitf-itfnso.
        SELECTION-SCREEN END OF LINE.
        p_int = ‘200’.

        DATA : lt_pids  TYPE sxms_sel_options,
               ls_sxmspemas  TYPE sxmspemas_sr,
        lt_back_pids  TYPE sxms_tab_sxmspid,
        ls_back_pids  TYPE sxmspid,
        ls_pids  TYPE sxmsselopt.

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

        *************Traigo PipeLine Id’s************************************

        lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_back_pid ).
        LOOP AT lt_back_pids INTO ls_back_pids.
          ls_pids-sign = ‘E’.
          ls_pids-option = ‘EQ’.
          ls_pids-low  = ls_back_pids.
          APPEND ls_pids TO lt_pids.
        ENDLOOP.
        lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_pe_pid ).
        LOOP AT lt_back_pids INTO ls_back_pids.
          ls_pids-sign = ‘E’.
          ls_pids-option = ‘EQ’.
          ls_pids-low  = ls_back_pids.
          APPEND ls_pids TO lt_pids.
        ENDLOOP.
        *********************************************************************

        ls_sxmspemas-ob_ns           = oifns.
        ls_sxmspemas-ob_name         = oifname.

        break t52252.
        ********Busco los Id por los filtros ******************
        CALL FUNCTION ‘SXMB_SELECT_MESSAGES’
          EXPORTING
            im_exedate           = p_stdt
            im_exetime           = p_htdt
            im_exe2date          = p_endt
            im_pids              = lt_pids
            im_s_sender_receiver = ls_sxmspemas
            im_client            = sy-mandt
            im_number            = p_int
          IMPORTING
            ex_msgtab            = msg_tab1.
        ********************************************************************
        break t52252.
        *********Busco los Payload de los registros********************************
        LOOP AT msg_tab1 INTO wa.
          SELECT * FROM sxmspvers APPENDING CORRESPONDING FIELDS OF TABLE msg_tab
          WHERE msgguid = wa-msgguid.
        ENDLOOP.
        ***********************************************************************
        Check not msg_tab[] is initial.

        CREATE OBJECT persist.

        *********Traigo los Key de los registros seleccionados ***********************
        LOOP AT msg_tab INTO wa.

          CLEAR :content,p_mesg,pid,vers.
          CLEAR payload[].
          FREE xms_msg.
          FREE xmb_msg.

          p_mesg = wa-msgguid .
          pid = wa-pid.
          vers = wa-vers.

          CALL METHOD persist->read_msg_all
            EXPORTING
              im_msgguid = p_mesg
              im_pid     = pid
              im_version = vers
            IMPORTING
              ex_message = xms_msg.

          xms_msg->deleteheaderbyname(
                 nsuri  = if_xms_run_time_env=>co_nsuri
                 lcname = if_xms_run_time_env=>co_lcname ).

          xmb_msg ?= xms_msg.
          CALL METHOD xmb_msg->if_xms_message_xmb~get_main_payloads
            RECEIVING
              return = payload.

          READ TABLE payload INTO wa_payload INDEX 1.
        *Buscar informacion en Payloads
          CALL METHOD wa_payload-mainpayload->getbinarycontent
            RECEIVING
              return = content.

          data: ex_string TYPE STRING.

          CALL FUNCTION ‘ECATT_CONV_XSTRING_TO_STRING’
            EXPORTING
              im_xstring = content
            IMPORTING
              ex_string  = ex_string.

        *Valido si encontre el dato en el XML
          SEARCH ex_string FOR xvalue.
          if sy-subrc eq 0.
            range_line-sign   = ‘I’.
            range_line-option = ‘EQ’.
            range_line-low    = wa-msgguid.
            APPEND range_line TO range_tab.
          else.
            wa-gen_entry = ‘X’.
            MODIFY msg_tab FROM wa.
          endif.

        ENDLOOP.
        DELETE  msg_tab WHERE gen_entry = ‘X’.
        DESCRIBE TABLE msg_tab.
        check not msg_tab[] is initial.
        SUBMIT rsxmb_select_messages
                             WITH msgguid IN range_tab
                             WITH lines = sy-tfill
                             AND RETURN.

        (0) 
        1. Former Member
          I am using isabella function in order to search for payload with Interface and Namespace criteria to make the search efficient

          I am trying to see if any written the following functionality about resubmitting messages to IE with the payload.

          When the function retrieves all the MSGIDs, in the next screen gives me an option to select the messages and resubmit messages to IE (one by one) with out going through SXMB_MONI screen and gives a report at the end with the message count submitted to IE

          If anyone already done this kinda of report, please advice or the approach todo that

          Thanks

          (0) 
          1. Former Member
            *———————————————————————
            *ABAP Name : ZDOWNLOAD_XI_MSG
            *Created by : T52252
            *Created on : 10/12/2010
            *Version :
            *Description: Export de Payloads al Unix
            *———————————————————————
            *Modification Log:
            *Date Programmer Correction Description
            *
            *
            *———————————————————————
            REPORT ZDOWNLOAD_XI_MSG_SEARCH.

            *Declaracion de Variables y Tablas
            data: l_backuphora like sy-uzeit.
            data: l_backupfecha like sy-datum.
            data: l_marcaok(1) type c.
            DATA persist TYPE REF TO cl_xms_persist.
            DATA xms_msg TYPE REF TO if_xms_message.
            DATA xmb_msg TYPE REF TO cl_xms_message_xmb.
            DATA content TYPE xstring.
            DATA content_res TYPE xstring.
            DATA content_string TYPE string.
            DATA :pid LIKE sxmspmast-pid.
            DATA vers LIKE sxmspmast-vers.
            DATA payload TYPE sxms_mmfpayloads.
            DATA wa_payload TYPE LINE OF sxms_mmfpayloads.
            DATA: ixmlfactory TYPE REF TO if_ixml,
            iparser TYPE REF TO if_ixml_parser,
            streamfactory TYPE REF TO if_ixml_stream_factory,
            istream TYPE REF TO if_ixml_istream,
            idocument TYPE REF TO if_ixml_document,
            lv_xpath TYPE string,
            root TYPE REF TO if_ixml_element,
            el TYPE REF TO if_ixml_element,
            vl TYPE string.
            DATA msg_tab1 TYPE sxmsmsgtab.
            DATA msg_tab TYPE sxmsmsgtab.
            DATA wa TYPE LINE OF sxmsmsgtab.
            DATA p_mesg LIKE sxmspmast-msgguid.
            DATA : range_tab LIKE RANGE OF sxmspmast-msgguid,
            range_line LIKE LINE OF range_tab.

            ********************************************************************
            data: ex_string TYPE STRING.
            DATA : lt_pids TYPE sxms_sel_options,
            ls_sxmspemas TYPE sxmspemas_sr,
            lt_back_pids TYPE sxms_tab_sxmspid,
            ls_back_pids TYPE sxmspid,
            ls_pids TYPE sxmsselopt.
            DATA: gt_verstab TYPE sxmsvtab.
            DATA: gt_master TYPE sxmsmsgtab.
            DATA: persist_adm TYPE REF TO cl_xms_persist_adm.
            DATA: WA_MASTER TYPE SXMSMSGLST.
            DATA: WA_TABLE TYPE SXMSMSGLST.
            DATA: WA_RES TYPE SXMSVLST.
            DATA: L_SERV(3) TYPE C.
            DATA:
            gv_msgguid_orig TYPE sxmsmguid,
            lt_msglist TYPE sxmsmsglst_sorted_tab,
            t_msgxire TYPE sxmsmsglst_sorted_tab.

            data: wa_msgxire type SXMSMSGLST_SORTED.

            data: l_c(20) type c.
            data: l_t(6) type c.

            DATA: T_RESULT_xml TYPE TABLE OF STRING.

            data: begin of t_data_down occurs 0,
            string type string,
            end of t_data_down.
            data: begin of w_data_down,
            string type string,
            end of w_data_down.

            * This method of file download with check uses the latest techniques
            * and achieves a very neat solution
            DATA: ld_filename TYPE string,
            ld_path TYPE string,
            ld_fullpath TYPE string,
            ld_result TYPE i.

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

            ********Seleccion por tipo de informacion ******************

            PARAMETERS xpath TYPE text256 no-display .
            PARAMETERS: xvalue TYPE text256 .
            PARAMETERS :p_stdt TYPE sy-datum obligatory default sy-datum.
            parameters : p_htdt type sy-uzeit.
            PARAMETERS :p_endt TYPE sy-datum obligatory default sy-datum.
            parameters : p_etdt type sy-uzeit default ‘235959’.
            parameters : p_int type INT4 no-display .
            selection-screen begin of block 0 with frame title text-000.
            PARAMETERS: oifname LIKE sxmsitf-itfnameo.
            PARAMETERS: oifns LIKE sxmsitf-itfnso.
            PARAMETERS: sservice type SXIMONI_SERVICE.
            selection-screen end of block 0.
            selection-screen begin of block 1 with frame title text-001.
            PARAMETERS: iifname LIKE sxmsitf-itfnamei.
            PARAMETERS: iifns LIKE sxmsitf-itfnsi.
            PARAMETERS: rservice type SXIMONI_SERVICE.
            selection-screen end of block 1.
            parameters: v_path like rlgrap-filename default ‘/TMP’ NO-DISPLAY.
            Parameters:
            p_check as checkbox default ‘X’ user-command comm,
            p_const as checkbox default ‘X’ user-command comm.

            *Backup de hora de proceso
            l_backuphora = sy-uzeit.
            l_backupfecha = sy-datum.

            if p_check = ‘X’.
            * Display save dialog window
            CALL METHOD cl_gui_frontend_services=>file_save_dialog
            EXPORTING
            * window_title = ‘ ‘
            DEFAULT_EXTENSION = ”
            default_file_name = ‘Playload’
            INITIAL_DIRECTORY = ‘D:\Documents and Settings\All Users’
            CHANGING
            filename = ld_filename
            path = ld_path
            fullpath = ld_fullpath
            user_action = ld_result.

            endif.
            p_int = ‘20000’.

            L_SERV = sy-SYSID.

            *v_path = wa_log_payload-PATH.

            data: l_id(32) type c.
            data: l_path like rlgrap-filename.
            ***********************************************************************

            *************Traigo PipeLine Id’s************************************

            lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_back_pid ).
            LOOP AT lt_back_pids INTO ls_back_pids.
            ls_pids-sign = ‘E’.
            ls_pids-option = ‘EQ’.
            ls_pids-low = ls_back_pids.
            APPEND ls_pids TO lt_pids.
            ENDLOOP.
            lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_pe_pid ).
            LOOP AT lt_back_pids INTO ls_back_pids.
            ls_pids-sign = ‘E’.
            ls_pids-option = ‘EQ’.
            ls_pids-low = ls_back_pids.
            APPEND ls_pids TO lt_pids.
            ENDLOOP.
            *********************************************************************
            if not oifns is initial.
            ls_sxmspemas-ob_ns = oifns.
            ls_sxmspemas-ob_name = oifname.
            elseif not iifns is initial.
            ls_sxmspemas-IB_NS = iifns.
            ls_sxmspemas-IB_NAME = iifname.
            endif.

            if not sservice is initial.
            ls_sxmspemas-OB_SYSTEM = sservice .
            elseif not rservice is initial.
            ls_sxmspemas-IB_SYSTEM = rservice .
            endif.
            data:
            t_EX_RESULT TYPE SXMSADMINRESULT,
            t_EX_FIRST_TS TYPE TIMESTAMPL.
            ********Busco los Id por los filtros ******************
            CALL FUNCTION ‘SXMB_SELECT_MESSAGES’
            EXPORTING
            im_exedate = p_stdt
            im_exetime = p_htdt
            im_exe2date = p_endt
            IM_EXE2TIME = p_etdt
            im_pids = lt_pids
            im_s_sender_receiver = ls_sxmspemas
            im_client = sy-mandt
            im_number = p_int
            IMPORTING
            ex_msgtab = msg_tab1
            EX_RESULT = t_EX_RESULT
            EX_FIRST_TS = t_EX_FIRST_TS.

            FORMAT INTENSIFIED ON.
            ULINE /(95).
            WRITE: / sy-vline,
            ‘Back Up XML’,
            40 ‘Date’,
            sy-datum DD/MM/YYYY,
            60 ‘Time’,
            sy-uzeit,
            95 sy-vline.
            ULINE /(95).
            if msg_tab1[] is initial.
            WRITE :/ ‘No existen registros para el rango indicado de fechas’ color 6.
            WRITE :/ p_stdt color 6, p_htdt color 6, p_endt color 6, p_etdt color 6.
            endif.

            *BUSCO TODOS LOS ID DEL LOS MENSAJES RELACIONADOS
            *RESPONSE RESPECTIVO PARA CADA MSG
            LOOP AT msg_tab1 INTO wa.
            gv_msgguid_orig = wa-msgguid.
            lt_msglist = cl_xms_persist=>read_nested_msg( im_msgguid = gv_msgguid_orig ).

            loop at lt_msglist into wa_msgxire.
            append wa_msgxire to t_msgxire.
            endloop.
            REFRESH lt_msglist.
            endloop.

            CREATE OBJECT persist_adm.
            data: v_fecha(40) type c.

            *********Busco los Payload de los registros********************************

            LOOP AT msg_tab1 INTO wa.
            * SELECT * FROM sxmspvers APPENDING CORRESPONDING FIELDS OF TABLE msg_tab
            * WHERE msgguid = wa-msgguid.

            TRY.
            CALL METHOD cl_xms_persist_adm=>find_msg_dynamic
            EXPORTING
            im_msgguid = wa-msgguid
            IMPORTING
            ex_msgtab = gt_master.

            CALL METHOD persist_adm->read_all_msg_vers_pub
            EXPORTING
            im_msgguid = wa-msgguid
            IMPORTING
            ex_verstab = gt_verstab.

            ENDTRY.

            LOOP AT gt_master INTO wa.
            CLEAR WA_TABLE.
            MOVE-CORRESPONDING wa TO WA_TABLE .
            APPEND WA_TABLE TO msg_taB.
            ENDLOOP.

            * SELECT * FROM SXMSPMAST APPENDING CORRESPONDING FIELDS OF TABLE msg_tab
            *WHERE msgguid = wa-msgguid.

            ENDLOOP.

            ***********************************************************************
            Check not msg_tab[] is initial.

            CREATE OBJECT persist.

            *********Traigo los Key de los registros seleccionados ***********************

            DELETE msg_tab WHERE gen_entry = ‘X’.

            REFRESH msg_taB.

            *********Traigo los Key de los registros seleccionados ***********************

            LOOP AT t_msgxire INTO wa_msgxire.
            CLEAR payload[].
            FREE xms_msg.
            FREE xmb_msg.

            p_mesg = wa_msgxire-msgguid .
            pid = wa_msgxire-pid.
            vers = ‘000’.

            CALL METHOD persist->read_msg_all
            EXPORTING
            im_msgguid = p_mesg
            im_pid = pid
            im_version = vers
            IMPORTING
            ex_message = xms_msg.

            xms_msg->deleteheaderbyname(
            nsuri = if_xms_run_time_env=>co_nsuri
            lcname = if_xms_run_time_env=>co_lcname ).

            xmb_msg ?= xms_msg.
            CALL METHOD xmb_msg->if_xms_message_xmb~get_main_payloads
            RECEIVING
            return = payload.
            if not payload[] is initial.
            READ TABLE payload INTO wa_payload INDEX 1.
            refresh payload .
            *Buscar informacion en Payloads
            CALL METHOD wa_payload-mainpayload->getbinarycontent
            RECEIVING
            return = content.

            CALL FUNCTION ‘ECATT_CONV_XSTRING_TO_STRING’
            EXPORTING
            im_xstring = content
            IMPORTING
            ex_string = ex_string.

            *Valido si encontre el dato en el XML
            SEARCH ex_string FOR xvalue.
            if sy-subrc eq 0.
            range_line-sign = ‘I’.
            range_line-option = ‘EQ’.
            range_line-low = wa-msgguid.
            APPEND range_line TO range_tab.
            else.
            wa-gen_entry = ‘X’.
            MODIFY msg_tab FROM wa.
            endif.

            *El ex_string se puede usar de filtro

            *El ex_string se puede usar de filtro
            break t52252.
            refresh T_RESULT_xml.
            APPEND ex_string TO T_RESULT_xml.

            *guardo los msg de responde en el unix.
            if vers = ‘006’.
            l_t = ‘input’.
            else.
            l_t = ‘output’.
            endif.

            v_fecha = wa_msgxire-EXETIMEST.

            condense v_fecha.

            concatenate
            ld_fullpath
            ‘_’
            v_fecha
            ‘_’
            l_t
            ‘.xml’
            into
            l_path.
            condense l_path.
            WRITE :/ l_path color 5.

            *HAGO EL DOWNLOAD DE LOS ARCHIVOS AL SERVER

            loop at T_RESULT_xml into ex_string.
            move ex_string to t_data_down-string.
            append t_data_down.

            endloop.
            ld_fullpath = l_path.

            CALL FUNCTION ‘GUI_DOWNLOAD’
            EXPORTING
            filename = ld_fullpath
            filetype = ‘ASC’
            * APPEND = ‘X’
            write_field_separator = ‘X’
            * CONFIRM_OVERWRITE = ‘X’
            TABLES
            data_tab = t_data_down[] “need to declare and populate
            EXCEPTIONS
            file_open_error = 1
            file_write_error = 2
            OTHERS = 3.
            refresh : t_data_down.

            if sy-subrc <> 0.
            WRITE :/ ‘Error Download’ color 6.
            l_marcaok = ‘N’.
            else.
            WRITE :/ ‘Okay Download’ color 3.
            endif.

            refresh T_RESULT_xml.
            endif.
            ENDLOOP.
            *GUARDO UPDATE DE ULTIMA CORRIDA
            DELETE msg_tab WHERE gen_entry = ‘X’.
            IF l_marcaok IS INITIAL.
            * wa_log_payload-mandt = sy-mandt.
            * wa_log_payload-NAMEINTERF = oifname.
            * wa_log_payload-DLASTEXE = l_backupfecha.
            * wa_log_payload-TLASTEXE = l_backuphora.
            * modify zLOG_PAYLOAD from wa_log_payload.
            ENDIF.

            if p_const = ‘X’.
            DELETE msg_tab WHERE gen_entry = ‘X’.
            DESCRIBE TABLE msg_tab.
            check not msg_tab[] is initial.

            SUBMIT rsxmb_select_messages
            WITH msgguid IN range_tab
            WITH lines = sy-tfill
            AND RETURN.
            ENDIF.

            (0) 
        2. Former Member
          New Search in Msg Input Output and download the msg in PC
          *———————————————————————
          *ABAP Name : ZDOWNLOAD_XI_MSG
          *Created by : T52252
          *Created on : 10/12/2010
          *Version :
          *Description: Export de Payloads al Unix
          *———————————————————————
          *Modification Log:
          *Date Programmer Correction Description
          *
          *
          *———————————————————————
          REPORT ZDOWNLOAD_XI_MSG_SEARCH.

          *Declaracion de Variables y Tablas
          data: l_backuphora like sy-uzeit.
          data: l_backupfecha like sy-datum.
          data: l_marcaok(1) type c.
          DATA persist TYPE REF TO cl_xms_persist.
          DATA xms_msg TYPE REF TO if_xms_message.
          DATA xmb_msg TYPE REF TO cl_xms_message_xmb.
          DATA content TYPE xstring.
          DATA content_res TYPE xstring.
          DATA content_string TYPE string.
          DATA :pid LIKE sxmspmast-pid.
          DATA vers LIKE sxmspmast-vers.
          DATA payload TYPE sxms_mmfpayloads.
          DATA wa_payload TYPE LINE OF sxms_mmfpayloads.
          DATA: ixmlfactory TYPE REF TO if_ixml,
          iparser TYPE REF TO if_ixml_parser,
          streamfactory TYPE REF TO if_ixml_stream_factory,
          istream TYPE REF TO if_ixml_istream,
          idocument TYPE REF TO if_ixml_document,
          lv_xpath TYPE string,
          root TYPE REF TO if_ixml_element,
          el TYPE REF TO if_ixml_element,
          vl TYPE string.
          DATA msg_tab1 TYPE sxmsmsgtab.
          DATA msg_tab TYPE sxmsmsgtab.
          DATA wa TYPE LINE OF sxmsmsgtab.
          DATA p_mesg LIKE sxmspmast-msgguid.
          DATA : range_tab LIKE RANGE OF sxmspmast-msgguid,
          range_line LIKE LINE OF range_tab.

          ********************************************************************
          data: ex_string TYPE STRING.
          DATA : lt_pids TYPE sxms_sel_options,
          ls_sxmspemas TYPE sxmspemas_sr,
          lt_back_pids TYPE sxms_tab_sxmspid,
          ls_back_pids TYPE sxmspid,
          ls_pids TYPE sxmsselopt.
          DATA: gt_verstab TYPE sxmsvtab.
          DATA: gt_master TYPE sxmsmsgtab.
          DATA: persist_adm TYPE REF TO cl_xms_persist_adm.
          DATA: WA_MASTER TYPE SXMSMSGLST.
          DATA: WA_TABLE TYPE SXMSMSGLST.
          DATA: WA_RES TYPE SXMSVLST.
          DATA: L_SERV(3) TYPE C.
          DATA:
          gv_msgguid_orig TYPE sxmsmguid,
          lt_msglist TYPE sxmsmsglst_sorted_tab,
          t_msgxire TYPE sxmsmsglst_sorted_tab.

          data: wa_msgxire type SXMSMSGLST_SORTED.

          data: l_c(20) type c.
          data: l_t(6) type c.

          DATA: T_RESULT_xml TYPE TABLE OF STRING.

          data: begin of t_data_down occurs 0,
          string type string,
          end of t_data_down.
          data: begin of w_data_down,
          string type string,
          end of w_data_down.

          * This method of file download with check uses the latest techniques
          * and achieves a very neat solution
          DATA: ld_filename TYPE string,
          ld_path TYPE string,
          ld_fullpath TYPE string,
          ld_result TYPE i.

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

          ********Seleccion por tipo de informacion ******************

          PARAMETERS xpath TYPE text256 no-display .
          PARAMETERS: xvalue TYPE text256 .
          PARAMETERS :p_stdt TYPE sy-datum obligatory default sy-datum.
          parameters : p_htdt type sy-uzeit.
          PARAMETERS :p_endt TYPE sy-datum obligatory default sy-datum.
          parameters : p_etdt type sy-uzeit default ‘235959’.
          parameters : p_int type INT4 no-display .
          selection-screen begin of block 0 with frame title text-000.
          PARAMETERS: oifname LIKE sxmsitf-itfnameo.
          PARAMETERS: oifns LIKE sxmsitf-itfnso.
          PARAMETERS: sservice type SXIMONI_SERVICE.
          selection-screen end of block 0.
          selection-screen begin of block 1 with frame title text-001.
          PARAMETERS: iifname LIKE sxmsitf-itfnamei.
          PARAMETERS: iifns LIKE sxmsitf-itfnsi.
          PARAMETERS: rservice type SXIMONI_SERVICE.
          selection-screen end of block 1.
          parameters: v_path like rlgrap-filename default ‘/TMP’ NO-DISPLAY.
          Parameters:
          p_check as checkbox default ‘X’ user-command comm,
          p_const as checkbox default ‘X’ user-command comm.

          *Backup de hora de proceso
          l_backuphora = sy-uzeit.
          l_backupfecha = sy-datum.

          if p_check = ‘X’.
          * Display save dialog window
          CALL METHOD cl_gui_frontend_services=>file_save_dialog
          EXPORTING
          * window_title = ‘ ‘
          DEFAULT_EXTENSION = ”
          default_file_name = ‘Playload’
          INITIAL_DIRECTORY = ‘D:\Documents and Settings\All Users’
          CHANGING
          filename = ld_filename
          path = ld_path
          fullpath = ld_fullpath
          user_action = ld_result.

          endif.
          p_int = ‘20000’.

          L_SERV = sy-SYSID.

          *v_path = wa_log_payload-PATH.

          data: l_id(32) type c.
          data: l_path like rlgrap-filename.
          ***********************************************************************

          *************Traigo PipeLine Id’s************************************

          lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_back_pid ).
          LOOP AT lt_back_pids INTO ls_back_pids.
          ls_pids-sign = ‘E’.
          ls_pids-option = ‘EQ’.
          ls_pids-low = ls_back_pids.
          APPEND ls_pids TO lt_pids.
          ENDLOOP.
          lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_pe_pid ).
          LOOP AT lt_back_pids INTO ls_back_pids.
          ls_pids-sign = ‘E’.
          ls_pids-option = ‘EQ’.
          ls_pids-low = ls_back_pids.
          APPEND ls_pids TO lt_pids.
          ENDLOOP.
          *********************************************************************
          if not oifns is initial.
          ls_sxmspemas-ob_ns = oifns.
          ls_sxmspemas-ob_name = oifname.
          elseif not iifns is initial.
          ls_sxmspemas-IB_NS = iifns.
          ls_sxmspemas-IB_NAME = iifname.
          endif.

          if not sservice is initial.
          ls_sxmspemas-OB_SYSTEM = sservice .
          elseif not rservice is initial.
          ls_sxmspemas-IB_SYSTEM = rservice .
          endif.
          data:
          t_EX_RESULT TYPE SXMSADMINRESULT,
          t_EX_FIRST_TS TYPE TIMESTAMPL.
          ********Busco los Id por los filtros ******************
          CALL FUNCTION ‘SXMB_SELECT_MESSAGES’
          EXPORTING
          im_exedate = p_stdt
          im_exetime = p_htdt
          im_exe2date = p_endt
          IM_EXE2TIME = p_etdt
          im_pids = lt_pids
          im_s_sender_receiver = ls_sxmspemas
          im_client = sy-mandt
          im_number = p_int
          IMPORTING
          ex_msgtab = msg_tab1
          EX_RESULT = t_EX_RESULT
          EX_FIRST_TS = t_EX_FIRST_TS.

          FORMAT INTENSIFIED ON.
          ULINE /(95).
          WRITE: / sy-vline,
          ‘Back Up XML’,
          40 ‘Date’,
          sy-datum DD/MM/YYYY,
          60 ‘Time’,
          sy-uzeit,
          95 sy-vline.
          ULINE /(95).
          if msg_tab1[] is initial.
          WRITE :/ ‘No existen registros para el rango indicado de fechas’ color 6.
          WRITE :/ p_stdt color 6, p_htdt color 6, p_endt color 6, p_etdt color 6.
          endif.

          *BUSCO TODOS LOS ID DEL LOS MENSAJES RELACIONADOS
          *RESPONSE RESPECTIVO PARA CADA MSG
          LOOP AT msg_tab1 INTO wa.
          gv_msgguid_orig = wa-msgguid.
          lt_msglist = cl_xms_persist=>read_nested_msg( im_msgguid = gv_msgguid_orig ).

          loop at lt_msglist into wa_msgxire.
          append wa_msgxire to t_msgxire.
          endloop.
          REFRESH lt_msglist.
          endloop.

          CREATE OBJECT persist_adm.
          data: v_fecha(40) type c.

          *********Busco los Payload de los registros********************************

          LOOP AT msg_tab1 INTO wa.
          * SELECT * FROM sxmspvers APPENDING CORRESPONDING FIELDS OF TABLE msg_tab
          * WHERE msgguid = wa-msgguid.

          TRY.
          CALL METHOD cl_xms_persist_adm=>find_msg_dynamic
          EXPORTING
          im_msgguid = wa-msgguid
          IMPORTING
          ex_msgtab = gt_master.

          CALL METHOD persist_adm->read_all_msg_vers_pub
          EXPORTING
          im_msgguid = wa-msgguid
          IMPORTING
          ex_verstab = gt_verstab.

          ENDTRY.

          LOOP AT gt_master INTO wa.
          CLEAR WA_TABLE.
          MOVE-CORRESPONDING wa TO WA_TABLE .
          APPEND WA_TABLE TO msg_taB.
          ENDLOOP.

          * SELECT * FROM SXMSPMAST APPENDING CORRESPONDING FIELDS OF TABLE msg_tab
          *WHERE msgguid = wa-msgguid.

          ENDLOOP.

          ***********************************************************************
          Check not msg_tab[] is initial.

          CREATE OBJECT persist.

          *********Traigo los Key de los registros seleccionados ***********************

          DELETE msg_tab WHERE gen_entry = ‘X’.

          REFRESH msg_taB.

          *********Traigo los Key de los registros seleccionados ***********************

          LOOP AT t_msgxire INTO wa_msgxire.
          CLEAR payload[].
          FREE xms_msg.
          FREE xmb_msg.

          p_mesg = wa_msgxire-msgguid .
          pid = wa_msgxire-pid.
          vers = ‘000’.

          CALL METHOD persist->read_msg_all
          EXPORTING
          im_msgguid = p_mesg
          im_pid = pid
          im_version = vers
          IMPORTING
          ex_message = xms_msg.

          xms_msg->deleteheaderbyname(
          nsuri = if_xms_run_time_env=>co_nsuri
          lcname = if_xms_run_time_env=>co_lcname ).

          xmb_msg ?= xms_msg.
          CALL METHOD xmb_msg->if_xms_message_xmb~get_main_payloads
          RECEIVING
          return = payload.
          if not payload[] is initial.
          READ TABLE payload INTO wa_payload INDEX 1.
          refresh payload .
          *Buscar informacion en Payloads
          CALL METHOD wa_payload-mainpayload->getbinarycontent
          RECEIVING
          return = content.

          CALL FUNCTION ‘ECATT_CONV_XSTRING_TO_STRING’
          EXPORTING
          im_xstring = content
          IMPORTING
          ex_string = ex_string.

          *Valido si encontre el dato en el XML
          SEARCH ex_string FOR xvalue.
          if sy-subrc eq 0.
          range_line-sign = ‘I’.
          range_line-option = ‘EQ’.
          range_line-low = wa-msgguid.
          APPEND range_line TO range_tab.
          else.
          wa-gen_entry = ‘X’.
          MODIFY msg_tab FROM wa.
          endif.

          *El ex_string se puede usar de filtro

          *El ex_string se puede usar de filtro
          break t52252.
          refresh T_RESULT_xml.
          APPEND ex_string TO T_RESULT_xml.

          *guardo los msg de responde en el unix.
          if vers = ‘006’.
          l_t = ‘input’.
          else.
          l_t = ‘output’.
          endif.

          v_fecha = wa_msgxire-EXETIMEST.

          condense v_fecha.

          concatenate
          ld_fullpath
          ‘_’
          v_fecha
          ‘_’
          l_t
          ‘.xml’
          into
          l_path.
          condense l_path.
          WRITE :/ l_path color 5.

          *HAGO EL DOWNLOAD DE LOS ARCHIVOS AL SERVER

          loop at T_RESULT_xml into ex_string.
          move ex_string to t_data_down-string.
          append t_data_down.

          endloop.
          ld_fullpath = l_path.

          CALL FUNCTION ‘GUI_DOWNLOAD’
          EXPORTING
          filename = ld_fullpath
          filetype = ‘ASC’
          * APPEND = ‘X’
          write_field_separator = ‘X’
          * CONFIRM_OVERWRITE = ‘X’
          TABLES
          data_tab = t_data_down[] “need to declare and populate
          EXCEPTIONS
          file_open_error = 1
          file_write_error = 2
          OTHERS = 3.
          refresh : t_data_down.

          if sy-subrc <> 0.
          WRITE :/ ‘Error Download’ color 6.
          l_marcaok = ‘N’.
          else.
          WRITE :/ ‘Okay Download’ color 3.
          endif.

          refresh T_RESULT_xml.
          endif.
          ENDLOOP.
          *GUARDO UPDATE DE ULTIMA CORRIDA
          DELETE msg_tab WHERE gen_entry = ‘X’.
          IF l_marcaok IS INITIAL.
          * wa_log_payload-mandt = sy-mandt.
          * wa_log_payload-NAMEINTERF = oifname.
          * wa_log_payload-DLASTEXE = l_backupfecha.
          * wa_log_payload-TLASTEXE = l_backuphora.
          * modify zLOG_PAYLOAD from wa_log_payload.
          ENDIF.

          if p_const = ‘X’.
          DELETE msg_tab WHERE gen_entry = ‘X’.
          DESCRIBE TABLE msg_tab.
          check not msg_tab[] is initial.

          SUBMIT rsxmb_select_messages
          WITH msgguid IN range_tab
          WITH lines = sy-tfill
          AND RETURN.
          ENDIF.

          (0) 
    1. Former Member Post author
      You are faster than a spark..:)
      I tested it for 1300 messages and it took me around 3 min…
      We can definetly tune the report for better performance..It is just one more way if you cannot wait till the server gets upgraded..:)
      Yeah..I can compare it ..if I have SP15..

      Oh..Is it him?I will change it..

      (0) 
  2. Former Member
    Hi Sravya,
    actually the challenge was a bit more sophisticated, and it’s something I’m currently workin’ on with the great help of a colleague: input help for XPath based on message type, very similar to IB expression editor… ๐Ÿ™‚
    This is really tricky.

    Take care,
    Alex

    P.S. Nice job.

    (0) 
  3. Sravya
           I picked up this weblog and tried to upload your program into XI 3.0 SP 13. Unfortunately, I get a syntax error – ‘Type SXMS_MMFPAYLOADS is unknown’ I searched for this data type in SE11 and could not find it – any limitations on whether this Z* program would not work on any SPs of XI ?

    Thank you for your time.

    (0) 
    1. Former Member Post author
      Hey ..

      Sorry for the late response as I have not checked it .

      You can change the code slightly by adding the following for > SP12:

      DATA payload TYPE ref to IF_XMS_PAYLOAD.
      CALL METHOD xmb_msg->if_xms_message_xmb~get_payload_with_main_document
          RECEIVING
            return = payload.
        CALL METHOD payload->getbinarycontent
          RECEIVING
            return = content.
      instead of
      DATA payload TYPE sxms_mmfpayloads.
      DATA wa_payload TYPE LINE OF sxms_mmfpayloads.
      CALL METHOD xmb_msg->if_xms_message_xmb~get_main_payloads
          RECEIVING
            return = payload.

        READ TABLE payload INTO wa_payload INDEX 1.

        CALL METHOD wa_payload-mainpayload->getbinarycontent
          RECEIVING
            return = content.

      (0) 
  4. Folks
            Have anyone of you tried Sravya’s code on XI 3.0 SP 13 – I am getting a syntax error and not able to use this utility…the details of the error are given below….
    (0) 
  5. Former Member
    i make some change for search into xml playload
    REPORT  YBUSQUEDA.

    DATA persist TYPE REF TO cl_xms_persist.
    DATA xms_msg TYPE REF TO if_xms_message.
    DATA xmb_msg TYPE REF TO cl_xms_message_xmb.
    DATA content TYPE xstring.
    DATA content_string TYPE string.
    DATA :pid LIKE sxmspmast-pid.
    DATA vers LIKE sxmspmast-vers.
    DATA payload TYPE sxms_mmfpayloads.
    DATA wa_payload TYPE LINE OF sxms_mmfpayloads.
    DATA: ixmlfactory TYPE REF TO if_ixml,
             iparser TYPE REF TO if_ixml_parser,
             streamfactory TYPE REF TO if_ixml_stream_factory,
             istream TYPE REF TO if_ixml_istream,
             idocument TYPE REF TO if_ixml_document,
             lv_xpath TYPE string,
             root TYPE REF TO if_ixml_element,
             el   TYPE REF TO if_ixml_element,
             vl   TYPE string.
    DATA msg_tab1 TYPE sxmsmsgtab.
    DATA msg_tab TYPE sxmsmsgtab.
    DATA wa TYPE LINE OF sxmsmsgtab.
    DATA p_mesg LIKE sxmspmast-msgguid.
    DATA : range_tab  LIKE RANGE OF sxmspmast-msgguid,
    range_line LIKE LINE OF range_tab.

    ********Seleccion por tipo de informacion ******************

    PARAMETERS xpath TYPE text256 no-display.
    PARAMETERS: xvalue TYPE text256 obligatory.
    PARAMETERS :p_stdt TYPE sy-datum obligatory.
    parameters : p_htdt type sy-uzeit no-display.
    PARAMETERS :p_endt TYPE sy-datum obligatory.
    parameters : p_int type  INT4 no-display.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (29) FOR FIELD oifname.
    PARAMETERS: oifname LIKE sxmsitf-itfnameo.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (29) FOR FIELD oifns.
    PARAMETERS: oifns LIKE sxmsitf-itfnso.
    SELECTION-SCREEN END OF LINE.
    p_int = ‘200’.

    DATA : lt_pids  TYPE sxms_sel_options,
           ls_sxmspemas  TYPE sxmspemas_sr,
    lt_back_pids  TYPE sxms_tab_sxmspid,
    ls_back_pids  TYPE sxmspid,
    ls_pids  TYPE sxmsselopt.

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

    *************Traigo PipeLine Id’s************************************

    lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_back_pid ).
    LOOP AT lt_back_pids INTO ls_back_pids.
      ls_pids-sign = ‘E’.
      ls_pids-option = ‘EQ’.
      ls_pids-low  = ls_back_pids.
      APPEND ls_pids TO lt_pids.
    ENDLOOP.
    lt_back_pids = cl_xms_persist=>get_pid( cl_xms_persist=>co_pe_pid ).
    LOOP AT lt_back_pids INTO ls_back_pids.
      ls_pids-sign = ‘E’.
      ls_pids-option = ‘EQ’.
      ls_pids-low  = ls_back_pids.
      APPEND ls_pids TO lt_pids.
    ENDLOOP.
    *********************************************************************

    ls_sxmspemas-ob_ns           = oifns.
    ls_sxmspemas-ob_name         = oifname.

    break t52252.
    ********Busco los Id por los filtros ******************
    CALL FUNCTION ‘SXMB_SELECT_MESSAGES’
      EXPORTING
        im_exedate           = p_stdt
        im_exetime           = p_htdt
        im_exe2date          = p_endt
        im_pids              = lt_pids
        im_s_sender_receiver = ls_sxmspemas
        im_client            = sy-mandt
        im_number            = p_int
      IMPORTING
        ex_msgtab            = msg_tab1.
    ********************************************************************
    break t52252.
    *********Busco los Payload de los registros********************************
    LOOP AT msg_tab1 INTO wa.
      SELECT * FROM sxmspvers APPENDING CORRESPONDING FIELDS OF TABLE msg_tab
      WHERE msgguid = wa-msgguid.
    ENDLOOP.
    ***********************************************************************
    Check not msg_tab[] is initial.

    CREATE OBJECT persist.

    *********Traigo los Key de los registros seleccionados ***********************
    LOOP AT msg_tab INTO wa.

      CLEAR :content,p_mesg,pid,vers.
      CLEAR payload[].
      FREE xms_msg.
      FREE xmb_msg.

      p_mesg = wa-msgguid .
      pid = wa-pid.
      vers = wa-vers.

      CALL METHOD persist->read_msg_all
        EXPORTING
          im_msgguid = p_mesg
          im_pid     = pid
          im_version = vers
        IMPORTING
          ex_message = xms_msg.

      xms_msg->deleteheaderbyname(
             nsuri  = if_xms_run_time_env=>co_nsuri
             lcname = if_xms_run_time_env=>co_lcname ).

      xmb_msg ?= xms_msg.
      CALL METHOD xmb_msg->if_xms_message_xmb~get_main_payloads
        RECEIVING
          return = payload.

      READ TABLE payload INTO wa_payload INDEX 1.
    *Buscar informacion en Payloads
      CALL METHOD wa_payload-mainpayload->getbinarycontent
        RECEIVING
          return = content.

      data: ex_string TYPE STRING.

      CALL FUNCTION ‘ECATT_CONV_XSTRING_TO_STRING’
        EXPORTING
          im_xstring = content
        IMPORTING
          ex_string  = ex_string.

    *Valido si encontre el dato en el XML
      SEARCH ex_string FOR xvalue.
      if sy-subrc eq 0.
        range_line-sign   = ‘I’.
        range_line-option = ‘EQ’.
        range_line-low    = wa-msgguid.
        APPEND range_line TO range_tab.
      else.
        wa-gen_entry = ‘X’.
        MODIFY msg_tab FROM wa.
      endif.

    ENDLOOP.
    DELETE  msg_tab WHERE gen_entry = ‘X’.
    DESCRIBE TABLE msg_tab.
    check not msg_tab[] is initial.
    SUBMIT rsxmb_select_messages
                         WITH msgguid IN range_tab
                         WITH lines = sy-tfill
                         AND RETURN.

    (0) 
  6. Former Member
    Hi Sravya,

    The code could not find the messages in the status application error – restart not possible but i am able to find the messages in the status application error – manual restart possible.

    Any help would be appreciated.

    Thanks,

    Reddy

    (0) 
  7. Former Member

    To Whom it may Concern,

    Few problems in the code above:

    1.

    The call to FM “SXMB_SELECT_MESSAGES” is missing 2 must-have parameters: From-Time & To-Time (param names are IM_EXETIME & IM_EXE2TIME).

    The call should be like this:

    CALL FUNCTION ‘SXMB_SELECT_MESSAGES’
         EXPORTING
           im_exedate          = p_stdt
           im_exetime          = ‘000000’
           im_exe2date         = p_endt
           im_exe2time         = ‘235959’
           im_client           = symandt
           im_number           = 9999                           
         IMPORTING
           ex_msgtab           = msg_tab1
         EXCEPTIONS
           persist_error       = 1
           missing_parameter   = 2
           negative_time_range = 3
           too_many_parameters = 4
           OTHERS              = 5.

    2.

    The parameter IM_NUMBER states the maximum number of messages

    to be found. In the example above you can see I defaulted it to “9999”.


    3.

    The line

    CALL METHOD xmb_msg->if_xms_message_xmb~get_main_payloads
           RECEIVING
             return = payload.
    might result in nothing in the Payload table, so it should be followed by a CHECK:

    CHECK payload[] IS NOT INITIAL.

    This CHECK will skip the current LOOP step and will continue to the next record in the table.

    (0) 

Leave a Reply