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



You could have achieved the same thing with Inz(*LIkeDS) alongside the LikeDS keyword. This has the benefit of copying any and all initializations from the cloned DS.


On 2014-05-05, at 4:56 PM, "Koester, Michael" <mkoester@xxxxxxxxxxxxx> wrote:

Thanks Buck. That seems to have fixed it!
I applied the same fix to my "real thing" module, and it appears to be behaving as well.
Many thanks to Bob, Chuck, and Stuart as well.
-- Michael

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Buck
Calabro
Sent: Monday, May 05, 2014 4:37 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Varying length subfield contains blanks instead of length
0 ?

On 5/5/2014 4:22 PM, Koester, Michael wrote:
Here's the offending code in all its [stripped-down] glory.

h option(*srcstmt : *nounref : *nodebugio )
h dftactgrp(*no) actgrp(*new)

D results s 32767A varying

d ParmsIn ds qualified
d keysAndValues...
d likeds(Pairs) dim(32)

d Pairs ds qualified inz
d Key 32a varying
d Value 32a varying

D*--------------------------------------------------
D* Procedure name: AddUser
D*------------- ------------------------------------
D AddUser...
D pr 512a VARYING
d KVPairs likeds(pairs) dim(20)

*==================================================
* ********* Main logic ***********
*==================================================
* Program Prototype (*Entry parms)
d TEST_1 PR

d TEST_1 PI
/free
ParmsIn.keysAndValues(1).key = 'LastName';
ParmsIn.keysAndValues(2).key = 'Company';

results = AddUser(ParmsIn.keysAndValues);
*inlr = *on;
/end-free

* End Mainline Logic

_____ * Private subprocedures
D*--------------------------------------------------
D* Procedure name: AddUser
D* Purpose: Construct & return the XML string for
add_user method.
D*------------- ------------------------------------
P AddUser...
P B
D AddUser...
D pi 512a VARYING
d KVPairs likeds(pairs) dim(20)

* Local fields
d String s 512a varying inz
d x s 3u 0 inz

/free
KVPairs(1).value = 'Moose';
KVPairs(2).value = 'Null & Void, Inc.';

for x = 1 to 32;
select;
when KVPairs(x).key = *blanks; // this is where it
breaks
LEAVE;
when KVPairs(x).key = 'LastName';
String = KVPairs(x).value;

when KVPairs(x).key = 'Company';
String += ' of ';
String += KVPairs(x).value;
endsl;

endfor;

Return string;
/end-free

P AddUser...
P E

Right, so you're passing the data structure ParmsIn and it is not
initialised. Put an INZ on that and see how it works. INZ on the
'likeds' doesn't inherit up to the 'liking' DS.
--buck

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


Jon Paris

www.partner400.com
www.SystemiDeveloper.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.