Tải bản đầy đủ (.pdf) (153 trang)

BC ABAP Programming PHẦN 6 pot

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (7.74 MB, 153 trang )

BC - ABAP Programming SAP AG
Processing Radio Buttons
768 December 1999
Processing Radio Buttons
In the PAI event of the selection screen, the event
AT SELECTION-SCREEN ON RADIOBUTTON GROUP <radi>
is triggered when the contents of all of the fields in a radio button group are passed from the
selection screen to the ABAP program. To define a radio button group <radi>, use the addition
RADIOBUTTON GROUP <radi> in the corresponding PARAMETERS statements. This event
block allows you to check the whole group. If an error message occurs within this event block,
the radio button group is made ready for input again on the selection screen. The individual
fields of radio button groups do not trigger the event AT SELECTION-SCREEN ON <field>.
REPORT EVENT_DEMO.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: R1 RADIOBUTTON GROUP RAD1 DEFAULT 'X',
R2 RADIOBUTTON GROUP RAD1,
R3 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
PARAMETERS: R4 RADIOBUTTON GROUP RAD2 DEFAULT 'X',
R5 RADIOBUTTON GROUP RAD2,
R6 RADIOBUTTON GROUP RAD2.
SELECTION-SCREEN END OF BLOCK B2.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD1.
IF R1 = 'X'.
MESSAGE W040(HB).
ENDIF.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD2.
IF R4 = 'X'.
MESSAGE W040(HB).
ENDIF.


If the user does not change one of the radio button groups, a warning is displayed.
R1
R2
W: This is the default setting!
R3
R4
R5
R6
SAP AG BC - ABAP Programming
Processing Radio Buttons
December 1999 769
BC - ABAP Programming SAP AG
Processing Multiple Selections
770 December 1999
Processing Multiple Selections
If the user opens the Multiple selections dialog box for a selection option, the same events are
triggered in the PAI of the selection screen as if the user had chosen
Execute. The user can then
enter the required multiple selections. In the
Multiple selections dialog box, user actions either
lead to input help or trigger the PAI event of the dialog box. At first, the
AT SELECTION-SCREEN ON <seltab>
event is triggered for the current line of the selection table. It can then be processed like a single
field [Page 765].
Next, the
AT SELECTION-SCREEN ON END OF <seltab>
event is triggered. This event block allows you to check the whole selection table <seltab>.
Warning messages are displayed as dialog boxes, not in the status line.
The program below is connected to the logical database F1S:
REPORT EVENT_DEMO.

NODES SPFLI.
AT SELECTION-SCREEN ON END OF CARRID.
LOOP AT CARRID.
IF CARRID-HIGH NE ' '.
IF CARRID-LOW IS INITIAL.
MESSAGE W050(HB).
ENDIF.
ENDIF.
ENDLOOP.
If the user chooses the multiple selection button ( ) on the selection screen, and
then enters upper limits without lower limits in an interval field, a dialog box appears
with a warning:
SAP AG BC - ABAP Programming
Processing Multiple Selections
December 1999 771
Multiple Selection for SEL_OPT1
Single vals Intervals IntervalsSingle vals
X
To
To
To
To
To
AF LH
NW
Warning
Lower limit missing
Reenter
BC - ABAP Programming SAP AG
Defining Field Help

772 December 1999
Defining Field Help
If the data type of an input field declared in an executable program is defined in the ABAP
Dictionary, the documentation of the underlying data element is automatically displayed if the
user positions the cursor in that field and presses F1. To create help for input fields that have no
Dictionary reference, or to override the help normally linked to the field, you can create an event
block for the event
AT SELECTION-SCREEN ON HELP-REQUEST FOR <field>
The event is triggered when the user calls the F1 help for the field <field>. If no corresponding
event block has been defined, the help from the ABAP Dictionary is displayed, or none at all if the
field has no Dictionary reference. If a corresponding event block exists, it takes precedence over
the default help mechanism. It is then up to the programmer to ensure that appropriate help is
displayed.
You cannot declare the event block AT SELECTION-SCREEN ON HELP-REQUEST for input
fields on the selection screen that are declared within a logical database. You cannot override
the help mechanism of a logical database within the program. You can define separate help
within the logical database program using the HELP-REQUEST option in the PARAMETERS and
SELECT-OPTIONS statements.

