|
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
As an Amazon Associate we earn from qualifying purchases.
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.