三代增强点:WORKORDER_GOODSMVT 方法:BACKFLUSH
代码如下:
method IF_EX_WORKORDER_GOODSMVT~BACKFLUSH.
DATA :
lt_resb TYPE TABLE OF resb,
ls_resb TYPE resb.
DATA : lv_prvbe TYPE mkal-elpro,
lv_werks TYPE resb-werks,
lv_arbpl TYPE crhd-arbpl.
FIELD-SYMBOLS : <lfs_item> TYPE imseg.
SELECT ('*') INTO CORRESPONDING FIELDS OF TABLE lt_resb
FROM resb
WHERE aufnr = i_order_header-aufnr
AND xloek <> 'X'
AND schgt <> 'X'
AND dumps <> 'X'
AND rgekz = 'X'.
SORT lt_resb BY aufnr matnr.
*--------------------------------------------------------------------*
LOOP AT ct_components ASSIGNING <lfs_item>.
READ TABLE lt_resb INTO ls_resb WITH KEY aufnr = i_order_header-aufnr
matnr = <lfs_item>-matnr BINARY SEARCH.
IF sy-subrc EQ 0.
CLEAR : lv_prvbe,lv_werks,lv_arbpl.
"按照工作中心
SELECT SINGLE a~werks a~arbpl INTO (lv_werks,lv_arbpl)
FROM crhd AS a
JOIN afvc AS b ON a~objid = b~arbid
WHERE b~aufpl = i_order_header-aufpl
AND b~aplzl = ls_resb-aplzl.
*
*--------------------------------------------------------------------*
SELECT SINGLE lgort INTO lv_prvbe
FROM ztpp014
WHERE werks = lv_werks
AND arbpl = lv_arbpl.
IF lv_prvbe IS NOT INITIAL.
<lfs_item>-lgort = lv_prvbe.
ELSE.
CLEAR : <lfs_item>-lgort.
ENDIF.
ENDIF.
ENDLOOP.
endmethod.