Skip to Content

In the sdn there are some documents abput how to improve or  fetch data from sxi_monitor. in this case a did two RFC.The first RFC (ZXI_MONITOR) fetch the data of differents messages from Imports parameters filters. 

The second RFC get back the Payload (inbound Message) from the message ID thats comes in a Import Parameter

zxi_monitor RFC receive parameters like

    • EndDate
    • BeginTime
    • EndTime
    • SenderSystem
    • TargetSystem
    • MessageID

in simples words the RFC fetch the data from those filters and fill the table GT_MESSAGES.

Also *ZDISPLAY_MESSAGE_PAYLOAD *RFC get the message payload from the messageID

But no much words a go to the action. here you have the ABAP code. this develop is different from others blogs cozi dont create any custom structureto return data, just ussing the standard code and tables.

Here ZXI_MONITOR 

 h5. FUNCTION zxi_monitor.<br />“—-


“Local
Interface:
”  IMPORTING<br />”     VALUE(D_BEGINDATE) TYPE  SYDATUM
*”    
VALUE(D_ENDDATE) TYPE  SYDATUM
*”     VALUE(T_BEGINTIME) TYPE 
SYUZEIT
”     VALUE(T_ENDTIME) TYPE  SYUZEIT OPTIONAL<br />”    
VALUE(S_SENDER_SYSTEM) TYPE  CHAR20 OPTIONAL
*”    
VALUE(S_TARGET_SYSTEM) TYPE  CHAR20 OPTIONAL
*”     VALUE(MESSAGEID)
TYPE  CHAR40 OPTIONAL
”  EXPORTING<br />”     VALUE(GT_MESSAGES)
TYPE  Z_TT_SXMSMSGDSP
“—-


<br /><br /><br />
Tables*&—-



**&     
Form  build_list
*&—-



**      
text
*—-


