Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Compare 2 rows of an internal table

Hello,

I have a requirement where I have to compare the rows of an internal table (table containing poduction order no., material no, required quantity and used quantity) and get a count of the required quantity and used quantity for the same materials belonging to one production order.

For E.g.:

Prod Ord Material Req. Qty Used Qty

123 A 1 1

133 A 2 0

123 B 1 1

123 A 3 3

The quantities of Rows 1 and 4 need to be summed up. (as they correspond to the same material used within the same production order).

Please let me know if there is a method to do this.

I tried using SUM within AT END OF...ENDAT, but it does not do the summation, maybe because these quantity fields have the data type as QUAN.

Helpful suggestions will be greatly appreciated.

Thanks,

Rugmani

Tags:
replied

Hi,

Try using this:

1. Use the COLLECT command when u populate the internal table. Use it instead of Append.

ex: COLLECT WA_COMP TO IT_COMP.

2. Create another itab: IT_COMP2.

LOOP AT IT_COMP INTO WA_COMP.

COLLECT WA_COMP TO IT_COMP2.

ENDLOOP.

COLLECT compares all the character fields and sums the numeric and amount fields if the character fields are same.

See if it works...

- Hemant

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question