背景
查问题时要根据关键词定位PO消息ID,而用SXI_MONITOR直接查不方便,尤其是数据多的时候。所以写了段小程序,根据关键词和查询条件直接定位,省点事~。
选择屏幕
条件可以根据需要自行添加。
查找结果
源码
REPORT zfind_keyword_in_payload.
TABLES:
sxmspmast.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) t1 FOR FIELD begda.
PARAMETERS: begda TYPE sy-datum DEFAULT sy-datum.
SELECTION-SCREEN COMMENT 48(2) t2 FOR FIELD begti.
PARAMETERS: begti TYPE sy-uzeit.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (33) t3 FOR FIELD endda.
PARAMETERS: endda TYPE sy-datum DEFAULT sy-datum.
SELECTION-SCREEN COMMENT 48(2) t4 FOR FIELD endti.
PARAMETERS: endti TYPE sy-uzeit DEFAULT '235959'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
PARAMETERS key_word TYPE c LENGTH 100.
SELECT-OPTIONS stamp FOR sxmspmast-inittimest NO-DISPLAY.
INITIALIZATION.
t1 = `起始日期/时间`.
t2 = `/`.
t3 = `截止日期/时间`.
t4 = `/`.
START-OF-SELECTION.
PERFORM process_data.
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_data .
DATA ls_messagekey TYPE sxmsmkey.
DATA lv_payload_size TYPE sxms_payload_size.
DATA lv_version_type TYPE sxms_versiontype.
DATA lv_version_request TYPE sxmslsqnbr.
DATA lt_messagepayload TYPE sxms_messagepayload_tab.
DATA xpl TYPE xstring.
DATA xml TYPE string.
DATA lv_length TYPE i.
DATA lt_cntbin TYPE sdokcntbins.
CONVERT DATE begda TIME begti INTO TIME STAMP DATA(low) TIME ZONE sy-zonlo.
CONVERT DATE endda TIME endti INTO TIME STAMP DATA(high) TIME ZONE sy-zonlo.
stamp[] = VALUE #( ( sign = `I` option = `BT` low = low high = high ) ).
SELECT *
INTO TABLE @DATA(lt_sxmspmast)
FROM sxmspmast
WHERE inittimest IN @stamp[].
LOOP AT lt_sxmspmast INTO DATA(ls_sxmspmast).
CLEAR ls_messagekey.
ls_messagekey-msgid = ls_sxmspmast-msgguid.
ls_messagekey-pid = ls_sxmspmast-pid.
lv_payload_size = ls_sxmspmast-msg_size .
CLEAR lt_messagepayload[].
CALL FUNCTION 'SXMB_READ_MESSAGE_VERSION_RAW'
EXPORTING
selection = 1
messagekey = ls_messagekey
version_request = lv_version_request
versiontype = lv_version_type
max_payload_size = lv_payload_size
IMPORTING
messagepayload = lt_messagepayload.
CHECK lt_messagepayload[] IS NOT INITIAL.
xpl = lt_messagepayload[ 1 ]-payload.
CLEAR lt_cntbin.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = xpl
IMPORTING
output_length = lv_length
TABLES
binary_tab = lt_cntbin.
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = lv_length
IMPORTING
text_buffer = xml
TABLES
binary_tab = lt_cntbin.
IF xml CS key_word.
WRITE: / ls_sxmspmast-msgguid.
ENDIF.
ENDLOOP.
ENDFORM.