Upload
lucian-povatanu
View
220
Download
0
Embed Size (px)
Citation preview
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
1/23
0
SAP AG 1999
Selection screen attributes and strengths
Defining selection screens
Evaluating user input to restrict database selection
Selection screen events
Example with syntax: Additional input checks with errordialog
Contents:
ser Dialogs: Selection Screens
(C) SAP AG BC400 8-1
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
2/23
0!"
SAP AG 1999
At the conclusion of this unit# you will be able to:
ser Dialogs: Selection Screens: nit $b%ectives
Describe selection screen attributes andstrengths
&rite a program that allows the user to inputintervals on a selection screen that can be used torestrict the number of data records retrieved fromthe database
&rite a program containing additional inputchecks on its selection screen which re'send theselection screen when an error occurs
(C) SAP AG BC400 8-2
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
3/23
0!(
SAP AG 1999
Selection Screen
Database)able
A*A++rocessing*lock
A*A+ ,untime System
A*A+ +rogram
Data $b%ects
Selection screens allow users to enter selection criteria required by the program.For example, if you create a list containing data from a very large database table, you can use aselection screen to restrict the amount of data that is selected. At runtime, the user can enter intervalsfor one of the key fields, and only data in this interval is read from the database anddisplayed in the list. This considerably reduces the load on the network.
(C) SAP AG BC400 8-3
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
4/23
0!-
SAP AG 1999
ValueValueEntryEntry
Multilingual Capa ityMultilingual Capa ity
!!!!!!
Variant!Variant!
Sear " #elpSear " #elp
$ype "e %!$ype "e %!
)he Selection Screen
Selection screens are designed to present users with an input template allowing them to enterselections, which reduce the amount of data that has to be read from the database. The following
possibilities are available to the user!ntries to single fieldsComplex entries: "ntervals, operations, patternsSaving selections fields filled with values as variants"nput help and search helps are available by choosing the F# function key or the possible entries
pushbutton$ou can translate selection texts into other languages so that they are then displayed in the languagein which the user is logged on.The system checks types automatically. "f you enter a value with an incorrect type, the systemdisplays an error message and makes the field ready to accept your corrected entry.
(C) SAP AG BC400 8-4
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
5/23
0!.
SAP AG 1999
SELECT-OPTIONS ...
PARAMETERS ... Departing from
Airline Carrier / to
S1231
$+)1$32E
/$&/
Airline Carrier
Single value2reater than or e4ual
2reater than/ess than3ot e4ual
Sele t
E& lu'e r * !ele ti n
Maintain Sele ti n +pti n!Maintain Sele ti n +pti n!
Airline Carrier
,e!! t"an r e ual,e!! t"an r e ual
5ultiple single values#1ntervals#Single value exclusion#1nterval exclusion
...
Entering Selections
Selection screens allow you to enter complex selections as well as single%value selections. Functionsof selection options programming include
Setting selection options!ntering multiple values or intervals&efining a set of exclusionary criteria for data selection
!very selection screen contains an information icon. 'hoose this icon to display additionalinformation.
(C) SAP AG BC400 8-/
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
6/23
0!6
SAP AG 1999
Airline Carrier
Search elpSearch elp
ABAP 0i ti)nary
Sear " #elp
7light no! to
DATA: wa LIKE spfli.PARAMETERS pa_car TYPE spfli-carrid.SELECT-OPTIONS so_co !OR wa-co id.
.
0-00
0-0"
epart.airp rt7,A
7,A
Arri .airp rt879
879
epartureti*e
0: 0:00
(:(0:00
/
/
C"e % $a le!
ata ele*ent
$a le iel'
Stru ture 5iel'
Search elp
"f you refer an input field to an A(A) &ictionary ob*ect to which a search help is assigned, thesystem automatically provides the corresponding possible values help.$ou can adapt the possible values help to meet your own requirements by defining a search help inthe A(A) &ictionary.
(C) SAP AG BC400 8-6
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
7/23
0!;
SAP AG 1999
Source Code )ext elements)itle< eaders
+rogram
)ext symbols
S$=CA,,
+A=C1)>
Selection )exts
E3 Airline carrier DE
E3 Departing fromDE...
Departing from
Airline Carrier / to
5ultilingual Capacity5ultilingual Capacity
REPORT "c#$$%d_s&l&c%io _scr&& .:
SELECT-OPTIONS so_carr !OR ...PARAMETERS pa_ci%' TYPE ...
Selection )exts
+n the selection screen, the names of the variables appear next to the input fields. owever, you canreplace these with selection texts, which you can then translate into any further languages yourequire. Selection texts are displayed in the user-s logon language.
(C) SAP AG BC400 8-7
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
8/23
0!?
SAP AG 1999
...
Departing from
Airline Carrier AA /to
@ariantCA,,1E,=AA=)$=/ :
Airlines AA to /
ide input field
@ariants
Departing from
$ou can define and store variants for any selection screen. $ou do this by starting the program andchoosing ariants %/ Save as variant.
ariants allow you to make selection screens easier to use by end users by)re%assigning values to input fields
iding input fieldsSaving these settings for reuse
A single variant can refer to more than one selection screen.ariants are client specific.
"f you choose the information icon 0on any selection screen1, the system will display moreinformation about variants. $ou can also find out more in course ('#23 Techniques of List
Processing .
(C) SAP AG BC400 8-8
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
9/23
0!
SAP AG 1999
,ecap: +A,A5E)E,S
PARAMETERS pa_carTYPE s_carr_id.
A*A+ ,untime System
A*A+ +rogram
PARAMETERSPARAMETERS
A*A++rocessing*lock
pa_car
/ocally Defined )ypes and 7ields
SelectionScreen
referenceA*A+ Dictionary
s_carr_id
"n an executable program, a single PARAMETERS statement is sufficient to generate a standardselection screen.The PARAMETERS ( a)&* TYPE (%'p&* statement and the PARAMETERS ( a)&* LIKE
(da%a o"+&c%* statement both generate a simple input field on the selection screen, and a dataob*ect ( a)&* with the type you have specified."f the user enters a value and chooses -!xecute-, that value is placed in the internal data ob*ect
( a)&* in the program. The system will only permit entries with the appropriate type.
(C) SAP AG BC400 8-9
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
10/23
0! 0
SAP AG 1999
Data )ransport
PARAMETERS pa_carTYPE s_carr_id.
A*A+ ,untime System
A*A+ +rogram
A*A++rocessing*lock
pa_car
)ime
/ocally Defined )ypes and 7ields
Selection
Screen
SelectionScreen
pa_car pa_car
pa_car pa_car
+nce the INITIALI,ATION event block has been processed, the selection screen is sent to the presentation server. The runtime system transports the data ob*ect values that are defined usingPARAMETERSto the selection screen input fields of the same name.The user can then change the values in the input fields. "f the user then clicks on the -!xecute-function, the input field values are transported to the program data ob*ects with the same name andcan be evaluated in the A(A) processing blocks.
(C) SAP AG BC400 8-10
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
11/23
0!
SAP AG 1999
sing +arameters in the SE/EC) Statement
REPORT ...DATA wa_spfli TYPE spfli.PARAMETERS pa_car TYPE s_carr_id....SELECT carrid co id ci%'fro) ci%'%o ...
!ROM spfliINTO CORRESPONDIN !IELDS O! wa_spfli
/ERE carrid 0 pa_car.
RITE: 1 wa_spfli-carrid2 wa_spfli-co id2 wa_spfli-flda%&2 ... .ENDSELECT.
/ERE carrid 0 pa_car
SELECT
ENDSELECT
"f you have used the PARAMETERS statement to program an input field as a key field for a databasetable, you can use a /ERE clause at the SELECT statement to limit data selection to this value."n the example above only those data records are read from database table SP!LI whose key fieldCARRID have the same value as is contained in data ob*ect pa_car at runtime.
(C) SAP AG BC400 8-11
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
12/23
0! "
SAP AG 1999
SE/EC)'$+)1$3S
A*A+ ,untime System
A*A+ +rogram
A*A++rocessing*lock
so_carr
SelectionScreen
3d_carrid
DATA 3d_carrid TYPE s_carr_id.SELECT-OPTIONS so_carr
!OR 3d_carrid.
/ocally Defined )ypes and 7ields
SELECTSELECT-- OPTIONSOPTIONS
Si3 low 4i34op%io
The statement SELECT-OPTIONS !OR defines a selection optionThis places two input fields on the selection screen, with the same type that you have defined in thereference. This enables users to enter a value range or complex selections. The statement alsodeclares an internal table 4name/ within the program, with the following four columns
si3 This field designates whether the value or interval should be included in or excludedfrom the selection.op%io This contains the operator For a list of possible operators, see the keyworddocumentation for the SELECT-OPTIONS statement.low This field contains the lower limit of a range, or a single value.4i34 This field contains the upper limit of a range.
Selection table ( a)&* always refers to a data ob*ect that has already been declared. This dataob*ect serves as a target field during database selection, the selection table as a pool of possiblevalues. A special version of the /ERE clause exists for database selection. "t determines whether ornot the database contains the corresponding field within its pool of possible values .
(C) SAP AG BC400 8-12
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
13/23
0! (
SAP AG 1999
Data )ransport
A*A+ ,untime System
A*A+ +rogram
A*A++rocessing*lock
so_carr
Selection
Screen
SelectionScreen
)ime
wa_scarr
DATA 3d_carrid TYPE s_carr_id.SELECT-OPTIONS so_carr
!OR 3d_carrid.
/ocally Defined )ypes and 7ields
so_ so_ carrcarr
3d_carrid
so_ so_ carrcarr
"f the user enters several values or intervals for a selection option and chooses -!xecute-, the system places them in the internal table.
(C) SAP AG BC400 8-13
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
14/23
0! -
SAP AG 1999
sing +arameters in the SE/EC) Statement "
REPORT ...DATA A_SP!LI TYPE SP!LI.SELECT-OPTIONS so_carr !OR wa_spfli-carrid....SELECT carrid co id ci%'fro) ci%'%o ...
!ROM spfliINTO CORRESPONDIN !IELDS O! wa_spfli
/ERE carrid IN so_carr.
RITE: 1 wa_spfli-carrid2 wa_spfli-co id2 wa_spfli-ci%'fro)2 wa_spfli-ci%'%o2 ... .ENDSELECT.
/ERE carrid IN so_carr
SELECT
ENDSELECT
The above example shows how you can restrict database selection to a certain range using a selectiontable.'onditions in an internal table declared using SELECT-OPTIONS are interpreted as follows
"f the internal table is empty, the condition (fi&ld* IN (s&l a)&* is always true."f the internal table only contains simple inclusive conditions i5 , ...2 i , the result is thecomposite condition 0 i5 OR ... OR i 6 ."f the internal table only contains simple exclusive conditions e5, ..., em, the result is thecomposite condition 7 NOT &5 6 AND ... AND 7 NOT &) 6 ."f the internal table contains both the simple inclusive conditions i5 , ...2 i and the simpleexclusive conditions &5, ...2 &) , the result is the composite condition 7 i5 OR ... ORi 6 AND 7 NOT &5 6 AND ... AND 7 NOT &) 6 .
(C) SAP AG BC400 8-14
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
15/23
0! .
SAP AG 1999
Selection Screen Events
)ime
A*A+ ,untime System
A*A+ +rogram
INITIALI,ATION.
START-O!-SELECTION
AT SELECTION-SCREEN.
3o >es
+rogramStart
"n an executable program, the A(A) runtime system generates a standard selection screen as long asyou have written at least one PARAMETERS or SELECT-OPTIONS statement. The selection screen
belongs to the event block AT SELECTION-SCREEN .The selection screen is displayed after the event block INITIALI,ATION . !ach time the user presses !nter, a pushbutton, a function key, or chooses a menu function, thesystem carries out a type check. "f the entries do not have the correct type, the system displays anerror message, and makes the fields ready for input again. 6hen the data types have been corrected,the system triggers the AT SELECTION-SCREEN event.Subsequent program flow depends on the user action
"f the user chose F7 or -!xecute-, the next event block is called "n this case, START-O!-SELECTION."f the user chose any other function, the selection screen is redisplayed.
(C) SAP AG BC400 8-1/
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
16/23
0! 6
SAP AG 1999
Error Dialogs in A) SE/EC)1$3'SC,EE3
)ime
+rogramStart
A*A+ ,untime System
A*A+ +rogram
INITIALI,ATION.
START-O!-SELECTION
AT SELECTION-SCREEN. MESSA E &$$5.
3o >es
MESSA E &$$5.
8se the event block AT SELECTION-SCREEN whenever you want to program additional inputchecks for a standard selection screen.The event block AT SELECTION-SCREEN is triggered by each user action. "f an error dialog istriggered, the system *umps back to the selection screen and automatically resets all input fields toready for input and displays a message in the status line.For more detailed information on the MESSA E statement, refer to the keyword documentation aswell.Additional information can be found in the keyword documentation for AT SELECTION-SCREEN !
(C) SAP AG BC400 8-16
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
17/23
0! ;
SAP AG 1999
A) SE/EC)1$3'SC,EE3 Syntax
PARAMETERS: pa_car TYPE s_carr_id.
8 !irs% &9& % proc&ss&d af%&r l&a9i 3 %4& s&l&c%io scr&& AT SELECTION-SCREEN.
A T/ORITY-C/ECK O;T= !IELD ac%9%_displa'.
I! s'-s?"rc (* $.8 S4ow s&l&c%io scr&& a3ai a d s4ow )&ssa3& i s%a%?s "ar MESSA E &$#@7"c#$$6 IT/ pa_car.
ENDI!.
AT SELECTION-SCREEN.
MESSA E &$#@7"c#$$6 IT/ pa_car.
As an example of an additional input check with error dialog, an input field for the airline "& needsto be added to the programAn authori9ation check is carried out on the selection screen.
"f the user has display authori9ation for the airline entered, the program continues."f the user does not have display authori9ation, then the selection screen is displayed again and anerror message appears in the status bar.
(C) SAP AG BC400 8-17
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
18/23
0! ?
SAP AG 1999
>ou are now able to:
ser Dialogs: Selection Screens: nit Summary
Describe selection screen attributes and strengths
&rite a program that allows the user to inputintervals on a selection screen that can be used torestrict the number of data records retrieved fromthe database
&rite a program containing additional input
checks on its selection screen which re'send theselection screen when an error occurs
(C) SAP AG BC400 8-18
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
19/23
0! Selection Screen: Exercises
Unit: Selection Screen
At the conclusion of these exercises, you will be able to
• 8se the A(A) statement SELECT-OPTIONS to enter complex valueson a standard selection screen.
• Take account of complex values in a database selection.
• )rogram an error message for a standard selection screen
!xtend your program ,;C#$$_ _DETAIL_LIST or thecorresponding model solution as follows)rovide the user with a means of entering a complex value set for theflight number. Take the values into account in your database selection.Additionally, change your program so that the user can only progressfrom the selection screen if the authori9ation check for the desired airlineis successful.
Program: ,;C#$$_ _SEL_SCREENModel solution: SAP;C#$$ DS_SEL_SCREEN
5%5 'opy your program ,;C#$$_ _DETAIL_LIST or the corresponding modelsolution SAP;C#$$_ DS_DETAIL_LIST to the program,;C#$$_ _SEL_SCREEN . Assign your program to development class,;C#$$_ and the change request for your pro*ect :('#22;< 0== is your group
number1.
5%> !xtend your selection screen to allow the user to enter a complex value range forthe flight number CONNID.
5%? 8se the complex value selection to restrict the amount of data selected from thedatabase table S!LI /T .
5%# 'hange your program so that the user cannot progress from the selection screen ifthe authori9ation check against the authori9ation ob*ect S_CARRID fails. "f the
authori9ation check fails, display a suitable error message from message class('#22, and allow the user to enter a different value on the selection screen.
(C) SAP AG BC400 8-19
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
20/23
(C) SAP AG BC400 8-20
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
21/23
0!"0 Solutions
Unit: Selection Screen
Model solution: Program SAP;C#$$ DS_SEL_SCREEN
*&--------------------------------------------------------------*
*& Report SAPBC400UDS_SEL_SCREE *
*& *
*&--------------------------------------------------------------*
REP!R" #apbc400$d#_#e%_#creen
C! S"A "S act't_d(#p%a) " PE act('_a$t+ ,ALUE 0.
DA"A/ a_1%(2+t " PE #bc4001occ3
a_#boo " PE #boo
PARA5E"ERS/ pa_car " PE #1%(2+t-carr(d
8 Da%a fi&ld for co)pl&B r&s%ric%io s appli&d %o co &c%io id
SELECT-OPTIONS: so_co !OR wa_fli34%-co id.
8 !irs% &9& % proc&ss&d af%&r l&a9i 3 %4& s&l&c%io scr&&
AT SELECTION-SCREEN.
A T/ORITY-C/ECK O;T= !IELD ac%9%_displa'.
I! s'-s?"rc (* $.
8 R&%?r %o s&l&c%io scr&& a3ai a d displa' )&ssa3& i s%a%?s 8 "ar
MESSA E &$#@7"c#$$6 IT/ pa_car.
ENDI!.
S"AR"-!6-SELEC"7!
(C) SAP AG BC400 8-21
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
22/23
SELEC" carr(d conn(d 1%date #eat#ma8 #eat#occ 6R!5 #1%(2+t
7 "! C!RRESP! D7 9 67ELDS !6 a_1%(2+t
:;ERE carr(d pa_car
A D conn(d 7 #o_con
a_1%(2+t-percenta2e
=00 * a_1%(2+t-#eat#occ a_1%(2+t-#eat#ma8 :R7"E/ a_1%(2+t-carr(d C!L!R C!L_?E 3
a_1%(2+t-conn(d C!L!R C!L_?E 3
a_1%(2+t-1%date C!L!R C!L_?E 3
a_1%(2+t-#eat#occ3
a_1%(2+t-#eat#ma83
a_1%(2+t-percenta2e3 @
;7DE/ a_1%(2+t-carr(d3 a_1%(2+t-conn(d3 a_1%(2+t-1%date
E DSELEC"
A" L7 E-SELEC"7!
76 #)-%#(nd =
:R7"E/ a_1%(2+t-carr(d3 a_1%(2+t-conn(d3 a_1%(2+t-1%date
UL7 E
S?7P
SELEC" boo (d c$#tom(d c$#tt)pe c%a## order_date
#mo er cance%%ed %occ$ram %occ$r e) 6R!5 #boo 7 "! C!RRESP! D7 9 67ELDS !6 a_#boo
:;ERE carr(d a_1%(2+t-carr(d
A D conn(d a_1%(2+t-conn(d
A D 1%date a_1%(2+t-1%date
:R7"E/ a_#boo -boo (d3
a_#boo -c$#tom(d3
a_#boo -c$#tt)pe3
a_#boo -c%a##3 a_#boo -order_date3
a_#boo -#mo er3
a_#boo -cance%%ed3
a_#boo -%occ$ram CURRE C a_#boo -%occ$r e)3
a_#boo -%occ$r e)
E DSELEC"
E D76
(C) SAP AG BC400 8-22
8/16/2019 EXP_0008 User Dialogs_Selection Screens.doc
23/23