Skip to Content
0
Feb 06, 2009 at 07:57 PM

Loop at Screen Problem

335 Views

Hello all,

I have a requirement where in I have 2 radio buttons and 2 input fields. If I select the first radio button , the input field for 1st should open up and the input field for 2nd should not be seen and vice a versa.

Please see the code below. This code works if I select the first radio button, but doesnt work if I select the second radio button. Please let me know what wrong I am doing. I tried doing the same thing in 2 different ways.

First method :

SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME.
PARAMETERS : p_rad1 RADIOBUTTON GROUP gr1 DEFAULT 'X'.

SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME.
PARAMETERS p_matnr TYPE mara-matnr MODIF ID md1.
SELECTION-SCREEN END OF BLOCK bl2.

PARAMETERS : p_rad2 RADIOBUTTON GROUP gr1 .

SELECTION-SCREEN BEGIN OF BLOCK bl3 WITH FRAME.
PARAMETERS p_vbeln TYPE vbak-vbeln MODIF ID md2.
SELECTION-SCREEN END OF BLOCK bl3.

SELECTION-SCREEN END OF BLOCK bl1.

AT SELECTION-SCREEN OUTPUT.

 IF p_rad1 EQ 'X'.
    LOOP AT SCREEN.
      IF screen-group1 = 'MD2'.
        screen-active = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      IF screen-group1 = 'MD1'.
        screen-active = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

Second Method :

SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME.
PARAMETERS : p_rad1 RADIOBUTTON GROUP gr1 DEFAULT 'X'.

SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME.
PARAMETERS p_matnr TYPE mara-matnr MODIF ID md1.
SELECTION-SCREEN END OF BLOCK bl2.

PARAMETERS : p_rad2 RADIOBUTTON GROUP gr1 .

SELECTION-SCREEN BEGIN OF BLOCK bl3 WITH FRAME.
PARAMETERS p_vbeln TYPE vbak-vbeln MODIF ID md2.
SELECTION-SCREEN END OF BLOCK bl3.

SELECTION-SCREEN END OF BLOCK bl1.

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.
    IF p_rad1 = 'X' AND screen-group1 = 'MD2'.
      screen-active = '0'.
    ENDIF.

    IF p_rad2 = 'X' AND screen-group1 = 'MD1'.
      screen-active = '0'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

Thanks,

Salil

Edited by: salil vaidya on Feb 6, 2009 3:03 PM