FORM. WOGR_CONTROL.
DATA:L_NOPOSTGR LIKE ZCM04-ERFMG.
DATA:L_TOTALGR LIKE ZCM04-ERFMG.
DATA: C_TOTALGR(16) TYPE C.
DATA: C_ORDERQTY(16) TYPE C.
DATA:L_ALPGR LIKE RESB-ALPGR.
DATA:L_ALPOS LIKE RESB-ALPOS.
DATA:L_BAUGR LIKE RESB-BAUGR.
DATA:BEGIN OF ITAB_ISSUE OCCURS 0,
MATNR LIKE RESB-MATNR,
ISSQTY LIKE RESB-ENMNG,
END OF ITAB_ISSUE.
DATA:L_MINMATNR LIKE RESB-MATNR,
L_MINISSQTY LIKE RESB-ENMNG.
DATA:L_ERROR(50) TYPE C.
DATA:L_ERROR2(50) TYPE C.
DATA:L_ENMNG LIKE RESB-ENMNG.
DATA:L_QPA LIKE RESB-ESMNG.
DATA:L_MATNR LIKE RESB-MATNR.
L_PSMNG = 0.
L_WEMNG = 0.
SELECT SINGLE AFPO~PSMNG AFPO~WEMNG INTO
(L_PSMNG, L_WEMNG ) FROM AFPO
WHERE AUFNR EQ ZCM03-AUFNR AND POSNR EQ '0001'.
L_NOPOSTGR = 0.
SELECT SUM( ZCM04~ERFMG ) INTO L_NOPOSTGR FROM ZCM04
INNER JOIN ZCM03 ON ZCM03~DOCNUMBER EQ ZCM04~DOCNUMBER
WHERE ZCM03~DOCTYPE EQ '3' AND ZCM03~MBLNR EQ ''
AND ZCM03~DOCSTAS EQ '0' AND ZCM03~AUFNR EQ ZCM03-AUFNR
AND ZCM04~MATNR EQ ZCM04TAB-MATNR AND
ZCM04~WERKS EQ ZCM04TAB-WERKS AND ZCM04~MARKDELETION NE 'X'
AND ZCM03~DOCNUMBER <> ZCM03-DOCNUMBER.
L_TOTALGR = 0.
L_TOTALGR = L_NOPOSTGR + L_WEMNG + ZCM04TAB-ERFMG.
IF ( ZCM04TAB-ERFMG > 0 AND L_TOTALGR > L_PSMNG ).
C_TOTALGR = L_TOTALGR.
CONDENSE C_TOTALGR.
C_ORDERQTY = L_PSMNG.
CONDENSE C_ORDERQTY.
CONCATENATE 'Error:WO GR QTY:' C_TOTALGR INTO L_ERROR.
CONCATENATE ' >Order Qty:' C_ORDERQTY INTO L_ERROR2.
CONDENSE L_ERROR.
CONDENSE L_ERROR2.
MESSAGE E000 WITH L_ERROR L_ERROR2
ZCM04TAB-MATNR ZCM04TAB-CHARG.
ENDIF.
L_CNT = 0.
SELECT COUNT(*) INTO L_CNT FROM ZMM048 WHERE
WERKS = ZCM04TAB-WERKS AND BJECT ='WOOVERGR2'
AND VALUE = 'ACTIVE'.
IF L_CNT > 0.
L_ENMNG = 0.
CLEAR L_ALPGR.
CLEAR L_ALPOS.
CLEAR L_BAUGR.
L_QPA = 1.
CLEAR ITAB_ISSUE[].
CLEAR ITAB_ISSUE.
SELECT MATNR RESB~ENMNG RESB~ALPGR RESB~ALPOS
RESB~BAUGR RESB~ESMNG "LBG20080419.ADD ying fa qty
INTO (ITAB_ISSUE-MATNR,L_ENMNG ,L_ALPGR ,
L_ALPOS ,L_BAUGR ,L_QPA )
FROM RESB INNER JOIN AFKO ON RESB~RSNUM = AFKO~RSNUM
WHERE AFKO~AUFNR EQ ZCM03-AUFNR
AND RESB~XLOEK NE 'X' AND RESB~BDMNG > 0.
IF NOT L_ALPGR IS INITIAL AND L_ALPGR <> ''
AND L_ALPOS EQ 'X'.
L_ENMNG = 0.
L_QPA = 1.
CLEAR L_MATNR.
ITAB_ISSUE-ISSQTY = 0.
SELECT RESB~ENMNG RESB~ESMNG RESB~MATNR INTO
(L_ENMNG , L_QPA , L_MATNR) FROM RESB
INNER JOIN AFKO ON RESB~RSNUM = AFKO~RSNUM
WHERE AFKO~AUFNR EQ ZCM03-AUFNR AND
RESB~ALPGR EQ L_ALPGR AND RESB~ALPOS = L_ALPOS
AND RESB~BAUGR EQ L_BAUGR.
ITAB_ISSUE-ISSQTY = ITAB_ISSUE-ISSQTY + ( L_ENMNG /
L_QPA ).
ENDSELECT.
ELSE.
ITAB_ISSUE-ISSQTY = L_ENMNG / L_QPA.
ENDIF.
APPEND ITAB_ISSUE.
CLEAR ITAB_ISSUE.
L_ENMNG = 0.
CLEAR L_ALPGR.
CLEAR L_ALPOS.
CLEAR L_BAUGR.
L_QPA = 1.
ENDSELECT.
SORT ITAB_ISSUE BY ISSQTY ASCENDING.
LOOP AT ITAB_ISSUE.
L_MINMATNR = ITAB_ISSUE-MATNR.
L_MINISSQTY = ITAB_ISSUE-ISSQTY.
EXIT.
ENDLOOP.
IF ( ZCM04TAB-ERFMG > 0 AND L_TOTALGR > L_MINISSQTY ).
C_TOTALGR = L_TOTALGR.
CONDENSE C_TOTALGR.
C_ORDERQTY = L_MINISSQTY.
CONDENSE C_ORDERQTY.
CONCATENATE 'Error:WO GR QTY:' C_TOTALGR INTO L_ERROR.
CONCATENATE ' >ALLOW GR QTY:' C_ORDERQTY INTO L_ERROR2.
CONDENSE L_ERROR.
CONDENSE L_ERROR2.
MESSAGE E000 WITH L_ERROR L_ERROR2
'Min Issue Material:' L_MINMATNR.
ENDIF.
ENDIF.
ENDFORM.
***lbg200806060934.add.en
FORM. CHECK_ITEM_DATA.
DATA: LBATCH(1) TYPE C,
UBATCH(1) TYPE C,
L_ENMNG_MAX LIKE RESB-ENMNG,
L_ENMNG_MIN LIKE RESB-ENMNG,
L_ENMNG LIKE RESB-ENMNG,
L_ENMNG1 LIKE RESB-ENMNG,"Yuan-Yuan 20091024 add
L_RESERVEQTY LIKE RESB-ENMNG,
L_VAILDQTY LIKE RESB-ENMNG,
L_AVAILQTY LIKE RESB-ENMNG,
L_PSMNG LIKE AFPO-PSMNG,
L_WEMNG LIKE AFPO-WEMNG,
L_DAUAT LIKE AFPO-DAUAT,
L_MINBT LIKE ZPCEMM003-MINBT,
L_MAXBT LIKE ZPCEMM003-MAXBT,
L_ALLRECEIVEDQTY LIKE AFPO-WEMNG,
L_OBJECT1(10) TYPE C.
DATA: L_CNT TYPE I."LBG20080411.ADD
DATA: BEGIN OF TMPITAB OCCURS 0,
MATNR LIKE RESB-MATNR,
BDMNG LIKE RESB-BDMNG,
ENMNG LIKE RESB-ENMNG,
ALPGR LIKE RESB-ALPGR,
BAUGR LIKE RESB-BAUGR,
ENTQTY LIKE RESB-ENMNG,
ALPOS LIKE RESB-ALPOS,
END OF TMPITAB.
***LBG20080418.ADD.SN
* DATA: L_MAXBT TYPE PROZS.
* DATA: L_MINBT TYPE PROZS.
* DATA: L_CNT TYPE I.
DATA: L_REQUIREQTY LIKE RESB-BDMNG.
DATA: L_MPQ LIKE MARC-BSTRF.
DATA: F_RESULT LIKE RESB-BDMNG.
DATA: I_RESULT TYPE I.
DATA: L_TOTALISSUE LIKE RESB-ENMNG.
DATA: C_TOTALISSUE(16) TYPE C.
DATA: C_REQUIREQTY(16) TYPE C.
DATA: C_MPQ(16) TYPE C.
DATA: C_MAXBT(6) TYPE C.
DATA: L_NOPOSTISSUE LIKE ZCM04-ERFMG.
DATA: L_ERROR(50) TYPE C.
DATA: L_ERROR2(50) TYPE C.
DATA: L_NOPOSTGR LIKE ZCM04-ERFMG."wo no post GR qty
DATA: L_TOTALGR LIKE ZCM04-ERFMG. "wo total GR qty
DATA: C_TOTALGR(16) TYPE C.
DATA: C_ORDERQTY(16) TYPE C.
DATA: L_RECONTROL(01) TYPE C.
DATA: L_NOPOSTRETURN LIKE ZCM04-ERFMG."wo no post return qty
DATA:L_ALPGR LIKE RESB-ALPGR.
DATA:L_ALPOS LIKE RESB-ALPOS.
DATA:L_YINGFA LIKE ZCM04-ERFMG. " account gr
DATA:C_YINGFA(16) TYPE C.
DATA:L_ALLOWRETURN LIKE ZCM04-ERFMG.
DATA:C_RETURNQTY(16) TYPE C.
DATA:C_ALLOWRETURN(16) TYPE C.
DATA:L_REQQTY LIKE RESB-BDMNG.
DATA:L_FAQTY LIKE RESB-ENMNG.
DATA:RE_POSTQTY LIKE ZCM04-ERFMG.
DATA:L_MATNR LIKE RESB-MATNR.
DATA:L_BAUGR LIKE RESB-BAUGR.
DATA:L_QPA LIKE RESB-ESMNG.
DATA:L_MPQCNT TYPE I.
DATA:LABST LIKE MCHB-CLABS.
DATA: L_CHAOFA LIKE ZCM04-ERFMG.
DATA: L_CHAOTUI LIKE ZCM04-ERFMG.
DATA: L_VALUE LIKE ZMM048-VALUE.
DATA: L_VALUE1 LIKE ZMM048-VALUE."Yuan-Yuan 20091024 add
DATA: L_VALUE2 LIKE ZPCECONTROLVALUE-INDICATOR1."kelly 20100608
DATA: L_VALUE3 LIKE ZPCECONTROLVALUE-INDICATOR1."kelly 20100608
* DATA: L_TOTALISSUE LIKE ZCM04-ERFMG.
DATA: L_TOTALRETURN LIKE ZCM04-ERFMG.
*add by yuan-yuan xiao 080519
DATA:L_SUM LIKE EKET-WEMNG.
DATA:L_ACCEPT LIKE ZCM04-ERFMG.
DATA:L_ALLOW(13) TYPE P DECIMALS 3.
DATA:L_RSNUM LIKE RESB-RSNUM.
DATA:L_RSPOS LIKE RESB-RSPOS.
DATA:L_CHARG LIKE ZCM04-CHARG. "echo090806.add
***LBG20080418.ADD.EN
***lbg20080918.add.sn
DATA: C_MPQCNT2 TYPE C.
DATA: L_MPQCNT2 TYPE I.
DATA: L_BUKRS LIKE T001K-BUKRS.
DATA: M_BUKRS LIKE T001K-BUKRS.
*Yuan-Yuan 20091123 add.sn
DATA: L_COUNT TYPE I.
DATA: TMP LIKE WA_TMP OCCURS 0.
DATA: TMP1 LIKE WA_TMP OCCURS 0.
*"Ariel add l_sgi 011014 for Over GI
DATA: L_SGI TYPE I.
*"Ariel add decimal 100423
DATA: L_DEC TYPE P DECIMALS 3.
DATA: L_BATCH LIKE ZCM04-CHARG. " added by vincent hou 100531
SELECT SINGLE FEVOR INTO AFKO-FEVOR
FROM AFKO WHERE AUFNR = ZCM03-AUFNR.
SELECT SINGLE A~VALUE INTO L_VALUE1
FROM ZMM048 AS A
JOIN AUFK AS B
ON A~WERKS = B~WERKS
WHERE B~AUFNR = ZCM03-AUFNR
AND A~OBJECT = 'WOREGIMBST'.
IF L_VALUE1 EQ 'ACTIVE' AND AFKO-FEVOR EQ 'CLD'
AND ZCM03-DOCTYPE = '2'.
SELECT COUNT( * )
INTO L_COUNT
FROM AUFM AS A
JOIN MKPF AS B
ON A~MBLNR = B~MBLNR
AND A~MJAHR = B~MJAHR
WHERE A~AUFNR = ZCM03-AUFNR
AND A~BWART = '262'
AND B~TCODE2 <> 'MB11'.
*Return issue by manually
IF L_COUNT > 0.
MESSAGE E208(00) WITH
'Reture all issue only use manual operation'.
*Return all issue
ELSE.
CLEAR WA_TMP.
LOOP AT ZCM04TAB WHERE MATNR NE SPACE.
MOVE-CORRESPONDING ZCM04TAB TO WA_TMP.
APPEND WA_TMP TO TMP1.CLEAR WA_TMP.
ENDLOOP.
SELECT DISTINCT MATNR WERKS CHARG ERFMG ERFME
RSNUM RSPOS
INTO CORRESPONDING FIELDS OF TABLE TMP
FROM RESB
FOR ALL ENTRIES IN TMP1
WHERE AUFNR = ZCM03-AUFNR
AND MATNR = TMP1-MATNR
AND WERKS = TMP1-WERKS
AND RSNUM = TMP1-RSNUM
AND RSPOS = TMP1-RSPOS.
SORT TMP1 BY MATNR WERKS RSNUM RSPOS.
SORT TMP BY MATNR WERKS RSNUM RSPOS.
IF TMP1[] NE TMP[].
MESSAGE E208(00) WITH 'Re-GI item is error'.
ENDIF.
ENDIF.
ENDIF.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14397246/viewspace-666157/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14397246/viewspace-666157/