Application Development and Automation 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: 
Read only

Problem with obligatory fields with radionbutton

Former Member
0 Likes
1,063

Hy,

i have follow problem:

in screen exist 2 radiobuttons.

to each radiobutton show 2 selecti-options....

but, when i select one radiobutton, the fields corresponding should be obligatory;

when select other radiobutton, the fields corresponding should be obligatory and the fields above should not be obligatory; but is impossible to do this event because exist a validation standard to inform the value to the obligatories fields.....

somebody have some light to my problem???

exist the possibilitie to change the color of fields in screen for identify that this field is obligatory??

Thanks !

Patricia

5 REPLIES 5
Read only

sridhar_meesala
Active Contributor
0 Likes
928

HI,

screen-required = '1' makes the field mandate during runtime.

Thanks,

Sri.

Read only

Former Member
0 Likes
928

you can control this action by assigning a user command to the first instance of the radiobutton, and setting your screen field attributes during AT SELECTION-SCREEN OUTPUT.

parameters: rbuttn1 radiobutton group mybt default 'X' user-command sy-ucomm.

A switch between radiobuttons will then trigger the selection-screen output event.

It's been a while since I last did this, so check sscrfields values with debug...

...

AT SELECTION-SCREEN OUTPUT.

if sscrfields-ucomm is initial or

sscrfields-ucomm eq 'SY-UCOMM'.

loop at screen.

case screen-name.

when ???

"set attributes.

modify screen.

when ???

"etc...

modify screen.

endcase.

endloop.

endif.

Then:

At selection-screen, verify that the user has correctly filled out the screen and issue an error message, if not.

AT SELECTION-SCREEN.

case sscrfields-ucomm.

when 'ONLI' or 'PRIN' or 'SJOB'. "user is executing

if radiobutton1 eq char_x.

.....

else....

endif.

endcase.

Read only

Former Member
0 Likes
928

Hi Patricia,

It is not possible to make the fields mandatory as you will get an error message just when you select the radiobuttons.

You could try this out:

at the beginning of START-OF-SELECTION event, write the following logic:

If radiobutton1 is selected, check whether fields related to this radiobutton are empty. If so display an error message and take the user back to the selection screen. Implement the same with radiobutton2.

Hope this helps. I had done a similar thing in one of my assignments.

Regards,

Dawood.

Read only

Former Member
0 Likes
928

Hi Particia,

use screen-required = 2. in at selection-screen output. this is for showing that tick mark as obligatory but wont stop the processing.

so.. you can do the validation in at selection screen event..

PARAMETERS: p1 type char5 MODIF ID aa,
            p2 type char10 MODIF ID bb.
PARAMETERS : r1 RADIOBUTTON GROUP r DEFAULT 'X' USER-COMMAND u1,
             r2 RADIOBUTTON GROUP r .

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
   if r1 = 'X'.
    if screen-name = 'P1'.
      screen-required = 2.
    endif.
    MODIFY SCREEN.
   ELSEIF r2 = 'X'.
    if screen-name = 'P2'.
      screen-required = 2.
    endif.
    MODIFY SCREEN.
   endif.
  endloop.

AT SELECTION-SCREEN.
  if sy-ucomm = 'ONLI'. " For F8.
  if r1 = 'X' and p1 is INITIAL.
    MESSAGE 'Error 1' type 'E'.
  ELSEIF r2 = 'X' and p2 is INITIAL.
    MESSAGE 'Error 2' type 'E'.
  endif.
  endif.

hope you enjoy the code...

Read only

Former Member
0 Likes
928

Genii!!!!

thanks for helps!

i put the required = 2 and i did the treatment with messages according the radiobutton that is checked!!!!!!!!!!!!!!

😃

happy new year for all!!!!

Pati