I still can't see why we need to do something like this is ILE/RPG. Create the 
list internally and code a procedure to retrieve each record. Just don't see a 
reason to return arrays or multiple occurrence data structures. ILE/RPG gives 
us the tools. IBM has made procedures extremely fast. I don't see any reason 
not to use them. If I am making 10 calls at .00000054 seconds per call, I don't 
see much in the way of overhead. 

The other issue I see is that the caller has to know the internal structure. I 
am really not that comfortable with even returning data structures but creating 
a function to retrieve each value doesn't seem to work very well. I struggle 
with that one.  

Anyway, my opinion again. 

-----Original Message-----
From: Jon Paris [mailto:Jon.Paris@xxxxxxxxxxxxxx]
Sent: Wednesday, July 06, 2005 9:51 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: RE: Multi Occurrence Data Structure returned from a procedure


 >> After reading your reply , would you please give me a example of using
LIKEDS as I may be able to improve on what I have done.

Gladly Paul, but I don't regard it as an improvement.

MODS are a legacy concept and for the most part better off ignored in my
opinion.  I was only using one because I was writing a sample program that
will later be converted to be an SQL stored procedure.  Since DS Arrays are
not handled as return values by SQL until V5R3 (and I am running on a V5R2
system) I had to use a MODS when I would have preferred a DS Array.  Clear
as mud right!

Anyway - for those who want it ....

This is the code in the caller:

     D ReturnDS        PR                  ExtPgm('RETURNDS')
     D  CatCode                       2A
     D  RowCount                      5S 0
     D  OutDS                              LikeDS(ReturnDta)

     D ReturnDta       DS                  Occurs(99)
     D  ProductCode                   7A
     D  TotalCost                    12S 2
     D  TotalValue                   12S 2
     D  TotalMargin                  12S 2

      /FREE

       %Occur(ReturnDta) = 1;           // Ensure first element's address is
passed

       ReturnDS( CATCD : ROWS: ReturnDta);

And this is the bit in the called program:

     D ReturnDta       DS                  Based(pOutDS) Occurs(99)
     D  ProductCode                        Like(ProdCd)
     D  TotalCost                    12S 2
     D  TotalValue                   12S 2
     D  TotalMargin                  12S 2

      /FREE

       pOutDS = %Addr(OutDS);           // Map ReturnDta to the caller's
MODS

Hope this helps.

Jon Paris
Partner400

www.Partner400.com
www.RPGWorld.com






This thread ...


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

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