***********************************************************************
* Title : ZMMR106 *
* Application : MM *
* Subject : MRP再计划日期更新PO的交货日期 *
* Requested by : 采购部 *
* Execution : any time *
* Ref no: : B179 *
* Author : rainy *
* Req Date : 20150706 *
***********************************************************************
* Production Order Variance Report *
***********************************************************************
***********************************************************************
*1.取数:通过料号+工厂 取出MD04 MRP清单数据, *
*2.输出:工厂:(1)3000公司下工厂时,用MRP里的再计划日期更新对应PO的 *
* 交货日期; *
* (2)1000公司下工厂时,找到po+po line 对应的预留的再计划*
* 日期,用该日期更新到原po line 的交货日期。 *
*
*3.Que:1.确定字符串的值 *
* 2.变量记清楚 *
* 3.处理3000的po 交货日期时候,是否要将再计划日期-7. *
* 4.zrevs."ReservationUdate LOG 修改预留号要不要保存历史 *
***********************************************************************
* MODIFICATIONS (latest entry at the top) *
* ------------------------------------------------------------------- *
* REL DATE NAME (COMPANY) DESCRIPTION TASK-NO *
* --- ---- ---- --------- ----------- ------- *
* *
***********************************************************************
REPORT zmmr106 MESSAGE-ID zmm_001.
TYPE-POOLS: slis.
*TYPE-POOLS: vrm.
*----------------------------------------------------------------------
* Tables
*----------------------------------------------------------------------
TABLES:mara,
marc,
resb,
ekpo.
* mchb, "批量库存
* zrevs."ReservationUdate LOG
TYPES: BEGIN OF ty_tab,
matnr LIKE marc-matnr,
mtart LIKE mara-mtart,
spart LIKE mara-spart,
werks LIKE marc-werks,
webaz LIKE marc-webaz,
dat00 LIKE mdez-dat00,
*&MRP元素 if delb0 = 'PO项目',则处理
delb0 LIKE mdez-delb0,
*&MRP数据()
extra LIKE mdez-extra,
*&拆解MRP数据
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
umdat LIKE mdez-umdat,
auskt LIKE mdez-auskt,
mng01 LIKE mdez-mng01,
mng02 LIKE mdez-mng02,
wrk02 LIKE mdez-wrk02,
lgort LIKE mdez-lgort,
lifnr LIKE mdez-lifnr,
md4li LIKE mdez-md4li,
zzdate LIKE ekpo-zzdate,
zzrsnum LIKE ekpo-zzrsnum,
rspos LIKE resb-rspos,
umdat_1 LIKE mdez-umdat,"1000公司更新的 再计划日期
umdat_1o LIKE mdez-umdat,"original
umdat_3 LIKE mdez-umdat,"3000公司更新的 再计划日期
umdat_3o LIKE mdez-umdat,
sel TYPE c,
zicon TYPE char4,
ztext TYPE string,
END OF ty_tab.
DATA:gt_tab TYPE STANDARD TABLE OF ty_tab,
* gt_tab_ALV TYPE STANDARD TABLE OF ty_tab,
gt_tab_use TYPE STANDARD TABLE OF ty_tab,
gt_tab_alv TYPE STANDARD TABLE OF ty_tab,
wa_tab TYPE ty_tab,
lw_tab TYPE ty_tab.
DATA:g_lines TYPE string.
DATA: BEGIN OF mdezx OCCURS 0.
INCLUDE STRUCTURE mdez."MRP要素的个别行
DATA: END OF mdezx.
DATA:mdezx_3 LIKE TABLE OF mdezx WITH HEADER LINE.
DATA: BEGIN OF mdpsx OCCURS 0.
INCLUDE STRUCTURE mdps."MRP凭证中的项目
DATA: END OF mdpsx.
DATA:mdpsx_3 LIKE TABLE OF mdpsx WITH HEADER LINE.
DATA: BEGIN OF mdsux OCCURS 0.
INCLUDE STRUCTURE mdsu."MRP元素全部的行
DATA: END OF mdsux.
DATA:mdsux_3 LIKE TABLE OF mdsux WITH HEADER LINE.
RANGES:r_lgort FOR mdez-lgort.
r_lgort(3) = 'IEQ'.
r_lgort-low = 'ACA1'.
APPEND r_lgort.
r_lgort-low = 'ACB1'.
APPEND r_lgort.
*&------------------------------------------------------------------*
*& PO change use
*&------------------------------------------------------------------*
DATA :return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
poitemx TYPE bapimepoitemx OCCURS 0 WITH HEADER LINE,
pocomponents TYPE bapimepocomponent OCCURS 0 WITH HEADER LINE,
pocomponentsx LIKE bapimepocomponentx OCCURS 0 WITH HEADER LINE,
poschedulex TYPE bapimeposchedulx OCCURS 0 WITH HEADER LINE,
poschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE.
DATA:lt_string TYPE STANDARD TABLE OF string WITH HEADER LINE.
*DATA:LT_EKET LIKE EKET OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF lt_eket OCCURS 0,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
etenr LIKE eket-etenr,
eindt LIKE eket-eindt,
zzdate LIKE ekpo-zzdate,
END OF lt_eket.
RANGES:r_ebelp FOR ekpo-ebelp.
*DATA:L_ZZRSNUM LIKE EKPO-ZZRSNUM,
* L_ZZDATE LIKE EKPO-ZZDATE.
* L_EBELN LIKE EKPO-EBELN,
* L_EBELP LIKE EKPO-EBELP.
*&------------------------------------------------------------------*
*& Global Variants Definition
*&------------------------------------------------------------------*
FIELD-SYMBOLS: <fs_tab> LIKE LINE OF gt_tab.
DATA:gt_exclude TYPE ui_functions,
container1 TYPE REF TO cl_gui_container,
container2 TYPE REF TO cl_gui_container,
splitter1 TYPE REF TO cl_gui_splitter_container.
CLASS gc_event_receiver DEFINITION DEFERRED.
DATA: g_container TYPE scrfname VALUE 'GCTR_ALV', "定义屏幕界面容器
gctr_alv TYPE REF TO cl_gui_custom_container,"定义容器对象
gct_alv TYPE REF TO cl_gui_alv_grid, "定义ALV控件名
g_event_receiver TYPE REF TO gc_event_receiver,
ls_row_no_wa TYPE lvc_s_roid,
lt_row_no TYPE lvc_t_roid,
lt_changed_rows TYPE lvc_t_modi,
wa_changed_rows LIKE LINE OF lt_changed_rows,
it_events TYPE slis_t_event,
wa_events LIKE LINE OF it_events,
lr_grid TYPE REF TO cl_gui_alv_grid,
stbl TYPE lvc_s_stbl.
DATA:gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
ok_code TYPE sy-ucomm.
*DATA:name1 TYPE vrm_id,
* list1 TYPE vrm_values,
* value1 LIKE LINE OF list1,
* name2 TYPE vrm_id,
* list2 TYPE vrm_values,
* value2 LIKE LINE OF list2,
* name3 TYPE vrm_id,
* list3 TYPE vrm_values,
* value3 LIKE LINE OF list3.
*----------------------------------------------------------------------
* Data parameters for alv report use
*----------------------------------------------------------------------
DATA: g_program TYPE sy-repid,
gw_layout TYPE slis_layout_alv,
gt_fieldcat_alv TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
gt_event TYPE slis_t_event,
wa_event TYPE slis_alv_event.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS gc_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
* HANDLE_DATA_CHANGED
* FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
* IMPORTING ER_DATA_CHANGED,
*&工具栏设置
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
*&用户事件
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
*&双击事件
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS. "GC_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_even_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS gc_event_receiver IMPLEMENTATION.
*&功能H:设定增加自定义ALV工具栏的按钮
METHOD handle_toolbar.
DATA:ls_toolbar TYPE stb_button.
ls_toolbar-butn_type = '3'.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
ls_toolbar-function = 'ALL'.
ls_toolbar-icon = icon_select_all.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
ls_toolbar-function = 'DALL'.
ls_toolbar-icon = icon_deselect_all.
APPEND ls_toolbar TO e_object->mt_toolbar.
* CLEAR LS_TOOLBAR.
* LS_TOOLBAR-FUNCTION = 'EXE'.
* LS_TOOLBAR-ICON = ICON_EXECUTE_OBJECT.
* APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "HANDLE_TOOLBAR
*&功能J:设定响应USER_COMMAND
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'ALL'.
PERFORM frm_select_all.
PERFORM frm_grid_refsh.
WHEN 'DALL'.
PERFORM frm_deselect_all.
PERFORM frm_grid_refsh.
* WHEN 'EXE'.
* PERFORM FRM_UPDATE_TABLE.
* PERFORM FRM_GRID_REFSH.
* WHEN 'INST'."收货入库
* PERFORM FRM_INSTORE_ORDER.
* WHEN 'OUST'."发货出库
* PERFORM FRM_OUTSTORE_ORDER.
ENDCASE.
ENDMETHOD. "HANDLE_USER_COMMAND
*&功能I:设定响应双击
METHOD handle_double_click.
READ TABLE gt_tab_alv INTO wa_tab INDEX e_row-index.
IF e_column-fieldname EQ 'EXTRA'.
*&CALL ME23N
IF sy-subrc EQ 0.
SET PARAMETER ID 'BES' FIELD wa_tab-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
* PERFORM frm_call_me23n USING wa_output-ebeln.
ENDIF.
ENDIF.
ENDMETHOD. "HANDLE_DOUBLE_CLICK
ENDCLASS. "handle_modify
************************************************************************
* Select Screen *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_matnr FOR marc-matnr,
s_werks FOR marc-werks,
s_mtart FOR mara-mtart,
s_spart FOR mara-spart,
s_wrk02 FOR marc-werks.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 . " '说明'.
PARAMETERS:rb_01 RADIOBUTTON GROUP g1 DEFAULT 'X',
rb_02 RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b2.
*&------------------------------------------------------------------*
*& INITIALIZATION
*&------------------------------------------------------------------*
INITIALIZATION.
*&I1.输入初始化
PERFORM frm_init_data.
*&------------------------------------------------------------------*
*& AT SELECTION-SCREEN
*&------------------------------------------------------------------*
AT SELECTION-SCREEN.
*&I2.权限检查
PERFORM frm_authority_check.
*&------------------------------------------------------------------*
*& START-OF-SELECTION
*&------------------------------------------------------------------*
START-OF-SELECTION.
*break misd11.
*&S1.查询数据
* BREAK ABAP30.
PERFORM frm_get_data.
CHECK gt_tab_alv[] IS NOT INITIAL.
IF rb_02 EQ 'X'.
*&M1.利用MRP数据里的在计划日期 更新PO交货日期
wa_tab-sel = 'X'.
MODIFY gt_tab_alv FROM wa_tab TRANSPORTING sel WHERE sel IS INITIAL.
PERFORM frm_change_po.
ENDIF.
*&S2.显示数据
IF rb_01 EQ 'X'.
CALL SCREEN 100.
ELSE.
PERFORM alv_grid_out.
ENDIF.
*&---------------------------------------------------------------------*
*& Form FRM_INIT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_init_data .
ENDFORM. " FRM_INIT_DATA
*&---------------------------------------------------------------------*
*& Form FRM_AUTHORITY_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_authority_check .
ENDFORM. " FRM_AUTHORITY_CHECK
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
DATA:BEGIN OF lt_t001l OCCURS 0,
werks LIKE t001l-werks,
lgort LIKE t001l-lgort,
lgobe LIKE t001l-lgobe,
END OF lt_t001l.
RANGES:r_delb0 FOR mdez-delb0.
*&S1.取物料主数据
SELECT mara~matnr
mara~mtart
mara~spart
marc~werks
marc~webaz
INTO TABLE gt_tab
FROM mara
INNER JOIN marc
ON mara~matnr EQ marc~matnr
WHERE marc~werks IN s_werks
AND marc~dismm EQ 'PD' "MRP类型
AND marc~lvorm NE 'X' "工厂级别的删除标记
AND mara~matnr IN s_matnr
AND mara~mtart IN s_mtart
AND mara~spart IN s_spart
AND mara~mstae NE '10' "跨工厂物料状态
AND mara~lvorm NE 'X'. "EQ ''
IF sy-subrc NE 0.
MESSAGE s000(oo) WITH '没有找到符合条件的数据!' DISPLAY LIKE 'E'.
LEAVE TO LIST-PROCESSING.
* MESSAGE e006(zdnmessage). 对不起,您权限不足。
ENDIF.
* DELETE...
LOOP AT gt_tab INTO wa_tab.
*&L1.GET mrp list.
PERFORM fem_get_md04data USING wa_tab-matnr wa_tab-werks.
CASE wa_tab-werks.
*&工厂= ‘3000’,找MRP数据=‘PO项目’的数据,当条目的再计划日期不为空时,用再计划日期更新PO的交货日期;
WHEN '3110' OR '3120' OR '3130' OR '3220'.
LOOP AT mdezx WHERE delb0 EQ 'PO项目' AND umdat IS NOT INITIAL.
wa_tab-dat00 = mdezx-dat00."收货/需求日期
wa_tab-delb0 = mdezx-delb0."MRP元素的缩写
wa_tab-extra = mdezx-extra."MRP元素数据
wa_tab-umdat = mdezx-umdat."再计划日期
wa_tab-auskt = mdezx-auskt."例外信息号
wa_tab-mng01 = mdezx-mng01."收货数量或需求数量
wa_tab-mng02 = mdezx-mng02."可用量
wa_tab-wrk02 = mdezx-wrk02."计划工厂
wa_tab-lgort = mdezx-lgort."发货/收货存储地点
wa_tab-lifnr = mdezx-lifnr."供应商
wa_tab-md4li = mdezx-md4li."供应商姓名
CLEAR:lt_string[],lt_string.
*&将MRP数据 单号+行号拆开
IF wa_tab-extra IS NOT INITIAL.
SPLIT wa_tab-extra AT '/' INTO TABLE lt_string.
READ TABLE lt_string INDEX 1.
wa_tab-ebeln = lt_string.
READ TABLE lt_string INDEX 2.
wa_tab-ebelp = lt_string.
ENDIF.
*&get 3000 MRP再计划日期
*&-再计划日期的取数逻辑,由于在表MARC-字段WEBAZ设置有收货处理时间GR为5天,
*& 所以取数日期=MRP再计划日期-GR/5*7,
wa_tab-umdat_3o = wa_tab-umdat.
IF wa_tab-webaz NE 0.
wa_tab-umdat_3 = wa_tab-umdat - wa_tab-webaz / 5 * 7.
ENDIF.
APPEND wa_tab TO gt_tab_use.
ENDLOOP.
WHEN '1000'.
LOOP AT mdezx WHERE delb0 EQ 'PO项目'. "AND umdat IS NOT INITIAL.
wa_tab-dat00 = mdezx-dat00."收货/需求日期
wa_tab-delb0 = mdezx-delb0."MRP元素的缩写
wa_tab-extra = mdezx-extra."MRP元素数据
wa_tab-umdat = mdezx-umdat."再计划日期
wa_tab-auskt = mdezx-auskt."例外信息号
wa_tab-mng01 = mdezx-mng01."收货数量或需求数量
wa_tab-mng02 = mdezx-mng02."可用量
wa_tab-wrk02 = mdezx-wrk02."计划工厂
wa_tab-lgort = mdezx-lgort."发货/收货存储地点
wa_tab-lifnr = mdezx-lifnr."供应商
wa_tab-md4li = mdezx-md4li."供应商姓名
*&将MRP数据 单号+行号拆开
IF wa_tab-extra IS NOT INITIAL.
SPLIT wa_tab-extra AT '/' INTO TABLE lt_string.
READ TABLE lt_string INDEX 1.
wa_tab-ebeln = lt_string.
READ TABLE lt_string INDEX 2.
wa_tab-ebelp = lt_string.
ENDIF.
*&->add by rainy on 20150728
*&werks= 1000,当po数据库位 = ACA1/ACB1,因为这种po不产生预留,就找po在1000公司下的再计划日期为再计划日期
IF wa_tab-werks EQ '1000' AND wa_tab-lgort IN r_lgort AND wa_tab-umdat IS INITIAL .
CLEAR:wa_tab.
CONTINUE.
ENDIF.
*&->end add
*&->add by rainy on 20150730 req by patrich
*& 工厂=1000 判断3000工厂下预留有无再计划日期,无再计划日期不显示
IF mdezx-delb0 EQ 'PO项目'.
PERFORM frm_delete_1000.
*& 无再计划日期
IF wa_tab-ztext = 'X'.
CLEAR:wa_tab-ztext.
CONTINUE.
ENDIF.
ENDIF.
*&->end add on 20150728
APPEND wa_tab TO gt_tab_use.
CLEAR:wa_tab-ztext.
ENDLOOP.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
DELETE gt_tab_use WHERE ztext = '无再计划日期'.
*&收货工厂选择条件
IF s_wrk02[] IS NOT INITIAL.
DELETE gt_tab_use WHERE wrk02 NOT IN s_wrk02.
ENDIF.
gt_tab_alv[] = gt_tab_use[].
DELETE gt_tab_alv WHERE delb0 NE 'PO项目'.
SORT gt_tab_alv BY ebeln ebelp.
g_lines = lines( gt_tab_alv[] ).
IF g_lines EQ 0.
MESSAGE s000(oo) WITH '没有找到符合条件的数据!' DISPLAY LIKE 'E'.
LEAVE TO LIST-PROCESSING.
ELSE.
MESSAGE s000(oo) WITH '找到数据' g_lines '条!'.
ENDIF.
ENDFORM. " FRM_GET_DATA
*&---------------------------------------------------------------------*
*& Form FEM_GET_MD04DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITAB0_MATNR text
* -->P_ITAB0_PLWRK text
*----------------------------------------------------------------------*
FORM fem_get_md04data USING p_matnr
p_plwrk.
CLEAR:mdpsx,mdezx,mdsux.
CLEAR:mdpsx[],mdezx[],mdsux[].
* IF p_plwrk EQ '1000'.
* ELSE.
* ENDIF.
*&读取 物料+工厂 的MRP list,据了解没有更多的条件可以限制
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = p_matnr
werks = p_plwrk
TABLES
mdpsx = mdpsx
mdezx = mdezx
mdsux = mdsux
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2.
* CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
* EXPORTING
** PLSCN = 长期计划中的计划方案
* matnr = 物料
* werks = 工厂
** BERID = MRP区域
** ERGBZ = 选择规则
** AFIBZ =
** INPER = 内部期指标
** DISPLAY_LIST_MDPSX =
** DISPLAY_LIST_MDEZX =
** DISPLAY_LIST_MDSUX =
** NOBUF =
** PLAUF = 计划运行类型
** IS_SFILT = 选择过滤器和显示结构
** IS_AFILT =
** IMPORTING
** E_MT61D =
** E_MDKP =
** E_CM61M =
** E_MDSTA =
** E_ERGBZ =
ENDFORM. " FEM_GET_MD04DATA
*&---------------------------------------------------------------------*
*& Form FRM_SELECT_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_select_all .
LOOP AT gt_tab_alv ASSIGNING <fs_tab> WHERE sel = space.
<fs_tab>-sel = 'X'.
ENDLOOP.
ENDFORM. " FRM_SELECT_ALL
*&---------------------------------------------------------------------*
*& Form FRM_GRID_REFSH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_grid_refsh .
CALL METHOD gct_alv->refresh_table_display
EXPORTING
is_stable = stbl.
ENDFORM. " FRM_GRID_REFSH
*&---------------------------------------------------------------------*
*& Form FRM_DESELECT_ALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_deselect_all .
LOOP AT gt_tab_alv ASSIGNING <fs_tab> WHERE sel = 'X'.
<fs_tab>-sel = space.
ENDLOOP.
ENDFORM. " FRM_DESELECT_ALL
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
DATA:title TYPE lvc_title.
*&gui_statu
* SET TITLEBAR '0100'.
IF rb_01 EQ 'X'.
SET PF-STATUS '0100'.
ELSE.
SET PF-STATUS '0200'.
ENDIF.
SET TITLEBAR '010'.
CONCATENATE '共输出' g_lines '条符合条件的数据!' INTO title.
IF gctr_alv IS INITIAL.
*&1.创建容器
CREATE OBJECT gctr_alv
EXPORTING
container_name = g_container.
"'GCTR_ALV'.
*&2.创建ALV控件
CREATE OBJECT gct_alv
EXPORTING
i_parent = gctr_alv."容器
*&3.创建输出布局
PERFORM frm_layout_alv .
*&4.按钮设置
PERFORM exclude_tb_functions TABLES gt_exclude.
*&5.事件处理器
CREATE OBJECT g_event_receiver.
*&6.注册事件
CALL METHOD GCT_ALV->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
* CALL METHOD CL_GUI_CONTROL=>SET_FOCUS "设置焦点在REF_ALVG1上
* EXPORTING
* CONTROL = GCT_ALV.
* SET HANDLER G_EVENT_RECEIVER->HANDLE_MODIFY FOR GCT_ALV.
* SET HANDLER G_EVENT_RECEIVER->HANDLE_DATA_CHANGED FOR GCT_ALV.
SET HANDLER g_event_receiver->handle_user_command FOR gct_alv.
SET HANDLER g_event_receiver->handle_double_click FOR gct_alv.
SET HANDLER g_event_receiver->handle_toolbar FOR gct_alv.
* CALL METHOD GCT_ALV->SET_TOOLBAR_INTERACTIVE.
*&7. METHOD 显示ALV.
CALL METHOD gct_alv->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_tab_alv[]
it_fieldcatalog = gt_fieldcat[].
ELSE.
CALL METHOD gct_alv->refresh_table_display.
* CALL METHOD GCT_ALV->CHECK_CHANGED_DATA.
* CALL METHOD G_EVENT_RECEIVER->HANDLE_MODIFY.
ENDIF.
PERFORM frm_grid_refsh.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_layout_alv .
*&显示设置
gs_layout-cwidth_opt = 'A'.
gs_layout-zebra = 'X'.
gs_layout-box_fname = 'SEL'.
* GS_LAYOUT-NO_ROWMARK = 'X'.
* GS_LAYOUT-SEL_MODE = 'D'.
* GS_LAYOUT-STYLEFNAME = 'CELLTAB'.
gs_layout-grid_title = title."'Update PO delivery date'.
* gs_layout-DETAIL_POPUP = 'X'.
*&设置输出字段
PERFORM frm_display_fieldcat.
ENDFORM. " FRM_LAYOUT_ALV .
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_display_fieldcat .
DATA ls_fieldcat TYPE lvc_s_fcat.
ls_fieldcat-fieldname = 'SEL' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '1' .
ls_fieldcat-coltext = 'SEL' .
ls_fieldcat-seltext = 'SEL' .
ls_fieldcat-checkbox = 'X' .
ls_fieldcat-edit = 'X' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
* READ TABLE GT_FIELDCAT INTO LS_FIELDCAT WITH KEY FIELDNAME = 'ZICON'.
* IF SY-SUBRC NE 0.
ls_fieldcat-fieldname = 'ZICON' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '1' .
ls_fieldcat-col_pos = '2' .
ls_fieldcat-coltext = 'SIGN' .
ls_fieldcat-seltext = 'SIGN' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZTEXT' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '20' .
ls_fieldcat-coltext = '文本'.
ls_fieldcat-seltext = '文本' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
* ENDIF.
ls_fieldcat-fieldname = 'MATNR' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '20' .
ls_fieldcat-coltext = '物料' .
ls_fieldcat-seltext = '物料' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '10' .
ls_fieldcat-coltext = '工厂' .
ls_fieldcat-seltext = '工厂' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MTART' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '8' .
ls_fieldcat-coltext = '类别' .
ls_fieldcat-seltext = '类别' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SPART' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '8' .
ls_fieldcat-coltext = '产品组' .
ls_fieldcat-seltext = '产品组' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'DAT00' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '16' .
ls_fieldcat-coltext = '日期' .
ls_fieldcat-seltext = '日期' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'DELB0' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '10' .
ls_fieldcat-coltext = 'MRP元素' .
ls_fieldcat-seltext = 'MRP元素' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EXTRA' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '20' .
ls_fieldcat-coltext = 'MRP数据' .
ls_fieldcat-seltext = 'MRP数据' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'UMDAT' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '10' .
ls_fieldcat-coltext = '再计划日期' .
ls_fieldcat-seltext = '再计划日期' .
* ls_fieldcat-edit = 'X' .
* ls_fieldcat-fix_column = 'X'.
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'AUSKT' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '8' .
ls_fieldcat-coltext = '例外' .
ls_fieldcat-seltext = '例外' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MNG01' .
ls_fieldcat-inttype = 'P' .
ls_fieldcat-outputlen = '16' .
ls_fieldcat-coltext = '收货需求' .
ls_fieldcat-seltext = '收货需求' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MNG02' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '16' .
ls_fieldcat-coltext = '可用数量' .
ls_fieldcat-seltext = '可用数量' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'WRK02' .
ls_fieldcat-inttype = 'P' .
ls_fieldcat-outputlen = '16' .
ls_fieldcat-coltext = '交货/收货工厂' .
ls_fieldcat-seltext = '交货/收货工厂' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LGORT' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '16' .
ls_fieldcat-coltext = '库存地点' .
ls_fieldcat-seltext = '库存地点' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LIFNR' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '16' .
ls_fieldcat-coltext = '供应商' .
ls_fieldcat-seltext = '供应商' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MD4LI' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '30' .
ls_fieldcat-coltext = '供应商名称' .
ls_fieldcat-seltext = '收供应商名称货需求' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
*&->add by riany on 20150908.
ls_fieldcat-fieldname = 'EBELN' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '10'.
ls_fieldcat-no_zero = 'X' .
ls_fieldcat-coltext = 'PO' .
ls_fieldcat-seltext = 'PO' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EBELP' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '5' .
ls_fieldcat-no_zero = 'X' .
ls_fieldcat-coltext = 'PO line' .
ls_fieldcat-seltext = 'PO line' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
*Add
ls_fieldcat-fieldname = 'WEBAZ' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '3' .
ls_fieldcat-coltext = '收货处理日期' .
ls_fieldcat-seltext = '收货处理日期' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZZDATE' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '8' .
ls_fieldcat-coltext = '原交货日期' .
ls_fieldcat-seltext = '原交货日期' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZZRSNUM' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '10' .
ls_fieldcat-coltext = '预留单号' .
ls_fieldcat-seltext = '预留单号' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'UMDAT_1' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '8' .
ls_fieldcat-coltext = '1000 工厂交期' .
ls_fieldcat-seltext = '1000 工厂交期' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'UMDAT_3' .
ls_fieldcat-inttype = 'C' .
ls_fieldcat-outputlen = '8' .
ls_fieldcat-coltext = '3000 工厂交期' .
ls_fieldcat-seltext = '3000 工厂交期' .
APPEND ls_fieldcat TO gt_fieldcat .
CLEAR ls_fieldcat.
ENDFORM. " FRM_DISPLAY_FIELDCAT
*&---------------------------------------------------------------------*
*& Form EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_EXCLUDE text
*----------------------------------------------------------------------*
FORM exclude_tb_functions TABLES pt_exclude TYPE ui_functions.
DATA: ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
DATA: code_ok TYPE sy-ucomm.
CLEAR code_ok.
code_ok = sy-ucomm.
*&强制退出
CASE code_ok.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command INPUT.
*BREAK ABAP30.
code_ok = sy-ucomm.
CASE code_ok.
WHEN 'SAVE'.
*&M1.利用MRP数据里的在计划日期 更新PO交货日期
PERFORM frm_change_po.
PERFORM frm_grid_refsh.
WHEN 'ZALL'.
PERFORM frm_select_all.
PERFORM frm_grid_refsh.
WHEN 'DALL'.
PERFORM frm_deselect_all.
PERFORM frm_grid_refsh.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
CLEAR code_ok.
ENDMODULE. " USER_COMMAND INPUT
*&---------------------------------------------------------------------*
*& Form FRM_CHANGE_PO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_change_po .
DATA:l_error TYPE c.
DATA:l_webaz LIKE marc-webaz.
DATA:l_err TYPE c.
* DATA:BEGIN OF LT_EBELN OCCURS 0,
* EBELN LIKE EKPO-EBELN,
* EBELP LIKE EKPO-EBELP,
* END OF LT_EBELN.
*&S1.处理选择的条目
LOOP AT gt_tab_alv INTO lw_tab WHERE sel EQ 'X'.
*&L0.按照行项,一行行处理
*&L1.找到计划行里的交货日期
CLEAR:lt_eket,lt_eket[],
poschedule,poschedule[],
poschedulex,poschedulex[],
return[].
SELECT ebeln
ebelp
etenr
eindt
INTO CORRESPONDING FIELDS OF TABLE lt_eket
FROM eket
WHERE ebeln EQ lw_tab-ebeln
AND ebelp EQ lw_tab-ebelp.
*&L2.计划行数据赋值
LOOP AT lt_eket.
poschedule-po_item = lw_tab-ebelp. "采购凭证的项目编号
poschedule-sched_line = lt_eket-etenr. "交货计划行号
IF lw_tab-werks CS '3'.
poschedule-delivery_date = lw_tab-umdat_3."交货日期
ELSE.
poschedule-delivery_date = lw_tab-umdat_1."交货日期
ENDIF.
APPEND poschedule.
CLEAR poschedule.
poschedulex-po_item = lw_tab-ebelp. "采购凭证的项目编号
poschedulex-sched_line = lt_eket-etenr. "交货计划行号
poschedulex-delivery_date = 'X'. "相关用户数据字段的已更新信息
* lt_poschedulex-po_itemx = 'X'. "相关用户数据字段的已更新信息
* lt_poschedulex-SCHED_LINEX = 'X' "相关用户数据字段的已更新信息
* lt_poschedulex-DEL_DATCAT_EXT "相关用户数据字段的已更新信息
APPEND poschedulex.
CLEAR poschedulex.
ENDLOOP.
*&+初始化
CALL FUNCTION 'MEPO_DOC_INITIALIZE'.
*&1.bapi_po_change.(更新再计划日期)
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = lw_tab-ebeln
TABLES
return = return
poschedule = poschedule
poschedulex = poschedulex.
* poitemx = poitemx
* pocomponents = pocomponents
* pocomponentsx = pocomponentsx.
READ TABLE return WITH KEY type = 'E'.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
* l_error = 'X'.
lw_tab-zicon = '@5C@'.
lw_tab-ztext = return-message."'失败原因?'
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
lw_tab-zicon = '@5B@'.
lw_tab-ztext = '更新成功'.
lw_tab-SEL = '-'.
CALL FUNCTION 'DEQUEUE_ALL'.
* EXPORTING
* _SYNCHRON = ' '
CLEAR:l_err.
DATA:lv_zzdate LIKE ekpo-zzdate.
*&2.更新PO原交货日期
CLEAR:lv_zzdate.
SELECT SINGLE zzdate
INTO lv_zzdate
FROM ekpo
WHERE ebeln EQ lw_tab-ebeln
AND ebelp EQ lw_tab-ebelp.
IF lv_zzdate IS INITIAL.
READ TABLE lt_eket WITH KEY ebeln = lw_tab-ebeln ebelp = lw_tab-ebelp.
IF sy-subrc EQ 0.
UPDATE ekpo SET zzdate = lt_eket-eindt
WHERE ebeln = lw_tab-ebeln
AND ebelp = lw_tab-ebelp.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
lw_tab-ztext = '原交货日期更新失败!'.
ENDIF.
IF sy-subrc NE 0.
l_err = 'X'.
ENDIF.
ENDIF.
ENDIF.
*&->add by rainy on 20150728 req by patrich
*&3.更新预留单需求日期
*& 工厂= ‘1000’更新PO交期同时,更新对应的预留单的需求日期,即RESB-BDTER,好到PO项目对应的预留单号
*& changed by patrich 直接用预留单的再计划日期(不需计算处理)更新对应的预留单的需求日期,
IF lw_tab-werks EQ '1000' AND lw_tab-lgort NOT IN r_lgort.
UPDATE resb SET bdter = lw_tab-umdat_1o "p_umdat
WHERE rsnum = lw_tab-zzrsnum
AND rspos = lw_tab-rspos.
COMMIT WORK.
IF sy-subrc NE 0.
l_err = 'X'.
ENDIF.
ENDIF.
ENDIF.
* AT END OF EBELN.
* CLEAR:LT_EKET,LT_EKET[],
* R_EBELP[].
**&L2.找到计划行里的交货日期
* SELECT EKET~EBELN
* EKET~EBELP
* EKET~ETENR
* EKET~EINDT
* EKPO~ZZDATE
* INTO CORRESPONDING FIELDS OF TABLE LT_EKET
* FROM EKET
* JOIN EKPO
* ON EKET~EBELN EQ EKPO~EBELN
* AND EKET~EBELP EQ EKPO~EBELP
* FOR ALL ENTRIES IN LT_EBELN
* WHERE EKET~EBELN EQ LT_EBELN-EBELN
* AND EKET~EBELP EQ LT_EBELN-EBELP.
**&L3.BAPI change po
* PERFORM FRM_PO_BAPI.
* CLEAR:LT_EBELN,LT_EBELN[].
* ENDAT.
IF lw_tab-zicon IS INITIAL.
lw_tab-zicon = '@5D@'.
lw_tab-ztext = '不符合处理条件'.
ENDIF.
MODIFY gt_tab_alv FROM lw_tab TRANSPORTING zicon ztext SEL.
CLEAR lw_tab.
ENDLOOP.
IF sy-subrc NE 0.
MESSAGE e000(oo) WITH '请选择需操作条目!'.
ENDIF.
*PERFORM frm_grid_refsh.
ENDFORM. " FRM_CHANGE_PO
*&---------------------------------------------------------------------*
*& Form FRM_DELETE_1000
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_delete_1000 .
*&找EKPO 预留单,及原交货日期
SELECT SINGLE zzrsnum zzdate
INTO (wa_tab-zzrsnum, wa_tab-zzdate)
FROM ekpo
WHERE ebeln EQ wa_tab-ebeln
AND ebelp EQ wa_tab-ebelp.
IF wa_tab-zzrsnum IS INITIAL.
wa_tab-ztext = 'X'.
ELSE.
*&找到1000下PO对应的3000下 的工厂
LOOP AT mdezx WHERE delb0 = 'StTRes' AND extra CS wa_tab-zzrsnum.
CLEAR:lt_string,lt_string[].
SPLIT mdezx-extra AT '/' INTO TABLE lt_string.
READ TABLE lt_string INDEX 1.
wa_tab-zzrsnum = lt_string.
READ TABLE lt_string INDEX 2.
wa_tab-rspos = lt_string.
*&找对应3000工厂的收货处理时间
SELECT SINGLE webaz
INTO wa_tab-webaz
FROM marc
WHERE matnr EQ wa_tab-matnr
AND werks EQ mdezx-wrk02.
*&取3000工厂下预留单的再计划日期
PERFORM fem_get_md043000.
READ TABLE mdezx_3 WITH KEY extra = mdezx-extra.
IF mdezx_3-umdat IS INITIAL.
wa_tab-ztext = '无再计划日期'.
* wa_tab-ztext = 'X'.
ELSE.
*&计算1000工厂MRP 的再计划日期
wa_tab-umdat_1o = mdezx_3-umdat.
IF wa_tab-webaz NE 0.
wa_tab-umdat_1 = mdezx_3-umdat - wa_tab-webaz / 5 * 7.
ENDIF.
ENDIF.
ENDLOOP.
* READ TABLE MDEZX WITH KEY DELB0 = 'StTRes' EXTRA CS L_ZZRSNUM.
ENDIF.
ENDFORM. " FRM_DELETE_1000
*&---------------------------------------------------------------------*
*& Form FEM_GET_MD043000
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fem_get_md043000 .
CLEAR:mdpsx_3,mdezx_3,mdsux_3,
mdpsx_3[],mdezx_3[],mdsux_3[].
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = wa_tab-matnr
werks = mdezx-wrk02
TABLES
mdpsx = mdpsx_3
mdezx = mdezx_3
mdsux = mdsux_3
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2.
ENDFORM. " FEM_GET_MD043000
*&---------------------------------------------------------------------*
*& Form ALV_GRID_OUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_grid_out.
DATA: l_nn TYPE i.
DEFINE add_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = &1.
wa_fieldcat-seltext_l = &2.
wa_fieldcat-key = &3.
wa_fieldcat-col_pos = l_nn + 1.
wa_fieldcat-just = &4.
wa_fieldcat-outputlen = &5.
wa_fieldcat-fix_column = &6.
wa_fieldcat-no_zero = &7.
wa_fieldcat-edit = &8.
append wa_fieldcat to gt_fieldcat_alv.
END-OF-DEFINITION.
CLEAR gt_fieldcat.
REFRESH gt_fieldcat.
add_fieldcat 'SEL' 'SEL' '' '' '' '' '' ''.
add_fieldcat 'ZICON' 'SIGN' '' '' '' '' '' ''.
add_fieldcat 'ZTEXT' '文本' '' '' '' '' '' ''.
add_fieldcat 'MATNR' '物料' '' '' '' '' 'X' ''.
add_fieldcat 'WERKS' '工厂' '' '' '' '' '' ''.
add_fieldcat 'MTART' '类别' '' '' '' '' '' ''.
add_fieldcat 'SPART' '产品组' '' '' '' '' '' ''.
add_fieldcat 'DAT00' '日期' '' '' '' '' '' ''.
add_fieldcat 'DELB0' 'MRP元素' '' '' '' '' '' ''.
add_fieldcat 'EXTRA' 'MRP数据' '' '' '' '' '' ''.
add_fieldcat 'UMDAT' '再计划日期' '' '' '' '' '' ''.
add_fieldcat 'AUSKT' '例外' '' '' '' '' '' ''.
add_fieldcat 'MNG01' '收货需求' '' '' '' '' '' ''.
add_fieldcat 'MNG02' '可用数量' '' '' '' '' '' ''.
add_fieldcat 'WRK02' '交货/收货工厂' '' '' '' '' '' ''.
add_fieldcat 'LGORT' '库存地点' '' '' '' '' '' ''.
add_fieldcat 'LIFNR' '供应商' '' '' '' '' '' ''.
add_fieldcat 'MD4LI' '供应商名称' '' '' '' '' '' ''.
add_fieldcat 'EBELN' 'PO' '' '' '' '' 'X' ''.
add_fieldcat 'EBELP' 'PO line' '' '' '' '' 'X' ''.
add_fieldcat 'UMDAT_1' '1000 工厂再计划日期' '' '' '' '' '' ''.
add_fieldcat 'UMDAT_3' '3000 工厂再计划日期' '' '' '' '' '' ''.
gw_layout-colwidth_optimize = 'X'.
* gw_layout-box_fieldname = 'SEL'.
*& 调用函数显示ALV列表
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program
i_save = 'A'
is_layout = gw_layout
it_fieldcat = gt_fieldcat_alv
it_events = gt_event
TABLES
t_outtab = gt_tab_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " ALV_GRID_OUT