在接口的处理中通常会需要记录日志,而如果是与PO(PI,XI)做的接口的话,可以使用事务码SXI_MONITOR – XI:消息监控,来查询日志,但对于一些有加密,或者在业务接口功能上想直接查询报文日志时,会在ECC中创建一个表来记录报文日志信息,以下是一个调用PI的接口,调用完成后,把PI接口的MESSAGE_ID记录到表中,这样可以通过表中记录的MESSAGE_ID来直接打开PI日志。同时由于发送的报文是加密的,所以把发送前未加密的报文,及收到的解密 后的报文保存到日志表中。最后使用一个程序来显示 日志,
1.日志记录
调用接口后,记录日志,以下是一个调用接口,有加解密,
FUNCTION ZFM_TR_GYLJY_LYR_PTFW.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(IV_DATUM1) TYPE DATUM OPTIONAL
*" VALUE(IV_DATUM2) TYPE DATUM OPTIONAL
*" EXPORTING
*" REFERENCE(EV_DATA) TYPE ZTRS_G13_OUT
*"----------------------------------------------------------------------DATA: LR_SENDER TYPE REF TO ZTR_CO_SI_RTR_LYRPLAT_FEE_INFO,LS_OUTPUT TYPE ZMT_LYRINFO_REQ,LS_MESSAGEOUT TYPE ZDT_LYRINFO_REQ_IS_MESSAGE,LS_INPUT TYPE ZMT_LYRINFO_RESP,LS_MESSAGEIN TYPE ZDT_LYRINFO_RESP_ES_MESSAGE,LR_SYS_EXCEPTION TYPE REF TO CX_AI_SYSTEM_FAULT,LV_DATA TYPE STRING,LV_KEY64 TYPE STRING,LV_JAVA_TIMESTAMP TYPE STRING,LV_SIGNED_DATASTR TYPE STRING.DATA: LV_JSON TYPE STRING,LV_TEXT TYPE STRING,LV_DOCNO TYPE STRING,LV_SERIAL TYPE STRING.DATA: LV_MSG TYPE STRING,LR_CXSYS_EXCEPTION TYPE REF TO CX_AI_SYSTEM_FAULT,LR_CXAPP_FAULT TYPE REF TO CX_AI_APPLICATION_FAULT.DATA: BEGIN OF LS_LIST,CASHAPPLYID TYPE STRING, "融资申请编号SEDCOMPANYNAME TYPE STRING, "融资申请企业名称BOSCPAYAPPROVENO TYPE STRING, "付款审批单编号PLATFEERATE TYPE STRING, "平台手续费率PLATFEE TYPE STRING, "平台手续费CASHPLATFEEMODE TYPE STRING, "平台服务费收取方式CASHPLATFEEPAYDATE TYPE STRING, "平台服务费付费时间CASHPLATFEEPAYSTATE TYPE STRING, "平台服务费支付状态END OF LS_LIST.DATA: BEGIN OF LS_DATA,MSG TYPE STRING,CODE TYPE STRING,DATA LIKE TABLE OF LS_LIST,END OF LS_DATA.DATA: LS_DATA_LIST LIKE ZTRS_G13_LIST.DATA LS_3000 TYPE ZTRGYLT3000.DATA:L_TIME_STAMP TYPE TIMESTAMPL,LS_TIME_STAMP TYPE CHAR100.DATA: L_GYLJKBM TYPE ZTR_GYLJKBM VALUE 'SFP0213'.DATA: L_DATUM1 TYPE DATUM,L_DATUM2 TYPE DATUM,LC_DATUM1 TYPE CHAR10,LC_DATUM2 TYPE CHAR10.CLEAR: EV_DATA.L_DATUM1 = IV_DATUM1.L_DATUM2 = IV_DATUM2.IF L_DATUM1 IS INITIAL.L_DATUM1 = SY-DATUM.ENDIF.IF L_DATUM2 IS INITIAL.L_DATUM2 = L_DATUM1.ENDIF.LC_DATUM1 = L_DATUM1(4) && '-' && L_DATUM1+4(2) && '-' && L_DATUM1+6(2).LC_DATUM2 = L_DATUM2(4) && '-' && L_DATUM2+4(2) && '-' && L_DATUM2+6(2).GET TIME STAMP FIELD L_TIME_STAMP.LS_TIME_STAMP = L_TIME_STAMP.CONDENSE LS_TIME_STAMP NO-GAPS.SELECT SINGLE * FROM ZTRGYLT3000 INTO LS_3000 WHERE PTBM = 'SFP02'.LV_SERIAL = 'PTFW' && LS_TIME_STAMP."LV_JSON = '{"beginPaymentTime":"' && LC_DATUM1 && '",' &&"放款日期起始时间'"endPaymentTime":"' && LC_DATUM2 && '"}'."放款日期截止时间*lv_docno = iv_docno.CALL FUNCTION 'ZFM_TR_GYLJY_LYR_ENCRYPT'EXPORTINGIV_DOCNO = LV_DOCNOIV_SERIAL = LV_SERIALIV_TEXT = LV_JSONIV_3000 = LS_3000IMPORTINGEV_TEXT = LV_DATAEV_KEY = LV_KEY64EV_TIMESTAMPL = LV_JAVA_TIMESTAMPEV_SIGNATURE = LV_SIGNED_DATASTR.LS_MESSAGEOUT-CHANNEL = LS_3000-APPKEY."'app'.LS_MESSAGEOUT-SERIAL_NO = LV_SERIAL.LS_MESSAGEOUT-DATA = LV_DATA.LS_MESSAGEOUT-KEY = LV_KEY64.LS_MESSAGEOUT-SIGNATURE = LV_SIGNED_DATASTR.LS_MESSAGEOUT-VERSION = LS_3000-VERSION."'1.0.0'.LS_MESSAGEOUT-TIMESTAMP = LV_JAVA_TIMESTAMP.LS_MESSAGEOUT-IS_PLAINTEXT = 'false'.LS_OUTPUT-MT_LYRINFO_REQ-IS_MESSAGE = LS_MESSAGEOUT.TRY.CREATE OBJECT LR_SENDER.CALL METHOD LR_SENDER->SI_RTR_LYRPLAT_FEE_INFO_OUT_SYEXPORTINGOUTPUT = LS_OUTPUTIMPORTINGINPUT = LS_INPUT.CATCH CX_AI_SYSTEM_FAULT INTO LR_CXSYS_EXCEPTION.LV_MSG = LR_CXSYS_EXCEPTION->GET_TEXT( ).CATCH CX_AI_APPLICATION_FAULT INTO LR_CXAPP_FAULT.LV_MSG = LR_CXAPP_FAULT->GET_TEXT( ).ENDTRY.LS_MESSAGEIN = LS_INPUT-MT_LYRINFO_RESP-ES_MESSAGE.IF LS_MESSAGEIN IS NOT INITIAL.CALL FUNCTION 'ZFM_TR_GYLJY_LYR_DECRYPT'EXPORTINGIV_TEXT = LS_MESSAGEIN-DATAIV_KEY = LS_MESSAGEIN-KEYIV_3000 = LS_3000IMPORTINGEV_MSG = LV_MSGEV_TEXT = LV_TEXT.IF LV_TEXT IS NOT INITIAL./UI2/CL_JSON=>DESERIALIZE( EXPORTING JSON = LV_TEXT
* pretty_name = /ui2/cl_json=>pretty_mode-camel_caseCHANGING DATA = LS_DATA ).EV_DATA-CODE = LS_DATA-CODE.EV_DATA-MSG = LS_DATA-MSG.LOOP AT LS_DATA-DATA INTO LS_LIST.LS_DATA_LIST-GYL_RZSQBH = LS_LIST-CASHAPPLYID . "融资申请编号LS_DATA_LIST-GYL_RZSQMC = LS_LIST-SEDCOMPANYNAME . "融资申请企业名称LS_DATA_LIST-DOCNO = LS_LIST-BOSCPAYAPPROVENO . "付款审批单编号LS_DATA_LIST-ZPTFL = LS_LIST-PLATFEERATE . "平台手续费率LS_DATA_LIST-ZPTFL = LS_DATA_LIST-ZPTFL * 100.LS_DATA_LIST-ZPTFY = LS_LIST-PLATFEE . "平台手续费LS_DATA_LIST-GLY_SQFS = LS_LIST-CASHPLATFEEMODE . "平台服务费收取方式LS_DATA_LIST-GYL_ZFZT = LS_LIST-CASHPLATFEEPAYSTATE . "平台服务费支付状态LC_DATUM1 = LS_LIST-CASHPLATFEEPAYDATE . "平台服务费付费时间YYYY-MMM-DDLS_DATA_LIST-GLY_FKDT = LC_DATUM1(4) && LC_DATUM1+5(2) && LC_DATUM1+8(2).APPEND LS_DATA_LIST TO EV_DATA-LIST.ENDLOOP.ENDIF.ENDIF.*--------------------------------------------------------------------*
* 接口日志数据存表
*获取PO MESSAGE IDDATA: LV_PO_MSGID TYPE SXMSGUID.DATA: LR_PROTOCOL_MESSAGEID TYPE REF TO IF_WSPROTOCOL_MESSAGE_ID.DATA: LV_MSGID TYPE ZIFT00090-MSGID,LV_T_SYSTEM TYPE C LENGTH 10 VALUE 'LYR'. "接收系统DATA: LS_LOG TYPE ZTRT00010,LT_LOG TYPE TABLE OF ZTRT00010.TRY .LR_PROTOCOL_MESSAGEID ?= LR_SENDER->GET_PROTOCOL( IF_WSPROTOCOL=>MESSAGE_ID ).CATCH CX_AI_SYSTEM_FAULT INTO LR_SYS_EXCEPTION .ENDTRY.LV_PO_MSGID = LR_PROTOCOL_MESSAGEID->GET_MESSAGE_ID( ).LS_LOG-MSGID = LS_TIME_STAMP . " MSGIDLS_LOG-POMSGID = LV_PO_MSGID. "POMSGIDLS_LOG-IFNUM = L_GYLJKBM. "接口编号LS_LOG-IFTYP = 'PO'. "接口方式LS_LOG-IFDIR = 'OUTBOUND' . "接口方向LS_LOG-IFMODE = 'S' . "接口模式LS_LOG-T_SYSTEM_CODE = LV_T_SYSTEM . "接收系统LS_LOG-RECVTIME = SY-DATUM && SY-UZEIT. "返回时间LS_LOG-ZREDAT = SY-DATUM.LS_LOG-ZRETIM = SY-UZEIT.LS_LOG-ERNAM = SY-UNAME.LS_LOG-FILE_S = LV_JSON ."发出报文件LS_LOG-FILE_R = LV_TEXT ."收到报文LS_LOG-MESSAGE = LV_MSG.LS_LOG-IS_ENCRY = 'X'."加密IF EV_DATA-CODE = '200'.LS_LOG-STATUS = 'S'. "接口状态LS_LOG-BSTATUS = 'S'. "业务处理状态ELSE.LS_LOG-STATUS = 'E'.ENDIF.APPEND LS_LOG TO LT_LOG.*更新日志表IF LT_LOG[] IS NOT INITIAL.MODIFY ZTRT00010 FROM TABLE LT_LOG.IF SY-SUBRC = 0.COMMIT WORK AND WAIT.ELSE.ROLLBACK WORK.ENDIF.ENDIF.*--------------------------------------------------------------------*ENDFUNCTION.
2.显未来日志的处理程序,
*&*********************************************************************
*& PROGRAM NAME : ZIFR00010
*& Module Name :
*& Apply Author : XXX
*& Author :
*& Started on : %DATE%
*& Transaction : ZIF00030
*& Program type : Report
*& Program ID : ZIFR00010
*& Program Description : PO接口日志以及重处理功能
*&*&*******************************************************************
*& REVISION LOG *
*& *
*& LOG# DATE AUTHOR DESCRIPTION *
*& ---- ---- ------ ----------- *
*& 0001 XXXXXX XXX Initial Creation
*&*********************************************************************
REPORT ZTRE_GYLJR0010.TYPE-POOLS: SLIS.TABLES: ZIFT00010,ZSCUD_INFO.DATA: BEGIN OF GS_DATA.INCLUDE TYPE ZTRT00010.
DATA: BOX TYPE C LENGTH 1,DURTM TYPE ZIFS00010-DURTM,ZGYLJKT TYPE ZTR_GYLJKBMT,END OF GS_DATA,GT_DATA LIKE TABLE OF GS_DATA.*--------------------------------------------------------------------*
* SELECTION-SCREEN
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_IFNUM FOR ZIFT00010-IFNUM,S_IFTYP FOR ZIFT00010-IFTYP NO INTERVALS NO-EXTENSION DEFAULT 'PO',S_IFDIR FOR ZIFT00010-IFDIR , "DEFAULT 'INBOUND',S_IFMODE FOR ZIFT00010-IFMODE,S_STATUS FOR ZIFT00010-STATUS,S_BSTATU FOR ZIFT00010-BSTATUS,S_RDATE FOR ZSCUD_INFO-CDATE_CRE NO-EXTENSION OBLIGATORY,S_RTIME FOR ZSCUD_INFO-CTIME_CRE NO-EXTENSION OBLIGATORY.PARAMETERS: P_XVALUE TYPE TEXT256.
SELECTION-SCREEN END OF BLOCK BLK1.*--------------------------------------------------------------------*
* INITIALIZATION
*--------------------------------------------------------------------*
INITIALIZATION.REFRESH S_RDATE.S_RDATE = 'IBT'.S_RDATE-LOW = SY-DATUM.S_RDATE-HIGH = SY-DATUM.APPEND S_RDATE.REFRESH S_RTIME.S_RTIME = 'IBT'.S_RTIME-LOW = '000000'.S_RTIME-HIGH = '235959'.APPEND S_RTIME.*--------------------------------------------------------------------*
* AT SELECTION-SCREEN
*--------------------------------------------------------------------*
*& 选择屏幕控制
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_IFNUM-LOW.PERFORM FRM_ZIFNUM_F4.AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_IFNUM-HIGH.PERFORM FRM_ZIFNUM_F4.AT SELECTION-SCREEN.IF P_XVALUE IS NOT INITIAL AND S_IFNUM IS INITIAL .MESSAGE E000(ZIF01) WITH TEXT-010.ENDIF.*--------------------------------------------------------------------*
* START-OF-SELECTION
*--------------------------------------------------------------------*
START-OF-SELECTION."GET DATAPERFORM FRM_GET_DATA."ALVPERFORM FRM_SHOW_ALV.*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .DATA: LT_DATA LIKE TABLE OF GS_DATA.DATA: L_ZGYLJK TYPE ZTR_GYLJKBM.RANGES: LR_TIME FOR ZIFT00010-RECVTIME.LR_TIME = 'IBT'.LR_TIME-LOW = S_RDATE-LOW && S_RTIME-LOW.LR_TIME-HIGH = S_RDATE-HIGH && S_RTIME-HIGH.APPEND LR_TIME.SELECT *INTO TABLE @DATA(LT_ZTRGYLT2001)FROM ZTRGYLT2001."get dataSELECT * FROM ZTRT00010INTO CORRESPONDING FIELDS OF TABLE GT_DATAWHERE IFNUM IN S_IFNUMAND IFTYP IN S_IFTYPAND IFDIR IN S_IFDIRAND IFMODE IN S_IFMODEAND STATUS IN S_STATUSAND BSTATUS IN S_BSTATUAND RECVTIME IN LR_TIME."如果要根据业务数据对消息进行过滤IF P_XVALUE IS NOT INITIAL.DATA: LS_VERS TYPE SXMSPVERS,LT_VERS LIKE TABLE OF LS_VERS.DATA(LO_PERSIST) = NEW CL_XMS_PERSIST( ).LOOP AT GT_DATA INTO GS_DATA.IF GS_DATA-IS_ENCRY = ''."报文不加密.CLEAR: LT_VERS."get all versionSELECT MSGGUID PID VERSFROM SXMSPVERSINTO CORRESPONDING FIELDS OF TABLE LT_VERSWHERE MSGGUID = GS_DATA-POMSGID.IF SY-SUBRC = 0.LOOP AT LT_VERS INTO LS_VERS."read messageLO_PERSIST->READ_MSG_ALL(EXPORTINGIM_MSGGUID = LS_VERS-MSGGUIDIM_PID = LS_VERS-PIDIM_VERSION = LS_VERS-VERSIMPORTINGEX_MESSAGE = DATA(LO_XMS_MSG) ).LO_XMS_MSG->DELETEHEADERBYNAME(NSURI = IF_XMS_RUN_TIME_ENV=>CO_NSURILCNAME = IF_XMS_RUN_TIME_ENV=>CO_LCNAME )."get payloadDATA(LT_PAYLOAD) = CAST CL_XMS_MESSAGE_XMB( LO_XMS_MSG )->IF_XMS_MESSAGE_XMB~GET_MAIN_PAYLOADS( ).READ TABLE LT_PAYLOAD INTO DATA(LS_PAYLOAD) INDEX 1.IF SY-SUBRC EQ 0.DATA(LV_PAYLOAD) = VALUE STRING( )."decode payloadCL_ABAP_CONV_IN_CE=>CREATE(INPUT = LS_PAYLOAD-MAINPAYLOAD->GETBINARYCONTENT( )IGNORE_CERR = ABAP_TRUEENDIAN = 'B'ENCODING = 'UTF-8' )->READ(IMPORTINGDATA = LV_PAYLOAD )."search data in payloadSEARCH LV_PAYLOAD FOR P_XVALUE.IF SY-SUBRC = 0.APPEND GS_DATA TO LT_DATA.EXIT.ENDIF.ENDIF.ENDLOOP.ENDIF.ELSEIF GS_DATA-IS_ENCRY = 'X'."报文加密.SEARCH GS_DATA-FILE_S FOR P_XVALUE.IF SY-SUBRC = 0.APPEND GS_DATA TO LT_DATA.CONTINUE.ENDIF.SEARCH GS_DATA-FILE_R FOR P_XVALUE.IF SY-SUBRC = 0.APPEND GS_DATA TO LT_DATA.CONTINUE.ENDIF.ENDIF.ENDLOOP.GT_DATA = LT_DATA.ENDIF.IF GT_DATA IS INITIAL.MESSAGE S000(ZIF01) WITH TEXT-011 DISPLAY LIKE 'E'.ENDIF.SORT GT_DATA BY RECVTIME DESCENDING.SORT LT_ZTRGYLT2001 BY ZGYLJK.LOOP AT GT_DATA ASSIGNING FIELD-SYMBOL(<LS_DATA>).IF <LS_DATA>-STATUS = 'S' AND <LS_DATA>-SENDTIME IS NOT INITIAL AND <LS_DATA>-RECVTIME IS NOT INITIAL.DATA(LV_SDATE) = CONV D( <LS_DATA>-SENDTIME(8) ).DATA(LV_STIME) = CONV T( <LS_DATA>-SENDTIME+8(6) ).DATA(LV_RDATE) = CONV D( <LS_DATA>-RECVTIME(8) ).DATA(LV_RTIME) = CONV T( <LS_DATA>-RECVTIME+8(6) ).IF <LS_DATA>-IFDIR = 'INBOUND'.<LS_DATA>-DURTM = LV_STIME - LV_RTIME.ELSE.<LS_DATA>-DURTM = LV_RTIME - LV_STIME.ENDIF.IF <LS_DATA>-DURTM < 0.<LS_DATA>-DURTM = <LS_DATA>-DURTM + 86400.ENDIF.ENDIF.L_ZGYLJK = <LS_DATA>-IFNUM.READ TABLE LT_ZTRGYLT2001 INTO DATA(LS_ZTRGYLT2001) WITH KEY ZGYLJK = L_ZGYLJK.IF SY-SUBRC = 0.<LS_DATA>-ZGYLJKT = LS_ZTRGYLT2001-ZGYLJKT.ENDIF.ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SHOW_ALV .DATA: LS_LAYOUT TYPE SLIS_LAYOUT_ALV,LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,LS_FIELDCAT LIKE LINE OF LT_FIELDCAT.CHECK GT_DATA IS NOT INITIAL.CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTINGI_STRUCTURE_NAME = 'ZTRS00010'CHANGINGCT_FIELDCAT = LT_FIELDCATEXCEPTIONSINCONSISTENT_INTERFACE = 1PROGRAM_ERROR = 2OTHERS = 3.IF SY-SUBRC <> 0.
* Implement suitable error handling hereENDIF.LOOP AT LT_FIELDCAT INTO LS_FIELDCAT.IF LS_FIELDCAT-FIELDNAME = 'NEWID'.LS_FIELDCAT-DDICTXT = 'New PO MSGID'.LS_FIELDCAT-SELTEXT_L = 'New PO MSGID'.LS_FIELDCAT-SELTEXT_M = 'New PO MSGID'.LS_FIELDCAT-SELTEXT_S = 'New PO MSGID'.ELSEIF LS_FIELDCAT-FIELDNAME = 'ZGYLJKT'.LS_FIELDCAT-COL_POS = 4.ENDIF.MODIFY LT_FIELDCAT FROM LS_FIELDCAT.ENDLOOP.LS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.LS_LAYOUT-BOX_FIELDNAME = 'BOX'.CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'EXPORTINGI_CALLBACK_PROGRAM = SY-CPROGI_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS'I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND'IT_FIELDCAT = LT_FIELDCATIS_LAYOUT = LS_LAYOUTI_SAVE = 'A'TABLEST_OUTTAB = GT_DATAEXCEPTIONSPROGRAM_ERROR = 1OTHERS = 2.IF SY-SUBRC <> 0.MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNOWITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_SET_STATUS
*&---------------------------------------------------------------------*
* Set pf-status
*----------------------------------------------------------------------*
FORM FRM_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.SET PF-STATUS 'STANDARD'.
ENDFORM. "frm_SET_STATUS
*&---------------------------------------------------------------------*
*& Form frm_USER_COMMAND
*&---------------------------------------------------------------------*
* User command
*----------------------------------------------------------------------*
FORM FRM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMMRS_SELFIELD TYPE SLIS_SELFIELD.CASE R_UCOMM.WHEN '&IC1'. "Double clickREAD TABLE GT_DATA INTO GS_DATA INDEX RS_SELFIELD-TABINDEX.IF SY-SUBRC = 0.IF RS_SELFIELD-FIELDNAME = 'NEWID' AND GS_DATA-NEWID IS NOT INITIAL.PERFORM FRM_DIS_MSG USING GS_DATA-NEWID ''.ELSEIF RS_SELFIELD-FIELDNAME = 'FILE_S' AND GS_DATA-FILE_S IS NOT INITIAL.PERFORM PF_TEXT_DISPLAY USING GS_DATA-FILE_S.ELSEIF RS_SELFIELD-FIELDNAME = 'FILE_R' AND GS_DATA-FILE_R IS NOT INITIAL.PERFORM PF_TEXT_DISPLAY USING GS_DATA-FILE_R.ELSE."否则显示POMSGIDPERFORM FRM_DIS_MSG USING GS_DATA-POMSGID ''.ENDIF.ENDIF.WHEN '&DIS_XML'. "显示XML消息"检查选中READ TABLE GT_DATA INTO GS_DATA WITH KEY BOX = 'X'.IF SY-SUBRC <> 0.MESSAGE E002(ZIF01).ENDIF.PERFORM FRM_DISPLAY_MESSAGES.WHEN '&RESEND'. "重新下发"检查选中READ TABLE GT_DATA INTO GS_DATA WITH KEY BOX = 'X'.IF SY-SUBRC <> 0.MESSAGE E002(ZIF01).ENDIF."只能重发 异步下发的接口LOOP AT GT_DATA INTO GS_DATA WHERE BOX = 'X'.IF NOT ( GS_DATA-IFTYP = 'PO' AND GS_DATA-IFDIR = 'OUTBOUND' AND GS_DATA-IFMODE = 'A' ).MESSAGE E003(ZIF01).ENDIF.ENDLOOP."重发PERFORM FRM_RESEND_MESSAGES.RS_SELFIELD-REFRESH = 'X'.WHEN 'REFRESH'. "REFRESHRS_SELFIELD-REFRESH = 'X'."Get data from log tablePERFORM FRM_GET_DATA.WHEN OTHERS.ENDCASE.
ENDFORM. "frm_USER_COMMAND
*&---------------------------------------------------------------------*
*& Form frm_DIS_MSG
*&---------------------------------------------------------------------*
* DISPLAY MESSAGE
*----------------------------------------------------------------------*
* -->P_MSG_ID MSG ID
* -->P_NEW_SESSION '':Current session 'X':New session
*----------------------------------------------------------------------*
FORM FRM_DIS_MSG USING PV_MSGIDPV_NEW_SESSION.DATA: LV_MSGID TYPE SXMSMGUID.LV_MSGID = PV_MSGID.IF PV_NEW_SESSION = 'X'."新窗口CALL FUNCTION 'SXMB_DISPLAY_MESSAGE_MONITOR' STARTING NEW TASK 'XI'EXPORTINGIM_MESSAGE_ID = LV_MSGIDEXCEPTIONSMESSAGE_NOT_FOUND = 1NOT_AUTHORIZED = 2OTHERS = 3.ELSE."当前窗口CALL FUNCTION 'SXMB_DISPLAY_MESSAGE_MONITOR'EXPORTINGIM_MESSAGE_ID = LV_MSGIDEXCEPTIONSMESSAGE_NOT_FOUND = 1NOT_AUTHORIZED = 2OTHERS = 3.ENDIF.CASE SY-SUBRC.WHEN 0.WHEN 2.MESSAGE E082(XMS_ADM).WHEN OTHERS.MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNOWITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDCASE.
ENDFORM. " frm_DIS_MSG
*&---------------------------------------------------------------------*
*& Form frm_DISPLAY_MESSAGES
*&---------------------------------------------------------------------*
* DISPLAY MESSAGES
*----------------------------------------------------------------------*
FORM FRM_DISPLAY_MESSAGES .LOOP AT GT_DATA INTO GS_DATA WHERE BOX = 'X' AND POMSGID IS NOT INITIAL.PERFORM FRM_DIS_MSG USING GS_DATA-POMSGID 'X'.ENDLOOP.IF SY-SUBRC <> 0.MESSAGE E110(ZIF01).ELSE.MESSAGE S583(SO) WITH TEXT-004.ENDIF.
ENDFORM. " frm_DISPLAY_MESSAGES
*&---------------------------------------------------------------------*
*& Form FRM_RESEND_MESSAGES
*&---------------------------------------------------------------------*
* RESEND MESSAGES
*----------------------------------------------------------------------*
FORM FRM_RESEND_MESSAGES.DATA LV_NEWGUID TYPE SXMSGUID.DATA: LS_DATA TYPE ZTRT00010,LT_DATA TYPE TABLE OF ZTRT00010,L_TABIX TYPE SY-TABIX,L_COUNT_SUCC TYPE I,L_COUNT_ERR TYPE I,L_COUNT_ALL TYPE I,L_ANSWER.CALL FUNCTION 'POPUP_TO_CONFIRM'EXPORTINGTITLEBAR = TEXT-008TEXT_QUESTION = TEXT-005TEXT_BUTTON_1 = TEXT-006ICON_BUTTON_1 = 'ICON_CHECKED'TEXT_BUTTON_2 = TEXT-007ICON_BUTTON_2 = 'ICON_INCOMPLETE'DEFAULT_BUTTON = '2'DISPLAY_CANCEL_BUTTON = SPACEPOPUP_TYPE = 'ICON_MESSAGE_WARNING'IMPORTINGANSWER = L_ANSWEREXCEPTIONSTEXT_NOT_FOUND = 1OTHERS = 2.IF SY-SUBRC <> 0.MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNOWITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.IF L_ANSWER = '2'.MESSAGE S063(/SAPBOQ/SRVPACK).EXIT.ENDIF.LOOP AT GT_DATA INTO GS_DATA WHERE BOX = 'X'.L_TABIX = SY-TABIX.CLEAR: GS_DATA-MESSAGE.IF GS_DATA-POMSGID IS INITIAL.GS_DATA-MESSAGE = TEXT-009.L_COUNT_ERR = L_COUNT_ERR + 1.ELSE.GS_DATA-MESSAGE = TEXT-003.CLEAR: LV_NEWGUID.FREE MEMORY ID 'ZIFR00010'.SUBMIT ZRSXMB_SUPPORT_RESTART WITH PGUID = GS_DATA-POMSGID AND RETURN.IMPORT GUID = LV_NEWGUID FROM MEMORY ID 'ZIFR00010'.IF LV_NEWGUID IS NOT INITIAL.GS_DATA-NEWID = LV_NEWGUID.ENDIF.L_COUNT_SUCC = L_COUNT_SUCC + 1.ENDIF.MODIFY GT_DATA FROM GS_DATA INDEX L_TABIX.MOVE-CORRESPONDING GS_DATA TO LS_DATA.APPEND LS_DATA TO LT_DATA.ENDLOOP.IF LT_DATA IS NOT INITIAL.MODIFY ZTRT00010 FROM TABLE LT_DATA.COMMIT WORK.ENDIF.L_COUNT_ALL = L_COUNT_ERR + L_COUNT_SUCC.MESSAGE S043(ZIF01) WITH L_COUNT_ALL L_COUNT_SUCC L_COUNT_ERR.
ENDFORM. " frm_RESEND_MESSAGES
*&---------------------------------------------------------------------*
*& Form FRM_ZIFNUM_F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_ZIFNUM_F4 .DATA: BEGIN OF HELPROW,IFNUM TYPE ZTRT00010-IFNUM,ZGYLJKT TYPE ZTR_GYLJKBMT,END OF HELPROW.DATA FIELD_TAB LIKE STANDARD TABLE OF DYNPREAD WITH HEADER LINE.DATA HELP_TAB LIKE STANDARD TABLE OF HELPROW WITH HEADER LINE.* SELECT DISTINCT IFNUM
* INTO CORRESPONDING FIELDS OF TABLE HELP_TAB
* FROM ZTRT00010.SELECT ZGYLJK ZGYLJKTINTO TABLE HELP_TABFROM ZTRGYLT2001.SORT HELP_TAB BY IFNUM.CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTING
* DDIC_STRUCTURE = ' 'RETFIELD = 'IFNUM'
* PVALKEY = ' 'DYNPPROG = SY-REPIDDYNPNR = SY-DYNNRDYNPROFIELD = 'S_IFNUM'VALUE_ORG = 'S'TABLESVALUE_TAB = HELP_TABEXCEPTIONSPARAMETER_ERROR = 1NO_VALUES_FOUND = 2OTHERS = 3.IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.
ENDFORM.*----------------------------------------------------------------------*
FORM XML_DISPLAY USING P_XML_STR.DATA: L_XML TYPE REF TO CL_XML_DOCUMENT .CREATE OBJECT L_XML.CALL METHOD L_XML->PARSE_STRINGEXPORTINGSTREAM = P_XML_STR. "xml_out is the variable which is holding the xml stringCALL METHOD L_XML->DISPLAY.
ENDFORM.FORM PF_TEXT_DISPLAY USING P_CFILE .DATA: RESULT_TAB TYPE MATCH_RESULT_TAB WITH HEADER LINE.DATA: L_CFILE TYPE STRING .L_CFILE = P_CFILE.."当包含%+字母(数字)时,认为是进行了URL编码。FIND ALL OCCURRENCES OF REGEX '(%\w)' IN L_CFILE RESULTS RESULT_TAB[].IF SY-SUBRC = 0 .
*URL解码。L_CFILE = CL_HTTP_UTILITY=>UNESCAPE_URL( L_CFILE ).ENDIF.CALL METHOD CL_DEMO_OUTPUT=>DISPLAY_TEXTEXPORTINGTEXT = L_CFILE.ENDFORM.
程序GUI 状态:STANDARD
- &DIS_XML 显示XML消息
- &RESEND 重新下发
- REFRESH 刷新