REPORT ZR_A1 NO STANDARD PAGE HEADING.
*Tables declarations*
TABLES: VBAK, VBAP.
*Variable declarations*
DATA: C1 TYPE C.
*Internal Table declarations**
DATA: BEGIN OF IT_VBAK OCCURS 0,
VBELN LIKE VBAK-VBELN,
VKORG LIKE VBAK-VKORG,
VTWEG LIKE VBAK-VTWEG,
SPART LIKE VBAK-SPART,
END OF IT_VBAK.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
NETWR LIKE VBAP-NETWR,
BRGEW LIKE VBAP-BRGEW,
NTGEW LIKE VBAP-NTGEW,
END OF IT_VBAP.
DATA: BEGIN OF IT_FINAL OCCURS 0,
VBELN LIKE VBAK-VBELN,
VKORG LIKE VBAK-VKORG,
VTWEG LIKE VBAK-VTWEG,
SPART LIKE VBAK-SPART,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
NETWR LIKE VBAP-NETWR,
BRGEW LIKE VBAP-BRGEW,
NTGEW LIKE VBAP-NTGEW,
END OF IT_FINAL.
*Selection-screen design*
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-R01.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
SELECTION-SCREEN: END OF BLOCK B1.
TOP-OF-PAGE.
FORMAT INTENSIFIED ON COLOR 5.
WRITE:/7 'LIST TO DISPLAY SALES ITEM INFO'.
START-OF-SELECTION.
*Populating it_vbak table*
SELECT VBELN
VKORG
VTWEG
SPART
FROM VBAK
INTO TABLE IT_VBAK
WHERE VBELN IN S_VBELN.
*populating it_vbap table*
IF NOT IT_VBAK[] IS INITIAL.
SELECT VBELN
POSNR
MATNR
NETWR
BRGEW
NTGEW
FROM VBAP
INTO TABLE IT_VBAP
FOR ALL ENTRIES IN IT_VBAK
WHERE VBELN = IT_VBAK-VBELN.
ENDIF.
*populating the final list*
LOOP AT IT_VBAP.
READ TABLE IT_VBAK WITH KEY VBELN = IT_VBAP-VBELN.
IF SY-SUBRC = 0.
MOVE: IT_VBAK-VBELN TO IT_FINAL-VBELN,
IT_VBAK-VKORG TO IT_FINAL-VKORG,
IT_VBAK-VTWEG TO IT_FINAL-VTWEG,
IT_VBAK-SPART TO IT_FINAL-SPART,
IT_VBAP-POSNR TO IT_FINAL-POSNR,
IT_VBAP-MATNR TO IT_FINAL-MATNR,
IT_VBAP-NETWR TO IT_FINAL-NETWR,
IT_VBAP-BRGEW TO IT_FINAL-BRGEW,
IT_VBAP-NTGEW TO IT_FINAL-NTGEW.
APPEND IT_FINAL.
ENDIF.
ENDLOOP.
SORT IT_FINAL BY VBELN.
LOOP AT IT_FINAL.
AT FIRST.
FORMAT INTENSIFIED ON COLOR 1.
WRITE:/35 'SALES DOCUMENT ITEM LIST'.
ULINE AT (100).
FORMAT INTENSIFIED ON COLOR 5.
WRITE:/ SY-VLINE,
2 'SALES.DOCU.NO',
13 'ITEM',
21 'MATERIAL',
50 'NET-VAL',
65 'GROSS-WT',
82 'NET-WT',
100 SY-VLINE.
ENDAT.
FORMAT INTENSIFIED ON COLOR 2.
WRITE:/ SY-VLINE,
2 C1 AS CHECKBOX,
5 IT_FINAL-VBELN,
13 IT_FINAL-POSNR,
21 IT_FINAL-MATNR,
41 IT_FINAL-NETWR,
56 IT_FINAL-BRGEW,
71 IT_FINAL-NTGEW,
100 SY-VLINE.
AT END OF VBELN.
SUM.
FORMAT INTENSIFIED ON COLOR 3.
WRITE:/ SY-VLINE,
30 'SUB-TOTAL:',
41 IT_FINAL-NETWR,
56 IT_FINAL-BRGEW,
71 IT_FINAL-NTGEW.
WRITE:/100 SY-VLINE.
ENDAT.
AT LAST.
SUM.
FORMAT INTENSIFIED ON COLOR 6.
WRITE:/ SY-VLINE,
30 'GRAND-TOTAL:',
41 IT_FINAL-NETWR,
56 IT_FINAL-BRGEW,
71 IT_FINAL-NTGEW.
WRITE:/100 SY-VLINE.
ENDAT. ENDLOOP.
Hello venkat,
ReplyDeleteYour subtotal & grandtotal in general is awesome. thank you for sharing with us.
Regards,
Shweta