pralash
20th December 2017, 15:07
Hi,

I'm new for LN Programming... I want to know about how to create User exit DLL for a baan table and also how to implement the programming logic for this dll. Can anybody please help me that how to use the User Exit DLL...
Thanks in advance,
Regards,
Pralash

bhushanchanda
20th December 2017, 16:01
Hi Pralash,

From programmers guide -

Overview
A User Exit DLL (UEDLL) is a DLL that will reside outside the standard software. It will have the same name as a standard DAL with the extension 'ue' (for 'user exit'). E.g. 'whinh200ue' for table whinh200. Customers can implement a UEDLL in order to be able to define extra business logic before and after the standard 'before' and 'after' handling of saves and deletes, by means of specific hooks that will be executed by the 4GL engine and/or DAL Engine. Stand-alone database operations (not triggered by saves and deletes of the 4GL engine or DAL Engine) are also extended to perform the extra business logic before and after performing the actual database operation. In this way it is possible to e.g. conditionally publish data changes to the outside world.

Interaction with 4GL Engine / DAL Engine
When present, the User Exit DLL for a certain table will be loaded by the 4GL engine/DAL Engine by the time the DAL for this particular table will be loaded. In situations where no DAL is present this will be the moment at which a DAL would be loaded if it existed. This means that there is no need to have a DAL in order to make use of the UEDLL.

Interaction with db operations
When one of the following database operations is executed stand-alone (so not as part of the standard save/deletes of the 4GL Engine or DAL Engine):

db.insert()
db.update()
db.delete()
and the User Exit DLL for the related table is present, the UEDLL will be loaded prior the database operation. This means that there is no need to have a DAL or a session in order to make use of the UEDLL.

Preconditions
A DLL becomes a UEDLL when it meets the following conditions:

Its name is consisting of the table code with 'ue' as suffix, like whinh200ue
It includes bic_dal, as follows: #include <bic_dal>
Restrictions
A UEDLL is treated like a regular DAL. This means all kind of DAL related functionality can be used, like:

Function with.old.object.values.do()
Function with.object.set.do()
Pre-defined variable subdal
Note however that the following restrictions apply:

Business methods cannot be implemented in a UEDLL Instead the business logic should be programmed in another (separate) general DLL.
It is strongly discouraged to define other external functions in a UEDLL and link the UEDLL directly to other scripts. Instead, use a normal general DLL. (This also applies to regular DALs).

Also,

User Exit Hooks
A UEDLL script can contain the following hooks:

ue.before.before.save.object()
ue.after.before.save.object()
ue.before.after.save.object()
ue.after.after.save.object()
ue.before.before.destroy.object()
ue.after.before.destroy.object()
ue.before.after.destroy.object()
ue.after.after.destroy.object()
disable.ue.dll()
enable.ue.dll()
disable.table.extension()
enable.table.extension()
ue.get.origin()

bhushanchanda
20th December 2017, 16:03
In my own words -

If you want to write some logic on any kind of database transaction like insert, update or delete on a particular table, you can use a UE dll for that table.

e.g. You want to update table xxyyy001 when a record is inserted in table tdsls400

1. Create a program script
2. Provide the name as tdsls400ue and save it
3. In function after.after.save.object() you can write your code to insert record in table xxyyy001
4. You are done.

pralash
21st December 2017, 07:27
Thanks a lot for your information Bhushan........
As you suggested, Can I use after.after.save.object() or ue.after.after.save.object() function for implementing the User Exit DLL operation... Please let me know that these two functions are same or different...

Regards,
Pralash

bhushanchanda
21st December 2017, 08:43
The function is a part of ue script which you need to created by following the steps I showed above.

pralash
21st December 2017, 09:13
Hello,

As per your guidance, I have created a new table under the new module(emp - employee management system) in the name of tcemp101...
Then I try to create a new program script like "tcemp101ue" but it allows the name as "tcemp101u" instead of "tcemp101ue"... Here the last letter is missing in the program script... So how can I create the program script in the name of "tcemp101ue"... Can you please assist me.

Thanks,
Regards,
Pralash

pralash
21st December 2017, 10:16
Hi,

As you suggested, I have created User Exit script as tcemp101ue which contains 8 functions such as ue.after.before.save.object, ue.before.after.save.object etc.

I have the filed name such as tcemp101.code, tcemp101.name, tcemp101.dept etc. I also create a new table tcemp102 with the same fields of tcemp101.
When I insert a new record in tcemp101 by executing the session, I want to store the same record in tcemp102... So how can I perform this task using ue.after.after.save.object... Can you please tell me this sample UE script....

Thanks,
Regards,
Pralash

bhushanchanda
21st December 2017, 10:57
Hi Pralash,

Just write the code like this in your UE -

function extern long ue.after.after.save.object(long mode)
{
on case mode
case DAL_NEW:
|# Write code to insert data in another table
tcemp102.code = tcemp101.code
tcemp102.name = tcemp101.name
tcemp102.dept = tcemp101.dept
db.insert(ttcemp102,db.retry,db.skip.dupl)
break
case DAL_UPDATE:
| Update your table here
break
endcase

return(0)
}

pralash
21st December 2017, 12:22
Hi bhushanchanda,
It's working fine for me... Thanks so much for your guidance....
Regards,
Pralash

pralash
22nd December 2017, 09:21
Hi Bhushan,

As you suggested, I insert a new record by using UE script... But when I update a table tcemp101, the corresponding table tcemp102 is not updated. But I got the error as shown in the attachement... (Record is locked)

My script is as follows...
function extern long ue.after.after.save.object(long mode)
{


on case mode
case DAL_NEW:
tcemp102.code = tcemp101.code
tcemp102.name = tcemp101.name
tcemp102.dept = tcemp101.dept
tcemp102.addr = tcemp101.addr
db.insert(ttcemp102,db.retry,db.skip.dupl)
dal.set.info.message("@%1s", "record is inserted...")
show.dal.messages(MSG.INFO)

break
case DAL_UPDATE:
tcemp102.code = tcemp101.code
tcemp102.name = tcemp101.name
tcemp102.dept = tcemp101.dept
tcemp102.addr = tcemp101.addr
db.update(ttcemp102,db.retry)
dal.set.info.message("@%1s", "record is updated")
show.dal.messages(MSG.INFO)

break
endcase
return(0)
}

Can you please assist me, how to perform the update operation in tcemp102, while update the record in tcemp101....
Thanks in advance,
Regards,
Pralash

JaapJD
2nd January 2018, 15:00
Two things:
- Why a User Exit if you have a custom table? You can just create a DAL for that table. User Exits are meant to program some additional logic around standard tables.
- Before you can update a record you should read it for update:

select tcemp102.*
from tcemp102 for update
where tcemp102.code = :tcemp101.code
selectdo
tcemp102.name = tcemp101.name
tcemp102.dept = tcemp101.dept
tcemp102.addr = tcemp101.addr
db.update(ttcemp102,db.retry)
endselect

pralash
3rd January 2018, 07:34
Hi,

I'm fresher for LN Programming... In order to get the working ideas about User exit, I developed some sample programs....
Thanks so much for your guidance....
Regards,
Pralash