REPORT SELECTION_SCREEN_F1_DEMO.
PARAMETERS: P_CARR_1 TYPE S_CARR_ID,
P_CARR_2 TYPE S_CARR_ID.
AT SELECTION-SCREEN ON HELP-REQUEST FOR P_CARR_2.
CALL SCREEN 100 STARTING AT 10 5
ENDING AT 60 10.
This program declares a selection screen with two parameters that both refer to the
data element S_CARR_ID in the ABAP Dictionary. The documentation from the
ABAP Dictionary is used for P_CARR_1, and a help screen 100 is called for
P_CARR_2. The help screen is defined in the Screen Painter as a modal dialog box
with next screen 0. It contains the help text defined as help texts. The screen does

not require any flow logic.
SAP AG BC - ABAP Programming
Defining Field Help
December 1999 773
P_CARR_1
P_CARR_2
Airline code
This field contains the code of the airline
The field contains the code of an airline that
collaborates with other airlines
ABAP-
Dictionary
BC - ABAP Programming SAP AG
Defining Input Help
774 December 1999
Defining Input Help
Suchhilfe für Parameter [Page 709]
If a field in an executable program is defined with reference to an ABAP Dictionary field for which
possible entries help is defined, the values from the ABAP Dictionary help are automatically
displayed when the user calls the F4 help for that field. To create possible values help for input
fields that have no Dictionary reference, or to override the help normally linked to the field, you
can create an event block for the event
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>
The event is triggered when the user calls the F4 help for the field <field>. If no corresponding
event block has been defined, the possible values help from the ABAP Dictionary is displayed, or
none at all if the field has no Dictionary reference. If a corresponding event block exists, it takes
precedence over the default possible values help mechanism. It is then up to the programmer to
ensure that an appropriate list of values is displayed, and that the user can choose a value from
it.
You cannot declare the event block AT SELECTION-SCREEN ON VALUE-REQUEST for input

fields on the selection screen that are declared within a logical database. You cannot override
the possible values help mechanism of a logical database within the program. You can define
separate help within the logical database program using the VALUE-REQUEST option in the
PARAMETERS and SELECT-OPTIONS statements.
REPORT SELECTION_SCREEN_F4_DEMO.
PARAMETERS: P_CARR_1 TYPE SPFLI-CARRID,
P_CARR_2 TYPE SPFLI-CARRID.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_CARR_2.
CALL SCREEN 100 STARTING AT 10 5
ENDING AT 50 10.
MODULE VALUE_LIST OUTPUT.
SUPPRESS DIALOG.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
SET PF-STATUS SPACE.
NEW-PAGE NO-TITLE.
WRITE 'Star Alliance' COLOR COL_HEADING.
ULINE.
P_CARR_2 = 'AC '.
WRITE: / P_CARR_2 COLOR COL_KEY, 'Air Canada'.
HIDE P_CARR_2.
P_CARR_2 = 'LH '.
WRITE: / P_CARR_2 COLOR COL_KEY, 'Lufthansa'.
HIDE P_CARR_2.
P_CARR_2 = 'SAS'.
WRITE: / P_CARR_2 COLOR COL_KEY, 'SAS'.
HIDE P_CARR_2.
SAP AG BC - ABAP Programming
Defining Input Help
December 1999 775
P_CARR_2 = 'THA'.

