spartacus
17th June 2003, 18:08
Without DAL it is possible, in the maintable io-section, for example in "after.write" to catch the moment at which data is definitely written. Related to that no I can do an update of a second table.

How can I catch this moment in a programscript with DAL? So that I can do some action after a record is DEFINETELY written?


Spartacus

lbencic
17th June 2003, 19:05
after.save.object is the DAL function that replaces the after.write and after.rewrite sections. You can check the help for that with examples.

spartacus
17th June 2003, 21:13
Yes, but "after.save.object" is executed every time a record is written to a table. But I would like to execute a function only in case a certain session writes to maintable.

Is a possible solution simething like that (in the DAL)

.
.
.
after.save.object:
import("parent.progname$",parent.progname)
if parent.progname$ = "<foo>" then
<do something>
endif
.
.
.

lbencic
17th June 2003, 21:31
You should be able to directly check the prog.name$ variable - can you check if that holds your session name in the DAL?

FransG
18th June 2003, 09:35
It is not nice to check on parent.progname$ in a DAL. An alternative that is used in several places within BaanERP is the use of a global variable within the DAL that is managed through a business method.

Example:
In the DAL declare the following:

domain tcbool called.by.spartacus.session

function extern long before.open.object.set()
{
called.by.spartacus.session = false |* Initialize.

return (0)
}

function extern long after.save.object(long mode)
{
...
if called.by.spartacus.session then
...
endif
...

return(0)
}

function extern long set.spartacus.flag(domain tcbool i.value)
{
called.by.spartacus.session = i.value

return(0)
}


From the session before executing the save you call the business method with value true and afterwards you reset it with false

dal.start.business.method("ppmmxxx", "set.spartacus.flag", ret.val, true)
...
|* Save record...
...
dal.start.business.method("ppmmxxx", "set.spartacus.flag", ret.val, false)