Address, Postcode and Bank solutions

- Pocket BankFinder Manual

PROGRAMMING POCKET BANKFINDER

The Application Programming Interface (API)

Overview

The Search Data Type or Structure

The Search Data Type contains all the fields that you can search as well as a lookup field to provide the same functionality as the Lookup box in the front end.  See the Search documentation for more details on the input that can be used with these fields.

Type SearchRec Field Details
  Lookup As String * 60   Place a query string to be looked up by the DLL here.  If this is specified the rest of the search parameters are ignored.
  SortCode As String * 8   Bank Sort Code to search for. 
  BankBIC As String * 8  Bank BIC Code to search for.
  BranchBIC As String * 3 Branch BIC Code to search for.
  Postcode As String * 8 Postcode to search for.
  BranchName As String *  60 Branch Name to search for
  BankName As String * 60   Bank Name to search for
  Town As String * 30 Town / Location to search for.
  Phone As String * 20   The STD Code & Phone Number to search on
  searchText As String * 256 Text to search for in all fields
End Type  

The Bank Data Type or Structure

This is called after a call to GetFirst or GetNext to get the general and address details for a bank record.  See the Bank Tab documentation for more details about these fields.

Type BankRec Field Details
  RecNo As Long  A unique record number used to jump directly to a record (see the  JumpRec function) 
  SortCode As String * 6 The Bank's Sort Code (Does not apply to IPSO records)
  BankBIC As String * 8 The Bank's BIC Code (Does not apply to IPSO records)
  BranchBIC As String * 3 The Branch's BIC Code (Does not apply to IPSO records)
  SubBranchSuffix As String * 2 Allows a branch to be uniquely identified where there is a cluster of branches sharing the same Sort Code (Does not apply to IPSO records)
  ShortBranchTitle As String * 27 The official title of the branch
  CentralBankCountryCode As String * 2 The ISO Country code for beneficiary banks in other countries
  Supervisory Body As String * 1 Indicates the supervisory body for an institution that is an agency in any of the clearings.  This will be A - Bank Of England, B - Building Society Commission, C - Jersey, Guernsey or Isle of Man authorities or D - Other.
  DeletedDate As String * 10 Specifies the date the branch was closed if it is not active
  BranchTypeIndicator  As String * 1 Shows the branch type (M - Main Branch, S - Sub or NAB Branch, or L - Linked Branch)
  MainBranchSortCode As String * 6 Set for linked branches in a cluster.  It identifies the main branch for the cluster. For IPSO records this is set to the branch that would handle transactions for this sortcode, if the branch has been amalgamated with another.
  MajorLocationName As String * 30 Optional field used to indent the Branch name or place in the printed directory (Does not apply to IPSO records where the branch name is normally also the location).
  MinorLocationName As String * 30 Optional field also used to indent the Branch name or place in the printed directory (Does not apply to IPSO records where the branch name is normally also the location).
  BranchName As String * 35 Defines the actual name or place of the branch
  BranchName2 As String * 35 Where applicable contains an alternative name or place for the branch
  FullBranchTitle As String * 105 Extended title for the institution (ShortBranchTitle is the official one).
  OwnerBankShortName As String * 20 The short version of the name of the Owning Bank
  OwnerBankFullName As String * 70 The full version of the name of the Owning Bank
  OwnerBankCode As String * 4 The four digit bank code of the Owning Bank (Does not apply to IPSO records).
  Property As String * 65 The Property for the Banks Postal Address
  Street As String * 60 The Street for the Banks Postal Address
  Locality As String * 60 The Locality for the Banks Postal Address
  Town As String * 30 The Town for the Banks Postal Address
  County As String * 30 The County for the Banks Postal Address
  Postcode As String * 8 The Postcode for the Banks Postal Address
  STDCode As String * 5 The Banks STD Code
  Phone As String * 8 The Banks Phone Number (concatenate with STD Code for the full number) 
  FaxSTDCode As String * 5 The Banks Fax STD Code (Only applies to IPSO records)
  Fax As String * 8 The Banks Fax Number (concatenate with Fax STD Code for the full number - Only applies to IPSO records)
  CountryIndicator As String * 1 Set to 'U' if the record is on the BACS clearing system, or 'I' if it is on the IPSO clearing system.  Branches on both will have an entry for each clearing system.
  Reserved As String * 36 Reserved for future use
