I'm writing a program that converts regular bank account numbers to IBAN numbers. Part of this process means I need to convert the letters (in fields like Bank-ID, Branch-ID and ISO-Country-CODE) into the numbers corresponding with their positions in the alphabet + 9. So A=10, B=11, Z=35.
So basically, the following Bank-ID: "LOYD" would become "21243413".
I need to put these numbers in a string later so I make calculations with it.
Now, if the input bank-ID would always be of equal length and always letters, I'd put this among the the rest of my working storage:
LETTERS PIC X(36) VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
And then I'd write this:
INITIALIZE BANK-CODE-NR PERFORM VARYING LOOP-COUNTR FROM 1 BY 1 UNTIL LOOP-COUNTR > 4 INSPECT LETTERS TALLYING BANK-CODE-NR(LOOP-COUNTER) FOR CHARACTERS BEFORE INITIAL BANK-CD IN COPYBOOK(LOOP-COUNTR:1) END-PERFORM
But in this case, the bank ID may be four positions long, or even longer. Plus, I'm working with PIC N fields, which means the INSPECT doesn't work.
EDITED FOR EXTRA INFO
I'm working with a copybook that has nationals in it.It is structured as follows:
01 Input-IBAN. 05 COUNTRY-CODE PIC N(02). 05 BANK-ID PIC N(10). 05 BRANCH-ID PIC N(10). 05 ACCOUNT-NR PIC N(28). 05 Output-IBAN PIC N(34).
It's a called program.