<br /><br />FORM
build_list TABLES gt_messages<br />                USING d_begindate<br />                     
d_enddate<br />                      t_begintime<br />                     
t_endtime<br />                      s_sender_system<br />                     
s_target_system<br />                      messageid.<br /><br /><br /> 
TYPES:BEGIN OF gt_msgguid_sel,<br />             sign(1),<br />            
option(2),<br />             low(36) TYPE c,<br />             high(36) TYPE
c,<br />           END OF gt_msgguid_sel.<br />  DATA: status(20).<br /> 
DATA: “lv_tabix      LIKE sy-tabix,<br />           lv_state_only TYPE
sxmsflag,<br />*          lv_msgstate   TYPE sxmspmstat,<br />          
lv_client     LIKE sy-mandt,<br />           ls_sxmspemas  TYPE
sxmspemas_sr,<br />           lt_msgguid    TYPE sxmsmguidt,<br />          
ls_msgguid    TYPE sxmsmguid,<br />           lt_pids       TYPE
sxms_sel_options,<br />           ls_pids       TYPE sxmsselopt,<br />          
lt_back_pids  TYPE sxms_tab_sxmspid,<br />           ls_back_pids  TYPE
sxmspid,<br />           wa            TYPE gt_msgguid_sel,<br />          
wa_msgtab     TYPE sxmsmsglst,<br />           lt_clients    TYPE
sxmb_symandt_tab,<br />           lv_index      TYPE sxmsmguid,<br />          
lv_index_count TYPE sxmxindex,<br />           lv_process_mode,<br />          
l_first_ts    TYPE timestampl,<br />           l_exe_date    TYPE d,<br />          
l_exe_time    TYPE t,<br />           l_number      TYPE i VALUE 200.<br /> 
DATA: lt_mstat_tab  TYPE sxmspmstat_tab.<br />  DATA: l_result TYPE
sxmsadminresult.<br />*          lv_stat_type  TYPE sxmspmstat_type.<br /> 
DATA: gt_msgtab              TYPE sxmsmsgtab.<br />  DATA: lv_msgtab LIKE
gt_msgtab.<br />  DATA: gv_xmb_admin.<br />  DATA: g_sel_tab TYPE sy-ucomm.<br /> 
DATA: persist TYPE REF TO cl_xms_persist.<br />  DATA:
gt_sxmsmsglst_sorted   TYPE sxmsmsglst_sorted_tab.<br />  DATA: oref TYPE
REF TO cx_xms_syserr_persist.<br />  DATA: gs_sxmsmsglst_sorted   TYPE
sxmsmsglst_sorted.<br />  DATA: gs_msgtab              TYPE sxmsmsglst.<br /> 
DATA: gs_msgtab_ext          TYPE sxmsmsgdsp.<br />  DATA:
gt_msgtab_ext          TYPE STANDARD TABLE OF sxmsmsgdsp.<br />  DATA: 
pid TYPE sxmspid.<br />  DATA: lt_msgtab LIKE gt_msgtab_ext,<br />             
l_tabix TYPE sytabix.<br />  DATA: errcat  TYPE sxmserrcat,<br />       
errcode TYPE sxmserrid,<br />        msgtype TYPE sxmspmtype.<br />  DATA:
l_icon          TYPE tv_image.<br />  DATA: msgtab TYPE sxmsmsgdsp.<br /> 
DATA: wa_messages TYPE zsxmsmsgdsp_tab.<br />  DATA:
zw_exedate             TYPE sy-datum,<br />      zw_exetime            
TYPE sy-uzeit,<br />      zw_senddate            TYPE sy-datum,<br />     
zw_sendtime            TYPE sy-uzeit,<br />      zw_initdate           
TYPE sy-datum,<br />      zw_inittime            TYPE sy-uzeit.<br /> 
FIELD-SYMBOLS: <msgline> LIKE LINE OF gt_msgtab_ext.<br /><br /> 
REFRESH: gt_msgtab.<br /><br />* Busca mensaje por Message ID. este
parametro debe ser el qe llega por parámetro<br />*  SORT msgguid.<br />*   
CLEAR lifecycl.<br />  REFRESH lt_msgguid.<br /><br />  IF messageid IS NOT
INITIAL.<br />    REPLACE ALL OCCURRENCES OF ‘-‘ IN messageid WITH ”.<br />   
CONDENSE messageid NO-GAPS.<br /><br />    IF messageid CO
‘0123456789abcdefABCDEF ‘.<br />      ls_msgguid = messageid.<br />     
APPEND ls_msgguid TO lt_msgguid.<br />* delete time fields, since only
guids are relevant<br />      CLEAR d_begindate.<br />      CLEAR d_enddate.<br />     
CLEAR t_begintime.<br />    ENDIF.<br /><br />    IF pid IS INITIAL AND
messageid IS INITIAL.<br />      lt_back_pids =
cl_xms_persist=>get_pid( cl_xms_persist=>co_back_pid ).<br />     
LOOP AT lt_back_pids INTO ls_back_pids.<br />        ls_pids-sign = ‘E’.<br />       
ls_pids-option = ‘EQ’.<br />        ls_pids-low  = ls_back_pids.<br />       
APPEND ls_pids TO lt_pids.<br />      ENDLOOP.<br />    ENDIF.<br />  ENDIF.<br />*Asigno
los valores de los filtros a las estructuras<br />*correspondientes para
luego hacer la busqueda correspondiente<br /><br />*   
ls_sxmspemas-ob_party        = sndrprty.<br />*   
ls_sxmspemas-ob_party_type   = sndprtty.<br />* 
ls_sxmspemas-ob_party_agency =<br />  ls_sxmspemas-ob_system       =
s_sender_system.<br />*    ls_sxmspemas-ob_ns           = oifns.<br />*   
ls_sxmspemas-ob_name         = oifname.<br />*   
ls_sxmspemas-ib_party        = rcvrprty.<br />*   
ls_sxmspemas-ib_party_type   = rcvprtty.<br />* 
ls_sxmspemas-ib_party_agency =<br />  ls_sxmspemas-ib_system       =
s_target_system.<br />*    ls_sxmspemas-ib_ns           = iifns.<br />*   
ls_sxmspemas-ib_name         = iifname.<br />*<br /><br />  CALL FUNCTION
‘SXMB_SELECT_MESSAGES'<br />    EXPORTING<br />      im_senddate          =
‘00000000’<br />      im_sendtime          = ‘000000’<br />     
im_snd2date          = ‘00000000’<br />      im_snd2time          =
‘000000’<br />      im_exedate           = d_begindate<br />     
im_exetime           = t_begintime<br />      im_exe2date          =
d_enddate<br />      im_exe2time          = t_endtime<br />     
im_pid               = pid<br />      im_pids              = lt_pids<br />     
im_client            = ‘100’<br />      im_user              = ”<br />     
im_adapter_type_in   = ”<br />      im_adapter_type      = ”<br />     
im_adapter_state     = ‘000’<br />      im_s_sender_receiver =
ls_sxmspemas<br />      im_errcat            = errcat<br />     
im_errcode           = errcode<br />      im_msgguid_tab       =
lt_msgguid<br />      im_msgstate_tab      = lt_mstat_tab<br />     
im_queueid           = ”<br />      im_msgtype           = msgtype<br />     
im_number            = l_number<br />      im_process_mode      = ‘0’<br />   
IMPORTING<br />      ex_msgtab            = gt_msgtab<br />     
ex_result            = l_result<br />      ex_first_ts          =
l_first_ts<br />    EXCEPTIONS<br />      persist_error        = 1<br />     
OTHERS               = 2.<br /><br />***************Control de errores de
busqueda de mensajes<br />  IF sy-subrc <> 0.<br />    MESSAGE ID
sy-msgid TYPE ‘S’ NUMBER sy-msgno DISPLAY LIKE ‘E'<br />            WITH
sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.<br />    EXIT.<br />  ENDIF.<br /><br />*
test if one message is selected at all<br />  IF gt_msgtab[] IS INITIAL.<br />   
MESSAGE i113(xms_adm) DISPLAY LIKE ‘E’.<br />    EXPORT g_sel_tab FROM
g_sel_tab TO MEMORY ID ‘RSXMB_SEL_MSG_SEL_TAB’.<br />    EXIT.<br />  ELSE.<br />***************/Control
de errores de busqueda de mensajes<br /><br />* eliminate duplicates<br />   
SORT gt_msgtab BY msgguid pid.<br />    DELETE ADJACENT DUPLICATES FROM
gt_msgtab<br />      COMPARING msgguid pid.<br />  ENDIF.<br /><br />  REFRESH
gt_msgtab_ext.<br />* build displayed list<br />* first step: version 0
entries<br />  LOOP AT gt_msgtab INTO gs_msgtab.<br />    CLEAR:
zw_exedate,  zw_exetime,<br />           zw_senddate, zw_sendtime,<br />          
zw_initdate, zw_inittime.<br />    CONVERT TIME STAMP gs_msgtab-exetimest
TIME ZONE sy-zonlo<br />      INTO DATE zw_exedate TIME zw_exetime.<br />   
CONVERT TIME STAMP gs_msgtab-sendtimest TIME ZONE sy-zonlo<br />     
INTO DATE zw_senddate TIME zw_sendtime.<br />    CONVERT TIME STAMP
gs_msgtab-inittimest TIME ZONE sy-zonlo<br />      INTO DATE zw_initdate
TIME zw_inittime.<br /><br />    CLEAR gs_msgtab_ext.<br />   
MOVE-CORRESPONDING gs_msgtab TO gs_msgtab_ext.<br />   
gs_msgtab_ext-initdate = zw_initdate.<br />    gs_msgtab_ext-inittime =
zw_inittime.<br />    gs_msgtab_ext-exedate  = zw_exedate.<br />   
gs_msgtab_ext-exetime  = zw_exetime.<br />    gs_msgtab_ext-senddate   =
zw_senddate.<br />    gs_msgtab_ext-sendtime   = zw_sendtime.<br />   
gs_msgtab_ext-pelname    = text-042.<br /><br />** get the BPM relevant
fields<br />*        CALL METHOD get_bpm_fields<br />*          EXPORTING<br />*           
msgline = gs_msgtab_ext<br />*          IMPORTING<br />*            msgtab 
= lt_msgtab.<br /><br />        APPEND LINES OF lt_msgtab TO
gt_msgtab_ext.        l_icon3(2)  = ‘\Q’.<br />        l_icon5(40)
= text-q01.
        l_icon+45(1) = ‘@’.
      WHEN
