SAP採購交貨已完成不能入庫增強
貌似用PP生產入庫的增強更好(區別在那個操作動作檢查)
SE19
METHOD if_ex_mb_migo_badi~post_document.
DATA: xx TYPE mkpf-mblnr .
**
* EXPORT p1 from gv_mblnr to MEMORY id 'dd' .
IMPORT p1 TO xx FROM MEMORY ID 'dd' .
DATA: lv_budat TYPE mkpf-budat . "原單的過賬日期
DATA: lv_budat2 TYPE mkpf-budat .
SELECT SINGLE budat
INTO lv_budat
FROM mkpf
WHERE vgart = 'WE' "採購訂單據收貨
AND mblnr = xx .
lv_budat2 = is_mkpf-budat ."當前單據的物料過賬日期
DATA: lv_bwart TYPE mseg-bwart .
DATA: is_mseg TYPE mseg.
DATA: lv_elikz TYPE ekpo-elikz .
DATA: lv_msg TYPE c LENGTH 100 .
LOOP AT it_mseg INTO is_mseg .
IF is_mseg-bwart EQ '122'.
lv_bwart = '122' .
ENDIF .
IF is_mseg-bwart EQ '101'.
CLEAR:lv_elikz ,lv_msg .
SELECT SINGLE elikz INTO lv_elikz
FROM ekpo
WHERE ebeln = is_mseg-ebeln
AND ebelp = is_mseg-ebelp .
IF lv_elikz EQ 'X'.
CONCATENATE is_mseg-ebeln '-' is_mseg-ebelp '交貨已完成,請聯絡採購員' INTO lv_msg .
MESSAGE lv_msg TYPE 'E'.
ENDIF .
ENDIF .
ENDLOOP .
IF lv_budat IS NOT INITIAL AND lv_bwart EQ '122' .
IF lv_budat2+0(6) > lv_budat+0(6) .
MESSAGE '單據跨月退貨,請聯絡採購員' TYPE 'E'.
ENDIF .
ENDIF .
FREE MEMORY ID 'dd' .
ENDMETHOD.