Você está na página 1de 12

Selection Screens

Audion Transcript

Selection screens serve as an interface between the program and the user, and
allow limitation of the amount of data to be read from the database.
You can use the declarative statements PARAMETERS and SELECT-
OPTIONS to generate a standard selection screen (screen 1000) with input-
ready fields.
Logical databases supply a selection screen whose appearance is dependent
on the specified nodes (NODES <name>).
Selection screen versions offer a subset of the standard selection screen.
In addition to the standard selection screen, you can also use SELECTION-
SCREEN BEGIN OF SCREEN... to generate an additional selection screen and
use CALL SELECTION-SCREEN to call them.
You can create variants to save selection screen values that you use frequently.
You can use the variants at any time. If a report with a selection screen runs in
the background, a variant is always required.
Declaration of Fields with PARAMETERS
The automatic ABAP Dictionary check is, by default, deactivated for report
selection screens. However, if you refer to a Dictionary object for which a
foreign key is set up, you can use VALUE CHECK to trigger a validity check of
the input.
You can also define parameters as checkboxes. With this definition, you create
a single character field that contains a space or X. You can evaluate the content
of the checkboxes in IF/ENDIF structures.
You can also create a group of radio buttons for the selection screen with the
help of the RADIOBUTTON GROUP <grp> addition. Only one radio button in a
group can be active. The radio button can be evaluated in the program
processing. You can evaluate the contents of radio buttons using
CASE/ENDCASE control structures. The radio button that you select has the
value X, and all others have the value space. If you have not assigned a value
to any radio button, the system automatically selects the first radio button when
it displays the selection screen.
You can use the MODIF ID <mod> addition to simplify dynamic modifications to
the selection screen.

Audio Transcript
The PARAMETERS statement is a declarative language element. As in the
case of the DATA statement, you can declare the parameters with the TYPE or
LIKE additions. The system generates input-ready fields on the selection
screen.
You can maintain selection texts by choosing Goto → Text Elements →
Selection Texts.
The names of the PARAMETERS fields can have a maximum of eight
characters.
With the DEFAULT <value> addition, you can set a default value for a
PARAMETERS statement. If you assign a MEMORY ID <pid>, the system
retrieves the current value from the SAP Memory and displays it on the screen
automatically. The SAP Memory is a user-specific memory area in which simple
data values, for example, the key for an airline, are stored for SET/GET
parameters. These data values are stored for the duration of a user session.
SET/GET parameters are identified by a name, which can be maximum 20
characters long. A SET/GET parameter can be assigned to a data element.
Fields based on this data element can then use the SAP Memory mechanism.
You can find out the name of a required SET/GET parameter by choosing Help
(F1) → Technical Information, in an output field to call Technical Information. In
the Parameter ID field, you find the name of the SET/GET parameter.
If you declare mandatory fields with the OBLIGATORY addition, users cannot
leave the selection screen without entering values in these fields.
Hint: The name <grp> of a radio button group can have a maximum of four
characters.

Declaration of Fields with SELECT-OPTIONS


This internal table has the following columns:

 Sign (indicator meaning including or excluding)


 Option (relational operator)
 Low (lower limit)
 High (upper limit)
SELECT-OPTIONS is a declarative language element with the same naming
restriction of eight characters as PARAMETERS. SELECT-OPTIONS allows the
use of a value range and complex selections instead of a single input field.
The SELECT-OPTIONS keyword generates an internal table <seltab> with a
standard structure and a header line.
You can maintain the selection text in the same way as with PARAMETERS by
choosing Goto → Text Elements → Selection Texts.
Use the addition FOR to specify the type of the field. Use the name of a variable
that you have already declared in a DATA or NODES statement.
Each line of the selection table <seltab> formulates a condition using one of the
relational operators.

Possible Values for SIGN and OPTION

To calculate the selection set S, the system forms the union of all includes (sign = ‘I’)
and the union of all excludes (sign = ‘E’). The set of exclusions is then subtracted from
the set of inclusions. If the SELECT-OPTIONS object contains no values, the system
returns all rows from the database.

SELECT-OPTIONS with Multiple Selection Criteria


If a user enters data in a SELECT-OPTIONS object, the system automatically
fills the internal table.
To change the default values for the SIGN and OPTION table fields, choose
Edit → Selection Options.
The system offers suitable options for this selection. The green traffic signal
icon in the Sign column indicates I (inclusive) and a red light indicates E
(exclusive).
To delete a table entry, choose Edit → Delete Selection Row.
Every selection criterion can be used to make multiple selections unless it is
defined otherwise. If multiple selections are present, the color of the arrow
changes from gray to green.

