Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Adding a PO through DI API


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


Noor hussain

Former Member
Not what you were looking for? View more on this topic or Ask a question