CALL TRANSACTION TCODE (调用的事务码) USING BDCDATA (创建好的BDC录屏数据 TYPE BDCDATA) OPTIONGS FROM OPTION (调用选项 TYPE CTU_PARAMS) MESSAGE INTO MESSTAB. (成功与否的消息 TYPE BDCMSGCOLL)
*&---------------------------------------------------------------------* *& Report ZBDCMM02_CYH *&---------------------------------------------------------------------* *& Module / Submodule: ABAP / New Train *&---------------------------------------------------------------------* *T_CODE : N/A * *CREATER : KF543 * *CREATE ON : 2023.08.08 * *TYPE : Report * *Description : Two Call Methods for Modifying BDC in Material * * Description * ************************************************************************ * Change History * * -------- ---------- ------------- -----------------------------------* * Version Date Change By Description * * -------- ---------- ------------- -----------------------------------* * N 2023.08.08 KF543 Creater * ************************************************************************ REPORT ZBDCMM02_CYH MESSAGE-ID ZMESCLA_CYH.
*----------------------------------------------------------------------* * Include *----------------------------------------------------------------------* INCLUDE ZBDCMM02_CYH_TOP. INCLUDE ZBDCMM02_CYH_SCR. INCLUDE ZBDCMM02_CYH_CLA. INCLUDE ZBDCMM02_CYH_PBO. INCLUDE ZBDCMM02_CYH_PAI. INCLUDE ZBDCMM02_CYH_F01.
*----------------------------------------------------------------------* * AT SELECTION-SCREEN OUTPUT *----------------------------------------------------------------------* *AT SELECTION-SCREEN OUTPUT.
*----------------------------------------------------------------------* * AT SELECTION-SCREEN *----------------------------------------------------------------------* *AT SELECTION-SCREEN.
*----------------------------------------------------------------------* * AT SELECTION-SCREEN ON *----------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FPATH. PERFORM SEARCH_HELP_FPATH CHANGING P_FPATH.
*&---------------------------------------------------------------------* *& 包含 ZBDCMM02_CYH_TOP *&---------------------------------------------------------------------* *----------------------------------------------------------------------* * Constants *----------------------------------------------------------------------* CONSTANTS: GC_X TYPE C LENGTH 1 VALUE 'X', GC_S TYPE C LENGTH 1 VALUE 'S', GC_E TYPE C LENGTH 1 VALUE 'E', GC_NULL TYPE C LENGTH 1 VALUE '', GC_MM02 TYPE C LENGTH 4 VALUE 'MM02'.
*----------------------------------------------------------------------* * Variables *----------------------------------------------------------------------* DATA: GV_RUNFLAG TYPE C, "运行标记,只运行一次的标记 GV_MESSAGE TYPE C. "异常终止代码流程标记
*----------------------------------------------------------------------* * Structure *----------------------------------------------------------------------* DATA: BEGIN OF GS_TABLE, "存放修改数据的结构,与Excel中结构对应 MATNR LIKE MARA-MATNR, MAKTX LIKE MAKT-MAKTX, END OF GS_TABLE, BEGIN OF GS_FMESG, "Session日志的Message结构 MART LIKE APQLE-MART, MID LIKE APQLE-MID, MNR LIKE APQLE-MNR, MSGV1 LIKE APQLE-MSGV1, MSGV2 LIKE APQLE-MSGV2, MSGV3 LIKE APQLE-MSGV3, MSGV4 LIKE APQLE-MSGV4, END OF GS_FMESG. DATA: GS_BDCTAB TYPE BDCDATA, "存放有BDC操作的结构 GS_MESSAGE TYPE BDCMSGCOLL,"事务码调用返回的Message结构 GS_MESSAGEP TYPE ESP1_MESSAGE_WA_TYPE."最后弹框展示Message的结构
*----------------------------------------------------------------------* * Internal Table *----------------------------------------------------------------------* DATA: GT_BDCTAB TYPE TABLE OF BDCDATA,"存放有BDC操作的内表 GT_TABLE LIKE TABLE OF GS_TABLE, GT_FMESG LIKE TABLE OF GS_FMESG, GT_MESSAGE TYPE TABLE OF BDCMSGCOLL, GT_MESSAGEP TYPE ESP1_MESSAGE_TAB_TYPE.
*&---------------------------------------------------------------------* *& 包含 ZBDCMM02_CYH_SCR *&---------------------------------------------------------------------* "执行模式 SELECTION-SCREEN BEGIN OF BLOCK K01 WITH FRAME TITLE TEXT-T01. SELECTION-SCREEN BEGIN OF LINE. "执行模式: PARAMETERS: P_TEXT NO-DISPLAY. SELECTION-SCREEN COMMENT 1(23) TEXT-001 FOR FIELD P_TEXT.
"调用事务码 SELECTION-SCREEN POSITION 32. PARAMETERS: P_TCODE RADIOBUTTON GROUP GR01 USER-COMMAND UC1 DEFAULT 'X'. SELECTION-SCREEN COMMENT 34(23) TEXT-R01 FOR FIELD P_TCODE.
"调用Function SELECTION-SCREEN POSITION 57. PARAMETERS: P_CFUNC RADIOBUTTON GROUP GR01 . SELECTION-SCREEN COMMENT 59(20) TEXT-R02 FOR FIELD P_CFUNC. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK K01.
"上传文件 SELECTION-SCREEN BEGIN OF BLOCK K02 WITH FRAME TITLE TEXT-T02. PARAMETERS: P_FPATH TYPE STRING. SELECTION-SCREEN END OF BLOCK K02.
*&---------------------------------------------------------------------* *& 包含 ZBDCMM02_CYH_F01 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form SEARCH_HELP_FPATH *&---------------------------------------------------------------------* *& text 获取文件上传路径 *&---------------------------------------------------------------------* *& <-- P_FPATH *&---------------------------------------------------------------------* FORM SEARCH_HELP_FPATH CHANGING VALUE(PV_PATH) TYPE STRING. *--------------------------Variables-----------------------------------* DATA: LV_DEF_PATH TYPE STRING, LT_FILE_TABLE TYPE FILETABLE, LV_RC TYPE I, LV_ACTION TYPE I. *----------------------------Logic-------------------------------------* CLEAR GV_MESSAGE. CL_GUI_FRONTEND_SERVICES=>DIRECTORY_GET_CURRENT( CHANGING CURRENT_DIRECTORY = LV_DEF_PATH ).
"用户取消上传操作 IF LV_ACTION = CL_GUI_FRONTEND_SERVICES=>ACTION_CANCEL. GV_MESSAGE = GC_X. EXIT. ENDIF.
CHECK LT_FILE_TABLE IS NOT INITIAL. READ TABLE LT_FILE_TABLE INTO DATA(LS_FILE) INDEX 1. CHECK SY-SUBRC EQ 0. IF STRLEN( LS_FILE ) GE 128. "The lengtn of file path should be less than 128. "文件路径长度不可大于128 MESSAGE TEXT-E02 TYPE GC_S DISPLAY LIKE GC_E. ELSE. PV_PATH = LS_FILE. TRANSLATE PV_PATH TO UPPER CASE. ENDIF.
FREE: LT_FILE_TABLE. ENDFORM. *&---------------------------------------------------------------------* *& Form CHECK_FILE_PATH *&---------------------------------------------------------------------* *& text 校验上传文件路径或文件格式 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CHECK_FILE_PATH . *--------------------------Variables-----------------------------------* CONSTANTS: LC_DROP TYPE C LENGTH 1 VALUE '.', LC_XLS TYPE C LENGTH 3 VALUE 'XLS', LC_XLSX TYPE C LENGTH 4 VALUE 'XLSX'. DATA: LV_LINES TYPE I, LV_FTYPE TYPE STRING, LT_FTYPE TYPE TABLE OF STRING. *----------------------------Logic-------------------------------------* "根据点区分文件类型 SPLIT P_FPATH AT LC_DROP INTO TABLE LT_FTYPE. "获取最后一行数据Index LV_LINES = LINES( LT_FTYPE ). "获取文件类型 READ TABLE LT_FTYPE INTO LV_FTYPE INDEX LV_LINES. IF SY-SUBRC EQ 0. IF LV_FTYPE NE LC_XLS AND LV_FTYPE NE LC_XLSX. "上传文件类型异常 MESSAGE S000 WITH TEXT-E01 DISPLAY LIKE GC_E. LEAVE LIST-PROCESSING. ENDIF. ENDIF. FREE: LT_FTYPE. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_EXCEL_DATA *&---------------------------------------------------------------------* *& text 获取Excel中的数据,并调用格式转换Function转换物料编号格式 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM GET_EXCEL_DATA . *--------------------------Variables-----------------------------------* DATA: LV_PATH TYPE RLGRAP-FILENAME, LT_DATA LIKE GT_TABLE, LT_ROWTAB TYPE TRUXS_T_TEXT_DATA. *----------------------------Logic-------------------------------------* REFRESH: GT_TABLE.
ENDFORM. *&---------------------------------------------------------------------* *& Form CALL_BDC *&---------------------------------------------------------------------* *& text 编写批量操作流程与数据 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CALL_BDC . REFRESH:GT_MESSAGEP.
IF P_CFUNC IS NOT INITIAL. PERFORM OPEN_GROUP. ENDIF.
"填充BDC数据 LOOP AT GT_TABLE INTO GS_TABLE. REFRESH: GT_BDCTAB,GT_MESSAGE.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'. PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RMMG1-MATNR'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'. PERFORM BDC_FIELD USING 'RMMG1-MATNR' GS_TABLE-MATNR. PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'. PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(02)'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'. PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)' 'X'. PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(02)' 'X'. PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4004'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=BU'. PERFORM BDC_FIELD USING 'BDC_CURSOR' 'MAKT-MAKTX'. PERFORM BDC_FIELD USING 'MAKT-MAKTX' GS_TABLE-MAKTX.
"根据选择调用合适的事务码 CASE GC_X. WHEN P_TCODE. "事务码形式调用 PERFORM CALL_TRANSACTION_CODE. WHEN P_CFUNC. "Session形式调用 PERFORM CALL_FUNCTION. WHEN OTHERS. ENDCASE.
CLEAR: GS_TABLE. ENDLOOP.
IF P_CFUNC IS NOT INITIAL. PERFORM CLOSE_GROUP. PERFORM RUN_SESSION. PERFORM GET_SESSION_STATE. PERFORM SET_MESSAGE_VALUE. ENDIF. ENDFORM. *----------------------------------------------------------------------* * Start new screen * *----------------------------------------------------------------------* FORM BDC_DYNPRO USING PROGRAM DYNPRO. CLEAR GS_BDCTAB. GS_BDCTAB-PROGRAM = PROGRAM. GS_BDCTAB-DYNPRO = DYNPRO. GS_BDCTAB-DYNBEGIN = 'X'. APPEND GS_BDCTAB TO GT_BDCTAB. ENDFORM. *----------------------------------------------------------------------* * Insert field * *----------------------------------------------------------------------* FORM BDC_FIELD USING FNAM FVAL. CLEAR GS_BDCTAB. GS_BDCTAB-FNAM = FNAM. GS_BDCTAB-FVAL = FVAL. APPEND GS_BDCTAB TO GT_BDCTAB. ENDFORM. *&---------------------------------------------------------------------* *& Form CALL_TRANSACTION_CODE *&---------------------------------------------------------------------* *& text 通过调用事务码形式,执行批量操作 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CALL_TRANSACTION_CODE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_A TYPE C LENGTH 1 VALUE 'A', LC_N TYPE C LENGTH 1 VALUE 'N'. DATA: LS_OPTION TYPE CTU_PARAMS. *----------------------------Logic-------------------------------------* "DISMODE (E:有错误是跳转前台; A:一直前台执行; N:均后台执行) "UPDMODE(A:异步; S: 同步; L:Local Update) "RACOMMIT (后台遇到commit work代码时是否结束BDC ,赋值为X时不结束。此处在实际业务中经常碰到问题,注意此参数设置) "设置属性 LS_OPTION-DISMODE = LC_N. LS_OPTION-UPDMODE = LC_A. LS_OPTION-RACOMMIT = GC_X.
CALL TRANSACTION GC_MM02 USING GT_BDCTAB OPTIONS FROM LS_OPTION MESSAGES INTO GT_MESSAGE. IF SY-SUBRC NE 0. "BDC调用失败 MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E. * EXIT. ENDIF.
APPEND GS_MESSAGEP TO GT_MESSAGEP. CLEAR: GS_MESSAGE,GS_MESSAGEP. ENDLOOP. * SORT GT_MESSAGE BY MSGTYP. * READ TABLE GT_MESSAGE INTO GS_MESSAGE WITH KEY MSGTYP = GC_E. * IF SY-SUBRC EQ 0. * MESSAGE ID GS_MESSAGE-MSGID TYPE GC_S NUMBER GS_MESSAGE-MSGNR * WITH GS_MESSAGE-MSGV1 GS_MESSAGE-MSGV2 * GS_MESSAGE-MSGV3 GS_MESSAGE-MSGV4 * DISPLAY LIKE GC_E. * ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form CALL_FUNCTION *&---------------------------------------------------------------------* *& text 在批量输入会话中插入批量输入事务 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CALL_FUNCTION . *--------------------------Variables-----------------------------------* DATA: LV_TCODE TYPE TSTC-TCODE. *----------------------------Logic-------------------------------------* LV_TCODE = GC_MM02. CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = LV_TCODE * POST_LOCAL = NOVBLOCAL * PRINTING = NOPRINT * SIMUBATCH = ' ' * CTUPARAMS = ' ' TABLES DYNPROTAB = GT_BDCTAB EXCEPTIONS INTERNAL_ERROR = 1 NOT_OPEN = 2 QUEUE_ERROR = 3 TCODE_INVALID = 4 PRINTING_INVALID = 5 POSTING_INVALID = 6 OTHERS = 7. IF SY-SUBRC <> 0. "BDC调用失败 MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E. EXIT. ENDIF.
ENDFORM. *&---------------------------------------------------------------------* *& Form DISPLAY_RESULT *&---------------------------------------------------------------------* *& text 弹框显示最后的运行结果 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM DISPLAY_RESULT . CHECK GT_MESSAGEP IS NOT INITIAL. CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP' TABLES I_MESSAGE_TAB = GT_MESSAGEP. FREE: GT_MESSAGEP. ENDFORM. *&---------------------------------------------------------------------* *& Form OPEN_GROUP *&---------------------------------------------------------------------* *& text 打开批量输入会话 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM OPEN_GROUP . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'. DATA: LV_HOLDDATE TYPE SY-DATUM, LV_USER TYPE C LENGTH 12. *----------------------------Logic-------------------------------------* LV_USER = SY-UNAME. * LV_HOLDDATE = SY-DATUM. CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT = SY-MANDT GROUP = LC_GROUP HOLDDATE = LV_HOLDDATE "' '=Delete,'X'=keep after processing KEEP = GC_X USER = LV_USER EXCEPTIONS CLIENT_INVALID = 1 DESTINATION_INVALID = 2 GROUP_INVALID = 3 GROUP_IS_LOCKED = 4 HOLDDATE_INVALID = 5 INTERNAL_ERROR = 6 QUEUE_ERROR = 7 RUNNING = 8 SYSTEM_LOCK_ERROR = 9 USER_INVALID = 10 OTHERS = 11 . 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 CLOSE_GROUP *&---------------------------------------------------------------------* *& text 关闭批量输入会话 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CLOSE_GROUP . CALL FUNCTION 'BDC_CLOSE_GROUP' EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 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 RUN_SESSION *&---------------------------------------------------------------------* *& text 调用RSBDCSUB执行Session进程 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM RUN_SESSION . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'. *----------------------------Logic-------------------------------------* SUBMIT RSBDCSUB WITH MAPPE EQ LC_GROUP WITH VON EQ SY-DATUM WITH BIS EQ SY-DATUM WITH FEHLER EQ '.' EXPORTING LIST TO MEMORY AND RETURN. WAIT UP TO 5 SECONDS. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_SESSION_STATE *&---------------------------------------------------------------------* *& text 从数据库表中获取Session日志信息 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM GET_SESSION_STATE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'. *----------------------------Logic-------------------------------------* REFRESH:GT_FMESG. SELECT MAX( M~CREDATE ) AS CREDATE, MAX( M~CRETIME ) AS CRETIME, I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4 FROM APQI AS M INNER JOIN APQLE AS I ON M~QID = I~QID INTO CORRESPONDING FIELDS OF TABLE @GT_FMESG WHERE M~GROUPID = @LC_GROUP AND I~TCODE = @GC_MM02 AND I~MID <> @GC_NULL GROUP BY I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4. IF SY-SUBRC NE 0. "Session尚未运行完成,请等待 MESSAGE S000 WITH TEXT-E04 DISPLAY LIKE GC_E. IF GV_RUNFLAG IS INITIAL. GV_RUNFLAG = GC_X."仅执行一次的标记 WAIT UP TO 5 SECONDS. PERFORM GET_SESSION_STATE. ELSE. "Session运行异常 MESSAGE S000 WITH TEXT-E05 DISPLAY LIKE GC_E. EXIT. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form SET_MESSAGE_VALUE *&---------------------------------------------------------------------* *& text 将Session日志中的Message信息更新到弹框Message的内表中 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_MESSAGE_VALUE . CHECK GT_FMESG IS NOT INITIAL. REFRESH: GT_MESSAGEP. CLEAR: GS_MESSAGEP,GS_FMESG. LOOP AT GT_FMESG INTO GS_FMESG. GS_MESSAGEP-LINENO = SY-TABIX. GS_MESSAGEP-MSGID = GS_FMESG-MID. GS_MESSAGEP-MSGNO = GS_FMESG-MNR. GS_MESSAGEP-MSGTY = GS_FMESG-MART. GS_MESSAGEP-MSGV1 = GS_FMESG-MSGV1. GS_MESSAGEP-MSGV2 = GS_FMESG-MSGV2. GS_MESSAGEP-MSGV3 = GS_FMESG-MSGV3. GS_MESSAGEP-MSGV4 = GS_FMESG-MSGV4. INSERT GS_MESSAGEP INTO TABLE GT_MESSAGEP. CLEAR: GS_FMESG,GS_MESSAGEP. ENDLOOP.
*&---------------------------------------------------------------------* *& Form CALL_TRANSACTION_CODE *&---------------------------------------------------------------------* *& text 通过调用事务码形式,执行批量操作 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CALL_TRANSACTION_CODE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_A TYPE C LENGTH 1 VALUE 'A', LC_N TYPE C LENGTH 1 VALUE 'N'. DATA: LS_OPTION TYPE CTU_PARAMS. *----------------------------Logic-------------------------------------* "DISMODE (E:有错误是跳转前台; A:一直前台执行; N:均后台执行) "UPDMODE(A:异步; S: 同步; L:Local Update) "RACOMMIT (后台遇到commit work代码时是否结束BDC ,赋值为X时不结束。此处在实际业务中经常碰到问题,注意此参数设置) "设置属性 LS_OPTION-DISMODE = LC_N. LS_OPTION-UPDMODE = LC_A. LS_OPTION-RACOMMIT = GC_X.
CALL TRANSACTION GC_MM02 USING GT_BDCTAB OPTIONS FROM LS_OPTION MESSAGES INTO GT_MESSAGE. IF SY-SUBRC NE 0. "BDC调用失败 MESSAGE S000 WITH TEXT-E03 DISPLAY LIKE GC_E. * EXIT. ENDIF.
FORM CLOSE_GROUP . CALL FUNCTION 'BDC_CLOSE_GROUP' EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 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.
(4)调用RSBDCSUB程序运行Session
1 2 3 4 5 6 7 8 9 10 11 12 13
FORM RUN_SESSION . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'. *----------------------------Logic-------------------------------------* SUBMIT RSBDCSUB WITH MAPPE EQ LC_GROUP WITH VON EQ SY-DATUM WITH BIS EQ SY-DATUM WITH FEHLER EQ '.' EXPORTING LIST TO MEMORY AND RETURN. WAIT UP TO 5 SECONDS. ENDFORM.
FORM GET_SESSION_STATE . *--------------------------Variables-----------------------------------* CONSTANTS: LC_GROUP TYPE C LENGTH 12 VALUE 'INTERNAL_ORD'. *----------------------------Logic-------------------------------------* REFRESH:GT_FMESG. SELECT MAX( M~CREDATE ) AS CREDATE, MAX( M~CRETIME ) AS CRETIME, I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4 FROM APQI AS M INNER JOIN APQLE AS I ON M~QID = I~QID INTO CORRESPONDING FIELDS OF TABLE @GT_FMESG WHERE M~GROUPID = @LC_GROUP AND I~TCODE = @GC_MM02 AND I~MID <> @GC_NULL GROUP BY I~MART, I~MID, I~MNR, I~MSGV1, I~MSGV2, I~MSGV3, I~MSGV4. IF SY-SUBRC NE 0. "Session尚未运行完成,请等待 MESSAGE S000 WITH TEXT-E04 DISPLAY LIKE GC_E. IF GV_RUNFLAG IS INITIAL. GV_RUNFLAG = GC_X."仅执行一次的标记 WAIT UP TO 5 SECONDS. PERFORM GET_SESSION_STATE. ELSE. "Session运行异常 MESSAGE S000 WITH TEXT-E05 DISPLAY LIKE GC_E. EXIT. ENDIF. ENDIF. ENDFORM.
(6)展示Session日志信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
FORM SET_MESSAGE_VALUE . CHECK GT_FMESG IS NOT INITIAL. REFRESH: GT_MESSAGEP. CLEAR: GS_MESSAGEP,GS_FMESG. LOOP AT GT_FMESG INTO GS_FMESG. GS_MESSAGEP-LINENO = SY-TABIX. GS_MESSAGEP-MSGID = GS_FMESG-MID. GS_MESSAGEP-MSGNO = GS_FMESG-MNR. GS_MESSAGEP-MSGTY = GS_FMESG-MART. GS_MESSAGEP-MSGV1 = GS_FMESG-MSGV1. GS_MESSAGEP-MSGV2 = GS_FMESG-MSGV2. GS_MESSAGEP-MSGV3 = GS_FMESG-MSGV3. GS_MESSAGEP-MSGV4 = GS_FMESG-MSGV4. INSERT GS_MESSAGEP INTO TABLE GT_MESSAGEP. CLEAR: GS_FMESG,GS_MESSAGEP. ENDLOOP.