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

www.partner400.com
www.SystemiDeveloper.com

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
Paris
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)

DCL-DS KnownUsersDS QUALIFIED DIM(64);
UserIDs LikeDS(UserIDs_T) Inz;
ChildOf VARCHAR(32) INZ('');
IsArchived IND;
END-DS;

DCL-DS UserIDs_T QUALIFIED Template;
Domain CHAR(16);
UserID VARCHAR(32) INZ('');
END-DS;

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

www.partner400.com
www.SystemiDeveloper.com

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

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
cool.
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:

DCL-DS KnownUsersDS QUALIFIED DIM(64);
Domain CHAR(16);
UserID VARCHAR(32) INZ('');
ChildOf VARCHAR(32) INZ('');
IsArchived IND;
END-DS;

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

DCL-DS UserIDs QUALIFIED DIM(64);
Domain CHAR(16);
UserID VARCHAR(32) INZ('');
END-DS;

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,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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-2022 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.