× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I don't see this appear anywhere in my example, so you are going to be a
bit more specific what you are asking me about.

On Tue, Dec 21, 2021 at 3:40 PM Alan Campin <alan0307d@xxxxxxxxx> wrote:

VARCHAR(65000:2) with two byte header is 65572 max (Small
Integer-Unsigned).
VarChar(65000:4) is limited by amount of memory allowed in RPG program
around 4 or 5 MB. 4-byte integer. Max value 2 billion something.

Not sure what you are doing with procedure declaration.

dcl-proc Proc1;
dcl-pi *N VarChar(2000) RtnParm;
Parm1 VarChar(65000:4) Const;
Parm2 Int(4) Value;
end-pi;



On Tue, Dec 21, 2021 at 12:08 PM x y <xy6581@xxxxxxxxx> wrote:

MAX_VARCHAR2 is a literal.

Aren't VARCHAR fields limited to 32765 (or something), with the first two
bytes defining the field's length?

What about this? SHouldn't the PI header have the procedure name and
return code only?
dcl-pi *n Varchar(MAX_VARCHAR2) RtnParm;

On Tue, Dec 21, 2021 at 9:23 AM Mark Murphy <jmarkmurphy@xxxxxxxxx>
wrote:

The error is RNX0115. Length of varying length variable is out of
range.

IBM i v7r2

Here is a reproduction of the problem:

**free
ctl-opt DftActGrp(*No) ActGrp(*New)
Option(*NoDebugIo: *SrcStmt: *NoUnref)
Main(SPLITTST);

dcl-c MAX_VARCHAR2 32767;

dcl-proc splittst;
dcl-s matterid Char(25) Inz('LA-Support');
dcl-s clino Varchar(20) Inz('');
dcl-s matno Varchar(20) Inz('');
dcl-s climat Char(20);

split('-': matterid: clino: matno);
climat = left(clino + ' ': 10) + matno;

dsply matterid;
dsply clino;
dsply matno;
dsply climat;

return;
end-proc;

dcl-proc Split;
dcl-pi *n;
arg Varchar(64) const options(*varsize);
string Varchar(MAX_VARCHAR2) const options(*varsize);
part1 Varchar(MAX_VARCHAR2) options(*varsize);
part2 Varchar(MAX_VARCHAR2) options(*varsize);
end-pi;

dcl-s pos Int(5);

pos = %scan(arg: string);
if pos = 0;
part1 = string;
part2 = '';
else;
part1 = Left(string: pos-1);
part2 = Mid(string: pos+%len(arg));
endif;
end-proc;

dcl-proc Left;
dcl-pi *n Varchar(MAX_VARCHAR2) RtnParm;
string Varchar(MAX_VARCHAR2) const options(*varsize);
len Int(5) const;
end-pi;

if len <= 0;
return '';
elseif %len(string) <= len;
return string;
endif;
return %subst(string: 1: len);
end-proc;

dcl-proc Mid;
dcl-pi *n Varchar(MAX_VARCHAR2) RtnParm;
string Varchar(MAX_VARCHAR2) const options(*varsize);
start Int(5) const;
len Int(5) const options(*nopass);
end-pi;

if %len(string) < start;
return '';
elseif %parms() < %parmnum(len);
return %subst(string: start);
elseif len = 0;
return '';
elseif %len(string) < start + len;
return %subst(string: start);
endif;

return %subst(string: start: len);
end-proc;

Everything you need is here. In the real program, the procedures are
in a
service program, and the constant is in a separate header file. But I
have
consolidated it all down into a single program that exhibits the
problem.
The error is:

Additional Message Information



Message ID . . . . . . : RNX0115 Severity . . . . . . . : 50

Message type . . . . . : Diagnostic

Date sent . . . . . . : 12/21/21 Time sent . . . . . . :
12:07:21


Message . . . . : Length of varying length variable is out of range.

Cause . . . . . : The length of a varying length character or DBCS
variable
is less than 0 or greater than its declared maximum length in RPG
procedure
SPLITTST in program JMMLIB/SPLITTST.

Recovery . . . : Contact the person responsible for program
maintenance
to
determine the cause of the problem.














Bottom
Press Enter to continue.



F3=Exit F6=Print F9=Display message details

F10=Display messages in job log F12=Cancel F21=Select assistance
level




The variables contain:

Evaluate Expression



Previous debug expressions



> EVAL matterid:x

00000 D3C160E2 A4979796 99A34040 40404040 - LA-Support

00010 40404040 40404040 40...... ........ -
.......

> EVAL clino:x

00000 0002D3C1 00000000 00000000 00000000 -
..LA............

00010 00000000 0000.... ........ ........ -
................

> EVAL matno:x

00000 0016E2A4 97979699 A3404040 40404040 - ..Support

00010 40404040 4040.... ........ ........ -
..........












Bottom
Debug . . .



F3=Exit F9=Retrieve F12=Cancel F16=Repeat find F19=Left
F20=Right
F21=Command entry F23=Display output




I don't see anything wrong with this.
But it gets better, change the value in matterid to '12345-001' and the
program runs fine!!

Here is that output:

Display Program Messages



Job 195579/MMURPHY/QPADEV0002 started on 12/21/21 at 12:06:21 in
subsystem
Q
DSPLY 12345-001

DSPLY 12345

DSPLY 001

























Press Enter to continue.







F3=Exit F12=Cancel
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.