Is varchar() needed?  Won't data-into drop trailing blanks for you?  In other words, since the data structures are work areas, fussing over a few bytes of trailing blanks is moot.


On 9/21/2019 7:32 PM, Don Brown 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.
______________________________________________________________________

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.