4 WRITE: / P_CARR_2 COLOR COL_KEY, 'Thai International'.
HIDE P_CARR_2.
P_CARR_2 = 'UA '.
WRITE: / P_CARR_2 COLOR COL_KEY, 'United Airlines'.
HIDE P_CARR_2.
CLEAR P_CARR_2.
ENDMODULE.
AT LINE-SELECTION.
CHECK NOT P_CARR_2 IS INITIAL.
LEAVE TO SCREEN 0.
This program defines a selection screen with two parameters, both of which refer to
the column CARRID in the database table SPFLI. The possible entries help from the
ABAP Dictionary is used for P_CARR_1, and a separate possible entries help is
programmed for P_CARR_2. Screen 100 is used for the possible entries help. The
dialog module VALUE_LIST is started in its PBO event. The actual screen mask is
not used, and there are no dialog modules used in the PAI.
PROCESS BEFORE OUTPUT.
MODULE VALUE_LIST.
PROCESS AFTER INPUT.
The dialog module VALUE_LIST suppresses the dialog of screen 100 and switches
to list processing. The list contains values for the parameter P_CARR_2. These
values are also placed in the HIDE area. When the user selects a line from the value
list, the AT LINE-SELECTION event is triggered, and the selected value is
transferred from the HIDE area into the field P_CARR_2. If the user selects a valid
line, the system switches directly from the event block AT LINE-SELECTION back to
the selection screen, and fills the corresponding input field.
BC - ABAP Programming SAP AG
Defining Input Help
776 December 1999
P_CARR_1

P_CARR_2
Airline code
ABAP
Dictionary
AA
AC
AF
AZ
BA
BL
CO

American Airlines
Air Canada
Air France
Alitalia
British Airways
Pacific Airlines
Continental Arlines

Star Alliance
AC
LH
SAS
THA
UA
Air Canada
Lufthansa
SAS
Thai International

United Airlines
User-Defined Value Help
SAP AG BC - ABAP Programming
Subscreens and Tabstrip Controls on
Selection Screens
December 1999 777
Subscreens and Tabstrip Controls on Selection Screens
Some of the complex screen elements [Page 641] that you can create in the Screen Painter for
screens can also be defined in ABAP programs for selection screens. For example, you can now
use tabstrip controls on selection screens. Since you need subscreens to work with tabstrip
controls, you can also now define selection screens as subscreens.
Selection Screens as Subscreens [Page 778]
Tabstrip Controls on Selection Screens [Page 783]
Subscreens on Selection Screens [Page 787]
BC - ABAP Programming SAP AG
Selection Screens as Subscreens
778 December 1999
Selection Screens as Subscreens
In the same way that you can define a screen as a subscreen [Page 653] in the Screen Painter, it
is now possible to define selection screens as subscreens in an ABAP program:
SELECTION-SCREEN BEGIN OF SCREEN <scrn> AS SUBSCREEN
[NO INTERVALS]
[NESTING LEVEL <n>].

SELECTION-SCREEN END OF SCREEN <scrn>.
Selection screens that you define in this way can be included in:
• Subscreens [Page 653] on screens
• Tabstrip Controls [Page 660] on screens
• Tabstrip Controls on Selection Screens [Page 783]
You cannot call them using CALL SELECTION-SCREEN.

If you use the NO INTERVALS addition, the subscreen is made smaller and the selection criteria
are all displayed with single input fields.
The NESTING LEVEL also reduces the size of the subscreen. You can use it to prevent
scrollbars from appearing when you use the subscreen in a tabstrip control on the selection
screen and the tabstrip already has a frame. If there is no frame around the tabstrip control, use
NESTING LEVEL 0. For each frame around the tabstrip control, increase NESTING LEVEL by
one.
When you include a selection screen as a subscreen on a screen or in a tabstrip control on a
screen, you should remember that the CALL SUBSCREEN statement is executed in both the
PBO and PAI events in the screen flow logic. Although you cannot program PAI modules for
selection screens as subscreens, the CALL SUBSCREEN statement ensures that the input data
is transferred to the ABAP program in the PAI event.
As on normal selection screens, the usual permitted user actions [Page 752] trigger the usual
selection screen processing [Page 759]. This allows you to check user input or process function
codes.
Examples
Selection screens as subscreens on screens.
REPORT demo_sel_screen_as_subscreen.
SELECTION-SCREEN BEGIN OF SCREEN 1100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
PARAMETERS: p1(10) TYPE c,
p2(10) TYPE c,
p3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF SCREEN 1100.
SELECTION-SCREEN BEGIN OF SCREEN 1200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-020.
SAP AG BC - ABAP Programming
Selection Screens as Subscreens
December 1999 779

