Wednesday, May 8, 2013

ABAP Interactive Report


Introduction:

When an ABAP report (Type 1) is executed, the program context and memory space variables are made available on the application server. The subsequent program flow is controlled by the ABAP runtime system. If the program contains a selection screen, the ABAP runtime system sends it to the presentation server at the start of the program.

When the user executes the report after entering selection fields, the data entered on the selection screen is automatically placed in the corresponding data objects. The ABAP runtime system takes over control of the program. Then the program sends information to the database about the records that should be read. The database returns the required database records and the runtime system ensures that the data is placed in the relevant data objects.

The list output is also programmed in the processing block. After the processing block finishes, the runtime system sends the list as a screen to the presentation server. The events START-OF-SELECTION, GET, END-OF-SELECTION, TOP-OF-PAGE and END-OFPAGE can be used only to create basic lists.

·         To create detail lists, use the events AT LINE-SELECTION or AT USER-COMMAND. We use   TOP-OF-PAGE DURING LINE-SELECTION for page headers on detail lists.
·         Each detail list event exists only once in the program and is shared by all detail lists. You must therefore ensure yourself, within the processing block, that the correct list is created. 
·         To do this, use a CASE structure that uses the system field sy-lsind. This system field contains the list index of the list that you are currently generating.
·         Use the statement HIDE global field to store the contents of the global data field
global_field for the current line.
·         If the user selects the line, the data field is automatically filled with the value that you retained for the line.
·         You do not have to display the field on the list in order to retain its value using HIDE.
·         The field can be a structure. However, deep structures (structures containing internal tables as components) are not supported.
·         When the user selects a line on an interactive list, all of the global data fields whose values you stored using the HIDE statement while you were creating the basic list are filled with those values.
·         The line selection is based on the cursor position when the AT LINE-SELECTION and AT USERCOMMAND events occur. (System field sy-lilli).
·         GET CURSOR gets the cursor position on a screen or in an interactive list event.  
Syntax : GET CURSOR FIELD [OFFSET ] [LINE ][VALUE ] [LENGTH ].      GET CURSOR LINE [OFFSET ] [VALUE ] [LENGTH ].
At a user action on a list or screen, the statement writes the position, value,  and displayed length of a field or line into the corresponding variables.
·         If you choose a line using the READ LINE... statement, the values are placed back in the original fields according to the line numbers.
·         To check whether the user selected a valid line, you can use the fact that the hide area only contains data for valid lines. When you have finished creating the list, initialize a suitable test field. 
·         This allows you to check before you create the detail list whether a value from the hide area has been placed in the test field.
·         Once you have created the detail list, re-initialize the test field to ensure that the user cannot choose an invalid line once he or she returns from the detail list and attempts to select another line for a new detail list.

An interactive report generally works in the following fashion:
1. Basic list is displayed.
2. User double clicks on any valid line
    or
    User selects a line and presses as button on the tool bar.
3. The corresponding event is triggered
4. Then in the code, the line on which action was done, is read.
5. Depending on the values in that selected line, a secondary list is displayed.
6. Steps from 2-5 are repeated till the end.

We can generate 19 secondary list of output. Hence a total of 20 output screen (1 Primary + 19 Secondary) can be generated by Interactive program.


Please find the example below :



2 comments: