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. You use the HIDE technique when creating a basic list. It defines the information that can be passed to subsequent detail lists.
· READ LINE
Use the statements READ LINE and READ CURRENT LINE to read data from the lines of existing list levels. These statements are closely connected to the HIDEtechnique.
· GET CURSOR
Use the statements GET CURSOR FIELD und GET CURSOR LINE to pass the output field or output line on which the cursor was positioned during the interactive event to the ABAP program.
· DESCRIBE LIST
The DESCRIBE LIST statement allows you to import certain list attributes, such as the number of lines or pages, into program variables.
In the following sections you will find examples of the individual statements. The exact description of the respective syntax is available in the keyword documentation.
The example below presents some of the essential features of interactive reporting. The basic list contains summarized information. With the HIDE technique, it is possible to branch to more detailed information on subsequent lists.
The following program is connected to the logical database F1S.
REPORT demo_list_hide 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 UNIT 'KG',
/
'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. So the event AT USER-COMMAND is triggered if the user double-clicks, presses F2, or chooses the pushbutton SELECT.
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 detail 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 detail list has status BOOKING, where F2 is assigned to function code INFO (text: Booking Information). The detail list presents data that the program selected using 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 detail list, the system displays the stored information in a dialog box with the status WIND. For the WIND status, the default values for the status type Dialog box have been adopted with the list status adjustment. The program uses sbook-bookid to check whether the user selected a valid line.
The program itself sets all page headers and the title bar of the dialog box.
All of the lists generated by a single program are stored internally in the system. You can therefore access any list in a program that was created for the same screen and that has not yet been deleted by returning to a lower list level. To read lines, use the statements READ LINE and READ CURRENT LINE.
To read a line from a list after an interactive list event, use the READ LINE ...statement:
To read a line twice in succession, use the READ CURRENT LINE ... statement
This statement reads a line read before by an interactive event (F2) or by READ LINE.
The following program is connected to the logical database F1S.
REPORT demo_list_read_line NO STANDARD PAGE HEADING.
TABLES: sflight.
DATA: box(1) TYPE c, 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 flight
dates'.
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.
After the selection screen has been selected, the system displays a basic list where the user can fill in checkbox fields. The self-defined page header of the basic list uses the parameters CITY_FR und CITY_TO. The parameters are defined in the logical database F1S.
The program uses the status CHECK, where the 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, the values stored previously using HIDE are placed in the respective fields for each line. Using the FIELD VALUE option, the system also reads the checkbox box. If seats are still free, the system writes the company, the connection, and the number of free seats into a detail list for each line in which the checkbox was selected.
The system starts a new page with an individual page header for each output. On the detail list, the function code READ is deactivated using the EXCLUDING addition of the SET PF-STATUS statement.
After returning from the detail list, the checkboxes are still filled.
To retrieve information about the current cursor position in an interactive event, use the GET CURSOR statement. You can retrieve information either about the current field or the current line.
For field information, use the variant:
GET CURSOR FIELD ...
For field information, use the variant:
GET CURSOR LINE ...
REPORT SAPMZTST NO STANDARD PAGE HEADING LINE-SIZE 40.
DATA:
HOTSPOT(10) VALUE 'Click me!',
F(10), OFF TYPE I, LIN TYPE I, VAL(40),
LEN TYPE I.
FIELD-SYMBOLS
<FS>.
ASSIGN HOTSPOT TO <FS>.
WRITE 'Demonstration of GET CURSOR
statement'.
SKIP TO LINE 4.
POSITION 20.
WRITE <FS> HOTSPOT COLOR 5 INVERSE ON.
AT
LINE-SELECTION.
WINDOW STARTING AT 5 6 ENDING AT 45
20.
GET CURSOR FIELD F OFFSET OFF
LINE
LIN VALUE VAL LENGTH LEN.
WRITE: 'Result of GET CURSOR FIELD:
'.
ULINE AT /(28).
WRITE: / 'Field: ', F,
/ 'Offset:', OFF,
/ 'Line: ',
LIN,
/ 'Value: ', (10) VAL,
/ 'Length:', LEN.
SKIP.
GET CURSOR LINE LIN OFFSET OFF
VALUE VAL LENGTH LEN.
WRITE: 'Result of GET CURSOR LINE:
'.
ULINE AT /(27).
WRITE: / 'Offset:', OFF,
/ 'Value: ', VAL,
/ 'Length:',
LEN.
In this program, the HOTSPOT field is assigned to the field symbol <FS> and displayed as a hotspot on the output screen. If the user positions the cursor on a list line and selects it, a dialog box appears containing the results of the GET CURSOR statements in the AT LINE-SELECTION event.
Note that, after GET CURSOR FIELD, the name of the field assigned to the field symbol <FS> is stored in F, and not the name of the field symbol.
If you need to know the attributes of list levels that were not stored in system variables during list creation, you can use the DESCRIBE LISTstatement.
To retrieve the number of lines or pages of a list, use:
DESCRIBE LIST NUMBER OF LINES|PAGES n ...
To get the page number of a particular line number, use:
DESCRIBE LIST LINE lin PAGE pag ...
To get the properties of a particular page, use:
DESCRIBE LIST PAGE pag ...
Use DESCRIBE LIST for completed lists only, since for lists in creation (index is sy-lsind) some properties are not up to date.
REPORT demo_list_describe_list NO STANDARD PAGE HEADING
LINE-SIZE 40 LINE-COUNT 5(1).
DATA: lin TYPE i, pag TYPE i,
col TYPE i, len TYPE i, lin1 TYPE i,
top TYPE i, tit TYPE i, head TYPE i, end
TYPE i.
DO 4 TIMES.
WRITE / sy-index.
ENDDO.
TOP-OF-PAGE.
WRITE 'Demonstration of DESCRIBE
LIST statement'.
ULINE.
END-OF-PAGE.
ULINE.
AT LINE-SELECTION.
NEW-PAGE LINE-COUNT 0.
WINDOW STARTING AT 1 13 ENDING AT 40 25.
DESCRIBE LIST: numBER OF LINES lin INDEX 0,
numBER OF PAGES pag INDEX 0.
WRITE: 'Results of DESCRIBE LIST: '.
ULINE AT /(25).
WRITE: / 'Lines: ', lin,
/ 'Pages: ', pag.
SKIP.
DESCRIBE LIST LINE sy-lilli PAGE
pag INDEX 0.
WRITE: / 'Line', (1) sy-lilli, 'is on page', (1) pag.
SKIP.
DESCRIBE LIST PAGE pag INDEX 0
LINE-SIZE col
LINE-COUNT len
LINES lin
FIRST-LINE lin1
TOP-LINES top
TITLE-LINES tit
HEAD-LINES head
END-LINES end.
WRITE: 'Properties of Page', (1)
pag, ':',
/
'Width: ', col,
/
'Length: ', len,
/
'Lines: ', lin,
/ 'First
Line: ', lin1,
/ 'Page Header: ', top,
/ 'Title Lines: ', tit,
/ 'Header Lines:', head,
/ 'Footer
Lines:', end.
This program creates a two-page list of five lines per page. Two lines are used for the self-defined page header and one line for the page footer. If the user selects a line, a dialog box appears containing the list attributes.
During creation of the secondary list, all variants of the DESCRIBE LIST statement apply to the basic list. The system displays the results in the dialog box. The lines and pages to be described are addressed dynamically using sy-lilli.