PARAMETERS: q1(10) TYPE c OBLIGATORY,
q2(10) TYPE c OBLIGATORY,
q3(10) TYPE c OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF SCREEN 1200.
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA: number(4) TYPE n VALUE '1100'.
START-OF-SELECTION.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BUTTON1'.
number = 1100.
WHEN 'BUTTON2'.
number = 1200.
ENDCASE.
ENDMODULE.
AT SELECTION-SCREEN.
MESSAGE s888(sabapdocu) WITH text-030 sy-dynnr.
This defines two selection screens – 1100 and 1200 – as subscreens.
The next screen (statically defined) for screen 100 is itself. It has the following layout:

BC - ABAP Programming SAP AG
Selection Screens as Subscreens
780 December 1999
Subscreen 1 Subscreen 2
The screen contains a subscreen area AREA and two pushbuttons with the function
codes BUTTON1 and BUTTON2.
The screen flow logic for screen 100 is as follows:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
CALL SUBSCREEN area INCLUDING sy-repid number.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
CALL SUBSCREEN area.
MODULE user_command_0100.
When you run the program, a screen appears on which selection screen 1100 is
displayed as a subscreen. You can display either selection screen in the subscreen
area, using the pushbuttons to switch between them. Before you switch from
selection screen 1200 to 1100, you must fill out the obligatory fields. The data you
enter is available to the program in the parameters in the PAI event.
Selection screens as subscreens in a tabstrip control on a screen.
REPORT demo_sel_screen_in_tabstrip.
SELECTION-SCREEN BEGIN OF SCREEN 1100 AS SUBSCREEN
NO INTERVALS.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
PARAMETERS: p1(10) TYPE c,
p2(10) TYPE c,
p3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF SCREEN 1100.
SAP AG BC - ABAP Programming

Selection Screens as Subscreens
December 1999 781
SELECTION-SCREEN BEGIN OF SCREEN 1200 AS SUBSCREEN
NO INTERVALS.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-020.
PARAMETERS: q1(10) TYPE c OBLIGATORY,
q2(10) TYPE c OBLIGATORY,
q3(10) TYPE c OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF SCREEN 1200.
CONTROLS mytabstrip TYPE TABSTRIP.
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm.
DATA: number(4) TYPE n VALUE '1100'.
START-OF-SELECTION.
mytabstrip-activetab = 'BUTTON1'.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BUTTON1'.
mytabstrip-activetab = save_ok.
number = 1100.

WHEN 'BUTTON2'.
mytabstrip-activetab = save_ok.
number = 1200.
ENDCASE.
ENDMODULE.
AT SELECTION-SCREEN.
MESSAGE s888(sabapdocu) WITH text-030 sy-dynnr.
This defines two selection screens – 1100 and 1200 – as subscreens.
The next screen (statically defined) for screen 100 is itself. It has the following layout:
BC - ABAP Programming SAP AG
Selection Screens as Subscreens
782 December 1999
Tab title 1 Tab title 2
The screen contains a tabstrip area called MYTABSTRIP with three tab titles
BUTTON1, BUTTON2 and BUTTON3. The function codes have the same name, and
no special function type. All of the tab titles are assigned to a single subscreen area
AREA.
The screen flow logic for screen 100 is as follows:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
CALL SUBSCREEN area INCLUDING sy-repid number.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
CALL SUBSCREEN area.
MODULE user_command_0100.
This example is programmed in almost exactly the same way as the last one, and
behaves in the same way. The only difference is that the pushbuttons have been
replaced with tab titles, and the control MYTABSTRIP has been declared and filled.
Scrolling between the tab pages is programmed in the ABAP program. Each time
the user chooses a tab title, the function code from the OK_CODE field is assigned

to the ACTIVETAB component of structure MYTABSTRIP. At the same time, the
variable NUMBER is filled with the screen number of the subscreen that has to be
displayed in the subscreen area AREA of the tabstrip control.
SAP AG BC - ABAP Programming
Tabstrip Controls on Selection Screens
December 1999 783
Tabstrip Controls on Selection Screens
As with screens, you can now use tabstrip controls [Page 660] on selection screens. To do this,
you must define a tabstrip area and the associated tab pages, and assign a subscreen to the tab
pages. You do not have to (indeed, cannot) declare the tabstrip control or program the screen
flow logic in your ABAP program, since both are automatically generated.
To define a tabstrip area with tab pages, use the following statements in your selection screen
definition:
SELECTION-SCREEN: BEGIN OF TABBED BLOCK <tab_area> FOR <n> LINES,
TAB (<len>) <tab1> USER-COMMAND <ucom1>
[DEFAULT [PROGRAM <prog>] SCREEN <scrn>],
TAB (<len>) <tab2> USER-COMMAND <ucom2>
[DEFAULT [PROGRAM <prog>] SCREEN <scrn>],

END OF BLOCK <tab_area>.
This defines a tabstrip control <tab_area> with size <n>. The tab pages <tab1>, <tab2>… are
assigned to the tab area. <len> defines the width of the tab title. You must assign a function
code <ucom> area to each tab title. You can find out the function code from the field SY-UCOMM
in the AT SELECTION-SCREEN event.
For each tab title, the system automatically creates a character field in the ABAP program with
the same name. Before the selection screen is displayed, you can assign a text to the field. This
then appears as the title of the corresponding tab page on the selection screen.
You must assign a subscreen to each tab title. This will be displayed in the tab area when the
user chooses that title. You can assign one of the following as a subscreen:
• A subscreen screen [Page 653] defined using the Screen Painter.

• A selection screen subscreen [Page 778], defined in an ABAP program.
You can make the assignment either statically in the program or dynamically at runtime. If, at
runtime, one of the tab titles has no subscreen assigned, a runtime error occurs.
• Static assignment
Use the DEFAULT addition when you define the tab title. You can specify an ABAP
program and one of its subscreens. If you do not specify a program, the system looks for
the subscreen in the current program. When the user chooses the tab title, it is
activated, and the subscreen is assigned to the tabstrip area. The static assignment is
valid for the entire duration of the program, but can be overwritten dynamically before the
selection screen is displayed.
• Dynamic assignment
For each tab area, the system automatically creates a structure in the ABAP program
with the same name. This structure has three components – PROG, DYNNR, and
ACTIVETAB. When you assign the subscreens statically, the structure contains the
name of the ABAP program containing the subscreen, the number of the subscreen, and
the name of the tab title currently active on the selection screen (and to which these
values are assigned). The default active tab page is the first page. You can assign
values to the fields of the structure before the selection screen is displayed, and so set a
subscreen dynamically.
BC - ABAP Programming SAP AG
Tabstrip Controls on Selection Screens
784 December 1999
If you assign a normal subscreen screen to a tab title, the dialog modules containing its flow logic
must be defined in the current ABAP program. If the subscreen is a selection screen, user
actions will trigger the AT SELECTION-SCREEN event and its variants (see Selection Screen
Processing [Page 759]). This includes when the user chooses a tab title. If one selection screen
is included on another, AT SELECTION-SCREEN will be triggered at least twice – firstly for the
“included” selection screen, then for the selection screen on which it appears.
REPORT demo_sel_screen_with_tabstrip.
DATA flag(1) TYPE c.

