giggty
14th November 2017, 13:57
Hello.
So I am developing an LN Extension and I need a chunk of my code to run in a separate process. It appears that activate() is what i need. But it requires a session name or the name of an object file as the process to be activated. I created a function component whinh290dalnew in LN Studio, put my code in and compiled it. But when i try to run it like act.return = activate("owhinh290dalnew", <parameters>) i get an error Process 25 - Error : [MR_E_READNG] Cannot read session or object (owhinh290dalnew) How to make sure object file gets created? Or am I doing it all wrong?

bhushanchanda
14th November 2017, 17:51
Hi,

You cannot call a DAL like that. What you can do is this -

exec_dll_function("oasacp205","before.save.object",ret,DAL_NEW)

Where, ret is return value and DAL_NEW is mode i.e. the argument for before.save.object function.

activate() can be used for 4GL and 3GL programs.

giggty
15th November 2017, 15:07
Hi, Bhushan!
You cannot call a DAL like that.
Why not? My whinh290dalnew script looks like this:

extern long res

function whinh290dalnew()
{
res = dal.new.object("whinh290")
if result = 0 then
dal.set.field("whinh290.oorg", argv$(1))
dal.set.field("whinh290.orno", argv$(2))
dal.set.field("whinh290.pono", argv$(3))
dal.set.field("whinh290.seqn", argv$(4))
dal.set.field("whinh290.dlin", 1)
dal.set.field("whinh290.cpor", tcpeg.cpor.manual)
dal.set.field("whinh290.cprj", argv$(5))
dal.set.field("whinh290.cact", argv$(6))
dal.set.field("whinh290.cspa", argv$(7))
res = dal.save.object("whinh290")
export("res", res)
endif
}

My main concern is about why i can't call this function using activate() (regardless of what it is actually doing). I thought when you save component in LN Studio and build it, object file gets created on server and you are good to go.
I tried running your code, but it gave me a similar error:
Process 57 - Error : [MR_E_READNG] Cannot read session or object (oasacp205) (after.save.object() in object otxestwhinh220.dbg)
Are you sure about "oasacp205"? I can't find it in ttstpbaandoc.

bhushanchanda
15th November 2017, 15:37
Hi,

That's a custom script.

What kind of script is whinh290dalnew?

What is the name of the script/object? Its clear that bshell is not able to find the object. Can you please double check the name of the object? And check if its exists in the directory or not.

giggty
16th November 2017, 15:31
What kind of script is whinh290dalnew?
It is a function component, like those stored in ttadv2560m000.
What is the name of the script/object? Its clear that bshell is not able to find the object. Can you please double check the name of the object? And check if its exists in the directory or not.

I see there are 3 files which are related to whinh290dalnew:
\bse\application\wh105C_0_bss\t_0003\baan\iwhinh\iinh290dalnew0
\bse\application\wh105U_0_a000\iwhinh\iinh290dalnew0
\bse\application\wh105C_0_bss\t_0003\iwhinh\iinh290dalnew0

Clearly, there is no object file oinh290dalnew :)
It seems like i misunderstood the concept of function. Here is the quote from "Infor LN Studio ApplicationDevelopment Guide":
If you want to include a function in a program script, use the following statement:
#include "i<entire code>"
So a function component in LN is like .h file with inline function in C/C++, which you include and then use it in your code.
So my question is: what entity i need to create in LN, so that it gets compiled into an object file with the code i posted above inside, so that i can run it via activate()?
I found a related thread (http://www.baanboard.com/baanboard/showthread.php?t=9536):
|* Second program script - zmadmnp
extern long ret.val
function main()
{
long i
message("No. of args=%d", argc()-1)
for i = 1 to (argc() - 1)
message("Argument(%d)=%s", i, argv$(i))
endfor
ret.val = 2003
export("ret.val", ret.val)
}
What is this zmadmnp? I need to create a similar one :o

NPRao
16th November 2017, 20:44
It seems like i misunderstood the concept of function. Here is the quote from "Infor LN Studio ApplicationDevelopment Guide":

So a function component in LN is like .h file with inline function in C/C++, which you include and then use it in your code.
Yes, it is similar to the C/C++, however the functions cannot be directly compiled or the objects are generated for them.
What is this zmadmnp? I need to create a similar one
The zmadmnp, is a custom 3-GL program, that I created to illustrate an example.

Refer to the Tools Programmer's manual -
activate() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_processes_activate)