Syntax of the SELECT-OPTIONS Statement


The SELECT-OPTIONS statement additions are as follows:

 DEFAULT
DEFAULT helps you to set default values for the parameters low or low and
high. You can use OPTION and SIGN to set the default values for option
and sign that differ from the normal default values.

 MEMORY ID <pid>
MEMORY ID <pid> helps you to retrieve the current value from the SAP
Memory and automatically displays it on the screen. MEMORY ID <pid>
writes it back again when you exit the screen (including any changes you
might have made).

 LOWER CASE
LOWER CASE suppresses the conversion of the input to uppercase as long
as the domain allows it or the typing was made for ABAP type C.

 OBLIGATORY
OBLIGATORY generates an obligatory field. A question mark appears in the
input field on the selection screen, and the user must enter a value.

 NO-EXTENSION
NO-EXTENSION suppresses multiple selections.

 NO INTERVALS
NO INTERVALS suppresses the upper interval limit (<seltab>-high) on the
selection screen. You can use the additional Multiple Selection screen to
enter intervals.

Dynamic Preassignment of the Selection Screen


Audio Transcript
You can overwrite the default value of a PARAMETERS field or a SELECT-
OPTIONS object in the INITIALIZATION event. For this reason, these events
are appropriate for a dynamic preassignment of the input fields that are
displayed on a selection screen.
AT SELECTION-SCREEN OUTPUT is processed before the selection screen is
displayed and AT SELECTION-SCREEN is processed after the selection
screen is displayed. You can display the selection screen multiple times (for
example, by pressing ENTER), and therefore the system can also process
those event blocks multiple times.

Initialization of the Selection Screen

Audio Transcript
The system processes the INITIALIZATION event once in each executable program.
You can deliver default values for the selection screen fields of a report or a logical
database during this INITIALIZATION event. You can use the F1 help (technical help)
to determine the names of the selection fields if a logical database is connected with
the program.

Filling of an Internal Table with a Header Line


The SELECT-OPTIONS <sel_opt> FOR <data_object> statement always
generates an internal table with a header line.
The statement creates the following data objects:

 Table body named <sel_opt>


 Work area (the header line) named <sel_opt>
Fill the <sel_opt> work area with correct values and use the APPEND <sel_opt>
command to add it to the table body as a separate line.
You can also provide values for the selection screen at the AT SELECTION-
SCREEN OUTPUT event. This event occurs before the selection screen is
displayed. However, this event may be processed multiple times, for example, if
the user chooses Enter on the selection screen. In this case, the values
provided at the AT SELECTION-SCREEN OUTPUT event overwrite the user
input.
Design of Selection Screen Blocks

Audio Transcript
You can use the SELECTION-SCREEN statement to design the structure of the
selection screen.
You can use the BEGIN OF BLOCK <block> addition to group logically related
screen elements and WITH FRAME to frame them. You can nest frames up to
five levels.
Assign a heading to the block to facilitate accessibility. You can write the title as
either text-<xxx> or as a field name of up to eight characters. To write a text as
a field name, you set the text at runtime in the INITIALIZATION event.
Before you design a selection screen, familiarize yourself with the guidelines for
screen design shown in transaction BIBS.
Design of Selection Screen Lines
The COMMENT ... FOR FIELD <f> addition causes the system to automatically
display the help menu of the <f> field for both the comment text and the
parameter. If you hide the parameter (selection variant: attribute invisible), the
comment text is also hidden.
You can use POSITION <pos> to position the cursor on a line for the next
output (only in BEGIN OF LINE ... END OF LINE), where <pos> is an integer.
You can define empty lines with the help of addition SKIP <n>, where <n> is an
integer.

Audio Transcript
You can display multiple parameters and comments in the same output line by
enclosing them between SELECTION-SCREEN BEGIN OF LINE and
SELECTION-SCREEN END OF LINE.
The COMMENT addition enables you to include text in the line. Comment texts
must always have a format (position and output length). You can define the
position using integer literals or variables. Pos_low and pos_high are the
positions of the upper and lower limits of the field SELECT-OPTIONS on the
selection screen. The output length is always defined as an integer literal

Você também pode gostar