PI Monitoring Functionality – Fetching Data from SXMB · PDF filePI Monitoring...

download PI Monitoring Functionality – Fetching Data from SXMB · PDF filePI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables Introduction Sometimes it’s necessary

If you can't read please download the document

Transcript of PI Monitoring Functionality – Fetching Data from SXMB · PDF filePI Monitoring...

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    Applies to: SAP Exchange Infrastructure (SAP NetWeaver Process Integration 7.0).

    For more information, visit the ABAP homepage.

    Summary In this I will show a way to fetch the PI monitoring data (accessed via transaction SXMB_MONI) from the various standard tables, save these data in a customizing transparent table and a report that recover the saved data and shows the payload in a HTML viewer control application.

    Author: David Fernandes Pietroniro

    Company: CSCorp

    Created on: 17 December 2008

    Author Bio

    David Fernandes Pietroniro works with ABAP since 2003, nowadays hes working in implementations of the SAP GRC NFe and developing custom applications using ABAP OO, Web Dynpro ABAP and PI.

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2008 SAP AG 1

    https://www.sdn.sap.com/irj/sdn/abap

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    Table of Contents Introduction .........................................................................................................................................................3 ZSXMB_MONI Function Module ........................................................................................................................3

    Importing Parameters......................................................................................................................................3 Exporting Parameters .....................................................................................................................................5 Exceptions.......................................................................................................................................................6 Source code ....................................................................................................................................................6

    Report to Fetch the Data ..................................................................................................................................10 Transparent Table.........................................................................................................................................10 Source Code .................................................................................................................................................11 Running the Program....................................................................................................................................16

    Application to Shows the Fetched Monitoring Messages.................................................................................17 Source Code .................................................................................................................................................17

    Program ZSXMB_MONI_VIEWER ............................................................................................................................17 Program ZSXMB_MONI_PAYLOAD..........................................................................................................................24

    Running the Viewer.......................................................................................................................................29 Related Content................................................................................................................................................30 Disclaimer and Liability Notice..........................................................................................................................31

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2008 SAP AG 2

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    Introduction Sometimes its necessary to fetch some PI monitoring messages accessed via transaction SXMB_MONI (to show them over a Portal or in another system for example). Here, I will show in few steps how to create a function that recovers these data, save it in a custom transparent table and a small application that shows these data in an ALV report that when some line is double clicked, shows the payload of the desired message in a HTML viewer control.

    ZSXMB_MONI Function Module This function module is an improved version of the one created by Pooja Pandey in Exposing the XI monitoring functionality as a Web Service.

    The function is responsible to fetch the data from the standard SAP monitoring tables (including the messages payloads) and export them as a table. I used a remote enabled function module (RFC) because with this option its possible to call it from others systems and save the fetched data remotely on the caller systems.

    Importing Parameters

    The importing parameters are:

    IV_DATE_FROM: The initial execution date;

    IV_TIME_FROM: The initial execution time;

    IV_DATE_TO: The final execution date;

    IV_TIME_TO: The final execution time;

    IT_FILTER: A filter table based on the ZSXMB_MONI_FILTER structure where is defined the field and the conditions that this field must respect. The field is one or more of the SXI_MSG_SELECT structure and the value is the desired condition. An example of how to fill this table will be showed in the report thats used to recover the monitoring data.

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2008 SAP AG 3

    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/909760cb-0ec8-2a10-4a96-ee8417acfbc9https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/909760cb-0ec8-2a10-4a96-ee8417acfbc9

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2008 SAP AG 4

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    Exporting Parameters

    The exporting parameter is:

    ET_DATA: The table that contains the message data including its payload. This table is based on the structure ZSXMB_MONI_DATA (which include the structures ZSXMB_MONI_KEY with the key fields for the messages and ZSXMB_MONI_OTHER that contains the data fields these structures are described in the topic Report to Fetch Data).

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2008 SAP AG 5

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    Exceptions

    The exceptions are:

    INVALID_DATES: The date and time passed as importing parameters are invalids (date and time from greater than the date and time to, for example);

    NO_DATA: Theres no PI monitoring messages for the conditions passed in the importing parameters.

    Source code

    FUNCTION zsxmb_moni. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" REFERENCE(IV_DATE_FROM) TYPE DATS *" REFERENCE(IV_TIME_FROM) TYPE TIMS *" REFERENCE(IV_DATE_TO) TYPE DATS *" REFERENCE(IV_TIME_TO) TYPE TIMS *" REFERENCE(IT_FILTER) TYPE ZSXMB_MONI_FILTER_TAB OPTIONAL *" EXPORTING *" REFERENCE(ET_DATA) TYPE ZSXMB_MONI_DATA_TAB *" EXCEPTIONS *" INVALID_DATES *" NO_DATA *"---------------------------------------------------------------------- * Declaration of constants CONSTANTS: lco_number TYPE int4 VALUE 2147483646, lco_filter TYPE c LENGTH 10 VALUE 'LS_FILTER-', lco_1 TYPE i VALUE 1, BEGIN OF lco_pids, sign TYPE sxmsselopt-sign VALUE 'E', option TYPE sxmsselopt-option VALUE 'EQ', central TYPE sxmsselopt-low VALUE 'CENTRAL_BACK', receiver TYPE sxmsselopt-low VALUE 'RECEIVER_BACK', sender TYPE sxmsselopt-low VALUE 'SENDER_BACK', adapter TYPE sxmsselopt-low VALUE 'PE_ADAPTER', process TYPE sxmsselopt-low VALUE 'PE_PROCESS', END OF lco_pids. * Declaration of data types. TYPES: * Data type used to fetch the message logs payloads. BEGIN OF lty_payload, msgguid TYPE sxmsmsglst-msgguid, pid TYPE sxmsmsglst-pid,

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2008 SAP AG 6

  • PI Monitoring Functionality Fetching Data from SXMB_MONI Standard Tables

    payload TYPE xstring, END OF lty_payload, lty_t_payload TYPE SORTED TABLE OF lty_payload WITH NON-UNIQUE KEY msgguid pid. * Declaration of data objects. DATA: lv_timestmp_from TYPE timestampl, lv_timestmp_to TYPE timestampl, ls_filter TYPE sxi_msg_select, ls_pids TYPE LINE OF sxi_msg_select-pids, lt_msgtab TYPE sxmsmsgtab, lr_msgtab TYPE REF TO sxmsmsglst, lt_msgtab_aux LIKE lt_msgtab, lr_filter TYPE REF TO zsxmb_moni_filter, lr_filter_aux TYPE REF TO zsxmb_moni_filter, lv_times TYPE zsxmb_moni_filter-filternum VALUE '001', lv_fieldname TYPE zsxmb_moni_filter-field, lr_xms_persist TYPE REF TO cl_xms_persist, lr_message TYPE REF TO if_xms_message, lr_resource TYPE REF TO if_xms_resource, lr_error TYPE REF TO cx_root, "#EC NEEDED lv_version TYPE sxmslsqnbr, lv_cont TYPE i, lv_size TYPE i, lv_data TYPE xstring, lt_payload TYPE lty_t_payload, ls_payload LIKE LINE OF lt_payload, lr_payload TYPE REF TO lty_payload, ls_data