Home » Developer & Programmer » Forms » re: trouble in total
re: trouble in total [message #78333] Thu, 14 February 2002 21:04 Go to next message
annu
Messages: 34
Registered: February 2002
Member
Dear pratap

Thanks for your atten.
well i make a triggure on When_new_form_instance with your given codes. Actually i need this becuz i want to fire it when form load

*****Triggure When_new_Form_instance

begin
Set_Window_Property(FORMS_MDI_WINDOW, WINDOW_STATE, MAXIMIZE);
set_window_property('window1',window_state,maximize);
execute_query;
:global.mbal:=0;
go_block('acc_trans');
first_record;
loop
:acc_trans.balance:=:global.mbal+:acc_trans.amountdr-:acc_trans.amountcr;
:global.mbal:=:acc_trans.balance;
down;
exit when :system.last_record='TRUE';
end loop;
end;
******************
It works perfectly, now i need to calculate balance during input. For that i make a program unit function named as u said calculate_balance
just like :

FUNCTION calulate_balance RETURN number IS
a number;
BEGIN
a:=:global.mbal+nvl(:acc_trans.amountdr,0)- nvl(:acc_trans.amountcr,0);
:global.mbal:=:acc_trans.balance;
return a;
END;

*****************
Now i control it on item level using amountdr and amountcr triggure key_next_item, like ....

begin
if :amountdr>0 then
next_record;
else
next_item;
end if;
end;
*************
now tell me how to call function calculate_balance here in this triggure, I mean what to declare and what is the syntex to calling programm unit function ... if u feel that i make any mistake in the above coding or style, so please suggest me ..

thanking you again

Annu
Re: re: trouble in total [message #78336 is a reply to message #78333] Fri, 15 February 2002 00:32 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
Hi annu,

you have making lot of mistake.you do not have to use global variable and function.
you have to just create one procedure and call it from triggers

here is the total code
..................................
Procedure calulate_balance IS
balance number;
BEGIN
balance:=0;
go_block('acc_trans');
first_record;
loop
:acc_trans.balance:=balance+nvl(:acc_trans.amountdr,0)-nvl(:acc_trans.amountcr,0);
balance :=:acc_trans.balance;
down;
exit when :system.last_record='TRUE';
end loop;
END;

when_new_form_instance
--------------------------------------
begin
Set_Window_Property(FORMS_MDI_WINDOW, WINDOW_STATE, MAXIMIZE);
set_window_property('window1',window_state,maximize);
execute_query;
calculate_balance;
end;

when_validate_item trigger for amountdr
---------------------------------------------------------
begin
calculate_balance;
end;

when_validate_item trigger for amountcr
---------------------------------------------------------
begin
calculate_balance;
end;

cheers
pratap
Re: re: trouble in total [message #79042 is a reply to message #78336] Tue, 16 April 2002 22:55 Go to previous message
vishal gupta
Messages: 111
Registered: March 2001
Senior Member
In Developer 5.0 & above U can use summary column for this purpose instead of using such long algrothym.
Previous Topic: Inserting a page break in Report
Next Topic: Does This Happen To Everyone???
Goto Forum:
  


Current Time: Mon Aug 10 15:38:32 CDT 2020