31
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 he’s 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

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

  • Upload
    idompol

  • View
    224

  • Download
    5

Embed Size (px)

Citation preview

Page 1: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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 he’s 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

Page 2: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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

Page 3: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

Introduction Sometimes it’s 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 it’s 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 that’s 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

Page 4: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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

Page 5: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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

Page 6: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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: There’s 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

Page 7: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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 LIKE LINE OF et_data. * Declaration of field-symbols FIELD-SYMBOLS: <fs_field> TYPE ANY. * Validate the dates received via importing parameters CONVERT: DATE iv_date_from TIME iv_time_from INTO TIME STAMP lv_timestmp_from TIME ZONE sy-zonlo, DATE iv_date_to TIME iv_time_to INTO TIME STAMP lv_timestmp_to TIME ZONE sy-zonlo. IF lv_timestmp_from > lv_timestmp_to. RAISE invalid_dates. ENDIF. FREE: lv_timestmp_from, lv_timestmp_to. * Determine the number of times that the messages log data * selection must occurs. IF LINES( it_filter ) > 0. READ TABLE it_filter INDEX 1 REFERENCE INTO lr_filter_aux. LOOP AT it_filter REFERENCE INTO lr_filter. CHECK lr_filter->filternum <> lr_filter_aux->filternum. lv_times = lv_times + 1. lr_filter_aux = lr_filter. ENDLOOP. FREE lr_filter_aux. ENDIF.

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

Page 8: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

DO lv_times TIMES. CLEAR: ls_filter, lt_msgtab_aux. * Move the fixed filter fields to the filter structure. ls_pids-sign = lco_pids-sign. ls_pids-option = lco_pids-option. ls_pids-low = lco_pids-central. APPEND ls_pids TO ls_filter-pids. ls_pids-low = lco_pids-receiver. APPEND ls_pids TO ls_filter-pids. ls_pids-low = lco_pids-sender. APPEND ls_pids TO ls_filter-pids. ls_pids-low = lco_pids-adapter. APPEND ls_pids TO ls_filter-pids. ls_pids-low = lco_pids-process. APPEND ls_pids TO ls_filter-pids. * Move the importing parameters to the corresponding filter structure * fields. ls_filter-exedate = iv_date_from. ls_filter-exetime = iv_time_from. ls_filter-exe2date = iv_date_to. ls_filter-exe2time = iv_time_to. * Move the others fields from the importing parameters to the * corresponding fields. LOOP AT it_filter REFERENCE INTO lr_filter WHERE filternum = sy-index. CONCATENATE lco_filter lr_filter->field INTO lv_fieldname. ASSIGN (lv_fieldname) TO <fs_field>. IF sy-subrc = 0. <fs_field> = lr_filter->value. ENDIF. ENDLOOP. * Select the messages log CALL FUNCTION 'SXMB_SELECT_MESSAGES_NEW' EXPORTING im_filter = ls_filter im_number = lco_number IMPORTING ex_msgtab = lt_msgtab_aux EXCEPTIONS persist_error = 1 missing_parameter = 2 negative_time_range = 3 too_many_parameters = 4 no_timezone = 5 OTHERS = 6. IF sy-subrc <> 0. "#EC NEEDED ENDIF. APPEND LINES OF lt_msgtab_aux TO lt_msgtab. ENDDO. FREE: ls_filter, ls_pids, lt_msgtab_aux, lv_times, lv_fieldname. * Fetch the payload data CREATE OBJECT lr_xms_persist. LOOP AT lt_msgtab REFERENCE INTO lr_msgtab. CLEAR: lv_version, ls_payload.

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

Page 9: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

lv_version = lr_msgtab->vers. lv_cont = lr_msgtab->vers + 1. DO lv_cont TIMES. TRY. lr_xms_persist->read_msg_all( EXPORTING im_msgguid = lr_msgtab->msgguid im_pid = lr_msgtab->pid im_version = lv_version IMPORTING ex_message = lr_message ). CATCH cx_xms_syserr_persist INTO lr_error. EXIT. ENDTRY. lv_size = lr_message->numberofattachments( ). IF lv_size IS NOT INITIAL. lr_resource = lr_message->getattachmentatindex( index = lco_1 ). TRY. lv_data = lr_resource->getbinarydata( ). CATCH: cx_xms_exception INTO lr_error, "#EC NO_HANDLER cx_xms_system_error INTO lr_error. "#EC NO_HANDLER ENDTRY. IF lv_data IS NOT INITIAL. CONCATENATE lv_data ls_payload-payload INTO ls_payload-payload IN BYTE MODE. ENDIF. lv_version = lv_version + 1. CLEAR lv_data. ENDIF. ENDDO. IF ls_payload-payload IS NOT INITIAL. ls_payload-msgguid = lr_msgtab->msgguid. ls_payload-pid = lr_msgtab->pid. INSERT ls_payload INTO TABLE lt_payload. ENDIF. ENDLOOP. FREE: ls_payload, lv_version, lv_cont, lv_size, lv_data, lr_xms_persist, lr_resource. * Process the retrieved data and return it to the function * caller. LOOP AT lt_msgtab REFERENCE INTO lr_msgtab. READ TABLE lt_payload WITH TABLE KEY msgguid = lr_msgtab->msgguid pid = lr_msgtab->pid REFERENCE INTO lr_payload. ls_data-msgguid = lr_msgtab->msgguid. ls_data-pid = lr_msgtab->pid. ls_data-ob_system = lr_msgtab->ob_system. ls_data-ob_ns = lr_msgtab->ob_ns. ls_data-ob_name = lr_msgtab->ob_name. ls_data-ib_system = lr_msgtab->ib_system.

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

Page 10: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

ls_data-ib_ns = lr_msgtab->ib_ns. ls_data-ib_name = lr_msgtab->ib_name. ls_data-msgtype = lr_msgtab->msgtype. ls_data-msgstate = lr_msgtab->msgstate. ls_data-exetimest = lr_msgtab->exetimest. ls_data-inittimest = lr_msgtab->inittimest. ls_data-sendtimest = lr_msgtab->sendtimest. ls_data-adminuser = lr_msgtab->adminuser. IF lr_payload IS BOUND. ls_data-payload = lr_payload->payload. CLEAR lr_payload. ENDIF. APPEND ls_data TO et_data. ENDLOOP. IF et_data IS INITIAL. RAISE no_data. ENDIF. ENDFUNCTION.

Report to Fetch the Data After the creation of the function module it’s necessary to create a way to call it, fetch the data and store these data in a transparent table.

For this will be created a report that calls the function module, shows a small summary of the processing status and store the fetched data in a transparent table.

Transparent Table

First of all, it’s necessary to create a transparent table to store the monitoring messages and the payload recovered from the standard tables. This transparent table is composed by the structure that contains the keys for the message (ZSXMB_MONI_KEY) and the structure that contains the data fields (ZSXMB_MONI_OTHER).

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

Page 11: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

Source Code

*&---------------------------------------------------------------------* *& Report ZSXMB_MONI *&---------------------------------------------------------------------* REPORT zsxmb_moni LINE-SIZE 80. CONSTANTS: lco_bar TYPE c LENGTH 1 VALUE '/', BEGIN OF co_log,

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

Page 12: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

success TYPE symsgty VALUE 'S', warning TYPE symsgty VALUE 'W', error TYPE symsgty VALUE 'E', END OF co_log. TYPES ty_t_zsxmb_moni_key TYPE SORTED TABLE OF zsxmb_moni_key WITH UNIQUE DEFAULT KEY. DATA: gv_error TYPE c LENGTH 1. SELECTION-SCREEN BEGIN OF BLOCK bl01 WITH FRAME. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (29) text-c01 FOR FIELD p_exedat. PARAMETERS p_exedat TYPE dats OBLIGATORY. SELECTION-SCREEN COMMENT 44(2) co_bar FOR FIELD p_exetim. PARAMETERS p_exetim TYPE tims OBLIGATORY. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (29) text-c02 FOR FIELD p_exe2da. PARAMETERS p_exe2da TYPE dats OBLIGATORY. SELECTION-SCREEN COMMENT 44(2) co_bar1 FOR FIELD p_exe2ti. PARAMETERS p_exe2ti TYPE tims OBLIGATORY. SELECTION-SCREEN END OF LINE. PARAMETER p_wri TYPE c AS CHECKBOX. SELECTION-SCREEN END OF BLOCK bl01. INITIALIZATION. co_bar = lco_bar. co_bar1 = lco_bar. p_exedat = sy-datum. p_exe2da = sy-datum + 1. START-OF-SELECTION. PERFORM validate_date. CHECK gv_error IS INITIAL. PERFORM main. *&---------------------------------------------------------------------* *& Form validate_date *&---------------------------------------------------------------------* FORM validate_date. DATA: lv_exedat TYPE timestampl, lv_exe2dat TYPE timestampl. CONVERT: DATE p_exedat TIME p_exetim INTO TIME STAMP lv_exedat TIME ZONE sy-zonlo, DATE p_exe2da TIME p_exe2ti INTO TIME STAMP lv_exe2dat TIME ZONE sy-zonlo. IF lv_exedat >= lv_exe2dat. MESSAGE i055(xms_adm) DISPLAY LIKE co_log-error. gv_error = '1'.

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

Page 13: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

ENDIF. ENDFORM. "validate_date *&---------------------------------------------------------------------* *& Form main *&---------------------------------------------------------------------* FORM main. DATA: lt_payload TYPE zsxmb_moni_data_tab, lv_log TYPE n LENGTH 5. PERFORM select_data CHANGING lt_payload. PERFORM verify_data CHANGING lt_payload lv_log. PERFORM save_data USING lt_payload. PERFORM print_logs USING lt_payload lv_log. ENDFORM. "main *&---------------------------------------------------------------------* *& Form select_data *&---------------------------------------------------------------------* FORM select_data CHANGING ct_payload TYPE zsxmb_moni_data_tab. CONSTANTS: BEGIN OF lco_filternum, num1 TYPE zsxmb_moni_filter-filternum VALUE '001', num2 TYPE zsxmb_moni_filter-filternum VALUE '002', END OF lco_filternum, BEGIN OF lco_field, field1 TYPE zsxmb_moni_filter-field VALUE 'SENDER_RECEIVER-OB_NS', field2 TYPE zsxmb_moni_filter-field VALUE 'SENDER_RECEIVER-OB_NAME', END OF lco_field, BEGIN OF lco_value, value1 TYPE zsxmb_moni_filter-value VALUE 'http://cscorp.com.br/pi/nfe', value2 TYPE zsxmb_moni_filter-value VALUE 'J_1B_NFE_XML_OUT', END OF lco_value. DATA: lt_filter TYPE zsxmb_moni_filter_tab, ls_filter TYPE zsxmb_moni_filter. ls_filter-filternum = lco_filternum-num1. ls_filter-field = lco_field-field1. ls_filter-value = lco_value-value1. APPEND ls_filter TO lt_filter. ls_filter-filternum = lco_filternum-num2. ls_filter-field = lco_field-field2. ls_filter-value = lco_value-value2. APPEND ls_filter TO lt_filter. CALL FUNCTION 'ZSXMB_MONI' EXPORTING iv_date_from = p_exedat iv_time_from = p_exetim iv_date_to = p_exe2da iv_time_to = p_exe2ti it_filter = lt_filter IMPORTING et_data = ct_payload

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

Page 14: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

EXCEPTIONS invalid_dates = 1 no_data = 2 OTHERS = 3. IF sy-subrc = 2. MESSAGE i007(sabapdocu) DISPLAY LIKE co_log-error. ENDIF. ENDFORM. "select_data *&---------------------------------------------------------------------* *& Form verify_data *&---------------------------------------------------------------------* FORM verify_data CHANGING ct_payload TYPE zsxmb_moni_data_tab cv_log TYPE n. DATA: lt_zsxmb_moni_key TYPE ty_t_zsxmb_moni_key, lr_zsxmb_moni_key TYPE REF TO zsxmb_moni_key. CHECK ct_payload IS NOT INITIAL. SELECT msgguid pid FROM zsxmb_moni INTO TABLE lt_zsxmb_moni_key FOR ALL ENTRIES IN ct_payload WHERE msgguid = ct_payload-msgguid AND pid = ct_payload-pid. CHECK lt_zsxmb_moni_key IS NOT INITIAL. SORT ct_payload BY msgguid pid. LOOP AT lt_zsxmb_moni_key REFERENCE INTO lr_zsxmb_moni_key. READ TABLE ct_payload WITH KEY msgguid = lr_zsxmb_moni_key->msgguid pid = lr_zsxmb_moni_key->pid BINARY SEARCH TRANSPORTING NO FIELDS. IF sy-subrc = 0. IF p_wri IS INITIAL. DELETE ct_payload WHERE msgguid = lr_zsxmb_moni_key->msgguid AND pid = lr_zsxmb_moni_key->pid. ENDIF. cv_log = cv_log + 1. ENDIF. ENDLOOP. ENDFORM. "validate_data *&---------------------------------------------------------------------* *& Form save_data *&---------------------------------------------------------------------* FORM save_data USING ut_payload TYPE zsxmb_moni_data_tab. DATA: lt_zsxmb_moni TYPE STANDARD TABLE OF zsxmb_moni WITH NON-UNIQUE DEFAULT KEY, ls_zsxmb_moni LIKE LINE OF lt_zsxmb_moni, lr_payload TYPE REF TO zsxmb_moni_data. LOOP AT ut_payload REFERENCE INTO lr_payload. MOVE-CORRESPONDING lr_payload->* TO ls_zsxmb_moni. APPEND ls_zsxmb_moni TO lt_zsxmb_moni. ENDLOOP.

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

Page 15: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

