SSelection Screen
SSelection Screen
Contents
• The standard selection screen always has the screen number 1000. User-
defined selection screens can have any screen number except 1000.
PARAMETERS
The PARAMETERS statement creates a single entry field on the selection
screen. It also creates a variable in your program with the same name.
The value placed into the field at run-time by the user is also placed into
the variable.
Caution
Parameters cannot have data type F. The data type F is not supported on
the selection screen.
ABAP/4 REPORTS
Parameters as Radiobutton
Example:
TABLES SPFLI.
PARAMETERS : R1 RADIOBUTTON GROUP RAD1,
R2 RADIOBUTTON GROUP RAD1,
R3 RADIOBUTTON GROUP RAD1 DEFAULT ‘X’,
S1 RADIOBUTTON GROUP RAD2,
S2 RADIOBUTTON GROUP RAD2,
S3 RADIOBUTTON GROUP RAD2 DEFAULT ‘X’.
Select-Options
ABAP/4 REPORTS
Select-Options
• What are Selection Criteria?
You define selection criteria with the SELECT-OPTIONS
statement.
Syntax
SELECT-OPTIONS <seltab> FOR <f>.
ABAP/4 REPORTS
Example
Selection table
• For SELECT-OPTIONS statement, the system creates a selection table.
• It is an internal table(with name same as select option) with a header line. Its
line structure is a field string of four components,
• SIGN : The data type of SIGN is C with length 1. Possible values are I and E.
• OPTION : The data type of OPTION is C with length 2. OPTION contains the selection operator.
• If HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP.
• If HIGH is filled, you can use BT and NB.
• LOW : The data type of LOW is the same as the column type of the database table, to which
the selection criterion is attached.
• HIGH : The data type of HIGH is the same as the column type of the database table, to which
the selection criterion is attached.
Syntax :
SELECTION-SCREEN …...
ABAP/4 REPORTS
Blank Lines:
To produce blank lines on the selection screen, use the SKIP option with the
SELECTION-SCREEN statement.
Syntax:
SELECTION-SCREEN SKIP [<n>]. [<n> denotes number of lines]
Underlines:
To underline a line or part of a line on the selection screen, use the ULINE option
with the SELECTION-SCREEN statement.
Syntax
SELECTION-SCREEN ULINE [[/]<pos(len)>].
Comments:
To write text on the selection screen, use the COMMENT option with the
SELECTION-SCREEN statement. The syntax is as follows:
Syntax
SELECTION-SCREEN COMMENT [/]<pos(len)> <name>.
ABAP/4 REPORTS
Example
Syntax
SELECTION-SCREEN BEGIN OF LINE.
...
SELECTION-SCREEN END OF LINE.
Note that the selection text (name of the parameter or text element) is not
displayed when you use this option. To display a selection text you must use
SELECTION-SCREEN statement with the COMMENT option.
Example
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(10) TEXT-001.
PARAMETERS : P1(3), P2(5), P3(1).
SELECTION-SCREEN END OF LINE.
ABAP/4 REPORTS
SELECTION-SCREEN POSITION
• For <pos>, you can specify a number, POS_LOW, or POS_HIGH.
Note:
• Use the POSITION option only between the BEGIN OF LINE and END OF
LINE options.
Example:
TABLES SPFLI.
SELECT-OPTIONS AIRLINE FOR SPFLI-CARRID.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION POS_HIGH.
PARAMETERS FIELD(5).
SELECTION-SCREEN END OF LINE.
ABAP/4 REPORTS
SELECTION-SCREEN BLOCKS
Syntax
SELECTION-SCREEN BEGIN OF BLOCK <block>
[WITH FRAME [TITLE <title>]].
...
SELECTION-SCREEN END OF BLOCK <block>.
• You must define a name <block> for each block. You can
nest blocks.
• If you add the WITH FRAME option, a frame will be drawn
around the block.
• You can add a title to each frame by using the TITLE option .
ABAP/4 REPORTS
Example
SELECTION-SCREEN BEGIN OF BLOCK RAD1
WITH FRAME TITLE TEXT-002.
PARAMETERS: R1 RADIOBUTTON GROUP GR1,
R2 RADIOBUTTON GROUP GR1,
R3 RADIOBUTTON GROUP GR1.
SELECTION-SCREEN END OF BLOCK RAD1.
On the selection screen, the three radio buttons R1, R2, R3 form a block, which is
surrounded by a frame and has the title specified in the text symbol 002.
ABAP/4 REPORTS
Example
TABLES SSCRFIELDS.
DATA FLAG.
PARAMETERS: TEST.
SELECTION-SCREEN PUSHBUTTON /20(10) BUT1USER-COMMAND CLI1.
SELECTION-SCREEN PUSHBUTTON /20(10) TEXT-020
USER-COMMAND CLI2.
INITIALIZATION.
BUT1 = ‘Button 1’.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = ‘CLI1’.
FLAG = ‘1’.
ELSEIF SSCRFIELDS-UCOMM = ‘CLI2’.
FLAG = ‘2’.
ENDIF.
START-OF-SELECTION.
IF FLAG = ‘1’.
WRITE : / ’Button 1 was clicked’.
ELSEIF FLAG = ‘2’.
Write : / ‘Button 2 was clicked’.
ENDIF.
ABAP/4 REPORTS
Example
If the text symbol TEXT-020 is defined as ‘button 2’, this example causes two
pushbuttons with the texts ‘Button 1’ and ‘Button 2’ to appear on the selection
screen.
Screen Table
Screen Table:
Using screen table we can modify selection screen elements dynamically.
Some of the fields are:
• Active: Possible values are 0 & 1. Used to activate or deactivate any element
for user entry.
• Invisible: Possible values are 0 & 1. Used to make field visible or invisible.
All the fields of screen table can be used with MODIF ID addition of elements’
declaration.
Example:
parameters: p_num(5) type c modif id ABC.
Loop at Screen.
If screen-group1 = ‘ABC’.
Screen-intensified = 1.
Endif.
Modify Screen.
Endloop.
Components of screen table
• REQUIRED
When you set REQUIRED = 1, a field that is ready for input is made mandatory.
Users can only leave the screen when all mandatory fields contain an entry.
Exception: Function codes with type E and modules with the AT EXIT-COMMAND
addition.
• VALUE_HELP
Setting VALUE_HELP to 0 or 1 switches the input help button off and on
respectively.
• INTENSIFIED
If you set INTENSIFIED = 1, the field contents of input fields are changed from black
to red. The contents of output fields are changed from black to blue.
• LENGTH
You can set the LENGTH component to a value shorter than the statically-defined
output length (vislength) for input/output fields and Output only fields. This allows
you to shorten their output length. You cannot shorten other screen elements, or
lengthen any screen elements.
Dynamic Screen Modification
• Each field on a screen has a set of attributes that are fixed when you define the
screen. When an ABAP program is running, a subset of the attributes of each screen
field can be addressed using the system table SCREEN.
• You can modify SCREEN in your ABAP program during the PBO event of a screen. Its
contents override the static attributes of the screen fields for a single screen call.
Example:
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_num1 TYPE i,
p_num2 TYPE i MODIF ID ACT.
SELECTION-SCREEN END OF BLOCK blk1.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = ‘ACT'.
screen-active = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
Output of above example
Example: Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE tit1.
SELECT-OPTIONS: s_num FOR w_test MODIF ID 001.
PARAMETERS: p_num1 TYPE i MODIF ID 002,
p_num2 TYPE i MODIF ID 002.
SELECTION-SCREEN SKIP 1.
INITIALIZATION.
tit1 = 'Mode of input'.
tit2 = 'Select operations'.
but1 = 'Clear Values'.
Example: Selection Screen contd.
AT SELECTION-SCREEN OUTPUT.
IF p_selop = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 002.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.