Selection Screen
Contents
• Selection screen Introduction
• Parameter Statement
• Select-options Statement
• Selection-screen Statement
• Screen table and its fields
• Dynamic screen modification by using Modified key
What is selection screen ?
• Selection screens are one of the three types of screen in the R/3 System,
along with dialog screens and lists.
• The standard selection screen always has the screen number 1000. User-
defined selection screens can have any screen number except 1000.
• In the application toolbar of the standard GUI status of the selection
screen, five pushbuttons are predefined with the function codes FC01 to
FC05, but are inactive by default.
• In an ABAP/4 program, you use the following statements to design
selection screens:
– PARAMETERS to define input fields for variables
– SELECT-OPTIONS to define input fields for selection criteria
– SELECTION-SCREEN to format the selection screen.
Parameters Statement
ABAP/4 REPORTS
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.
To declare a parameter and its data type, use the PARAMETERS
statement as follows:
Syntax
PARAMETERS <p>[(<length>)] <type> [<decimals>].
Caution
Parameters cannot have data type F. The data type F is not supported on
the selection screen.
ABAP/4 REPORTS
Parameters statement variants
PARAMETERS <p> ...... DEFAULT <f> ......
PARAMETERS <p> ...... NO-DISPLAY ......
PARAMETERS <p> ...... LOWER CASE ......
PARAMETERS <p> ...... OBLIGATORY ......
PARAMETERS <p> ...... AS CHECKBOX ......
PARAMETERS <p> ...... RADIOBUTTON GROUP <radi>......
PARAMETERS <p> ...... MEMORY ID <pid>......
PARAMETERS <p> ...... MATCHCODE OBJECT <obj> ......
PARAMETERS <p> ...... MODIF ID <key> ......
Examples of PARAMETER statement
PARAMETERS: FNAME(50) TYPE C DEFAULT ‘YashTechnologies’ LOWER
CASE OBLIGATORY.
• The PARAMETERS statement also has the following additions:
– DEFAULT: Provides a default value for the parameter.
– LOWER CASE: Preserves the case of the value the user enters.
Without this clause, all parameters are converted to upper case.
– OBLIGATORY: Prevents the user from leaving the field blank.
• The above statement asks the user to provide a file name. Since file
names in some operating systems are case-sensitive, the LOWER CASE
clause is used. Additionally, a default value is suggested, and the field
is made mandatory.
TABLES SPFLI.
PARAMETERS : WORD(10) TYPE C,
DATE TYPE D,
NUMBER TYPE P DECIMALS 2,
CONNECT Like SPFLI-CONNID.
Assigning Default Values to
Parameters
TABLES SPFLI.
PARAMETERS : value type i default 100,
name like sy-uname default sy-uname,
date like sy-datum default '20020110'.
Parameters as Obligatory
Example:
PARAMETERS: VALUE TYPE I,
NAME(8) TYPE C OBLIBATORY,
DATE TYPE D OBLIBATORY.
When you use this option, a question mark appears in the input field for
parameter <p>. The user cannot continue with the program without
entering a value in this field on the selection screen.
Parameters as Checkbox
Example :
TABLES SPFLI.
PARAMETERS : A as Checkbox,
B as Checkbox Default 'X'.
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.
• If you use the SELECT-OPTIONS statement, the report user can
enter the selection criteria on the selection screen.
• During its definition, you normally attach a selection criterion to a
specific column of a database table that must be declared in the
program.
Syntax
SELECT-OPTIONS <seltab> FOR <f>.
ABAP/4 REPORTS
Example
SELECT-OPTIONS AIRLINE FOR SPFLI-CARRID.
After Executing above statement a Selection Screen appears as above
ABAP/4 REPORTS
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.
The purpose of selection tables is
• store complex selection limits in a standardized manner.
• transfer the selection criteria directly to database tables using the WHERE
clause of Open SQL statements.
ABAP/4 REPORTS
Select Option variants
SELECT-OPTIONS <seltab> FOR <f> DEFAULT <g> [TO <h>] ....
SELECT-OPTIONS <seltab> FOR <f> ... NO-EXTENSION .....
SELECT-OPTIONS <seltab> FOR <f> ... NO INTERVALS .....
SELECT-OPTIONS <seltab> FOR <f> .. NO DATABASE SELECTION……..
SELECT-OPTIONS <seltab> FOR <f> ... NO-DISPLAY ..............
SELECT-OPTIONS <seltab> FOR <f> ... LOWER CASE ..............
SELECT-OPTIONS <seltab> FOR <f> ... OBLIGATORY ..............
SELECT-OPTIONS <seltab> FOR <f> ... MEMORY ID <pid>..........
SELECT-OPTIONS <seltab> FOR <f> ... MODIF ID <key>...........
SELECT-OPTIONS <seltab> FOR <f> ... MATCHCODE OBJECT <obj>...
• To allow the user to process only the first row of the selection table
on the selection screen, you use the following syntax:
SELECT-OPTIONS <seltab> FOR <f> ..... NO-EXTENSION .....
• As a result, the pushbutton for multiple selections does not appear
on the selection screen, and multiple selections are not available to
the user.
• To allow the user to process only single fields on the selection
screen, you use the following syntax:
SELECT-OPTIONS <seltab> FOR <f> ..... NO INTERVALS .....
• As a result, the second input field does not appear on the selection
screen. The user can only enter a single field comparison for the
first row of the selection table. However, the user can call the
Multiple Selection screen and enter range selections there.
• To set the default value in the selection field on the selection screen,
use the following syntax:
SELECT-OPTIONS <seltab> FOR <f> DEFAULT <g> [TO <h>]
• To make select option a mandatory field, use the following syntax:
SELECT-OPTIONS <seltab> FOR <f> ... OBLIGATORY
User cannot leave the selection screen without entering value in this
input field.
• To assign a search help to the select option, use following variation:
SELECT-OPTIONS <seltab> FOR <f> ... MATCHCODE OBJECT <obj>
A push button will be available with the input field for value help for
the user.
Formatting the Selection Screen
Formatting the Selection Screen
• SELECTION-SCREEN statement can be used to format
selection screen when the standard selection screen
layout is not sufficient.
• The SELECTION-SCREEN statement works only on
selection screens. It has no effect in reports which have
no selection screen.
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
SELECTION-SCREEN COMMENT /2(5) TEXT-001 MODIF ID SC1.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT /10(30) COMM1.
SELECTION-SCREEN ULINE.
PARAMETERS : R1 RADIOBUTTON GROUP RAD1,
R2 RADIOBUTTON GROUP RAD1,
R3 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN ULINE /1(50).
SELECTION-SCREEN COMMENT /10(30) COMM2.
SELECTION-SCREEN ULINE.
PARAMETERS : S1 RADIOBUTTON GROUP RAD2,
S2 RADIOBUTTON GROUP RAD2,
S3 RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN ULINE /1(50).
ABAP/4 REPORTS
Placing
ABAP/4 Several
REPORTS Elements On a Single Line
To position a set of parameters or comments on a single line on the selection
screen, you must declare the elements in a block enclosed by the following
two statements:
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.
Note: Do not use a slash with the format option <pos(len)>
ABAP/4 REPORTS
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
Selection Screen Pushbuttons
Syntax
SELECTION SCREEN PUSHBUTTON [/]<pos(len)> <name>
USER-COMMAND <ucom> [MODIF ID <key>].
• The parameters [/]<pos(len)>, <name>, and the MODIF ID option
are the same as described for the COMMENT option in Comments.
• The text specified in <name> is the pushbutton text.
• For <ucom>, you must specify a code of up to four characters.
Note : You must declare SSCRFIELDS by using a TABLES
statement.
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.
PARAMETERS: p_selop RADIOBUTTON GROUP rg1
USER-COMMAND selopt DEFAULT 'X',
p_para RADIOBUTTON GROUP rg1 .
SELECTION-SCREEN PUSHBUTTON 50(20) but1 USER-COMMAND clr.
SELECTION-SCREEN END OF BLOCK blk1.
Example: Selection Screen
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE
tit2.
PARAMETERS: p_add AS CHECKBOX,
p_sub AS CHECKBOX,
p_multi AS CHECKBOX,
p_div AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK blk2.
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.
ELSEIF p_para = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 001.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
Output of example program
Thank You