Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to convert to IBAN

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!

Before I'm going to spend time to write a routine for converting european bank-accounts into IBAN notation I'd like to check if this is already in the public domain.

Anyone who could inform me on this?

KR
-Bart

 
Bart,

Surely this is country-specific? The IBAN format is standard, but the format of the constituent branch and account codes must vary by country.

I would guess that the following code would work with UK accounts, but probably not with others:

Code:
LPARAMETERS tcBranch, tcAccount

lcBranch = STRTRAN(tcBranch, "-") && remove dashes from branch

lcCountry = <your 4-char banking country code>
lcBank = <your 4-char bank code>
lcAccount = RIGHT("0" + tcAccount, 8)  
  && add leading zero to a/c no. if necessary

RETURN ;
  lcCountry + " " + lcBank + " " + LEFT(lcBranch, 4) + ;
  " " + RIGHT(lcBranch, 2) + LEFT(lcAccount, 2) + " " +;
  SUBSTR(lcAccount, 3, 4) + " " + RIGHT(lcAccount, 2)

Note that this is just a guess on my part. I just wanted to show the general idea, so please don't rely on the above code.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

Oops. I was testing the above code, and noticed a glitch.

This line:

lcBranch = STRTRAN(tcBranch, "-")

should of course be:

lcBranch = STRTRAN(tcBranch, "-", "")

The code works correctly on my UK bank account, but not on my US account. This confirms what I said about it being country-specific.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Bart,

please try following code, which I figured out some years ago, and I am sure 2day would do differently, but to my opinion it still works

Code:
PARAMETERS pIban2Check
** 1st move first 4 digits to the end
cAcntnmbr2Chck = ALLTRIM(SUBSTR(pIban2Check,5,50))+LEFT(pIban2Check,4)
cAcntInNmbrs = ''
** change all letters into numbers
FOR x = 1 TO LEN(ALLTRIM(cAcntnmbr2Chck))
cAcntInNmbrs = cAcntInNmbrs+TRANSF(IIF(ISALPHA((SUBSTR(cAcntnmbr2Chck,x,1))),;
(ASC(LOWER((SUBSTR(cAcntnmbr2Chck,x,1))))-87),(SUBSTR(cAcntnmbr2Chck,x,1))))
ENDFOR
** Ibannumbers can be > 32 digits FoxPro can't handle these numbers
** so chop into acceptable portions
cMod = TRANSFORM(MOD(VAL(SUBSTR(cAcntInNmbrs,1,9)),97))
FOR T = 10 TO 24 STEP 7
cMod = TRANSFORM(MOD(VAL(cMod+SUBSTR(cAcntInNmbrs,T,7)),97))
ENDFOR
nResult = VAL(cMod)
* nResult = 1 = passed Iban test
Regards,

Jockey(2)
 
Hi !
Thanks,
I'm going to give it a try.
I was triggered because today formaly the IBAN will be in charge.

KR
-Bart
 
Bart,
Take care, I have given you the code to valid-check if a given bankaccount number is a valid IBAN number. I have not given you the code to construct an IBAN. This could be done easy enough as well but is also highly UNrecommended. It could lead to wrong solutions. Customers should never construct tehmselves an IBAN number, this should always be colected from there bank.
In case you publish an 'IBAN-maker' you are facing troubles with the European Banking Athority.
Groetjes,
Jockey(2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top