Vous êtes sur la page 1sur 25

INTERACTIVE REPORTS

ABAP/4 allows you to create interactive lists. On an interactive list on the screen, the
user can select lines, type input, and enter commands using function keys, menu bars, or
pushbuttons. Interactive lists enhance the classical type of output list with dialog
functionality, thus coming close to dialog programming. Interactive lists provide the user
with the so-called "interactive reporting" facility.
The subsequent topics describe
What is Interactive Reporting?
Event Control for Interactive Lists
Basic Lists and Secondary Lists
User Interfaces of Interactive Lists
Passing Data from List to Report
Manipulating Interactive Lists
Calling Programs
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
A classical non-interactive report consists of one program that creates a single list. This
means that after the report was startet, the list it creates has to contain all data requested,
regardless of the number of details the user wants to see. 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
report 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
developped 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 secondary lists. A secondary list may either overlay
the basic list completely or appear in an additional dialog window on the same screen.
The secondary list can itself be interactive again.
Apart from creating secondary lists, interactive reporting also allows you to call
transactions or other 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.

This section describes how to program lists for dialogs and explains the ABAP/4
statements you can use to call reports and transactions and to pass data between the
different components.
For an example showing the main features of interactive reporting, see The HIDE
Technique.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
ABAP/4 programs are controlled by event keywords (see Concept of Flow Control in
ABAP/4). And event keywords are what you need to use lists interactively.
Events for Interactive Lists
The following events are specific for the context of interactive lists:

AT LINE-SELECTION
AT PF<nn>
AT USER-COMMAND

If you define a processing block for one of these events in your program, the program can
react on certain user actions. If the user then executes a defined action on the displayed
list, the system triggers the corresponding event. The system writes the output of all
output statements programmed in the processing blocks of one of the above events to a
so-called secondary list. For more information on secondary lists, see Basic Lists and
Secondary Lists.

Actions on Interactive Lists


An action that the user can execute on the list and that triggers a certain event, must be
determined in the list's interface definition. You can define an individual interface for
each of your lists. By default, the events occur after the following actions on lists:

AT LINE-SELECTION occurs after the user double-clicks on a line, clicks once


on a hotspot, or chooses Edit Choose.

AT PF<nn> occurs after the user presses the corresponding function key.

AT USER-COMMAND occurs after the user chooses a self-defined action.


For more information on user actions and user interfaces, see User Interfaces of
Interactive Lists.
Consequences from Event Control
The fact that you use event keywords to program interactive lists, has the following
inportant consequences: As described in Controlling the Flow of ABAP/4 Programs by
Events, you cannot nest processing blocks, since each new event keyword terminates the
previous processing block. Therefore, you cannot process other events within the
processing blocks of interactive lists.
Especially, you cannot

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 report
only for the basic list. If you want to use logical databases during interactive events, you
must call an independent report using SUBMIT (see Calling Programs )

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 Page Headers for Secondary Lists). However, the
system processes the event END-OF-PAGE also on secondary lists.

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. Several system fields help you in this context (see
System Fields for Secondary Lists).
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Creating the Basic List
An ABAP/4 program places the output data created while processing the events related to
data retrieval (START-OF-SELECTION, GET, and so on) into the so-called basic list.
By default, a basic list has a standard page header (see Standard Page Header). If, while
creating the basic list, the events TOP-OF-PAGE and END-OF-PAGE occur, the system

writes all subsequent output into the page header or page footer of the basic list. After
processing all events related to data retrieval, the system displays the basic list on the
output screen.
The SY-LSIND system field contains the index of the list currently created. While
creating a basic list, SY-LSIND equals 0.
For examples for basic lists, see Creating Lists.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Creating Secondary Lists
A list is an interactive list if the user interface allows actions that trigger events and if the
corresponding interactive event keywords occur in the report (see Event Control for
Interactive Lists). All output statements executed during an interactive list event write
their data into a new list (list level) with the index SY-LSIND.
Each time an interactive list event occurs, the system automatically increases SY-LSIND
by 1.
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. If you want to program a window that
overlays only part of the previous list, see Displaying Lists in Dialog Windows.
All lists created during an interactive list event are secondary lists.
Each interactive list event creates a new secondary list. With one ABAP/4 report, you can
maintain one basic list and up to 20 secondary 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. Only one list is active, and that is always the most recently created list. To
delete existing lists, see Maintaining Lists.
For secondary lists, the system does not display a standard page header. To create page
headers for secondary lists, see Page Headers for Secondary Lists.
REPORT SUNIL1.
WRITE: 'Basic List, SY-LSIND =', SY-LSIND.
AT LINE-SELECTION.
WRITE: 'Secondary List, SY-LSIND =', SY-LSIND.
After executing the program, the system displays the following basic list:

