pur615
4th February 2011, 23:39
Would much appreciate if someone posted a sample UE script. Thanks

vinceco252
4th February 2011, 23:46
|******************************************************************************
|* tdsls401ue 0
|* Sales Order Lines
|******************************************************************************
|* Script Type: Library
|******************************************************************************
table ttdsls400
table ttdsls401
table tbrarw010
#include <bic_dal>


function extern long ue.before.before.save.object(long mode)
{
on case mode
case DAL_NEW:
select brarw010.*
from brarw010
where brarw010.cuno = :tdsls401.ofbp
and brarw010.item = :tdsls401.item
selectdo
tdsls401.corn = brarw010.cupo
selectempty
if not isspace(tdsls400.corn) then
tdsls401.corn = tdsls400.corn
else
tdsls401.corn = ""
endif
endselect
break

case DAL_UPDATE:
select brarw010.*
from brarw010
where brarw010.cuno = :tdsls401.ofbp
and brarw010.item = :tdsls401.item
selectdo
tdsls401.corn = brarw010.cupo
selectempty
if not isspace(tdsls400.corn) then
tdsls401.corn = tdsls400.corn
endif
endselect

break
endcase
return(0)
}

bdittmar
5th February 2011, 00:48
Would much appreciate if someone posted a sample UE script. Thanks

Hello,

User Exit DLL Overview
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. 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.

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).
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()
Related topics

Data Access Layer


Regards

pur615
5th February 2011, 03:24
That was helpful. Thanks a lot.

benito
7th February 2011, 18:53
do you attach the ue script to a table or a session?

bdittmar
7th February 2011, 20:40
do you attach the ue script to a table or a session?

Hello,
as described:

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.

User Exit for Table tisfc001 is tisfc001ue.
User Exit for Table timfc010 is timfc010ue aso.

Regards

benito
7th February 2011, 21:20
that's exactly what i did but cant make it to work. i created a standard library called ticpr200ue. it is also outside the standard software, meaning not linked to a table. any new tips?

vinceco252
7th February 2011, 22:30
I don't have an LN environment in front of me, but I think you do have to attach the script to the table as you would a standard DAL.

Vince

benito
7th February 2011, 22:48
i have tried that also but im having a message "change the value of the program script/library field. Reason: script already exists in package VRC ti B61U a stnd". I was wondering if im missing some enabling parameter. ticpr200 has the DAL library already and looks like its not allowing me to add another one on top of this.

vinceco252
7th February 2011, 23:55
Ok, so it is NOT attached to the table. It needs to be a general library with the naming convention as indicated above (i.e., tdsls401ue for a UE library for table tdsls401). You also need to include bic_dal. I don't see this listed as a requirement, but I would also suggest you declare the table for which you are writing the script.

That should be it.

Vince

ulrich.fuchs
8th February 2011, 08:19
Again, it's just a DLL following a particular naming convention. No need to link it to a table somehow.

Next: You're showing "FP3" there. For User Exits to be available, you need at lease Tools-Version 7.6.b4, or Tools Version 7.6.a4 with Solution 224004.

benito
8th February 2011, 15:22
still not working...see attachment.

ulrich.fuchs
8th February 2011, 18:52
Again, do NOT link the user exit script anywhere. Neither to the Table, nor as a library of the DAL of that table.

Most important thing: The user exit script is always exectuted WITHIN the standard's transactions.

!!!!! NEVER EVER use either one of db.retry.point (), commit.transaction () or abort.transaction() in such a script or any DLL function that is called from that script!!!!!

This will certainly mess up the standard functionality of the software a lot, creating corrupt data.

Also, please ** READ ** what people are telling you here, if they are taking the time to help you. You're on an outdated tools version that does not support user exits, unless a solution is installed. Is it installed?

Third, user exists are only triggered if the table is accessed
* as the main table of a session. Since there is no session for maintaining records in ticpr200, that's not true for you
* or programmatically, using dal.save-commands instead of db.updates. This may not be the case in your situation. Especially in older patch levels of FP3 (even up to nowadays FP7) there might be situations when the standard scripts update tables directly. In that case, the User Exit will not be triggered. I can easily imagine that eg during cost price calculation that might be the case.

Uli

benito
8th February 2011, 20:28
ulrich,

most of the information you gave are new to me (e.g. not to use db.retry.point, etc., including the trigger of the table. ). solution 224120 (that includes 224004) is already installed in my system. i guess i will have to look for a table that is being used as main table and try it from there.

lbencic
10th February 2011, 21:30
Solved yet? it should be that simple, if your tools are patched. maybe it's not using dal commands to update your values to begin with, so your ue is not calling either? just a thought.
Try testing if the ue works at all -
in TEST!! Generate a simple maintenance session for the table you are working with, and put your ue code in debug so you can see if it even comes up when you change/save a record (if it works is a different matter ;)