2

I have some radiobuttons and when I change between them some blocks appear/disappear.

However, if I set parameters as obligatory or required they do not hide unless I fill them. I want to make parameters required but I need to hide them when I change the radiobutton option.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
luiserta
  • 43
  • 1
  • 2
  • 8

2 Answers2

4

I guess it's a selection screen...

  • then loop at your screen and check the value of "YOUR_RADIO_BUTTON"
  • enable or disable the blocks

    AT SELECTION-SCREEN OUTPUT.
    
      LOOP AT SCREEN.
    * Radio button parameter = P_RADIO
    *   hide the parameter named "to_hide" 
        IF P_RADIO EQ 'X' AND SCREEN-NAME CS 'TO_HIDE'.
          SCREEN-INPUT = 0.
          MODIFY SCREEN.
        ENDIF.
    
    *   display the parameter named "to_hide"
        IF P_RADIO <> 'X' AND SCREEN-NAME CS 'TO_HIDE'.
          SCREEN-INPUT = 1.
          MODIFY SCREEN.
        ENDIF.
    
      ENDLOOP.
    
mydoghasworms
  • 18,233
  • 11
  • 61
  • 95
  • I understand what you mean, but if a parameter inside block is obligatory, you can't hide a block because you need to fill the obligatory parameter. – luiserta Dec 09 '12 at 14:35
  • The purposed solution does not work because the event AT SELECTION-SCREEN OUTPUT will not fire unless the parameter has been filled. – Marcel Nov 13 '18 at 09:50
2

If you use PARAMETERS ... OBLIGATORY, this is an unconditional statement - this parameter is required regardless of the other settings. If you need a conditional check, you have to code it for yourself:

PARAMETERS p_chkbuk AS CHECKBOX.
PARAMETERS p_bukrs  TYPE bukrs.

AT SELECTION-SCREEN ON p_bukrs. 
  IF p_chkbuk = abap_true AND p_bukrs IS INITIAL. 
    MESSAGE 'You need to enter something.' TYPE 'I' DISPLAY LIKE 'E'.
  ENDIF.
vwegert
  • 18,371
  • 3
  • 37
  • 55
  • Hmm. Ok. It works, but program ends. I found a way. I can simply put `MESSAGE 'You need to enter something.' TYPE 'I' DISPLAY LIKE 'E'.` – luiserta Dec 13 '12 at 18:12