If you compare the toolbar to the standard toolbar of User Interface of the Standard List,
you find no difference. Nevertheless, the effect of the event keyword AT LINESELECTION is that after positioning the cursor on a line, this event is triggered by
choosing Edit Choose, double-clicking with the mouse, or pressing the function key F2
(see Allowing Line Selection). Therefore, the list is interactive and after such an action
by the user, the output screen changes:

The first secondary list overlays the basic list. This list has no standard page header. It is
an interactive list again. By choosing Choose, the user can now create up to 20 of these
lists. Trying to produce more than 20 lists results in a runtime error.

Using Back , the user can return to previous lists. For more information on returning to
previous lists, see Maintaining Lists.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Maintaining Lists
To return from a high list level to the next-lower level (SY-LSIND), the user chooses
Back on a secondary list. The system then releases the currently displayed list and
activates the list created one step earlier. The system deletes the contents of the released
list.
To explicitly specify the list level into which you want to place output, set the SY-LSIND
field. 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.

The system reacts to a manipulation of SY-LSIND only at the end of an event, directly
before displaying the secondary list. So, if within the processing block you use statements
whose INDEX options access the list with the index SY-LSIND (such as SCROLL),
make sure that you manipulate the SY-LSIND field only after processing these
statements. The best way to avoid unintentional confusion is to always enter the
statement that manipulate SY-LSIND as the last statement of the processing block.
REPORT SUNIL1.
WRITE: 'Basic List, SY-LSIND =', SY-LSIND.
AT LINE-SELECTION.
IF SY-LSIND = 3.
SY-LSIND = 0.
ENDIF.
WRITE: 'Secondary List, SY-LSIND =', SY-LSIND.
After executing the program, the system displays the basic list that contains the following
line:
Basic List, SY-LSIND = 0
Due to the AT LINE-SELECTION statement, the list is interactive and enables the user
action Choose (see Allowing Line Selection). If the user positions the cursor on the list
line and chooses Choose to trigger the AT LINE-SELECTION event, the system displays
a secondary list that contains the following line:
Secondary List, SY-LSIND = 1
Choosing Choose again produces:
Secondary List, SY-LSIND = 2
Goto Back leads to the previous list level. Choosing Choose for the third time produces
a secondary list that, due to the IF condition, contains the following line:
Secondary List, SY-LSIND = 0
The system deletes the list levels 1 and 2. If you choose Goto Back now, you return to
the screen from which you started the report. If you choose Choose, the system creates a
secondary list with index 1. However, the list on level 0 is no longer a basic list (no page
header), but a secondary list as well.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
System Fields for Secondary Lists
With each interactive event, the system automatically sets the following system fields:
System field
SY-LSIND
SY-LISTI
SY-LILLI
SY-LISEL

Information
Index of the list created during the current event (basic list = 0)
Index of the list level from which the event was triggered
Absolute number of the line from which the event was triggered
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). Possibly, a page header occupies this
line.
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 displayed list
The system fields SY-UCOMM and SY-PFKEY are important if you use self-defined list
interfaces (see Defining Individual User Interfaces).
You can use the information contained in the system fields listed above to structure the
secondary lists. For more information and an example, see Passing Data Automatically.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Page Headers for Secondary Lists
On secondary 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 secondary list, you must
enhance TOP-OF-PAGE:
Syntax
TOP-OF-PAGE DURING LINE-SELECTION.
The system triggers this event for each secondary 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).
When the user scrolls vertically through secondary lists, the page header remains and
only the list lines beneath the header scroll.
REPORT SUNIL1.
WRITE 'Basic List'.
AT LINE-SELECTION.
WRITE 'Secondary List'.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
WRITE 'First Secondary List'.
WHEN 2.

