Skip to Content

I want the select-option to open when I click on the radio button

There are 2 radio buttons on a selection screen. Then select the option that appears, I will enter the information and show it on ALV. I want different select options to be opened for the two buttons.

Definitions :

PARAMETERS : p_rad1 RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND seher,
             p_rad2 RADIOBUTTON GROUP rad1.

SELECT-OPTIONS: so_lifnr FOR lfa1-lifnr NO INTERVALS NO-EXTENSION,
                so_kunnr FOR kna1-kunnr NO INTERVALS NO-EXTENSION,
                so_bkr_l FOR lfb1-bukrs NO INTERVALS NO-EXTENSION,
                so_bkr_k FOR knb1-bukrs NO INTERVALS NO-EXTENSION.

I want SO_LIFNR and SO_BKR_L for p_rad1, SO_KUNNR and SO_KUNNR for p_rad2. I wrote this way:

  LOOP AT SCREEN.
    IF screen-name CS 'SO_LIFNR'.
       IF NOT p_rad1 IS INITIAL.
         screen-active = 1.
       ELSE.
         screen-active = 0.
       ENDIF.
       MODIFY SCREEN.
    ELSEIF screen-name CS 'SO_BKR_L'.
       IF NOT p_rad1 IS INITIAL.
         screen-active = 1.
       ELSE.
         screen-active = 0.
       ENDIF.
       MODIFY SCREEN.
    ELSEIF screen-name CS 'SO_KUNNR'.
       IF NOT p_rad2 IS INITIAL.
         screen-active = 1.
       ELSE.
         screen-active = 0.
       ENDIF.
       MODIFY SCREEN.
    ELSEIF screen-name CS 'SO_BKR_K'.
       IF NOT p_rad2 IS INITIAL.
         screen-active = 1.
       ELSE.
         screen-active = 0.
       ENDIF.
       MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

But it gives me such an output. It works correctly but this screen is wrong :

I want it to look separate like this example. Separate images for two radio buttons.

For p_rad1 :

For p_rad2:

How can I do that?

