Dear Sir,
I need to add an accounting entry into SAP BO via SDK.
I am using the following code:
For iColCount = 1 To lFactorColl.Count
'//Search Accounting information
oTable = oDataSet.Tables("DocList")
Dim oSRows() As DataRow = oTable.Select("FactorCode = '" & lFactorColl.Item(iColCount).ToString & "'")
oJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)
Try
iIndex = 0
oJE.TaxDate = CDate(Right(oDate, 2) & "/" & Mid(oDate, 5, 2) & "/" & Left(oDate, 4))
oJE.DueDate = CDate(Right(oDate, 2) & "/" & Mid(oDate, 5, 2) & "/" & Left(oDate, 4))
oJE.ReferenceDate = CDate(Right(oDate, 2) & "/" & Mid(oDate, 5, 2) & "/" & Left(oDate, 4))
oJE.Memo = "test"
'// Set the first lines for the clients invoices - credit side
For iRowCount = 0 To oSRows.GetUpperBound(0)
iIndex = iRowCount
oJE.Lines.SetCurrentLine(iIndex)
'sAccountKey = GetAccountKey(oSRows(iRowCount)("CardCode"))
oJE.Lines.ShortName = oSRows(iRowCount)("CardCode")
'oJE.Lines.AccountCode = oSRows(iRowCount)("CardCode")
'sAccountKey = GetAccountKey(oSRows(iRowCount)("FactorCode"))
'oJE.Lines.ContraAccount = sAccountKey
sFactor = lFactorColl.Item(iColCount + 1).ToString
oJE.Lines.Credit = CDbl(Replace(oSRows(iRowCount)("Amount"), ".", ","))
sTotalAmt = sTotalAmt + CDbl(Replace(oSRows(iRowCount)("Amount"), ".", ","))
oJE.Lines.Add()
Next iRowCount
'Set the factor line - debit side
iIndex = iIndex + 1
oJE.Lines.SetCurrentLine(iIndex)
'sAccountKey = GetAccountKey(sFactor)
'oJE.Lines.AccountCode = sFactor
oJE.Lines.ShortName = "02"
oJE.Lines.Debit = sTotalAmt
oJE.Lines.Add()
If oJE.Add = 0 Then
Dim num As Integer
oCompany.GetLastError(num, sStr2)
SBO_Application.MessageBox(sStr2)
Else
SBO_Application.MessageBox("Import was successful!")
oJE.SaveXML("c:\JournalEntries" + Str(oJE.Number) + ".xml")
End If
Catch exception1 As Exception
End Try
Next
this code does not generate any error but no accouting entry are entered although if i try to enter it manually, it is saved in the database.
please advise what it is wrong in my code making it not working properly.
PS: both credit and Debit side in my entry is using the BP code and not G/L account.
Best Regards