业务情景: 生产订单或内部订单,在某些情况下,发料时采用不同移动类型记账,记账科目也会发生变化。比如根据订单不同的状态进而确定移动类型。
通常,在生成预留数据时,移动类型也确定了。那么要实现临时改变移动类型,可通过增强来处理。
增强代码:
SE37->DBMMIMRKPFRESBF01->FORM prefetch.
代码语言:javascript复制*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZZ_MIGO_MOVETYPE_CTRL. "active version
FIELD-SYMBOLS <FS> TYPE GODYNPRO.
DATA C_FIELD(18) TYPE C VALUE '(SAPLMIGO)GODYNPRO'.
ASSIGN (C_FIELD) TO <FS>.
DATA:W_RESB TYPE RESB,
V_BWART TYPE RESB-BWART,
V_KOSTV TYPE COAS-KOSTV.
IF SY-SUBRC EQ 0 AND <FS> IS ASSIGNED.
* 针对:MIGO A07 发货- R09预留的处理
IF <FS>-RESERVATION_NUMBER IS NOT INITIAL AND SY-TCODE EQ 'MIGO' AND <FS>-ACTION EQ 'A07' AND <FS>-REFDOC EQ 'R09'.
LOOP AT t_resbkey INTO ls_key.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF W_RESB FROM RESB WHERE RSNUM = LS_KEY-RSNUM AND RSPOS = LS_KEY-RSPOS.
IF SY-SUBRC EQ 0 AND W_RESB-AUFNR IS NOT INITIAL AND W_RESB-WERKS = '0000'
AND ( W_RESB-BWART EQ 'ZX1' OR W_RESB-BWART EQ 'ZX2' OR W_RESB-BWART EQ 'ZY1' OR W_RESB-BWART EQ 'ZY2' ).
V_BWART = W_RESB-BWART.
CALL FUNCTION 'ZXWMS_AEAP_BWART_REPLACE'
EXPORTING
IM_PRODOC = W_RESB-AUFNR
IMPORTING
EX_BWART = V_BWART
EX_KOSTV = V_KOSTV.
IF V_BWART NE W_RESB-BWART.
UPDATE RESB SET BWART = V_BWART WHERE RSNUM = LS_KEY-RSNUM AND RSPOS = LS_KEY-RSPOS.
ENDIF.
ENDIF.
ENDLOOP.
IF t_resbkey[] IS NOT INITIAL.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDIF.
ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*