📚 SAP Business One SDK Help

FormatCode Property
See Also  Example

Description

Sets or returns the account number when account segmentation is defined in SAP Business One.

Field name: FormatCode.

Length: 210 characters.

Mandatory field in SAP Business One when working with account segmentation

Property type

Read-write property

Syntax

Visual Basic
Public Property FormatCode() As String

Remarks

Retrieving an account that operates with account segmentation

When working with segmentation, SAP Business One ignores the account Code and uses only the FormatCode that its value represents the account number in Chart Of Accounts.

To retrieve an account that operates with account segmentation:

1. Find the account key using the method GetObjectKeyBySingleValue.

2. Use the returned Recordset to retrieve the value of the key (for example, _SYS00000000010).

3. Call the method GetByKey with this value (for example, _SYS00000000010) to retrieve the account.

FormatCode Structure

The FormatCode can include up to 10 segments. The default account segmentation format in US databases includes four segments as follows:

  • Natural account - 8 numbers (for example: 11100000)
  • Division - 2 numbers (for example: 01)
  • Region - 3 numbers (for example: 001)
  • Department - 2 numbers (for example: 03)

The complete FormatCode is in the example listed above is: 11100000-01-001-03.

Example

Retrieving an account when working with segmentation (Visual Basic)Copy Code
Dim sStr As String
    Dim vRs As SAPbobsCOM.Recordset
    Dim vBOB As SAPbobsCOM.SBObob
    Dim vCH As SAPbobsCOM.ChartOfAccounts
    Set vCH = Vcmp.GetBusinessObject(oChartOfAccounts)
    Set vBOB = Vcmp.GetBusinessObject(BoBridge)
    Set vRs = Vcmp.GetBusinessObject(BoRecordset)
    Set vRs = vBOB.GetObjectKeyBySingleValue(oBusinessPartners, "CardName", "aaa", bqc_Equal)

    ' When working with segmentation use this function
    ' to find the account key in the ChartOfAccount object

    Set vRs = vBOB.GetObjectKeyBySingleValue(oChartOfAccounts, "FormatCode", "125100000100101", bqc_Equal)

    'The Recordset retrieves the value of the key (for example, sStr = _SYS00000000010).
    sStr = vRs.Fields.Item(0).Value

    'Call the method GetByKey with this value (for example, sStr =_SYS00000000010) to 'retrieve the account
    vCH.GetByKey (sStr)

See Also