项目背景:
搞备库单(新建一种类型的销售订单),备库单不出货(通过排程明细类别控制,也需要新增),正式销售订单创建时,备库单分配数量给正式SO,SO的排程明细类别也是新增的(不跑MRP),
创建后,如果备库单已有库存,则从备库单直接自动调拨库存到正式SO上,还有其它的一些增强还有控制,这里不说了。只能说这种需求能不做就尽量不做。后台作业太多了,各种错误都有。还得设置专门
修复错误的程序。
这里贴上VA02显示分配的情况(自建表)
MODULE SHOW_BKD_DATA OUTPUT. * CHECK SY-UNAME EQ 'MISHM'. CHECK SY-TCODE EQ 'VA02' OR SY-TCODE EQ 'VA03'. " DEFINE %_SET_FCAT. CLEAR: GS_FIELDCAT. GS_FIELDCAT-FIELDNAME = &1. "字段名称 GS_FIELDCAT-COLTEXT = &2. "字段描述 GS_FIELDCAT-REPTEXT = &2. "字段描述 GS_FIELDCAT-SCRTEXT_S = &2. "字段描述 GS_FIELDCAT-SCRTEXT_M = &2. "字段描述 GS_FIELDCAT-SCRTEXT_L = &2. "字段描述 GS_FIELDCAT-HOTSPOT = &3. "单机敏感热点事件 GS_FIELDCAT-KEY = &4. "关键字段 GS_FIELDCAT-NO_ZERO = &5. "隐藏前导零 GS_FIELDCAT-EDIT = &6. "可编辑 GS_FIELDCAT-CHECKBOX = &7. "复选框 GS_FIELDCAT-REF_TABLE = &8. "参考表 GS_FIELDCAT-REF_FIELD = &9. "参考字段 APPEND GS_FIELDCAT TO LT_FIELDCAT. END-OF-DEFINITION. DATA: * GV_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER, GV_ALV TYPE REF TO CL_GUI_ALV_GRID , "ALV网格 GV_ROW_ALV TYPE REF TO CL_GUI_ALV_GRID_BASE, GT_EXCLUDE TYPE UI_FUNCTIONS, "用于去掉不要的菜单栏 GV_INDEX_COLUMNS TYPE LVC_T_COL, "选择列 LT_FIELDCAT TYPE LVC_T_FCAT, "fcat GS_FIELDCAT TYPE LVC_S_FCAT, "fcat GT_F4 TYPE LVC_T_F4 WITH HEADER LINE, "搜索帮助 GS_LAYOUT TYPE LVC_S_LAYO , "布局结构 GS_VARIANT TYPE DISVARIANT, "字段格式保存 GT_SORT TYPE LVC_T_SORT, "用于排序 GT_INDEX TYPE LVC_T_COL, "选择列 GT_FILT TYPE LVC_T_FILT. "用于过滤 DATA:GT_NU3_ROWS TYPE LVC_T_ROW, GT_NU3_NO TYPE LVC_T_ROID, GS_NU3_NO TYPE LVC_S_ROID. DATA:GV_LINES TYPE I. DATA: BEGIN OF GT_EXCLTAB OCCURS 0, "隐藏工具栏按钮 FCODE LIKE SY-UCOMM, END OF GT_EXCLTAB. DATA: G_CUSTOM_CONTAINER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER, G_CONTAINER2 TYPE SCRFNAME VALUE 'Z_BKD_ALV'. IF GV_ALV IS INITIAL . "ALV对象如果为空,则生成对象,把ALV放入容器中 CREATE OBJECT G_CUSTOM_CONTAINER2 EXPORTING CONTAINER_NAME = G_CONTAINER2. CREATE OBJECT GV_ALV EXPORTING I_PARENT = G_CUSTOM_CONTAINER2. * PERFORM FRM_PREPARE_LAYOUT CHANGING GS_LAYOUT . "获取样式 GS_LAYOUT-NO_ROWMARK = 'X'. "禁用行选择 GS_LAYOUT-CWIDTH_OPT = 'X'. "最优化宽度 GS_LAYOUT-ZEBRA = 'X'. "间隔颜色(斑马线) GS_LAYOUT-STYLEFNAME = 'CELLTAB'. "单元格可编辑控制字段 GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'."颜色控制字段 * PERFORM FRM_BUILD_FIELDCAT . "获取字段格式 CLEAR:LT_FIELDCAT. %_SET_FCAT 'VKORG' '銷售組織' '' '' '' '' '' 'ZHMSBKALV' 'VKORG'. %_SET_FCAT 'ZVBELN' '備庫單(虛擬SO)' '' '' '' '' '' 'ZHMSBKALV' 'ZVBELN'. %_SET_FCAT 'ZPOSNR' '備庫單(虛擬SO)行項目' '' '' '' '' '' 'ZHMSBKALV' 'ZPOSNR'. %_SET_FCAT 'VBELN' '正式銷售訂單' '' '' '' '' '' 'ZHMSBKALV' 'VBELN'. %_SET_FCAT 'POSNR' '正式銷售訂單行項目' '' '' '' '' '' 'ZHMSBKALV' 'POSNR'. %_SET_FCAT 'MATNR' '物料號碼' '' '' '' '' '' 'ZHMSBKALV' 'MATNR'. %_SET_FCAT 'ZKWMENG_C' '待調撥(冲销)数量' '' '' '' '' '' 'ZHMSBKALV' 'ZKWMENG_C'. %_SET_FCAT 'ZKWMENG_F' '分配的數量' '' '' '' '' '' 'ZHMSBKALV' 'ZKWMENG_F'. * PERFORM FRM_EXCLUDE_TB_FUNCTIONS CHANGING GT_EXCLUDE . "去掉不用的菜单按钮 DATA LS_EXCLUDE TYPE UI_FUNC. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_PRINT . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_VIEW . APPEND LS_EXCLUDE TO GT_EXCLUDE. LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_INFO . APPEND LS_EXCLUDE TO GT_EXCLUDE. * PERFORM FRM_EVENTLOAD . "读取事件(总) DATA LV_EVENT_HANDLER TYPE REF TO LCL_EVENT_HANDLER . "事件响应 DATA:LT_F4 TYPE LVC_T_F4 WITH HEADER LINE. "F4帮助 CREATE OBJECT LV_EVENT_HANDLER. * IF GV_ALV IS NOT INITIAL. "注册单元格可编辑事件 CALL METHOD GV_ALV->SET_READY_FOR_INPUT EXPORTING I_READY_FOR_INPUT = 1. "注册回车触发单元格校验事件 CALL METHOD GV_ALV->REGISTER_EDIT_EVENT EXPORTING I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER EXCEPTIONS ERROR = 1 OTHERS = 2. "注册鼠标移动触发单元格校验事件 CALL METHOD GV_ALV->REGISTER_EDIT_EVENT EXPORTING I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED EXCEPTIONS ERROR = 1 OTHERS = 2. "注册搜索帮助事件 * lt_f4[] = VALUE #( ( fieldname = 'ZXSY' register = 'X' getbefore = 'X' chngeafter = 'X' ) ). CALL METHOD GV_ALV->REGISTER_F4_FOR_FIELDS EXPORTING IT_F4 = LT_F4[]. "为ALV添加按钮 SET HANDLER LV_EVENT_HANDLER->HANDLE_TOOLBAR FOR GV_ALV . "数据更新事件 SET HANDLER LV_EVENT_HANDLER->HANDLE_DATA_CHANGED FOR GV_ALV. "数据更新完成后事件 SET HANDLER LV_EVENT_HANDLER->HANDLE_DATA_CHANGED_FINISHED FOR GV_ALV. "单机事件 SET HANDLER LV_EVENT_HANDLER->HANDLE_HOTSPOT_CLICK FOR GV_ALV. "双击事件 SET HANDLER LV_EVENT_HANDLER->HANDLE_DOUBLE_CLICK FOR GV_ALV. "按钮触发前事件 SET HANDLER LV_EVENT_HANDLER->HANDLE_BEFORE_USER_COMMAND FOR GV_ALV. "搜索帮助事件 SET HANDLER LV_EVENT_HANDLER->HANDLE_ONF4 FOR GV_ALV. DATA LV_EVENT_HANDLER1 TYPE REF TO LCL_EVENT_HANDLER . "事件响应 CREATE OBJECT LV_EVENT_HANDLER1. ENDIF. IF GT_ALV[] IS INITIAL. CASE VBAK-AUART. WHEN 'ZBK1'."備庫單 SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ALV FROM ZHMTSDXH01 WHERE ZVBELN EQ VBAK-VBELN. "備庫單 WHEN OTHERS."正式SO SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ALV FROM ZHMTSDXH01 WHERE VBELN EQ VBAK-VBELN. "正式SO ENDCASE. ENDIF. LOOP AT GT_ALV INTO GS_ALV. IF GS_ALV-ZFLAG EQ 'X'. GS_ALV-ZKWMENG_C = 0. ENDIF. MODIFY GT_ALV FROM GS_ALV . CLEAR GS_ALV. ENDLOOP. *----------------------显示ALV-------------------------- CLEAR GS_VARIANT. GS_VARIANT-REPORT = SY-REPID. GS_VARIANT-HANDLE = 9000. CALL METHOD GV_ALV->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING IS_LAYOUT = GS_LAYOUT IT_TOOLBAR_EXCLUDING = GT_EXCLUDE IS_VARIANT = GS_VARIANT I_SAVE = 'A' CHANGING IT_OUTTAB = GT_ALV IT_FIELDCATALOG = LT_FIELDCAT EXCEPTIONS INVALID_PARAMETER_COMBINATION = 0 PROGRAM_ERROR = 0 TOO_MANY_LINES = 0 OTHERS = 0. ELSE . CASE VBAK-AUART. WHEN 'ZBK1'."備庫單 SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ALV FROM ZHMTSDXH01 WHERE ZVBELN EQ VBAK-VBELN. "備庫單 WHEN OTHERS."正式SO SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ALV FROM ZHMTSDXH01 WHERE VBELN EQ VBAK-VBELN. "正式SO ENDCASE. LOOP AT GT_ALV INTO GS_ALV. IF GS_ALV-ZFLAG EQ 'X'. GS_ALV-ZKWMENG_C = 0. ENDIF. MODIFY GT_ALV FROM GS_ALV . CLEAR GS_ALV. ENDLOOP. * PERFORM FRM_REFURBISH_ALV. "刷新ALV DATA:LS_STABLE TYPE LVC_S_STBL. CALL METHOD GV_ALV->SET_FRONTEND_LAYOUT EXPORTING IS_LAYOUT = GS_LAYOUT. LS_STABLE-ROW = 'X'. LS_STABLE-COL = 'X'. CALL METHOD GV_ALV->REFRESH_TABLE_DISPLAY EXPORTING IS_STABLE = LS_STABLE EXCEPTIONS FINISHED = 0 OTHERS = 0. ENDIF . ENDMODULE. "SHOW_BKD_DATA OUTPUTView Code
标签:GT,GS,TYPE,ALV,LS,alv,EXCLUDE,VA03,VA02 From: https://www.cnblogs.com/chaguoguo/p/18316371