Home » Developer & Programmer » Forms » troble in totaling
troble in totaling [message #78298] Tue, 12 February 2002 02:04 Go to next message
annu
Messages: 34
Registered: February 2002
Member
i have three column in my tabular form one column is amt_dr , sec is amt_cr and third one is balance .. i want to make running total in balance column ..
In my tabular form first record total is based on amt_dr-amt_cr=balance but the sec record and the rest of records are based on previous row balance+currrent record amt_dr-amt_cr = balance formula .. how i make it possiable to reach my condition. is there any one tell me ?
Re: troble in totaling [message #78301 is a reply to message #78298] Tue, 12 February 2002 06:01 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
here is the code u will need

balance:=0
go_block(your_block);
first_record;
loop
:your_block.balance:=balance+:your_block.amt_dr- :your_block.amt_cr;
balance:=:your_block.balance;
exit when :system.last_record='TRUE';
down;
end loop;
Re: troble in totaling [message #78323 is a reply to message #78298] Wed, 13 February 2002 19:26 Go to previous messageGo to next message
annu
Messages: 34
Registered: February 2002
Member
dear Pratap,
thank u for your kind attn. I use your above given code which really works . But first understand what i actually needs, Here the question occurs where should i apply your coding, i which triggure. Suppose if i apply in when new form instance then it fires only one time when forms runs, beside i need to total balance on every row. If i use when new record instance then it work every row but becuz of initializing 0 to balance in coding we got onely total of current row. So pleaz tell me where should i apply this coding in which triggure.

beside this i also what to know that at a time i only want to put input in amt_dr or amt_cr. If i input in amt_dr then leave amt_cr with 0 or if i input in amt_cr then leav amt_dr with 0. Tell me How it is possiable?

Annu
Re: troble in totaling [message #78326 is a reply to message #78298] Wed, 13 February 2002 23:57 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
hi annu,

1. first create a procedure of these code.let us call it "calculate_balance".

balance:=0
go_block(your_block);
first_record;
loop
***:your_block.balance:=balance+nvl(:your_block.amt_dr,0)- nvl(:your_block.amt_cr,0);
balance:=:your_block.balance;
exit when :system.last_record='TRUE';
down;
end loop;

2.your question is when to call it.as changes to amt_cr and amt_dr affects the balance . in when_validate_item trigger of both field call the procedure "calculate_balance"
3.see the code above (see the line marked ***). i have applied nvl function. so if u leave one of field blank.it will treat it as zero.

Hope it helps!!! i think i am pretty clear.if u have still problem then feel free to discuss.

cheers
pratap
Re: troble in totaling [message #78358 is a reply to message #78298] Fri, 15 February 2002 20:22 Go to previous message
rama krishna
Messages: 97
Registered: December 2001
Member
which version of forms u r using????
if it is forms 6i, u don't need to write any code......
in the when_new_block_instance take the previous records balance into a global variable by navigating into previous block
go to balance item properties. calculation mode set it to formula and in formula add this
:global.variable + :amt_dr - :amt_cr.
thats it it will work properly
any problem u can send me queries
ram
Previous Topic: forms and joins
Next Topic: Re: designer 6i repository installation
Goto Forum:
  


Current Time: Mon Mar 30 00:21:21 CDT 2020