[AccessD] IBAN/BIC length and structure.

Erwin Craps Erwin.Craps at ithelps.be
Wed Nov 26 10:48:49 CST 2003


German is OK
Every Dutch speaking persons understand pretty well German...

When ich das spreche musse kan ich das mit eines heise kartuffel in den mond :-) 
I hope this makes some sense.....


I was on the Swift site, but no way I could find some definitions.
I got more than I needed from U Gustav, Thanks for your code, I'll leave the credit in it...

Dankeschön...
(Or something :-)


-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, November 26, 2003 5:30 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] IBAN/BIC length and structure.

Hi Erwin

> I'm adding some IBAN and BIC fields to an internationaly used app but 
> can't find some data.
> I found everything I need to know about IBAN code structure and 
> lenght, but i can't seem to find a structure and/or length for the 
> Swift BIC code.
 
> Does anyone knows what the lenght and structure of a BIC code is?

Yes, in German!

Also note this ultimate link:

  http://www.swift.com/biconline/index.cfm


<german>

Jeder SWIFT-Teilnehmer hat eine eindeutige Kennung, den sogenannten BIC (Bank Identifier Code). 
Dieser hat 8 oder 11 Stellen und ist wie folgt aufgebaut : 

bank code
        4 Stellen Alphazeichen frei gewählt (Bundesbank z.B. MARK) 

country code
        2 Stellen Alphazeichen, ISO-Code des Landes (in Deutschland also DE) 

location code
        2 Stellen alphanumerisch zur Ortsangabe (z.B. FF für Frankfurt) 

branch code
        wahlweise 3 Stellen alphanumerisch zur Bezeichnung von Filialen 

Einige Besonderheiten kann man auch am SWIFT-BIC erkennen: 

Eine Null an der 8. Stelle kennzeichnet eine Testkennung 

Eine 1 an der 8. Stelle gibt an, daß es sich nicht um einen Live-Teilnehmer handelt, der selber an SWIFT angeschlossen ist (sogenannte non-SWIFT BICs). Solche Kennungen können nur als eine Art "Adreßkürzel" in Nachrichten benutzt werden, wenn auf diese Bank verwiesen wird, diese Teilnehmer können aber selber keine Nachrichten
senden oder empfangen     
Bei US-amerikanischen Kennungen gibt die vorletzte Stelle des location codes die Zeitzone (3=Ostküste bis 6=Westküste) der betreffenden Bank an  

Eine Stelle mit Sende-/Empfangsterminal hat immer eine 8-stellige Kennung, Filialen (11 Stellen) senden immer über die übergeordnete 8-stellige Nummer  

Wegen seiner Eindeutigkeit wird ein SWIFT-BIC im grenzüberschreitenden Zahlungsverkehr wie eine Art internationale Bankleitzahl verwendet.
Diese Codes sind nach ISO 9362 genormt und SWIFT ist von ISO als die "registration authority" für die Umsetzung der Norm benannt worden.

</german>


We use these declarations and two functions:

<code>

' Module for handling and validation of
'   IBAN, International Bank Account Number
' and
'   BIC, Bank Identifier Code
'
' as well as ISO 7064 MOD 97-10 calculations.
'
' (c) 2003. Cactus Data ApS. CPH.

  ' Length of short ISO 3166 alpha country code per definition.
  Private Const pclngLenISO3166Alpha              As Long = 2
  ' Lenght of ISO 7064 check number per definition.
  Private Const pclngLenISO7064Check              As Long = 2
  ' Minimum length of BBAN, Basic Bank Account Number.
  ' Emperic value. Normally minimum 4 + 8 but 11 for Norway.
  Private Const pclngLenBBANMin                   As Long = 10
  
  ' Length of BIC bank code per definition.
  Private Const pclngLenBICBank                   As Long = 4
  ' Length of BIC location code per definition.
  Private Const pclngLenBICLocation               As Long = 2
  ' Length of BIC branch code per definition.
  Private Const pclngLenBICBranch                 As Long = 3
  
  ' Maximum length of Electronic IBAN string per definition.
  ' Example: FR1420041010050500013M02606
  Private Const pclngLenIBANElectronicMax         As Long = 34
  ' Length of Paper IBAN group per definition.
  Private Const pclngLenIBANPaperGroup            As Long = 4
  ' Spacing of Paper IBAN groups per definition.
  Private Const pclngLenIBANPaperGroupSpacing     As Long = 1
  
  ' Constants for IsStrISO13616() for verification method.
  Private Const pcbytVerifyISO13616Alphanums      As Byte = 0
  Private Const pcbytVerifyISO13616Chars          As Byte = 1
  Private Const pcbytVerifyISO13616Digits         As Byte = 2
  
  ' Valid IBAN characters, 0-9 and A-Z.
  Private Const pcbytAscIBANDigitMin              As Byte = &H30
  Private Const pcbytAscIBANDigitMax              As Byte = &H39
  Private Const pcbytAscIBANCharMin               As Byte = &H41
  Private Const pcbytAscIBANCharMax               As Byte = &H5A
  ' IBAN value of character "A" per definition.
  Private Const pclngValIBANCharA                 As Long = 10
  ' Offset from IBAN value of char to ASCII value of char.
  Private Const pclngValIBANCharOffset            As Long = pcbytAscIBANCharMin - pclngValIBANCharA
  
  ' Type definition for IBAN string.
  ' An IBAN string consists of:
  '   tIBAN.strISO & tIBAN.strChk & tIBAN.strBBAN
  '
  Private Type tIBAN
    ' Chars only.
    strISO      As String * pclngLenISO3166Alpha
    ' Digits only.
    strChk      As String * pclngLenISO7064Check
    ' Alphanums. Variable length.
    strBBAN     As String
  End Type

  ' Type definition for BIC string.
  ' A BIC string consists of:
  '   tBIC.strBank & tBIC.strCountry & tBIC.strLocation
  ' or
  '   tBIC.strBank & tBIC.strCountry & tBIC.strLocation & tBIC.strBranch
  '
  Private Type tBIC
    ' Chars only.
    StrBank     As String * pclngLenBICBank
    ' Chars only.
    strISO      As String * pclngLenISO3166Alpha
    ' Alphanums.
    strLocation As String * pclngLenBICLocation
    ' Alphanums.
    strBranch   As String * pclngLenBICBranch
  End Type

