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



Hello Leif,

According to the MI syntax described in the QPRCRTPG section of the API
manual:
"Data objects declared with DIR may also have an explicit POS value.  The
object is defined on the appropriate space object and uses the specified
POS value.  However, the next byte count is changed only if the POS value
causes the count to increase."
                    ~~~~~~~~~  <= This is the important statement.

The DIR directive simply gets the system to calculate a POS value.  I
wouldn't expect either of your examples to change the next byte counter
the way you expect.  Running them through debug with ZZZ initialized to a
hexadecimal string from 00 to FF shows that:

DCL SPC XXX BAS(.ZZZ);                  <= next byte count starts at 1
   DCL DD AAA BIN(4)  DIR;              <= POS=1, next byte is 5
   DCL DD BBB BIN(4)  DIR;              <= POS=5, next byte is 9

   DCL DD CCC CHAR(100) DIR POS(9);     <= POS=9, next byte is 109
      DCL DD CC1 BIN(2) DIR;            <= POS=109, next byte is 111
      DCL DD CC2 CHAR(8) DIR;           <= POS=111, next byte is 119

   DCL DD DDD CHAR(50) DIR POS(9);      <= POS=9, next byte not changed
      DCL DD DD1 CHAR(10) DIR;          <= POS=119, next byte is 129
      DCL DD DD2 CHAR(10) DIR;          <= POS=129, next byte is 139

and

DCL SPC XXX BAS(.ZZZ);                  <= next byte count starts at 1
   DCL DD AAA BIN(4)  DIR;              <= POS=1, next byte is 5
   DCL DD BBB BIN(4)  DIR;              <= POS=5, next byte is 9

   DCL DD CCC CHAR(100) DEF(XXX) POS(9);<= POS=9, next byte not changed
      DCL DD CC1 BIN(2) DIR;            <= POS=9, next byte is 11
      DCL DD CC2 CHAR(8) DIR;           <= POS=11, next byte is 19

   DCL DD DDD CHAR(50) DEF(XXX) POS(9); <= POS=9, next byte not changed
      DCL DD DD1 CHAR(10) DIR;          <= POS=19, next byte is 29
      DCL DD DD2 CHAR(10) DIR;          <= POS=29, next byte is 39

In the second case CC1 and CC2 are located where you want but only as a
by-product.  DD1 and DD2 are still in the wrong location because you want
them to be at POS 11 and 21 respectively.

I think the only way you can get what you want (without explictly using
DEF and POS) is:

DCL SPC YYY BAS(.ZZZ);
   DCL DD AAA BIN(4)  DIR;
   DCL DD BBB BIN(4)  DIR;
   DCL DD CCC CHAR(256)  DIR;

DCL SPCPTR .WWW ;
DCL SPC WWW BAS(.WWW);
   DCL DD WW1 BIN(2) DIR;
   DCL DD WW2 CHAR(8) DIR;

DCL SPCPTR .XXX ;
DCL SPC XXX BAS(.XXX);
   DCL DD XX1 CHAR(10) DIR;
   DCL DD XX2 CHAR(10) DIR;

SETSPP .WWW, CCC;
SETSPP .XXX, CCC;

Regards,
Simon Coulter.

--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.