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

Checkbox issue in module pool program

manish_malakar0316
Active Participant
0 Likes
11,856

Hi all,

I have a small issue in a module pool program using checkboxes. The requirement is that my basic list should contain the data with checkboxes and as per the selection by the user, the selected records should appear in the next screen (secondary list). But after selection, all the records barring the last record is appearing in my secondary list. Below are the screenshots of my program:

These are the global variables I declared:

The layout for the  basic list is as shown. The function code is cbox for checkbox.

The flow logic :

The code for user-command:

Now on executing the program,

As you can see, sales orders 4970,4972,4974 and 4975 are selected. So after clicking NEXT, in the secondary list , the data for these selected sales orders from VBAP table should come up. But instead, the records from 4970, 4972 and 4974 are displayed except the last sales order which is 4975.

This is happening for all the records. The last selected sales order is not getting selected. Why is it so?

Thanks.

Manish

1 ACCEPTED SOLUTION
Read only

former_member183073
Active Participant
0 Likes
11,259

Hi Manish,

what are you doing in READ_THIS? might be passing X in to your internal table so call USER_COMMAND_9000 after READ_THIS.

16 REPLIES 16
Read only

Former Member
0 Likes
11,259

Hi manish,

After selecting the check box, just press enter and then click NEXT.

hope it ll helpful.

Regards,

Venkat.

Read only

0 Likes
11,259

Hi Venkat,

It was due to the module READ_THIS. I corrected it. Thanks.

Regards

Manish

Read only

Former Member
0 Likes
11,259

Hi,

Instead of writing the code for CBOX, write it in NEXT.

Also,

after appending the wa_vbak to it_vbak1

i see the modify statement irrelevant. remove it and try.

Read only

0 Likes
11,259

Hi Ashish

Sorry, I did that earlier, but it didnt work. I have to use the function code for checkbox else the program doesnt work at all.

Regards

Manish

Read only

Former Member
0 Likes
11,259

Hi Manish,

I hope its is problem with internal table index (Sy-tabix).

Review & Debug the code while the ucomm is CBOX and DSEL.

Otherwise,

WHEN 'NEXT'

Refresh : IT_VBAK1[].

IT_VBAK1[] = IT_VBAK[].

DELETE IT_VBAK1 where CHECK NE 'X'.

SELECT VBELN

....

Hope this helps.

regards,

Velmurugan B

Read only

former_member183073
Active Participant
0 Likes
11,260

Hi Manish,

what are you doing in READ_THIS? might be passing X in to your internal table so call USER_COMMAND_9000 after READ_THIS.

Read only

0 Likes
11,259

Hi Ali,

Thanks, I corrected that part and almost the entire issue has been resolved. This is what I did as per your suggestion. The code at MODULE READ_THIS is MODIFY IT_VBAK FROM WA_VBAK INDEX TC1-CURRENT_LINE.

However, there is a slight problem. Initially when I select the sales orders from the basic list :

I am getting the correct output in the secondary list:

But if I go back to the basic list and select another sales order (here it is 4974):

No data comes up for 4974. The initial records are only displayed as before in the secondary list.

Can you please tell me how to rectify this? My issue will be resolved if this is corrected.

Regards.

Manish

Read only

0 Likes
11,259

1.On CBOX user command you are always appending wa_vbak into it_vbak1 what do you think happens if I uncheck the check box? It_vbak1 will hold the record even if you uncheck. you didnt write any code for removing the record after unchecking.

2. Better you just prepare it_vbak1 in next command just before the selct on vbap. no need to prepare the itab for every check and un check. Do as velmurugan coded. That should resolve.

Read only

0 Likes
11,259

Hi Ali,

I have modified the code but there are still a couple of things which are confusing me. In the below screenshot you can see the modified version of the code:

Now to see what is going wrong, I tried to debug the code. I placed the breakpoint on 'NEXT' as shown. Then I selected the following sales orders and pressed NEXT.

In the debugger, IT_VBAK1 correctly holds the 2 selected values:

IT_VBAP displays the values correctly as well.

Now, this is where the issue is. On clicking the BACK button and selecting another sales order (4974):

IT_VBAK1 holds the additional sales order 4974 along with the previous ones as well:

IT_VBAP also displays the values accordingly as per the debugger:

But in the table control, the sales order 4974 is not displayed. Only the initial sales orders are displayed.

1) There is nothing wrong with the code as the debugger shows the records are held and displayed correctly by the internal tables. So what could be the reason for the data not to be displayed correctly in the table control? I also tried refreshing IT_VBAP after the BACK button, but still it isnt working. 

2) Also, another thing I've seen that is after clicking the BACK button, when I select the sales orders, only data from 2 sales orders are displayed in the secondary list.

For example, if I select any number of sales orders and press NEXT, then all the data are displayed correctly in the secondary list. Once I click the BACK button and deselect all of them and then I checkbox 3 sales orders (more than 2), then only the records for 2 sales orders are displayed, not the 3rd one.   Why is this happening?

Regards

Manish.

Read only

0 Likes
11,259

if the problem is not resolved yet please paste the code from screen 9001.

Read only

0 Likes
11,259

The only code written for screen 9001 is for the BACK button which is:

IF SY-UCOMM = 'BACK'.

LEAVE TO SCREEN 0.

ENDIF.

Read only

0 Likes
11,259

what about the PBO of you table control.

it should be something like this.

REFRESH CONTROL 'K_VBAP' FROM SCREEN '0100'. " Use this to refresh the data in table control.

LOOP AT  ITAB

        INTO WA

        WITH CONTROL K_VBAP

        CURSOR K_VBAP-CURRENT_LINE.

     MODULE K_VBAP_MOVE.

ENDLOOP.

MODULE K_VBAP_MOVE OUTPUT.

   MOVE-CORRESPONDING WA TO VBAP.

ENDMODULE.



Read only

0 Likes
11,259

Hi Ali,

Its working fine now..surprisingly! The above part of your code is not required. The issue is resolved fully. Thanks a lot for your help. I appreciate it.

Regards.

Manish.

Read only

0 Likes
11,259

This message was moderated.

Read only

Aiolos
Active Participant
0 Likes
11,259

Hi, Manish

this is only caused by your code, which the selected lines are not got correcly.

please checked the internal table and find out correct logic to fetch your data.

hope helpful.

Read only

0 Likes
11,259

Hi Aiolos,

There is nothing wrong with the logic. Its just that the updated values are not displayed in the table control. Please go though the latest post regarding my issues above. It will be clear.

Regards.

Manish