End Type  

The BACS Data Type or Structure- Not relevant to IPSO records

This is called after a call to GetFirst or GetNext to get the BACS details for a bank record.  See the BACS Tab documentation for more details about these fields.

Type BACSRec Field Details
  Status As String * 1  BACS Clearing Status (M - Branch of a BACS Member, A - Branch of an Agency Bank, N - Does not accept BACS Payments)
  LastChange As String * 10 Effective date on which this data group was last amended
  ClosedClearing As String * 10 Where a branch is closed in BACS clearing this will be set at the same time that the Status field is changed to 'N'.
  RedirectedFromFlag As String * 1 Set to R if other branches are redirected to this Sort Code.  (See the GetFirstRedirect function to get a list of those redirected to this code)
  RedirectedToSortCode As String * 6 This specifies the Sort Code to which BACS should redirect payments addressed to this Sort Code if applicable.
  SettlementBankCode As String * 4 The BACS generated Bank Code of the Bank that will settle payments for this branch.
  SettlementBankShortName As String * 20 The Short form of the name of the bank corresponding to the SettlementBankCode field.
  SettlementBankFullName As String * 70 The Full form of the name of the bank corresponding to the SettlementBankCode field.
  SettlementSection As String * 2 Numeric data required for BACS to perform it's settlement
  SettlementSubSection  As String * 2 Numeric data required for BACS to perform it's settlement
  HandlingBankCode As String * 4 BACS Generated Bank Code that defines the member that will take BACS output for this branch.
  HandlingBankShortName As String * 20 The Short form of the name of the bank corresponding to the HandlingBankCode field
  HandlingBankFullName As String * 70 The Full form of the name of the bank corresponding to the HandlingBankCode field.
  HandlingBankStream As String * 2 Numeric code defining the stream of output within the Handling Bank that will be used for payments to this branch.
  AccountNumberedFlag As String * 1 Set to 1 if numbered bank accounts are used by this branch
  DDIVoucherFlag As String * 1 Set to 1 if Paper vouchers have to be printed for Direct Debit Instructions.
  AllowedDirectDebits As String * 1 Set to 1 if this branch accepts Direct Debits
  AllowedBankGiroCredits As String * 1 Set to 1 if this branch accepts Bank Giro Credits
  AllowedBuildingSocietyCredits As String * 1 Set to 1 if this branch accepts Building Society Credits
  AllowedDividendInterestPayments As String * 1 Set to 1 if this branch accepts Dividend Interest Payments
  AllowedDirectDebitInstructions As String * 1 Set to 1 if this branch accepts Direct Debit Instructions
  AllowedUnpaidChequeClaims As String * 1 Set to 1 if this branch accepts UnpaidChequeClaims
  Reserved As String * 10 Reserved for future use
End Type  

The CHAPS Data Type or Structure- Not relevant to IPSO records

This is called after a call to GetFirst or GetNext to get the CHAPS details for a bank record.  See the CHAPS Tab documentation for more details about these fields.

Type CHAPSRec Field Details
  PStatus As String * 1  Shows if the branch can accept CHAPS sterling payments and if it is an agency (M - Branch of a CHAPS £ member, A - Branch of an agency bank, N- Does not accept CHAPS £ payments).
  PLastChange As String * 10 Effective date on which this CHAPS sterling data group was last amended.
  PClosedClearing As String * 10 Where a branch is closed in CHAPS sterling clearing this will be set at the same time that the PStatus field is changed to 'N'.
  PSettlementBankCode As String * 3 CHAPS ID of the bank that will settle payments for this branch (not the same as the BACS bank code present elsewhere).
  PSettlementBankShortName As String * 20 The short form of the name of the bank corresponding to the PSettlementBankCode field.
  PSettlementBankFullName As String * 70 The Full form of the name of the bank corresponding to the PSettlementBankCode field.
  EStatus As String * 1 Shows if the branch can accept CHAPS Euro payments and if it is a direct branch (one of the member BICs which are part of the SWIFT closed user group).  (D - Direct Branch, I - Indirect Branch, N - Does not accept CHAPS Euro payments).
  ELastChange As String * 10 Effective date on which this CHAPS Euro data group was last amended.
  EClosedClearing As String * 10 Where a branch is closed in CHAPS Euro clearing this will be set at the same time that the EStatus field is changed to 'N'.
  EEuroRoutingBICBank  As String * 8 Specifies the SWIFT closed user group Bank BIC to which CHAPS Euro payments for this branch should be routed.
  EEuroRoutingBICBranch As String * 3 Specifies the SWIFT closed user group Branch BIC to which CHAPS Euro payments for this branch should be routed.
  ESettlementBankCode As String * 3 CHAPS ID of the bank that will settle payments for this branch.
  ESettlementBankShortName As String * 20 The Short form of the name of the bank corresponding to the ESettlementBankCode field.
  ESettlementBankFullName As String * 70 The Full form of the name of the bank corresponding to the ESettlementBankCode field.
  EReturnIndicator As String * 1 Set to 'R' if this is the branch to which CHAPS Euro payments should be sent.
  Reserved As String * 10 Reserved for future use
