SELECTION-SCREENS: Designing Selection Screens

SELECTION-SCREEN - Designing Selection screens

Variants:
1. SELECTION-SCREEN BEGIN OF BLOCK block.
2. SELECTION-SCREEN END OF BLOCK block.
3. SELECTION-SCREEN BEGIN OF LINE.
4. SELECTION-SCREEN END OF LINE.
5. SELECTION-SCREEN POSITION pos.
6. SELECTION-SCREEN ULINE.
7. SELECTION-SCREEN COMMENT fmt name.
8. SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom.
9. SELECTION-SCREEN SKIP n.
10.SELECTION-SCREEN FUNCTION KEY n.

Effect

Reports, that is, programs with type "1" in their attributes, usually have a selectionscreen, which is generated from the SELECT-OPTIONS and PARAMETERS statements from the report and the access routines for the logical database, where one line of the selection screen is taken up by each of these objects.
Additionaly, you can define your own selection screen in any ABAP programs (except type "S" programs), using SELECTION-SCREEN BEGIN/END OF SCREEN. You call them in your program using the CALL SELECTION-SCREEN statement.
You design selection screens using the SELECTION-SCREEN statement. In the standard selection screen of a report, the SELECTION-SCREEN statement in the report, and the selection include of the logical database ldb assigned to the report in its attributes, control the screen design. The logical database section is controlled by special additions.
SELECTION-SCREEN allows you to create blocks, combine several parameters and comments into a single line, create pushbuttons on the screen or in the application toolbar, and include spaces, underlines and comments on the screen.
There are other variants on SELECTION-SCREEN, which have been designed exclusively for logical databases, and can therefore only be used in the selection include.

Additions:
1. ... WITH FRAME
2. ... TITLE title
3. ... NO INTERVALS

Effect

The system opens a logical block on the selection screen. If you use the WITH FRAME addition, the block is enclosed in a box. You can only use the TITLE title addition in conjunction with WITH FRAME.

The title title can be defined either statically or at runtime (see also the COMMENT, PUSHBUTTON and variants).

At runtime, the event

AT SELECTION-SCREEN ON BLOCK block is triggered in the PAI phase for each block of the selection screen. (In database-specific blocks, the PAI routine is started in program SAPDBldb, passing the parameters FNAME = BLOCK_block and MARK = SPACE). If an error message is output, the fields in this block are ready for input.

You can nest blocks. The maximum depth for blocks in boxes is five levels.

Effect

All SELECT-OPTIONS within the block are displayed in simplified form on the selection screen without a 'to' field (corresponds to the "NO INTERVALS " addition for the SELECT-OPTIONS statement). The frame for the block (if applicable) is made smaller accordingly.

Note

The "NO INTERVALS" attribute is not inherited by blocks without boxes nested deeper. However, if the blocks are in boxes, the attribute is inherited, since a smaller box is generated, in which there is no room for the 'to' field.

Effect

Closes the block opened in SELECTION-SCREEN BEGIN OF BLOCK block. If the block has a box, this is also closed.

Note

Blocks opened in the database selection include must also be closed in the same program.

Example

TABLES SAPLANE. 
 
SELECTION-SCREEN BEGIN OF BLOCK CHARLY 
				 WITH FRAME TITLE TEXT-001. 
  PARAMETERS PARM(5). 
  SELECT-OPTIONS SEL FOR SAPLANE-PLANETYPE. 
SELECTION-SCREEN END   OF BLOCK CHARLY. 

(TEXT-001 = 'Block Charly').

Selection screen:

--Block Charly-----------------------------------
| PARM _____ |
| SEL ________ to ________ |
-------------------------------------------------

Effect

This enables you to arrange several parameters, comments, pushbuttons or underline blocks, included between the SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE statements, in a single line. The automatic newline after each PARAMETER is suppressed. Furthermore, the system does not output selection texts for parameters.

Example

SELECTION-SCREEN BEGIN OF LINE. 
  SELECTION-SCREEN COMMENT 1(10) TEXT-001 FOR FIELD P1. 
  PARAMETERS: P1 LIKE SAPLANE-PLANETYPE, P2(5), P3(1). 
SELECTION-SCREEN END OF LINE. 

Selection screen:

Comment 1________ _____ _

Note

You cannot include SELECT-OPTIONS between SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE , since the system generates more than one object on the selection screen in a SELECT-OPTION (like fields for lower and upper limits).
You cannot use any variants of SELECTION-SCREEN that generate a newline (like SELECTION-SCREEN SKIP) between SELECTION-SCREEN BEGIN OF LINE and SELECTION-SCREEN END OF LINE.

Effect

The next object on the current line ( parameter, comment, pushbutton or underline) is positioned at pos.
You may only use this variant between SELECTION-SCREEN BEGIN OF LINE und SELECTION-SCREEN END OF LINE.
You can specify the position pos as a number (relative to the box) if you use the statement between the SELECTION-SCREEN BEGIN OF BLOCK ... WITH FRAME ... and SELECTION-SCREEN END OF BLOCK ... statements. You can also use the symbolic positions POS_LOW and POS_HIGH. These are the positions on the screen at which the system places the input fields for SELECT-OPTIONS. (POS_LOW is also the screen position for PARAMETERS).

Within the selection include: Addition FOR TABLE dbtab.

