Initially it will be called by an outside web service request, and defined
via a java bean using WDSC, based on the RPG's PCML. The web service is
running on Websphere on the iSeries.

Now that may change (the way we call it) in the future, but initially that's
the goal.

The users who will call it via their application (I believe they are using
an Acrobat form I believe, that (I think) was created using Adobe Flex) and
they are getting tired of getting back empty array records because they
don't want to have to process them, so they asked if I could return only the
number of elements that are being processed.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Scott Klement
Sent: Thursday, July 30, 2009 4:47 PM
To: RPG programming on the IBM i / System i
Subject: Re: Varying RPG Array Size - Is this even possible?

Hi Shannon,

Can you please explain how this RPG routine is called? How is it
expected to return data to the caller?

For example, if it's called as a stored procedure, it can choose how
many array elements are returned as a parameter on the "set result sets"
SQL command.

If it's called as a UDTF, then you may have 100 elements defined in the
RPG array, but you might stop after returning the 3 that are needed, and
simply send back state 02000.

If it's connected via a pipe, or socket, or data queue, then it's just a
matter of only returning the data you need via those interfaces instead
of returning the whole array.

If this is a web service call, then it depends on the tooling... but IWS
has a parameter for the number of entries to return. With POX or REST,
you'd just only write out the entries you're using into the XML or JSON
response you create.

I could continue listing possible ways to call an RPG, and how to
accomplish it...

...but in all of these situations, it's a matter of defining the RPG
array at it's maximum size, and then having a counter that keeps track
of how many array entries you're actually using. That way you don't
have to return the entire array including the blank entries.

The only time that won't work is when you have a call method (such as
the CL CALL PGM() command) that doesn't support variable-length data
like this. So teh limit isn't really in the RPG language, the limit is
in the call mechanism -- which we know nothign about at this point.

Shannon ODonnell wrote:
Is this even possible?

I want to define an array as, say, 100 elements, with 2 fields in it (or
or 4.).

If I only need to fill 3 of those elements, I only want to return an
size of 3 elements to the caller (probably called through a java bean or
possibly through a PHP call, but not necessarily). I DO NOT want to
100 elements, with 3 filled and 97 empty.

Is that even possible with RPG?

I can't for the life of me figure out the array definition syntax if it

Shannon O'Donnell

This thread ...


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

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