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: 

Finding the totals

Former Member
0 Kudos
98

Hi,

In my scenario if i give a range of document number(belnr) i have to fetch the details of the PO and have to find the totals of the PO from the history tab.

I have written the code as

gi_value and gi_amt are like table ekbe.

gv_total = 0.

LOOP AT gi_value WHERE vgabe = 1.

gv_total = gv_total + gi_price-dmbtr.

APPEND gi_value TO gi_amt.

ENDLOOP.

this code is working fine if i give only one belnr value.It identifying the total correctly.If i give 10 belnr values its finding the total of 10 belnr.In my scenario have to find the totals of each belnr based on PO number to do further coding.How to do so.Please help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
69

use at new

data: gs_value like line of gi_value.


LOOP AT gi_value into gs_value WHERE vgabe = 1.
at new belnr.
APPEND gs_value TO gi_amt.
endat.
gv_total = gv_total + gs_price-dmbtr.
ENDLOOP.

Edited by: riki frisky on Feb 19, 2009 9:52 AM

3 REPLIES 3

Former Member
0 Kudos
70

use at new

data: gs_value like line of gi_value.


LOOP AT gi_value into gs_value WHERE vgabe = 1.
at new belnr.
APPEND gs_value TO gi_amt.
endat.
gv_total = gv_total + gs_price-dmbtr.
ENDLOOP.

Edited by: riki frisky on Feb 19, 2009 9:52 AM

Former Member
0 Kudos
69

Hello

Use COLLECT instead of APPEND.

0 Kudos
69

Hi ,

Your requirement is not clear, you are taking the total in to GV_TOTAL field.

If you have 10 belnr numbers it will obviously add all the amounts .

Do you want amounts to be added for each PO. If so after each PO where do you want to place the total do u want to place it in any internal table?

what is the need of APPEND gi_value TO gi_amt statement in your code?

you are directly appending the content of gi_value table to gi_amt with out making any modifications in gi_valueit structure..

It is as good as below code.

gi_amt[] = gi_value [] .

Can you please make your requirement little more clear.