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: 

how to switch two fields with one of them OBLIGATORY

Former Member
0 Kudos

Hi everyone,

i have two radio button on the screen: RD_A and RD_B, while there are two fields corresponding to them: P_A and P_B, P_A is OBLIGATORY.

i want to implment: when i click RD_A, field P_A is enable and field p_B is disable. when i click RD_B, field P_B is enable and field P_A is disable.

i tried using LOOP AT SCREEN ...screen-input = '0' and screen-required = '0' ....MODIFY SCREEN...statements, but it cannot work fine. when i switch from A to B, it always popup error message 'Fill in all required entry fields'.

can anyone help me? thanks in advance!

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

you can try this approach, instead of using Obligatory Addition.

REPORT  ztest_radio.

TABLES: sflight.
SELECT-OPTIONS: carrid FOR sflight-carrid,
                connid FOR sflight-connid.

PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND abc DEFAULT 'X',
            r2 RADIOBUTTON GROUP g1.

AT SELECTION-SCREEN OUTPUT.
  IF r1 = 'X'.
    LOOP AT SCREEN.
      IF screen-name CS 'CONNID'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      IF screen-name CS 'CARRID'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

AT SELECTION-SCREEN.
  IF sy-ucomm = 'ONLI'.   "This triggers only when you press execute button
    IF r1 = 'X'.
      IF carrid IS INITIAL.
        MESSAGE 'Enter Carrid' TYPE 'E'.
      ENDIF.
    ELSE.
      IF connid IS INITIAL.
        MESSAGE 'Enter Connid' TYPE 'E'.
      ENDIF.
    ENDIF.
  ENDIF.

4 REPLIES 4

Former Member
0 Kudos

Hi

You need to code LOOP AT SCREEN.

In AT SELECTION-SCREEN OUTPUT.

Regards

MD

asik_shameem
Active Contributor
0 Kudos

Hi

The way you are doing is right. But you should not use OBLIGATORY

Just add user-command abcd at the end of your each radio button.

PARAMETERS :  RD_A RADIOBUTTON GROUP rad USER-COMMAND abcd ,
              RD_B RADIOBUTTON GROUP rad .

former_member188685
Active Contributor
0 Kudos

you can try this approach, instead of using Obligatory Addition.

REPORT  ztest_radio.

TABLES: sflight.
SELECT-OPTIONS: carrid FOR sflight-carrid,
                connid FOR sflight-connid.

PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND abc DEFAULT 'X',
            r2 RADIOBUTTON GROUP g1.

AT SELECTION-SCREEN OUTPUT.
  IF r1 = 'X'.
    LOOP AT SCREEN.
      IF screen-name CS 'CONNID'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      IF screen-name CS 'CARRID'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

AT SELECTION-SCREEN.
  IF sy-ucomm = 'ONLI'.   "This triggers only when you press execute button
    IF r1 = 'X'.
      IF carrid IS INITIAL.
        MESSAGE 'Enter Carrid' TYPE 'E'.
      ENDIF.
    ELSE.
      IF connid IS INITIAL.
        MESSAGE 'Enter Connid' TYPE 'E'.
      ENDIF.
    ENDIF.
  ENDIF.

0 Kudos

Hello Wei,

You can't achieve this by using obligatory or screen-required = 1.

Just validate the field as below.

at selection-screen on p_a.

if rd_a eq 'X and p_a is initial'.

"Raise error message.

endif.