2008年(7)
分类:
2008-08-14 09:15:06
* * Production Order Quantity Change Daily Checklist * * An 'Err' flag will be assigned to the 'Rmks' column if the Required * components quantity does not equal to the calculated BOM components * quantity. * * Submitted by : SAP Basis, ABAP Programming and Other IMG Stuff * REPORT ZPPORDER LINE-SIZE 180 NO STANDARD PAGE HEADING LINE-COUNT 058(001). TABLES: AUFK, "Order master data AFKO, "Order header data PP orders RESB, "Reservation/dependent requirements MAST, "Material to BOM Link STKO, "BOM Header STPO. "BOM item DATA: BEGIN OF WA, AUART TYPE AUFK-AUART, AUFNR TYPE AUFK-AUFNR, AEDAT TYPE AUFK-AEDAT, AENAM TYPE AUFK-AENAM, WERKS TYPE AUFK-WERKS, PLNBEZ TYPE AFKO-PLNBEZ, GAMNG TYPE AFKO-GAMNG, GASMG TYPE AFKO-GASMG, MATNR TYPE RESB-MATNR, POSNR TYPE RESB-POSNR, BDMNG TYPE RESB-BDMNG, BMENG TYPE STKO-BMENG, MENGE TYPE STPO-MENGE, END OF WA, ITAB LIKE SORTED TABLE OF WA WITH NON-UNIQUE KEY AUFNR POSNR. DATA: BEGIN OF ITAB2 OCCURS 0. INCLUDE STRUCTURE WA. DATA: END OF ITAB2. DATA: BEGIN OF ITAB-AUFK OCCURS 0, AUART LIKE AUFK-AUART, AUFNR LIKE AUFK-AUFNR, POSNR LIKE RESB-POSNR, AEDAT LIKE AUFK-AEDAT, AENAM LIKE AUFK-AENAM, WERKS LIKE AUFK-WERKS, PLNBEZ LIKE AFKO-PLNBEZ, GAMNG(7) TYPE P DECIMALS 0, GASMG(7) TYPE P DECIMALS 0, MATNR LIKE RESB-MATNR, BDMNG(7) TYPE P DECIMALS 0, BMENG(7) TYPE P DECIMALS 0, MENGE(7) TYPE P DECIMALS 3. DATA: END OF ITAB-AUFK. DATA: FDATE LIKE SY-DATUM, LDATE LIKE SY-DATUM. DATA: X_AUFNR LIKE AFKO-AUFNR, X_MENGE(7) TYPE P DECIMALS 0, X_ERR(3). DATA: W_DATASET1(500) VALUE '/usr/sap/trans/data/'. SELECT-OPTIONS T_WERKS FOR AUFK-WERKS OBLIGATORY. SELECT-OPTIONS T_AUFNR FOR AUFK-AUFNR. SELECT-OPTIONS T_AEDAT FOR AUFK-AEDAT. PARAMETERS PDATA LIKE W_DATASET1. CONCATENATE W_DATASET1 PDATA INTO W_DATASET1. PERFORM F_COLLECT_DATA. FORM F_COLLECT_DATA. OPEN DATASET W_DATASET1 FOR INPUT IN TEXT MODE. DO. IF sy-subrc <> 0. EXIT. ENDIF. READ DATASET W_DATASET1 INTO WA. APPEND WA TO ITAB2. ENDDO. CLOSE DATASET W_DATASET1. SELECT A~AUFNR A~AUART A~AEDAT A~AENAM A~WERKS B~PLNBEZ B~GAMNG B~GASMG C~MATNR C~BDMNG C~POSNR INTO CORRESPONDING FIELDS OF TABLE ITAB FROM ( AUFK AS A INNER JOIN AFKO AS B ON B~AUFNR = A~AUFNR INNER JOIN RESB AS C ON C~AUFNR = A~AUFNR ) WHERE A~AEDAT IN T_AEDAT AND A~WERKS IN T_WERKS. LOOP AT ITAB INTO WA. CLEAR MAST. SELECT SINGLE * FROM MAST WHERE MATNR = WA-PLNBEZ AND WERKS = WA-WERKS. CLEAR STKO. SELECT SINGLE * FROM STKO WHERE STLNR = MAST-STLNR AND STLAL = MAST-STLAL. CLEAR STPO. SELECT SINGLE * FROM STPO WHERE STLNR = MAST-STLNR AND POSNR = WA-POSNR. WA-BMENG = STKO-BMENG. WA-MENGE = STPO-MENGE. MODIFY ITAB FROM WA. AT NEW AUFNR. SKIP. ENDAT. LOOP AT ITAB2 WHERE AUFNR = WA-AUFNR AND POSNR = WA-POSNR. IF ITAB2-GAMNG <> WA-GAMNG OR ITAB2-GASMG <> WA-GASMG OR ITAB2-BDMNG <> WA-BDMNG. CLEAR X_MENGE. IF ITAB2-BMENG <> 0. X_MENGE = ITAB2-GAMNG / ITAB2-BMENG * ITAB2-MENGE. ENDIF. CLEAR X_ERR. IF ITAB2-BDMNG <> X_MENGE. X_ERR = 'Err'. ENDIF. FORMAT COLOR COL_TOTAL. WRITE: / ITAB2-AUART UNDER 'Type', ITAB2-AUFNR UNDER 'Prod Order', ITAB2-AEDAT UNDER 'Last Chg Dt', ITAB2-AENAM UNDER 'Last Chg by', ITAB2-WERKS UNDER 'Plant', ITAB2-PLNBEZ UNDER 'Material', (10) ITAB2-GAMNG UNDER 'Order Qty' DECIMALS 0, (10) ITAB2-GASMG UNDER 'Scrap Qty' DECIMALS 0, ITAB2-POSNR UNDER 'Item', ITAB2-MATNR UNDER 'Component Req', (10) ITAB2-BDMNG UNDER 'Req Qty' DECIMALS 0, X_MENGE UNDER 'BOM Qty' COLOR COL_TOTAL, ITAB2-BMENG UNDER 'BOM Base', ITAB2-MENGE UNDER 'BOM Comp', X_ERR UNDER 'Rmks' COLOR COL_TOTAL. CLEAR X_MENGE. IF WA-BMENG <> 0. X_MENGE = WA-GAMNG / WA-BMENG * WA-MENGE. ENDIF. CLEAR X_ERR. IF WA-BDMNG <> X_MENGE. X_ERR = 'Err'. ENDIF. FORMAT COLOR OFF. WRITE: / WA-AUART UNDER 'Type', WA-AUFNR UNDER 'Prod Order', WA-AEDAT UNDER 'Last Chg Dt', WA-AENAM UNDER 'Last Chg by', WA-WERKS UNDER 'Plant', WA-PLNBEZ UNDER 'Material', (10) WA-GAMNG UNDER 'Order Qty' DECIMALS 0, (10) WA-GASMG UNDER 'Scrap Qty' DECIMALS 0, WA-POSNR UNDER 'Item', WA-MATNR UNDER 'Component Req', (10) WA-BDMNG UNDER 'Req Qty' DECIMALS 0, X_MENGE UNDER 'BOM Qty' COLOR COL_TOTAL, WA-BMENG UNDER 'BOM Base', WA-MENGE UNDER 'BOM Comp', X_ERR UNDER 'Rmks' COLOR COL_TOTAL. ENDIF. ENDLOOP. ENDLOOP. LOOP AT ITAB2. LOOP AT ITAB INTO WA WHERE AUFNR = ITAB2-AUFNR AND POSNR = ITAB2-POSNR. DELETE ITAB2. ENDLOOP. SELECT SINGLE * FROM AUFK WHERE AUFNR = ITAB2-AUFNR. IF SY-SUBRC <> 0. DELETE ITAB2. ENDIF. ENDLOOP. OPEN DATASET W_DATASET1 FOR OUTPUT IN TEXT MODE. LOOP AT ITAB INTO WA. TRANSFER WA TO W_DATASET1. ENDLOOP. LOOP AT ITAB2 INTO WA. TRANSFER WA TO W_DATASET1. ENDLOOP. CLOSE DATASET W_DATASET1. ENDFORM. TOP-OF-PAGE. FORMAT COLOR COL_TOTAL. WRITE: / SY-DATUM, SY-UZEIT, SY-REPID, SY-UNAME, 50 'Daily Qty Changed Checklist for Production Order', 120 SY-PAGNO. SKIP. WRITE: / 'Plant ', T_WERKS-LOW. WRITE: ' Last Change Date ', T_AEDAT-LOW, ' to ', T_AEDAT-HIGH. SKIP. WRITE: /1 'Type', 6 'Prod Order', 17 'Last Chg Dt', 29 'Last Chg by', 42 'Plant', 49 'Material', 69 'Order Qty', 83 'Scrap Qty', 99 'Item', 105 'Component Req', 121 'Req Qty', 135 'BOM Qty', 149 'BOM Base', 163 'BOM Comp', 178 'Rmks'. ULINE. WRITE: / 'Previous data :- '. FORMAT COLOR OFF. WRITE: / 'Current data :- '. INITIALIZATION. LDATE = SY-DATUM. LDATE = LDATE - 1. FDATE = LDATE. MOVE: FDATE TO T_AEDAT-LOW. APPEND T_AEDAT. PDATA = 'AE001'. *--- End of Program