10-23-2006 2:25 PM
Hi,
I have one internal table.
in that itab i have one numberic fild as Billamount.
The sum of all the bill amt should be displayed in a textfield.
How to dot that.
I tried as
Loop at itab.
at end of billamt.
sum
endat.
endloop.
But how to place the sum in the text field.
Thanks & Regards,
Sumithra
10-23-2006 2:28 PM
data: v_billamt(20).
Loop at itab.
at end of billamt.
sum.
v_billamt = itab-billamount.
endat.
endloop.
write:/ v_billamt.
10-23-2006 2:28 PM
Loop at itab.
at end of <b>billno</b>.
sum
<b>write billamt to ltext.</b>
endat.
endloop.
<b>Please note the change in the above..previously it was billamt..hence it just showed the last billamt. if you wish to sum the amount at end of each bill or material or customer you can use the particular field. If you need the grand total than please use AT LAST.<b></b></b>
Message was edited by: Anurag Bankley
10-23-2006 2:38 PM
Hi Ravi & Anurag,
both are not working.
If I give itab-Billamt...its copying the last amt not the Sum
If igive "write to"..its not copying the Sum.
10-23-2006 2:59 PM
Check Anurags last post. It will give you the required result.
Regards,
ravi
10-23-2006 2:50 PM
Hi Vasu,
Hope you are showing the Sum of amounts for some Document number. Keep your internal table with the Document number as first field. After populating data into the internal table, sort it by Document Number(First field). Then use the logic At end of Document Number... SUM... Move Amount field to text.
10-23-2006 2:55 PM
try this
data: v_billamt(20).
Loop at itab.
at end of billamt.
sum.
endat.
v_billamt = itab-billamount.
endloop.
write:/ v_billamt.
10-23-2006 3:04 PM
HI,
data v_sum(20) type c
Loop at itab.
at end of billamt.
sum.
v_sum = itab-qty.
condense v_sum.(remove leading spaces)
endat.
endloop.
write v_sum input.
Regards
amole
10-23-2006 3:10 PM
DATA : BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN ,
LFIMG LIKE LIPS-LFIMG,
END OF ITAB .
DATA: v_tot like lips-lfimg,
V_SUM like lips-lfimg.
SELECT VBELN LFIMG
INTO TABLE ITAB
FROM LIPS
WHERE VBELN = '0080576653'.
LOOP AT ITAB .
AT END OF VBELN .
SUM.
v_tot = v_tot + itab-lfimg.
move v_tot to v_sum.
clear v_tot.
ENDAT.
ENDLOOP.
WRITE:/ V_SUM.
delivery num i have two quantities 5 1nd 15
tot is 15.
When you use SUM in a LOOP with an explicitly specified output area, this output area must be compatible with the line type of the internal table.
When using LOOP to process a sorted extract (see SORT), the control total of f at the end of the group appears in the field SUM(f) - - if f is type I, F or P.
hope this helps ..
regards,
vijay.
10-23-2006 3:12 PM
Hi Sumi,
if you want the sum per billamt you have to make
an own sum-table.
data: begin of sum_table occurs 0,
bill like ...
billamout like ...
end sum_table.
*
loop at itab.
...
sum_table-bill = itab-bill.
sum_table-billamount = itab-billamount.
collect sum_table.
...
endloop.
at this code you don't need at end of bill.
Hope it helps.
regards, Dieter
10-23-2006 3:19 PM
Hi sumithra ,
like there is a possibility of sum_overflow if in ur itab structure a field is present say
begin of itab occurs 0
peinh like mbew-peinh
end of itab .
now peinh is price unit of length 5
but if do
loop at itab
sum .
endloop.
since peinh holds number value this also gets added
causing u r using sum in loop endloop.
and the whole value is added up cause of sum and if the value exceeds 99999 max for range of 5 digits
then it may result in sum over flow .
just remember this and do a cross check on ur itab ..
if u can send the code to us it will be easy for us to interpret .
regards,
Vijay
10-24-2006 9:28 AM
Hi sumithra ,
go through this sample code .
take a delivery number from ur lips table which is having some items and quanity and substitute that number in this code as WHERE VBELN = 'XXXXXXXXXX'.
*****************************************************
DATA : BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN ,
LFIMG LIKE LIPS-LFIMG,
END OF ITAB .
DATA: v_tot like lips-lfimg,
V_SUM like lips-lfimg.
v_sum(13) type c.
SELECT VBELN LFIMG
INTO TABLE ITAB
FROM LIPS
WHERE VBELN = '0080576653'.
LOOP AT ITAB .
AT END OF VBELN .
SUM.
move itab-lfimg to v_sum.
write itab-lfimg to v_sum.
ENDAT.
ENDLOOP.
WRITE:/ V_SUM.
*****************************************************
u can use move to v_sum and here the both data types should be equal ,
put in *
u can use write also ,, here v_sum declared as type c
note the difference .
just put a debugging point in the at end in ur code and see how this is fetching the value to the field .
regards,
VIjay.
kindly close the thread if ur query is solved .
10-24-2006 9:42 AM