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: 

Total for invoice wise material

former_member203806
Participant
0 Kudos

Hi All

I Have following internal table,

VBELN           matnr          qty

1000005           m1              5

1000005           m1              3

1000005           m2              2

1000006           m2              5

Requirement is :

1000005           m1          8

1000005          m2           2

1000006          m2           5

How i can do this.....

Rgds

pp

1 ACCEPTED SOLUTION

former_member212148
Participant
0 Kudos

Hi Pramod,

Create one more internal table ITFIINAL with one more field v_total.

pass data intis internal table.

here itab is internal as you created in your program.

itfinal[] = itab[].

data: v_total like vbrk-menge.  " Declare variable.

sort itfinal.

delete adjecent duplicat from itfinal comparing vbeln matnr.

loop at itfinal.

loop at itab where vbeln = itfinal-vbeln and matnr = itab-matnr.

itfinal-v_total = itfinal-v_total +  v_toal .

endloop.

modify itfinal transporting v_total.

clear: v_total.

endloop.

Now internal table ITFINAL contains record as you want.

Any issue write.

Thanks,

Ranjit Kumar.

6 REPLIES 6

arivazhagan_sivasamy
Active Contributor
0 Kudos

Hi Pramod,

Itab-vbeln = 1000005.

itab-matnr = m1.

itab-qty = 5.

collect itab.

Itab-vbeln = 1000005.

itab-matnr = m1.

itab-qty = 3.

collect itab.

Itab-vbeln = 1000005.

itab-matnr = m2.

itab-qty = 2.

collect itab.

Itab-vbeln = 1000006.

itab-matnr = m2.

itab-qty = 5.

collect itab.

You will get required output.

When using collect statement, if non-numerical(C,N,D,T) fields are same, numerical(P,I and F) fields will be added.

Arivazhagan S

0 Kudos

Hi Arivazhagan

actually my internal table will dynamically change. so how can i put u r logic for it?

(Collect Line by line is not possible)

Rgds

pp

former_member212148
Participant
0 Kudos

Hi Pramod,

Create one more internal table ITFIINAL with one more field v_total.

pass data intis internal table.

here itab is internal as you created in your program.

itfinal[] = itab[].

data: v_total like vbrk-menge.  " Declare variable.

sort itfinal.

delete adjecent duplicat from itfinal comparing vbeln matnr.

loop at itfinal.

loop at itab where vbeln = itfinal-vbeln and matnr = itab-matnr.

itfinal-v_total = itfinal-v_total +  v_toal .

endloop.

modify itfinal transporting v_total.

clear: v_total.

endloop.

Now internal table ITFINAL contains record as you want.

Any issue write.

Thanks,

Ranjit Kumar.

former_member187748
Active Contributor
0 Kudos

Hi Pramod , why not you are using the concept of ON CHANGE OF matnr.

Or you can use AT NEW statement.

Summarize your internal table accordingly.

0 Kudos

hi sanjeev

As per my requirement AT NEW is not possible, because i have two veblen & matnr wise total..

Rgds

pp

Former Member
0 Kudos

This message was moderated.