Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Selection screen (based on Radio button hide the mandatory fields)

former_member183917
Active Contributor
0 Kudos

Hi all,

I have 2 radio buttons and based on radio button selection, set of fields will be displayed and other set of fields will be in read only.

Default Radio button 1 is 'X'. So first set of fields will be displayed. In that i am having 2 mandatory fields, so without giving data to that 2 fields, its not allowing to select 2nd radion button.

I am making the field mandatory as screen-required = "X" in At selection screen output and not as Obligatory. Pls suggest a solution for this.

-Vinoth

1 ACCEPTED SOLUTION

Former Member

Don't use screen-required = "X" and obligatory.

Declare them normally, then under at selection screen event, check if sy-ucomm = 'ONLI' or space, check if first RB is selected and any of the two fields are blank throw errror msg. If second RB is selected, don't perform this validation.

Ganga

8 REPLIES 8

Former Member
0 Kudos

why not make the fields available for input or not available for input instead?

Former Member

Don't use screen-required = "X" and obligatory.

Declare them normally, then under at selection screen event, check if sy-ucomm = 'ONLI' or space, check if first RB is selected and any of the two fields are blank throw errror msg. If second RB is selected, don't perform this validation.

Ganga

0 Kudos

Thanks for the reply.

Pls tell me the use of SY-UCOMMvalue and when it have value as "ONLI"

Vinoth

0 Kudos

It will be 'ONLI' if you press F8 button and it will be space if you press ENTER. As validation should be performed when enter button or F8 pressed, use that logic. If RB is selected SY-UCOMM will be not equal to 'ONLI' and space. We can stop triggering the validation with this check. Try and get back in case of any issues.

Regards,

Ganga

0 Kudos

I got it and Thank you Ganga and Tanmaya.

Vinoth

0 Kudos

Hi Ganga,

Suppose i have two parametres or select-options in my selection-screen and both are mandatory..For example

Parametres : p_matnr type matnr obligatory.

If i press ENTER with out giving the material number in the selection-screen..ERROR MESSAGE does not want to show like this

'Fill ALL the required field'..If i give material number and press f8 then only the operation has to start...If i does nt give means nothing to be shown in selection-screen i mean no messages has to be shown..slection-screen should be same..

Former Member

hi vinoth,

Dont define the fields as mandatory or obligatory or screen-required ='X'.

what u can do is :

define the radio button.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.   "'Input Fileu2019.
PARAMETERS : p_fgnd TYPE c RADIOBUTTON GROUP r1  USER-COMMAND xyz DEFAULT 'X',
             p_bgnd TYPE c  RADIOBUTTON GROUP r1,
             p_file TYPE rlgrap-filename modif id id1.
SELECTION-SCREEN END OF BLOCK b1.

now you have to check the radio button if p_bgnd = 'X' do this else do that.

define the modif id like p_file have.


AT selection-screen output.
loop at screen.
if p_fgnd = c_x.
if screen-group1 EQ 'ID1'.
  screen-required = 1.
    modify screen.
endif.
elseif p_bgnd = c_x.
if screen-group1 EQ 'ID1'.
  screen-active = 0.
  modify screen.
endif.
endif.
endloop.

if u want to display one set of field and some field as mandatory create a group of those field and give screen-required = 1.

similarly if you want to just display some field then use screen-output = 1.

take a F1 help on SCREEN.

hope this will help and solve your query.

Thanks and regards,

Tanmaya Gupta

0 Kudos

Hi Vinoth,

You can use below code as reference:

PARAMETERS:  p_file  TYPE rlgrap-filename OBLIGATORY DEFAULT 'C:/' MODIF ID id1.

PARAMETERS: r_vka0   RADIOBUTTON GROUP r1 DEFAULT 'X' USER-COMMAND rd,

             r_ka03   RADIOBUTTON GROUP r1.

           

for hide fields based on radio button:

AT SELECTION-SCREEN OUTPUT .

   LOOP AT SCREEN.

     IF r_vka0 = 'X'.

       IF  screen-group1 EQ 'ID1'.

         screen-active = 1.

         MODIFY SCREEN.

       ENDIF.

     ELSE.

       IF  screen-group1 EQ 'ID1'.

         screen-active = 0.

         MODIFY SCREEN.

       ENDIF.

     ENDIF.

   ENDLOOP.


Thanks,

Sayani