on 06-05-2008 5:06 AM
Hi All! "Item no. is missing [INV1.ItemCode][line: 2]"
I have function to Insert A/R Invoice as follows:
Private Function Add_Invoice(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.SetCurrentLine(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
oInv.Lines.Add()
Next
lRetCode = oInv.Add()
If lRetCode <> 0 Then
oCompany.GetLastError(lErrCode, sErrMsg)
MessageBox.Show(sErrMsg)
Return False
else
Return true
end if
end function
But when I Add 1 item, It Appears error "Item no. is missing [INV1.ItemCode][line: 2]". Add 2 items appears "Item no. is missing [INV1.ItemCode][line: 3]". I don't know this bug. Help me to solve this problem. Thanks.
Dear Tao lao,
Please check if the Cash G/L Account "111100" is a valid account.
Best Regards
Jane Jing
SAP Business One Forums team
Edited by: Jane Jing on Jun 6, 2008 4:17 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
When adding marketing documents, the first line is automatically created. Therefore, you need to put a little bit of logic that only adds new rows after the first one has been populated.
Something like:
For i_row As Integer = 0 To jsgxDetails.RowCount - 1
jsgxDetails.Row = i_row
' Only add a new row if the first row has been populated
If i_row > 0 Then
oInv.Lines.Add()
End If
oInv.Lines.SetCurrentLine(i_row)
...
Next
Kind Regards,
Owen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Tao lao,
The DI documents object has defualt first line and don't need call oInv.Lines.Add() for first line.
Your code will add a empty last line since you call oInv.Lines.Add() but not assign any property value for it.
You could sample change code
'------------------------------------
oInv.Lines.Add()
'------------------------------------
to
'------------------------------------
If i_row < RowCount - 1 Then
oInv.Lines.Add()
End If
'------------------------------------
to fix the issue
Best regards
Jane Jing
SAP Business One Forum team
Edited by: Jane Jing on Jun 5, 2008 9:13 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jane Jing!
Thanks for your support I have fixed this problem. Now I want to add Payment continue in Add Invoice function:
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)
MessageBox.Show(sErrMsg)
Return False
End If
The DocEntry of Invoice i have Add, but appear Error "No matching records found (ODBC -2028)" . Help me to fix it. Thanks
Edited by: Tao lao on Jun 5, 2008 12:09 PM
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
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.