业务场景见抬头,有没有标准的解决方案就不说了,也没去考虑。。。
这个增强还是SAP老表提供的,感谢,省了不少时间。
INCLUDE:LMR1MF6S
最后的位置
ENHANCEMENT ZMIR7_01. "active version
DATA:LS_YDRSEG LIKE LINE OF YDRSEG.
DATA:L_T_QTY LIKE EKBE-MENGE.
DATA:LY_PRUEFLOS TYPE QPLOS.
DATA:LY_ART TYPE QPART.
DATA:LV_INSMK TYPE MSEG-INSMK.
DATA:lv_BSART TYPE ESART.
DATA:lv_KNTTP TYPE KNTTP. CHECK RM08M-VORGANG = ''. LOOP AT YDRSEG INTO LS_YDRSEG.
L_T_QTY = .
CLEAR:LY_PRUEFLOS,LV_INSMK,lv_bSART,lv_KNTTP."排除没做出使用决策的物料凭证 SELECT SINGLE KNTTP INTO LV_KNTTP FROM EKPO WHERE EBELN = LS_YDRSEG-EBELN AND EBELP = LS_YDRSEG-EBELP..
IF LV_KNTTP = 'A' OR LV_KNTTP = 'K' OR LV_KNTTP = 'Z' OR LV_KNTTP = 'F'.
ELSE.
SELECT SINGLE INSMK INTO LV_INSMK FROM MSEG WHERE MJAHR = LS_YDRSEG-LFGJA
AND MBLNR = LS_YDRSEG-LFBNR AND ZEILE = LS_YDRSEG-LFPOS.
IF LV_INSMK = 'X'.
SELECT SINGLE ART INTO lY_ART FROM QMAT WHERE ART = '' AND MATNR = LS_YDRSEG-matnr AND WERKS = LS_YDRSEG-werks.
IF sy-subrc = .
SELECT SINGLE PRUEFLOS INTO LY_PRUEFLOS
FROM QALS WHERE MJAHR = LS_YDRSEG-LFGJA
AND MBLNR = LS_YDRSEG-LFBNR AND ZEILE = LS_YDRSEG-LFPOS AND STAT34 = 'X'.
IF LY_PRUEFLOS IS INITIAL.
DELETE YDRSEG.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
ENDIF. SELECT SUM( CASE SHKZG WHEN 'S' THEN MENGE ELSE - * MENGE END )
INTO @L_T_QTY
FROM EKBE
WHERE EBELN = @LS_YDRSEG-EBELN
AND EBELP = @LS_YDRSEG-EBELP
AND BEWTP IN ('T','Q')
AND LFGJA = @LS_YDRSEG-LFGJA
AND LFBNR = @LS_YDRSEG-LFBNR
AND LFPOS = @LS_YDRSEG-LFPOS. SELECT SINGLE bsart INTO lv_bsart FROM ekko WHERE ebeln = LS_YDRSEG-EBELN.
IF lv_bsart = ''.
LS_YDRSEG-MENGE = LS_YDRSEG-WEMNG + L_T_QTY.
ELSE.
LS_YDRSEG-MENGE = LS_YDRSEG-WEMNG - L_T_QTY.
ENDIF. "DELETE 没有使用决策的物料凭证
LS_YDRSEG-BPMNG = LS_YDRSEG-MENGE. IF LS_YDRSEG-MENGE <= .
DELETE YDRSEG.
CONTINUE.
ELSE.
MODIFY YDRSEG FROM LS_YDRSEG.
ENDIF. ENDLOOP.
ENDENHANCEMENT.
中间有一大串IF ELSE的可以忽略,特殊业务处理