1、写在前面
生产订单修改记录报表对于项目上并不陌生。通常会在增强中编写逻辑来判断生产订单主要信息是否有变更,有则保存到日志表,并通过查询报表展示,帮助用户查看生产订单发生的修改。
本文档的代码,只是对现有逻辑的一些优化,通过配置表的方式,设置监控字段,灵活监控生产订单这些字段的变更,也方便迁移到其他项目使用。
利弊不谈,只是换个思路解决问题,感兴趣的读者可以试一下,也一起测试一下是否有隐藏的BUG。
如果仅仅实施一次,也不需要像本文档这么复杂,直接在增强中写死需要监控的字段就可以了。
2、实施过程
2.1、实施保存增强
CMOD实施订单保存增强
保存时调用日志记录函数
2.2、自建表
创建监控字段配置表,配置需要监控的生产订单字段
其中“表名”和“删除标识”是自定义的域
维护上对应结构的字段,可以根据“表名”字段的搜索帮助找到对应字段。例如找到抬头对应的结构为CAUFVDB,可从CAUFVDB结构中找到要监控的抬头字段,工艺、组件同理。
创建更改日志表,用于存放更改的记录
增强中的函数ZPP_CO02_LOG则根据配置表维护的数据,监控对应的数据改变,并保存到日志表中。
创建查询报表将日志表中的数据进行展示,效果如下
3、参考代码
3.1、增强函数
FUNCTION zpp_co02_log. *"---------------------------------------------------------------------- *"*"本地接口: *" TABLES *" HEADER_TABLE STRUCTURE CAUFVDB *" HEADER_TABLE_OLD STRUCTURE CAUFVDB *" POSITION_TABLE STRUCTURE AFPOB *" POSITION_TABLE_OLD STRUCTURE AAFPO *" SEQUENCE_TABLE STRUCTURE AFFLB *" SEQUENCE_TABLE_OLD STRUCTURE AAFFL *" OPERATION_TABLE STRUCTURE AFVGB *" OPERATION_TABLE_OLD_AFVC STRUCTURE AAFVC *" OPERATION_TABLE_OLD_AFVV STRUCTURE AAFVV *" COMPONENT_TABLE STRUCTURE RESBB *" COMPONENT_TABLE_OLD STRUCTURE ARESB *" RELATION_TABLE STRUCTURE AFABB OPTIONAL *" RELATION_TABLE_OLD STRUCTURE AAFAB OPTIONAL *" PSTEXT_TABLE STRUCTURE NPTXB OPTIONAL *" PSTEXT_TABLE_OLD STRUCTURE ANPTX OPTIONAL *" MILESTONE_TABLE STRUCTURE MLSTB OPTIONAL *" MILESTONE_TABLE_OLD STRUCTURE AMLST OPTIONAL *" PLANNED_ORDER_TABLE STRUCTURE PLAF *" STATUS_TABLE STRUCTURE JEST *" STATUS_TABLE_OLD STRUCTURE JEST *" OPERATION_RELATIONS STRUCTURE PRE_DEC *" OPERATION_RELATIONS_OLD STRUCTURE PRE_DEC *" OPERATION_TABLE_OLD_AFVU STRUCTURE AAFVU *" DOCLINK_TABLE STRUCTURE AFDLD *" DOCLINK_TABLE_OLD STRUCTURE AFDLD *"---------------------------------------------------------------------- CHECK sy-tcode = 'CO02'. CONSTANTS:c_h TYPE string VALUE '抬头'. CONSTANTS:c_r TYPE string VALUE '工艺'. CONSTANTS:c_c TYPE string VALUE '组件'. CONSTANTS:c_s TYPE string VALUE '订单状态'. DATA:lt_log TYPE TABLE OF zppt_gdbg_log, ls_log TYPE zppt_gdbg_log, ls_log_temp TYPE zppt_gdbg_log. DATA:lv_tname TYPE zppt_gdbg_zd-tabname, lv_tname_old TYPE zppt_gdbg_zd-tabname. "IP和HOST DATA: lv_iporg TYPE msxxlist-hostadr, lv_ipdec TYPE char16, lv_host TYPE char18. DATA:lv_arbpl TYPE arbpl, lv_arbpl_old TYPE arbpl. DATA:lv_delete TYPE c, lv_seq TYPE zppt_gdbg_log-seqno. FIELD-SYMBOLS:<fs_field> TYPE any, <fs_field_old> TYPE any. SELECT SINGLE MAX( seqno ) FROM zppt_gdbg_log INTO lv_seq WHERE aufnr = header_table-aufnr. "生产订单变更日期监控字段 SELECT tabname,"表名 fieldname,"字段 ddtext"名称 FROM zppt_gdbg_zd INTO TABLE @DATA(lt_field). ** Get user IP,hostname CALL FUNCTION 'TH_USER_INFO' " Get user IP,hostname EXPORTING client = sy-mandt user = sy-uname IMPORTING hostaddr = lv_iporg terminal = lv_host EXCEPTIONS OTHERS = 1. **"Conv.IP addr to format 'xxx.xxx.xxx.xxx' CALL FUNCTION 'GWY_IPADR2STRING' "Conv.IP addr EXPORTING ipadr = lv_iporg IMPORTING string = lv_ipdec. READ TABLE header_table INDEX 1. READ TABLE header_table_old INDEX 1. READ TABLE position_table INDEX 1. READ TABLE position_table_old INDEX 1. ls_log_temp-mandt = sy-mandt. ls_log_temp-aenam = sy-uname. ls_log_temp-laeda = sy-datum. ls_log_temp-times = sy-uzeit. ls_log_temp-tcode = sy-tcode. ls_log_temp-host = lv_host. ls_log_temp-ip = lv_ipdec. ls_log_temp-aufnr = header_table-aufnr. *1)生产订单抬头更改记录字段 LOOP AT lt_field INTO DATA(ls_field) WHERE tabname = 'HEAD'. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE header_table TO <fs_field>. IF sy-subrc EQ 0. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE header_table_old TO <fs_field_old>. IF sy-subrc EQ 0 AND <fs_field> <> <fs_field_old>. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_h. ls_log-chnid = 'U'. ls_log-field = ls_field-ddtext. ls_log-value_old = <fs_field_old>. ls_log-value_new = <fs_field>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDIF. CLEAR:ls_field. ENDLOOP. LOOP AT lt_field INTO ls_field WHERE tabname = 'POSI'. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE position_table TO <fs_field>. IF sy-subrc EQ 0. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE position_table_old TO <fs_field_old>. IF sy-subrc EQ 0 AND <fs_field> <> <fs_field_old>. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_h. ls_log-chnid = 'U'. ls_log-field = ls_field-ddtext. ls_log-value_old = <fs_field_old>. ls_log-value_new = <fs_field>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDIF. CLEAR:ls_field. ENDLOOP. *-组件 *2)生产订单组件更改记录字段 * 删除组件时也需要记录以上内容 LOOP AT component_table WHERE vbkz EQ 'U' OR vbkz EQ 'I' OR vbkz EQ 'D'. CASE component_table-vbkz. WHEN 'I'. LOOP AT lt_field INTO ls_field WHERE tabname = 'COMP'. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE component_table TO <fs_field>. IF sy-subrc EQ 0 AND <fs_field> IS NOT INITIAL. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_c. ls_log-chnid = 'I'. ls_log-field = ls_field-ddtext. ls_log-matnr = component_table-matnr. ls_log-value_new = <fs_field>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. CLEAR:ls_field. ENDLOOP. WHEN 'D'. CLEAR component_table_old. READ TABLE component_table_old WITH KEY rsnum = component_table-rsnum rspos = component_table-rspos. LOOP AT lt_field INTO ls_field WHERE tabname = 'COMP'. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE component_table_old TO <fs_field_old>. IF sy-subrc EQ 0 AND <fs_field_old> IS NOT INITIAL. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_c. ls_log-chnid = 'D'. ls_log-field = ls_field-ddtext. ls_log-matnr = component_table_old-matnr. ls_log-value_old = <fs_field_old>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. CLEAR:ls_field. ENDLOOP. WHEN 'U'. CLEAR component_table_old. READ TABLE component_table_old WITH KEY rsnum = component_table-rsnum rspos = component_table-rspos. LOOP AT lt_field INTO ls_field WHERE tabname = 'COMP'. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE component_table TO <fs_field>. IF sy-subrc EQ 0. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE component_table_old TO <fs_field_old>. IF sy-subrc EQ 0 AND <fs_field> <> <fs_field_old>. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_c. ls_log-chnid = 'U'. ls_log-field = ls_field-ddtext. ls_log-matnr = component_table-matnr. ls_log-value_old = <fs_field_old>. ls_log-value_new = <fs_field>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDIF. CLEAR:ls_field. ENDLOOP. ENDCASE. ENDLOOP. *-工艺路线 *3)生产订单工艺更改记录字段 LOOP AT operation_table WHERE vbkz EQ 'U' OR vbkz EQ 'I' OR vbkz EQ 'D'. CASE operation_table-vbkz. WHEN 'I'. LOOP AT lt_field INTO ls_field WHERE tabname = 'OPER'. IF ls_field-fieldname = 'ARBPL'."工作中心 CLEAR:lv_arbpl. SELECT SINGLE arbpl FROM crhd INTO lv_arbpl WHERE objid = operation_table-arbid. IF lv_arbpl IS NOT INITIAL. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_r. ls_log-chnid = 'I'. ls_log-field = '工作中心'. ls_log-vornr = operation_table-vornr. ls_log-value_new = lv_arbpl. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ELSE. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE operation_table TO <fs_field>. IF sy-subrc EQ 0 AND <fs_field> IS NOT INITIAL. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_r. ls_log-chnid = 'I'. ls_log-field = ls_field-ddtext. ls_log-vornr = operation_table-vornr. ls_log-value_new = <fs_field>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDIF. CLEAR:ls_field. ENDLOOP. WHEN 'D'."删除工艺并不会设置为D,要用状态来判断 WHEN 'U'. "用状态判断工艺是否删除 CLEAR lv_delete. READ TABLE status_table WITH KEY objnr = operation_table-objnr stat = 'I0013' inact = ''. IF sy-subrc = 0. lv_delete = 'X'. ENDIF. CLEAR operation_table_old_afvc. READ TABLE operation_table_old_afvc WITH KEY aufpl = operation_table-aufpl aplzl = operation_table-aplzl. CLEAR operation_table_old_afvv. READ TABLE operation_table_old_afvv WITH KEY aufpl = operation_table-aufpl aplzl = operation_table-aplzl. CLEAR lv_arbpl. SELECT SINGLE arbpl FROM crhd INTO lv_arbpl WHERE objid = operation_table-arbid. CLEAR lv_arbpl_old. SELECT SINGLE arbpl FROM crhd INTO lv_arbpl_old WHERE objid = operation_table_old_afvc-arbid. IF lv_delete = 'X'."删除 LOOP AT lt_field INTO ls_field WHERE tabname = 'OPER'. IF ls_field-fieldname = 'ARBPL'."工作中心 IF lv_arbpl_old IS NOT INITIAL. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_r. ls_log-chnid = 'D'. ls_log-field = '工作中心'. ls_log-vornr = operation_table-vornr. ls_log-value_old = lv_arbpl_old. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ELSE. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE operation_table_old_afvc TO <fs_field_old>. IF sy-subrc NE 0. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE operation_table_old_afvv TO <fs_field_old>. ENDIF. IF sy-subrc EQ 0 AND <fs_field_old> IS NOT INITIAL. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_r. ls_log-chnid = 'D'. ls_log-field = ls_field-ddtext. ls_log-vornr = operation_table-vornr. ls_log-value_old = <fs_field_old>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDIF. CLEAR:ls_field. ENDLOOP. ELSE."修改 LOOP AT lt_field INTO ls_field WHERE tabname = 'OPER'. IF ls_field-fieldname = 'ARBPL'."工作中心 IF lv_arbpl <> lv_arbpl_old. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_r. ls_log-chnid = 'U'. ls_log-field = '工作中心'. ls_log-vornr = operation_table-vornr. ls_log-value_old = lv_arbpl_old. ls_log-value_new = lv_arbpl. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ELSE. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE operation_table TO <fs_field>. IF sy-subrc EQ 0. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE operation_table_old_afvc TO <fs_field_old>. IF sy-subrc NE 0. ASSIGN COMPONENT ls_field-fieldname OF STRUCTURE operation_table_old_afvv TO <fs_field_old>. ENDIF. IF sy-subrc EQ 0 AND <fs_field> <> <fs_field_old>. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_r. ls_log-chnid = 'U'. ls_log-field = ls_field-ddtext. ls_log-vornr = operation_table-vornr. ls_log-value_old = <fs_field_old>. ls_log-value_new = <fs_field>. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDIF. ENDIF. ENDLOOP. ENDIF. WHEN OTHERS. ENDCASE. ENDLOOP. *-生产订单状态 *4)生产订单状态记录 LOOP AT status_table WHERE objnr = header_table-objnr. READ TABLE status_table_old WITH KEY objnr = status_table-objnr stat = status_table-stat. IF sy-subrc = 0. IF status_table_old-inact <> status_table-inact. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_s. ls_log-chnid = 'U'. ls_log-field = status_table-stat. IF status_table_old-inact = 'X'. ls_log-value_old = '状态未激活'. ls_log-value_new = '状态激活'. ELSE. ls_log-value_old = '状态激活'. ls_log-value_new = '状态未激活'. ENDIF. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ELSE. ls_log = ls_log_temp. lv_seq = lv_seq + 1. ls_log-seqno = lv_seq. ls_log-object = c_s. ls_log-chnid = 'U'. ls_log-field = status_table-stat. ls_log-value_old = ''. ls_log-value_new = '状态激活'. APPEND ls_log TO lt_log. CLEAR ls_log. ENDIF. ENDLOOP. IF lt_log IS NOT INITIAL. INSERT zppt_gdbg_log FROM TABLE lt_log. REFRESH:lt_log. ENDIF. ENDFUNCTION.
3.2、报表代码
*&---------------------------------------------------------------------* *& Report: ZPP_GDBG_LOG * *& * *&---------------------------------------------------------------------* * Creation Date : * * Author : * * Description : 生产订单变更记录报表 * * Tcode : ZPP_GDBG_LOG * * Doc : 生产订单变更记录报表 * Notion: * 依赖增强 * # 二代增强 * PPCO0001 : EXIT_SAPLCOBT_001 开发应用程序: PP订单 * # 增强内部调用函数 * ZPP_CO02_LOG *----------------------------------------------------------------------* REPORT ZPP_GDBG_LOG. *----------------------------------------------------------------------* *表声明 *----------------------------------------------------------------------* TABLES:afko,zppt_gdbg_log,aufk. *----------------------------------------------------------------------* *类型池声明 *----------------------------------------------------------------------* TYPE-POOLS:slis. *----------------------------------------------------------------------* * 类型定义 *----------------------------------------------------------------------* TYPES: BEGIN OF ty_alv. include structure zppt_gdbg_log. TYPES: color(4) TYPE c. TYPES: END OF ty_alv. *----------------------------------------------------------------------* * 声明内表和工作区 *----------------------------------------------------------------------* DATA:gt_alv TYPE TABLE OF ty_alv, gs_alv TYPE ty_alv. *----------------------------------------------------------------------* *ALV参数声明 *----------------------------------------------------------------------* DATA:gt_fieldcat TYPE lvc_t_fcat, "字段目录内表 gs_fieldcat TYPE lvc_s_fcat, "字段目录工作区 gs_layout TYPE lvc_s_layo. "用于定义ALV表单的相关格式、属性 *----------------------------------------------------------------------* *选 择 屏 幕 定 义 块 *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE TEXT-001 . SELECT-OPTIONS:s_werks FOR aufk-werks NO INTERVALS OBLIGATORY, s_aufnr FOR zppt_gdbg_log-aufnr, "生产订单 s_aenam FOR zppt_gdbg_log-aenam, "更改者 s_laeda FOR zppt_gdbg_log-laeda. "修改日期 SELECTION-SCREEN END OF BLOCK block1 . *&---------------------------------------------------------------------* *& INITIALIZATION:程序初始化时所执行的代码 *&---------------------------------------------------------------------* INITIALIZATION. *&---------------------------------------------------------------------* *& AT SELECTION-SCREEN:在选择屏幕上执行的代码 *&---------------------------------------------------------------------* AT SELECTION-SCREEN. *&---------------------------------------------------------------------* *& START-OF-SELECTION:程序运行所处理的代码 *&---------------------------------------------------------------------* START-OF-SELECTION. "权限检查 PERFORM frm_check_srceen. "获取取数 PERFORM frm_get_data. "设置字段属性 PERFORM frm_set_fieldcat. "设置输出格式 PERFORM frm_set_layout. "显示ALV PERFORM frm_display_alv. *&---------------------------------------------------------------------* *& Form FRM_CHECK_SRCEEN *----------------------------------------------------------------------* FORM frm_check_srceen. ENDFORM. "frm_check_srceen *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *----------------------------------------------------------------------* FORM frm_get_data. SELECT co~aufnr," co~aenam," co~laeda," co~times," co~seqno," co~tcode," co~chnid," co~field," co~object," co~matnr," co~vornr," co~host," co~value_old," co~value_new," co~ip FROM zppt_gdbg_log AS co INNER JOIN aufk AS fv ON fv~aufnr = co~aufnr INTO TABLE @DATA(lt_log) WHERE co~aufnr IN @s_aufnr AND co~aenam IN @s_aenam AND co~laeda IN @s_laeda AND fv~werks IN @s_werks. LOOP AT lt_log INTO DATA(ls_log). CLEAR:gs_alv. MOVE-CORRESPONDING ls_log TO gs_alv. CASE gs_alv-chnid. WHEN 'U'. gs_alv-color = 'C510'. WHEN 'I'. gs_alv-color = 'C710'. WHEN 'D'. gs_alv-color = 'C610'. ENDCASE. APPEND gs_alv TO gt_alv. CLEAR:ls_log. ENDLOOP. SORT gt_alv BY aufnr seqno. ENDFORM. "FRM_GET_DATA *&---------------------------------------------------------------------* *& Form FRM_SET_FIELDCAT *----------------------------------------------------------------------* FORM frm_set_fieldcat. REFRESH gt_fieldcat. DEFINE init_fill_fcat. CLEAR:gs_fieldcat. gs_fieldcat-fieldname = &1. gs_fieldcat-coltext = &2. gs_fieldcat-ref_table = &3. gs_fieldcat-ref_field = &4. gs_fieldcat-key = &5. gs_fieldcat-hotspot = &6. gs_fieldcat-edit = &7. gs_fieldcat-no_zero = &8. gs_fieldcat-icon = &9. APPEND gs_fieldcat TO gt_fieldcat. END-OF-DEFINITION. init_fill_fcat 'AUFNR' '生产订单' 'ZPPT_GDBG_LOG' 'AUFNR' 'X' '' '' 'X' ''. init_fill_fcat 'SEQNO' '序号' '' '' 'X' '' '' '' ''. init_fill_fcat 'FIELD' '描述' '' '' 'X' '' '' '' ''. init_fill_fcat 'VALUE_OLD' '旧值' '' '' '' '' '' '' ''. init_fill_fcat 'VALUE_NEW' '新值' '' '' '' '' '' '' ''. init_fill_fcat 'OBJECT' '对象名称' 'ZPPT_GDBG_LOG' 'OBJECT' 'X' '' '' '' ''. init_fill_fcat 'MATNR' '物料' 'ZPPT_GDBG_LOG' 'MATNR' '' '' '' 'X' ''. init_fill_fcat 'VORNR' '组件工序' 'ZPPT_GDBG_LOG' 'VORNR' '' '' '' '' ''. init_fill_fcat 'AENAM' '修改人' 'ZPPT_GDBG_LOG' 'AENAM' '' '' '' '' ''. init_fill_fcat 'LAEDA' '修改日期' 'ZPPT_GDBG_LOG' 'LAEDA' '' '' '' 'X' ''. init_fill_fcat 'TIMES' '修改时间' 'ZPPT_GDBG_LOG' 'TIMES' '' '' '' 'X' ''. init_fill_fcat 'TCODE' '事务代码' 'ZPPT_GDBG_LOG' 'TCODE' '' '' '' '' ''. init_fill_fcat 'CHNID' '修改类型' 'ZPPT_GDBG_LOG' 'CHNID' '' '' '' '' ''. init_fill_fcat 'IP' 'IP地址' 'ZPPT_GDBG_LOG' 'IP' '' '' '' '' ''. init_fill_fcat 'HOST' '机器名' 'ZPPT_GDBG_LOG' 'HOST' '' '' '' '' ''. ENDFORM. "FRM_SET_FIELDCAT *&---------------------------------------------------------------------* *& 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'. gs_layout-info_fname = 'COLOR'. ENDFORM. " FRM_SET_LAYOUT *&---------------------------------------------------------------------* *& 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 = gt_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 SUB_USER_COMMAND、 *----------------------------------------------------------------------* FORM frm_user_command USING s_ucomm TYPE sy-ucomm re_selfield TYPE slis_selfield. CASE s_ucomm. WHEN '&IC1'. CLEAR gs_alv. READ TABLE gt_alv INTO gs_alv INDEX re_selfield-tabindex. IF sy-subrc = 0. SET PARAMETER ID 'ANR' FIELD gs_alv-aufnr. CALL TRANSACTION 'CO03' AND SKIP FIRST SCREEN. ENDIF. ENDCASE. ENDFORM. "SUB_USER_COMMAND *Selection texts *---------------------------------------------------------- * S_AENAM 更改者 * S_AUFNR 生产订单 * S_LAEDA 更改日期 * S_WERKS 工厂