End Type  

The C&CCC Data Type or Structure- Not relevant to IPSO records

This is called after a call to GetFirst or GetNext to get the C&CCC details for a bank record.  See the C&CCC Tab documentation for more details about these fields.

Type CCCCRec Field Details
  Status As String * 1  Shows if the branch is part of Cheque and Credit Clearing and if it is an agency.  (M - Branch of a C&CCC Member, F - Full agency bank branch, D - Debit agency branch only, N - Not part of C&CCC Clearing)
  LastChange As String * 10 Effective date on which this C&CCC data group was last amended.
  ClosedClearing As String * 10 Where a branch is closed in C&CCC clearing this will be set at the same time that the Status field is changed to 'N'.
  SettlementBankCode As String * 3 BACS generated code of the bank that will settle payments for this branch.
  SettlementBankShortName As String * 20 The short form of the name of the bank corresponding to the SettlementBankCode field.
  SettlementBankFullName As String * 70 The Full form of the name of the bank corresponding to the SettlementBankCode field.
  DebitAgencySortCode As String * 6 When the Status field is set to 'D' this specifies where cheque clearing is handled for this branch. 
 ReturnIndicator As String * 1 Set if this is the branch that other banks should return paper to.  It will only be set for a sort code of a Member.
  Reserved As String * 10 Reserved for future use
End Type  

Constants

Although it is not essential, you may find it useful to declare the following constants - which are used by the Pocket BankFinder DLL functions to return error conditions etc.

Record Selection Flag Constants
   Global Const ALL_RECORDS = 0   Specifies that you want records returned on both the UK (BACS) and Irish (IPSO) clearing systems or accounts validated on both systems.
  Global Const UK_ONLY = 1 Specifies that you only want records returned which relate to the UK (BACS) clearing system, or want accounts only validated if they reside at branches wihin the UK system.
   Global Const IRISH_ONLY = 2 Specifies that you only want records returned which relate to the Irish (IPSO) clearing system, or want accounts only validated if they reside at branches wihin the Irish system.
Standard Return Code Constants
   Global Const SUCCESS = 0   Successful
  Global Const RECORD_BREAK = 5 Return with no new record after 500 non-matching records - to allow for the user to cancel a search when the searchText search field is used on it's own with few matching records.
   Global Const NOT_FOUND = -2 No records matching the lookup/search criteria specified where found
   Global Const ERROR_OPENING FILES = -4   Error opening BankFinder files
  Global Const END_OF_SEARCH = -6 GetNext has reached the end of a lookup/search, no new record returned.
  Global Const DATA_LICENSE_ERROR = -7 Registration error - run the Welcome program to register your copy of BankFinder.
   Global Const NO_SEARCH_DATA = -10   No data was found to lookup/search
Account Number Return Flag Constants
   Global Const UK_ACCOUNT = 1 Specifies that the account number validated resides at a branch on the UK (BACS) clearing system.
  Global Const IRISH_ACCOUNT = 2 Specifies that the account number validated resides at a branch on the Irish (IPSO) clearing system.
   Global Const DUAL_ACCOUNT=3 Specifies that the account number validated resides at a branch on both the UK (BACS) and the Irish (IPSO) clearing system.  The account could therefore accept transactions on one or both of these clearing systems and you will probably want to verify which should be used with the customer.