cl_xms_persist=>co_stat_queue_error.
        l_icon       =
icon_led_red.
        l_icon3(2)  = ‘\Q’.<br />        l_icon5(40) =
text-q02.
        l_icon+45(1) = ‘@’.
      WHEN
cl_xms_persist=>co_stat_queue_waiting.
        l_icon       =
icon_led_yellow.
        l_icon3(2)  = ‘\Q’.<br />        l_icon5(40)
= text-q03.
        l_icon+45(1) = ‘@’.
      WHEN
cl_xms_persist=>co_stat_queue_processing.
        l_icon       =
icon_led_green.
        l_icon3(2)  = ‘\Q’.<br />        l_icon5(40) =
text-q04.
        l_icon+45(1) = ‘@’.
      WHEN OTHERS.
       
l_icon       = icon_space.
    ENDCASE.
   
gs_msgtab_ext-queueicon = l_icon.

*—–set status of job
   
CASE gs_msgtab_ext-status.

      WHEN ‘X’.
       
l_icon       = icon_led_yellow.
        l_icon+3(2)  = ‘\Q’.
       
l_icon5(40) = text-j01.<br />        l_icon45(1) = ‘@’.
      WHEN
‘D’.
        l_icon       = icon_okay.
        l_icon+3(2)  =
‘\Q’.
        l_icon5(40) = text-j02.<br />        l_icon45(1) = ‘@’.
     
