09-23-2008 6:59 AM
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!
09-23-2008 7:06 AM
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.
09-23-2008 7:02 AM
Hi
You need to code LOOP AT SCREEN.
In AT SELECTION-SCREEN OUTPUT.
Regards
MD
09-23-2008 7:03 AM
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 .
09-23-2008 7:06 AM
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.
09-23-2008 2:52 PM
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.