IF lt_zsxmb_moni IS NOT INITIAL. MODIFY zsxmb_moni FROM TABLE lt_zsxmb_moni. ENDIF. ENDFORM. "save_data *&---------------------------------------------------------------------* *& Form print_logs *&---------------------------------------------------------------------* FORM print_logs USING ut_payload TYPE zsxmb_moni_data_tab uv_log TYPE n. IF ut_payload IS NOT INITIAL. PERFORM print_success USING ut_payload. ENDIF. IF uv_log IS NOT INITIAL. PERFORM print_overwrite USING uv_log. ENDIF. ENDFORM. "print_log *&---------------------------------------------------------------------* *& Form print_header *&---------------------------------------------------------------------* FORM print_header USING uv_msg TYPE c uv_type TYPE c. CASE uv_type. WHEN co_log-success. FORMAT COLOR COL_POSITIVE. WHEN co_log-warning. FORMAT COLOR COL_TOTAL. WHEN co_log-error. FORMAT COLOR COL_NEGATIVE. ENDCASE. ULINE. WRITE: sy-vline, (76) uv_msg CENTERED, sy-vline. ULINE. FORMAT COLOR OFF. ENDFORM. "print_header *&---------------------------------------------------------------------* *& Form print_log *&---------------------------------------------------------------------* FORM print_log USING uv_count TYPE n. WRITE: 'Processed message logs:'(m01), uv_count. ULINE. ENDFORM. "print_log *&---------------------------------------------------------------------* *& Form print_success *&---------------------------------------------------------------------* FORM print_success USING ut_payload TYPE zsxmb_moni_data_tab. DATA lv_count TYPE n LENGTH 5. lv_count = LINES( ut_payload ). PERFORM print_header USING 'Records successfully saved.'(m02) co_log-success. PERFORM print_log USING lv_count.

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

Page 16: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

ENDFORM. "print_success *&---------------------------------------------------------------------* *& Form print_overwrite *&---------------------------------------------------------------------* FORM print_overwrite USING uv_count TYPE n. IF p_wri IS INITIAL. PERFORM print_header USING 'Records not saved.'(m03) co_log-warning. ELSE. PERFORM print_header USING 'Records overwriten.'(m04) co_log-warning. ENDIF. PERFORM print_log USING uv_count. ENDFORM. "print_overwrite

Running the Program

When you run the program will be showed the following selection screen:

And when the program finishes running will be showed the following report:

This is a simple report that only saves the data in the transparent table ZSXMB_MONI and shows a summary log (I created this one to run in a job to get monitoring messages in a scheduled time – acting like an archiving job).

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

Page 17: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

Application to Shows the Fetched Monitoring Messages This application is composed by two reports:

• The first one reads the transparent table ZSMXB_MONI and shows the data in an ALV table.

• When you double click one of the monitoring messages displayed it calls the report ZSXMB_MONI_PAYLOAD that shows the payload related to the message in a HTML viewer control.

Source Code

Program ZSXMB_MONI_VIEWER

*&---------------------------------------------------------------------* *& Report ZSXMB_MONI_VIEWER *&---------------------------------------------------------------------* REPORT zsxmb_moni_viewer. TYPE-POOLS: abap, slis. CONSTANTS: lco_bar TYPE c LENGTH 1 VALUE '/', BEGIN OF co_log, error TYPE symsgty VALUE 'E', END OF co_log. TYPES: BEGIN OF ty_zsxmb_moni, msgguid TYPE zsxmb_moni-msgguid, pid TYPE zsxmb_moni-pid, ob_system TYPE zsxmb_moni-ob_system, ob_ns TYPE zsxmb_moni-ob_ns, ob_name TYPE zsxmb_moni-ob_name, ib_system TYPE zsxmb_moni-ib_system, ib_ns TYPE zsxmb_moni-ib_ns, ib_name TYPE zsxmb_moni-ib_name, msgstate TYPE zsxmb_moni-msgstate, exetimest TYPE zsxmb_moni-exetimest, adminuser TYPE zsxmb_moni-adminuser, END OF ty_zsxmb_moni, ty_t_zsxmb_moni TYPE SORTED TABLE OF ty_zsxmb_moni WITH NON-UNIQUE KEY msgguid pid, ty_t_output TYPE STANDARD TABLE OF zsxmb_moni_output WITH NON-UNIQUE KEY msgdate msgtime msgguid pid. DATA: gt_zsxmb_moni TYPE ty_t_zsxmb_moni, gt_output TYPE ty_t_output, gv_error TYPE c LENGTH 1. SELECTION-SCREEN BEGIN OF BLOCK bl01 WITH FRAME. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (29) text-c01 FOR FIELD p_exedat. PARAMETERS p_exedat TYPE dats OBLIGATORY. SELECTION-SCREEN COMMENT 44(2) co_bar FOR FIELD p_exetim. PARAMETERS p_exetim TYPE tims OBLIGATORY. SELECTION-SCREEN END OF LINE.

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