WHEN OTHERS.
        l_icon       = icon_space.
    ENDCASE.
   
gs_msgtab_ext-jobicon = l_icon.

*—–set status of message

   
CALL FUNCTION ‘SXMB_GET_ICON_FOR_MSG_STATE’
      EXPORTING
       
im_state           = gs_msgtab_ext-msgstate
       
im_commit_flag     = gs_msgtab_ext-commitact
       
im_restart_version = gs_msgtab_ext-rest_vers
       
im_msgtype         = gs_msgtab_ext-msgtype
      IMPORTING
       
ex_icon            = l_icon.

    gs_msgtab_ext-staticon =
l_icon.
    MODIFY gt_msgtab_ext FROM gs_msgtab_ext.
*move-corresponding
gs_msgtab_ext to
  ENDLOOP.

* cargo los mensajes obtenidos a
mi
* estructura return que pasara los  datos al front end
  LOOP
AT gt_msgtab_ext INTO gs_msgtab_ext.
    MOVE-CORRESPONDING
gs_msgtab_ext TO wa_messages.
    APPEND wa_messages TO gt_messages.
   
CLEAR wa_messages.
  ENDLOOP.
ENDFORM.                   
“build_list*

  Here Zdisplay_message_payload

 

h5. FUNCTION zdisplay_message_payload.

“—-


<br />
“*”Local
Interface:
”  IMPORTING<br />”     VALUE(MESSAGEID) TYPE  CHAR40
*” 
EXPORTING
”     VALUE(PAYLOAD) TYPE  SLDSTRING<br />“—-


 
DATA:
   iv_version TYPE sxmslsqnbr,
   i_version TYPE
sxmslsqnbr,
   size TYPE i,
   ref_xms_persist TYPE REF TO
cl_xms_persist,
   ref_xms_main TYPE REF TO cl_xms_main,
  
ex_message TYPE REF TO if_xms_message,
   prop TYPE REF TO
if_xms_prop,
   props TYPE REF TO sxms_pro_t,
   resource TYPE REF
TO if_xms_resource,
   ex_msgstate TYPE sxmspmstat,
    
ex_string TYPE string,
   comp_string TYPE string,
   data TYPE
etxml_line_str,
   cx_ref TYPE REF TO cx_xms_syserr_persist.
 
