on 03-04-2009 7:55 PM
I have 2007 Business one installed and I am exporting invoice from our Software to SAP but it shows the Amount $0 in SAP when I see the A/R Invoice. Below is my code:
Dim vDrafts As SAPbobsCOM.Documents
Set vDrafts = vCmp.GetBusinessObject(oDrafts)
vDrafts.CardCode = invoiceEvents.ClientId
vDrafts.ManualNumber = invoiceEvents.InvoiceNumber
vDrafts.HandWritten = tNO
vDrafts.DocDate = invoiceEvents.DocumentDate
vDrafts.DocType = dDocument_Service
vDrafts.DiscountPercent = CDbl("0")
vDrafts.PaymentGroupCode = "-1"
If isFirstOne <> 1 Then vDrafts.Lines.Add
vDrafts.Lines.AccountCode = AcctCode
vDrafts.Lines.ItemDescription = invItem.Reference
vDrafts.Lines.Price = IIf(isCreditNote = 1, -CDbl(invItem.Amount), CDbl(invItem.Amount))
vDrafts.Lines.Quantity = 1
RetVal = vDrafts.Add
If RetVal <> 0 Then
vCmp.GetLastError RetVal, ErrMsg
If RetVal = -2028 Then ErrMsg = strError(8)
WriteToReportFile gstrLogFile, ErrMsg
Exit Function
End If
You are using the DRAFT object. That is not the same as Invoice. You probably could find the records from Document Draft. If that is what you need, you have to create invoice from those drafts.
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The same code was working fine in SAP Business 2005 but since I have switched to 2007 Business one I started having this problem, Now if I put the price in the Interface PriceAfterVAT then everything is fine there is no problem. only problem is with the Price Interface which is not updating the SAP database.
Here is my code:
'Create the Documents object
Dim vDrafts As SAPbobsCOM.Documents
If SaveArasDraft = 1 Then
Set vDrafts = vCmp.GetBusinessObject(oDrafts)
If lExportCreditNote = 1 And invoiceEvents.NewBalance < 0 Then
vDrafts.DocObjectCode = oCreditNotes
isCreditNote = 1
Else
vDrafts.DocObjectCode = oInvoices
End If
Else
If lExportCreditNote = 1 And invoiceEvents.NewBalance < 0 Then
Set vDrafts = vCmp.GetBusinessObject(oCreditNotes)
isCreditNote = 1
Else
Set vDrafts = vCmp.GetBusinessObject(oInvoices)
End If
End If
vDrafts.CardCode = invoiceEvents.ClientId
vDrafts.ManualNumber = invoiceEvents.InvoiceNumber
vDrafts.HandWritten = tNO
'vDrafts.DocDate = Now
'Modified by Knar Najarian to pass Invoice Document date
vDrafts.DocDate = invoiceEvents.DocumentDate
vDrafts.DocType = dDocument_Service
vDrafts.DiscountPercent = CDbl("0")
vDrafts.Comments = strError(7) & " " & invoiceEvents.InvoiceNumber
If InvoiceAlreadyExported(invoiceEvents.InvoiceNumber) Then
WriteToReportFile gstrLogFile, strError(1)
Exit Function
End If
If Not TaxCodeIsValid(invoiceEvents.TaxId) Then
WriteToReportFile gstrLogFile, invoiceEvents.TaxId & " " & strError(0)
Exit Function
End If
If Not TaxCodeIsValid(ExemptTaxCode) Then
WriteToReportFile gstrLogFile, ExemptTaxCode & " " & strError(0)
Exit Function
End If
For Each invItem In invoiceEvents.ItemsList
If invItem.TrnsType = "C" And CLng(invItem.IsTaxAcc) = 0 Then
If CLng(invItem.Status) <> 1 Then
WriteToReportFile gstrLogFile, strError(2)
WriteToReportFile gstrLogFile, strError(3) & invItem.AccNumber
WriteToReportFile gstrLogFile, strError(4) & invItem.Amount
WriteToReportFile gstrLogFile, strError(5) & invItem.Reference & strError(6)
Exit Function
End If
Dim AcctCode As String
AcctCode = getAccountCode(invItem.AccNumber)
If AcctCode = "" Then Exit Function
If isFirstOne <> 1 Then vDrafts.Lines.Add
vDrafts.Lines.AccountCode = AcctCode
vDrafts.Lines.ItemDescription = invItem.Reference
vDrafts.Lines.Price = IIf(isCreditNote = 1, -CDbl(invItem.Amount), CDbl(invItem.Amount))
vDrafts.Lines.Quantity = 1
If invItem.IsTaxable Then
If gstrTaxSystem = "US" Then
vDrafts.Lines.TaxCode = invoiceEvents.TaxId
Else
vDrafts.Lines.VatGroup = invoiceEvents.TaxId
End If
Else
If gstrTaxSystem = "US" Then
vDrafts.Lines.TaxCode = ExemptTaxCode
Else
vDrafts.Lines.VatGroup = ExemptTaxCode
End If
End If
vDrafts.Lines.DiscountPercent = CDbl("0")
If lUseCostCenter = 1 Then vDrafts.Lines.CostingCode = invItem.CostCenter
If lUseProjectCode = 1 Then vDrafts.Lines.ProjectCode = invItem.ProjectCode
isFirstOne = 2
End If
Next
'Add the Invoice
RetVal = vDrafts.Add
Thanks
Donald
Edited by: Donald George on Mar 6, 2009 8:44 PM
User | Count |
---|---|
98 | |
12 | |
11 | |
6 | |
5 | |
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.