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

collect statement

Former Member
0 Likes
705

Hi all,

Iam using a collect statement with all fields which belong to char type. All the values differ in each record. Can i use a collect statement here. If yes! then how it is possible.

for example.

loop at itab.

matnr like mard-matnr, "Material Number

werks like mard-werks, "Plant

lgort like mard-lgort, "Storage Location

mtart like mara-mtart, "Material type

abcin like marc-abcin, "Physical inv ind for cycle

endloop.

material and plant will be the same, but others differ for each record.

Please give your suggestions,

Thanks,.

Rajesh.

6 REPLIES 6
Read only

dani_mn
Active Contributor
0 Likes
675

HI,

why you are using collect when all fields are character type. there is no usage of this. collect sum of the numeric fields where all character fields match.

So use append.

Regards,

Read only

Former Member
0 Likes
675

sorry there is a qty field in it.

Rajesh.

Read only

Former Member
0 Likes
675

Hi rajesh,

1. Can i use a collect statement here

We can use collect statement in all internal tables.

2. The only MAIN CONCEPT is

3. that it will SUM up the Quantity fields,

based upon

the COMBINATION of all Character Fields.

regards,

amit m.

Read only

Former Member
0 Likes
675

hi

good

you can use the collect statement in this way.

Collect:

When the line is inserted, the system checks whether there is already a table entry that matches the key. If there is no corresponding entry already in the table, the COLLECT statement has the same effect as inserting the new line. If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.

You should only use the COLLECT statement if you want to create summarized tables. If you use other statements to insert table entries, you may end up with duplicate entries.

GO THROUGH THIS LINK

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm

thanks

mrutyun^

Read only

Former Member
0 Likes
675

hi

good

you can use the collect statement in this way.

Collect:

When the line is inserted, the system checks whether there is already a table entry that matches the key. If there is no corresponding entry already in the table, the COLLECT statement has the same effect as inserting the new line. If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.

You should only use the COLLECT statement if you want to create summarized tables. If you use other statements to insert table entries, you may end up with duplicate entries.

GO THROUGH THIS LINK

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm

thanks

mrutyun^

Read only

Former Member
0 Likes
675

Hi,

Mrutyunjaya Tripathy is answer is very useful u can follow his answer.

Regards

Justin