SAP 報工增強
CMOD: CONFPP04 PP定單確認:客戶特殊輸入檢查2
EXIT_SAPLCORF_104
INCLUDE ZXCOFU14
*&---------------------------------------------------------------------*
*& 包含 ZXCOFU14
*&---------------------------------------------------------------------*
DATA:p_menge TYPE mseg-menge.
DATA:p_auart TYPE aufk-auart.
DATA:menge1 TYPE mseg-menge.
DATA:menge2 TYPE afru-lmnga.
DATA:l_menge TYPE mseg-menge.
DATA:menge3 TYPE mseg-menge.
DATA:menge4 TYPE mseg-menge.
CLEAR:p_menge,p_auart.
SELECT SINGLE auart INTO p_auart
FROM aufk
WHERE aufnr = afrud_imp-aufnr
AND werks = afrud_imp-werks.
if SY-MANDT eq '601' or SY-MANDT eq '801'.
IF p_auart = 'LX21'
OR p_auart = 'LX22'OR p_auart = 'LX23' OR p_auart = 'LX31'
or p_auart = 'LX32' OR P_AUART = 'LX33' .
SELECT SINGLE SUM( menge ) AS menge INTO p_menge
FROM mseg
WHERE aufnr = afrud_imp-aufnr
AND bwart = '261'.
IF p_menge = 0 .
MESSAGE '未領料,不允許報工' TYPE 'E'.
ENDIF.
ENDIF.
else .
IF p_auart = 'LX01' OR p_auart = 'LX02' OR p_auart = 'LX11'
OR p_auart = 'LX07'OR p_auart = 'LX04' OR p_auart = 'LX10'.
SELECT SINGLE SUM( menge ) AS menge INTO p_menge
FROM mseg
WHERE aufnr = afrud_imp-aufnr
AND bwart = '261'.
IF p_menge = 0 .
MESSAGE '未領料,不允許報工' TYPE 'E'.
ENDIF.
ENDIF.
endif .
IF p_auart = 'LX05' OR p_auart = 'LX09'.
"領料數量
SELECT SINGLE SUM( menge ) AS menge INTO p_menge
FROM mseg
WHERE aufnr = afrud_imp-aufnr
AND bwart = '261'.
SELECT SINGLE SUM( menge ) AS menge INTO l_menge
FROM mseg
WHERE aufnr = afrud_imp-aufnr
AND bwart = '262'.
IF p_menge - l_menge = 0.
MESSAGE '未領料,不允許報工' TYPE 'E'."SMENG 工序總數量
ENDIF.
"需求數量
SELECT SINGLE SUM( bdmng ) AS bdmng INTO menge1
FROM resb
WHERE aufnr = afrud_imp-aufnr
AND bwart = '261'
AND xloek = ''.
"報工數量
SELECT SINGLE SUM( lmnga ) AS lmnga INTO menge2
FROM afru
WHERE aufnr = afrud_imp-aufnr
AND werks = afrud_imp-werks
AND stokz = ''
AND stzhl = ''.
"允許報工數量
IF menge1 <> 0.
menge3 = afrud_imp-smeng * ( p_menge - l_menge ) / menge1.
menge3 = ceil( menge3 ).
ENDIF.
IF menge3 - menge2 - afrud_imp-lmnga < 0.
menge4 = menge2 + afrud_imp-lmnga - menge3.
MESSAGE '訂單報工數量大於允許報工的數量' && menge4 TYPE 'E'.
ENDIF.
ENDIF.