Professional Documents
Culture Documents
ITB258 ABAP Programming: Basics of Interactive Reporting Selection Screens
ITB258 ABAP Programming: Basics of Interactive Reporting Selection Screens
ITB258 ABAP Programming: Basics of Interactive Reporting Selection Screens
ABAP Programming
Lecture 6 (Week 7)
Basics of Interactive Reporting
Selection Screens
Objectives
Interactive Reporting
– what are interactive lists
– basic & secondary lists
– the HIDE statement
– event control
• AT LINE-SELECTION
– SY-LSIND
• AT PFnn
• AT USER-COMMAND
– system fields for secondary lists
Objectives
Selection Screens
• the creation and use of Selection Screens in ABAP
reports:
• the SELECT-OPTIONS statement
• Selection tables
• Formatting the selection screen
• Selection texts, Lines, Comments, Frames
• the PARAMETERS statement
• Radiobuttons, Checkboxes
Secondary
List
Report
Interactive
List
Transaction
Interactive Reports are Event Driven
REPORT ZLIST.
*Basic List
END-OF-SELECTION. AT LINE-SELECTION.
TOP-OF-PAGE. AT USER-COMMAND.
END-OF-PAGE. AT PFnn.
TOP-OF-PAGE DURING
LINE-SELECTION.
The Basic List
• Contains the output of the data created while processing
either
– START-OF-SELECTION
– GET <dbtable>
• by default a basic list has a standard page header
– if TOP-OF-PAGE / END-OF-PAGE event occurs
• system writes data to page header / page footer and then displays basic
list data on the output screen
• system field SY-LSIND = 0
Secondary Lists
• basic list + up to 20 secondary lists can exist in
parallel
• on moving to (next) secondary list
– current list added to memory area
– SY-LSIND incremented by one
• using back or exit
– logically superior list is displayed again
– SY-LSIND decremented by one
• no standard heading for secondary lists
Basic List
SY-LSIND = 0
REPORT ZSAPTEST.
• On secondary lists
– system does not display a standard page header
– does not trigger the TOP-OF-PAGE event
• TOP-OF-PAGE DURING LINE-SELECTION
– triggered for each secondary list
– to create different page headers for each secondary
list you must program a processing block for each
value of SY-LSIND
REPORT ZRAL7001 .
START-OF-SELECTION.
WRITE: / 'Basic List. SY-LSIND = ', SY-LSIND.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
FORMAT COLOR COL_HEADING.
WRITE: / '1st secondary list. SY-LSIND = ', SY-LSIND.
WHEN '2'.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE: / '2nd secondary list. SY-LSIND = ', SY-LSIND.
WHEN '3'.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE: / '3rd secondary list. SY-LSIND = ', SY-LSIND.
SY-LSIND = SY-LSIND - 1.
ENDCASE.
TOP-OF-PAGE DURING LINE-SELECTION.
* Write the headings for the secondary lists
CASE SY-LSIND.
WHEN '1'.
WRITE 'Heading For 1st Secondary List'.
WRITE AT 90 SY-PAGNO. ULINE.
WHEN '2'.
WRITE 'Heading For 2nd Secondary List'.
WRITE AT 90 SY-PAGNO. ULINE.
WHEN '3'.
WRITE 'Heading For 3rd Secondary List'.
WRITE AT 90 SY-PAGNO. ULINE.
ENDCASE.
The HIDE Event
HIDE f
• stores the contents of f in relation to the
current output line in the HIDE area
– not necessary for f to appear on current line
– place the HIDE statement immediately after the
output statement for f
• user selection of a line for which HIDE fields
are available fills the variables in the program
with the values stored
REPORT ZSAPTEST.
X HIDE Area
CARRID CONNID CITYFROM CITYTO CARRID CONNID
AA 0016 New York Denver AA 0016
LH 0400 Frankfurt New York LH 0400
LH 0357 Rome Frankfurt LH 0357
: :
* write basic list, hide fields for secondary list
SELECT * FROM SPFLI.
WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM, SPFLI-CITYTO.
HIDE: SPFLI-CARRID, SPFLI-CONNID.
ENDSELECT.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'SORT'.
PERFORM Sort_List.
WHEN 'DELE'.
PERFORM Del_Record.
ENDCASE.
AT Event Processing
• AT PFnn
– nn is in the range of 0 to 99
– determine what action to take by:
• inserting an event header for that PF key; OR
• checking the current function code value stored in SY-UCOMM
– code the appropriate action
AT PF6.
PERFORM Sort_List.
AT PF8.
PERFORM Del_Record.
System Fields & Interactive Reports
SY-CUROW current cursor position (line)
PARAMETERS: P1 TYPE P,
P2(6) TYPE C DEFAULT ‘ITN258’.
P1
P2
Basic Form of select-options
SELECT-OPTIONS seltab FOR f.
1. creates a selection table seltab (an internal table with a
header line) which has a relation to table field f.
– the name for seltab, like parameter names, can be up to 8
characters only
– f cannot be of type f (floating point)
2. displays data input fields on a selection screen.
REPORT ZSAPTEST.
TABLES: SFLIGHT.
SELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRID,
CONN FOR SFLIGHT-CONNID.
AIRLINE CONN
SIGN OPTION LOW HIGH SIGN OPTION LOW HIGH
I EQ
E NE
LT
GT
LE
GE
BT
NB
CP
NP
seltab and Table Selections
• If seltab contains more than one line:
– form the union of sets defined on the lines that have
SIGN = I
– subtract the union of sets defines on the lines that
have SIGN = E
– select the resulting set
• If seltab contains only lines with SIGN = E
– select all data outside the set specified in these lines
Assigning Default Values to
Selection Criteria
SELECT-OPTIONS seltab FOR f DEFAULT g
[TO h] OPTION op SIGN s.
• g and h may be
– literals (enclosed in single quotes)
– names of fields whose contents should be used as
default values
• op may be one of
– EQ,NE,GE,LE,GT,LT,CP,NP for single selections
– BT,NB for interval selections
• s may be either I or E
REPORT ZSAPTEST.
TABLES: SFLIGHT.
SELECT-OPTIONS: AIRLINE FOR SFLIGHT-CARRID
DEFAULT 'AA' TO 'LH'
OPTION NB
SIGN I.
Assigning Default Values to
Selection Criteria
SELECT-OPTIONS: Notes:
AIRLINE FOR SPFLI-CARRID,
CONN FOR SPFLI-CONNID. • Can also use (for example):
INITIALIZATION. AIRLINE-LOW = 'AA'.
MOVE ‘AA’ TO AIRLINE-LOW.
MOVE ‘DL’ TO AIRLINE-HIGH. • If SIGN is not given, 'I' is
MOVE ‘I’ TO AIRLINE-SIGN.
MOVE ‘BT’ TO AIRLINE-OPTION. assumed.
APPEND AIRLINE.
MOVE ‘LH’ TO AIRLINE-LOW. • If OPTION is not given,
MOVE ‘UA’ TO AIRLINE-HIGH. 'EQ' is assumed.
APPEND AIRLINE.
MOVE ‘QF’ TO AIRLINE-LOW.
MOVE ‘NE’ TO AIRLINE-OPTION.
• Only BT and NB use HIGH
APPEND AIRLINE. field.
MOVE ‘0400’ TO CONN-LOW. • SIGN & OPTION reused
MOVE ‘EQ’ TO CONN-OPTION.
APPEND CONN. for second append in this
example.
Restricting the Selection Screen
to One Line
SELECT-OPTIONS seltab FOR f
NO-EXTENSION … .
• right arrow
REPORT ZSAPTEST.
does not appear on
the selection screen TABLES: SFLIGHT.
• user cannot access
SELECT-OPTIONS AIRLINE
the multiple selection FOR SFLIGHT-CARRID
input screen NO-EXTENSION.
Restricting the Selection Screen
to Single Value Selection
SELECT-OPTIONS seltab FOR f … NO
INTERVALS … .
• TO field does not REPORT ZSAPTEST.
appear on the
TABLES: SFLIGHT.
selection screen
• user can access the SELECT-OPTIONS AIRLINE
multiple selection FOR SFLIGHT-CARRID
NO INTERVALS.
input screen
Further Select-Options Clauses
• NO-DISPLAY
• suppresses display of select-option
• LOWER CASE
• enables acceptance of upper & lower case letters
• OBLIGATORY
• makes selection for FROM field mandatory
TABLES SFLIGHT.
SELECT-OPTIONS: CARRIER FOR SFLIGHT-CARRID,
CONN FOR SFLIGHT-CONNID NO-EXTENSION,
FDATE FOR SFLIGHT-FLDATE NO INTERVALS,
CURR FOR SFLIGHT-CURRENCY NO-DISPLAY,
PLANE FOR SFLIGHT-PLANETYPE OBLIGATORY.
Using Selection Tables in
WHERE Conditions
SELECT … WHERE f IN seltab
• f is a database column (without a prefix)
• seltab is the selection table attached to f
REPORT ZSAPTEST.
TABLES: SFLIGHT.
A
x B
Checkboxes on the Selection Screen
REPORT ZSAPTEST.
TABLES: SPFLI, SFLIGHT, SBOOK.
SELECT-OPTIONS: DepTime FOR SPFLI-DEPTIME.
PARAMETERS: Luggage AS CHECKBOX.
TABLES: SBOOK.
• SELECTION-SCREEN SKIP n.
– leaves n blank lines on the selection screen
• SELECTION-SCREEN ULINE
– draws an underline on the selection screen
Formatting the Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK block
… WITH FRAME
… TITLE title
SELECTION-SCREEN END OF BLOCK block.
SELECTION-SCREEN BEGIN OF BLOCK SPFLI WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: CARR FOR SPFLI-CARRID DEFAULT 'LH',
CITY FOR SPFLI-CITYFROM DEFAULT 'BERLIN',
DEPART FOR SPFLI-DEPTIME DEFAULT '100000' TO
'130000'.
SELECTION-SCREEN END OF BLOCK SPFLI.
Formatting Selection Text
REPORT ZB258REP602.
• Textbook
– Ch 3.3 - The Interface (pp. 175 - 197)
• defining a GUI status
– Ch 3.2.16 – Messages (pp. 167 – 174)
– WINDOW statement (p. 248)