Dear ABAP masters I am very new to ABAP programming and an SD consultant friend of mine asked me to develop a code wherein I must get Delivery and Billing Doc for the all sales order selected.. and I developed following code. But I get no data.. I checked the DB tables too there certainly is no data for the given VBAK-VBELN.. So I was wondering if U could guide me if my code is correct if not please help me correct my code.
Please forgive me if I did not follow any of the guidelines of SCN.
TABLES : VBRK.
DATA : BEGINOF WA_VBAK,
VBELN LIKE VBAK-VBELN,
ENDOF WA_VBAK.
DATA IT_VBAK LIKETABLEOF WA_VBAK.
DATA : BEGINOF WA_VBRK,
VBELN LIKE VBRK-VBELN,
ENDOF WA_VBRK.
DATA IT_VBRK LIKETABLEOF WA_VBRK.
DATA : BEGINOF WA_LIKP,
VBELN LIKE LIKP-VBELN,
ENDOF WA_LIKP.
DATA IT_LIKP LIKETABLEOF WA_LIKP.
DATA : BEGINOF WA_FINAL,
VBELN_S LIKE VBAK-VBELN,
VBELN_B LIKE VBRK-VBELN,
VBELN_D LIKE LIKP-VBELN,
ENDOF WA_FINAL.
DATA IT_FINAL LIKETABLEOF WA_FINAL.
TYPE-POOLS : SLIS.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
SELECTION-SCREENBEGINOFBLOCK A WITHFRAMETITLETEXT-001.
SELECTION-SCREENSKIP.
SELECT-OPTIONS : SO_VBELN FOR VBRK-VBELN.
SELECTION-SCREENSKIP.
SELECTION-SCREENENDOFBLOCK A.
START-OF-SELECTION.
SELECT VBELN FROM VBRK INTOTABLE IT_VBRK
WHERE VBELN IN SO_VBELN.
IFNOT IT_VBRK ISINITIAL.
SELECT VBELN FROM LIKP INTOTABLE IT_LIKP
FORALL ENTRIES IN IT_VBRK
WHERE VBELN = IT_VBRK-VBELN.
ENDIF.
IFNOT IT_LIKP ISINITIAL.
SELECT VBELN FROM VBAK INTOTABLE IT_VBAK
FORALL ENTRIES IN IT_LIKP
WHERE VBELN = IT_LIKP-VBELN.
ENDIF.
* LOOP AT IT_VBRK INTO WA_VBRK.
*
* WA_FINAL-VBELN_B = WA_VBRK-VBELN.
*
* READ TABLE IT_LIKP INTO WA_LIKP
* WITH KEY VBELN = WA_VBRK-VBELN.
*
* WA_FINAL-VBELN_D = WA_LIKP-VBELN.
*
* READ TABLE IT_VBAK INTO WA_VBAK
* WITH KEY VBELN = WA_LIKP-VBELN.
*
* WA_FINAL-VBELN_S = WA_VBAK-VBELN.
*
* APPEND WA_FINAL TO IT_FINAL.
* CLEAR WA_FINAL.
* ENDLOOP.
LOOPAT IT_VBAK INTO WA_VBAK.
WA_FINAL-VBELN_S = WA_VBAK-VBELN.
READTABLE IT_VBRK INTO WA_VBRK
WITHKEY VBELN = WA_VBAK-VBELN.
WA_FINAL-VBELN_B = WA_VBRK-VBELN.
READTABLE IT_LIKP INTO WA_LIKP
WITHKEY VBELN = WA_VBRK-VBELN.
WA_FINAL-VBELN_D = WA_LIKP-VBELN.
APPEND WA_FINAL TO IT_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
CALLFUNCTION'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = 'WA_FINAL'
CHANGING
CT_FIELDCAT = IT_FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGEID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALLFUNCTION'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGEID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.