Search
Search

# Internal Table Logic Needed

Hi all,

I have a requirement regarding data processing in a internal table,

internal table consists of filelds Vendor,Material and Scheduling Dates and Total Qty.

Here i need to fill the field Total Quantity, individual addition of quanties of that material for a particular vendor .

Let us consider intitially my internal table consists of data like this with these fields.

Vendor , Material , qty(individual), Total qty , Schedule dates

v1 , m1 , 10

v1 , m1 , 10

v1 , m1 , 20

v1 , m2 , 5

v1 , m2 , 10

v2 , m2 , 20

v2 , m2 , 15

v2 , m3 , 20

v2 , m3 , 10

Initiall the total qty field is empty i need to fill tht field for the last item for a particular material Like M1

for vendor v1 and total qty of m2 for vendor v1, total qty of m1 for v2, total qty of m2 for v2 and so on.

Requied output should be like this.

Vendor , Material , qty(individual) Total qty Schedule dates

v1 , m1 , 10 , 0

v1 , m1 , 10 , 0

v1 , m1 , 20 , 40(101020)

v1 , m2 , 5 , 0

v1 , m2 , 10 , 15(5+10)

v2 , m2 , 20 , 0

v2 , m2 , 15 , 35(20+15)

v2 , m3 , 20 , 0

v2 , m3 , 10 , 30(20+10)

Here i made one thing , i calculated the total qty of material for particular vendor.

Like

Vendor Material Total Qty

v1 , m1 , 40

v1 , m2 , 15

v2 , m2 , 35

v2 , m3 , 30

Finally i need the logic by using Control Events(At New , At End of ) to adjust that total qty of a material for a particular vendor by Modifying the internal table.

i hope my problem is clear , pls let me know if any clarifications needed. and

code for the same .

Niranjan.

##### Former Memberreplied

Use this code!

```data: total type i.
loop at itab.                    " itab is assumed to be with header.
total = total + itab-quantity. " adding quantities
at end of material.            " triggerred when material or vender ends (about to change)
itab2-total = total.
modify itab.                 "Modify the internal table
clear total.
endat.
endloop.
Delete itab where quantity = ' '.```

So you get the entries like you mentioned.

If you want to retain the previous internal table also then copy internal table first and then manipulate.

Regards,

Lalit Mohan Gupta.

0 View this answer in context
View more on this topic or