ibmtor
10th October 2002, 17:52
We successfully call a script/function "<function>" at baan that takes one parameter <parameter>.

Shell("BW.EXE MyLogin.bwc /app/baan/bse/home/../<function> <parameter>",1)

What is the equivalent call using Baan Class library "Baan.BwCOleAutomationServer"?

Have tried the visualbasic code:
---------------------------------------------
Set BaanObj = New Baan.BwCOleAutomationServer

'<What code do i need here?>

BaanObj.Quit
Set BaanObj = Nothing
---------------------------------------------

Tip for baan developer responsible for the "Baan" type library:

When the class i created it starts poping up windows and requests user intervention etc.

Good practice when developing classes is to enable class methodes and properties to read options to inquire and configure the class before it actually starts executing anything vital. For example what bwc file to use if any. All those bwc properties should be possible to configure through the class/type library.



Greatfull for help though..
















:confused:

mark_h
10th October 2002, 18:44
Gordon showed me this at one time.


Sub Run_function_server()
'
' Baseline Macro
' Macro recorded 3/2/2001 by United Defense LP
'
Row = 2

dllname = "otisfcdll9475"
Sheets("Run Parameters").Activate
main_f = Sheets("Run Parameters").Cells(Row, 1)
Call open_baan
While main_f <> ""
' Read all and make sure it is text
comp$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 1) & Chr(34) & ","
main_f$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 2) & Chr(34) & ","
Main_t$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 3) & Chr(34) & ","
sub_f$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 4) & Chr(34) & ","
sub_t$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 5) & Chr(34) & ","
year_f = Sheets("Run Parameters").Cells(Row, 6) & ","
year_t = Sheets("Run Parameters").Cells(Row, 8) & ","
date_f = Sheets("Run Parameters").Cells(Row, 7) & ","
date_t = Sheets("Run Parameters").Cells(Row, 9) & ","
efficiency = Format(Sheets("Run Parameters").Cells(Row, 10), "####.00") & ","
salary_perc = Sheets("Run Parameters").Cells(Row, 11) & ","
' simu_comp$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 12) & Chr(34) & ","
simu_comp$ = Sheets("Run Parameters").Cells(Row, 12) & ","
file1$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 13) & Chr(34) & "," ' Input File
file2$ = Chr(34) & Sheets("Run Parameters").Cells(Row, 14) & Chr(34) & "," ' Report File
dllfunction = "sfcdll9475.process.records" & "("
dllfunction = dllfunction & comp$ ' Company
dllfunction = dllfunction & main_f$ ' main from
dllfunction = dllfunction & Main_t$ ' main to
dllfunction = dllfunction & sub_f$ ' sub from
dllfunction = dllfunction & sub_t$ ' sub to
dllfunction = dllfunction & year_f ' year from
dllfunction = dllfunction & year_t ' year to
dllfunction = dllfunction & date_f ' date from
dllfunction = dllfunction & date_t ' date to
dllfunction = dllfunction & efficiency ' Efficiency
dllfunction = dllfunction & salary_perc ' Salary Perc.
dllfunction = dllfunction & simu_comp$ ' Simulation Company
msg = "Start" + String(60, " ")
dllfunction = dllfunction & file1$ ' Input File
dllfunction = dllfunction & file2$ ' Report File
dllfunction = dllfunction & Chr(34) & msg & Chr(34) ' Report File
dllfunction = dllfunction & ")"
Call SendtoBAAN
Row = Row + 1
main_f = Sheets(1).Cells(Row, 1)
Wend
Call close_baan

' Save as for the sub-totals
End Sub

