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

Using Collect statement!!

Former Member
0 Likes
615

Hi All,

i have a requirment .

i have a internal table ITAB1.

when iam displaying my alv report.

vendor name profitcntr plnt valclas materlno matdec quantity Standard price

1000 ram 100 200 abc m-123 test1 200 20

ram 100 200 abc m-123 test1 100 20

ram 100 200 abc m-123 test1 700 20

ram 100 200 abc m-123 test1 900 20

1000 ram 100 200 abc m-345 test2 200 20

ram 100 200 abc m-345 test2 100 20

2000 dam 100 200 abc m-123 test1 400 20

dam 100 200 abc m-123 test1 100 20

dam 100 200 abc m-123 test1 800 20

dam 100 200 abc m-123 test1 900 20

i need to collect reocrds which are same for a particular vendor..

instead of append iam using collect statement.

i need outupt in this way.

1000 ram 100 200 abc m-123 test1 1900 20

1000 ram 100 200 abc m-345 test2 300 20

2000 dam 100 200 abc m-123 test1 2200 20

but its displaying in this way.

1000 ram 100 200 abc m-123 test1 1900 80

1000 ram 100 200 abc m-345 test2 300 40

2000 dam 100 200 abc m-123 test1 2200 80

the last numeric field standard price is also adding but it should not add.

how can i do that.

Thanks & Regards

Jerry

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
593

Hi,

declare your last numeric field as N .

COLLECT add only those fields which are of number typy like I.

regards,

Anirban

4 REPLIES 4
Read only

Former Member
0 Likes
594

Hi,

declare your last numeric field as N .

COLLECT add only those fields which are of number typy like I.

regards,

Anirban

Read only

Former Member
0 Likes
593

Hi,

you can us append statement instead of collect statement so that it wont add fields

Regards

Chandu

Read only

Former Member
0 Likes
593

Declaring with type as Numeric for the last field will avoid the problem ( xyz type N).

otherwise remove the last field from itab1 and move to itab2. Do the collect statement and move back the last field to itab2.

Read only

Former Member
0 Likes
593

Hi Jerry,

I hope your issue got resolved. Please close the thread if it has.

To add few points on it, even SAP recommends not to use collect. But if you can give a try it's well and good.

The other option is: Try using the 'At New'/'At End' with SUM option.

Let me know if you need more details on it.

Regards,

Santosh Verma,

Deloitte, India