WRITE 'Second Secondary List'.


WHEN OTHERS.
WRITE: 'Secondary List, Level:', SY-LSIND.
ENDCASE.
ULINE.
After the user executes the above program, the system displays a basic list resembling the
list from the example in Creating Secondary Lists. The user can choose Choose to create
secondary lists. The secondary list of list level 1 looks as follows:

The secondary list of list level 3 looks like this:

Due to the CASE control statement within the TOP-OF-PAGE DURING LINESELECTION processing block, the system creates a different page header for each
secondary list.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Messages in Lists
ABAP/4 allows you to react to incorrect or doubtful user input by displaying messages
that influence the program flow depending on how serious the error was. Handling
messages is mainly a topic of dialog programming where it is described in detail (see
Handling Errors and Messages). This topic only explains the influence messages have on
interactive list processing.
You store and maintain messages in Table T100. Messages are sorted by language, by a
two-character ID, and by a three-digit number. You can assign different message types to
each message you output. The influence of a message on the program flow depends on
the message type.
In your program, use the MESSAGE statement to output messages statically or
dynamically and to determine the message type.
Use the MESSAGE-ID option of the REPORT or PROGRAM statement, if you want to
use messages of a certain ID statically in your program:
Syntax
REPORT <rep> MESSAGE-ID <id>.

Due to this statement, the report <rep> can use all messages stored in Table T100 under
the ID <id>. If you specify message IDs dynamically, you can omit this option.
To specify a message number and type statically, use:
Syntax
MESSAGE <c><num> [WITH <f1> ... <f4>].
This statement outputs the message stored in Table T100 under number <num>, that has
the same ID <id> as in the REPORT statement, as message type <c>.
To specify a message ID, type, and number dynamically at runtime, use:
Syntax
MESSAGE ID <id> TYPE <c> NUMBER <num> [WITH <f1> ... <f4>].
This statement outputs the message whose ID, number, and type are stored in the fields
<id>, <num>, and <c>. For this statement, you do not need the MESSAGE-ID option in
the REPORT statement.
A message can have five different types. These message types have the following effects
during list processing:

A (=Abend):

The system displays a message of this message type in a dialog window. 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 a message of this message type in the status line. After the user
chooses ENTER, the system acts as follows:
While creating the basic list, the system terminates the report.
While creating a secondary list, the system terminates the corresponding
processing block and keeps displaying the previous list level.

I (=Information):

The system displays a message of this message type in a dialog window. After the user
chooses ENTER, the system resumes processing at the current program position.

S (=Success):

The system displays a message of this message type on the output screen in the status line
of the currently created list.

Ampersand characters '&' serve as placeholders within a message. If you use the WITH
option, the system replaces the placeholders '&' in the message one after the other with
the contents of the fields <fi> and the numbered placeholders '&i' according to the
number. To output a '&' character in the message, you must write '&&'.
To create, display, or change messages, simply double-click on the ID <id> or the
message number in the ABAP/4 Editor. If the object does not yet exist, the system asks
you whether you want to create it.
You can easily include static MESSAGE statements into your program by choosing Edit
Insert statement... from the ABAP/4 Editor. Select MESSAGE as statement:
With this method, you can either copy existing messages or create a new object (ID and
number). In addition, the system includes the message text as comment into your
program.
Suppose, the following messages are stored in Table T100 under the ID HB:

The following program uses these messages:


REPORT SUNIL1 MESSAGE-ID HB NO STANDARD PAGE HEADING.
WRITE 'Basic List'.
MESSAGE S100.
AT LINE-SELECTION.
IF SY-LSIND = 1.
MESSAGE ID 'HB' TYPE 'I' NUMBER 100.
ENDIF.
IF SY-LSIND = 2.
MESSAGE E200 WITH SY-LSIND.
ENDIF.
WRITE: 'Secondary List, SY-LSIND:', SY-LSIND.
After executing the program, the system displays the basic list and the success message
100 in the status line. After selecting a line by double-clicking, the event AT LINESELECTION occurs. While the system creates the first secondary list, it displays a dialog
window with the information message 100. You cannot create the second secondary list,
because the message 200 has message type E:
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.

The two topics below describe the events AT LINE-SELECTION and AT PF<nn> in
connection with their predefined standard interfaces.
Allowing Line SelectionAllowing Function Key Selection

