Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > AFS/DDC/OLE: Function servers

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 30th August 2017, 13:32
VishalMistry's Avatar
VishalMistry VishalMistry is offline
Guru
 
Join Date: Dec 2004
Location: India, Gujarat
Posts: 566
VishalMistry has a little shameless behaviour in the past
Baan: Baan IV, ERPLn - DB: SQL Server 2000 / 2008 - OS: Windows Server 2003 / 2008
Red face Getting item description through Baan OLE automation

Hi all,

I have little or no experience related to Baan OLE automation, but i want to explore it. I want to perform a simple task as shown below:

pass an item code using stpapi.put.field
search the item record using stpapi.find
get the value of item description using stpapi.get.field

For this I have written attached code in Excel VBA. I have debugged code in VBA and it gives an error message indicating invalid number of arguments whereas I am passing three argument (sessioncode,tablefield,getfield) to stpapi.get.field function.

getfield is excel vba variable.

BaanObj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & "tiitm001.dsca" & Chr(34) & "," & getfield & ")"

Can anybody guide me how to write the above statement correctly in VBA so that I will get item description in getfield variable ?

Thanks,
Vishal
Reply With Quote
  #2  
Old 30th August 2017, 14:03
VishalMistry's Avatar
VishalMistry VishalMistry is offline
Guru
 
Join Date: Dec 2004
Location: India, Gujarat
Posts: 566
VishalMistry has a little shameless behaviour in the past
Baan: Baan IV, ERPLn - DB: SQL Server 2000 / 2008 - OS: Windows Server 2003 / 2008
I could get rid of the error with below statement:

BaanObj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & "tiitm001.dsca" & Chr(34) & ",itemdesc" & ")"

But still while displaying value of itemdesc, the value remains empty.

Any clue what could be wrong here ?

NOTE : I changed the name of variable from getfield to itemdesc

Vishal
Reply With Quote
  #3  
Old 30th August 2017, 19:20
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,903
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
I only have this that I tested a couple of times - notice the baan function call and how I had to use mid$ to get a description.

Code:
datarec$ = "datarec"
retVal2$ = "retval"
retval = Space(128)
getfield = Space(30)
Set BaanObj = CreateObject("Baan4.Application.701")

BaanObj.Timeout = 10
'AREAS TEST RETURN VAL...
'put area 'AZ, find , get desc
'put area
SessionName$ = "tcmcs0145m000"
FieldName$ = "tcmcs045.creg"
FieldValue$ = "105"
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & SessionName$ & Chr(34) & "," & Chr(34) & FieldName$ & Chr(34) & "," & Chr(34) & FieldValue$ & Chr(34) & ")"

BaanObj.ParseExecFunction "ottstpapihand", "stpapi.find(" & Chr(34) & SessionName$ & Chr(34) & ")"

errstr = BaanObj.Error
'get desc
SessionName$ = "tcmcs0145m000"
FieldName$ = "tcmcs045.dsca"

BaanObj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & SessionName$ & Chr(34) & "," & Chr(34) & FieldName$ & Chr(34) & "," & Chr(34) & getfield & Chr(34) & ")"
tempstr$ = BaanObj.FunctionCall

descr = Mid(tempstr$, 50, 32)

longVar = BaanObj.ReturnValue

errstr = BaanObj.Error
MsgBox (descr)

BaanObj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & SessionName$ & Chr(34) & "," & Chr(34) & errmessage1 & Chr(34) & ")"
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #4  
Old 31st August 2017, 10:25
VishalMistry's Avatar
VishalMistry VishalMistry is offline
Guru
 
Join Date: Dec 2004
Location: India, Gujarat
Posts: 566
VishalMistry has a little shameless behaviour in the past
Baan: Baan IV, ERPLn - DB: SQL Server 2000 / 2008 - OS: Windows Server 2003 / 2008
Hello Mark,

Your code is working. One strange thing (and it has nothing to do with your code) is if I am already connected to Baan and run my macro then I get ole automation error. For the code to work, I have to logout of Baan, then only I can run the Excel code.

Thanks for your help.
Vishal
Reply With Quote
  #5  
Old 31st August 2017, 13:54
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,903
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Yes - I recall that happening also. I believe that was one of the reasons I never went this direction because it was very slow in our environment. I never really played with this a lot.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to perform Baan Automation together with BOI data dberg72 Miscellaneous 3 25th September 2015 08:58
Baan OLE automation problem when calling from a service Jabran AFS/DDC/OLE: Function servers 0 14th September 2005 15:25
Availability of Web-Based DEM (Baan Press Release) Pierre B. General Discussion & Chat 0 5th September 2001 05:59
BSP-US (LLC) added as a Baan Education Alliance svandenh General Discussion & Chat 1 20th August 2001 19:44


All times are GMT +2. The time now is 02:29.


©2001-2017 - Baanboard.com - Baanforums.com