* SUBSCREEN 1
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p1(10) TYPE c,
p2(10) TYPE c,
p3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF SCREEN 100.
* SUBSCREEN 2
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
PARAMETERS: q1(10) TYPE c OBLIGATORY,
q2(10) TYPE c OBLIGATORY,
q3(10) TYPE c OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF SCREEN 200.
* STANDARD SELECTION SCREEN
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES,
TAB (20) button1 USER-COMMAND push1,
TAB (20) button2 USER-COMMAND push2,
TAB (20) button3 USER-COMMAND push3
DEFAULT SCREEN 300,
END OF BLOCK mytab.
INITIALIZATION.
button1 = text-010.
button2 = text-020.
button3 = text-030.
mytab-prog = sy-repid.
mytab-dynnr = 100.
mytab-activetab = 'BUTTON1'.

AT SELECTION-SCREEN.
CASE sy-dynnr.
WHEN 1000.
CASE sy-ucomm.
WHEN 'PUSH1'.
mytab-dynnr = 100.
mytab-activetab = 'BUTTON1'.
WHEN 'PUSH2'.
SAP AG BC - ABAP Programming
Tabstrip Controls on Selection Screens
December 1999 785
mytab-dynnr = 200.
mytab-activetab = 'BUTTON2'.
ENDCASE.
WHEN 100.
MESSAGE s888(sabapdocu) WITH text-040 sy-dynnr.
WHEN 200.
MESSAGE s888(sabapdocu) WITH text-040 sy-dynnr.
ENDCASE.
MODULE init_0100 OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'MOD'.
CASE flag.
WHEN 'X'.
screen-input = '1'.
WHEN ' '.
screen-input = '0'.
ENDCASE.
MODIFY SCREEN.
ENDIF.

ENDLOOP.
ENDMODULE.
MODULE user_command_0100 INPUT.
MESSAGE s888(sabapdocu) WITH text-050 sy-dynnr.
CASE sy-ucomm.
WHEN 'TOGGLE'.
IFflag=''.
flag = 'X'.
ELSEIF flag = 'X'.
flag=''.
ENDIF.
ENDCASE.
ENDMODULE.
START-OF-SELECTION.
WRITE: / 'P1:', p1,'Q1:', q1,
/ 'P2:', p2,'Q2:', q2,
/ 'P3:', p3,'Q3:', q3.
This program defines two selection screens – 100 and 200, as subscreens, and
places a tabstrip control area with three tab pages on the standard selection screen.
A subscreen screen 300 (from the same program) is assigned statically to the third
tab page.
The layout of screen 300 is:
BC - ABAP Programming SAP AG
Tabstrip Controls on Selection Screens
786 December 1999
Display/Change
Subscreen screen
P1 Q1
P2 Q2
P3 Q3

The input/output fields P1 to Q3 are defined by using [Extern] the parameters from
the ABAP program The pushbutton has the function code TOGGLE.
The screen flow logic for screen 300 is as follows:
PROCESS BEFORE OUTPUT.
MODULE init_0100.
PROCESS AFTER INPUT.
MODULE user_command_0100.
Both dialog modules are defined in the ABAP program.
When you run the program, the standard selection screen appears. In the
INITIALIZATION event, the texts are defined on the tab titles, the subscreen
selection screen 100 is assigned to the tab area, and the first tab title is activated.
User actions on the selection screen are processed in the AT SELECTION-SCREEN
event block. In particular, it is here that the subscreens are assigned and tab titles
activated when the user chooses one of the first two tab titles. This is not necessary
for the third tab title, since the dynamic assignment (screen 300) is always placed in
the structure MYTAB when the user chooses it.
Before the subscreen screen is displayed, the PBO module INIT_100 is executed.
User actions on the subscreen screen trigger the PAI module. This includes when
the user chooses a tab title. After that, the AT SELECTION-SCREEN event is
triggered.
Messages in the status line show where an action has been processed.
SAP AG BC - ABAP Programming
Subscreens on Selection Screens
December 1999 787
Subscreens on Selection Screens
Displaying a subscreen in a subscreen area on a selection screen is a special case of a tabstrip
control on a selection screen [Page 783]. To define a subscreen area on a selection screen, use
these statements:
SELECTION-SCREEN: BEGIN OF TABBED BLOCK <sub_area> FOR <n> LINES,
END OF BLOCK <sub_area>.

