Skip to Content
author's profile photo Former Member
Former Member

Conform to SAP address format settings, is there an object or service?

Is there any object or service available that implements the SAP Business One address formatting feature--i.e. we would like to have something that puts the address in the proper format given the following parameters:

Address Format (Code or Name from OADF), street, block, city, county, state, zip, country

Also, how does the system know what address format code to use for the company address (stored in Administration->System Initialization->Company Details)?

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Feb 11, 2006 at 11:30 AM

    Hi Daniel,

    I don´t think there is any standard address formatting method.

    What I can tell you is that address formatting is set under AdministrationDefinitionsBusiness PartnersDefine Address Formats . Here you design the format you like. Then you should asign that format to a specific country under AdministrationDefinitionsBusiness PartnersDefine Countries .

    The format used for the address in the company address depends on the country you specify on it (Acording to the definition of countries).

    Hope helps,

    Ibai Peñ

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 10:12 PM

    Daniel (or anyone),

    Have you found/created a solution for this?

    I also need something like this:

    strFormattedAddress = SBOGetFormattedAddress( oBP, oBP.Addresses)

    The contents of OADF.Format column (that stores the Address Formats set in Administration - Setup - Business Partners - Address Formats) are quite cryptic:

    $1$N$7$N$ $2[ U]$N$[UD].

    Has anyone figured out how to get the BP addresses formatted in the same way that B1 does?

    Is there any documentation out there on Address Formats that could be useful?



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      It was not too tricky:

      [code] Dim strSQL As String

      Dim strFormat As String

      Dim strFormattedAddress As String

      Dim str_1_Street As String

      Dim str_2_City As String

      Dim str_3_PostCode As String

      Dim str_4_County As String

      Dim str_5_State As String

      Dim str_6_Country As String

      Dim str_7_Block As String

      Dim arr() As String

      Dim i As Integer

      Dim s As String

      With oAddress

      str_1_Street = .Street

      str_2_City = .City

      str_3_PostCode = .ZipCode

      str_4_County = .County

      str_5_State = .State

      str_6_Country = .Country

      str_7_Block = .Block

      PostalAddress.strCountryCode = .Country

      strSQL = "SELECT Format FROM OADF T0 JOIN OCRY T1 ON T0.Code = T1.AddrFormat WHERE T1.Code = '_Country_'"

      strSQL = Replace(strSQL, "_Country_", .Country)


      If gsboRS.RecordCount = 1 Then

      strFormat = gsboRS.Fields.Item(0).Value

      If InStr(strFormat, "$6[D") Or InStr(strFormat, "$6[UD") Or InStr(strFormat, "$6[OD") Or InStr(strFormat, "$6[PD") Then

      ' Get Country Name

      str_6_Country = SBOGetBySQL("CountryName", str_6_Country)

      End If

      If InStr(strFormat, "$5[D") Or InStr(strFormat, "$5[UD") Or InStr(strFormat, "$5[OD") Or InStr(strFormat, "$6[PD") Then

      ' Get State Name

      str_5_State = SBOGetBySQL("StateName", str_5_State)

      End If


      If InStr(strFormat, "$1[U") Then str_1_Street = str_1_Street.ToUpper

      If InStr(strFormat, "$2[U") Then str_2_City = str_2_City.ToUpper

      If InStr(strFormat, "$3[U") Then str_3_PostCode = str_3_PostCode.ToUpper

      If InStr(strFormat, "$4[U") Then str_4_County = str_4_County.ToUpper

      If InStr(strFormat, "$5[U") Then str_5_State = str_5_State.ToUpper

      If InStr(strFormat, "$6[U") Then str_6_Country = str_6_Country.ToUpper

      If InStr(strFormat, "$7[U") Then str_7_Block = str_7_Block.ToUpper

      ' lowercase

      If InStr(strFormat, "$1[O") Then str_1_Street = str_1_Street.ToLower

      If InStr(strFormat, "$2[O") Then str_2_City = str_2_City.ToLower

      If InStr(strFormat, "$3[O") Then str_3_PostCode = str_3_PostCode.ToLower

      If InStr(strFormat, "$4[O") Then str_4_County = str_4_County.ToLower

      If InStr(strFormat, "$5[O") Then str_5_State = str_5_State.ToLower

      If InStr(strFormat, "$6[O") Then str_6_Country = str_6_Country.ToLower

      If InStr(strFormat, "$7[O") Then str_7_Block = str_7_Block.ToLower

      ' Capitalized

      If InStr(strFormat, "$1[P") Then str_1_Street = str_1_Street.Substring(1, 1).ToUpper & str_1_Street.Substring(2).ToLower

      If InStr(strFormat, "$2[P") Then str_2_City = str_2_City.Substring(1, 1).ToUpper & str_2_City.Substring(2).ToLower

      If InStr(strFormat, "$3[P") Then str_3_PostCode = str_3_PostCode.Substring(1, 1).ToUpper & str_3_PostCode.Substring(2).ToLower

      If InStr(strFormat, "$4[P") Then str_4_County = str_4_County.Substring(1, 1).ToUpper & str_4_County.Substring(2).ToLower

      If InStr(strFormat, "$5[P") Then str_5_State = str_5_State.Substring(1, 1).ToUpper & str_5_State.Substring(2).ToLower

      If InStr(strFormat, "$6[P") Then str_6_Country = str_6_Country.Substring(1, 1).ToUpper & str_6_Country.Substring(2).ToLower

      If InStr(strFormat, "$7[P") Then str_7_Block = str_7_Block.Substring(1, 1).ToUpper & str_7_Block.Substring(2).ToLower

      arr = strFormat.Split("$")

      For i = 0 To arr.Length - 1

      s = arr(i)

      If s.StartsWith("1") Then

      strFormattedAddress &= str_1_Street & " "

      ElseIf s.StartsWith("2") Then

      strFormattedAddress &= str_2_City & " "

      ElseIf s.StartsWith("3") Then

      strFormattedAddress &= str_3_PostCode & " "

      ElseIf s.StartsWith("4") Then

      strFormattedAddress &= str_4_County & " "

      ElseIf s.StartsWith("5") Then

      strFormattedAddress &= str_5_State & " "

      ElseIf s.StartsWith("6") Then

      strFormattedAddress &= str_6_Country & " "

      ElseIf s.StartsWith("7") Then

      strFormattedAddress &= str_7_Block & " "

      ElseIf s.StartsWith("N") Then

      strFormattedAddress &= vbCrLf

      ElseIf Not s.StartsWith("L") Then

      strFormattedAddress &= strFormattedAddress & " "

      End If


      End If

      End With




      Message was edited by: Juha Lassila

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.