Account Number Validation Constants
   Global Const SUCCESS = 0   Successful Verification of Account Number
  Global Const VALIDATION_NOT_AVAILABLE = 1 No Validatation is available for  Account Numbers on the supplied Sort Code (so as validation has not failed it is valid for submission to BACS)
   Global Const NOT_FOUND = -2 Sort Code Not Found
  Global Const INVALID_SORT_CODE = -13 Invalid Sort Code Passed
  Global Const INVALID_ACCOUNT_NUMBER = -14 Invalid Account Number Passed
Debit / Credit Card Validation Constants
  Global Const MASTERCARD = 1 Successfully validated Mastercard Details
  Global Const VISA = 2 Successfully validated Visa Details
  Global Const AMERICAN_EXPRESS = 3 Successfully validated American Express Details
  Global Const SWITCH = 4 Successfully validated Switch Details
  Global Const VISA_DELTA = 5 Successfully validated Visa Delta Details
  Global Const VISA_UK_ELECTRON = 6 Successfully validated Visa UK Electron Details
  Global Const VISA_PURCHASING = 7 Successfully validated Visa Purchasing Details
  Global Const SWITCH_AND_MAESTRO = 8 Successfully validated Switch and Maestro (combined) Details
  Global Const MAESTRO = 9 Successfully validated Maestro Details
  Global Const SOLO_AND_MAESTRO = 10 Successfully validated Solo and Maestro (combined) Details
  Global Const JCB = 11 Successfully validated JCB Details
  Global Const INVALID_EXPIRY = -15 Invalid Expiry Date Passed
  Global Const CARD_EXPIRED = -16 Debit/Credit Card has Expired
  Global Const INVALID_CARD_NUMBER = -18 An Invalid Card Number was passed
  Global Const VISA_ATM_ONLY  = -19 Validated VISA Card valid for ATM machine use only
  Global Const UNRECOGNISED_CARD = -20 Number validated but Card Type unrecognised

BankFinder Functions

There are Unicode and ASCII forms of each of the Pocket BankFinder functions, the Unicode forms are generally easier to work with in the CE environment.  The Unicode versions have the prefix 'w'.  The String type used in the data structures in each of these examples is assumed to be an array of TChars (2 bytes per character) if the Unicode function is used, or an array of Chars (1 byte per character) if the ASCII version is used.  Where Strings to not form part of the parameters supplied or returned by the function the Unicode version of the function is identical to the ASCII form.

BankGetFirst

Used to initiate a BankFinder Lookup or Search and to return the first matching bank record.

Unicode Declaration
Declare Function BankGetFirst Lib "afdbank.dll" alias "wBankGetFirst" _
(details As SearchRecType, flags As Long) As Long

ASCII Declaration
Declare Function BankGetFirst Lib "afdbank.dll" _
(details As SearchRecType, flags As Long) As Long

BankGetNext

Used to call of subsequent records from a BankFinder Lookup or Search, returns END_OF_SEARCH (-6) when you attempt to call off another record after all records have been returned.

Unicode Declaration
Declare Function BankGetNext Lib "afdbank.dll" alias "wBankGetNext" () As Long

ASCII Declaration
Declare Function BankGetNext Lib "afdbank.dll" () As Long

Usage

To carry out a bank lookup or search:

Example:

Dim SearchData As SearchRec
Dim flags As Long
' Set Lookup Data
SearchData.Lookup = "517032"
' Set Flags to indicate the systems you require data from (0 - Both, 1 - BACS only, 2 - IPSO Only)
flags = 0
' Call Get First to get the first record
retVal = GetFirst(SearchData)
' If success process and call of subsequent records 
Do While RetVal >= 0 Then
   ' If RetVal <> 5 (Record_Break) Call GetBankRecord, GetBACSRecord, GetCHAPSRecord and/or GetCCCCRecord to get the data you require
   RetVal = GetNext
   ' Allow user to cancel if desired
Loop

BankGetFirst Return Type

Returns 0 if success:

Returns <0 if fails:

BankGetNext Return Type

Returns 0 if success:

Returns <0 if fails:

