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: 

To get average of netwr based on matnr

Former Member
0 Kudos

Hi,

I have a requirement to print average of netwr (net value) for similar matnr (materials) for a particular range of vbeln (Slaes order).

The problem i am having is how will i take the condition 'Similar Materials' and then get the average.

How should i go about this requirement?

Regards,

Darpana.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

suppose u have data in the internal table itab.

data: begin of itab occurs 0,

matnr type matnr,

netwr type netwr_g,

end of itab.

data: n type i,

sort itab by matnr.

loop at itab.

n = n + 1.

at end of matnr.

avg = sum / n.

*move this avg to another internal table.

n = 0.

endat.

endloop.

revrt back if any issues,

Regards,

Naveen

7 REPLIES 7

Former Member
0 Kudos

Hello

You will have to do average of all VBAP-NETWR for a given material in VBAP-MATNR... (Same material across different sales orders)

Thanks

Amol Lohade

Former Member
0 Kudos

Hi,

suppose u have data in the internal table itab.

data: begin of itab occurs 0,

matnr type matnr,

netwr type netwr_g,

end of itab.

data: n type i,

sort itab by matnr.

loop at itab.

n = n + 1.

at end of matnr.

avg = sum / n.

*move this avg to another internal table.

n = 0.

endat.

endloop.

revrt back if any issues,

Regards,

Naveen

0 Kudos

Each sales order has different materials.

How will i separate each of the similar materials and then find average of net value from these similar materials?

0 Kudos

hi,

provide me the test data how it looks in the internal table. Then i can answer ur question, as i didnt understand.

revrt back

regards,

Naveen

0 Kudos

Collect material and net value from VBAP into an internal table. Then loop over said table and calculate the average net value by dividing the collected net value by the number of occurences of the material.

Basically, almost like the example above.

0 Kudos

Hi

To get information according to similar materials, you must be maintaining some type of grouping like using field Material Type. You have to sort your internal table as per the material type and then if you are displaying the data in ALV then use SORTINFO to add sorting information according to the material type and add subtotal information for the NETWR field in Field catalog.

Regards

Vijai

Former Member
0 Kudos

Get the value into a particular internal table when the range of vbeln.get the matnr alone into a itaernal table ok.delete the adjacent duplicates form the internal table havibg matnr only.Then loop the internal table having matnr and then under that give another loop looping the table we have all the details.In the second loop check the matnr if matnr is same you can append to another new internal table and adding netwr.