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: 

Collect where itab structures are different...

Former Member
0 Kudos

Hi Experts,

I have a problem where by i'm trying to collect identical lines from an internal table.

What ive done in the past is to move the header line one by one and then collectther esults into a itab that has the same stucture as the contents being moved into it.

However, i'm trying to collect identical lines where by i have 4 columns usign the above steps but doesnt seem to be working. Any help would be greatly appreciated.

Thanks - DJ

DATA: BEGIN OF gt_data OCCURS 0,

material(13) TYPE C,

quantity TYPE i,

unique_no(18) TYPE C,

description(40) TYPE c,

END OF gt_data.

DATA: BEGIN OF gt_putput OCCURS 0,

material(13) TYPE C,

quantity TYPE i,

unique_no(18) TYPE C,

description(40) TYPE c,

END OF gt_output.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Qty should be last field

DATA: BEGIN OF gt_data OCCURS 0,

material(13) TYPE C,

unique_no(18) TYPE C,

description(40) TYPE c,

quantity TYPE i,

END OF gt_data.

DATA: BEGIN OF gt_putput OCCURS 0,

material(13) TYPE C,

unique_no(18) TYPE C,

description(40) TYPE c,

quantity TYPE i,

END OF gt_output

Regards

MD

6 REPLIES 6

Former Member
0 Kudos

Hi

Qty should be last field

DATA: BEGIN OF gt_data OCCURS 0,

material(13) TYPE C,

unique_no(18) TYPE C,

description(40) TYPE c,

quantity TYPE i,

END OF gt_data.

DATA: BEGIN OF gt_putput OCCURS 0,

material(13) TYPE C,

unique_no(18) TYPE C,

description(40) TYPE c,

quantity TYPE i,

END OF gt_output

Regards

MD

0 Kudos

Hi MD,

Even if i move type i to be the last field in both itabs this still doesnt work.

Anyone further ideas?

Cheers - DJ

0 Kudos

Hi

I hope you are looking unique combination of the following fields ?

material(13) TYPE C,

unique_no(18) TYPE C,

description(40) TYPE c,

If yes, than can you pls show the code written to collect

Regards

MD

0 Kudos

Hi MD,

OK, think the problem is that the material is the same, can you advise how to count integer from these 3 rows and then merge into 1??

Many thanks

Material Unique No Qty

C_TBKO1 |230920081111111-1 | 1

C_TBKO1 |230920081111111-2 | 1

C_TBKO1 |230920081111111-5 | 1

0 Kudos

Hi

Try the below code

DATA: BEGIN OF gt_data OCCURS 0,

material(13) TYPE C,

quantity TYPE i,

unique_no(18) TYPE C,

description(40) TYPE c,

END OF gt_data.

DATA: BEGIN OF gt_putput OCCURS 0,

material(13) TYPE C,

quantity TYPE i,

END OF gt_output.

sort gt_data.

loop at gt_data .

gt_putput-material = gt_data-material .

gt_putput-quantity = gt_data-quantity.

collect gt_putput.

endloop.

Let me know, if you need further help

Regards

MD

Edited by: Madhan Doraikannan on Sep 25, 2008 10:18 AM

Former Member
0 Kudos

Hi i hope description is not matching.

DATA: BEGIN OF gt_data OCCURS 0,

material(13) TYPE C,

quantity TYPE i,

unique_no(18) TYPE C,

description(40) TYPE c,

END OF gt_data.

DATA: BEGIN OF gt_putput OCCURS 0,

material(13) TYPE C,

quantity TYPE i,

unique_no(18) TYPE C,

description(40) TYPE c,

END OF gt_output.

loop at gt_data .

move : gt_data-material to gt_putput-material,

gt_data-quantity to gt_putput-quantity,

gt_data-unique_no to gt_putput-unique_no.

collect gt_putput.

endloop.

now fill the description by reading from first table looping through second table.