wait.and.activate() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_processes_wait_and_activate)

giggty
17th November 2017, 09:36
The zmadmnp, is a custom 3-GL program, that I created to illustrate an example.
Right, and how do I create one? Can I do it in LN Studio (i believe i cannot)? Or do i need to create a text file with my source, upload it to the server and fire some binary to compile it into object file? Can you guide me through or point where i can find step-by-step procedure for that? Sorry, I have started recently and I have not touched some aspects of LN in my work yet.

bhushanchanda
17th November 2017, 16:58
Right, and how do I create one? Can I do it in LN Studio (i believe i cannot)? Or do i need to create a text file with my source, upload it to the server and fire some binary to compile it into object file? Can you guide me through or point where i can find step-by-step procedure for that? Sorry, I have started recently and I have not touched some aspects of LN in my work yet.

Hi,

There are a few ways to create 3GL script.

1. Just use Worktop/BECS and use LN tools to create it. Just go to Tools -> Application Development -> Program Scripts -> Create new -> Use script type as 3GL.
2. Create a script manually under the applications directory and use command line tool bic6.2/ bic for compiling (More info here) (http://www.baanboard.com/baanboard/showthread.php?t=9738)
3. In the script tab, for the script type option change it to 3GL. More info can be found in Infor LN Studio Application Development Guide.

Here's a sample bic command for compiling a sample script tccomtest

bic -T 1805 -Pvariant=0 ptccomtest0 -z -u -o otccomtest -f "E:\Infor\erpln\bse\tmp\tmp082332508" -pacc b61prod -qe "E:\Infor\erpln\bse\tmp\tmp082332510"

Usage: bic [-ilpstzEV] [-u[level] -f fn] [-w[level]] [-Idir[:dir ...] [-Dmacro[=
value]] [-d dll[:dll ...] [ -pacc pack_comb ] [-T TIVNumber] source [-o object]
[ -qo outfile ] [ -qe errfile ] [ -qx xmlfile ]

-i: Assembler output in <source>.i
-l: Object runs in debug mode
-p: Object runs in profiling mode(time analyse)
-pacc pack_comb: Use specified package combination
-s: Generate symbol table to stdout
-t: Print tokens after preprocessor pass
-u[l]: Create 'where used' list [for level l]
-f fn: File name for 'where used' output file.
-z: Ignore the BAAN_SCM_GRP
-E: Only preprocessor pass output to stdout
-w[l]: Suppress warnings of level <l>
-W[l]: Give warnings of level <l>
-d dll:Load dll[:dll ...] for search lib.functions
-Idir: Add dir[:dir ...] to searchpath #include <>
-Ddef: define a macro. Or with value -Ddef[=value]
-qo fn: Redirect standard output to file fn
-qe fn: Redirect error output to file fn
-qx fn: Generate XML document with compile errors in file fn
-6: Generate 6.1 object format
-7: Generate 7.2 object format
-V: Print release number
-T num: Add 'num' as Tools Interface Version number to the object

giggty
21st November 2017, 16:04
Hi,

There are a few ways to create 3GL script.

1. Just use Worktop/BECS and use LN tools to create it. Just go to Tools -> Application Development -> Program Scripts -> Create new -> Use script type as 3GL.

Yeah, right, silly me :o So i created a 3GL script, but I had to open the created p-file on the server and add my code there. Isn't it possible to edit it from LN UI?
And after I compiled it I found out that I had to specify a full path to object file (as "C:\infor\bse\application\tx105O_a_bss\t_0004tx\otxest\oest290dalnew") as the first argument of activate(). That seems to me like a not really portable solution. Can i somehow get rid of the full path?