*&---------------------------------------------------------------------*
**& Report ZAJD_PROD_MISS_PART_RPT *
**& *
**&---------------------------------------------------------------------*
**& *
**& *
**&---------------------------------------------------------------------*
*
REPORT ZAJD_PROD_MISS_PART_RPT NO STANDARD PAGE HEADING .
**& TABLES ------------------------------------*
TABLES : AUFK,AFKO,AFPO,RESB.
**& Work Area ------------------------------------*
DATA : BEGIN OF WA_AUFK,
AUFNR LIKE AUFK-AUFNR, "Order Number
AUART LIKE AUFK-AUART, "Order Type
ERDAT LIKE AUFK-ERDAT, "Created on
WERKS LIKE AUFK-WERKS, "Plant
OBJNR LIKE AUFK-OBJNR, "Object number
LOEKZ LIKE AUFK-LOEKZ, "Deletion flag
KDAUF LIKE AUFK-KDAUF, "Sales Order Number
END OF WA_AUFK.
*DATA : BEGIN OF WA_AFKO,
* AUFNR LIKE AFKO-AUFNR, "Order Number
* GSTRI LIKE AFKO-GSTRI, "Actual start date
* FTRMI LIKE AFKO-FTRMI, "Actual release date
* RSNUM LIKE AFKO-RSNUM, "Number of Reservation / Dependent Requirement
* END OF WA_AFKO.
*
*DATA : BEGIN OF WA_AFPO,
* AUFNR LIKE AFPO-AUFNR, "Order Number
* POSNR LIKE AFPO-POSNR, "Order Item Number
* PSMNG LIKE AFPO-PSMNG, "Order item quantity
* MATNR LIKE AFPO-MATNR, "Material Number for Order
* END OF WA_AFPO.
DATA : BEGIN OF WA_ORD,
AUFNR LIKE AFPO-AUFNR, "Order Number
GSTRI LIKE AFKO-GSTRI, "Actual start date
FTRMI LIKE AFKO-FTRMI, "Actual release date
RSNUM LIKE AFKO-RSNUM, "Number of Reservation / Dependent Requirement
POSNR LIKE AFPO-POSNR, "Order Item Number
PSMNG LIKE AFPO-PSMNG, "Order item quantity
MATNR LIKE AFPO-MATNR, "Material Number for Order
KDAUF LIKE AFPO-KDAUF, "Sales order number
DAUAT LIKE AFPO-DAUAT, "Order Type
DWERK LIKE AFPO-DWERK, "Plant
END OF WA_ORD.
DATA : BEGIN OF WA_RESB,
RSNUM LIKE RESB-RSNUM, "Number of Reservation / Dependent Requirement
RSPOS LIKE RESB-RSPOS, "Item Number of Reservation / Dependent Requirements
MATNR LIKE RESB-MATNR, "Material Number
BDMNG LIKE RESB-BDMNG, "Requirement Quantity
ENMNG LIKE RESB-ENMNG, "Quantity withdrawn
DUMPS LIKE RESB-DUMPS,
END OF WA_RESB.
DATA : BEGIN OF WA_MAKT,
MATNR LIKE MAKT-MATNR, "Material Numeber
MAKTX LIKE MAKT-MAKTX, "Material Description
END OF WA_MAKT.
DATA : BEGIN OF WA,
AUFNR LIKE AUFK-AUFNR, "Order Number
AUART LIKE AUFK-AUART, "Order Type
ERDAT LIKE AUFK-ERDAT, "Created on
WERKS LIKE AUFK-WERKS, "Plant
KDAUF LIKE AUFK-KDAUF, "Sales Order Number
SODAT LIKE VBAK-ERDAT, "Sales Order Date
KUNNR LIKE VBAK-KUNNR, "Customer Code
PRODNO LIKE AFPO-MATNR, "Product Code
PRQTY LIKE AFPO-PSMNG, "Product Quantity
MATNR LIKE RESB-MATNR, "Material(Parts) Number
MAKTX LIKE MAKT-MAKTX, "Material Description
OPQTY LIKE RESB-BDMNG, "Open Quantity
END OF WA.
**& Internal Tables ------------------------------------*
DATA : IT_AUFK LIKE WA_AUFK OCCURS 0 WITH HEADER LINE.
*DATA : IT_AFKO LIKE WA_AFKO OCCURS 0 WITH HEADER LINE.
*DATA : IT_AFPO LIKE WA_AFPO OCCURS 0 WITH HEADER LINE.
DATA : IT_RESB LIKE WA_RESB OCCURS 0 WITH HEADER LINE.
DATA : IT_ORD LIKE WA_ORD OCCURS 0 WITH HEADER LINE.
DATA : IT_MAKT LIKE WA_MAKT OCCURS 0 WITH HEADER LINE.
DATA : IT LIKE WA OCCURS 0 WITH HEADER LINE.
**& Variables ------------------------------------*
DATA : STR LIKE BSVX-STTXT.
DATA : MTXT LIKE MAKT-MAKTX,
CNAME LIKE KNA1-NAME1.
DATA : OBJNR TYPE J_OBJNR.
DATA : OPENQTY TYPE RESB-BDMNG.
**& Selection Screen ------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_WERKS FOR AUFK-WERKS,
S_AUART FOR AUFK-AUART,
S_AUFNR FOR AUFK-AUFNR,
S_MATNR FOR AFPO-MATNR,
* S_ERDAT FOR AUFK-ERDAT,
S_KDAUF FOR AUFK-KDAUF.
SELECTION-SCREEN END OF BLOCK B1.
**& Start of selection ------------------------------------*
START-OF-SELECTION.
*BREAK-POINT.
SELECT *
FROM AFPO
JOIN AFKO ON AFKO~AUFNR = AFPO~AUFNR
INTO CORRESPONDING FIELDS OF TABLE IT_ORD
WHERE AFPO~AUFNR IN S_AUFNR
AND AFPO~KDAUF IN S_KDAUF
AND AFPO~MATNR IN S_MATNR
AND AFPO~DWERK IN S_WERKS
AND AFPO~DAUAT IN S_AUART.
*SELECT * FROM AUFK INTO CORRESPONDING FIELDS OF TABLE IT_AUFK
* WHERE AUFNR IN S_AUFNR
* AND AUART IN S_AUART
* AND ERDAT IN S_ERDAT
* AND WERKS IN S_WERKS
* AND LOEKZ NE 'X'
* AND KDAUF IN S_KDAUF.
CHECK IT_ORD[] IS NOT INITIAL.
LOOP AT IT_ORD.
CLEAR OBJNR.
CONCATENATE 'OR' IT_ORD-AUFNR INTO OBJNR.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
CLIENT = SY-MANDT
OBJNR = OBJNR
SPRAS = SY-LANGU
IMPORTING
LINE = STR
EXCEPTIONS
OBJECT_NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
message 'Object Number not find' type 'I'.
ENDIF.
SEARCH STR FOR 'REL'.
IF SY-SUBRC ne 0.
DELETE IT_ORD.
ENDIF.
CLEAR IT_ORD.
ENDLOOP.
*CHECK IT_AUFK[] IS NOT INITIAL.
* SELECT *
* FROM AFKO JOIN AFPO ON AFKO~AUFNR = AFPO~AUFNR
* INTO CORRESPONDING FIELDS OF TABLE IT_ORD
* FOR ALL ENTRIES IN IT_AUFK
* WHERE AFKO~AUFNR = IT_AUFK-AUFNR.
IF IT_ORD[] IS NOT INITIAL.
SELECT * FROM RESB INTO CORRESPONDING FIELDS OF TABLE IT_RESB
FOR ALL ENTRIES IN IT_ORD
WHERE RSNUM = IT_ORD-RSNUM.
ENDIF.
IF IT_RESB[] IS NOT INITIAL.
SELECT * FROM MAKT INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
FOR ALL ENTRIES IN IT_RESB
WHERE MATNR = IT_RESB-MATNR
AND SPRAS = SY-LANGU.
ENDIF.
CLEAR IT_RESB.
LOOP AT IT_RESB.
CLEAR OPENQTY.
OPENQTY = IT_RESB-BDMNG - IT_RESB-ENMNG.
IF OPENQTY > 0 AND IT_RESB-DUMPS <> 'X'.
IT-MATNR = IT_RESB-MATNR.
IT-OPQTY = OPENQTY.
READ TABLE IT_MAKT WITH KEY MATNR = IT-MATNR.
IT-MAKTX = IT_MAKT-MAKTX.
READ TABLE IT_ORD WITH KEY RSNUM = IT_RESB-RSNUM.
IT-AUFNR = IT_ORD-AUFNR.
IT-PRQTY = IT_ORD-PSMNG.
IT-PRODNO = IT_ORD-MATNR.
IT-AUART = IT_ORD-DAUAT.
IT-WERKS = IT_ORD-DWERK.
IT-KDAUF = IT_ORD-KDAUF.
* READ TABLE IT_AUFK WITH KEY AUFNR = IT-AUFNR.
* IT-AUART = IT_AUFK-AUART.
* IT-ERDAT = IT_AUFK-ERDAT.
* IT-WERKS = IT_AUFK-WERKS.
* IT-KDAUF = IT_AUFK-KDAUF.
SELECT SINGLE ERDAT KUNNR
FROM VBAK
INTO (IT-SODAT, IT-KUNNR)
WHERE VBELN = IT-KDAUF.
SELECT SINGLE MAKTX
FROM MAKT INTO (IT-MAKTX)
WHERE MATNR = IT_RESB-MATNR.
APPEND IT.
CLEAR : IT,IT_MAKT,IT_ORD,IT_AUFK.
ENDIF.
ENDLOOP.
SORT IT BY WERKS AUFNR PRODNO MATNR.
LOOP AT IT.
ON CHANGE OF IT-AUFNR.
WRITE : /1(85) SY-ULINE.
WRITE : / .
WRITE : /3 'PLANT' ,
20 IT-WERKS color 6 inverse intensified on,
40 'SO NO' ,
55 IT-KDAUF color 6 inverse intensified on ,
70 'SO DATE' ,
80 IT-SODAT color 6 inverse intensified on.
clear : MTXT,CNAME.
SELECT SINGLE NAME1 INTO CNAME FROM KNA1 WHERE KUNNR = IT-KUNNR.
WRITE : /3 'ORDER' ,
20 IT-AUFNR color 6 inverse intensified on,
40 'CUST. NAME' ,
55 CNAME color 6 inverse intensified on.
SELECT SINGLE MAKTX INTO MTXT FROM MAKT WHERE MATNR = IT-PRODNO.
WRITE : /3 'PRODUCT CODE' ,
20 IT-PRODNO color 6 inverse intensified on,
40 'DESCRIPTION' ,
55 MTXT color 6 inverse intensified on.
WRITE : /3 'QUANTITY' ,
20 IT-PRQTY LEFT-JUSTIFIED color 6 inverse intensified on.
WRITE : / .
WRITE : /1(85) SY-ULINE.
FORMAT COLOR 3 INTENSIFIED ON.
WRITE : /1 SY-VLINE,
2 'MATERIAL',
22 SY-VLINE,
23 'DESCRIPTION',
65 SY-VLINE,
71 'OPEN QUANTITY',
SY-VLINE.
FORMAT COLOR OFF.
WRITE : /1(85) SY-ULINE.
ENDON.
FORMAT COLOR 4 INTENSIFIED ON.
WRITE : / SY-VLINE ,
IT-MATNR ,
SY-VLINE,
IT-MAKTX ,
SY-VLINE,
IT-OPQTY,
SY-VLINE.
FORMAT COLOR OFF.
ENDLOOP.
WRITE : /1(85) SY-ULINE.