2008 Nov 19 1:28 PM
Hi all,
I have two radiobuttons and single parameter on the selection screen.I want the parameter field obligatory when first radiobutton is clicked and not obligatory when second button is clicked.its working fine when i put some values in parameter otherwise its giving me error that enter value in required fiels.
below is the code ,Please suggest me what can i do..
parameters: r1 radiobutton group rad1 default 'X' user-command radio,
r2 radiobutton group rad1.
parameters: p1 type matnr modif id a.
at selection-screen output.
IF R1 = 'X'.
loop at screen.
if screen-group1 = 'A'.
screen-input = 0.
MODIFY SCREEN.
endif.
endloop.
ENDIF.
IF R2 = 'X'.
loop at screen.
if screen-group1 = 'A'.
screen-required = 0.
MODIFY SCREEN.
endif.
endloop.
ENDIF.
Regards
Lalit
2008 Nov 19 1:32 PM
If the field is obligatory then you must enter values otherwise it throws an error
2008 Nov 19 1:34 PM
you only need this:
AT SELECTION-SCREEN.
IF r1 EQ 'X' AND
p1 IS INITIAL.
==> error message
ENDIF.
your original logic can be simplified (however you get the error message, when p1 is empty and you switch from r1 to r2):
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CHECK screen-group1 EQ 'A'.
CASE 'X'.
WHEN r1.
screen-required = 1.
WHEN r2.
screen-required = 0.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
2008 Nov 19 1:35 PM
Don't declare the parameter field as mandatory ..
But
at selection-screen output.
IF R1 = 'X'.
loop at screen.
if screen-group1 = 'A'.
screen-input = 0.
MODIFY SCREEN.
endif.
if screen-name = <parameter name>
screen-required = 'X'.
modify screen.
endif.
endloop.
ENDIF.
IF R2 = 'X'.
loop at screen.
if screen-group1 = 'A'.
screen-required = 0.
MODIFY SCREEN.
endif.
if screen-name = <parameter name>
screen-required = ' '.
modify screen.
endif.
endloop.
ENDIF.
2008 Nov 19 1:42 PM
Hello Lalit,
May be below code can help you.
S E L E C T I O N S C R E E N
SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
PARAMETERS : p_begda TYPE sydatum,
p_days(2) TYPE n.
SELECTION-SCREEN END OF BLOCK blk3.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*& radiobttn to choose destination server--
PARAMETERS : p_appl RADIOBUTTON GROUP serv DEFAULT 'X'
USER-COMMAND click,
p_pres RADIOBUTTON GROUP serv .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
*¶meters to choose file paths--
PARAMETERS : p_apath TYPE dxfile-filename,
p_ppath TYPE rlgrap-filename.
PARAMETERS : p_apath TYPE dxfile-filename MODIF ID sl3,
p_ppath TYPE rlgrap-filename MODIF ID sl4.
SELECTION-SCREEN END OF BLOCK blk2.
*SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
PARAMETERS : p_test TYPE c AS CHECKBOX DEFAULT c_x. "test run
*SELECTION-SCREEN END OF BLOCK blk3.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK blk4 WITH FRAME TITLE text-058.
**-- Radiobutton to choose Upload Path
PARAMETERS : p_app2 RADIOBUTTON GROUP ser2 DEFAULT 'X'
USER-COMMAND click1,
p_pres2 RADIOBUTTON GROUP ser2 .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK blk5 WITH FRAME TITLE text-002.
*¶meters to choose file paths--
PARAMETERS : p_apath2 TYPE dxfile-filename MODIF ID sl1,
p_ppath2 TYPE rlgrap-filename MODIF ID sl2.
SELECTION-SCREEN END OF BLOCK blk5.
PARAMETERS : p_upload TYPE c AS CHECKBOX. "Upload Old Deparment Numbers
SELECTION-SCREEN END OF BLOCK blk4.
Event AT SELECTION-SCREEN OUTPUT.
IF p_appl = c_x.
LOOP AT SCREEN.
IF screen-group1 = 'SL4'.
screen-active = 0.
MODIFY SCREEN.
CLEAR p_pres2.
p_app2 = c_x.
ENDIF.
IF screen-group1 = 'SL2'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF screen-group1 = 'SL3'.
screen-active = 0.
MODIFY SCREEN.
CLEAR p_app2.
p_pres2 = c_x.
ENDIF.
IF screen-group1 = 'SL1'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
Event AT SELECTION-SCREEN.
CHECK sy-ucomm <> c_click.
CHECK p_test <> c_x.
*& if source server is Presentation
IF p_pres = c_x.
IF p_p_ppath IS INITIAL.
MESSAGE e142 DISPLAY LIKE 'I'. "Input File path not given
ENDIF.
ENDIF.
*& if source server is Application
IF p_appl = c_x.
*-- if source applcn path is initial
IF p_p_apath IS INITIAL.
MESSAGE e142 DISPLAY LIKE 'I'. "Input File Path not given
ENDIF.
ENDIF.
IF p_upload = c_x.
*& if source server is Presentation
IF p_pres2 = c_x.
IF p_ppath2 IS INITIAL.
MESSAGE e142 DISPLAY LIKE c_i. "Input File path not given
ENDIF.
ENDIF.
*& if source server is Application
IF p_app2 = c_x.
*-- if source applcn path is initial
IF p_apath2 IS INITIAL.
MESSAGE e142 DISPLAY LIKE c_i. "Input File Path not given
ENDIF.
ENDIF.
ENDIF.
Hope this long code helps!!
Thanks,
Jayant