Page 18: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT (29) text-c02 FOR FIELD p_exe2da. PARAMETERS p_exe2da TYPE dats OBLIGATORY. SELECTION-SCREEN COMMENT 44(2) co_bar1 FOR FIELD p_exe2ti. PARAMETERS p_exe2ti TYPE tims OBLIGATORY. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK bl01. INITIALIZATION. co_bar = lco_bar. co_bar1 = lco_bar. p_exedat = sy-datum. p_exe2da = sy-datum + 1. START-OF-SELECTION. PERFORM validate_date. CHECK gv_error IS INITIAL. PERFORM main. *&---------------------------------------------------------------------* *& Form validate_date *&---------------------------------------------------------------------* FORM validate_date. DATA: lv_exedat TYPE timestampl, lv_exe2dat TYPE timestampl. CONVERT: DATE p_exedat TIME p_exetim INTO TIME STAMP lv_exedat TIME ZONE sy-zonlo, DATE p_exe2da TIME p_exe2ti INTO TIME STAMP lv_exe2dat TIME ZONE sy-zonlo. IF lv_exedat >= lv_exe2dat. MESSAGE i055(xms_adm) DISPLAY LIKE co_log-error. gv_error = '1'. ENDIF. ENDFORM. "validate_date *&---------------------------------------------------------------------* *& Form main *&---------------------------------------------------------------------* FORM main. DATA: lt_fieldcat TYPE slis_t_fieldcat_alv, lt_sort TYPE slis_t_sortinfo_alv, lt_excluding TYPE slis_t_extab, ls_layout TYPE slis_layout_alv. PERFORM select_data. IF gt_zsxmb_moni IS NOT INITIAL. PERFORM process_data. PERFORM prepare_field_catalog CHANGING lt_fieldcat. PERFORM prepare_sort_criteria CHANGING lt_sort. PERFORM prepare_pf_status CHANGING lt_excluding. PERFORM prepare_layout CHANGING ls_layout. PERFORM show_alv_grid USING lt_fieldcat lt_sort

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

Page 19: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

lt_excluding ls_layout. ENDIF. ENDFORM. "main *&---------------------------------------------------------------------* *& Form select_data *&---------------------------------------------------------------------* FORM select_data. DATA: lv_exedat TYPE timestampl, lv_exe2dat TYPE timestampl. CONVERT: DATE p_exedat TIME p_exetim INTO TIME STAMP lv_exedat TIME ZONE sy-zonlo, DATE p_exe2da TIME p_exe2ti INTO TIME STAMP lv_exe2dat TIME ZONE sy-zonlo. SELECT msgguid pid ob_system ob_ns ob_name ib_system ib_ns ib_name msgstate exetimest adminuser FROM zsxmb_moni INTO TABLE gt_zsxmb_moni WHERE exetimest BETWEEN lv_exedat AND lv_exe2dat. IF gt_zsxmb_moni IS INITIAL. MESSAGE i007(sabapdocu) DISPLAY LIKE co_log-error. ENDIF. ENDFORM. "select_data *&---------------------------------------------------------------------* *& Form process_data *&---------------------------------------------------------------------* FORM process_data. DATA: lr_zsxmb_moni TYPE REF TO ty_zsxmb_moni, ls_output LIKE LINE OF gt_output. LOOP AT gt_zsxmb_moni REFERENCE INTO lr_zsxmb_moni. CLEAR ls_output. ls_output-msgguid = lr_zsxmb_moni->msgguid. ls_output-pid = lr_zsxmb_moni->pid. ls_output-ob_system = lr_zsxmb_moni->ob_system. ls_output-ob_ns = lr_zsxmb_moni->ob_ns. ls_output-ob_name = lr_zsxmb_moni->ob_name. ls_output-ib_system = lr_zsxmb_moni->ib_system. ls_output-ib_ns = lr_zsxmb_moni->ib_ns. ls_output-ib_name = lr_zsxmb_moni->ib_name. ls_output-adminuser = lr_zsxmb_moni->adminuser. CONVERT TIME STAMP lr_zsxmb_moni->exetimest TIME ZONE sy-zonlo INTO DATE ls_output-msgdate TIME ls_output-msgtime. PERFORM get_msgstat_icon USING lr_zsxmb_moni->msgstate CHANGING ls_output-msgstate. APPEND ls_output TO gt_output. ENDLOOP. ENDFORM. "process_data

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

Page 20: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