The AT USER-COMMAND event serves mainly to handle own function codes. In this
case, you should create an individual interface with the Menu Painter and define such
function codes. The following topic explains how to define individual interfaces and how
to use the AT USER-COMMAND event.
Defining Individual User Interfaces
You can also display lists in dialog windows instead of the fullscreen:
Displaying Lists in Dialog Windows
And you can trigger interactive events not only from the interface but also from within
the program:
Triggering Events from within the Program
The user interfaces described in this section apply to programs of type 1 (online program)
only. The system sets the interface accordingly and uses the list processor. Note that
programs for creating transactions use a different environment.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
To effectively use interactive lists for interactive reporting, it is not sufficient for the
program to react to events triggered by user actions on the output list. You must also be
able to interpret the lines selected by the user and their contents.
To do this, you use information that the interactive lists pass to the program. ABAP/4
provides three ways of passing data:

Passing data automatically using system fields

You use automatic data transfer mainly for auxiliary data that you need to better localize
user actions.

Using statements in the program to fetch data

You use program-controlled data transfer to transfer the contents of individual output
fields into the processing blocks of the interactive events and to continue processing with
these values.

Passing list attributes

If you do not save certain attributes of a list level, such as number of pages or lines per
page, while creating the list, you can lateron retrieve these data using the DESCRIBE
LIST statement.
The following topics describe these possibilities:
Passing Data Automatically
Passing Data by Program Statements
Passing List Attributes
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Passing Data Automatically
Automatic data transfer happens by means of the system fields that are filled by the
system for each interactive event. For an overview of the relevant system fields, see
System Fields for Secondary Lists.
The subsequent topics describe
Data from System Fields of Interactive Lists
Using SY-LISEL
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Data from System Fields of Interactive Lists
From system fields, you retrieve the following information: the index of a list, the
position of the list in the output window, and the location of the cursor. The only system
field that contains the contents of the selected line is SY-LISEL.
The example below demonstrates how the system fills these system fields during
interactive events.
REPORT SUNIL2 NO STANDARD PAGE HEADING
LINE-COUNT 12 LINE-SIZE 40.
DATA: L TYPE I, T TYPE C.
DO 100 TIMES.
WRITE: / 'Loop Pass:', SY-INDEX.
ENDDO.
TOP-OF-PAGE.
WRITE: 'Basic List, Page', SY-PAGNO.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.

WRITE 'Secondary List'.


ULINE.
AT LINE-SELECTION.
DESCRIBE FIELD SY-LISEL LENGTH L TYPE T.
WRITE: 'SY-LSIND:', SY-LSIND,
/ 'SY-LISTI:', SY-LISTI,
/ 'SY-LILLI:', SY-LILLI,
/ 'SY-CUROW:', SY-CUROW,
/ 'SY-CUCOL:', SY-CUCOL,
/ 'SY-CPAGE:', SY-CPAGE,
/ 'SY-STARO:', SY-STARO,
/ 'SY-LISEL:', 'Length =', L, 'Type =', T,
/ SY-LISEL.
This program creates a list of ten pages. After executing the program, the user should
scroll the list and position the cursor as shown below:

After choosing Select or F2, the secondary list looks like this:

SY-LSIND is the index of the current list, SY-LISTI is the index of the previous list. SYLILLI is the number of the selected line in the absolute list (nine times twelve lines for
the previous pages plus nine lines on the current page), SY-CUROW is the position of the
selected line on the screen. SY-CUCOL is the position of the cursor in the window. This
position exceeds the corresponding unscrolled list column by one. SY-CPAGE is the
currently displayed page of the list. SY-STARO is the number of the topmost actual list
line displayed on the current page. This does not include the page header. SY-CPAGE
and SY-STARO do not depend on the cursor position. For SY-LISEL, the program
displays length, data type, and contents. The length of SY-LISEL is always 255,
independent of the list's width.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.

Passing Data by Program Statements


To pass individual output fields or additional information from a line to the
corresponding processing block during an interactive event, use these statements:

HIDE

The HIDE statement is one of the fundamental statements for interactive reporting. Using
the HIDE technique, you can at the moment you create a list level define, which
information later to pass to the subsequent secondary lists.

