bhushanchanda
19th June 2013, 10:04
Hi,

Just thought why can't DAL be invoked and used in VB script to insert data into table. I just created a script which inserts a single record into my customized table tcbed001. (The table has just a single field).

The program executes success fully, but the table is not updated. I didn't got a similar post on the Board so created one!

The similar 3GL script using all 4 functions:-

dal.new.object,
dal.set.field,
dal.save.object,
commit.transaction

works pretty well without any errors. I guess someone might have given a try to use DAL within VB script.

Here's my code (which doesn't work):-

Set BaanObj = CreateObject("Baan.Application.Test")
BaanObj.ParseExecFunction "ottstpstandard" ,"dal.new.object(" & Chr(34) & "tcbed001" & Chr(34) & ") "
Stop
BaanObj.ParseExecFunction "ottstpstandard" ,"dal.set.field(" & Chr(34) & "tcbed001.creg" & Chr(34) & Chr(34) & "," & Chr(34) & Chr(34) & "TTN" & Chr(34) & ") "
BaanObj.ParseExecFunction "ottstpstandard" , "dal.save.object(" & Chr(34) & "tcbed001" & Chr(34) & ") "
BaanObj.ParseExecFunction "ottstpstandard" , "commit.transaction()"
Set BaanObj = Nothing

bhushanchanda
19th June 2013, 13:40
Hi,

Just tried to put the idea other way, I created a DLL script on LN and added my dal commands to a function which accepts 1 or more argument. Then through VB Script I can pass the values which will pass the values to the function withing my DLL.

Here's the VB Code:-

Set BaanObj = CreateObject("Baan.Application.Test")
creg = "TTN"
BaanObj.ParseExecFunction "otcbedtestdll" ,"calling.dal("& Chr(34) & creg & Chr(34) &")"

Here, tcbedtestdll is the DLL which I created. It has a function calling.dll which accepts one argument.


Here's my function :-

function extern calling.dal(string creg(3))
{
long ret1
dal.new.object("tcbed001")
dal.set.field("tcbed001.creg",creg)
ret1 = dal.save.object("tcbed001"):)
commit.transaction()
}



Here are the two attached files.

mark_h
19th June 2013, 14:51
Very cool Bhushan. That should answer the other thread.

bhushanchanda
19th June 2013, 17:04
Thank you Mark. :)

PW@KKI
20th June 2013, 10:41
Thanks for this Bhushan ..... I will have a play later and see where it gets me