Skip to Content
0
Jan 18, 2021 at 02:31 PM

Get invoice related information for selected sales order

63 Views

I need to enhance the program to get Invoice related information for selected sales orders and display against each sales item Invoice Billing date and Billing qty .

please correct the code. i didnt get correct invoice number.

TYPE-POOLS SLIS.

TABLES : VBAP , VBRK , VBFA.


TYPES : BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
KWMENG TYPE VBAP-KWMENG,
FKDAT TYPE VBRK-FKDAT,
VBELV TYPE VBELN_VON,
VBTYP_N TYPE VBTYP_N,
END OF TY_VBAP.



DATA : IT_VBAP TYPE TABLE OF TY_VBAP .
DATA : WA_VBAP TYPE TY_VBAP .

DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA : WA_FCAT LIKE LINE OF IT_FCAT .


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : SO_VBELN FOR VBAP-VBELN.
SELECTION-SCREEN END OF BLOCK B1.




START-OF-SELECTION.

WA_FCAT-COL_POS = '1' .
WA_FCAT-FIELDNAME = 'VBELN' .
WA_FCAT-TABNAME = 'IT_VBAP' .
WA_FCAT-SELTEXT_M = 'Sales Order' .
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


WA_FCAT-COL_POS = '2' .
WA_FCAT-FIELDNAME = 'KWMENG' .
WA_FCAT-TABNAME = 'IT_VBAP' .
WA_FCAT-SELTEXT_M = 'Billing Quantity' .
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


WA_FCAT-COL_POS = '3' .
WA_FCAT-FIELDNAME = 'FKDAT' .
WA_FCAT-TABNAME = 'IT_VBAP' .
WA_FCAT-SELTEXT_M = 'Billing Date' .
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .

WA_FCAT-COL_POS = '4' .
WA_FCAT-FIELDNAME = 'VBELV' .
WA_FCAT-TABNAME = 'IT_VBAP' .
WA_FCAT-SELTEXT_M = 'INVOICE NUMBER' .
APPEND WA_FCAT TO IT_FCAT .
CLEAR WA_FCAT .


PERFORM GET_DATA.
PERFORM DISPLAY_DATA.
FORM GET_DATA .


SELECT A~VBELN
A~KWMENG
B~FKDAT
C~VBELV
C~VBELN


FROM VBRK AS B INNER JOIN VBFA AS C ON B~VBELN = C~VBELN
INNER JOIN VBAP AS A ON A~VBELN = C~VBELV
INTO TABLE IT_VBAP
WHERE A~VBELN IN SO_VBELN AND
C~VBELV = A~VBELN AND
VBTYP_N = 'M'.


ENDFORM.



FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_VBAP.



ENDFORM.