GetBankRecord, GetBACSRecord, GetCHAPSRecord, GetCCCCRecord

Used to get the data type/structures containing the data for a bank record matched by a call to BankGetFirst or BankGetNext.  Note that while the other functions will not fail for IPSO records, only the GetBankRecord function returns useful data for IPSO records as the others provide data specific to the UK clearing systems.  The CountryIndicator parameter of the BankRecType structure returned from the GetBankRecord function can easily be examined to determine the clearing system the record is for if you are searching on both - it will contain "I" for IPSO records and "U" for BACS records.

Unicode Declarations
Declare Function GetBankRecord Lib "afdbank.dll" alias "wGetBankRecord" _
(bankRecord As BankRecType) As Long
Declare Function GetBACSRecord Lib "afdbank.dll" alias "wGetBankRecord" _
(bacsRecord As BACSRecType) As Long
Declare Function GetCHAPSRecord Lib "afdbank.dll" alias "wGetBankRecord" _
(chapsRecord As CHAPSRecType) As Long
Declare Function GetCCCCRecord Lib "afdbank.dll" alias "wGetBankRecord" _
(ccccRecord As CCCCRecType) As Long

ASCII Declarations
Declare Function GetBankRecord Lib "afdbank.dll" _
(bankRecord As BankRecType) As Long
Declare Function GetBACSRecord Lib "afdbank.dll" _
(bacsRecord As BACSRecType) As Long
Declare Function GetCHAPSRecord Lib "afdbank.dll" _
(chapsRecord As CHAPSRecType) As Long
Declare Function GetCCCCRecord Lib "afdbank.dll" _
(ccccRecord As CCCCRecType) As Long

Example:

Dim searchData As SearchRec
Dim bankData As BankRec
Dim BACSData As BACSRec
Dim CHAPSData As CHAPSRec
Dim CCCCData As CCCCRec
' Set Lookup Data
SearchRec.Lookup = "517032"
' Set Flags to indicate the systems you require data from (0 - Both, 1 - BACS only, 2 - IPSO Only)
flags = 0
' Call BankGetFirst to get the first record
retVal = BankGetFirst(SearchRec, flags)
' If success process and call of subsequent records 
Do While RetVal >= 0 Then
   If RetVal <> 5 (Record_Break) Then
      GetBankRecord (bankData)
      GetBACSRecord (BACSData)
      GetCHAPSRecord (CHAPSData)
      GetCCCCRecord (CCCCData)
      ' Process the data
   End If
   ' Allow user to cancel if desired
   retVal = BankGetNext
Loop

Return Type

These functions will always return 0 for success.  If no call to GetFirst or GetNext has yet been made a blank data record will be returned.

GetFirstRedirect, GetNextRedirect - Applies to UK (BACS) branches only

These functions are used to get a list of banks that are redirected to a sort code.  When you lookup a bank record if the 'Redirected From' field contains 'R' this means that other sort codes are redirected to this one.  Call GetFirstRedirect with that records sort code and it will return the first sort code that has been redirected to it, then repeatedly call GetNextRedirect until it returns -6 to get the rest of the records.

Unicode Declarations
Declare Function GetFirstRedirect Lib "afdbank.dll" _
(ByVal sortcode As String) As Long
Declare Function GetNextRedirect Lib "afdbank.dll" _
(ByVal sortcode As String) As Long

ASCII Declarations
Declare Function GetFirstRedirect Lib "afdbank.dll" alias "wGetFirstRedirect" _
(ByVal sortcode As String) As Long
Declare Function GetNextRedirect Lib "afdbank.dll" alias "wGetNextRedirect" _
(ByVal sortcode As String) As Long

Example:

Dim sortCode As String * 8
sortCode = "086001"
' Call GetFirstRedirect to get the first record
retVal = GetFirstRedirect(sortCode)
' If success process and call of subsequent records 
Do While RetVal >= 0 Then
   ' Sort Code now contains a sort code that has been redirected to the one originally supplied.
   retVal = GetNextRedirect(sortCode)
Loop

Return Type

GetFirstRedirect Return Type

Returns 0 if success:

Returns <0 if fails:

GetNextRedirect Return Type

Returns 0 if success:

Returns <0 if fails:

JumpToRecord

