What do you think of the idea to post routines that checks if a given Bank Account No. is correct? Every country has it's own validation rules, so if everyone posts a routine for his/her country, we can build a library of Bank Account checks.
To start with, here are the checks for Belgium and Holland. Both functions returns '' if the bank account is not valid, and returns the (formatted) bank account when valid.
fctCheckBankAccountBE(ptxtBankAccountNo : Text[250]) : Text[250]
local vars:
ltxtAccountNo, Text 250
ldecWorkAccountNo, Decimal
ldecCtrl, Decimal
ltxtAccountNo := DELCHR(ptxtBankAccountNo,'=',DELCHR(ptxtBankAccountNo,'=','0123456789'));
IF STRLEN(ltxtAccountNo) <> 12 THEN
EXIT('');
EVALUATE(ldecWorkAccountNo,COPYSTR(ltxtAccountNo,1,10));
EVALUATE(ldecCtrl,COPYSTR(ltxtAccountNo,11,2));
ldecWorkAccountNo := ldecWorkAccountNo MOD 97;
IF ldecWorkAccountNo = 0 THEN
ldecWorkAccountNo := 97;
IF NOT(ldecWorkAccountNo = ldecCtrl) THEN
EXIT('');
EXIT(COPYSTR(ltxtAccountNo,1,3) + '-' + COPYSTR(ltxtAccountNo,4,7) + '-' + COPYSTR(ltxtAccountNo,11,2));
fctCheckBankAccountNL(ptxtBankAccountNo : Text[250]) : Text[250]
local vars:
i, Integer
lintResult, Integer
lintDigit, Integer
ldecCtrl1, Decimal
ldecCtrl2, Decimal
ltxtBankAccountNo, Text 250
ltxtBankAccountNo := DELCHR(ptxtBankAccountNo,'=',DELCHR(ptxtBankAccountNo,'=','0123456789'));
IF (STRLEN(ltxtBankAccountNo) = 9) OR (STRLEN(ltxtBankAccountNo) = 10) THEN BEGIN
FOR i := 1 TO STRLEN(ltxtBankAccountNo) DO BEGIN
EVALUATE(lintDigit,COPYSTR(ltxtBankAccountNo,i,1));
lintResult := lintResult + (lintDigit * (STRLEN(ltxtBankAccountNo) + 1 - i));
END;
ldecCtrl1 := lintResult DIV 11;
ldecCtrl2 := (lintResult / 11) - ldecCtrl1;
IF ldecCtrl2 = 0 THEN
EXIT(ptxtBankAccountNo)
ELSE
EXIT('');
END;
IF STRLEN(ptxtBankAccountNo) > 10 THEN
EXIT('');
[This message has been edited by Luc Van Dyck (edited 20-07-2001).]
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
0