'----

Public Function IsStrBIC(ByVal strBIC As String) As Boolean

' Verifies if strString is a valid BIC, Bank Interchange Code, or ' S.W.I.F.T. code according to ISO 13616.
' Returns True for strings that can be validated.
' Returns False for all other strings including empty strings.
'
' Requires:
'   IsStrISO13616()
'
' 2003-06-20. Cactus Data ApS. CPH.

  ' Length of BIC without branch code per definition.
  Const clngBICShort        As Long = pclngLenBICBank + pclngLenISO3166Alpha + pclngLenBICLocation
  ' Length of BIC branch code per definition.
  Const clngBICBranch       As Long = pclngLenBICBranch
  ' Length of BIC with branch code per definition.
  Const clngBICLong         As Long = clngBICShort + clngBICBranch
  
  Dim typBIC  As tBIC
  
  Dim lngLen  As Long
  Dim booChk  As Boolean
    
  lngLen = Len(strBIC)
  ' Check length of strBIC.
  If lngLen = clngBICShort Or lngLen = clngBICLong Then
    ' Extract substrings.
    With typBIC
      .StrBank = Mid(strBIC, 1)
      .strISO = Mid(strBIC, 1 + pclngLenBICBank)
      .strLocation = Mid(strBIC, 1 + pclngLenBICBank + pclngLenISO3166Alpha)
      .strBranch = Mid(strBIC, 1 + clngBICShort)
      ' Verify substrings.
      If IsStrISO13616(.StrBank, pcbytVerifyISO13616Chars) = True Then
        If IsStrISO13616(.strISO, pcbytVerifyISO13616Chars) = True Then
          If IsStrISO13616(.strLocation, pcbytVerifyISO13616Alphanums) = True Then
            If lngLen = clngBICShort Then
              ' Short BIC verified.
              booChk = True
            ElseIf IsStrISO13616(.strBranch, pcbytVerifyISO13616Alphanums) = True Then
              ' Long BIC verified.
              booChk = True
            End If
          End If
        End If
      End If
    End With
  End If
  
  IsStrBIC = booChk

End Function

Public Function IsStrISO13616( _
  ByVal strString As String, _
  Optional ByVal bytAlphaNum As Byte) _
  As Boolean

' Performs a character by character validation according to ISO 13616.
' If bytAlphaNum is 1, only digits are accepted.
' If bytAlphaNum is 2, only chars are accepted.
' If bytAlphaNum is 0, missing or another value than 1 or 2, both ' chars and digits are accepted.
'
' Returns True for strings that can be validated.
' Returns False for all other strings including empty strings.
'
' 2003-06-20. Cactus Data ApS. CPH.

  Dim lngLoop As Long
  Dim lngLen  As Long
  Dim bytAsc  As Byte
  Dim booChk  As Boolean

  lngLen = Len(strString)
  If lngLen > 0 Then
    booChk = True
    For lngLoop = 1 To lngLen
      ' Check each character.
      bytAsc = Asc(Mid(strString, lngLoop))
      Select Case bytAsc
        Case pcbytAscIBANDigitMin To pcbytAscIBANDigitMax
          ' Digit.
          If bytAlphaNum = pcbytVerifyISO13616Chars Then
            ' Digits not allowed.
            booChk = False
          End If
        Case pcbytAscIBANCharMin To pcbytAscIBANCharMax
          ' Valid non-numeric character.
          If bytAlphaNum = pcbytVerifyISO13616Digits Then
            ' Characters not allowed.
            booChk = False
          End If
        Case Else
          ' Invalid character.
          booChk = False
      End Select
    Next
  End If
  
  IsStrISO13616 = booChk

End Function

</code>

Great fun!

/gustav

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list