2006 Jun 21 12:15 PM
hi.. all,
i am struck with some problem in script, can any one help me.
my problem is i hv two fields total price & total qty, i hve to get the out put. i wrote the code for that. like that i have 4-5 fields or blocks, i need to get the total of all those fields.
1. total price * qty = total amount
2. total price * qty = total amount
3. total price * qty = total amount
4. total price * qty = total amount
-
sum = xxxxxxxxxxxx
-
the sum shld change dynamically as per no. of records, i mean, if i hve two records i shld get sum of total amount for two records. plz help me.
Hi use 'SUM' statement at end of your loop to get total.
LIKE.
LOOP AT itab.
AT LAST.
SUM.
call your text element to write values.
ENDAT.
ENDLOOP.
Regards,
Wasim Ahmed
2006 Jun 21 12:35 PM
Hi,
Its very simple.
Take 2 variables (VAR1, VAR2).
VAR1 - total of all fields within the record.
VAR2 - Sum of all records.
If you are in LOOP,
for each field while calculating total amount, add total amount to one variable (VAR1).
total amount = total price * total quantity
var1 = var1 + total amount.
Then for each end of record (before end loop), assign the var1 to var2.
var2 = var2 + var1.
clear var1.
regards,
Subba.
2006 Jun 21 1:26 PM
loop at lt_tab.
sum = price * qty.
totsum = totsum + sum.
endloop.
you can use this for any number of records...
RS
2006 Jun 21 1:30 PM
you can not do the manupulation of fields in script.
so write a PERFORM & define that FORM in any z program & pass all your field values & do the sum & revert it to the script.
regards
srikanth
2006 Jun 21 1:31 PM
Hi use 'SUM' statement at end of your loop to get total.
LIKE.
LOOP AT itab.
AT LAST.
SUM.
call your text element to write values.
ENDAT.
ENDLOOP.
Regards,
Wasim Ahmed
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |