cancel
Showing results for 
Search instead for 
Did you mean: 

Create journal by SDK using different associated accounts.

Former Member
0 Kudos

It is possible to use a different account associated in the journal via SDK

If I asing the value to the field shortname assumes the account by default. and if it indicates the value to the field account and shortname, sends an error indicating that the account is incorrect.

How can do that?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Claudio Guerra,

Please use AccountCode for 'G/L account' and ShortName for 'BP Code' respectively.

You don't need to assign the value for both fields.

Best Regards

Jane Jing

SAP Business One Forums team

Answers (2)

Answers (2)

Former Member
0 Kudos

HI,

Please check for the segments and the account formats in ur SAP B1 settings..

Hope it helps,

Vasu Natari.

Former Member
0 Kudos

Hi,

This is the sample code extracted from sdk.I hope this will help u...:)

Description

The following sample code shows how to add a JournalEntries object into the database.

Source 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

REgards

Mohana