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.
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.