‎2007 Dec 19 6:20 AM
Hi experts,
I have a selection screen:
Paramater p1 & p2 OBLIGATORY.
Radiobutton rb1 & rb2.
By default rb1 is marked.
p1 is mandatory when rb1 is marked while p2 is mandatory when rb2 is marked. The problem is when I select rb2 without filling p1 with data. Error message: fill in all required fields appear. How do I bypass this? The problem is that the parameter are declared as OBLIGATORY and I only want the check the OBLIGATORY fields when I choose to execute the program.
‎2007 Dec 19 6:24 AM
Hi,
u cannot make ur parameters as obligatory ,it wil always throw error what u can do is make them when u click RB1 ,the field p1 will be enabled and the field p2 will be disabled...
check the below sample code for it..
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_aserv RADIOBUTTON GROUP grp
USER-COMMAND app, "Application server
p_afile1 TYPE filename-fileextern , "Application File
"Name for contracts
p_afile2 TYPE filename-fileextern , "Application
"FileName for
"Long text
p_aerfl1 TYPE filename-fileextern , "Error File
"forcontracts
p_aerfl2 TYPE filename-fileextern , "Error File
"for Longtext
p_pserv RADIOBUTTON GROUP grp, "Presentation Server
p_pfile1 TYPE rlgrap-filename , "Presentation File
"Name forcontracts
p_pfile2 TYPE rlgrap-filename , "Presentation File
"Name for long
"texts
p_errfl1 TYPE rlgrap-filename ,
"Error File for
"contracts
p_errfl2 TYPE rlgrap-filename . "Err File Long text
SELECTION-SCREEN : END OF BLOCK b1.
AT SELECTION-SCREEN OUTPUT.
IF p_pserv IS INITIAL.
LOOP AT SCREEN.
CASE screen-name.
WHEN 'P_PFILE1'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'P_PFILE2'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'P_ERRFL1'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'P_ERRFL2'.
screen-input = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
CASE screen-name.
WHEN 'P_AFILE1'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'P_AFILE2'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'P_AERFL1'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'P_AERFL2'.
screen-input = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
Regards,
Nagaraj
‎2007 Dec 19 6:27 AM
The problem is that we want to have the Mandatory indicator(a box with a check on it) in the fields. Declaring it with OBLIGATORY statement is the only way to have that indicator?
‎2007 Dec 19 6:30 AM
Hi,
Instead of making P1 and P2 as Mandatory fields.
make them as ordinary parameters but in AT SELECTION SCREEN event validate these two fields.
there also use status message or warning message instead of
error message.
hope this helps.
‎2007 Dec 19 6:30 AM
You need to set the Screen-REQUIRED parameter to '0' to mark the field as not mandatory field.
Reward Points if useful.
‎2007 Dec 19 7:14 AM
Hi Marc,
you can follow this code.
parameters:r1 radiobutton group g1 ,
r2 radiobuttion group g1'.
parameters:f1 like lfa1-name1 modif id 'ABC',
f1 like lfa1-land1 modif id 'EFG'.
At Selection Screen Output.
loop at Screen.
if screen-group1 = 'ABC' and r1 = 'X'.
screen-required = '1'.
elseif
screen-group2 = 'EFG' and r2 = 'X'
screen-required = '1'.
endif.
modify screen.
endloop.
Please reward if it is helpful to you.
Regards,
suresh
‎2007 Dec 19 7:24 AM
The problem is still that if I choose to navigate from rb1 to rb2 without filling data in parameter 1, error message that must fill required field which is the parameter 1 being blank. I want to bypass that when I navigate from rb1 to rb2 or vice versa without filling any required field it will not show any error message.
‎2007 Dec 19 7:30 AM
Hi marc,
with obligatory statement u cannot achiveve the functionality because standard SAP first validates the screen and checks whther any field is mandatory or not,hence it will always throw message ....u have to do what i ahve given u in the code..one mor thing u can validate is when the user won't give any values to the parameter u can throw some information message to him saying that 'INPUT IS REQUIRED' like this..now the user knows that he ahs to input some value into the field...Thsi way u can achieve ur functionality..also the main purpose of obligatory is that u have to put values in it inorder to navigate..so do as per my suggestion..
Regards,
Nagaraj
‎2007 Dec 19 8:15 AM
Just check this and reward if useful...:-)
REPORT YPATTERN MESSAGE-ID ZPP .
PARAMETERS:RAD1 RADIOBUTTON GROUP G1 DEFAULT 'X',
RAD2 RADIOBUTTON GROUP G1.
PARAMETERS:VAL1 LIKE LFA1-NAME1,
VAL2 LIKE LFA1-LAND1.
AT SELECTION-SCREEN.
IF RAD1 = 'X'.
IF VAL1 = SPACE.
SET CURSOR FIELD 'VAL1'.
MESSAGE E001."<----
(VAL1 IS MANDATORY)
ENDIF.
ENDIF.
IF RAD2 = 'X'.
IF VAL2 = SPACE.
SET CURSOR FIELD 'VAL2'.
MESSAGE E002."<----
(VAL2 IS MANDATORY)
ENDIF.
ENDIF.
START-OF-SELECTION.
END-OF-SELECTION.