DATA:
     lt_msgguid TYPE sxmsmguidt,
     ls_msgguid TYPE
sxmsmguid.
  DATA:
    gt_msgtab   TYPE sxmsmsgtab,
   
gs_msgtab   TYPE sxmsmsglst.

  ls_msgguid = messageid.
 
APPEND ls_msgguid TO lt_msgguid.

  CALL FUNCTION
‘SXMB_SELECT_MESSAGES’
    EXPORTING
*  
IM_SENDDATE                =
*   IM_SENDTIME                =
*  
IM_SND2DATE                =
*   IM_SND2TIME                =
*    
im_exedate                 = exedate
*    
im_exetime                 = start_time
*    
im_exe2date                = exe2date
*    
im_exe2time                = end_time
*   IM_PID                     =
*  
IM_PIDS                    =
*   IM_CLIENT                  =
*  
IM_USER                    =
*   IM_ADAPTER_TYPE_IN         =
*  
IM_ADAPTER_TYPE            =
*   IM_ADAPTER_STATE           =
*  
IM_S_SENDER_RECEIVER       =
*   IM_ERRCAT                  =
*  
IM_ERRCODE                 =
  im_msgguid_tab             =
lt_msgguid
*   IM_MSGSTATE_TAB            =
*  
IM_QUEUEID                 =
*   IM_MSGTYPE                 =
 
im_number                  = 1
*   IM_ADAPTER_OR              = ‘0’
*  
IM_PROCESS_MODE            = ‘0’
 IMPORTING
  
ex_msgtab                  = gt_msgtab
*   EX_RESULT                 
=
*   EX_FIRST_TS                =
 EXCEPTIONS
  
persist_error              = 1
   missing_parameter          = 2
  
negative_time_range        = 3
   too_many_parameters        = 4
  
OTHERS                     = 5.

  IF sy-subrc <> 0.
   
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH
sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    LOOP AT gt_msgtab
INTO gs_msgtab.
      CLEAR ex_message.
      CLEAR ex_msgstate.
     
CLEAR i_version.
      CREATE OBJECT ref_xms_persist.

     
TRY.
          CALL METHOD ref_xms_persist->read_msg_all
           
EXPORTING
              im_msgguid  = ls_msgguid
             
im_pid      = gs_msgtab-pid
              im_version  = i_version
           
IMPORTING
              ex_message  = ex_message
             
ex_msgstate = ex_msgstate.
        CATCH cx_xms_syserr_persist INTO
cx_ref.
          EXIT.
      ENDTRY.

      CALL METHOD
ex_message->numberofattachments
        RECEIVING
         
size = size.

      IF size IS NOT INITIAL.
        CALL METHOD
ex_message->getattachmentatindex
          EXPORTING
           
index    = ‘1’
          RECEIVING
            resource =
resource.
        TRY.
            CALL METHOD
resource->getbinarydata
              RECEIVING
               
data = data.
          CATCH cx_xms_exception.
          CATCH
cx_xms_system_error.
        ENDTRY.
        IF ex_string IS NOT
INITIAL.
          MOVE ex_string TO comp_string.
        ENDIF.

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

        IF i_version EQ ‘000’.
         
CONCATENATE ex_string payload INTO payload.
        ENDIF.

       
IF ex_string NE comp_string AND comp_string IS NOT INITIAL.
         
CONCATENATE ex_string payload INTO payload.
          CONTINUE.
       
ENDIF.
      ENDIF.
      i_version = i_version + 1 .
   
ENDLOOP.
  ENDIF.
ENDFUNCTION.
 

h5.

 

To report this post you need to login first.

