需求:A/B/C下了3个生成订单,生产订单里面 特定的组件 做数量归集后,下到D工厂进行相应组件的生产
小计归集
创建生产订单
完整代码
*&---------------------------------------------------------------------*
*& REPORT ZRPT_PP_ORDER_CREATE_M
*&
*&---------------------------------------------------------------------*
*& AUTHOR GAVIN
*& DATE: 20220307
*& FROM:
*&---------------------------------------------------------------------*
REPORT ZRPT_PP_ORDER_CREATE_M.
TABLES:CAUFV,RESB,MARA,MAKT,ZCWPPORDERLOG.
DATA: REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA:LLOGS LIKE ZCWPPORDERLOG OCCURS 0 WITH HEADER LINE.
DATA:LUALIAS LIKE USREFUS-USERALIAS.
datA:flg TYPE C.
data:sumflg TYPE C.
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS HANDLE_MODIFY
FOR EVENT DATA_CHANGED_FINISHED OF CL_GUI_ALV_GRID
IMPORTING E_MODIFIED ET_GOOD_CELLS.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_MODIFY.
DATA STBL TYPE LVC_S_STBL.
* LOOP AT ALVTB ASSIGNING <FS>.
* LMENGE = <FS>-MMENGE.
* IF LMENGE > <FS>-DMENGE.
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
* EXPORTING
* INPUT = <FS>-MATNR
* IMPORTING
* OUTPUT = LMATNR.
*
* LMSG = '物料[' && LMATNR && ']本次调拨数量[' && <FS>-MMENGE && ']超出了待调拨数量[' && <FS>-DMENGE && ']'.
* MESSAGE LMSG TYPE 'I'.
* ENDIF.
* ENDLOOP.
* 稳定刷新
STBL-ROW = 'X'." 基于行的稳定刷新
STBL-COL = 'X'." 基于列稳定刷新
CALL METHOD REF_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = STBL.
ENDMETHOD. "HANDLE_MODIFY
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
DATA GT_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER .
DATA:BEGIN OF WITAB OCCURS 0,
AUFNR LIKE CAUFV-AUFNR,
ERDAT LIKE CAUFV-ERDAT,
GSTRP LIKE CAUFV-GSTRP,
GLTRP LIKE CAUFV-GLTRP,
WERKS LIKE CAUFV-WERKS,
MATNR LIKE RESB-MATNR,
MAKTX LIKE MAKT-MAKTX,
BDMNG LIKE RESB-BDMNG,"需求数量
OBJNR LIKE caufv-OBJNR,
END OF WITAB.
DATA:BEGIN OF SUMITAB OCCURS 0,
MATNR LIKE RESB-MATNR,
MAKTX LIKE MAKT-MAKTX,
BDMNG LIKE RESB-BDMNG,"汇总需求数量
AQMNG LIKE RESB-BDMNG,"MES安全库存数量
KCMNG LIKE RESB-BDMNG,"MES成品库存数量
QRMNG(18) TYPE C,"确认生成数量
AUFNR LIKE CAUFV-AUFNR,"目标公司的订单号
MSGTXT(255) TYPE C,"消息文本
END OF SUMITAB.
DATA:
STDATUM LIKE SY-DATUM,
STUZEIT LIKE SY-UZEIT.
DATA: BEGIN OF L_TAB OCCURS 0,
STAT LIKE JEST-STAT,
END OF L_TAB.
DATA:LT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE,
LT_AUFNR TYPE AUFNR.
SELECTION-SCREEN: BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT_B01.
SELECT-OPTIONS:S_AUFNR FOR CAUFV-AUFNR,
S_AUART FOR CAUFV-AUART DEFAULT 'ZP01',
S_WERKS FOR CAUFV-WERKS ," OBLIGATORY,
S_ERDAT FOR CAUFV-ERDAT,
S_GSTPP FOR CAUFV-GSTPP OBLIGATORY, "基本开始日期 > PENDDT
S_LABOR FOR MARA-LABOR."待转到目标工厂生产的组件
SELECTION-SCREEN: END OF BLOCK BLK1.
SELECTION-SCREEN: BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT_