cancel
Showing results for 
Search instead for 
Did you mean: 

Error creating an AP Invoice

Former Member
0 Kudos

Hi,

I am trying to create an AP invoice(Doc Type = Service) using DI API.I am getting the following eror message:

[OPCH.GrosProfit][line: 1] , 'No matching records found (ODBC -2028)'

My code is as follows:

-


Set oCmp = New SAPbobsCOM.Company

oCmp.UseTrusted = True

oCmp.Server = "(local)"

oCmp.CompanyDB = "ABC-Holding"

oCmp.UserName = "manager"

oCmp.Password = "manager"

oCmp.Language = SAPbobsCOM.BoSuppLangs.ln_English

l = oCmp.Connect()

Set oApInvoice = oCmp.GetBusinessObject(oPurchaseInvoices)

oApInvoice.DocType = dDocument_Service

oApInvoice.CardCode = "VA001S"

oApInvoice.Lines.ItemDescription = "Banana"

oApInvoice.Lines.Price = 2.36

oApInvoice.Lines.AccountCode = "999999-100"

RetVal = oApInvoice.Add

If RetVal <> 0 Then

oCmp.GetLastError ErrCode, ErrMsg

MsgBox ErrCode & " " & ErrMsg

End If

-


Please help.

Thanks.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello,

I think you must use this sentence to add the line before adding the invoice:

oApInvoice.Lines.Add

But DI has a problem when you use that method. You have to set another line after calling the add method. Then setting another line this way:

oApInvoice.Lines.ItemDescription = "Banana 2"
oApInvoice.Lines.Price = 2.40
oApInvoice.Lines.AccountCode = "999999-100"

Don't forget to set the taxCode in Both lines and after that you can add the Invoice:

RetVal = oApInvoice.Add

I hope i could help you..

Former Member
0 Kudos

Hi,

I think you'll need to setup the itemcode for every line which is added to your document.

Try to add the following code for every line you would like to add:

oAPInvoice.Lines.ItemCode = "Your ItemCode"

Furthermore you have to add the line to the document after you setup the properties. You do this with the following command:

oAPInvoice.Lines.Add()

I hope this helps you fixing your problem.

Regards

Dennis Karjetta

Message was edited by: Dennis Karjetta

Former Member
0 Kudos

I am having the same problem. I am setting the taxcode. Satish Dwevedi did you get this working?

Former Member
0 Kudos

Hi Satish,

Try setting the taxcode on the invoice line.

Lita