on 04-08-2010 8:57 AM
Hi,
I am using the below code to create a PO using DI API. But the PO is not being created. I am getting an erroer as -50003 an internal error occured. Please let me know where I am going wrong
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vPurchaseOrder As SAPbobsCOM.Documents
vPurchaseOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
vPurchaseOrder.CardCode = "V1010"
vPurchaseOrder.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
vPurchaseOrder.DocDate = DateTime.Today
vPurchaseOrder.Lines.ItemCode = "A00002"
vPurchaseOrder.Lines.UnitPrice = 2.36
vPurchaseOrder.Lines.Quantity = 50
vPurchaseOrder.Lines.DiscountPercent = 10
vPurchaseOrder.Lines.Add()
vPurchaseOrder.Lines.SetCurrentLine(1)
vPurchaseOrder.Lines.ItemCode = "A00002"
vPurchaseOrder.Lines.Quantity = 8
vPurchaseOrder.Lines.UnitPrice = 5
vPurchaseOrder.Lines.DiscountPercent = 10
'Add the po
RetVal = vPurchaseOrder.Add
'Check the result
If RetVal <> 0 Then
'objMain.objCompany.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrCode & " " & ErrMsg)
End If
regards,
Noor hussain
SOLVED
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasu,
I went wrong near the document date. The date which I was assigning was not in the specified posting period range. I made a few other changes also. I am posting the code below.
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vPurchaseOrder As SAPbobsCOM.Documents
vPurchaseOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
'Document Data
vPurchaseOrder.CardCode = "V1010"
vPurchaseOrder.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
vPurchaseOrder.DocDate = "08/04/08" 'DateTime.Today
'Document Lines
vPurchaseOrder.Lines.ItemCode = "A00002"
vPurchaseOrder.Lines.UnitPrice = 2.36
vPurchaseOrder.Lines.Quantity = 50
vPurchaseOrder.Lines.DiscountPercent = 10
vPurchaseOrder.Lines.Add()
vPurchaseOrder.Lines.SetCurrentLine(1)
vPurchaseOrder.Lines.ItemCode = "A00002"
vPurchaseOrder.Lines.Quantity = 1
vPurchaseOrder.Lines.UnitPrice = 118
vPurchaseOrder.Lines.DiscountPercent = 10
vPurchaseOrder.Lines.Add()
vPurchaseOrder.Lines.SetCurrentLine(2)
'Add the po
RetVal = vPurchaseOrder.Add
'Check the result
If RetVal <> 0 Then
oCompany.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrCode & " " & ErrMsg)
End If
Regards,
Noor
Hi Noor,
Try with the following code..
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vPurchaseOrder As SAPbobsCOM.Documents
vPurchaseOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
vPurchaseOrder.CardCode = "V1010"
vPurchaseOrder.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
vPurchaseOrder.DocDate = DateTime.Today
vPurchaseOrder.Lines.ItemCode = "A00002"
vPurchaseOrder.Lines.UnitPrice = 2.36
vPurchaseOrder.Lines.Quantity = 50
vPurchaseOrder.Lines.DiscountPercent = 10
vPurchaseOrder.Lines.Add()
vPurchaseOrder.Lines.ItemCode = "A00002"
vPurchaseOrder.Lines.Quantity = 8
vPurchaseOrder.Lines.UnitPrice = 5
vPurchaseOrder.Lines.DiscountPercent = 10
'Add the po
RetVal = vPurchaseOrder.Add
'Check the result
If RetVal 0 Then
'objMain.objCompany.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrCode & " " & ErrMsg)
End If
And also if the above doesn't work then try to hard code the date and check, if u face further problems then try to add the same PO, with the same values from the SAP Front end and check for the error.
Hope it helps,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.