Showing results for 
Search instead for 
Did you mean: 

Error When Add Payment to SAP!

Former Member
0 Kudos

Hi All !

I have function to Add Invoice and payment as follows:

Private Function Add_Invoice_Payment(ByVal TransCode As Double) As Boolean

Dim strShop As String = "C570004"

Dim oInv As SAPbobsCOM.Documents

oInv = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

oInv.CardCode = strShop

oInv.DocDate = Now.Date

oInv.DocDueDate = Now.Date

oInv.Comments = "From POS System - With Transaction Code " & TransCode

Dim disc As Double = 0

Dim WarehouseCode As String = "HCI001"

Dim VATGroup As String = "S10_CM"

For i_row As Integer = 0 To jsgxDetails.RowCount - 1

jsgxDetails.Row = i_row


oInv.Lines.ItemCode = jsgxDetails.GetValue("Item_Code")

oInv.Lines.ItemDescription = jsgxDetails.GetValue("Item_Name")

oInv.Lines.UnitPrice = jsgxDetails.GetValue("Item_Price")

oInv.Lines.Quantity = jsgxDetails.GetValue("Item_Quantity")

oInv.Lines.DiscountPercent = disc

oInv.Lines.WarehouseCode = WarehouseCode

oInv.Lines.VatGroup = VATGroup



lRetCode = oInv.Add()

If lRetCode = 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)


Return False


'''''''''''''''''Add Payment from Invoice have Added

Dim oPayment As SAPbobsCOM.Payments

oPayment = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)

oPayment.CardCode = strShop

oPayment.DocDate = Now.Date

oPayment.DocCurrency = "VND"

oPayment.CashAccount = "111100"

oPayment.CashSum = oInv.DocTotal

oPayment.Series = 0

oPayment.Remarks = "Remarks"

oPayment.Invoices.DocEntry = oInv.DocEntry

oPayment.Invoices.DocLine = 0

oPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice

oPayment.Invoices.SumApplied = oInv.DocTotal

lRetCode = oPayment.Add

If lRetCode 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)


Return False

End If

end if

end function

Add Invoice is OK! but when Add Payment it appears Error: "No matching records found (ODBC -2028)" . Help me to fix it. Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos


the issue has got something to do with oInv.DocEntry only. have you tried passing some hardcoded docentry of Invoice? and after you add the invoice thorough DI API, are you sure , oInv.DocEntry has that docentry reference only?


Former Member
0 Kudos

Dear Tao lao,

The error "No matching records found (ODBC -2028)" can mean any property's value are invalid.

Do you get more detailed error like

"No matching record found 'G/L Accounts' [ODBC 2028]" ?

If you suspect the issue is due to the DocEntry is incorrect, then you can try

1. use DocNum

oPayment.Invoices.DocEntry = oInv.DocNum

2. check the value of DocNum after the invoice added, then assign the value to oPayment.Invoices.DocEntry.

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Dear Tao lao,

Please check if the case G/L Account "111100" is a valid account.

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Hi Jane Jing

I Cheked, It's the valid Account.

I don't know this Error. I think It cannot found the A/R Invoice(Doc Entry) I have Added. Help me.

Former Member
0 Kudos

Hi Tao lao

In some systems the account number in the screen may differ from

the acctual account number in the OACT table.

Please check the "111100" exists in OACT table or not.


Syn Qin

SAP Business One Forums Team