READ LINE

Use the statements READ LINE and READ CURRENT LINE to explicitly read data
from the lines of existing list levels. These statements are tightly connected to the HIDE
technique.

GET CURSOR

Use the statements GET CURSOR FIELD and GET CURSOR LINE to pass the output
field or output line on which the cursor was positioned during the interactive event to the
processing block.
The following topics describe these statements:
The HIDE Technique
Reading Lines from Lists
Reading Lists at the Cursor Position
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
The HIDE Technique
You use the HIDE technique while creating a list level to store line-specific information
for later use.
Syntax
HIDE <f>.
This statement stores the contents of variable <f> in relation to the current output line
(system field SY-LINNO) internally in the so-called HIDE area. The variable <f> must
not necessarily appear on the current line.

To improve the readability of your program, place the HIDE statement always directly
after the output statement for the variable <f> or after the last output statement for the
current line. To hide several variables, concatenate several HIDE statements (see
Concatenating Similar Statements).
As soon as the user selects a line for which you stored HIDE fields, the system fills the
variables in the program with the values stored. A line can be selected

by an interactive event.

For each interactive event, the HIDE fields of the line on which the cursor is positioned
during the event are filled with the stored values.

by the READ LINE statement.

See Reading Lines from Lists.


You can think of the HIDE area as a table, in which the system stores the names and
values of all HIDE fields for each list and line number. As soon as they are needed, the
system reads the values from the table.
The example below presents some of the essential features of interactive reporting. The
basic list contains summarized information. By means of the HIDE technique, each
secondary list contains more details.
The following report is connected to the logical database F1S.
PROGRAM SUNIL1 NO STANDARD PAGE HEADING.
TABLES: SPFLI, SBOOK.
DATA: NUM TYPE I,
DAT TYPE D.
START-OF-SELECTION.
NUM = 0.
SET PF-STATUS 'FLIGHT'.
GET SPFLI.
NUM = NUM + 1.
WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM, SPFLI-CITYTO.
HIDE: SPFLI-CARRID, SPFLI-CONNID, NUM.
END-OF-SELECTION.
CLEAR NUM.
TOP-OF-PAGE.
WRITE 'List of Flights'.
ULINE.
WRITE 'CA CONN FROM
TO'.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.

CASE SY-PFKEY.
WHEN 'BOOKING'.
WRITE SY-LISEL.
ULINE.
WHEN 'WIND'.
WRITE: 'Booking', SBOOK-BOOKID,
/ 'Date ', SBOOK-FLDATE.
ULINE.
ENDCASE.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'SELE'.
IF NUM NE 0.
SET PF-STATUS 'BOOKING'.
CLEAR DAT.
SELECT * FROM SBOOK WHERE CARRID = SPFLI-CARRID
AND CONNID = SPFLI-CONNID.
IF SBOOK-FLDATE NE DAT.
DAT = SBOOK-FLDATE.
SKIP.
WRITE / SBOOK-FLDATE.
POSITION 16.
ELSE.
NEW-LINE.
POSITION 16.
ENDIF.
WRITE SBOOK-BOOKID.
HIDE: SBOOK-BOOKID, SBOOK-FLDATE, SBOOK-CUSTTYPE,
SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-CLASS.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE / 'No bookings for this flight'.
ENDIF.
NUM = 0.
CLEAR SBOOK-BOOKID.
ENDIF.
WHEN 'INFO'.
IF NOT SBOOK-BOOKID IS INITIAL.
SET PF-STATUS 'WIND'.
SET TITLEBAR 'BKI'.
WINDOW STARTING AT 30 5 ENDING AT 60 10.
WRITE: 'Customer type :', SBOOK-CUSTTYPE,
/ 'Smoker :', SBOOK-SMOKER,
/ 'Luggage weigtht :', SBOOK-LUGGWEIGHT,
/ 'Class :', SBOOK-CLASS.

ENDIF.
ENDCASE.
At the event START-OF-SELECTION, the system sets the status FLIGHT for the basic
list. In status FLIGHT, function code SELE (text SELECT) is assigned to function key
F2 and to a pushbutton. Thus, the user actions of double-clicking the mouse, pressing F2,
and clicking on pushbutton SELECT all trigger the AT USER-COMMAND event.
The basic list appears as below:

