Alignment Rules

The DASDL compiler ensures that items are aligned on word, byte, or digit boundaries as necessary. The following alignment rules are used for word, byte, and digit boundaries:

Boundary Type

Alignment Order

Word

  1. Fixed part of record

  2. Variable part of record

  3. First link item, data set, set, or subset contained in the fixed part

  4. First link item in the variable part

Byte

  1. Alpha items

  2. Group items

  3. Real items

  4. First data item in record, that is, the first item that is not a control item

  5. Filler items, which are initialized to all bits on

Digit

  1. Boolean items

  2. Numeric items

  3. Field items

  4. Link items

  5. Data sets, sets, and subsets

  6. Population items

  7. Count items

  8. Record type items

  9. System-created Boolean values, which indicate whether STORED OPTIONALLY items are present on disk

Some items are padded with extra bits or digits. The following rules govern padding:

  • Boolean items occupy a single 4-bit digit. Only the low order (rightmost) bit of the field is significant.

  • Field items always occupy an integral number of 4-bit digits. They are padded with trailing bits if necessary.

  • Field items always occupy an integral number of 4-bit digits. They are padded with leading bits if necessary.

Example 1

The following figure illustrates the record layout for the D data set in the following DASDL declaration:

D DATA SET
 (
  N  NUMBER(3) REQUIRED;
  F  FIELD(1);
  RT RECORD TYPE(17);
  LC IS IN E COUNTED;
  M  NUMBER(7);
  R  REAL;
 ),
  1: (
     LC1 IS IN E COUNTED;
     N1  NUMBER(8);
     B1  BOOLEAN;
     A1  ALPHA(2);
     ),
   7: (
      A7  ALPHA(3);
      LV7 IS IN E VERIFY ON N;
      LN7 IS IN E WITH NO PROTECTION;
      );
E DATA SET
  (
   N NUMBER(4);
   C COUNT(2);
  );

Figure 21. Record Layout of Data Set D (Part 1)

Record Layout of Data Set D (Part 1)


Example 2

The following figure illustrates the record layout of the D data set described in the following DASDL description:

D DATA SET
 (
  N1 NUMBER(3) REQUIRED;
  G  GROUP
  (
   G1 NUMBER(3);
   G2 ALPHA(1);
   G3 NUMBER(3);
  );
  L1 IS IN F VERIFY ON F1;
  N2 NUMBER(11);
  S1 SET OF E KEY EA;
  E  UNORDERED DATA SET
   (
    EA  ALPHA(2);
   );
  S2 SET OF E KEY EA DESCENDING;
  L2 IS IN F VERIFY ON F2;
  P  POPULATION(100) OF E;
  C  COUNT(4);
  N3 NUMBER(8);
 );
F DATA SET
 (
  F1 ALPHA(3);
  F2 NUMBER(5);
 );

Figure 22. Record Layout of Data Set D (Part 2)

Record Layout of Data Set D (Part 2)


The actual offsets of every item in the record can be found by setting the DASDL compiler control options TEST and STORE. To understand the results produced, it is necessary to understand the difference between records as they are stored on disk and records as they appear in the record area. The following items are present on disk but are not present in the record area:

  • Link items

  • Data sets, sets, and subsets

  • System-created Boolean values which indicate whether STORED OPTIONALLY items are present on disk

  • System-created length fields which indicate the length of SIZE VARYING alpha items

The actual record layout on disk for a compact data set cannot follow the preceding rules because every record is compacted before being written to disk. Once the record is read back in memory and moved to the user work area, the layout follows the stated rules.

The compiler control options TEST and STORE give the offsets in the record area for all items, except those listed previously. The locations given for the items listed previously are their locations in the record on disk.

Example 3

The following figure illustrates the record layout of data set D described in the following DASDL description:

D DATA SET
 (
  N NUMBER(3) REQUIRED;
  F  FIELD(1);
  RT RECORD TYPE(17);
  L  IS IN E COUNTED;
 ),
1: (
   L1 IS IN E COUNTED;
   N1 NUMBER(8);
   B1 BOOLEAN;
  );
STORE PRINTOUT
E DATA SET
  (
  N NUMBER(4);
  C COUNT(2);
      );          
  (RECORD TYPE) ITEM NAME  OFFSET(WORD,DIGIT)  SIZE(DIGITS)
                 N            2 = ( 0, 2)          3
                 F            5 = ( 0, 5)          1
                 RT           0 = ( 0, 0)          2
                 L           12 = ( 1, 0)         12
          1      L1          36 = ( 3, 0)         12
          1      N1           6 = ( 0, 6)          8
          1      B1          14 = ( 1, 2)          1
 

Figure 23. Record Layout of Data Set D (Part 3)

Record Layout of Data Set D (Part 3)