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

Total for invoice wise material

former_member203806
Participant
0 Likes
1,209

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
Read only

former_member212148
Participant
0 Likes
1,177

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
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,177

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

Read only

0 Likes
1,177

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

Read only

former_member212148
Participant
0 Likes
1,178

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.

Read only

former_member187748
Active Contributor
0 Likes
1,177

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.

Read only

0 Likes
1,177

hi sanjeev

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

Rgds

pp

Read only

Former Member
0 Likes
1,177

This message was moderated.