The three fields SPFLI-CARRID, SPFLI-CONNID, and NUM are stored in the HIDE
area while creating the basic list. After selecting a line, the system displays the secondary
list defined in the AT USER-COMMAND event for function code SELE. In the AT
USER-COMMAND event, the system refills all fields of the selected line that were
stored in the HIDE area. You use NUM to check whether the user selected a line from the
actual list. The secondary list has status BOOKING, where F2 is assigned to function
code INFO (text: Booking Information). The secondary list presents data that the
program selected by means of the HIDE fields of the basic list. For each list line
displayed, the system stores additional information in the HIDE area.
If the user selects a line of the secondary list, the system displays the "hidden"
information in a dialog window with the status WIND. For the status WIND, the
proposals of the status type List in dialog box have been accepted. The program uses
SBOOK-BOOKID to check whether the user selected a valid line. The first secondary list
together with another secondary list created from there looks, for example, like this:
The program itself sets all page headers and the title bar of the dialog window.

Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Reading Lines from Lists
The system internally stores all lists created in succession by one report program.
Therefore, you can access any list from within the program that was created during the
current dialog session and has not been deleted by returning to a previous list level (see
Maintaining Lists). To read lines, use the statements READ LINE and READ CURRENT
LINE.
To read a line from a list after an interactive list event occurred, use the READ LINE
statement:
Syntax
READ LINE <lin> [INDEX <idx>]
[FIELD VALUE <f1> [INTO <g1>] ... <fn> [INTO <gn>]]
[OF CURRENT PAGE|OF PAGE <p>].
The statement without any options stores the contents of line <lin> from the list on which
the event was triggered (index SY-LILLI) in the SY-LISEL system field and fills all
HIDE information stored for this line back into the corresponding fields (see The HIDE
Technique). As far as SY-LISEL and the HIDE area are concerned, READ LINE has the
same effect as an interactive line selection.
If the selected line <lin> exists, the system sets SY-SUBRC to 0, otherwise to 4.
The options have the following effects:

INDEX <idx>

The system reads the information for line <lin> from the list of level <idx>.

FIELD VALUE <f1> [INTO <g1>] ... <fn> [INTO <gn>]

The system interprets the output values of the variables <fi> in line <lin> as character
strings and places them either into the same fields <fi> or, when using INTO, into the
fields <gi>. When refilling the fields, the system applies the conversion rules (see Source
Type Character).
Fields that do not appear in a line, do not affect the target field. If a field appears several
times in a line, the system uses only the first one.
The system transports the field contents using the output format, that is, including all
formatting characters. This may lead to inconvertibilities, such as converting editing
characters to decimal characters and others.
You mainly use this option to process user entries in list fields that accept input, since
you cannot use the HIDE technique in this case.

OF CURRENT PAGE

With this option, <lin> is not the number of the line of the entire list, but the number of
the line of the currently displayed page of the addressed list. The system field SYCPAGE stores the corresponding page number.

OF PAGE <p>

With this option, <lin> is not the number of the line of the entire list, but the number of a
line on page <p> of the addressed list.
Depending on the contents of the line read, you may want to fill fields again from the
same line. To do this, you use the READ CURRENT LINE statement in your program.
This statement reads a line twice in succession:
Syntax
READ CURRENT LINE [FIELD VALUE <f1> [INTO <g1>] ...].
This statement reads a line read before by an interactive event (F2) or by READ LINE.
The FIELD VALUE option is the same as for READ LINE.
The following report is connected to the logical database F1S.
REPORT SAPMZTST NO STANDARD PAGE HEADING.
TABLES: SFLIGHT.
DATA: BOX, LINES TYPE I, FREE TYPE I.
START-OF-SELECTION.
SET PF-STATUS 'CHECK'.
GET SFLIGHT.

WRITE: BOX AS CHECKBOX, SFLIGHT-FLDATE.


