Calculate IBAN from Bank No. and Account No.


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#.

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.

thanx for the link. I will try to convert the C# string modulo function to C/AL and keep you updated.

And I hope you will share the function with the community then[:D]

Here is the C/AL Code for the Modulo function:
********************** Start
PROCEDURE Modulo@1000000001(sModulus@1000000000 : Code[30];iTeiler@1000000001 : Integer) : Code[2];
sRest@1000000002 : Code[30];
sErg@1000000003 : Code[30];
iStart@1000000004 : Integer;
iEnd@1000000005 : Integer;
iResult@1000000006 : Integer;
iRestTmp@1000000007 : Integer;
iBuffer@1000000008 : Integer;
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;
IF (sErg <> ‘’) THEN
sErg := sErg + ‘0’;

iEnd := iEnd + 1;

IF (iStart <= STRLEN(sModulus)) THEN
sRest := sRest + COPYSTR(sModulus,iStart);

********************** End

Thanks for sharing this code with this comunity [:)]


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.

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.