Skip to Content
0
Former Member
Mar 10, 2009 at 08:00 PM

Add a JournalEntries

19 Views

I need to do an import to the Journal table, I trying to use the sample code in SAP Business One SDK but i can't connect. Any of you has done something similar.

Albert Torres

here is the code:

Private Sub cmdTest_Click()

On Error GoTo ErrorHandler

Dim vCompany As SAPbobsCOM.Company

'create company object

Set vCompany = New SAPbobsCOM.Company

'set paras for connection

vCompany.CompanyDB = "SBODemo_US"

vCompany.Password = "manager"

vCompany.UserName = "manager"

vCompany.Server = "(local)"

'connect to database server

If (0 <> vCompany.Connect()) Then

MsgBox "Failed to connect"

Exit Sub

End If

Dim nErr As Long

Dim errMsg As String

'add an Journal entry

Dim vJE As SAPbobsCOM.JournalEntries

Set vJE = vCompany.GetBusinessObject(oJournalEntries)

vJE.TaxDate = Now

vJE.Lines.AccountCode = "110000"

vJE.Lines.ContraAccount = "10110"

vJE.Lines.Credit = 0

vJE.Lines.Debit = 150

vJE.Lines.DueDate = CDate("11/13/ 2002")

vJE.Lines.ReferenceDate1 = Now

vJE.Lines.ShortName = "110000"

vJE.Lines.TaxDate = Now

Call vJE.Lines.Add

Call vJE.Lines.SetCurrentLine(1)

vJE.Lines.AccountCode = "10110"

vJE.Lines.ContraAccount = "110000"

vJE.Lines.Credit = 150

vJE.Lines.Debit = 0

vJE.Lines.DueDate = CDate("11/13/ 2002")

vJE.Lines.Line_ID = 1

vJE.Lines.ReferenceDate1 = Now

vJE.Lines.ShortName = "10110"

vJE.Lines.TaxDate = Now

If (0 <> vJE.Add()) Then

MsgBox ("failed to add a journal entry")

Else

MsgBox ("Succeeded in adding a journal entry")

vJE.SaveXml ("c:\temp\JournalEntries" + Str(vJE.JdtNum) + ".xml")

End If

'Check Error

Call vCompany.GetLastError(nErr, errMsg)

If (0 <> nErr) Then

MsgBox ("Found error:" + Str(nErr) + "," + errMsg)

End If

'disconnect the company object, and release resource

Call vCompany.Disconnect

Set vCompany = Nothing

Exit Sub

ErrorHandler:

MsgBox ("Exception:" + Err.Description)

End Sub