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

table control with checkbox in module pool

Former Member
0 Likes
15,944

Hi all,

I have a slight issue in my table control with checkbox. My requirement is that in the basic list the user can checkbox a few sales orders and in the selected sales orders will be displayed in the secondary list. However, the problem is that in spite of the sales orders that are selected, the secondary list is displaying all the sales orders from the basic list and not the ones that are selected. So, it seems that the internal table in the basic list is not getting modified accordingly. I have attached the screenshots for your reference. Please help me identify the error.

These are the variables I declared:

For the basic list:

Screenshot for the layout. Here I have inserted a function code for the checkbox as CBOX.

Code for user command:

The basic list is fine as shown.  Here 4970 and 4972 are selected:

However, the secondary list is displaying all the values from the basic list, not the selected values. Why?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
12,945

Hi,

Just check your code for

WHEN 'CBOX'.

LOO AT IT_VBAK INTO WA_VBAK WHERE CHECK = 'X'.

MODIFY IT_VBAK FROM WA_VBAK INDEX SY-TABIX TRANSPORTING CHECK.

ENDLOOP.

In this loop why IT_VBAK is modified? You are transporting CHECK field, but this field contents

will be same like as they are existing in IT_VBAK. If you really want to modify IT_VBAK then set

WA_VBAK-CHECK = <<Some Value>>.

Without using the statement  WA_VBAK-CHECK = <<Some Value>>. no need modify IT_VBAK.

I hope you understood.

Regards,

Rafi

14 REPLIES 14
Read only

Former Member
0 Likes
12,945

Hi Manish,

While CBOX action the selected records to be maintain in another internal table.

loop at it_vBAK into wa_vbak where check = 'X'.

APPEND WA_VBAK TO IT_VBAK1.

MODFIY IT_VBAK FROM WA_VBAK INDEX SY-TABIX TRANSPORTING CHECK.

ENDLOOP.

Use IT_VBAK1 internal table in for all entries select statement.

Thanks,

Ashok.

Read only

0 Likes
12,943

Hi Ashok,

I tried your approach. This is wat you told me to do:

However it's giving problems. The secondary list is not displaying the output correctly.

On selecting the sales orders:

The secondary list produces the incorrect output as shown. Sales order 4974 is not displayed at all.

Read only

0 Likes
12,943

Hi Manish,

Did the Sales order 4974 having entries in VBAP....? Please check once. Try to check different orders in screen 9000 and perform NEXT action.

Thanks,

Ashok.

Read only

0 Likes
12,943

Yes Ashok, there are entries for sales order 4974. In fact all the sales orders from 4969 to 4974 have records in the VBAP table.

Just to add a minor detail, I modified internal table IT_VBAK1 instead of IT_VBAK as u specified in your post. The reason being that IT_VBAK is not needed in the FOR ALL ENTRIES  part. Even when I modified IT_VBAK (as per your suggestion), the output did not come correctly.

Read only

0 Likes
12,943

Hi Manish,

Can you please share you declaration part of IT_VBAK structures both internal table and work areas.

Thanks,

Ashok.

Read only

0 Likes
12,943

Hi Manish,

Can you please check IT_VBAK1 and IT_VBAP internal table entries in debugging mode after for all entries select statement while NEXT action. How many entries does IT_VBAP exits when you select

4974 and 4975 ?

Thanks,

Ashok.

Read only

0 Likes
12,936

Hi Ashok,

In my post, I have already attached the screenshot of all the variables which I had declared. Nevertheless, I am pasting the screenshot again. (Please not that IT_VBAK1 is not shown in the screenshot, but I have declared it as well ,which is of type TY_VBAK).

When I debugged, I found out that after selecting 4974 and 4975, IT_VBAP consists of all the entries starting from 4969 to 4975 from the select-options. This means that the selection part in the basic list (checkbox) is not working properly. I saw while debugging that when I am using the for all entries statement based on IT_VBAK1, the selected records are not coming up, but all the records from 4969 to 4975. So the part WA_VBAK-CHECK = 'X' is not functioning properly.

Hope this answers your question.

Regards.

Manish

Read only

0 Likes
12,936

Hi Manish,

Can you please refer this program.

DEMO_DYNPRO_TABCONT_LOOP_AT

Remove check box column, the standard SAP provides us check box option, Please see the attachment, you can assign wa_vbak-check(check w/Selcolumn)   field on highlighted spot. And mean while CBOX action not required i think.

Use below code under NEXT action, place this code before for all entries statement.

refresh it_vbak1[ ].

loop at it_VBAK into wa_vbak where check = 'X'.

APPEND WA_VBAK TO IT_VBAK1.

ENDLOOP.

if IT_VBAK1 is not initial.

for all entries.

endif.

Hopes this helps you.

Thnaks,

Ashok.

Read only

0 Likes
12,932

Hi Ashok,

Firstly I would like to tell you that I found the program DEMO_DYNPRO_TABCONT_LOOP_AT confusing in some areas. It used the global structure as a work area and I am not quite aware of that . I did try the same approach in my program, but I did not get any value in the secondary list.

Below are the screenshots of how I approached the program after taking some reference from DEMO_DYNPRO_TABCONT_LOOP_AT.

I created 2 global structures for VBAK and VBAP:

These are the variables declared:

I did the layout and inserted the global structure name in selcol as per DEMO_DYNPRO_TABCONT_LOOP_AT :

This is what I typed for user command:

Now in the secondary list, no values from VBAP table are displayed; this means that the marked records from the basic list are not being selected, as a result not a single value is displayed in the secondary list as IT_VBAK1 is initial. So IT_VBAK1 is not holding the selected records which I found out while debugging. Why is this so and how can it be corrected?

Regards.

Manish.

Read only

0 Likes
12,932

Hi Manish,

At table control screen field you should assign w/SelCcolumn as WA_VBAK-MARK field instead of ZVBAKSTR.

I think this time it should be working fine, please check.

Thanks,

Ashok.

Read only

Former Member
0 Likes
12,946

Hi,

Just check your code for

WHEN 'CBOX'.

LOO AT IT_VBAK INTO WA_VBAK WHERE CHECK = 'X'.

MODIFY IT_VBAK FROM WA_VBAK INDEX SY-TABIX TRANSPORTING CHECK.

ENDLOOP.

In this loop why IT_VBAK is modified? You are transporting CHECK field, but this field contents

will be same like as they are existing in IT_VBAK. If you really want to modify IT_VBAK then set

WA_VBAK-CHECK = <<Some Value>>.

Without using the statement  WA_VBAK-CHECK = <<Some Value>>. no need modify IT_VBAK.

I hope you understood.

Regards,

Rafi

Read only

0 Likes
12,932

Hi Rafi,

Yes, I modified the code later. Actually the issue was resolved in the thread . It works perfect.

Regards.

Manish.

Read only

0 Likes
12,932

Hi Manish

I also stuck with the same point ,Can u please provide the modified code.

Read only

moshenaveh
Community Manager
Community Manager
12,932
Hello, While we're happy that you've come to SAP Community to get an answer to your question, you posted your question as an answer in an old thread.
I've converted your answer to a comment, but even so -- posting in older threads is not the best way to get guidance.
If you're looking for help, you should ask a new question: https://answers.sap.com/questions/ask.html.
Here are some tips to help you craft an effective question for our community: https://community.sap.com/resources/questions-and-answers, https://developers.sap.com/tutorials/community-qa.html, https://groups.community.sap.com/t5/welcome-corner-discussions/advice-from-sap-champions-questions-a....
I encourage you to follow this guidance, as I'd really like to see you get a solution to your problem.
I hope you find this advice useful!