I need to calculate the IBAN from the bank no. and the account no. I know the algorithm, but one step is the MOD 97 operation of a 24 digit integer no. (here in Germany). I tried to use BigInteger and Decimal but got out of range. So the question would be: how could I calulate 500105170123456789131400 MOD 97? Or in the first place: how to create a variable that holds this BIG integer?
You must develop a MOD function in Navision that accepts strings.You can develop such function, there are several available functions in other languages over the internet. You must convert it to C/AL
For example here there is a function in C#.http://www.tsql.de/csharp/csharp_IBAN_validieren_IBAN_testen_IBAN_code.php
If you don’t want to develop such function convert to this code to a COM component and exposit to Navision.
Other way, it’s a user from forum to paste code off an already developed function.
Here is the C/AL Code for the Modulo function:********************** Start PROCEDURE Modulo@1000000001(sModulus@1000000000 : Code;iTeiler@1000000001 : Integer) : Code; VAR sRest@1000000002 : Code; sErg@1000000003 : Code; iStart@1000000004 : Integer; iEnd@1000000005 : Integer; iResult@1000000006 : Integer; iRestTmp@1000000007 : Integer; iBuffer@1000000008 : Integer; BEGIN iStart := 1; iEnd := 1; WHILE (iEnd <= STRLEN(sModulus)) DO BEGIN EVALUATE(iBuffer, sRest + COPYSTR(sModulus, iStart, iEnd - iStart + 1)); IF (iBuffer >= iTeiler) THEN BEGIN iResult := ROUND(iBuffer / iTeiler, 1, '<'); iRestTmp := iBuffer - (iResult * iTeiler); sRest := FORMAT(iRestTmp); sErg := sErg + FORMAT(iResult); iStart := iEnd + 1; iEnd := iStart; END ELSE BEGIN IF (sErg <> '') THEN sErg := sErg + '0'; iEnd := iEnd + 1; END; END; IF (iStart <= STRLEN(sModulus)) THEN sRest := sRest + COPYSTR(sModulus,iStart); EXIT(sRest); END;********************** End
you just have to make sure that "sModulus" contains only numbers. Otherwise you get errors with the evaluate function.
I have seen a calculation in Navision for the "clé" (checksum) in the french RIB using modulus as well. And as they have long account numbers, there must be the same problem as yours. I should have a FR version somewhere. Will report later.
walter@kirz:(...)you just have to make sure that "sModulus" contains only numbers(...)
(...)you just have to make sure that "sModulus" contains only numbers(...)
Walter,I agree, but this could be part of the program building the to be evaluated number.
I have found this where is necessary to convert the letters to numbers first then call the Modulo:
Then it is works fine.