Skip to Content

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

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2010 at 12:35 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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..

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2010 at 01:11 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2010 at 12:32 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 27, 2016 at 10:20 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.