Page 1 of 1

IBAN - International Bank Account Number - SWIFT

Posted: Mon Jan 28, 2013 6:49 am
by Otto
Hier ein Link, wie man IBAN - International Bank Account Number - SWIFT berechnet.
mfg
Otto

http://www.xbaseforum.de/viewtopic.php?f=6&t=6863

Re: IBAN - International Bank Account Number - SWIFT

Posted: Mon Jan 28, 2013 7:53 am
by StefanHaupt
und eine Function, die IBAN zu überprüfen

Code: Select all

FUNCTION CheckIBAN (cIBAN)
  LOCAL cCountryID := SubStr (cIBAN,1,2)
  LOCAL cCheck := SubStr (cIban,5,Len(cIban)) +;
                  SubStr (CreateCountryID (cCountryID),1,4)+;
                  Substr (cIBAN,3,2)
  LOCAL nCheck, nID

  nID := ( _CalcModulo (cCheck))
  nCheck := Int (nId % 97)
//? cCheck, nID, nCheck
RETURN (nCheck == 1)

//-------------------------------------------------------------//
STATIC FUNCTION CreateCountryID (cCountry)

  LOCAL cLatin := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  LOCAL nID  := At (Substr(cCountry,1,1),cLatin)+9
  LOCAL nID2 := At (Substr(cCountry,2,1),cLatin)+9
RETURN (Str (nID,2,0)+Str(nID2,2,0)+"00")

//---------------------------------------------------------------------//
STATIC FUNCTION _CalcModulo (cControlNr)

  LOCAL nMod //:= Int (Val (cControlNr)) % 97
  LOCAL nNr, cNr //:= 98 - nMod, nVal :=  Val (cControlNr)
  LOCAL cMod := "", i, cID

  FOR i := 1 TO Len (cControlNr) STEP 8
    cNr := cMod+Substr (cControlNr,i,8)
    nNr := Val (cNr) % 97
    cMod := Str (nNr, Lennum (nNr),0)
  NEXT
  nMod := Int (Val (cMod))

RETURN (nMod)