'***************************************************************************************
' Name : SendtoBaan
' Short Description : Send/Receive information to/from Baan
' Comments : Check if Baan is active otherwise connect to Baan
' send information to Baan with parseexecfunction with 2 parameters
' a) dllname
' b) dllfunction (includes parameters)
' return information checked for errors and messages displayed
' Also if a record has an error the error flag switch is turned on
'***************************************************************************************
'Sub SendtoBAAN(ByVal dllname As String, ByVal dllfunction As String)
Sub SendtoBAAN()
BaanObj.ParseExecFunction dllname, dllfunction
' check result
errormsg = ""
If BaanObj.Error <> 0 Then
Select Case BaanObj.Error
Case Is = -1
errormsg = "DLL Unknown"
Case Is = -2
errormsg = "Function Unknown"
Case Is = -3
errormsg = "Syntax Error in Function Call"
End Select
MsgBox ("Call to Baan DLL failed, error = " & errormsg)
close_baan
End If
' If return false then everything was okay. If return value true
' then we had an error
returnvalue = Val(BaanObj.returnvalue)
If returnvalue Then
strlen = Len(BaanObj.functioncall)
compos = InStr(1, BaanObj.functioncall, "commmsg:", 1)
msg = Mid(BaanObj.functioncall, compos + 8, strlen - 3)
msg = RTrim(Mid(msg, 1, Len(msg) - 3))
MsgBox msg
End If
Exit Sub
AutomationError:
MsgBox "Baan IV automation error: " & BaanObj.Error
End Sub

Sub open_baan()
' The DLL "ottdllsql_query" contains a function to convert this string to a Baan query and
' other functions to parse and execute the query. The DLL also contains functions to retrieve
' the result of the query, e.g. function "olesql_getstring".
On Error GoTo CannotCreateBaan

'My connection was Automatic since I changed a registry entry to
'run a different .bwc file.
'run Baan Application
Set BaanObj = CreateObject("Baan4.Application.ole701")
BaanObj.Timeout = 3600
On Error GoTo BaanAutomationError
Exit Sub

' error handling
CannotCreateBaan:
MsgBox "Unable to start Baan"
Exit Sub

BaanAutomationError:
MsgBox "Baan IV automation error: " & BaanObj.Error
MsgBox "Return value function: " & B_function & " " & BaanObj.returnvalue
BaanObj.Quit
Set BaanObj = Nothing
Exit Sub

End Sub
Sub close_baan()
' exit Baan
If Not BaanObj Is Nothing Then
BaanObj.Quit
Set BaanObj = Nothing
End If
End Sub


This called a Baan DLL that I created - I did not edit it or clean it up. I hope this helps.

Mark

ibmtor
11th October 2002, 11:10
Baan.BwCOleAutomationServer


More recomendations for baan developer responsible for the "Baan" type library:

1.
The library should not pop up graphical interfaces unless instructed to do so! Then rather return an error and have the application investigate selectable options and operate completely without user intervention.

2.
The ERROR property in "Baan.BwCOleAutomationServer" will conflict with the Visual basic ERROR function. User is forced to prefix VBA module calls using VBA.ERROR()

3.
Allso if you design a default.bwc configuration file to execute a function. When the class is created it immediately starts executing the bwc function and when the seesion completes it unloads the class. So we get a class registration error even before we completed loading the class into memory.

4.
Even the cheapest 30$ webcamera is shiped with more professional OLE modules than "Baan.BwCOleAutomationServer".


:mad:

lorry.lu
22nd July 2008, 17:16
Hello Mark,

How to change Baan4.Application to Baan4.application.ole701?
I means in which path in regedit?
If there are 2 different configure file for different baan servere, but the baan client are installed in the same PC, the rename is only take in afffect in one of the baan server or both of the 2 servers?

Thanks/Lorry Lu
*********************************
Set BaanObj = CreateObject("Baan4.Application.ole701")
BaanObj.Timeout = 3600
On Error GoTo BaanAutomationError
Exit Sub

mark_h
22nd July 2008, 22:42
If you look at the .bwc configuration file for a login there is now a tab that says automation. In that tab you can define the name for that connection. So look at you .bwc file - you can set the name in it.

lorry.lu
23rd July 2008, 05:06
OK,Thanks a lot.