kevinwangsct
5th May 2009, 06:47
I am trying to call some dll provide by LN to excute some functions. For example, I want to update the purchase order line header thru object otdpurdll4110, function: tdpur.dll4110.update.purchase.order.header.

The function is defined as below.

tdpur.dll4110.update.purchase.order.header
long tdpur.dll4110.update.purchase.order.header( domain tcorno i.purchase.order, domain tcyesno i.approved, domain tcyesno i.cancelled, domain tcyesno i.closed, domain tcyesno i.confirm.receipt, boolean i.set.order.status, domain tdpur.hdst i.order.status, boolean i.set.order.amount, domain tcamnt i.order.amount, boolean i.set.for.commingling, domain tcyesno i.for.commingling )


Expl.: Use the function to update the purchase order header
fields.
Pre: NA
Post: NA
Input: i.purchase.order
i.approved
i.cancelled
i.closed
i.confirm.receipt
i.set.order.status
i.order.status
i.set.order.amount
i.order.amount
i.set.for.commingling
i.for.commingling
Output: NA
Return: 0 / DALHOOKERROR

I have my VBA as below:



Private Sub CommandButton2_Click()

Dim MagValue1 As String
Dim MagValue2 As String
Dim ErrMessage1 As String

On Error GoTo BaanAutomationError
Set baanobj = CreateObject("Baan.Application.Base")


rowIndex = 4
Do
'If no data to be processed, quit.
If Cells(rowIndex, 1) = "" Then Exit Do


B_FUNCTION = "tdpur.dll4110.update.purchase.order.header(" & """" & Cells(rowIndex, 1) & """" & ",2,2,1,2, 1, 25, 2, 0.000, 2,2)"

baanobj.ParseExecFunction "otdpurdll4110", B_FUNCTION

If baanobj.Error <> 0 Then
Select Case baanobj.Error
Case Is = -1
baan_error_code = -1
baan_error = "DLL Unknown"
Case Is = -2
baan_error_code = -2
baan_error = "Function Unknown"
Case Is = -3
baan_error_code = -3
baan_error = "Syntax Error in Function Call"
End Select
baanobj.Quit
Set baanobj = Nothing
MsgBox ("Call to Baan DLL failed, error = " & baan_error)
GoTo EXITSUB:
End If
Cells(rowIndex, 7) = baanobj.ReturnValue
rowIndex = rowIndex + 1
Loop

If baanobj.ReturnValue < 0 Then
MsgBox "Call to Baan DLL failed, error = " & baan_error, vbOKOnly + vbCritical, "Data Upload"
baanobj.Quit
Set baanobj = Nothing
GoTo EXITSUB:
End If

MsgBox "Process Completed... Refer Status of Individual Lines", vbOKOnly + vbInformation, "Data Upload"

EXITSUB:
baanobj.Quit
Set baanobj = Nothing
Exit Sub
BaanAutomationError:
MsgBox "Baan ERP automation error: " & baanobj.Error, vbOKOnly + vbCritical, "Data Upload"
MsgBox "Return value function: " & B_FUNCTION & " " & baanobj.ReturnValue, vbOKOnly + vbCritical, "Data Upload"
baanobj.Quit
Set baanobj = Nothing
End Sub




But I got the below error message after the sub exist.
48 : process 82 - Error : ttstpoledaem : A not terminated transaction is aborted (__overloaded.exit() in object ottstp_stddll)


Any idea will be greatly appreciated.

ulrich.fuchs
5th May 2009, 08:37
you will have to create your own DLLs in ERP LN which will do the transaction handling.

mymod.dll0001:
function extern long do.some.stuff () {
db.retry.point()
if tdpur.dll4110.update.purchase.order.header (..) then
abort.transaction ()
return (1)
else
commit.transaction ()
endif
return (0)
}

then call do.some.stuff from OLE

Hope that helps
Uli

kevinwangsct
5th May 2009, 12:10
Yes, it's the way we are working in the past days. I just want to have this done within one excel file. You know, it's boring to create one dll function for a ole call just for a transaction commit.

p.cole
9th May 2009, 01:20
I'd say that's dangerous. You may then have no control (if the Excel macro can be modified by users) of how the macro may be changed to perform other more undesirable updates!!

kevinwangsct
11th May 2009, 04:28
I'd say that's dangerous. You may then have no control (if the Excel macro can be modified by users) of how the macro may be changed to perform other more undesirable updates!!

Yes, you are correct. So we plan to encrypt the macro and implement some authorization mechanism if the commit works via OLE.