This function is used to jump back to a record that has previously been accessed.  It is useful if you are listing results and need to recall a record when the user selects it.  Each Bank record has a record number simply pass that to this function, you will be moved to that position from where you can call off the data you then require using the GetBankRecord, GetBACSRecord, GetCHAPSRecord and GetCCCCRecord methods as desired.

Unicode Declaration
Declare Function JumpToRecord Lib "afdbank.dll" _
(ByVal recPos As Long) As Long

ASCII Declaration
Declare Function JumpToRecord Lib "afdbank.dll" alias "wJumpToRecord" _
(ByVal recPos As Long) As Long

Example:

retVal = JumpToRecord (recPos)   ' where recPos contains the record number of the record to jump back to
If retVal >= 0 Then
   ' Successfully Jumped - Use GetBankRecord, GetBACSRecord, GetCHAPSRecord and/or GetCCCCRecord to get data for this bank as desired
Else
  ' Failed - inform user (See below for error codes)
End If

Return Type

Returns 0 if success:

Returns <0 if fails:

ValidateAcc

This function is used to verify that an Account Number is valid and therefore can be used to help eliminate errors in capturing an account number.  The sortcode and accountNo parameters will be updated with the translated numbers for BACS processing if applicable, so you should use the values returned by the function in any subsequent processing. The TypeOfAccountCode parameter is normally zero but for some account translations will be set and is necessary for BACS submission. You may also want to lookup the Sort Code using the GetFirst and GetNext methods to verify the bank details are correct.

Unicode Declaration
Declare Function ValidateAcc Lib "afdbank.dll" alias "wValidateAcc" _
(flags As Long, ByVal sortcode As String, ByVal accountNo As String, typeOfAccountCode As Long) As Long

ASCII Declaration
Declare Function ValidateAcc Lib "afdbank.dll" 
(flags As Long, ByVal sortcode As String, ByVal accountNo As String, typeOfAccountCode As Long) As Long

Flags
The flags parameter serves two purposes.  Prior to calling ValidateAcc you should set this to indicate the clearing systems that you wish to validate accounts for.  This will likely depend on which clearing system or systems you are able or willing to process payments through.  This should be one of the following values:

On successfully validating an account number. the flags parameter passed will be set to show which clearing system the branch is part of:

Example:

Dim retVal As Long
Dim sortCode As String * 8
Dim accountNo As String * 12
Dim typeOfAccountCode As Long
Dim flags As Long
flags = 0
sortCode = "401101"
accountNo = "61893939"
retVal = ValidateAcc (flags, sortCode, accountNo, typeOfAccountCode)
If retVal >= 0 Then
   ' Successfully validated - process it here - sortCode, accountNo, and typeOfAccountCode variables will have been updated with any necessary account translation
   ' flags will also now indicate the clearing system the branch resides on.
Else
  ' Validation failed - inform user (See below for error codes)
End If

Return Type

Returns >=0 if success:

Returns <0 if fails:

ValidateCard

This function is used to verify that a Debit / Credit Card Number and expiry date is valid and to determine what the card type is.  It can be used to help eliminate errors in capturing debit or credit card details.

Unicode Declaration
Declare Function ValidateCard Lib "afdbank.dll" _
(RevisionID As Long, ByVal cardNumber As String, ByVal expiry As String) As Long

ASCII Declaration
Declare Function ValidateCard Lib "afdbank.dll" alias "wValidateCard" _
(RevisionID As Long, ByVal cardNumber As String, ByVal expiry As String) As Long

Example:

Dim retVal As Long
Dim cardNumber As String * 30
Dim expiryDate As String * 5
Dim revisionID As Long
revisionID = 2 ' Set to 2 to indicate current checking methods
cardNumber = "6439401101618939396"
expiryDate = "04/02"    ' Must be in the format MM/YY (set to an empty string if you don't want to check this)
retVal = ValidateCard (revisionID, cardNumber, expiryDate)
If retVal > 0 Then
   ' Successfully validated - check return value for card type and process it here
Else
  ' Validation failed - inform user (See below for error codes)
End If

Return Type

Returns Card Type (>0) if success:

Returns <0 if fails:

Any Questions? Call now on 01624 811711
  Pocket Bankfinder

  Manual Contents

  Appendix