ABAP Event Magic: Navigating Interactive Classical Reports for Dynamic Displays
Welcome back everyone, We were discussing about Interactive Classical Report events, So, let’s continue it.
System Variables in Interactive Classical Report Events :-
- SY-LISEL :- It is a system variable which returns the contents of the selected line.
- SY-LSIND :- It is a system variable which returns the index of the displayed list.
Interactive Classical Report Events :-
1. At Line-Selection :-
- When user double clicks on the line or select a line and press F2 or select a line and click choose at that time at line-selection event triggers.
Suppose, user double click on the below line :-
Then the output should be showing the respective line items for the respective header items in a new page :-
Note :-
- F2 is the shortcut key for double click.
- It is a reserve key by SAP used for double click purpose.
Let’s take a requirement to understand the At Line Selection event.
Requirement :-
- Let’s use our order header and order item table, which we have been using so bar.
- So, I want a order number on the selection screen and when I press the execute button, It should be showing the header items and when I double click on a particular header items, It must be showing me line items.
Solution :-
-
Step 1 :- Create a executable program in SE38 ( ABAP Editor ).
-
Step 2 :- Create a type structure for order header table and also create internal table and work area.
-
Step 3 :- Declare a select option for order number.
-
Step 4 :- Write a select query to fetch data from database table into the internal table and then display the data from the internal table using loop statements.
-
Step 5 :- Create a structure, internal table and work area for the item table.
-
Step 6 :- Write a select query below the loop statements to fetch data from the item table based on SY-LISEL because it contain the selected line.
Note :- Here SY-LISEL will contain the entire selected line,
so we need to fetch only our order number from it.
-
Step 7 :- Use loop on internal table of item to display the data.
Code :-
*************************************************************
*Start of Program
*Declaring Strcutrure for header
TYPES: BEGIN OF ty_header,
order_number TYPE zar_order_number,
order_date TYPE zar_order_date,
payment_mode TYPE zar_payment_mode,
currency TYPE zar_curency,
END OF ty_header.
*********************
*Internal table and Work Area
DATA : lt_header TYPE TABLE OF ty_header,
ls_header TYPE ty_header.
****************
*Declaring Strcuture for item table
TYPES: BEGIN OF ty_item,
order_number TYPE zar_order_number,
order_item_number TYPE zar_order_item_number,
item_cost TYPE zar_total_amount,
END OF ty_item.
************************************
*Declaring internal table and work area
DATA : lt_item TYPE TABLE OF ty_item,
ls_item TYPE ty_item.
*******************************
*Select option Declaration
DATA : lv_order TYPE zar_order_number.
SELECT-OPTIONS : s_order FOR lv_order.
*********************************
*Writing a select query for header
START-OF-SELECTION.
SELECT order_number order_date
payment_mode currency
FROM zar_header INTO
TABLE lt_header
WHERE order_number IN s_order.
***************************************
*Displaying the data
LOOP AT lt_header INTO ls_header.
WRITE :/ ls_header-order_number,
ls_header-order_date,
ls_header-payment_mode,
ls_header-currency.
ENDLOOP.
*********************************
AT LINE-SELECTION.
SELECT order_number
order_item_number
item_cost FROM zar_item
INTO TABLE lt_item
WHERE order_number = sy-lisel+0(12).
IF lt_item IS NOT INITIAL.
****************************
*LOOP on item
LOOP AT lt_item INTO ls_item.
WRITE :/ ls_item-order_number,
ls_item-order_item_number,
ls_item-item_cost.
ENDLOOP.
ENDIF.
********************************************
*End of Program
**************************************************************
Execute the Program :-
Header details :-
- Now, double click on the second record
Item Details :-
So, that’s enough for today.
We will continue with Interactive Classical Report statements in the next blog.
Thanx a lot for being a part of this wonderful journey.
Comments
Post a Comment