4 Comments

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

    1. Alejandro Per Post author
      Hi,
      you just said it. you can use those RFC to fetch the monitoring data from an external app. its oriented to functional or Help desk that does not have experience with SAP PI.
      also if you have experience with WDP you can also get information of Channels to have and end-to-end external monitoring.
      (0) 
    1. Alejandro Per Post author
      Hi, Sorry i forgot to include it in the blog. here it go.

      Z_TT_SXMSMSGDSP is a table type which have a line type ZSXMSMSGDSP_TAB.

      ZSXMSMSGDSP_TAB

      field           type

      MANDT             SYMANDT
      MSGGUID             SXMSMGUID
      PID             SXMSPID
      MSGTYPE             SXMSPMTYPE
      MSGSTATE     SXMSPMSTAT
      QOSMODE             SXMSQOS
      EXETIMEST     TIMESTAMPL
      INITTIMEST     TIMESTAMPL
      SENDTIMEST     TIMESTAMPL
      SNDRGUID     SXMSSNDRID
      QUEUEGUID     SXMSQID
      EO_REFID     SXMSREFID
      EO_REFVAL     SXMSREFVAL
      ADAPT_TYP     SXMSPSTYPE
      ADAPT_STAT     SXMSPASTAT
      PARENTMSG     SXMSMGUID
      CHILDCOUNT     NUMC3
      CLIENT     SYMANDT
      ADMINUSER     SYUNAME
      ADMINUSER     SYUNAME
      GEN_ENTRY     SXMSFLAG
      MANUALSTAT     SXMSFLAG
      RETRYCOUNT     NUMC3
      ITFACTION     SXMSITFACT
      COMMITACT     SXMSFLAG
      EO_REFID_I     SXMSREFID
      EO_REFVL_I     SXMSREFVAL
      ADAPT_TP_I     SXMSPSTYPE
      REST_VERS     SXMSLSQNBR
      EO_REFID_O     SXMSREFID
      EO_REFVL_O     SXMSREFVAL
      QUEUEINT     TRFCQNAM
      REF_TO_MSG     SXMSMGUID
      REF_TO_REC_MSG     SXMSMGUID
      ACK_STATE     SXMSPACKSTAT
      REORG             SXMSREORG
      RND_NUMBER     SXMSRNDNUM
      VERS             SXMSLSQNBR
      SECURITY     SXMSSECURITY
      RETRYCOUNT_MAN     SXMS_MAN_RETRYCO
      USERINFOSTORAGE     USERINFO_GUID
      USERINFODATA     USERINFO_GUID
      OB_SYSTEM     AIT_SNDR
      OB_NS             RM_OIFNS
      OB_NAME             RM_OIFNAME
      OB_PARTY     SXI_PARTY
      OB_PARTY_TYPE     SXI_PARTY_TYPE
      OB_PARTY_AGENCY     SXI_PARTY_AGENCY
      IB_SYSTEM     AIT_RCVR
      IB_NS             RM_IIFNS
      IB_NAME             RM_IIFNAME
      IB_PARTY     SXI_PARTY
      IB_PARTY_TYPE     SXI_PARTY_TYPE
      IB_PARTY_AGENCY     SXI_PARTY_AGENCY
      JOB_ID             SXMSJOB
      STATUS             SXMSMSGREFSTATUS
      ERRCAT             SXMSERRCAT
      ERRCODE             SXMSERRID
      STATICON     CHAR50
      ADAPICON     CHAR50
      ACKSTATICON     CHAR50
      INITDATE     SYDATUM
      INITTIME     SYUZEIT
      EXEDATE             SYDATUM
      EXETIME             SYUZEIT
      SENDDATE     SYDATUM
      SENDTIME     SYUZEIT
      TYPETEXT     CHAR20
      VERSION             SXMSLSQNBR
      PELNAME             SXMPELNAME
      LOG_ICON     CHAR4
      INT_TIMEST     TIMESTAMPL
      INT_NUM             NUMC3
      LINECOLOR     CHAR4
      EXPANDED     CHAR1
      QUEUEICON     CHAR50
      QUEUESTATE     SXMSPQSTAT
      REORGICON     CHAR50
      JOBICON             CHAR50
      DIRPARTY     SWFDXIDIRPTY
      DIRSERVICE     SWFDXIDIRSRV
      TASK             SWF_XI_WF_ID
      XI_PROXY     SWFDXMPNAM
      WI_ID             SWW_WIID
      BULKMESSAGE     CHAR4

      (0) 

Leave a Reply