Defining a subscreen area is the equivalent of defining a tabstrip area without tab titles. Before
the selection screen is displayed, you
must assign a subscreen to the subscreen area
<sub_area>. To do this, use the components PROG and DYNNR of the structure <sub_area>,
which is created automatically when you define the subscreen area. Assign the program name
of the subscreen screen to the component PROG, and its screen number to DYNNR. You can
use the following subscreens:
• A subscreen screen [Page 653] defined using the Screen Painter.
• A selection screen subscreen [Page 778], defined in an ABAP program.
If you have not assigned a subscreen when the selection screen is displayed, a runtime error
occurs.
REPORT demo_sel_screen_with_subscreen.
TABLES sscrfields.
* SUBSCREEN 1
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
PARAMETERS: p1(10) TYPE c,
p2(10) TYPE c,
p3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN END OF SCREEN 100.
* SUBSCREEN 2
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-020.
PARAMETERS: q1(10) TYPE c,
q2(10) TYPE c,
q3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF SCREEN 200.
* SUBSCREEN 3

SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-030.
PARAMETERS: r1(10) TYPE c,
r2(10) TYPE c,
r3(10) TYPE c.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN END OF SCREEN 300.
BC - ABAP Programming SAP AG
Subscreens on Selection Screens
788 December 1999
* STANDARD SELECTION SCREEN
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK sub FOR 10 LINES,
END OF BLOCK sub.
INITIALIZATION.
sscrfields-functxt_01 = '@0D@'.
sscrfields-functxt_02 = '@0E@'.
sub-prog = sy-repid.
sub-dynnr = 100.
AT SELECTION-SCREEN.
CASE sy-dynnr.
WHEN 100.
IF sscrfields-ucomm = 'FC01'.
sub-dynnr = 300.
ELSEIF sscrfields-ucomm = 'FC02'.
sub-dynnr = 200.
ENDIF.
WHEN 200.
IF sscrfields-ucomm = 'FC01'.

sub-dynnr = 100.
ELSEIF sscrfields-ucomm = 'FC02'.
sub-dynnr = 300.
ENDIF.
WHEN 300.
IF sscrfields-ucomm = 'FC01'.
sub-dynnr = 200.
ELSEIF sscrfields-ucomm = 'FC02'.
sub-dynnr = 100.
ENDIF.
ENDCASE.
START-OF-SELECTION.
WRITE: / 'P1:', p1,'Q1:', q1, 'R1:', r1,
/ 'P2:', p2,'Q2:', q2, 'R2:', r2,
/ 'P3:', p3,'Q3:', q3, 'R3:', r3.
This program defines three subscreen selection screens, 100, 200, and 300. It also
defines a subscreen area SUB on the standard selection screen. There are two
pushbuttons in the application toolbar.
In the INITIALIZATION event, the subscreen selection screen 100 is assigned to the
subscreen area. In the AT SELECTION-SCREEN event, the function keys are
processed, and one of the other subscreens is assigned according to the user’s
choice.
SAP AG BC - ABAP Programming
Using Selection Criteria
December 1999 789
Using Selection Criteria
When you define selection criteria, selection tables of the same name are declared in the
program. The selections that the user specifies on the selection screen are stored in the rows of
these tables in a standardized format. So that the program must not explicitly process the
structure of the selection tables [Page 719] and their contents, selection tables can be addressed

