How to Create ABAP Interactive Report for displaying first list & Secondary list:
SAP ABAP Interview Questions – Real Time
Interactive Report displaying data of two tables with 1 Sub Level.
Step 1: Go to SE38 Tcode. Type the program name and choose Source Code from Sub objects and Click on Create button.
Step 2: Type Title & select ‘Executable Program’ and then click on save.
Step 3: Now enter Package name in ‘Package’ and click on Savebutton.
Step 4: Enter the TR number and click onbutton.
Now ABAP Editor will open, and write the code given below for the report.
Best Laptops for ABAP Programmers
REPORT ziexample1 NO STANDARD PAGE HEADING.
TABLES : vbak, vbap.
*Types Declaration
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
ernam TYPE vbak-ernam,
auart TYPE vbak-auart,
vkorg TYPE vbak-vkorg,
vtweg TYPE vbak-vtweg,
spart TYPE vbak-spart,
vkgrp TYPE vbak-vkgrp,
kunnr TYPE vbak-kunnr,
END OF ty_vbak.
TYPES : BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
matkl TYPE vbap-matkl,
arktx TYPE vbap-arktx,
netwr TYPE vbap-netwr,
waerk TYPE vbap-waerk,
klmeng TYPE vbap-klmeng,
vrkme TYPE vbap-vrkme,
END OF ty_vbap.
*Data Declaration
DATA : gt_vbak TYPE STANDARD TABLE OF ty_vbak,
wa_vbak TYPE ty_vbak,
gt_vbap TYPE STANDARD TABLE OF ty_vbap,
wa_vbap TYPE ty_vbap.
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : so_vbeln FOR vbap-vbeln,
so_matnr FOR vbap-matnr,
so_matkl FOR vbap-matkl.
SELECTION-SCREEN END OF BLOCK b1.
*Header Information
TOP-OF-PAGE.
WRITE: ‘Sales Doc.’,
12 ‘Created Date’,
26 ‘Created By’,
38 ‘Doc. Type’,
48 ‘Sales Org.’,
60 ‘D. Channel’,
72 ‘Division’,
82 ‘Sales Group’,
94 ‘Customer’.
ULINE.
START-OF-SELECTION.
*Data Fetching
SELECT vbeln
erdat
ernam
auart
vkorg
vtweg
spart
vkgrp
kunnr
FROM vbak INTO TABLE gt_vbak
WHERE vbeln IN so_vbeln.
SORT gt_vbak BY vbeln.
*Displaying First List
LOOP AT gt_vbak INTO wa_vbak.
WRITE:/ wa_vbak-vbeln,
12 wa_vbak-erdat,
26 wa_vbak-ernam,
38 wa_vbak-auart,
48 wa_vbak-vkorg,
62 wa_vbak-vtweg,
74 wa_vbak-spart,
84 wa_vbak-vkgrp,
96 wa_vbak-kunnr.
HIDE: wa_vbak .
ENDLOOP.
*Displaying Secondary List
AT LINE-SELECTION.
WRITE: ‘Sales Doc.’,
12 ‘Item No.’,
21 ‘Material No.’,
40 ‘Mat. Group’,
51 ‘Description’,
101 ‘Amount’,
116 ‘Currency’,
130 ‘Quantity’,
147 ‘Sales unit’.
ULINE.
SELECT vbeln
posnr
matnr
matkl
arktx
netwr
waerk
klmeng
vrkme
FROM vbap INTO TABLE gt_vbap
WHERE vbeln = wa_vbak-vbeln.
SORT gt_vbap BY vbeln.
LOOP AT gt_vbap INTO wa_vbap.
WRITE:/ wa_vbap-vbeln,
12 wa_vbap-posnr,
20 wa_vbap-matnr,
40 wa_vbap-matkl,
51 wa_vbap-arktx,
91 wa_vbap-netwr,
117 wa_vbap-waerk,
122 wa_vbap-klmeng,
148 wa_vbap-vrkme.
ENDLOOP.
OUTPUT
Step 1: Press the F8 button in the report to execute it & then click on the below mark button.
Step 2: Now the first list of reports will be displayed as below.
Step 3: And then click on any Sales Doc number to display the secondary list of this report.