You can do so (as you discovered) but should only do so when the types are compatible.

For instance you could do this to protect the back end of the DS:

%SubStr(BigDS: 1: %Len(SmallDS)) = SmallDS;

Not a good approach when there are much better alternatives as we’ve shown in this thread.

What you forgot was that a DS is treated as a big character field and the same rules apply so:

BigDS = SmallDS;

Will always result in the back end of the BigDS being space filled just as it would have been if you had assigned a 4a to an 8a.

By the way - the resulting code would have blown up anyway because the value of spaces in the first two bytes of each of the space filled varying fields did not constitute a valid length - so “boom” when you try to use it.

Jon Paris

On Jun 24, 2015, at 3:11 PM, Koester, Michael <mkoester@xxxxxxxxxxxxx> wrote:

Thanks Darren and Jon.
I thought things were a bit too easy when I found that I could load a similar (but not same) data structure as a target of the call. Close, but...

I'm not yet familiar enough with the advantages of template DS, but I do use /copy for common definitions.

Thanks again.

Michael Koester

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jon
Sent: Wednesday, June 24, 2015 2:57 PM
To: Rpg400 Rpg400-L
Subject: Re: varying subfield in array DS getting loaded with blanks?

Darren has it right I think.

Personally I would code it like so: (not tested)

UserIDs LikeDS(UserIDs_T) Inz;
ChildOf VARCHAR(32) INZ('');
IsArchived IND;

Domain CHAR(16);
UserID VARCHAR(32) INZ('');

Pass UserIds to the procedure.

Really the template should be in a /Copy then you can also incorporate it
into the called procedure.

Jon Paris

On Jun 24, 2015, at 12:53 PM, Koester, Michael <mkoester@xxxxxxxxxxxxx>

I have an array data structure that has some varchar subfields,
initialized with INZ(''). There is no space between the quotes, which
appears to set the length to 0 for all rows. That's what I want. All's
I then call a procedure that gets some values for two of the four
subfields, and loads three rows with those values. That's cool too. What
isn't so cool is the two fields that should be untouched by the called
procedure get blank-filled, and I don't know why, or how best to prevent
that. I could spin through a for-loop and load the target DS from the
results of the called procedure, but I thought I might not have to.

Calling program defines the target ds as:

Domain CHAR(16);
UserID VARCHAR(32) INZ('');
ChildOf VARCHAR(32) INZ('');
IsArchived IND;

Called Procedure only retrieves values for "Domain" and "UserID", so it
has a ds defined as:

Domain CHAR(16);
UserID VARCHAR(32) INZ('');

The UserIDs data structure is what is passed back to the caller, and
gets stuffed into the 4-subfield array data structure with:

KnownUsersDS = GetUserIDsFromNova(acct : phone : domainsDS);

After the call, all 64 rows of the ChildOf subfield get blanks
(including the length bytes). What I find curious is that the UserID
subfield for the 61 unfilled rows remain empty with length = 0.

We're at v7.1 here.

So have I pushed my luck trying to load only two of four subfields by
making it the receiver of the call? (seeems to work except for trashing
the unused subfields).

Michael Koester

This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

This mailing list archive is Copyright 1997-2022 by 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.