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
data: v_billamt(20).
Loop at itab.
at end of billamt.
sum.
v_billamt = itab-billamount.
endat.
endloop.
write:/ v_billamt.
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
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.
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.
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
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
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 .
Add a comment