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 3
or 4.).

If I only need to fill 3 of those elements, I only want to return an array
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 return
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 is.

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