*&---------------------------------------------------------------------* *& Form get_msgstat_icon *&---------------------------------------------------------------------* FORM get_msgstat_icon USING uv_msgstate TYPE sxmspmstat CHANGING cv_icon TYPE sxms_stast_icon. DATA: lt_sxmsmstat TYPE sxmsmstat_attr_t, lr_sxmsmstat TYPE REF TO sxmsmstat_attr. CHECK uv_msgstate IS NOT INITIAL. CALL FUNCTION 'SXMB_GET_STATUS_ATTRIBUTES' EXPORTING im_langu = sy-langu im_msgstate = uv_msgstate im_icon_convert = space IMPORTING ex_msgstate_attr = lt_sxmsmstat EXCEPTIONS msgstate_not_found = 1 OTHERS = 2. IF sy-subrc <> 0. "#EC NEEDED ENDIF. READ TABLE lt_sxmsmstat INDEX 1 REFERENCE INTO lr_sxmsmstat. IF lr_sxmsmstat IS NOT INITIAL. cv_icon = lr_sxmsmstat->icon_id. ENDIF. ENDFORM. "get_msgstat_icon *&---------------------------------------------------------------------* *& Form prepare_field_catalog *&---------------------------------------------------------------------* FORM prepare_field_catalog CHANGING ct_fieldcat TYPE slis_t_fieldcat_alv. CONSTANTS: lco_structure TYPE dd02l-tabname VALUE 'ZSXMB_MONI_OUTPUT', BEGIN OF lco_fieldname, pid TYPE slis_fieldcat_alv-fieldname VALUE 'PID', msgdate TYPE slis_fieldcat_alv-fieldname VALUE 'MSGDATE', msgtime TYPE slis_fieldcat_alv-fieldname VALUE 'MSGTIME', END OF lco_fieldname. DATA lr_fieldcat TYPE REF TO slis_fieldcat_alv. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_structure_name = lco_structure CHANGING ct_fieldcat = ct_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. "#EC NEEDED

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

Page 21: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

ENDIF. LOOP AT ct_fieldcat REFERENCE INTO lr_fieldcat. CASE lr_fieldcat->fieldname. WHEN lco_fieldname-pid. lr_fieldcat->no_out = abap_true. WHEN lco_fieldname-msgdate. lr_fieldcat->reptext_ddic = 'Execution Date'(h01). WHEN lco_fieldname-msgtime. lr_fieldcat->reptext_ddic = 'Execution Time'(h02). ENDCASE. ENDLOOP. ENDFORM. "prepare_field_catalog *&---------------------------------------------------------------------* *& Form prepare_sort_criteria *&---------------------------------------------------------------------* FORM prepare_sort_criteria CHANGING ct_sort TYPE slis_t_sortinfo_alv. CONSTANTS: BEGIN OF lco_fieldname, tabname TYPE slis_tabname VALUE 'GT_OUTPUT', date TYPE slis_fieldname VALUE 'MSGDATE', time TYPE slis_fieldname VALUE 'MSGTIME', END OF lco_fieldname. DATA ls_sort LIKE LINE OF ct_sort. ls_sort-fieldname = lco_fieldname-date. ls_sort-tabname = lco_fieldname-tabname. APPEND ls_sort TO ct_sort. ls_sort-fieldname = lco_fieldname-time. ls_sort-tabname = lco_fieldname-tabname. APPEND ls_sort TO ct_sort. ENDFORM. "prepare_sort_criteria *&---------------------------------------------------------------------* *& Form prepare_pf_status *&---------------------------------------------------------------------* FORM prepare_pf_status CHANGING ct_excluding TYPE slis_t_extab. CONSTANTS: BEGIN OF lco_excluding, total TYPE slis_extab-fcode VALUE '&UMC', preview TYPE slis_extab-fcode VALUE '&RNT_PREV', excel TYPE slis_extab-fcode VALUE '&VEXCEL', text TYPE slis_extab-fcode VALUE '&AQW', local TYPE slis_extab-fcode VALUE '%PC', mail TYPE slis_extab-fcode VALUE '%SL', graph TYPE slis_extab-fcode VALUE '&GRAPH', layout TYPE slis_extab-fcode VALUE '&OL0', info TYPE slis_extab-fcode VALUE '&INFO', END OF lco_excluding. DATA ls_excluding LIKE LINE OF ct_excluding. ls_excluding-fcode = lco_excluding-total. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-preview.

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

Page 22: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-excel. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-text. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-local. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-mail. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-graph. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-layout. APPEND ls_excluding TO ct_excluding. ls_excluding-fcode = lco_excluding-info. APPEND ls_excluding TO ct_excluding. ENDFORM. "prepare_pf_status *&---------------------------------------------------------------------* *& Form prepare_layout *&---------------------------------------------------------------------* FORM prepare_layout CHANGING cs_layout TYPE slis_layout_alv. cs_layout-colwidth_optimize = abap_true. cs_layout-zebra = abap_true. ENDFORM. "prepare_layout *&---------------------------------------------------------------------* *& Form show_alv_grid *&---------------------------------------------------------------------* FORM show_alv_grid USING ut_fieldcat TYPE slis_t_fieldcat_alv ut_sort TYPE slis_t_sortinfo_alv ut_excluding TYPE slis_t_extab us_layout TYPE slis_layout_alv. CONSTANTS lco_user_command TYPE slis_formname VALUE 'USER_COMMAND'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid i_callback_user_command = lco_user_command is_layout = us_layout it_fieldcat = ut_fieldcat it_excluding = ut_excluding it_sort = ut_sort TABLES t_outtab = gt_output EXCEPTIONS program_error = 1 OTHERS = 2. IF sy-subrc <> 0. "#EC NEEDED ENDIF. ENDFORM. "show_alv_grid *&---------------------------------------------------------------------* *& Form user_command *&---------------------------------------------------------------------* FORM user_command USING r_ucomm TYPE sy-ucomm rs_selfield TYPE slis_selfield. "#EC CALLED

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

Page 23: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

CONSTANTS lco_dclick LIKE r_ucomm VALUE '&IC1'. CASE r_ucomm. WHEN lco_dclick. PERFORM show_payload USING rs_selfield-tabindex. ENDCASE. ENDFORM. "user_command *&---------------------------------------------------------------------* *& Form show_payload *&---------------------------------------------------------------------* FORM show_payload USING uv_index TYPE slis_selfield-tabindex. CONSTANTS: BEGIN OF lco_rsparam, p TYPE rsparams-kind VALUE 'P', msgguid TYPE rsparams-selname VALUE 'P_MSGGUI', pid TYPE rsparams-selname VALUE 'P_PID', END OF lco_rsparam. DATA: lr_output TYPE REF TO zsxmb_moni_output, lr_zsxmb_moni TYPE REF TO ty_zsxmb_moni, lt_rsparam TYPE rsparams_tt, ls_rsparam LIKE LINE OF lt_rsparam. IF uv_index IS INITIAL. RETURN. ENDIF. READ TABLE gt_output INDEX uv_index REFERENCE INTO lr_output. IF lr_output IS NOT INITIAL. READ TABLE gt_zsxmb_moni WITH TABLE KEY msgguid = lr_output->msgguid pid = lr_output->pid REFERENCE INTO lr_zsxmb_moni. CLEAR lr_output. ENDIF. IF lr_zsxmb_moni IS NOT INITIAL. ls_rsparam-selname = lco_rsparam-msgguid. ls_rsparam-kind = lco_rsparam-p. ls_rsparam-low = lr_zsxmb_moni->msgguid. APPEND ls_rsparam TO lt_rsparam. ls_rsparam-selname = lco_rsparam-pid. ls_rsparam-kind = lco_rsparam-p. ls_rsparam-low = lr_zsxmb_moni->pid. APPEND ls_rsparam TO lt_rsparam. SUBMIT zsxmb_moni_payload WITH SELECTION-TABLE lt_rsparam AND RETURN. ENDIF. ENDFORM. "show_payload

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

Page 24: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

Program ZSXMB_MONI_PAYLOAD

This program is composed by one screen that has a container used to shows the HTML viewer control. In the next pictures is showed all the necessary information to create the screen in the screen painter (SE51).

Screen Attributes

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

Page 25: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

GUI Title

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

Page 26: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

GUI Status

And above you can see the source code for the payload viewer program:

*&---------------------------------------------------------------------* *& Report ZSXMB_MONI_PAYLOAD *&---------------------------------------------------------------------* REPORT zsxmb_moni_payload. CONSTANTS: BEGIN OF co_log, error TYPE symsgty VALUE 'E', END OF co_log, BEGIN OF co_code, back TYPE sy-ucomm VALUE 'BACK', canc TYPE sy-ucomm VALUE 'CANC', exit TYPE sy-ucomm VALUE 'EXIT', END OF co_code. TYPES: BEGIN OF ty_zsxmb_moni, msgguid TYPE zsxmb_moni-msgguid, pid TYPE zsxmb_moni-pid, payload TYPE zsxmb_moni-payload, END OF ty_zsxmb_moni. DATA: gs_zsxmb_moni TYPE ty_zsxmb_moni, ok_code TYPE sy-ucomm, gr_container TYPE REF TO cl_gui_custom_container, gr_html_viewer TYPE REF TO cl_gui_html_viewer. SELECTION-SCREEN BEGIN OF BLOCK bl01 WITH FRAME. PARAMETERS: p_msggui TYPE zsxmb_moni-msgguid OBLIGATORY, p_pid TYPE zsxmb_moni-pid OBLIGATORY. SELECTION-SCREEN END OF BLOCK bl01. START-OF-SELECTION. PERFORM select_data. IF gs_zsxmb_moni IS NOT INITIAL. CALL SCREEN 100. ENDIF. *&---------------------------------------------------------------------* *& Form select_data *&---------------------------------------------------------------------*

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

