Application Development and Automation 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: 
Read only

button enabling/disabling via checkbox

Former Member
0 Likes
2,969


Hi all,

I have a table control with checkboxes. My requirement is that there aill be 2 buttons (Fail and Pass) and which are going to be in invisible mode when the table control is displayed. When one or more than one checkbox is selected, "Fail" button will be visible. If all cj\heckboxes are selected, only then the "Pass" button should be enabled. How can I achieve this?

My table control is shown above. The buttons are invisible as per my requirement.

Below is the layout:

The variables I declared are:

TYPES: BEGIN OF TY_VBAP ,
              check TYPE c,
              VBELN TYPE VBAP-VBELN,
              POSNR TYPE VBAP-POSNR,
              MATNR TYPE VBAP-MATNR,
              MATKL TYPE VBAP-MATKL,
              POSAR TYPE VBAP-POSAR,
              END OF TY_VBAP.

DATA: IT_VBAP TYPE STANDARD TABLE OF TY_VBAP,
            WA_VBAP TYPE TY_VBAP.

DATA:ok_code TYPE sy-ucomm.

CONTROLS tc1 TYPE TABLEVIEW USING SCREEN 1001 .

In my PAI, I tried with this code, but its not working.

LOOP AT IT_VBAP INTO WA_VBAP WHERE CHECK = 'X'.

  loop at screen.

    IF SCREEN-GROUP1 = 'CHK' AND

       SCREEN-GROUP2 = 'GPS' AND

       SCREEN-NAME = 'FAIL'.

       screen-ACTIVE = '1'.

*       screen-invisible = '0'.

       modify screen.

       ENDIF.

       ENDLOOP.

       ENDLOOP.

Please help me with this.

Regards.

Souvik.

18 REPLIES 18
Read only

Aiolos
Active Participant
0 Likes
2,743

i think it is easy to meet this requiremnt.

all your lines' information is stored in 1 internal table.

in pbo, base on the data in this internal table , do loop screen, and modify input to 0, it will be working.

Hope you can fix your issue.

feel free to let me know your concern.

Read only

Former Member
0 Likes
2,743

I have done it in the PBO of screen 9001 to keep the buttons invisible as shown:

loop at screen.

    if screen-group1 eq 'GRP'.

       screen-active = '0'.

       modify screen.

    endif.

   endloop.

loop at screen.

    if screen-group1 eq 'GPS'.

       screen-active = '0'.

       modify screen.

    endif.

   endloop.

The issue I am facing is that I need to enable them based on my checkbox selection as mentioned in my post.

Read only

Aiolos
Active Participant
0 Likes
2,743

1.add fcode to checkbox.

2.in pbo, base on checkbox field value to set this button invisible or not.

Read only

Former Member
0 Likes
2,743

Sorry Aiolos, but if I add a fcode to the checkbox, the checkbox doesnt function properly in my screen.. i.e. the fields dont get selected via the checkbox. I had already tried this approach earlier.

Read only

0 Likes
2,743

If you don't assign a function code to check-boxes, you wont be able to trigger a PAI/PBO cycle and unable to automatically display any of the two buttons.

So you have to either

  • solve first the "the checkbox doesn't function properly in my screen.", could you explain what problem you encountered ?
  • Accept that the user must press ENTER or any key to trigger the cycle

Regards,

Raymond

Read only

Former Member
0 Likes
2,743


When I mentioned that "the checkbox doesn't function properly in my screen", I meant that when I am selecting a field using checkboxes,the Fail button is not appearing as per requirement.

The user does not have to press Enter to make the buttons visible, its basically the role of the checkboxes to make that happen.

Read only

Former Member
0 Likes
2,743

Hi,

I have solved part of the issue, that is, I am able to enable the "Fail" button with the click of another button. However , as per my requirement, the "Fail" button should be enabled by triggering a checkbox, and not a push button . Now if I assign a function code to the checkbox, it acts as a push button, and the checkbox does not hold the 'tick' mark. So how do I solve this?

Regards.

Manish.

Read only

santhoshi_gudini
Explorer
0 Likes
2,743

Hi Use a variable to set screen-active property 0 or 1.

when declaring the variable assign some initial value to it ( 0 or 1). Later (PAI or PBO) if all the lines are selected assign value 1 to the variable else 0.

Sample code

data: gv_grp_Active type c value '0'.

in PBO loop at screen.

screen-active = gv_grp_active.

Read only

0 Likes
2,743

Its not working Santhoshi  Whether I use 0 or 1 or I declare a variable for the values, its one and the same thing.  There is no difference. The buttons are not getting enabled. Please refer to my code snippet and tell me where am I going wrong, if possible.

Regards.

Souvik.

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,743

Hi Souvik

Simply do one thing. Declare a global variable GV_PASS type C.

In PAI of your screen in user command after loop endloop. Check if all checkbox are marked.

LT_TEMP[] = LT_PASS[]

delete lt_temp where mark is initial.

if sy-subrc ne 0." all marked

GV_PASS = X

else.

clear gv_pass.

endif.

in PBO if flag is initial hide it else show it

Nabheet

Read only

0 Likes
2,743

Hi Nabheet,

Can you tell me what I can do to make the buttons get enabled as per my requirement? That is my main concern.

Regards.

Souvik.

Read only

0 Likes
2,743

Souvik

The solution to your problem has already been provided in above threads.

  • Assign fcode to checkbox. Each marking of checkbox will trigger PAI with UCOMM values. For that UCOMM check in internal table whether all chekcboxes are selected if not dontset GV_PASS flag else set it.
  • In PBO if you find this flag marked then enable PASS button by LOOP SCREEN else keep hiding it.

Nabheet

Read only

0 Likes
2,743

I did try, but it seems that the buttons are not getting enabled...  

Read only

0 Likes
2,743

I think you need to switch on the debugger and use F5. Check how your logic is running. We can propose ways to do it. But actually how you have done it depends on you. Best thing will be to switch on the debugger put break points at various points like where you are enabling disabling stuff

Nabheet

Read only

0 Likes
2,743

Hi,

I have solved part of the issue, that is, I am able to enable the "Fail" button with the click of another button. However , as per my requirement, the "Fail" button should be enabled by triggering a checkbox, and not a push button . Now if I assign a function code to the checkbox, it acts as a push button, and the checkbox does not hold the 'tick' mark. So how do I solve this?

Regards.

Manish.

Read only

dibyajeeban_jena
Active Participant
0 Likes
2,743

Hi,,

Please do as follows in a  PBO module..

READ TABLE IT_VBAP  INTO  WA_VBAP WITH KEY  CHECK  IS INITIAL .

( if at least one check box is blank then fail button will appear )

IF SY-SUBRC  = 0 .

  loop at screen.

    IF  SCREEN-NAME = 'FAIL'.

       screen-ACTIVE = '1'.


       modify screen.

       ENDIF.

ENDLOOP.

else  .  (if all check boxes are checked and no blank check boxes )

  loop at screen.

    IF    SCREEN-NAME = 'PASS'.

       screen-ACTIVE = '1'.


       modify screen.

     ENDIF.

ENDLOOP.


ENDIF .


Regards

DJ

Read only

0 Likes
2,743

iTS STILL NOT WORKING ..... 

Read only

0 Likes
2,743

Hi Souvik,

Maybe you can use classes to do this. I have used this kind in a module pool with class CL_GUI_ALV_GRID. Hope this helps