Populating the Results in the item :Problem [message #137319] |
Wed, 14 September 2005 11:36 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
hamdard
Messages: 37 Registered: July 2005
|
Member |
|
|
Hi,
I'm trying to solve this problem from many hours but of no avail. Anybody please help.
I have a master and detail form.
I have one number column, total_price in the master form.
I have 3 number columns in the detail form.
say, price, discount, total.
the total column is calculated automatically whenever user enters the discount and moves out of the discount item.
As detail block is a multi-record block, user can enter the prices more than once.
I need to calculate the SUM(total) in the detail block and populate this sum to the total_price in master form.
I'm applying this logic.
Post-Text-Item trigger on total (detail-block)
:GLOBAL.g_total := 0;
IF :System.CURSOR_RECORD = 1 THEN
:GLOBAL.g_total := :my_detail_block.total;
:my_master_block.total_price := :GLOBAL.g_total;
ERASE('GLOBAL.g_total');
ELSIF
:SYSTEM.CURSOR_RECORD = 2 THEN
:GLOBAL.g_total := :my_detail_block.total;
:my_master_block.total_price := :my_master_block.total_price + :GLOBAL.g_total;
ERASE('GLOBAL.g_total');
ELSIF
:SYSTEM.CURSOR_RECORD = 3 THEN
:GLOBAL.g_total := :AD_CONTRACT_DETAIL.nett_price;
:my_master_block.total_price := :my_master_block.total_price + :GLOBAL.g_total;
ERASE('GLOBAL.g_total');
END IF;
This code is only working when user creates the new record. But when the user updates the record, you can see that this code will not work.
Please suggest me a proper way. I want the total_price column in the master form always show the sum of total column in detail block. Whether the user inserts a new record or updates the record.
Please help.
Thank You.
|
|
|
|
Re: Populating the Results in the item :Problem [message #137506 is a reply to message #137367] |
Thu, 15 September 2005 07:19 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
hamdard
Messages: 37 Registered: July 2005
|
Member |
|
|
Hi,
Thanks alot Mr. David.
Before posting my question I tried what you have suggested and I tried it in different ways but it was not working properly.
Anyhow, after posting my question, I was trying to solve it and I got the solution.
I created a new item in the detail block and made it a SUMMARY item and calculated the sum for my required item into this new item. and then in post item trigger, I just copied the value from the newly created item to the total_price item in master form and it's working like a magic.
Now, no matter if the user is entering a new record or modifying an existing record, the total_price item in the master form will be synchronized with the resultant sum of the price in detail block.
Thank you again so much for your precious reply.
regards.
|
|
|
|
|
|
Re: Populating the Results in the item :Problem [message #355539 is a reply to message #137637] |
Fri, 24 October 2008 17:51 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
wdv12345
Messages: 2 Registered: October 2007 Location: Tegucigalpa
|
Junior Member |
|
|
Just a brief grammar lesson for you both:
Magic is not a verb, but an uncountable noun and adjective. The expression "It's working like magic." is correct, though. Look at this other sentence: Magic is what he does for a living.
djmartin, thanks a lot for your advice at every time we have bugs messing around our programs.
|
|
|
|