Skip to Content
author's profile photo Former Member
Former Member

how to switch two fields with one of them OBLIGATORY

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!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Sep 23, 2008 at 06: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 23, 2008 at 06: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 .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2008 at 06:02 AM

    Hi

    You need to code LOOP AT SCREEN.

    In AT SELECTION-SCREEN OUTPUT.

    Regards

    MD

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2008 at 01: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.

    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.