Additions:
1. ... fmt.
2. ... MODIF ID modid.

Effect

Generates an underline (similar to ULINE).
By specifying the format, you can control length, position and newlines.
By specifying a
Modif ID you can assign the underline to a modification group.

Within the selection include: Additions FOR TABLE dbtab und ID id.

Addition 1

AP_ADDITION_2&

... MODIF ID modid

Effect

The underline is assigned to the modification group specified (SCREEN-GROUP1). You can use the group to modify screens.

Additions:
1. ... FOR FIELD f
2. ... MODIF ID modid.
3. ... VISIBLE LENGTH vlen.


You can define the content (name) either statically or at runtime (see also the BEGIN OF BLOCK, PUSHBUTTON and SELECTION-SCREEN BEGIN OF SCREEN variants).

When you use comments, you must always specify a format fmt.

Effect

The comment is assigned to either a Parameter or a select-option f. When the user displays help, the documentation for the reference field of the parameter or select-option is displayed.
The comment is hidden if the reference object is set to 'invisible' in a selection variant.

Example

SELECTION-SCREEN BEGIN OF LINE. 
  SELECTION-SCREEN COMMENT 10(20) TEXT-001 
				 FOR FIELD PARM. 
  SELECTION-SCREEN POSITION POS_LOW. 
  PARAMETERS PARM LIKE SAPLANE-PLANETYPE. 
SELECTION-SCREEN END OF LINE. 

The comment appears with length 20 in the normal position (POS_LOW , and in the same line as the parameter. If the user presses F1 for either object, the system displays the documentation for SAPLANE-PLANETYPE.

By specifiying a
Modif ID , you can assign the comment to a modification group.

Effect

The comment is displayed in the shortedned length vlen. However, you can still scroll through its full length as specified in the format definition (similarly to SELECT-OPTIONS and PARAMETERS).

Within the selection include: Additi FOR TABLE dbtab und ID id .

Variant 8

SELECTION-SCREEN PUSHBUTTON fmt name USER-COMMAND ucom.

Addition:
MODIF ID modid .

Effect

Generates a pushbutton on the selection screen. When you define the button, you also define a user command ucom (no inverted commas), up to four characters long, which is triggered when the user pushes the button. The rest of the syntax is the same as for SELECTION-SCREEN COMMENT

You can define the name name either statically or at runtime (see also the BEGIN OF BLOCK, COMMENT</> and variants).

When you define a pushbutton, you must always specify a format fmt.

By specifying a

Modif ID , you can assign the pushbutton to a modification group.

The best way of reacting to the pushbutton is in the AT SELECTION-SCREEN event, or, for pushbuttons in the selection include, in the PAI routine (with FNAME = '*' and MARK = SPACE ) in the database program SAPDBldb. The field SSCRFIELDS-UCOMM contains the user command ucom. (You need to declare the SSCRFIELDS table using the TABLES statement).

Within the selectoin include: Additions FOR NODE node, FOR TABLE dbtab und ID id .

Example

TABLES SSCRFIELDS. 
  ... 
SELECTION-SCREEN PUSHBUTTON /10(20) CHARLY USER-COMMAND ABCD. 
  ... 
 
INITIALIZATION. 
  MOVE 'My text' TO CHARLY. 
  ... 
 
AT SELECTION-SCREEN. 
  IF SSCRFIELDS-UCOMM = 'ABCD'. 
	... 
  ENDIF.

A pushbutton appears on the selection screen with the text 'My text'. In the AT SELECTION-SCREEN event, the field SSCRFIELDS-UCOMM has the contents ABCD after the button has been pushed.

Effect

Generates n blank lines (similar to SKIP)
n can have any value from 1 to 9. If you only want to insert one blank line, you can leave out n.

Within the selection include: Additions FOR NODE node, FOR TABLE dbtab and ID id.

Effect

Activates a pushbutton (one of a maximum of 5) in the application toolbar of the selection screen (where n is between 1 and 5).
At runtime, you must insert the text for the pushbutton into the appropriate ABAP Dictionary field SSCRFIELDS-FUNCTXT_01 ... SSCRFIELDS-FUNCTXT_05.
The function code placed in field SSCRFIELDS-UCOMM is 'FC01' ... 'FC05'. You can query this function code in the AT SELECTION-SCREEN event or the PAI routine in the database access program SAPDBldb.

Within the selection include: Additions FOR NODE node, FOR TABLE dbtab, and DS:ABAP.SELECTION-SCREEN_LDB_ADDYS>ID id. FOR TABLE dbtab und ID id.

If a pushbutton (ex. FUNCTION KEY 2,) is already defined in the selection include, the system returns a syntax error if you try to include an equivalent statement in your report.

Example

TABLES SSCRFIELDS. 
... 
SELECTION-SCREEN FUNCTION KEY 1. 
... 
 
INITIALIZATION. 
  MOVE 'My text' TO SSCRFIELDS-FUNCTXT_01. 
  ... 
 
AT SELECTION-SCREEN. 
  IF SSCRFIELDS-UCOMM = 'FC01'. 
	... 
  ENDIF.

Generates a pushbutton in the application toolbar of the selection screen with the text 'My text'. In the AT SELECTION-SCREEN event, SSCRFIELDS-UCOMM has the contents FC01 when the button has been pushed.