bep7h.png (58.2 kB)
vskam.png (26.7 kB)
5y2a4.png (19.5 kB)
Add a comment
10|10000 characters needed characters exceeded

  • Sorry but your code works on my system:

    PARAMETERS : p_rad1 RADIOBUTTON GROUP rad1 DEFAULT 'X' USER-COMMAND seher,
                 p_rad2 RADIOBUTTON GROUP rad1.
    TABLES scarr.
    SELECT-OPTIONS: so_lifnr FOR scarr-carrid NO INTERVALS NO-EXTENSION,
                    so_kunnr FOR scarr-carrid NO INTERVALS NO-EXTENSION,
                    so_bkr_l FOR scarr-carrid NO INTERVALS NO-EXTENSION,
                    so_bkr_k FOR scarr-carrid NO INTERVALS NO-EXTENSION.
    
    
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF screen-name CS 'SO_LIFNR'.
          IF NOT p_rad1 IS INITIAL.
            screen-active = 1.
          ELSE.
            screen-active = 0.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF screen-name CS 'SO_BKR_L'.
          IF NOT p_rad1 IS INITIAL.
            screen-active = 1.
          ELSE.
            screen-active = 0.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF screen-name CS 'SO_KUNNR'.
          IF NOT p_rad2 IS INITIAL.
            screen-active = 1.
          ELSE.
            screen-active = 0.
          ENDIF.
          MODIFY SCREEN.
        ELSEIF screen-name CS 'SO_BKR_K'.
          IF NOT p_rad2 IS INITIAL.
            screen-active = 1.
          ELSE.
            screen-active = 0.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
  • You will likely get more help if you use a real name and not something anonymous (as well as misspelled ) like "concultant grl".

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jul 19, 2020 at 08:46 AM

    To sum up the resolution of the question, based on latest comments and full code provided (https://answers.sap.com/answers/13097369/view.html):

    The question was:

    • When executing custom program,
    • (1) ALV 1 displays immediately instead of selection screen,
    • (2) and when leaving ALV + choosing ALV 2, there's short dump GETWA_NOT_ASSIGNED

    The reason was:

    • (1) The ALV 1 displayed immediately because the code of the ALV display was defined in the PBO of the selection screen (AT SELECTION-SCREEN OUTPUT)
    • (2) The short dump occurred because while attempting to display the ALV 2, the field catalog of the ALV 1 was not cleared, so the ALV display failed at finding fields in the internal table.

    The solution was:

    • (1) Display the ALV only after the selection screen is displayed, and after F8 (Execute) is pressed, by moving the ALV code inside the event START-OF-SELECTION.
    • (2) Clear the ALV field catalog (CLEAR IT_FCAT) before appending lines to it.
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 17, 2020 at 02:17 PM

    Hi,

    Try below code

    LOOP AT SCREEN.
    
    if p_rad1 EQ 'X'.
        IF screen-name = 'SO_KUNNR' or screen-name = 'SO_BKR_K'.
    		screen-active = 1.
                ELSE.
                    SCREEN-ACTIVE = 0.
    	    ENDIF.
         MODIFY SCREEN. 
    ELSEIF P_RAD2 EQ 'X'.
        IF screen-name = 'SO_LIFNR' or screen-name = 'SO_BKR_L'.
    		screen-active = 1.
                ELSE.
                    SCREEN-ACTIVE = 0.
    	    ENDIF.
         MODIFY SCREEN. 
    
    
    ENDIF. 
                
    ENDLOOP.
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 17, 2020 at 02:35 PM
    -1

    Use group4 instead of name.

    PARAMETERS : P_RAD1 RADIOBUTTON GROUP RAD1 DEFAULT 'X' USER-COMMAND SEHER, "000
                 P_RAD2 RADIOBUTTON GROUP RAD1. "001
    
    
    SELECT-OPTIONS: SO_LIFNR FOR LFA1-LIFNR NO INTERVALS NO-EXTENSION, "002
                    SO_KUNNR FOR KNA1-KUNNR NO INTERVALS NO-EXTENSION, "003
                    SO_BKR_L FOR LFB1-BUKRS NO INTERVALS NO-EXTENSION, "004
                    SO_BKR_K FOR KNB1-BUKRS NO INTERVALS NO-EXTENSION. "005
    
    
    AT SELECTION-SCREEN OUTPUT.
      IF P_RAD1 EQ ABAP_ON.
    
    
        LOOP AT SCREEN.
          IF SCREEN-GROUP4 EQ '003' OR SCREEN-GROUP4 EQ '005'.
            SCREEN-INPUT = 0.
            SCREEN-INVISIBLE = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
    
    
      ENDIF.
    
    
      IF P_RAD2 EQ ABAP_ON.
    
    
        LOOP AT SCREEN.
          IF SCREEN-GROUP4 EQ '002' OR SCREEN-GROUP4 EQ '004'.
            SCREEN-INPUT = 0.
            SCREEN-INVISIBLE = 1.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
    
    
      ENDIF.
    
    Add a comment
    10|10000 characters needed characters exceeded

    • I tried, but it goes directly to the list screen without the selection screen. When I get back I select p_rad2 and it gives an error. The default 'X' is working properly. But as I said, the selection screen works without opening. When I remove the expression 'AT SELECTION-SCREEN OUTPUT.' there is no change.That's not exactly what I want, but thank you for your answer.

  • Posted on Jul 17, 2020 at 03:28 PM
    -1

    Sandra Rossi Yes, It works like this, but I fill two different ALV tables for two radio buttons. The Radio Button, which is checked by default, works smoothly at first. When I select other radio button, it gives an error. I want to see the selection screen first and click any radio button and go to the list screen. And this code is not enough for this.

    Thanks for reply.

    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.