Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Google search


Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
15%
200 - 500 GB
27%
500 - 800 GB
3%
800 - 1200 GB
9%
1200 - 1500 GB
12%
1500 - 2000 GB
12%
> 2000 GB
21%
Total votes: 33

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 4th September 2018, 14:21
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Extension - Execute when an object finishes initialization
Baan: Other/Unknown
C/S: None/Unknown

Hi,

I created an extension type Table for tisfc001. I want it to execute some functions when a new record is created. Sounds easy, right?
Yes. I then implemented on After Save hook with the condition "mode = DAL_NEW". As a result, the functions inside the condition get executed as expected. However, the functions need to use some data that is related to the table, which is Material. The tough part comes when I realized that the data that link to the table is generated after a new Production Order is created. Therefore, my functions inside the Extension cannot perform correctly because the data is not there in time.

To make it easier to understand, let me visualize it this way. It now flows like this:
1. Create new record
2. After Save hook is executed
3. The related data is generated according to the newly created order

The desired flow:
1. Create new record
2. The related data is generated according to the newly created order
3. **a way to execute the functions here**

The generated data often have many records.
The After Save hook triggers in total of 3 times like this:
1. DAL_NEW
2. DAL_UPDATE
3. DAL_UPDATE
at the point of 2. and 3. are the only moment that the functions can perform correctly since the required data is not generated in the step 1.

I tried using CDF in this table to act as a flag.
When an order is created, the flag is initialized to 0, and when the After Save hook gets executed, it will check if this CDF is 0, which means it was just created then it will perform the functions and then update the CDF to other value such as 1 in order to trigger it only once.
The problem is that updating in the same table as the table in the After Save here is not allowed because it will cause a recursion. So, this method is not valid.

In case who wants to see the code, it's as simple as this:
Code:
function extern long after.save.object(long mode)
{
	if mode = DAL_UPDATE then
	        some.functions.to.run() |* Gets executed 2 times on creating new record
	endif
	return (0)
}
Please help.

Regards,
Thana
Reply With Quote
  #2  
Old 4th September 2018, 17:19
Ajesh's Avatar
Ajesh Ajesh is offline
Guru
 
Join Date: Feb 2009
Posts: 534
Ajesh is on a distinguished road
Baan: LN 10.4 - DB: Oracle - OS: HP-Unix
You mean to say you want some data in some other related table than tisfc001 ? But that data is not coming at the time of after.save.object.

Why dont you try writing in db dll? specifically in db.after.update() Hook,worth a try...
Reply With Quote
Sponsored Links
  #3  
Old 5th September 2018, 06:57
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Quote:
Originally Posted by Ajesh View Post
You mean to say you want some data in some other related table than tisfc001 ? But that data is not coming at the time of after.save.object.
Yes, I think you understand most of it.

Quote:
Originally Posted by Ajesh View Post
Why dont you try writing in db dll? specifically in db.after.update() Hook,worth a try...
I have never tried db dll. Could you please give me more details about what it is and how to start using it?

By the way, I have changed the method of achieving the goal to use another hook that is somehow acceptable; so, this case is not urgent anymore but solving it will lead to a knowledge that one might find it useful in the future.
Reply With Quote
  #4  
Old 5th September 2018, 09:57
Ajesh's Avatar
Ajesh Ajesh is offline
Guru
 
Join Date: Feb 2009
Posts: 534
Ajesh is on a distinguished road
Baan: LN 10.4 - DB: Oracle - OS: HP-Unix
db dll wouldnt work because after its execution after.save.object will be called.

At this point i could think of scrapping the extension altogether and write a User Exit dll, In the after.after.save.object hook of User Exit.

Other option is in the Session Extension of that session and including New Record and after.command of that new Record you can write your logic. But it depends whether you want your logic to execute every time at a New Record creation or only through entering of that session. In the First case writing a Session Extension wouldnt work...
Reply With Quote
  #5  
Old 5th September 2018, 13:45
JaapJD's Avatar
JaapJD JaapJD is offline
Guru
 
