注:此版本中修正了不能根据发送方 Sending System \ Outbound Interface Name ,接收方 Receiving System Inbound Interface Name 进行查询,初步测试通过,欢迎PI爱好者进行完善。
*&---------------------------------------------------------------------*
*& http://www.cnblogs.com/byfhd/
*& 通过值查询message,给定值查询message payload
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Report ZPMONITOR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPMONITOR.
tables: sxmspmast,SXMSPEMAS.
data:
BEGIN OF clustkey,
msgguid TYPE SXMSMGUID,
pid TYPE sxmspid,
vers TYPE sxmslsqnbr,
END OF clustkey,
wa_clur type sxmsclur,
stringa type string,
xstringa type xstring,
keytable like clustkey occurs 0 with header line,
attachname type string.
DATA: persist TYPE REF TO cl_xms_persist.
data: clmess type ref to cl_abap_expimp_db.
DATA DIRTAB1 LIKE CDIR OCCURS 10 WITH HEADER LINE.
DATA: g_sxmspmast TYPE sxmspmast,
g_sxmspvers TYPE sxmspvers,
g_sxmspprop TYPE sxmspprop,
g_sxmspres TYPE sxmspres,
g_sxmspxres TYPE sxmspxres,
g_sxmspns TYPE sxmspns,
g_sxmsppropv TYPE sxmsppropv,
g_sxmspresv TYPE sxmspresv,
g_sxmspxresv TYPE sxmspxresv,
g_sxmspnsv TYPE sxmspnsv,
g_verstab TYPE sxmsvlst,
g_pel TYPE sxmsplelt,
g_msgtab TYPE sxmsmsglst.
DATA: gt_sxmspprop TYPE sxmstprop,
gt_sxmspres TYPE sxmstres,
gt_sxmspxres TYPE sxmstxres,
gt_sxmspns TYPE sxmstns,
gt_sxmspvers TYPE STANDARD TABLE OF sxmspvers,
gt_sxmsppropv TYPE STANDARD TABLE OF sxmsppropv,
gt_sxmspresv TYPE STANDARD TABLE OF sxmspresv,
gt_sxmspxresv TYPE STANDARD TABLE OF sxmspxresv,
gt_sxmspnsv TYPE STANDARD TABLE OF sxmspnsv,
gt_verstab TYPE sxmsvtab,
gt_pel TYPE TABLE OF sxmsplelt,
gt_msgtab TYPE sxmsmsgtab.
DATA: gt_master TYPE sxmsmsgtab,
oref type ref to cx_root.
DATA: g_message TYPE REF TO if_xms_message,
res type ref to if_xms_resource,
props type ref to SXMS_PRO_T,
prop type ref to SXMS_PRO_S.
DATA: timestampfrom TYPE timestampl,
timestampto type timestampl,
dat TYPE d,
tim TYPE t,
tz TYPE ttzz-tzone,
versprogr(3) type n,
condtion type string.
ranges: r_msgguid for sxmspmast-msgguid.
parameters: datefrom type datum,
timefrom type uzeit,
dateto type datum,
timeto type uzeit,
SendSys type AIT_SNDR,
ObdName type RM_OIFNAME,
RecSys type AIT_RCVR,
IbdName type RM_IIFNAME,
search type char50.
tz = 'CET'.
CONVERT DATE datefrom TIME timefrom DAYLIGHT SAVING TIME 'X'
INTO TIME STAMP timestampfrom TIME ZONE tz.
CONVERT DATE dateto TIME timeto DAYLIGHT SAVING TIME 'X'
INTO TIME STAMP timestampto TIME ZONE tz.
condtion = 'exetimest between timestampfrom and timestampto'.
IF SendSys <> ''.
CONCATENATE condtion ' and b~OB_SYSTEM eq ''' SendSys ''''INTO condtion.
ENDIF.
IF ObdName <> ''.
CONCATENATE condtion ' and b~OB_NAME eq ''' ObdName '''' INTO condtion.
ENDIF.
IF ObdName <> ''.
CONCATENATE condtion ' and b~IB_SYSTEM eq ''' RecSys '''' INTO condtion.
ENDIF.
IF ObdName <> ''.
CONCATENATE condtion ' and b~IB_NAME eq ''' IbdName '''' INTO condtion.
ENDIF.
select * from sxmspmast as a INNER JOIN SXMSPEMAS as b
ON a~MSGGUID eq b~MSGGUID
appending corresponding fields of table
keytable where (condtion) ."exetimest between timestampfrom and timestampto
"and b~OB_SYSTEM eq SendSys ."and b~OB_NAME eq ObdName
"and b~IB_SYSTEM eq RecSys and b~IB_NAME eq IbdName.
create object persist.
loop at keytable.
clustkey-msgguid = keytable-msgguid.
clustkey-pid = keytable-pid.
clustkey-vers = keytable-vers.
versprogr = 000.
do keytable-vers times.
versprogr = versprogr + 1.
TRY.
CALL METHOD persist->read_persist_tab_all_pub
* call method persist->read_persist_tab_version
EXPORTING
im_msgguid = clustkey-msgguid
im_pid = clustkey-pid
im_version = versprogr
IMPORTING
ex_pmast = g_sxmspmast
ex_pvers = g_sxmspvers
ex_tprop = gt_sxmspprop
ex_tres = gt_sxmspres
ex_txres = gt_sxmspxres
ex_tns = gt_sxmspns.
CATCH cx_xms_syserr_persist INTO oref.
MESSAGE oref type 'S' display like 'E'.
exit.
ENDTRY.
TRY.
CALL METHOD persist->built_msg
EXPORTING
im_pmast = g_sxmspmast
im_tprop = gt_sxmspprop
im_tres = gt_sxmspres
im_txres = gt_sxmspxres
im_tns = gt_sxmspns
IMPORTING
ex_message = g_message.
clear res.
call method g_message->GETATTACHMENTatindex
EXPORTING
index = 1
RECEIVING
resource = res.
if res is initial. continue. endif.
call method res->getbinarydata
RECEIVING
data = xstringa.
data partutil type ref to cl_xms_part_util.
partutil = cl_xms_part_util=>getInstance( ).
data l_conttypeobj type ref to cl_xms_contenttype.
create object l_conttypeobj.
l_conttypeobj->valuesFromString( values = 'T' ).
data l_mimetype type string.
l_mimetype = l_conttypeobj->getMIMEType( ).
data l_charset type string.
l_charset = l_conttypeobj->getCharset( ).
try.
stringa = partutil->convert_xstring_to_string( charset = l_charset
in = xstringa ).
if stringa cs search.
r_msgguid-low = keytable-msgguid.
r_msgguid-sign = 'I'.
r_msgguid-option = 'EQ'.
append r_msgguid.
exit.
endif.
catch cx_xms_exception.
* unfortunately this exception is not declared for this method and
*cannot be thrown further
endtry.
* string_data = props->writetoxmlstring( external = false ).
CATCH cx_xms_exception INTO oref.
message oref type 'S' display like 'E'.
exit.
CATCH cx_xms_system_error INTO oref.
message oref type 'S' display like 'E'.
exit.
ENDTRY.
enddo.
endloop.
if not r_msgguid is initial.
submit RSXMB_SELECT_MESSAGES
with msgguid in r_msgguid and return.
endif.