Once again, I'm trying to learn coding in RPGLE. This time, I'm trying to take a street address from a physical file that is in all capitals and having only the first letter capitalized with the rest being lowercase. I'm using the %SCAN, %SUBST, and %XLATE to do this. I am able to get my city names to display correctly but I can't seem to figure out how to walk the string to get my street address to display correctly. Right now, it's just adding the beginning of the street address to the end. It compiles correctly but I'm also getting a "Length or position out of range" error. My code is as follows:
Any help for this RPG IV newbie is greatly appreciated!!
Code:
SAMPLE OUTPUT
BEEBE Dennis
4401 Milham rd. Milh
Kalamazoo MI 49045
ARMINE Yvonne
3300 Mckinley Mckinl
St. Joseph MI 49003
The code:
Address = %TRIM(STREET);
Adrscan = %SCAN(' ':Address);
IF Adrscan > 1;
Adrnumb = %SUBST(Address:1:Adrscan- 1);
Adrscnd = %SUBST(Address:Adrscan+ 1);
Adrscnd= %XLATE(UC:LC:Adrscnd:2);
Adrscan2 = %SCAN(' ':Address:Adrscan+ 2);
IF Adrscan2 > 1;
Adrthrd = %SUBST(Adrscnd:1:Adrscan2 - 1);
Adrfour = %SUBST(Adrscnd:Adrscan2 + 1);
Adrthrd = %XLATE(UC:LC:Adrthrd:2);
Adrfour = %XLATE(UC:LC:Adrfour:2);
ENDIF;
ENDIF;
Address = %TRIM(Adrnumb) + ' ' + %TRIM(Adrscnd) + ' ' +
%TRIM(Adrthrd) + ' ' + %TRIM(Adrfour);
Address = %TRIM(Address);




Comment