‎2007 Jul 18 5:56 AM
Hi all,
I am learning interactive report . i want to know how to use AT LINE SELECTION and a sample program using that.
Thanking u all.
regards,
Karan
‎2007 Jul 18 5:58 AM
Hi,
AT LINE-SELECTION is to capture the events that a user does on the LIST output.
So you can use CASE ENDCASE on sy-lsind to work on different levels of the list.
when sy-lsind = 1 its basic list.
then sy-lsind > 1 are called detail lists.
the example is
REPORT demo_at_line_selection.
START-OF-SELECTION.
WRITE 'Click me!' COLOR = 5 HOTSPOT.
AT LINE-SELECTION.
WRITE: / 'You clicked list', sy-listi,
/ 'You are on list', sy-lsind.
IF sy-lsind < 20.
SKIP.
WRITE: 'More ...' COLOR = 5 HOTSPOT.
ENDIF.
<b>Also goto ABAPDOCU transaction and check
BC-ABAP Programing ->ABAP user Dialogs ->Lists-> User Actions on Lists.</b>
Regards,
Sesh
‎2007 Jul 18 5:58 AM
Hi,
AT LINE-SELECTION is to capture the events that a user does on the LIST output.
So you can use CASE ENDCASE on sy-lsind to work on different levels of the list.
when sy-lsind = 1 its basic list.
then sy-lsind > 1 are called detail lists.
the example is
REPORT demo_at_line_selection.
START-OF-SELECTION.
WRITE 'Click me!' COLOR = 5 HOTSPOT.
AT LINE-SELECTION.
WRITE: / 'You clicked list', sy-listi,
/ 'You are on list', sy-lsind.
IF sy-lsind < 20.
SKIP.
WRITE: 'More ...' COLOR = 5 HOTSPOT.
ENDIF.
<b>Also goto ABAPDOCU transaction and check
BC-ABAP Programing ->ABAP user Dialogs ->Lists-> User Actions on Lists.</b>
Regards,
Sesh
‎2007 Jul 18 5:59 AM
‎2007 Jul 18 5:59 AM
hi,
Check this code
*-----Tables declaration
TABLES:EKKO. "PO Header
*-----Data Declaration
INITIALIZATION.
TYPES:BEGIN OF X_EKKO,
EBELN TYPE EKKO-EBELN, "PO Number
BUKRS TYPE EKKO-BUKRS, "Company code
BSART TYPE EKKO-BSART, "Document type
LIFNR TYPE EKKO-LIFNR, "Vendor
SPRAS TYPE EKKO-SPRAS, "Language key
ZTERM TYPE EKKO-ZTERM, "Terms of payment
END OF X_EKKO,
BEGIN OF X_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP, "PO Item
WERKS TYPE EKPO-WERKS, "Plant
MATNR TYPE EKPO-MATNR, "Material Number
MATKL TYPE EKPO-MATKL, "Material Group
END OF X_EKPO.
DATA:IT_EKKO TYPE TABLE OF X_EKKO,
WA_EKKO TYPE X_EKKO,
IT_EKPO TYPE TABLE OF X_EKPO,
WA_EKPO TYPE X_EKPO,
V TYPE EKKO-EBELN.
*-----Selection-screen design
SELECTION-SCREEN BEGIN OF BLOCK B1.
SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
*-----Selection-screen validation
AT SELECTION-SCREEN.
*-----retrieving data from the PO Header
SELECT EBELN
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
*-----if there are no records display an error
IF SY-SUBRC NE 0.
MESSAGE E009.
ENDIF.
*-----Data retrieval
START-OF-SELECTION.
*-----To retrieve the header information
SELECT EBELN BUKRS BSART LIFNR SPRAS ZTERM
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN
AND SPRAS = 'EN'.
*-----Top-of-page
TOP-OF-PAGE.
WRITE:/30 TEXT-012.
ULINE (100).
*-----Top-of-page for the secondary list
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE:/30 TEXT-013.
SKIP.
ULINE (80).
*-----Displaying the data
END-OF-SELECTION.
WRITE:/01 SY-VLINE,02 TEXT-001,
19 SY-VLINE,20 TEXT-002,
32 SY-VLINE,33 TEXT-003,
57 SY-VLINE,58 TEXT-004,
70 SY-VLINE,71 TEXT-005,
91 SY-VLINE,92 TEXT-006,
100 SY-VLINE.
ULINE (100).
LOOP AT IT_EKKO INTO WA_EKKO.
WRITE:/01 SY-VLINE,02 WA_EKKO-EBELN,
19 SY-VLINE,20 WA_EKKO-BUKRS,
32 SY-VLINE,33 WA_EKKO-BSART,
57 SY-VLINE,58 WA_EKKO-LIFNR,
70 SY-VLINE,71 WA_EKKO-SPRAS,
91 SY-VLINE,92 WA_EKKO-ZTERM,
100 SY-VLINE.
ULINE (100).
ENDLOOP.
*-----To get the secondary list.
AT LINE-SELECTION.
GET CURSOR FIELD WA_EKKO-EBELN VALUE V.
*-----To retrieve the item information
SELECT EBELN EBELP WERKS MATNR MATKL
FROM EKPO
INTO TABLE IT_EKPO
WHERE EBELN = V.
*-----To display an error if the user clicks on any other header detail
IF SY-SUBRC NE 0.
MESSAGE E001.
ENDIF.
WRITE:/01 SY-VLINE,02 TEXT-007,
19 SY-VLINE,20 TEXT-008,
42 SY-VLINE,43 TEXT-009,
48 SY-VLINE,49 TEXT-010,
67 SY-VLINE,68 TEXT-011,
80 SY-VLINE.
ULINE (80).
LOOP AT IT_EKPO INTO WA_EKPO.
WRITE:/01 SY-VLINE,02 WA_EKPO-EBELN,
19 SY-VLINE,20 WA_EKPO-EBELP,
42 SY-VLINE,43 WA_EKPO-WERKS,
48 SY-VLINE,49 WA_EKPO-MATNR,
67 SY-VLINE,68 WA_EKPO-MATKL,
80 SY-VLINE.
ULINE (80).
ENDLOOP.
‎2007 Jul 18 6:01 AM
Hi,
Sample report for INTERACTIVE report.
REPORT YMS_INTERACTIVETEST LINE-SIZE 50 NO STANDARD PAGE HEADING.
TABLES: VBAP,KNA1,VBAK.
SELECT-OPTIONS: CUST FOR KNA1-KUNNR.
DATA: BEGIN OF ITAB OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
VBELN LIKE VBAK-VBELN,
AUDAT LIKE VBAK-AUDAT,
AUART LIKE VBAK-AUART,
POSNR LIKE VBAP-POSNR,
POSAR LIKE VBAP-POSAR,
END OF ITAB.
DATA: ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE.
INITIALIZATION.
START-OF-SELECTION.
SELECT KNA1KUNNR KNA1NAME1 INTO CORRESPONDING FIELDS OF TABLE ITAB1
FROM KNA1 WHERE KNA1~KUNNR IN CUST.
LOOP AT ITAB1.
WRITE:/10 ITAB1-KUNNR HOTSPOT, 30 ITAB1-NAME1.
HIDE: ITAB1-KUNNR.
ENDLOOP.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
SELECT KNA1KUNNR VBAKVBELN VBAKAUDAT VBAKERDAT INTO CORRESPONDING FIELDS OF TABLE ITAB1
FROM KNA1 INNER JOIN VBAK ON KNA1KUNNR = VBAKKUNNR.
LOOP AT ITAB1.
WRITE:/ ITAB1-VBELN HOTSPOT, ITAB1-AUDAT, ITAB1-AUART.
HIDE: ITAB1-VBELN, ITAB1-AUDAT, ITAB1-AUART.
ENDLOOP.
WHEN '2'.
SELECT VBAKVBELN VBAPPOSNR VBAP~POSAR
INTO CORRESPONDING FIELDS OF TABLE ITAB1 FROM VBAK INNER JOIN VBAP ON VBAKVBELN = VBAPVBELN.
LOOP AT ITAB1.
WRITE:/ ITAB1-POSNR, ITAB1-POSAR.
ENDLOOP.
ENDCASE.
TOP-OF-PAGE.
WRITE:/ SY-VLINE,TEXT-001 COLOR COL_NEGATIVE.
ULINE.
Thanks,
Sankar M
‎2007 Jul 18 6:02 AM
hi,
Find the simple code here.
report zineractive no standard page heading.
start-of-selection.
set pf-status'XYZ'.
write 'basic list'.
top-of-page.
write 'list 0'.
AT LINE-SELECTION.
CASE sy-lsind.
WHEN '1'.
WRITE 'first secondary list'.
WHEN '2'.
WRITE 'second secondary list'.
ENDCASE.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: 'list', sy-lisel.
regards,
praveen
‎2007 Jul 18 6:03 AM
&----
*& Report ZAK_IR_AS16 *
*& *
&----
*& *
*& Interactive Report to check the number of secondary lists *
&----
REPORT ZAK_IR_AS16.
WRITE 😕 'LIST INDEX DURING BASIC LIST- ', SY-LSIND.
AT LINE-SELECTION.
WRITE 😕 'LIST INDEX DURING LINE SELECTION (SECONDARY LIST)- ', SY-LSIND.
‎2007 Jul 18 6:05 AM
Hi ,
check it out.
When the system processes event blocks that are not assigned to interactive list events, and when processing dialog modules, the ABAP program writes its list output to the basic list.
The ABAP system field SY-LSIND contains the index of the list currently being created. While the basic list is being created, SY-LSIND is zero.
By default, the basic list has a standard list status and a standard page header. The TOP-OF-PAGE and END-OF-PAGE events can occur while the basic list is being created. All output in these events is placed in the page header or footer of the basic list. In executable programs, the basic list is automatically sent to the list processor and displayed at the end of the END-OF-SELECTION event. Otherwise, it is displayed after the PAI processing block on the screen from which the LEAVE TO LIST-PROCESSING statement occurred.
Creating Detail Lists
Each time the user executes an action on a list, the runtime environment checks whether there is an event block defined that corresponds to the function code. If there is, SY-LSIND is automatically increased by one, and the relevant event block is executed. Any list output arising during this event block places its data into a new list (list level) with the index SY-LSIND. In order to create a new list level, the GUI status of the basic list must allow user actions, and the relevant event blocks must be defined in the program.
All lists created during an interactive list event are detail lists. Each interactive list event creates a new detail list. With one ABAP program, you can maintain one basic list and up to 20 detail lists. If the user creates a list on the next level (that is, SY-LSIND increases), the system stores the previous list and displays the new one. The user can interact with whichever list is currently displayed.
The system displays this list after processing the entire processing block of the event keyword or after leaving the processing block due to EXIT or CHECK. By default, the new list overlays the previous list completely. However, you can display a list in a dialog box. If no other dialog status is set in the event block for the detail list, the system uses the status from the previous list level. However, there is no standard page header for detail lists (see below).
Consequences of Event Control
The fact that you program detail lists in event blocks has important consequences. You cannot nest processing blocks (see Structure of an ABAP Program). Therefore, you cannot process other events within the processing blocks of interactive lists.
Especially, you cannot
use separate processing blocks to process further interactive events. A certain user action always triggers the same processing block in your program. You must use control statements (IF, CASE) within the processing block to make sure that the system processes the desired statements. There is a range of system field that you can use for this.
use the event TOP-OF-PAGE to influence the list structure of secondary lists. To layout the page headers of the secondary lists, you must use the event TOP-OF-PAGE DURING LINE-SELECTION (see below). However, the system does process the event END-OF-PAGE in secondary lists.
use events such as GET and GET LATE to retrieve data for secondary lists, but must use SELECT statements. You can use the logical database assigned to the executable program (report) only for the basic list. If you want to use a logical database during interactive events, you must either call another executable program using SUMIT, or (better) call the logical database using a function module.
Navigating in Lists:
To return from a high list level to the next-lower level (SY-LSIND), the user can choose back from a detail list. The system releases the last list to have been displayed, and returns to the previous list level. The system deletes the contents of the released list.
To determine the list level in which the output from an event block will be displayed, you can change the value of the system fields SY-LSIND. This is one of the few exceptions to the rule that states that you must never overwrite ABAP system fields. The system accepts only index values which correspond to existing list levels. It then deletes all existing list levels whose index is greater or equal to the index you specify. For example, if you set SY-LSIND to 0, the system deletes all secondary lists and overwrites the basic list with the current secondary list.
When you change SY-LSIND, the change only takes effect at the end of the corresponding event. If you work with statements that access the list with index SY-LSIND (using the INDEX addition - for example, SCROLL), you should set the new value of SY-LISND after these statements. The best place to set it is in the last statement of the event block.
System Fields for Details Lists
After each user action on a list, the following ABAP system fields will be set in the corresponding event block:
System field
SY-LSIND Index of the list created during the current event (basic list = 0)SY-LISTI Index of the list level from which the event was triggered
SY-LILLI Absolute number of the line from which the event was triggered
SY-LISEL Contents of the line from which the event was triggered
SY-CUROW Position of the line in the window from which the event was triggered (counting starts with 1)
SY-CUCOL Position of the column in the window from which the event was triggered (counting starts with 2)
SY-CPAGE Page number of the first displayed page of the list from which the event was triggered
SY-STARO Number of the first line of the first page displayed of the list from which the event was triggered (counting starts with 1). This line may contain the page header.
SY-STACO Number of the first column displayed in the list from which the event was triggered (counting starts with 1)
SY-UCOMM Function code that triggered the event
SY-PFKEY Status of the list currently being displayed.
Page Headers for Detail Lists
On detail lists, the system does not display a standard page header and it does not trigger the event TOP-OF-PAGE. To create page headers for detail list, you must use a different TOP-OF-PAGE event:
TOP-OF-PAGE DURING LINE-SELECTION.
The system triggers this event for each detail list. If you want to create different page headers for different list levels, you must program the processing block of this event accordingly, for example by using system fields such as SY-LSIND or SY-PFKEY in control statements (IF, CASE).
As on the basic list, the page header of a detail list remains displayed even when you scroll vertically.
Messages on Detail Lists
ABAP allows you to react to incorrect or possibly-incorrect user input by displaying messages. The seriousness of the error determines how program processing continues.
In list processing, the message processing for the individual message types is as follows:
A (=Abend): Termination
The system displays the message in a dialog box. After the user confirms the message using ENTER , the system terminates the entire transaction (for example SE38).
E (=Error) or W (=Warning):
The system displays the message in the status bar. Once the user has confirmed the error by pressing ENTER, the current event block is terminated and the previous list level remains displayed. If you use an error or warning message while creating the basic list, the entire program is terminated.
I (=Information):
The system displays the message in a dialog box. Once the user has confirmed the message (ENTER), the program continues processing after the MESSAGE statement.
S (= status)
The system displays the message in the status bar of the current list.
X (= Exit) Runtime error:
This message type triggers a runtime error and generates a short dump.
Using Detail Lists
A classic report is a program that generates a single list, which must contain all of the required detail information. This procedure may result in extensive lists from which the user has to pick the relevant data. For background processing, this is the only possible method. After starting a background job, there is no way of influencing the program. The desired selections must be made beforehand and the list must provide detailed information.
For dialog sessions, there are no such restrictions. The user is present during the execution of the program and can control and manipulate the program flow directly. To be able to use all advantages of the online environment, classical reporting was developed into interactive reporting.
Interactive reporting allows the user to participate actively in retrieving and presenting data during the session. Instead of one extensive and detailed list, with interactive reporting you create a condensed basic list from which the user can call detailed information by positioning the cursor and entering commands. Interactive reporting thus reduces information retrieval to the data actually required. Detailed information is presented in detail lists.
Apart from creating detail lists, interactive reporting also allows you to call transactions or other executable programs (reports) from lists. These programs then use values displayed in the list as input values. The user can, for example, call a transaction from within a list to change the database table whose data is displayed in the list.
AT LINE-SELECTION : This Event triggers when we double click a line on the list, when the event is triggered a new sublist is going to be generated. Under this event what ever the statements that are been return will be displayed on newly generated sublist.
<code>
***********************************************************************
Title : Purchase Order Listing REPORT *
Author : *
Date of Creation : *
***********************************************************************
Modification Log *
Author : *
Date of Change : *
Functional Specs # : *
Correction Request # : *
Description of Change : *
***********************************************************************
REPORT ZEXAMPLE_PO_LISTING NO STANDARD PAGE HEADING
LINE-SIZE 160
LINE-COUNT 30(1)
MESSAGE-ID Z00.
----
T A B L E S *
----
TABLES : EKKO, "Purchasing Document Header
EKPO, "Purchasing Document Item
LFA1, "Vendor Master (General Section)
SSCRFIELDS. "Fields on selection screens
----
INTERNAL TABLES *
----
DATA: BEGIN OF ITAB OCCURS 0,
EBELN LIKE EKKO-EBELN,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
AEDAT LIKE EKKO-AEDAT,
WAERS LIKE EKKO-WAERS,
END OF ITAB.
DATA: BEGIN OF ITAB2 OCCURS 0,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
TXZ01 LIKE EKPO-TXZ01,
EMATN LIKE EKPO-EMATN,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF ITAB2.
----
D A T A D E C L A R A T I O N S *
----
DATA: DATE LIKE SY-DATUM.
DATE = SY-DATUM.
----
S E L E C T I O N S C R E E N *
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
SELECT-OPTIONS S_AEDAT FOR EKKO-AEDAT.
SELECTION-SCREEN END OF BLOCK B1.
----
AT-S E L E C T I O N S C R E E N *
----
*PURCHASE ORDER SCREEN VALIDATION
AT SELECTION-SCREEN ON S_EBELN.
CHECK SSCRFIELDS-UCOMM = 'ONLI'.
IF NOT S_EBELN[] IS INITIAL.
SELECT SINGLE EBELN FROM EKKO INTO EKKO WHERE EBELN IN S_EBELN.
ELSE.
MESSAGE E010 WITH 'Purchase Order Not Found'.
ENDIF.
----
I N I T I A L I Z A T I O N *
----
INITIALIZATION.
----
S T A R T - O F - S E L E C T I O N *
----
START-OF-SELECTION.
PERFORM FETCH_RECORDS.
----
E N D - O F - S E L E C T I O N *
----
END-OF-SELECTION.
LOOP AT ITAB.
WRITE:/ SY-VLINE, ITAB-EBELN,11 SY-VLINE,
12 ITAB-LIFNR, SY-VLINE,
30 ITAB-NAME1,42 SY-VLINE,
47 ITAB-AEDAT,SY-VLINE,
65 ITAB-WAERS,77 SY-VLINE .
HIDE ITAB-EBELN.
ULINE /(77).
ENDLOOP.
----
TOP-OF-PAGE *
----
TOP-OF-PAGE.
PERFORM DISPLAY_PAGE_HEADER.
----
END-OF-PAGE *
----
END-OF-PAGE.
----
AT LINE-SELECTION *
----
AT LINE-SELECTION.
IF SY-LSIND EQ 1.
SELECT EBELN
EBELP
TXZ01
EMATN
MENGE
MEINS
NETPR
FROM EKPO INTO TABLE ITAB2
WHERE EBELN EQ ITAB-EBELN.
ENDIF.
IF SY-SUBRC <> 0.
MESSAGE I010 WITH 'NO ITEMS FOUND FOR THIS PO'.
ELSE.
PERFORM FETCH_PO_DETAILS.
ENDIF.
*----
TOP-OF-PAGE DURING LINE-SELECTION.
*----
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM GENERATE_SECONDARY_LIST_HEADER.
&----
*& Form Validate_outer
&----
text
----
--> p1 text
<-- p2 text
----
FORM FETCH_RECORDS.
SELECT A~EBELN
A~AEDAT
A~WAERS
A~LIFNR
B~LIFNR
B~NAME1
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM EKKO AS A
INNER JOIN LFA1 AS B
ON ALIFNR = BLIFNR
WHERE A~EBELN IN S_EBELN.
IF SY-SUBRC NE 0.
MESSAGE E010(Z00) WITH 'Valid Data not Found'(001).
ENDIF.
ENDFORM. " FETCH_RECORDS
*GETTING ALL THE DETAILS FROM EKPO ON A EBELN
FORM FETCH_PO_DETAILS.
LOOP AT ITAB2.
WRITE:/ SY-VLINE,
ITAB2-EBELN,
15 SY-VLINE,
ITAB2-EBELP,
30 SY-VLINE,
ITAB2-EMATN,
45 SY-VLINE,
ITAB2-TXZ01,
80 SY-VLINE,
ITAB2-MENGE UNIT 'PC' CENTERED,
95 SY-VLINE,
ITAB2-MEINS,
110 SY-VLINE,
ITAB2-NETPR CURRENCY 'USD',
125 SY-VLINE.
ULINE /(125).
AT END OF EBELN.
SUM.
WRITE:/97 'TOTAL VALUE:',112 ITAB2-NETPR CURRENCY 'USD'.
ENDAT.
ENDLOOP.
ENDFORM.
*GENERATING THE PAGE HEADER
FORM DISPLAY_PAGE_HEADER.
PERFORM COMPANY_HEADER.
FORMAT INTENSIFIED ON COLOR COL_KEY.
ULINE (77).
WRITE:/ SY-VLINE,
'P.ORDER NO',
11 SY-VLINE,
'VENDOR NO',
SY-VLINE,
30 'VENDOR NAME',
SY-VLINE,
50 'PO DATE',
SY-VLINE,
65 'CURRENCY KEY',
77 SY-VLINE.
ULINE /0(77).
FORMAT RESET.
ENDFORM.
&----
*& Form GENERATE_SECONDARY_LIST_HEADER
&----
text
----
--> p1 text
<-- p2 text
----
FORM GENERATE_SECONDARY_LIST_HEADER.
PERFORM COMPANY_HEADER_02.
FORMAT INTENSIFIED ON COLOR COL_KEY.
ULINE (125).
WRITE:/ SY-VLINE,
'P.O.No',
15 SY-VLINE,
'Item No',
30 SY-VLINE,
'Material',
45 SY-VLINE,
'Material Desc',
80 SY-VLINE,
'Order Qty',
95 SY-VLINE,
'Order Unit',
110 SY-VLINE,
'Net Price',
125 SY-VLINE.
ULINE (125).
ENDFORM. " GENERATE_SECONDARY_LIST_HEADER
&----
*& Form COMPANY_HEADER
&----
text
----
--> p1 text
<-- p2 text
----
FORM COMPANY_HEADER.
WRITE:/40 ' INDIA IS GR8'.
WRITE:/40 ' India '.
WRITE:/40 'Purchase Order Header Listing'.
SKIP.
ENDFORM. " COMPANY_HEADER
&----
*& Form COMPANY_HEADER_02
&----
text
----
--> p1 text
<-- p2 text
----
FORM COMPANY_HEADER_02.
WRITE:/40 ' India is gr8'.
WRITE:/40 ' India '.
WRITE:/40 'Purchase Order Items Listing'.
SKIP.
ENDFORM. " COMPANY_HEADER_02
</code>
Reward if u find helpful.
Thanks & Regards,
Rajesh