as a whole in certain ABAP statements. In these statements, complex selections are analyzed in
a selection table. The programmer does not have to deal with their logic.
Selection Tables in the WHERE Clause [Page 790]
Selection Tables in Logical Expressions [Page 791]
Selection Tables in GET Events [Page 794]
BC - ABAP Programming SAP AG
Selection Tables in the WHERE Clause
790 December 1999
Selection Tables in the WHERE Clause
The WHERE clause is an addition to Open SQL statements SELECT, UPDATE, and DELETE,
and is used to restrict the values read during database accesses [Page 1078].
To use a selection table in the WHERE clause, you write:
WHERE <f> IN <seltab>.
<f> is the name of a database column, and <seltab> is the selection table that is assigned to this
field. The relevant Open SQL statement accesses only those rows of the database table, where
the contents of field <f> meet the selection criteria stored in <seltab>.

REPORT DEMO.
DATA WA_CARRID TYPE SPFLI-CARRID.
SELECT-OPTIONS AIRLINE FOR WA_CARRID.
SELECT CARRID FROM SPFLI INTO WA_CARRID WHERE CARRID IN
AIRLINE.
WRITE WA_CARRID.
ENDSELECT.
Selection table AIRLINE is linked to the CARRID column of database table SPFLI.
The WHERE clause of the SELECT statement checks if the contents of the CARRID
column meet the selection criteria stored in AIRLINE.
If the selection table is filled as follows:
SIGN OPTION LOW HIGH
IBT DLUA

EEQ LH
Then the database rows for all airlines between DL and UA except LH are read.
SAP AG BC - ABAP Programming
Selection Tables in Logical Expressions
December 1999 791
Selection Tables in Logical Expressions
To check if the value of a field meets the conditions in a selection table, you can use the following
special logical expression [Page 226]:
<f> IN <seltab>
This logical expression is true if the contents of field <f> meet the conditions stored in selection
table <seltab>. <f> can be any elementary field.
If field <f> is identical to the field for which selection table <seltab> has been declared using
SELECT-OPTIONS, you can use the following shortened form for the logical expression:
<seltab>
This shortened form is not possible for selection tables defined using the RANGES statement.

REPORT DEMO.
DATA WA_CARRID TYPE SPFLI-CARRID.
SELECT-OPTIONS AIRLINE FOR WA_CARRID.
WRITE: 'Inside', 'Outside'.
SELECT CARRID FROM SPFLI INTO WA_CARRID.
IF WA_CARRID IN AIRLINE.
WRITE: / WA_CARRID UNDER 'Inside'.
ELSE.
WRITE: / WA_CARRID UNDER Outside'.
ENDIF.
ENDSELECT.
If the selection table is filled as follows:
SIGN OPTION LOW HIGH
IBT DLUA

EEQ LH
The list output appears as follows:
BC - ABAP Programming SAP AG
Selection Tables in Logical Expressions
792 December 1999
Selection tables in logical expressions 1
Inside Outside
AA
AA
AA
AZ
AZ
AZ
AZ
AZ
DL
DL
LH
LH
LH
LH
In the SELECT loop, all rows are read from database table SPFLI. If the IF statement
is used, the program flow is branched into two statement blocks depending on the
logical expression. The shortened form IF AIRLINE is also possible in this program.
REPORT DEMO.
DATA WA_SPFLI TYPE SPFLI.
SELECT-OPTIONS: S_CARRID FOR WA_SPFLI-CARRID,
S_CITYFR FOR WA_SPFLI-CITYFROM,
S_CITYTO FOR WA_SPFLI-CITYTO,
S_CONNID FOR WA_SPFLI-CONNID.

SELECT * FROM SPFLI INTO WA_SPFLI.
CHECK: S_CARRID,
S_CITYFR,
S_CITYTO,
S_CONNID.
WRITE: / WA_SPFLI-CARRID, WA_SPFLI-CONNID,
WA_SPFLI-CITYFROM, WA_SPFLI-CITYTO.
ENDSELECT.
After starting the program, the selection screen appears, on which the user might fill
the input fields as follows:

×