Join Date: Sep 2002
Location: Netherlands
Posts: 803
JaapJD will become famous soon enoughJaapJD will become famous soon enough
Baan: BaanIV, BaanERP, ERP LN 6.1 - DB: Oracle, SQL Server - OS: Unix, Windows
I would do it the other way round: In the table extension of the Material table you can update tisfc001...
Reply With Quote
  #6  
Old 6th September 2018, 04:46
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
When a Production Order is created, Materials will be generated accordingly and there are a lot of them. I was thinking of a way to run only when the last Material is generated but I don't know how to check for the conditions. Moreover, I don't know if this will impact any other part of the system, like if a Material is created separately (I don't know if it is possible) then the extension will trigger, which it is not supposed to.
Reply With Quote
  #7  
Old 6th September 2018, 15:47
Ajesh's Avatar
Ajesh Ajesh is offline
Guru
 
Join Date: Feb 2009
Posts: 534
Ajesh is on a distinguished road
Baan: LN 10.4 - DB: Oracle - OS: HP-Unix
What do you mean by Materials will be generated? Which Table you are talking about?
Reply With Quote
  #8  
Old 7th September 2018, 04:47
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
Quote:
Originally Posted by Ajesh View Post
What do you mean by Materials will be generated? Which Table you are talking about?
Materials are data in table ticst001. They will be automatically created from some conditions after a Production Order is created.
Reply With Quote
  #9  
Old 17th September 2018, 14:50
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
Lightbulb I might be missing something but...

... why not just declare a global flag variable and use it like you were trying to use CDF? it should retain its value between hook calls.
Reply With Quote
  #10  
Old 20th September 2018, 09:14
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
The point is that the hook is not firing in the needed timing.
Reply With Quote
  #11  
Old 20th September 2018, 12:02
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
But your original post states that after.save hook gets called 3 times, 2nd and 3rd being the eligible ones. How so?
Reply With Quote
  #12  
Old 21st September 2018, 04:41
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
because they are in DAL_UPDATE step, which is not exactly where I wanted to have my functions executed. I want it to execute the functions when a new record is created, which should be DAL_NEW but it just doesn't do at the right moment for me.
Reply With Quote
  #13  
Old 21st September 2018, 09:12
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
But afer.save hook with mode=DAL_UPDATE is called right after the materials are created. This is exactly what you need, no?
Reply With Quote
  #14  
Old 21st September 2018, 13:51
tmannais's Avatar
tmannais tmannais is offline
Member
 
Join Date: Jul 2017
Posts: 98
tmannais is on a distinguished road
Baan: LN 10.5 - DB: MySQL - OS: Windows
For that particular event, yes. But it needs to do only once after the creation. Now that if I use on DAL_UPDATE it will be executed every time the record is modified not only by users but it will be triggered even from the system itself too when it does something that affects the table. Moreover, it triggers twice in the first place.
Reply With Quote
  #15  
Old 21st September 2018, 14:06
JaapJD's Avatar
JaapJD JaapJD is offline
Guru
 
Join Date: Sep 2002
Location: Netherlands
Posts: 803
JaapJD will become famous soon enoughJaapJD will become famous soon enough
Baan: BaanIV, BaanERP, ERP LN 6.1 - DB: Oracle, SQL Server - OS: Unix, Windows
What you are trying to accomplish is simply not possible. When the record is inserted in tisfc001 the mode is DAL_NEW. Whatever happens after that on tisfc001 for that production order will never be with mode DAL_NEW again.
In your first post you said you tried with a CDF. That can be a good approach. Initialize on 0 and update to 1 as soon as the after.save.hook() did the work using the materials. That recursion problem is probably caused by the fact that you did an update yourself on the table record. If you would move your code to the before.save.hook() and assign just the value 1 to the CDF will work, I suppose.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Critical] Tape Backup problem. flysurfing Operating Systems & Databases 14 31st August 2007 08:38
Object Data Management, Currency Initialization and Office Integration? sosrowk Miscellaneous 4 15th October 2003 13:40
mapper extension object bemisgrm Open World, Portal & Decision Manager 0 12th August 2003 19:33
tfacp9450m000 FIBU Brush Up Kai's Forum Users Deutsches Forum 1 16th November 1999 01:00


All times are GMT +2. The time now is 10:41.


©2001-2018 - Baanboard.com - Baanforums.com