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: 

Make fields active on radiobutton selection

Former Member
0 Kudos
90

Hello all,

I have two radiobuttons and two fields.When I select first radiobutton, field1 should be active and when I select second radiobutton field2 should be active.I am able to achieve this using at selection screen output event.But the problem is that when I select first radiobutton, field1 should be mandatory and if I switch to second radiobutton from the first one, field2 should be mandatory. When I switch from radiobutton 1 to radiobutton 2, the validation for the field2 is kicked off even before the field is avaiable for input.How to achieve this?

Thanks

Sandeep

5 REPLIES 5

Former Member
0 Kudos
61

hi ,

&----


*& Report ZVENKATTEST0

*&

&----


*&

*&

&----


REPORT ZVENKATTEST0.

TABLES:MARA.

SELECT-OPTIONS:S_TEST1 FOR MARA-MATNR MODIF ID M1 ,

S_TEST2 FOR MARA-MEINS MODIF ID M2 .

PARAMETERS:P_RAD1 RADIOBUTTON GROUP G1 USER-COMMAND UC1 DEFAULT 'X',

P_RAD2 RADIOBUTTON GROUP G1 ,

P_RAD3 RADIOBUTTON GROUP G1 .

AT SELECTION-SCREEN OUTPUT .

LOOP AT SCREEN.

IF P_RAD1 = 'X'.

IF SCREEN-NAME = 'S_TEST1-LOW' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

IF SCREEN-NAME = 'S_TEST1-HIGH' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

IF SCREEN-NAME = 'S_TEST2-LOW' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

IF SCREEN-NAME = 'S_TEST2-HIGH' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

ENDIF.

IF P_RAD2 = 'X'.

IF SCREEN-NAME = 'S_TEST1-LOW' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

IF SCREEN-NAME = 'S_TEST1-HIGH' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

ENDIF.

IF P_RAD3 = 'X'.

IF SCREEN-NAME = 'S_TEST2-LOW' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

IF SCREEN-NAME = 'S_TEST2-HIGH' .

SCREEN-INPUT = '0'.

MODIFY SCREEN.

ENDIF.

ENDIF.

ENDLOOP.

regards,

venkat.

Former Member
0 Kudos
61

Hi

U need to insert a control in the event AT SELECTION-SCREEN:

AT SELECTION-SCREEN.
  IF RADIO1 = 'X'.
    IF FIELD1 IS INITIAL.
------> ERROR MESSAGE
    ENDIF.
  ENDIF.

  IF RADIO2 = 'X'.
    IF FIELD2 IS INITIAL.
------> ERROR MESSAGE
    ENDIF.
  ENDIF.

Max

Former Member
0 Kudos
61

You should write this way

parameters : p_val like mara-matnr,

p_kdate like sy-datum,

gp_opt1 radiobutton group rad1 user-command rac DEFAULT 'X',

gp_opt2 radiobutton group rad1.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF GP_OPT1 = 'X' AND SCREEN-NAME = 'P_VAL'.

SCREEN-INPUT = '0'.

ELSEIF GP_OPT2 = 'X' AND SCREEN-NAME = 'P_KDATE'.

SCREEN-INPUT = '0'.

ENDIF.

MODIFY SCREEN .

ENDLOOP.

Former Member
0 Kudos
61

Hi,

If you are using the SCREEN-REQUIRED = '1' loop at screen .....endloop in the at selection screen event, you cannot switch to select the other radiobutton. It will promt to enter the values as it is mandatory.

Instead of that, you can do validation in the at selection-screen event.

Switching from non-mandotory fields to mandatory fields is possible, but vice-versa is not possible.

Thanks,

Sriram Ponna.

0 Kudos
61

Hello Sriram,

My validations for the two fields are in 'AT SELECTION SCREEN' event and the modification of these fields for input values(based on the radiobutton selected) is done in 'AT SELECTION SCREEN OUTPUT'.The problem here is like this.

Radiobutton 1-selected--->field1 should be filled

Radiobutton 2-selected--->field2 should be filled.

Radiobutton1 is selected by default.

Now if I switch to radiobutton2 , the validation for field2 is kicked off even before displaying this field for input values.

Also field2 is not mandatory while declaring it as a parameter, but I am manually doing the validation like this.

if radioubutton2 = 'X'.

if field2 = ' '.

give error message.

endif.

endif.

Any thoughts on this

Thanks

Sandeep