在接口的处理中通常会需要记录日志,而如果是与PO(PI,XI)做的接口的话,可以使用事务码SXI_MONITOR – XI:消息监控,来查询日志,但对于一些有加密,或者在业务接口功能上想直接查询报文日志时,会在ECC中创建一个表来记录报文日志信息,以下是一个调用PI的接口,调用完成后,把PI接口的MESSAGE_ID记录到表中,这样可以通过表中记录的MESSAGE_ID来直接打开PI日志。同时由于发送的报文是加密的,所以把发送前未加密的报文,及收到的解密 后的报文保存到日志表中。最后使用一个程序来显示 日志,
1.日志记录
调用接口后,记录日志,以下是一个调用接口,有加解密,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
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' EXPORTING IV_DOCNO = LV_DOCNO IV_SERIAL = LV_SERIAL IV_TEXT = LV_JSON IV_3000 = LS_3000 IMPORTING EV_TEXT = LV_DATA EV_KEY = LV_KEY64 EV_TIMESTAMPL = LV_JAVA_TIMESTAMP EV_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_SY EXPORTING OUTPUT = LS_OUTPUT IMPORTING INPUT = 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' EXPORTING IV_TEXT = LS_MESSAGEIN-DATA IV_KEY = LS_MESSAGEIN-KEY IV_3000 = LS_3000 IMPORTING EV_MSG = LV_MSG EV_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_case CHANGING 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-DD LS_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 ID DATA: 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 . " MSGID LS_LOG-POMSGID = LV_PO_MSGID. "POMSGID LS_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.显未来日志的处理程序,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
*&********************************************************************* *& 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 2017-06-16 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 DATA PERFORM FRM_GET_DATA. "ALV PERFORM 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 data SELECT * FROM ZTRT00010 INTO CORRESPONDING FIELDS OF TABLE GT_DATA WHERE IFNUM IN S_IFNUM AND IFTYP IN S_IFTYP AND IFDIR IN S_IFDIR AND IFMODE IN S_IFMODE AND STATUS IN S_STATUS AND BSTATUS IN S_BSTATU AND 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 version SELECT MSGGUID PID VERS FROM SXMSPVERS INTO CORRESPONDING FIELDS OF TABLE LT_VERS WHERE MSGGUID = GS_DATA-POMSGID. IF SY-SUBRC = 0. LOOP AT LT_VERS INTO LS_VERS. "read message LO_PERSIST->READ_MSG_ALL( EXPORTING IM_MSGGUID = LS_VERS-MSGGUID IM_PID = LS_VERS-PID IM_VERSION = LS_VERS-VERS IMPORTING EX_MESSAGE = DATA(LO_XMS_MSG) ). LO_XMS_MSG->DELETEHEADERBYNAME( NSURI = IF_XMS_RUN_TIME_ENV=>CO_NSURI LCNAME = IF_XMS_RUN_TIME_ENV=>CO_LCNAME ). "get payload DATA(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 payload CL_ABAP_CONV_IN_CE=>CREATE( INPUT = LS_PAYLOAD-MAINPAYLOAD->GETBINARYCONTENT( ) IGNORE_CERR = ABAP_TRUE ENDIAN = 'B' ENCODING = 'UTF-8' )->READ( IMPORTING DATA = LV_PAYLOAD ). "search data in payload SEARCH 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' EXPORTING I_STRUCTURE_NAME = 'ZTRS00010' CHANGING CT_FIELDCAT = LT_FIELDCAT EXCEPTIONS INCONSISTENT_INTERFACE = 1 PROGRAM_ERROR = 2 OTHERS = 3. IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. 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' EXPORTING I_CALLBACK_PROGRAM = SY-CPROG I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS' I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND' IT_FIELDCAT = LT_FIELDCAT IS_LAYOUT = LS_LAYOUT I_SAVE = 'A' TABLES T_OUTTAB = GT_DATA EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. 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 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-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. CASE R_UCOMM. WHEN '&IC1'. "Double click READ 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. "否则显示POMSGID PERFORM 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'. "REFRESH RS_SELFIELD-REFRESH = 'X'. "Get data from log table PERFORM 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_MSGID PV_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' EXPORTING IM_MESSAGE_ID = LV_MSGID EXCEPTIONS MESSAGE_NOT_FOUND = 1 NOT_AUTHORIZED = 2 OTHERS = 3. ELSE. "当前窗口 CALL FUNCTION 'SXMB_DISPLAY_MESSAGE_MONITOR' EXPORTING IM_MESSAGE_ID = LV_MSGID EXCEPTIONS MESSAGE_NOT_FOUND = 1 NOT_AUTHORIZED = 2 OTHERS = 3. ENDIF. CASE SY-SUBRC. WHEN 0. WHEN 2. MESSAGE E082(XMS_ADM). WHEN OTHERS. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH 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' EXPORTING TITLEBAR = TEXT-008 TEXT_QUESTION = TEXT-005 TEXT_BUTTON_1 = TEXT-006 ICON_BUTTON_1 = 'ICON_CHECKED' TEXT_BUTTON_2 = TEXT-007 ICON_BUTTON_2 = 'ICON_INCOMPLETE' DEFAULT_BUTTON = '2' DISPLAY_CANCEL_BUTTON = SPACE POPUP_TYPE = 'ICON_MESSAGE_WARNING' IMPORTING ANSWER = L_ANSWER EXCEPTIONS TEXT_NOT_FOUND = 1 OTHERS = 2. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH 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 ZGYLJKT INTO TABLE HELP_TAB FROM ZTRGYLT2001. SORT HELP_TAB BY IFNUM. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING * DDIC_STRUCTURE = ' ' RETFIELD = 'IFNUM' * PVALKEY = ' ' DYNPPROG = SY-REPID DYNPNR = SY-DYNNR DYNPROFIELD = 'S_IFNUM' VALUE_ORG = 'S' TABLES VALUE_TAB = HELP_TAB EXCEPTIONS PARAMETER_ERROR = 1 NO_VALUES_FOUND = 2 OTHERS = 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_STRING EXPORTING STREAM = P_XML_STR. "xml_out is the variable which is holding the xml string CALL 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_TEXT EXPORTING TEXT = L_CFILE. ENDFORM. |
程序GUI 状态:STANDARD
- &DIS_XML 显示XML消息
- &RESEND 重新下发
- REFRESH 刷新