Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to Uncheck a Check-box.

Former Member
0 Kudos

Hi,

I have two check-boxes pa_abc and pa_def in ALV Grid. If pa_abc is checked, then pa_def should automatically get <b>dis-abled</b> and also should get <b>unchecked</b>.

I have written code for <b>dis-abling</b> pa_def and is working. It is given below.

LOOP AT SCREEN.
    IF pa_abc EQ 'X'.
      IF screen-name = 'pa_def'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.
  ENDLOOP.

But, if pa_abc is checked, pa_def should automatically get <b>unchecked</b> too. Kindly, help me to uncheck pa_def. Thanks in advance.

Regards,

Preetha

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check this sample code.


  parameters : p_chk1 as checkbox user-command ABCD default 'X',
               p_chk2 as checkbox user-command PQRS.

  data: v_clk1 type c value 'X',
        v_clk2 type c.

  at selection-screen output.

   if v_clk1 = 'X'.
     p_chk1 = 'X'.
   else.
     p_chk1 = ' '.
   endif.
  if v_clk2 = 'X'.
    p_chk2 = 'X'.
  else.
    p_chk2 = ' '.
  endif.
  at selection-screen.

    case sy-ucomm.
      when 'ABCD'.
        if p_chk1 = 'X'.
          v_clk1 = 'X'.
          v_clk2 = ' '.
        else.
          v_clk1 =  ' '.
          v_clk2 = 'X'.
        endif.
      when 'PQRS'.
       if p_chk2 = 'X'.
          v_clk2 = 'X'.
          v_clk1 = ' '.
       else.
          v_clk2 = ' '.
          v_clk1 = 'X'.
       endif.
    endcase.

Regards

Sailaja.

5 REPLIES 5

former_member196299
Active Contributor
0 Kudos

Hi Preetha ,

you can get the same functionaity by using Radiobuttons wher you need not write the code for checking and unchecking .

Why d't you try using radio buttons then using checkboxes, as check boxes dunot support your functionality in this kind of casess...

if you need further help , then please respong back ..

Regards,

Ranjita

Former Member
0 Kudos

hi preetha....

if cb1 eq 'x'.

clear cb2.

endif.

With regards,

S.Barani

Former Member
0 Kudos

LOOP AT SCREEN.

IF screen-name = 'pa_def'.

if pa_abc = 'X'.

screen-input = ' '.

it should be either space of 'X'

MODIFY SCREEN.

ENDIF.

vice versa

ENDLOOP.

Former Member
0 Kudos

Hi,

Check this sample code.


  parameters : p_chk1 as checkbox user-command ABCD default 'X',
               p_chk2 as checkbox user-command PQRS.

  data: v_clk1 type c value 'X',
        v_clk2 type c.

  at selection-screen output.

   if v_clk1 = 'X'.
     p_chk1 = 'X'.
   else.
     p_chk1 = ' '.
   endif.
  if v_clk2 = 'X'.
    p_chk2 = 'X'.
  else.
    p_chk2 = ' '.
  endif.
  at selection-screen.

    case sy-ucomm.
      when 'ABCD'.
        if p_chk1 = 'X'.
          v_clk1 = 'X'.
          v_clk2 = ' '.
        else.
          v_clk1 =  ' '.
          v_clk2 = 'X'.
        endif.
      when 'PQRS'.
       if p_chk2 = 'X'.
          v_clk2 = 'X'.
          v_clk1 = ' '.
       else.
          v_clk2 = ' '.
          v_clk1 = 'X'.
       endif.
    endcase.

Regards

Sailaja.

Former Member
0 Kudos

Hi

Instead of checkbox define the radiobuttons . extra coding is not required for unchecking. When u use a radio button, there are two parameters defined. Depending on which button is selected the value for that is set to 'X' and the other is set to space. To use this option all you have to do is assign both the radio buttons to one group.