scough
8th April 2011, 20:17
I am not a Baan developer but in another post I asked about using 4GL code in a constraint and a user (EdHubbard) generously offered the following:

!#pragma used dll otcmcsdll9988c
!table ttipcf500
!table ttccom010
!import("tipcf500.cuno", tipcf500.cuno)
!if (tcmcs.dll9988c.read.customer.master(tipcf500.cuno) ) then
! [custname] = tccom010.cuno(3;4)
!endif

function extern domain tcbool
tcmcs.dll9988c.read.customer.master(
domain tccuno pcuno
)
{
select tccom010.cuno,
tccom010.nama,
tccom010.ccty,
tccom010.ccur,
tccom010.cbrn,
tccom010.crat
from tccom010
where tccom010._index1 = {:pcuno}
as set with 1 rows
selectdo
return ( true )
endselect
return ( false )
}

The problem is that I do not know how to go about compiling this script so that I can call the function.

Can anyone provide any assistance? Like I said I am not a Baan developer so using generalities will most likely not be enough information. I hoping someone might help with a step by step guide.

Thanks!

mark_h
8th April 2011, 23:05
What Ed recommended was using a DLL. A DLL can be created in session ttadv2131m000. This is the session where you can create and compile the DLL. First you would hit insert, give the DLL a name, and then hit edit. Enter the code, save and exit. Then just click on compile - that creates a library.

Then in a session you can call the library function from a session. You would include the library in the session script. Using something like

#pragma used dll ottstpapihand | Baan API Handler

Or you could add them in the session script by clicking the libraries button and adding the library there. At that point anywhere in the session script you can call the library function that you created.

I did not review the code request or what was provided. Just tried to provied some basic steps for creating and using a library.

scough
11th April 2011, 17:45
Thank you for your help. Hopefully I will get a chance to try this out today!

scough
12th April 2011, 19:34
Not having much luck.

I am just trying get a simple test script to work but it keeps erroring out when I try to exit the constraint editor.


I created this script under:
Package: ti
Module : pcf
Librady : dllcits01
VRC : B40P c4 cust


|******************************************************************************
|* tipcfdllcits01 0 VRC B40P c4 cust
|* Write messages from within contraint code to message tables.
|* baan
|* 04-12-11 [11:05]
|******************************************************************************
|* Script Type: Library
|******************************************************************************

function extern domain tcbool
tipcf.dllcits01.test( )
{
return ( true )
}

It compiles fine so I tried using it in a validation constraint I am editing in the constraint editor:

!#pragma used dll otipcfdllcits01
if [PRODFEAT] = "Y" then

!if (tipcf.dllcits01.test()) then
!message = "True"
!endif

endif

I get an error : Constraint expression cannot be executed (line # where !if (tipcf.... starts)

In the BW messages window I see:

Error : Syntax error in expression: value 0 assumed

What am I doing wrong in this simple test?

mark_h
12th April 2011, 22:32
!#pragma used dll otipcfdllcits01
if [PRODFEAT] = "Y" then

if (tipcf.dllcits01.test()) then
message = "True"
endif

endif


Remove the ! infront of the test. See above.

scough
12th April 2011, 22:46
No go.... I removed the ! and I still get the error.

mark_h
12th April 2011, 22:51
Can you post the whole session script and the exact error message? I am not sure where you are putting this code. I would expect it to be in a check field input or something like that.

scough
12th April 2011, 22:58
This is not in a session script. This is being run in a validation constraint.

That is why you saw the ! infront of the code.

mark_h
12th April 2011, 23:52
Then you have my sincere apologies. I have never used a validation constrait like this and you will need to wait for someone else to respond. All of my DLL's I used through session scripts. Once again my apologies.

scough
13th April 2011, 20:14
No need to apologize. You were trying to help and it was appreciated!

EdHubbard
14th April 2011, 18:48
To actually compile the PCF script you would use session tipcf2201m000 if your parameters are set to Object Version [check form 1 of tipcf0100m000].

See what you get from checking those things out first.

Ed

scough
15th April 2011, 03:17
Thanks Ed,

I did compile the constraint and I have the "Object Version" selected.

I am not sure what I was doing wrong as I am certain that I have had the option set to "Object Version" all along and I compile the code every time I make a change. I do that not only to make sure the compiled version is up to date, but for syntax checking as well:)

In any event I was able to get some very simple code in the dll and I can call it from the constraint and get the results I expect.

I will be working on expanding the code to do what I need.

Thank you for your help.