Interactive Report Programming in SAP ABAP – Step-by-Step Tutorial for Developers
✅ What You Will Learn in This SAP ABAP Interactive reports.
-
Understanding SAP ABAP Interactive Reports and how they differ from Classical Reports for real-time data display.
-
Implementing AT LINE-SELECTION event to create clickable rows and drill-down secondary lists in your report.
-
Using HIDE statements to pass selected row data from the basic list to secondary lists effectively.
-
Creating hotspots and navigation in Interactive Reports for better user interaction and dynamic output.
-
Building real-time examples using MARA or other SAP tables to demonstrate practical Interactive Report programming in ABAP.
📘 What is an Interactive Report in SAP ABAP?
Interactive Reports allow users to interact with the report output. They start with a basic list and allow users to drill down into secondary or detail lists.
- Basic List: Main report output
- Secondary List: Output shown after user action (e.g., clicking a line)
- Supports up to 20 secondary lists
- Navigation is done via
AT LINE-SELECTION,HIDE, andSY-LSIND
🎯 Why Use Interactive Reports?
- Improve user experience
- Provide hierarchical data views
- Useful in master-detail scenarios (e.g., header → item)
- Save screen clutter
🔁 Key Events in Interactive Reporting
Event | Description |
|---|---|
START-OF-SELECTION | Basic list logic |
AT LINE-SELECTION | Triggered on user click |
HIDE | Stores values for use in detail screen |
SY-LSIND | System variable showing list level |
- Basic List: Show Purchase Orders from
EKKO - Secondary List: Show Items from
EKPOfor selected PO.
REPORT z_interactive_ekko_ekpo.
TABLES: ekko, ekpo.
DATA: it_ekko TYPE STANDARD TABLE OF ekko, wa_ekko TYPE ekko.
DATA: it_ekpo TYPE STANDARD TABLE OF ekpo, wa_ekpo TYPE ekpo.
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE it_ekko WHERE ebeln IN s_ebeln.
IF sy-subrc = 0. LOOP AT it_ekko INTO wa_ekko. WRITE: / 'PO Number:', wa_ekko-ebeln, 'Vendor:', wa_ekko-lifnr, 'Doc Type:', wa_ekko-bsart.
" HIDE the PO number for later use HIDE wa_ekko-ebeln. ENDLOOP. ELSE. WRITE: / 'No purchase orders found.'. ENDIF.
*--- Secondary List on PO selectionAT LINE-SELECTION.
CLEAR it_ekpo. READ LINE sy-lilli FIELD VALUE wa_ekko-ebeln. SELECT * FROM ekpo INTO TABLE it_ekpo WHERE ebeln = wa_ekko-ebeln.
IF sy-subrc = 0. WRITE: / 'Item details for PO:', wa_ekko-ebeln. ULINE.
LOOP AT it_ekpo INTO wa_ekpo. WRITE: / 'Item:', wa_ekpo-ebelp, 'Material:', wa_ekpo-matnr, 'Quantity:', wa_ekpo-menge, 'Net Price:', wa_ekpo-netpr. ENDLOOP. ELSE. WRITE: / 'No items found for this PO.'. ENDIF.* The below screen short shows the purchase order data.
WHEN A USER DOUBLE CLICK ON THE PURCHASE ORDER HEADER DATA IT WILL OPEN THE SECOUNDRY SCREEN, IT HAS ITEM PURCHASE DATA.
🧠 Explanation of the Code
HIDE is used to remember the ebeln value for use in the secondary list.
On clicking any PO line, AT LINE-SELECTION is triggered, and the corresponding EKPO data is displayed.
SY-LSIND is automatically handled to show a secondary screen.
Initial Screen – List of Purchase Orders from EKKO.
User clicks on any PO line.
Secondary screen – Shows PO items from EKPO for selected EBELN.
Always use HIDE after WRITE when you want to use field values in detail screens.
You can create up to 20 levels of interaction (SY-LSIND increases with every drill-down).
Use ULINE, SKIP, and formatting for better output r
*****REAL TIME EXAMPLE USING PURCHASE HEADER AND ITEM DATA.
💡 Real-Time Example Using EKKO & EKPO (Header/Item)
📌 Goal:
📄 Output Behavior
📌 Tips for Interactive Reports.
REPORT ZMM_INTERACTIVE_REPORT.
it_orders TYPE TABLE OF vbak,
wa_customer TYPE kna1,
wa_order TYPE vbak.
START-OF-SELECTION.
SELECT *
INTO TABLE it_customers
FROM kna1
UP TO 20 ROWS.
LOOP AT it_customers INTO wa_customer.
WRITE: / wa_customer-kunnr, wa_customer-name1.
HIDE wa_customer-kunnr.
ENDLOOP.
AT LINE-SELECTION.
CLEAR it_orders.
SELECT *
INTO TABLE it_orders
FROM vbak
WHERE kunnr = wa_customer-kunnr.
LOOP AT it_orders INTO wa_order.
WRITE: / wa_order-vbeln, wa_order-erdat.
ENDLOOP.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: / 'Sales Orders for Customer:', wa_customer-name1.
1️⃣ What is an Interactive Report in SAP ABAP?
An Interactive Report allows the user to click on a list line and display a secondary list, enabling drill-down navigation for detailed data.
2️⃣ How many secondary lists can an Interactive Report have?
Up to 20 secondary lists (up to list index 21) can be created using WRITE statements in interactive mode.
3️⃣ Which event is mandatory for Interactive Reports?
The event AT LINE-SELECTION is mandatory because it triggers when the user double-clicks a line to display the secondary list.
4️⃣ What is the use of the HIDE statement?
HIDE stores the field values of the selected line so that they can be accessed in secondary lists. It is used to pass context.
5️⃣ What is the purpose of SY-LSIND?
SY-LSIND represents the current list level.
-
0 = Basic list
-
1…20 = Secondary lists
6️⃣ How do you create Hotspot fields in an Interactive Report?
Use WRITE statement with HOTSPOT option.
Example:
7️⃣ What is the difference between Classical and Interactive Reports?
Classical reports show only one list, while Interactive Reports allow drilldown lists using events like AT LINE-SELECTION and HIDE.
8️⃣ What is the ON HELP-REQUEST event used for?
It triggers when F1 help is pressed, allowing dynamic help for input fields or list contents.
9️⃣ How do you display a secondary list?
By writing statements inside the AT LINE-SELECTION event:
🔟 Can ALV Reports be Interactive?
Yes, ALV Grid and OO ALV support interactive features like double-click events using user commands (sy-ucomm).
Comments
Post a Comment