当不知道IDOC同步的具体时间,而WE02数据量过大时;
当某条IDOC记录中数据量过大,找不到具体某条数据时;
可采用自开发程序查找,具体代码如下:
REPORT ZIDOC_LOG. *----------------------------------------------------------------------* *表声明 *----------------------------------------------------------------------* TABLES:SSCRFIELDS,EDIDC." *----------------------------------------------------------------------* *类型池声明 *----------------------------------------------------------------------* TYPE-POOLS:SLIS. *----------------------------------------------------------------------* * 类型定义 *----------------------------------------------------------------------* TYPES:BEGIN OF TY_IDOC, DOCNUM TYPE EDIDC-DOCNUM, "IDoc 号码 STATUS TYPE EDIDC-STATUS, "状态 RCVPOR TYPE EDIDC-RCVPOR, "接收方端口 SNDPOR TYPE EDIDC-SNDPOR, "发件人端口 SNDPRN TYPE EDIDC-SNDPRN, "发送者伙伴编号 CREDAT TYPE EDIDC-CREDAT, "创建日期 CRETIM TYPE EDIDC-CRETIM, "创建时间 MESTYP TYPE EDIDC-MESTYP, "消息类型 IDOCTP TYPE EDIDC-IDOCTP, "基本类型 UPDDAT TYPE EDIDC-UPDDAT, "更改日期 UPDTIM TYPE EDIDC-UPDTIM, "更改时间 MAXSEGNUM TYPE EDIDC-MAXSEGNUM, "数据记录的数目 SEGNUM TYPE EDID4-SEGNUM, "SAP 段编号 SEGNAM TYPE EDID4-SEGNAM, "SAP 段名 SDATA TYPE STRING, "应用程序数据 END OF TY_IDOC. TYPES:BEGIN OF TY_EDID4, DOCNUM TYPE EDID4-DOCNUM, "IDoc 号码 COUNTER TYPE EDID4-COUNTER, "簇表的计数器 SEGNUM TYPE EDID4-SEGNUM, "SAP 段编号 SEGNAM TYPE EDID4-SEGNAM, "SAP 段名 SDATA TYPE STRING, "应用程序数据 END OF TY_EDID4. TYPES:BEGIN OF TY_SEGNAM, SEGNAM TYPE EDID4-SEGNAM, "SAP 段名, END OF TY_SEGNAM. DATA:GT_SEGNAM_HASH TYPE HASHED TABLE OF TY_SEGNAM WITH UNIQUE KEY SEGNAM, GS_SEGNAM_HASH TYPE TY_SEGNAM. *----------------------------------------------------------------------* * 声明内表和工作区 *----------------------------------------------------------------------* DATA:GT_IDOC TYPE TABLE OF TY_IDOC, GS_IDOC TYPE TY_IDOC, GT_ALV TYPE TABLE OF TY_IDOC, GS_ALV TYPE TY_IDOC, GT_EDID4 TYPE TABLE OF EDIDD, GS_EDID4 TYPE EDIDD. DATA: TIME_0 LIKE EDIDC-UPDTIM VALUE '000000', TIME_24 LIKE EDIDC-UPDTIM VALUE '240000'. FIELD-SYMBOLS:<GS_IDOC> TYPE TY_IDOC, <DYN_ALV> TYPE STANDARD TABLE, <DYN_WA>, <GS_FIELD> TYPE LVC_S_FCAT, <DYN_FIELD>. DATA:DY_TABLE TYPE REF TO DATA, GS_LINE TYPE REF TO DATA. DATA:GT_ROW TYPE LVC_T_ROW, GS_ROW TYPE LVC_S_ROW, GT_ROW_NO TYPE LVC_T_ROID. *----------------------------------------------------------------------* *ALV参数声明 *----------------------------------------------------------------------* DATA: GT_FIELDCAT TYPE LVC_T_FCAT, "字段目录内表 GS_FIELDCAT TYPE LVC_S_FCAT, "字段目录工作区 GT_FIELD TYPE LVC_T_FCAT, "字段目录内表 GS_FIELD TYPE LVC_S_FCAT, "字段目录工作区 GS_LAYOUT TYPE LVC_S_LAYO. "用于定义ALV表单的相关格式、属性 *----------------------------------------------------------------------* *选 择 屏 幕 定 义 块 *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK BLK0 WITH FRAME. PARAMETERS:P_IDOCTP TYPE EDIDC-IDOCTP OBLIGATORY."基本类型 SELECT-OPTIONS:S_CREDAT FOR EDIDC-CREDAT DEFAULT SY-DATUM TO SY-DATUM OBLIGATORY."创建日期 SELECT-OPTIONS:S_CRETIM FOR EDIDC-CRETIM DEFAULT TIME_0 TO TIME_24 OBLIGATORY."创建时间 SELECTION-SCREEN END OF BLOCK BLK0. *&---------------------------------------------------------------------* * 初始化 *&---------------------------------------------------------------------* SELECTION-SCREEN: FUNCTION KEY 1."定义按钮1 *&---------------------------------------------------------------------* * INITIALIZATION:启动程序开始执行,初始话数据 *&---------------------------------------------------------------------* INITIALIZATION. AT SELECTION-SCREEN. *&---------------------------------------------------------------------* *& AT SELECTION-SCREEN OUTPUT:在屏幕输出前 *&---------------------------------------------------------------------* AT SELECTION-SCREEN OUTPUT. *----------------------------------------------------------------------* * ALV逻辑流 *----------------------------------------------------------------------* START-OF-SELECTION. "获取数据 PERFORM FRM_GET_DATA. "设置输出格式 PERFORM FRM_SET_LAYOUT. "设置字段属性 PERFORM FRM_SET_FIELDCAT. "创建动态内表 PERFORM FRM_CREATE_TABLE. "显示ALV PERFORM FRM_DISPLAY_ALV. *&---------------------------------------------------------------------* *& Form FRM_CHECK_SRCEEN *&---------------------------------------------------------------------* * text 检查必输字段 *----------------------------------------------------------------------* FORM FRM_CHECK_SRCEEN. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CHECK_AUTHORITY *&---------------------------------------------------------------------* * text 权限检查 *----------------------------------------------------------------------* FORM FRM_CHECK_AUTHORITY. * DATA:LV_MESSAGE TYPE CHAR200. * * AUTHORITY-CHECK OBJECT 'M_MSEG_WMB' ID 'WERKS' FIELD P_WERKS. * IF SY-SUBRC <> 0. * CONCATENATE '你没有' P_WERKS '工厂的权限' INTO LV_MESSAGE. * MESSAGE LV_MESSAGE TYPE 'S' DISPLAY LIKE 'E'. * STOP. * ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *&---------------------------------------------------------------------* * text 获取数据 *----------------------------------------------------------------------* FORM FRM_GET_DATA. DATA:LV_CHECK TYPE CHAR1. SELECT DOCNUM"IDoc 号码 STATUS"状态 RCVPOR"接收方端口 SNDPOR"发件人端口 SNDPRN"发送者伙伴编号 CREDAT"创建日期 CRETIM"创建时间 MESTYP"消息类型 IDOCTP"基本类型 UPDDAT"更改日期 UPDTIM"更改时间 MAXSEGNUM"数据记录的数目 FROM EDIDC INTO TABLE GT_IDOC WHERE IDOCTP = P_IDOCTP AND CREDAT IN S_CREDAT AND CRETIM IN S_CRETIM. IF GT_IDOC IS NOT INITIAL. SELECT * FROM EDID4 INTO CORRESPONDING FIELDS OF TABLE GT_EDID4 FOR ALL ENTRIES IN GT_IDOC WHERE DOCNUM = GT_IDOC-DOCNUM. SORT GT_EDID4 BY DOCNUM SEGNUM. LOOP AT GT_IDOC ASSIGNING <GS_IDOC>. * LV_CHECK = ''. LOOP AT GT_EDID4 INTO GS_EDID4 WHERE DOCNUM = <GS_IDOC>-DOCNUM. <GS_IDOC>-SEGNUM = GS_EDID4-SEGNUM. <GS_IDOC>-SEGNAM = GS_EDID4-SEGNAM. <GS_IDOC>-SDATA = GS_EDID4-SDATA. * LV_CHECK = 'X'. CLEAR:GS_SEGNAM_HASH. GS_SEGNAM_HASH-SEGNAM = GS_EDID4-SEGNAM. INSERT GS_SEGNAM_HASH INTO TABLE GT_SEGNAM_HASH. APPEND <GS_IDOC> TO GT_ALV. CLEAR:GS_EDID4. ENDLOOP. * IF LV_CHECK <> 'X'. * APPEND <GS_IDOC> TO GT_ALV. * ENDIF. ENDLOOP. ENDIF. IF GT_ALV IS INITIAL. MESSAGE '系统中无相关数据' TYPE 'S' DISPLAY LIKE 'E'. STOP. ELSE. SORT GT_ALV BY DOCNUM SEGNUM. ENDIF. ENDFORM. " FRM_GET_DATA *&---------------------------------------------------------------------* *& Form FRM_SET_LAYOUT *&---------------------------------------------------------------------* * text 界面格式属性 *----------------------------------------------------------------------* FORM FRM_SET_LAYOUT . CLEAR GS_LAYOUT. GS_LAYOUT-SEL_MODE = 'A'. "选择行模式 GS_LAYOUT-CWIDTH_OPT = 'A'. "优化列宽设置 GS_LAYOUT-ZEBRA = 'X'. "设置斑马线 * GS_LAYOUT-BOX_FNAME = 'CHECKBOX'. ENDFORM. " FRM_SET_LAYOUT *&---------------------------------------------------------------------* *& Form FRM_SET_FIELDCAT *&---------------------------------------------------------------------* * text 字段属性定义 *----------------------------------------------------------------------* FORM FRM_SET_FIELDCAT. DATA:LT_ALV TYPE TABLE OF TY_IDOC, LS_ALV TYPE TY_IDOC, * LT_SEGNAM_HASH TYPE HASHED TABLE OF TY_SEGNAM WITH UNIQUE KEY SEGNAM, LT_SEGNAM_HASH TYPE TABLE OF TY_SEGNAM, LS_SEGNAM_HASH TYPE TY_SEGNAM, LT_FIELD TYPE LVC_T_FCAT, "字段目录内表 LS_FIELD TYPE LVC_S_FCAT. "字段目录工作区. DATA:CL_TABLE TYPE REF TO CL_ABAP_TABLEDESCR, CL_STRUCT TYPE REF TO CL_ABAP_STRUCTDESCR, LV_LINES TYPE I, LV_TABNAME TYPE DD02L-TABNAME. FIELD-SYMBOLS:<GS_TEMP> TYPE ANY, <LV_VALUE> TYPE ANY. REFRESH GT_FIELDCAT. DEFINE INIT_FILL_FCAT. CLEAR gs_fieldcat. gs_fieldcat-fieldname = &1. gs_fieldcat-coltext = &2. gs_fieldcat-scrtext_l = &2. gs_fieldcat-scrtext_m = &2. gs_fieldcat-scrtext_s = &2. gs_fieldcat-reptext = &2. gs_fieldcat-ref_table = &3. gs_fieldcat-ref_field = &4. gs_fieldcat-no_zero = &5. gs_fieldcat-ICON = &6. gs_fieldcat-hotspot = &7. gs_fieldcat-datatype = &8. gs_fieldcat-inttype = &9. APPEND gs_fieldcat TO gt_fieldcat. END-OF-DEFINITION. INIT_FILL_FCAT 'DOCNUM' 'IDoc 号码' 'EDIDC' 'DOCNUM' '' '' 'X' '' ''. INIT_FILL_FCAT 'SEGNUM' '段编号' 'EDID4' 'SEGNUM' '' '' '' '' ''. INIT_FILL_FCAT 'STATUS' '状态' 'EDIDC' 'STATUS' '' '' '' '' ''. INIT_FILL_FCAT 'RCVPOR' '接收方端口' 'EDIDC' 'RCVPOR' '' '' '' '' ''. INIT_FILL_FCAT 'SNDPOR' '发件人端口' 'EDIDC' 'SNDPOR' '' '' '' '' ''. * INIT_FILL_FCAT 'SNDPRN' '发送者伙伴编号' 'EDIDC' 'SNDPRN' '' '' '' '' ''. INIT_FILL_FCAT 'MESTYP' '消息类型' 'EDIDC' 'MESTYP' '' '' '' '' ''. INIT_FILL_FCAT 'IDOCTP' '基本类型' 'EDIDC' 'IDOCTP' '' '' 'X' '' ''. INIT_FILL_FCAT 'SEGNAM' 'SAP 段名' 'EDID4' 'SEGNAM' '' '' '' '' ''. INIT_FILL_FCAT 'CREDAT' '创建日期' 'EDIDC' 'CREDAT' '' '' '' '' ''. INIT_FILL_FCAT 'CRETIM' '创建时间' 'EDIDC' 'CRETIM' '' '' '' '' ''. INIT_FILL_FCAT 'UPDDAT' '更改日期' 'EDIDC' 'UPDDAT' '' '' '' '' ''. INIT_FILL_FCAT 'UPDTIM' '更改时间' 'EDIDC' 'UPDTIM' '' '' '' '' ''. * REFRESH:LT_ALV. * LT_ALV = GT_ALV. * * SORT LT_ALV BY SEGNUM SEGNAM. * DELETE ADJACENT DUPLICATES FROM LT_ALV COMPARING SEGNUM SEGNAM. * LOOP AT LT_ALV INTO LS_ALV. * CLEAR:LS_SEGNAM_HASH. * LS_SEGNAM_HASH-SEGNAM = LS_ALV-SEGNAM. * INSERT LS_SEGNAM_HASH INTO TABLE LT_SEGNAM_HASH. * CLEAR:LS_ALV. * ENDLOOP. REFRESH:LT_SEGNAM_HASH. LT_SEGNAM_HASH = GT_SEGNAM_HASH. * SORT LT_ALV BY DOCNUM SEGNUM. CLEAR:LV_LINES. * DESCRIBE TABLE LT_ALV LINES LV_LINES. DESCRIBE TABLE LT_SEGNAM_HASH LINES LV_LINES. REFRESH:GT_FIELD. IF LV_LINES > 1. * LOOP AT LT_ALV INTO LS_ALV. LOOP AT LT_SEGNAM_HASH INTO LS_SEGNAM_HASH. * CLEAR:LV_TABNAME. * LV_TABNAME = LS_ALV-SEGNAM. REFRESH:LT_FIELD. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING I_STRUCTURE_NAME = LS_SEGNAM_HASH-SEGNAM "这里也可以是表名 CHANGING CT_FIELDCAT = LT_FIELD. LOOP AT LT_FIELD INTO LS_FIELD. CLEAR:GS_FIELD. GS_FIELD = LS_FIELD. GS_FIELD-FIELDNAME = LS_SEGNAM_HASH-SEGNAM && '-' && GS_FIELD-FIELDNAME. GS_FIELD-TABNAME = LS_SEGNAM_HASH-SEGNAM. GS_FIELD-REF_TABLE = LS_SEGNAM_HASH-SEGNAM. GS_FIELD-REF_FIELD = LS_FIELD-FIELDNAME. APPEND GS_FIELD TO GT_FIELD. CLEAR:LS_FIELD. ENDLOOP. ENDLOOP. ELSE. READ TABLE LT_SEGNAM_HASH INTO LS_SEGNAM_HASH INDEX 1. IF SY-SUBRC EQ 0. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING I_STRUCTURE_NAME = LS_SEGNAM_HASH-SEGNAM "这里也可以是表名 CHANGING CT_FIELDCAT = GT_FIELD. ENDIF. LOOP AT GT_FIELD ASSIGNING <GS_FIELD>. <GS_FIELD>-TABNAME = LS_SEGNAM_HASH-SEGNAM. <GS_FIELD>-REF_TABLE = LS_SEGNAM_HASH-SEGNAM. <GS_FIELD>-REF_FIELD = <GS_FIELD>-FIELDNAME. ENDLOOP. ENDIF. * DELETE ADJACENT DUPLICATES FROM GT_FIELD COMPARING FIELDNAME. LOOP AT GT_FIELD INTO GS_FIELD. * INIT_FILL_FCAT GS_FIELD-FIELDNAME GS_FIELD-FIELDNAME GS_ALV-SEGNAM GS_FIELD-FIELDNAME '' '' '' '' ''. INIT_FILL_FCAT GS_FIELD-FIELDNAME GS_FIELD-FIELDNAME GS_FIELD-REF_TABLE GS_FIELD-REF_FIELD '' '' '' '' ''. CLEAR:GS_FIELD. ENDLOOP. ENDFORM. " FRM_SET_FIELDCAT *&---------------------------------------------------------------------* *& Form frm_create_table *&---------------------------------------------------------------------* * 创建动态内表 *----------------------------------------------------------------------* FORM FRM_CREATE_TABLE. DATA:LV_FIELDNAME TYPE CHAR5, LV_LENGTH TYPE I, LV_START TYPE I, LV_WIDTH TYPE I. CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE EXPORTING IT_FIELDCATALOG = GT_FIELDCAT IMPORTING EP_TABLE = DY_TABLE. "用表类型指针 <dyn_table> 指向 数据对象的内容. ASSIGN DY_TABLE->* TO <DYN_ALV>. "建立一个与动态内表结构相同的数据对象,且数据对象为是一个结构 CREATE DATA GS_LINE LIKE LINE OF <DYN_ALV>. "用<dyn_wa>指针指向该结构 ASSIGN GS_LINE->* TO <DYN_WA>. LOOP AT GT_ALV INTO GS_ALV. MOVE-CORRESPONDING GS_ALV TO <DYN_WA>. CLEAR:LV_LENGTH. LV_LENGTH = STRLEN( GS_ALV-SDATA )."日志字段值得长度 LOOP AT GT_FIELD INTO GS_FIELD WHERE TABNAME = GS_ALV-SEGNAM. IF LV_LENGTH > 0. ASSIGN COMPONENT GS_FIELD-FIELDNAME OF STRUCTURE <DYN_WA> TO <DYN_FIELD>. CLEAR:LV_START,LV_WIDTH. LV_WIDTH = GS_FIELD-INTLEN."当前字段的长度 <DYN_FIELD> = GS_ALV-SDATA. LV_LENGTH = LV_LENGTH - LV_WIDTH."总长度 - 截取的长度 IF LV_LENGTH > 0. GS_ALV-SDATA = GS_ALV-SDATA+LV_WIDTH(LV_LENGTH)."日志字段值截掉已赋值的长度 ENDIF. ENDIF. ENDLOOP. APPEND <DYN_WA> TO <DYN_ALV>. CLEAR:GS_ALV,<DYN_WA>. ENDLOOP. ENDFORM. " *&---------------------------------------------------------------------* *& Form FRM_DISPLAY_ALV *&---------------------------------------------------------------------* * text 界面显示 *----------------------------------------------------------------------* FORM FRM_DISPLAY_ALV . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING I_CALLBACK_PROGRAM = SY-REPID IS_LAYOUT_LVC = GS_LAYOUT * I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS' I_CALLBACK_USER_COMMAND = 'FRM_USER_COMMAND' IT_FIELDCAT_LVC = GT_FIELDCAT I_SAVE = 'A' TABLES T_OUTTAB = <DYN_ALV> 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. " FRM_DISPLAY_ALV *&---------------------------------------------------------------------* *& Form FRM_SET_STATUS *&---------------------------------------------------------------------* * text 状态栏 *----------------------------------------------------------------------* FORM FRM_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB. ENDFORM. " FRM_SET_STATUS *&---------------------------------------------------------------------* *& Form USER_COMMAND *&---------------------------------------------------------------------* * text 用户操作 *----------------------------------------------------------------------* FORM FRM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD. DATA:REF_GRID TYPE REF TO CL_GUI_ALV_GRID. RANGES:DOCNUM FOR EDIDC-DOCNUM, IDOCTP FOR EDIDC-IDOCTP, CREDAT FOR EDIDC-CREDAT. CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' IMPORTING E_GRID = REF_GRID. "获取全局变量 CALL METHOD REF_GRID->CHECK_CHANGED_DATA. "获取响应事件 REFRESH:GT_ROW. CALL METHOD REF_GRID->GET_SELECTED_ROWS "获取选择的行 IMPORTING ET_INDEX_ROWS = GT_ROW ET_ROW_NO = GT_ROW_NO. CASE R_UCOMM. WHEN '&IC1'. "ALV中双击事件代码 CLEAR GS_ALV. READ TABLE GT_ALV INTO GS_ALV INDEX RS_SELFIELD-TABINDEX. IF SY-SUBRC = 0. CASE RS_SELFIELD-FIELDNAME. WHEN 'DOCNUM'. REFRESH:DOCNUM. DOCNUM-SIGN = 'I'. DOCNUM-OPTION = 'EQ'. DOCNUM-LOW = GS_ALV-DOCNUM. APPEND DOCNUM. SUBMIT RSEIDOC2 WITH CRETIM IN S_CRETIM WITH CREDAT IN CREDAT WITH DOCNUM IN DOCNUM AND RETURN. WHEN 'IDOCTP'. REFRESH:IDOCTP. IDOCTP-SIGN = 'I'. IDOCTP-OPTION = 'EQ'. IDOCTP-LOW = GS_ALV-IDOCTP. APPEND IDOCTP. SUBMIT RSEIDOC2 WITH CRETIM IN S_CRETIM WITH CREDAT IN S_CREDAT WITH IDOCTP IN IDOCTP AND RETURN. ENDCASE. ENDIF. WHEN '&BACK'. LEAVE TO SCREEN 0. WHEN '&EXIT'. LEAVE PROGRAM. ENDCASE. RS_SELFIELD-REFRESH = 'X'."刷新界面 ENDFORM. "USER_COMMAND