Hello all!
I'm creating a program that allows a user to enter an account number (the account number length varies) and then have the program return a concatenated string of email addresses that are associated with the aforementioned account number. Whenever I CALL FOECADDRPG PARM('38539') and step through my program I run into this error, "Length of varying length variable is out of range", on the first line after /Free (Thanks to JonBoy I know that /Free is no longer required however my higher-ups insist I do it anyway).
I am still playing around with the tools commonly used in RPG Free and, since this is my first time learning a programming language, I probably am not using them correctly (this program is my first time playing around with a "FOR" loop as well as an "ARRAY") so feel free to critique away!
As always, thanks for the help and words of encouragement!
-TJ
I'm creating a program that allows a user to enter an account number (the account number length varies) and then have the program return a concatenated string of email addresses that are associated with the aforementioned account number. Whenever I CALL FOECADDRPG PARM('38539') and step through my program I run into this error, "Length of varying length variable is out of range", on the first line after /Free (Thanks to JonBoy I know that /Free is no longer required however my higher-ups insist I do it anyway).
I am still playing around with the tools commonly used in RPG Free and, since this is my first time learning a programming language, I probably am not using them correctly (this program is my first time playing around with a "FOR" loop as well as an "ARRAY") so feel free to critique away!
PHP Code:
*--------------------------------------------------------------------------------------------*
*--------------------------------------------------------------------------------------------*
*Files
Dcl-F FOECADD DISK(*EXT) keyed Usage(*INPUT);
*--------------------------------------------------------------------------------------------*
*--------------------------------------------------------------------------------------------*
*Standalones
Dcl-S ACCT VARCHAR(20);
Dcl-S X Packed(2);
Dcl-S DSPVAR VARCHAR(50);
Dcl-S KADBKNM LIKE(ADBKNM);
Dcl-s KADKEY1 LIKE(ADKEY1);
*--------------------------------------------------------------------------------------------*
*--------------------------------------------------------------------------------------------*
*Plist
Dcl-Pi FOECADDRPG ExtPgm;
ACCTP VARCHAR(12);
End-Pi;
*--------------------------------------------------------------------------------------------*
*--------------------------------------------------------------------------------------------*
*Data Structures
Dcl-Ds EmailArray;
Array VARCHAR(50) Dim(15);
END-DS;
*--------------------------------------------------------------------------------------------*
*--------------------------------------------------------------------------------------------*
//MAINLINE PROCESSING
/Free
ACCT = '%' + %TRIM(ACCTP) + '%'; <--Length of varying length variable is out o
KADBKNM = *BLANKS;
KADKEY1 = *BLANKS;
EmailArray = *BLANKS;
Array = *Blanks;
EXEC SQL
SELECT ADBKNM,ADKEY1 into :KADBKNM,:KADKEY1
FROM FOECADD
WHERE ADKEY1 like :ACCT;
Dou %Eof(FOECADD);
Chain (KADBKNM:KADKEY1) FOECADD;
IF %found(FOECADD);
For X = 1 to %Elem(Array);
Array(X) = ADEMAD + ' ; ';
ENDFOR;
ENDIF;
ENDDO;
DSPVAR = EmailArray;
Dsply DSPVAR;
*InLR = *On;
/End-Free
-TJ
Comment