Obligatory Selection Screen Parameters - ABAP Police
Obligatory Selection Screen Parameters - ABAP Police
ObligatoryselectionscreenparametersABAPPolice
Obligatoryselectionscreen
parameters
Almost every ABAP developer comes to a point where they require obligatory parameters along
withusercommandlogicintheirselectionscreens.Asyoumightalreadyknow,thatsaproblem.
Because obligatory parameters demand input on every action of user and interfere with user
commandlogic,whichresultsinabrokenselectionscreen.Letsseeanexample.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PARAMETERSp_bukrsTYPEt001bukrsOBLIGATORY.
PARAMETERSp_sumRADIOBUTTONGROUPr01DEFAULT'X'USERCOMMAND
PARAMETERSp_detRADIOBUTTONGROUPr01.
PARAMETERSp_subASCHECKBOX.
ATSELECTIONSCREENOUTPUT.
IFp_det=space.
LOOPATSCREEN.
IFscreenname='P_SUB'.
screeninput=0.
MODIFYSCREEN.
ENDIF.
ENDLOOP.
ENDIF.
Assoonaswerunthereport,wesee
enabledwhenweclick
P_DET
P_SUB
parameterasinputdisabledandweexpectittobe
radiobutton.Butno
Company Code field demands input and Display subtotal field is still disabled although
Detailradiobuttonisalreadyselected,whichmeansourselectionscreenisbroken.Thiscertainly
isnotdesired.Theoutcomegetsevenfunnierifuse
OBLIGATORY
additionforaselectoption.We
arenotallowedtoclickextensionbuttontoenteranintervaltotheverysameselectoption!
Mostlikely,SAPintendedtomakethingseasierforusbyautomatingrequiredfieldvalidationwith
a simple
OBLIGATORY
addition. But almost every time, this validation is only required after
executing the report, not on every user action. Fortunately SAP also provided us with a
workaround:therecommendedfield.Ifweassignvalue
tothe
REQUIRED
attributeofscreen,
the field becomes recommended, which means we still see the checkmark in field which
http://abappolice.com/2015/04/obligatoryselectionscreenparameters/#more35
1/2
8/3/2016
ObligatoryselectionscreenparametersABAPPolice
indicatesthefieldexpectsanentrybutnoautomatedvalidationwillrun.Soitisuptouswhenand
howtherequiredfieldvalidationwouldtakeplace.Inordertofixourpreviouscode,weneedan
assignmenttoaselectionscreenfieldattribute,plusthevalidationcode.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PARAMETERSp_bukrsTYPEt001bukrs.
PARAMETERSp_sumRADIOBUTTONGROUPr01DEFAULT'X'USERCOMMAND
PARAMETERSp_detRADIOBUTTONGROUPr01.
PARAMETERSp_subASCHECKBOX.
ATSELECTIONSCREENOUTPUT.
LOOPATSCREEN.
CASEscreenname.
WHEN'P_BUKRS'.
screenrequired='2'.
WHEN'P_SUB'.
IFp_det=space.
screeninput=0.
ENDIF.
ENDCASE.
MODIFYSCREEN.
ENDLOOP.
ATSELECTIONSCREENONp_bukrs.
IFsyucomm='ONLI'.
IFp_bukrsISINITIAL.
MESSAGEe055(00).
ENDIF.
ENDIF.
Withthiscode,wewontseeanyerrormessagesuntilwehittheexecutebutton,butstillhavethe
obligatorycheckmark.Thisfeatureisalsoavailableinclassicaldynproscreens.
http://abappolice.com/2015/04/obligatoryselectionscreenparameters/#more35
2/2