📚 SAP Business One SDK Help

CreateOpenBalance Method
See Also  Example
pIOpenningBalanceAccount

Specifies the opening balance account.

pBPCodes

Bpcodes is a collection of BPCode, a data structure related to the BusinessPartnersService.

Description

Transfers credit or debit amounts from a specified opening balance account to one or more business partner accounts.

Syntax

Visual Basic
Public Sub CreateOpenBalance( _
   ByVal pIOpenningBalanceAccount As OpenningBalanceAccount, _
   ByVal pBPCodes As BPCodes _
) 

Parameters

pIOpenningBalanceAccount

Specifies the opening balance account.

pBPCodes

Bpcodes is a collection of BPCode, a data structure related to the BusinessPartnersService.

Example

Creating an opening balance for two business partners (Visual Basic)Copy Code
Dim oCmpSrv As SAPbobsCOM.CompanyService
Dim oBusinessPartnersService As SAPbobsCOM.BusinessPartnersService
Dim oOpenningBalanceAccount As SAPbobsCOM.OpenningBalanceAccount
Dim oBpAccounts As SAPbobsCOM.BPCodes
Dim oBpAccountFirst As SAPbobsCOM.BPCode
Dim oBpAccountSecond As SAPbobsCOM.BPCode

'get company service
oCmpSrv = oCompany.GetCompanyService

'get account service
oBusinessPartnersService = oCmpSrv.GetBusinessService(ServiceTypes.BusinessPartnersService)

'get Accounts Service Data Interface
oOpenningBalanceAccount = oBusinessPartnersService.GetDataInterface(AccountsServiceDataInterfaces.asdiOpenningBalanceAccount)

'set the account code (account name = Common Stock (HO, USA, GA )) 'for the opening balance account
oOpenningBalanceAccount.OpenBalanceAccount = "_SYS00000000078"
'set the details
oOpenningBalanceAccount.Details = "Bp Accounts Opening Balance"

'set the date
oOpenningBalanceAccount.Date = Date.Today

'get ref to Bp accounts
oBpAccounts = oBusinessPartnersService.GetDataInterface(BusinessPartnersServiceDataInterfaces.bpsdiBPCodes)

'add accounts that will be in credit or in debit
'add first account
oBpAccountFirst = oBpAccounts.Add
'set the account code
oBpAccountFirst.Code = "HU1006"
'set credit amount
oBpAccountFirst.Credit = 300

'add second account
oBpAccountSecond = oBpAccounts.Add
'set the account code
oBpAccountSecond.Code = "HU1007"
'set credit amount
oBpAccountSecond.Credit = 300

'create the balance for the first and second accounts from the Opening Balance Account
oBusinessPartnersService.CreateOpenBalance(oOpenningBalanceAccount,oBpAccounts)

See Also