Previous Topic Next topic Print topic


NEXT Phrase of CONSTANT-NAMES

The NEXT phrase of the constant-name format of a VALUE clause always points to the offset at which the next byte of storage occurs after the previous data declaration. For example, given the following:

 01  x1             pic x(10).
 01  x2 redefines x1    pic x.
     78  next-offset    value next.
 01  x3             pic xx.

the value in next-offset will be the location of the second byte of x1 and not the starting location of x3.

This also can cause confusion with OCCURS clauses. For example, given the following:

 01  group-item.
     05  tabl occurs 10 times.
             78  offset-a   value next.
         10 elem            pic x.
             78  offset-b   value next.
     05  after-tabl     pic x(02).  

offset-a will point to the offset at the start of the first occurrence of elem while offset-b will point to the starting location of the second occurrence of table element elem and not to the starting location of after-tabl. If you wanted to get the starting location of after-tabl, you should recode your source as follows:

 01  group-item.
     05  dummy-item     pic x(10).
          78 offset-c            value next.
     05  tabl redefines dummy-item
               occurs 10 times.
          78 offset-a     value next.
         10 elem            pic x.
             78 offset-b     value next.
     05  after-tabl     pic x (02).

In this example, offset-c will point to the starting offset of after-tabl.

Previous Topic Next topic Print topic