Rory,
    The RCVM0100 DS in my question was defined with all those overlays
   because... well because that was how the original example was coded. I
   agree that it is easier to read without them, but while I'm experimenting
   with these new (for me anyway) techniques I didn't want my test program
   lurching off into the ditch because of some error I introduced
   unwittingly.
    Likewise with the 'template' technique. In a recent article about
   something else, Bob Cozzi used the technique wherein certain well-used
   data structures were defined as templates in an /include member. Each
   calling procedure then declares its own working-storage with a "myWhatever
   DS   LikeDS(Whatever_T)  Inz(*LIKEDS)". The thought of being able to
   identify commonly-used DSs with the prefix 'my' somehow appeals to me, and
   thought I'd first experiment with a 'real' DS, then switch to a 'dummy' DS
   once I felt more comfortable.
   Many thanks, JK
   On Tue Jun 26 15:33 , 'Rory Hewitt' sent:
     John,
     A couple of things:
     First, why are you defining the subfields as being overlays of another
     subfield? Why not simply define them as e.g.:
     D RCVM0100 DS 65535 Qualified
     D BytesRtn 10I 0
     D BytesAvail 10I 0
     D MsgSeverity 10I 0
     D MsgID 7A
     D MsgType 2A
     D MsgKey 4A
     D 7A
     D CCSIDCvtSts 10I 0
     D RplDtaCCSID 10I 0
     D RplDtaLenRtn 10I 0
     D RplDtaLenAvl 10I 0
     It's a lot simpler and easier to read, I think. There's no reason to use
     overlays (just like there isn't really a reason to name reserved fields
     in
     RPGLE, so I leave them blank). It's all just style, though, since both
     methods work fine.
     Second, if you're going to use a template structure and then refer to
     another LIKEDS structure in your program, then you should base the
     template
     structure on a dummy pointer, otherwise you're simply defining two
     structures (both of which take up memory). In fact, in my example above,
     I
     didn't define a separate based-on-dummy template - I simply use the
     RCVM0100
     structure in my program - it's not (in my opinion) significantly less
     readable to refer to RCVM0100.MsgID than it is to refer to
     MsgInfo.MsgID.
     Again, just a style thing. Although the likes of Bob Cozzi and Scott
     Klement
     would probably chastize me for it, I *very* rarely use template
     structures
     and LIKEDS, unless there are likely to be multiple copies of the same
     structure in the same procedure (or module) which need to be used at the
     same time.
     As far as your actual question goes, I typically define several large
     stand-alone variables and load them, as Charles suggests. However,
     I typically define a fixed-length constant field which refers to the
     offset
     of the variable-length data and use that:
     D RplDta S 3000A Inz
     D RCVM0100DataOS C Const(49)
     RplDta = %subst( RCVM0100 : RCVM0100DataOS : RplDtaLenRtn );
     or maybe if I'm being lazy, I just use:
     RplDta = %subst( RCVM0100 : 49 : RplDtaLenRtn );
     Yes, I know it's 'bad' to use hard-coded 'magic' numbers, but since
     IBM's
     not going to change the layout of any existing API formats (they'll just
     create new ones), they're pretty much cast in stone.
     HTH,
     Rory
   ---- Msg sent via Internet America Webmail -
   
http://www.internetamerica.com/
As an Amazon Associate we earn from qualifying purchases.