× 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 would personally always use a count - but I don't think that is your issue per-se.

What I suspect will fix things is to add the Inz keyword to the DS or at least to the VarChar. As it is unused fields will have an invalid length because spaces are in the length position.

P.S. Why not use Template? Or for that matter simply nest your structures directly so so no template is needed?

e.g.
dcl-ds someOuterDs;
count_ValidationFields int(5);
dcl-ds ValidationFields Dim(20) Inz;
... //stuff
end-ds;
end-ds;



On Sep 21, 2019, at 8:32 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:

I have the following data structure;

dcl-ds ValidationFields qualified;
value varchar(50);
title varchar(50);
id varchar(10);
end-ds;

dcl-ds fields likeds(ValidationFields) dim(20);

This is just a snippet of a very large set of data structures used to
process json

If I do a data-into and the data contains for example 2 values for fields
if I try and access the 3rd element I get an error;

MSG(RNX0115) Length of varying length field variable is out of range.

ok that is correct as the length of that field would be zero.

I could code a count ...

count_fields int(10);
dcl-ds fields likeds(ValidationFields) dim(20);

Which would be set to 2 and then use that to control what array elements I
access. (While this is the best option I would like to understand the
following)

I thought I could check the length like

if %len(fields(x).id) > 0;

But this also fails with the same error which I am not yet understanding
why ?

In debug if I display fields I see all 20 occurrences of the three fields.


Do/should I initialise the data structure ? and if I do that what length
would be assigned to the varchar fields or do I need to set a minimum
length in that case ?

I am sure there is a document that explains this but so far this morning I
have not found it.

Assistance appreciated.

Thanks


Don Brown


______________________________________________________________________
This email has been scanned for computer viruses. Although MSD has taken reasonable precautions to ensure no viruses are present in this email, MSD cannot accept responsibility for any loss or damage arising from the use of this email or attachments.
______________________________________________________________________
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx 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 ...

Follow-Ups:
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.