Page 27: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

FORM select_data. SELECT SINGLE msgguid pid payload FROM zsxmb_moni INTO gs_zsxmb_moni where msgguid = p_msggui and pid = p_pid. IF gs_zsxmb_moni IS INITIAL. MESSAGE i007(sabapdocu) DISPLAY LIKE co_log-error. ENDIF. ENDFORM. "select_data *----------------------------------------------------------------------* * MODULE status_0100 OUTPUT *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS '100'. SET TITLEBAR '100'. ENDMODULE. "status_0100 OUTPUT *----------------------------------------------------------------------* * MODULE pbo_0100 OUTPUT *----------------------------------------------------------------------* MODULE pbo_0100 OUTPUT. PERFORM create_objects. PERFORM show_url. ENDMODULE. "pbo_0100 OUTPUT *----------------------------------------------------------------------* * MODULE user_command_0100 INPUT *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. CASE ok_code. WHEN co_code-back OR co_code-canc OR co_code-exit. gr_html_viewer->free( ). gr_container->free( ). LEAVE PROGRAM. ENDCASE. ENDMODULE. "user_command_0100 INPUT *&---------------------------------------------------------------------* *& Form create_objects *&---------------------------------------------------------------------* FORM create_objects. IF gr_container IS NOT BOUND. CREATE OBJECT gr_container EXPORTING container_name = 'CC_WDA'. CREATE OBJECT gr_html_viewer EXPORTING parent = gr_container EXCEPTIONS cntl_error = 1 cntl_install_error = 2 dp_install_error = 3 dp_error = 4. IF sy-subrc = 0. cl_gui_cfw=>flush( ).

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

Page 28: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

ENDIF. ENDIF. ENDFORM. "create_objects *&---------------------------------------------------------------------* *& Form show_url *&---------------------------------------------------------------------* FORM show_url. CONSTANTS: lco_type TYPE c LENGTH 50 VALUE 'application', lco_subtype TYPE c LENGTH 50 VALUE 'octet-stream', lco_512 TYPE i VALUE 512. DATA: lv_length TYPE i, lv_len TYPE i, lv_offset TYPE i, lv_len_tmp TYPE i, lv_url TYPE c LENGTH 255, lt_raw_lines TYPE sxmsraw512lines, ls_raw_line LIKE LINE OF lt_raw_lines. lv_length = XSTRLEN( gs_zsxmb_moni-payload ). lv_len = lv_length. lv_offset = 0. lv_len_tmp = lv_len. IF lv_len_tmp > lco_512. DO. ls_raw_line = gs_zsxmb_moni-payload+lv_offset(lco_512). APPEND ls_raw_line TO lt_raw_lines. lv_offset = lv_offset + lco_512. lv_len_tmp = lv_len_tmp - lco_512. IF lv_len_tmp < lco_512. EXIT. ENDIF. ENDDO. ENDIF. IF lv_len_tmp > 0. ls_raw_line = gs_zsxmb_moni-payload+lv_offset(lv_len_tmp). APPEND ls_raw_line TO lt_raw_lines. ENDIF. gr_html_viewer->load_data( EXPORTING type = lco_type subtype = lco_subtype size = lv_length IMPORTING assigned_url = lv_url CHANGING data_table = lt_raw_lines EXCEPTIONS dp_invalid_parameter = 1 dp_error_general = 2

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

Page 29: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

cntl_error = 3 OTHERS = 4 ). IF sy-subrc <> 0. "#EC NEEDED ENDIF. gr_html_viewer->show_url( url = lv_url ). ENDFORM. "show_url

Running the Viewer

When you run the application you’ll get the following selection screen:

After enter the data in the selection screen you’ll get the following report:

And after double click one of the messages will be called the program ZSXMB_MONI_PAYLOAD that will shows the payload like follows:

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

Page 30: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

Related Content Exposing the XI monitoring functionality as a Web Service

Finding the PI message with NF-e Access Key

Interesting ABAP tables in XI

RFC programming in ABAP

HTML viewer control

For more information, visit the ABAP homepage.

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

Page 31: PI Monitoring Functionality – Fetching Data from SXMB_MONI Standard Tables

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 31

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.