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



Hi Jerry,

What you are doing will work fine BUT... :-)

If you are on V5R1 or later you can rid yourself of the need for pointers -
simply pass the DS as a data structure

Since you are using prototypes, put the definition of the data structure in
a copy member that is included in all programs - just like your prototypes.
This definition should be qualified and based on a "dummy" pointer that is
never set. e.g.

D SIPROTODEF      DS                   Qualified Based(Dummy_Ptr)

D  #End                          1A                   
D  blitm#                                             
D  blsqty                                             
D  bltxcd                                             
D  bllc01                                             
D  bllc02                                             
D  bllc03                                             
D  blcust                                             
D  blref#                                             
D  dlspst                                             
D  dlsp01                                             
D  dlsp02                                             
D  dlsp03             

Your Prototype would be...

D SIU002          PR                  ExtPgm('SIU002')
D  SIUAddr                            LikeDS(SiProtoDef)   

Your Program would be

D SIProto                             LikeDS(SiProtoDef)   
                                
SIU002(SiProto);

The called program would have the same copy members for the definition and
the prototypes and a PI definition of     

D SIU002          PI                                
D  InParms                            LikeDS(SiProtoDef)    

Of course InParms is a qualified data structure so you must qualify the
field names (InParms.blitm#, InParms.blsqty etc.)

HTH

Regards
 
Paul Tuohy
ComCon
www.comconadvisor.com 
 

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Jerry Adams
Sent: 04 October 2006 13:50
To: RPG Midrange
Subject: Passing a data structure as a parm

I have a whole mess of data elements that I need to pass to another 
program so I thought that using a data structure would be more concise 
than something like:  PGM(parm1:parm2:...parm13); . 

I think Bob's book (4th ed.) explained how to do this with prototypes, 
but, since it'll be awhile before I can actually get around to testing 
this, I thought perhaps someone might have suggestions or criticisms 
(both willingly accepted) of how I implemented it.  Code samples are 
below. 

D SIPROTO         DS                                  
D  #End                          1A                   
D  blitm#                                             
D  blsqty                                             
D  bltxcd                                             
D  bllc01                                             
D  bllc02                                             
D  bllc03                                             
D  blcust                                             
D  blref#                                             
D  dlspst                                             
D  dlsp01                                             
D  dlsp02                                             
D  dlsp03                                             
                                                      
D SIU002          PR                  ExtPgm('SIU002')
D  SIUAddr                            Like(SiProto)   

 Later the actual "call":


SIU002(SiProto);

SIU002 (the humble callee) has this as the prototype:

D SIU002          PR                                
D  Parms                              Like(SiProto) 
                                                    
D SIU002          PI                                
D  InParms                            Like(SiProto) 
                                                    
D SiProto         DS                  Based(pSiProto)
D  #End                          1A                 
D  #Item                         5S 0               
D  #Qty                          5P 0               
D  #TaxCode                      5A                 
D  #Local1                       5A                 
D  #Local2                       5A                 
D  #Local3                       5A                 
D  #Cust                         5S 0               
D  #Ref                          6S 0               
D  #StStamps                     5P 0               
D  #Lc1Stamps                    5P 0               
D  #Lc2Stamps                    5P 0               
D  #Lc3Stamps                    5P 0               


Then, as the first step in the program:

pSiProto  = %Addr(inParms);


Am I doing this right? 

Thanks.

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