HIDE: SFLIGHT-FLDATE, SFLIGHT-CARRID, SFLIGHT-CONNID,
SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC.
END-OF-SELECTION.
LINES = SY-LINNO - 1.
TOP-OF-PAGE.
WRITE: 'List of Flights from',
(12) CITY_FR, 'to', CITY_TO.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: 'Date:', SFLIGHT-FLDATE.
ULINE.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'READ'.
BOX = SPACE.
SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
DO LINES TIMES.
READ LINE SY-INDEX FIELD VALUE BOX.
IF BOX = 'X'.
FREE = SFLIGHT-SEATSMAX - SFLIGHT-SEATSOCC.
IF FREE > 0.
NEW-PAGE.
WRITE: 'Company:', SFLIGHT-CARRID,
'Connection: ',SFLIGHT-CONNID,
/ 'Number of free seats:', FREE.
ENDIF.
ENDIF.
ENDDO.
ENDCASE.
If after executing the report, the user fills in the departure and arrival airports on the
selection screen as follows

The self-defined page header uses the parameters CITY_FR and CITY_TO. They are
defined in the logical database F1S. How to find out the names of such parameters using
F1 and Technical Information, is described in the example of the topic
INITIALIZATION.
The program uses the status CHECK, where the self-defined function code READ (text
Read Lines) is assigned to function key F5 and to a pushbutton in the application toolbar.
The corresponding user action triggers the AT USER-COMMAND event. The system
now reads all lines of the basic list using READ LINE in a DO loop. For each line, it fills
the corresponding fields with all values previously stored in the HIDE area. By means of
the FIELD VALUE option, the system in addition reads the checkbox BOX. If seats are
still free, the system writes the company, the connection, and the number of free seats
into a secondary list for each line marked in the checkbox.

The system starts a new page with an individual page header for each output. On the
secondary list, no self-defined user action is supported, since the EXCLUDING option of
the SET PF-STATUS statement deactivates the function code READ.
After returning from the secondary list, the checkboxes are still filled. The example in
Modifying Field Formatting shows how to clear them.

Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.
Modifying Field Formatting
To modify the formatting of fields in the line you want to change, use the option FIELD
FORMAT of the MODIFY statement as follows:
Syntax
MODIFY ... FIELD FORMAT <f1> <options1> <f2> <options2> ... .
This statement sets the output format of the fields <fi> occurring in the line according to
the format specified in <optionsi>. As <optionsi>, you can specify one or more format
options of the FORMAT statement (see The FORMAT Statement).
The option FIELD FORMAT overwrites the specifications of the LINE FORMAT option
for the corresponding field(s). If a field <fi> occurs more than once in the line, the system
modifies only the first. If a field <fi> does not occur in the line, the system ignores the
option.
This example shows how you may continue processing checkboxes after evaluating them.
REPORT SAPMZTST NO STANDARD PAGE HEADING.
DATA: BOX, LINES TYPE I, NUM(1).
SET PF-STATUS 'CHECK'.
DO 5 TIMES.
NUM = SY-INDEX.
WRITE: / BOX AS CHECKBOX, 'Line', NUM.
HIDE: BOX, NUM.
ENDDO.
LINES = SY-LINNO.
TOP-OF-PAGE.
WRITE 'Select some checkboxes'.
ULINE.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'READ'.
SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
BOX = SPACE.
DO LINES TIMES.
READ LINE SY-INDEX FIELD VALUE BOX.
IF BOX = 'X'.
WRITE: / 'Line', NUM, 'was selected'.
BOX = SPACE.
MODIFY LINE SY-INDEX
FIELD VALUE BOX
FIELD FORMAT BOX INPUT OFF
NUM COLOR 6 INVERSE ON.

ENDIF.
ENDDO.
ENDCASE.
This program creates a basic list with the status CHECK. In the status CHECK, function
code READ (text Read Lines) is assigned to function key F5 and to a pushbutton. The
user can mark checkboxes and then choose Read Lines.

In the AT USER-COMMAND event, the system reads the lines of the list using READ
LINE. It continues processing the selected lines on a secondary list. When returning to
the basic list, the system deletes the marks in the checkboxes of the selected lines using
MODIFY LINE and sets the format INPUT OFF to the checkboxes. In addition, it
changes the format of field NUM.

The user can now mark only those lines that have not yet been changed.
You can include the lines of code executing the line modification from this program into
the sample program in Reading Lines from Lists, making only slight modifications.
Neither this documentation nor any part of it may be copied or reproduced in any form or
by any means or translated into another language, without the prior consent of SAP AG.

Vous aimerez peut-être aussi