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: 

AGGREGATION OF QUANTITY(MARD-LABST) FIELD

Former Member
0 Kudos

I want to aggregate quantity field(MARD-LABST) based on

werks and lgort. Please explain

me sample example ?

Kindly explain me.

2 REPLIES 2

b_deterd2
Active Contributor
0 Kudos

Don't have an an eample right now but you should search in this forum for the abap statement COLLECT.

Good luck,

Bert

Former Member
0 Kudos

Hi Saritha,

As suggested..you can use collect statements:

Imagine you have a table with 3 fields

werks / lgort / quantity and stored in an internal table

using collect statement all numeric values will be added

so you have values in itab as fillows

WERK1 STORAGE1 001

WERK2 STORAGE1 100

WERK1 STORAGE2 200

WERK1 STORAGE1 100

so first (1) create anither internal table same as itab lets say itab_coll

(2)do a sort statement on itab

WERK1 STORAGE1 001

WERK1 STORAGE1 100

WERK2 STORAGE1 100

WERK1 STORAGE2 200

loop at itab into workarea.

collect workarea to itab_coll.

endloop.

output:

WERK1 STORAGE1 101(adds same werks/lgort quantities)

WERK2 STORAGE1 100

WERK1 STORAGE2 200

so collect does an append + sum if the non-numeric fields are similar..but keep in mind that all numeric fields will be added

Regards

Byju