Virtual Item

Virtual items are declared and used much like normal items. Unlike normal items, however, virtual items are not stored on disk. Instead, virtual items exist only in the user work area and are assigned a value each time a record is retrieved from the data set. The value of a virtual item can be constant, or it can be computed from the values of other unmasked items in the record. Programs can assign a new value to a virtual item, but the assignment has no lasting effect because the virtual item is never stored on disk. The following diagram illustrates the syntax for virtual items:

<virtual item>

──┬─<virtual count item>──────┬────────────────────────────────────────┤
  ├─<virtual data item>───────┤
  ├─<virtual group item>──────┤
  └─<virtual population item>─┘

Virtual items can be used to compute a value from the contents of other items in the record. This saves disk space and eliminates the need to duplicate the computation in each program which uses the value.

A virtual item can also be used to replace an item deleted using reorganization. When an existing item is no longer needed, it can be deleted from the data set and replaced by a virtual item in the remap. The virtual item takes the place of the deleted item, prevents the remap record format from changing, and allows existing programs which invoke the remap to run without recompilation.

Virtual items can be declared only in remaps; they are not permitted in data sets.

Virtual items cannot use Record Serial Numbers in their declarations. For example, the following declaration is not allowed because RSN-ITEM is the identifier for an RSN item.

V VIRTUAL NUMBER (8)=2*RSN-ITEM

The following DASDL examples use virtual items.

Example 1

V, N, G, X, and Y are not stored on disk. Instead their values are computed each time a record is retrieved using the remap.

D DATA SET
 (
  A ALPHA(2);
  P REAL;
 );
R REMAPS D
 (
  A;
  V VIRTUAL ALPHA(6) = "      ";
  N VIRTUAL NUMBER(S5,2) = P * .25;
  G VIRTUAL GROUP
   (
    X VIRTUAL FIELD(4) = 15;
    Y BOOLEAN = P GTR 0;
   );
  Z = P;
 );

Example 2

TOTAL-HRS is not stored on disk. Its value is simply computed from REGULAR-HRS and OVERTIME-HRS each time a record is retrieved using the remap.

D DATA SET
 (
  NAME          ALPHA(20);
  OVERTIME-HRS NUMBER(4,1);
  REGULAR-HRS   NUMBER(4,1);
 );
R REMAPS D
 (
  NAME;
  OVERTIME-HRS;
  REGULAR-HRS;
  TOTAL-HRS     VIRTUAL NUMBER(4,1)
                 = REGULAR-HRS + OVERTIME-HRS;
 );

Virtual Count Item

Virtual count items can be used to replace deleted count items. The following diagram illustrates the syntax for virtual count items:

<virtual count item>

── <virtual count item name> VIRTUAL ─┬───────────┬────────────────────►
                                      └─<comment>─┘

►─ COUNT ( <unsigned integer> ) ─┬───────┬─────────────────────────────┤
                                 └─ = 0 ─┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual count item name>

A virtual count item name is an identifier that names the item. The item can be assigned a unique name, or it can assume the name of the deleted count item which it replaced. The virtual count item name cannot exceed 30 characters.

<unsigned integer>

The unsigned integer determines the size of the virtual count item. The item always occupies an integral number of 4-bit digits, and sufficient digits are allocated to contain the binary representation of the unsigned integer.

Virtual count items are always initialized to 0 (zero). The value part serves only as documentation.

Example

The remap counts the virtual count item C. Item C has 10 items that are always initialized to 0 (zero).

D DATA SET
 (
  A ALPHA(3);
  P REAL;
 );
R REMAPS D
 (
  C VIRTUAL COUNT(10) = 0;
  A;
  P;
 );

Virtual Data Item

Virtual data items can consist of any of the following items:

<virtual data item>

──┬─<virtual alpha item>───┬───────────────────────────────────────────┤
  ├─<virtual Boolean item>─┤
  ├─<virtual field item>───┤
  ├─<virtual numeric item>─┤
  └─<virtual real item>────┘

These syntax elements are explained in the following text.

Virtual Alpha Item

Virtual alpha items contain character information. Information is stored in EBCDIC and the item is aligned on an 8-bit boundary. The following diagram illustrates the syntax for a virtual alpha item:

<virtual alpha item>

── <virtual alpha item name> VIRTUAL ─┬───────────┬────────────────────►
                                      └─<comment>─┘

►─ ALPHA ( <item size> ) ─┬───────────────────────────────────┬────────┤
                          ├─ OCCURS <unsigned integer> TIMES ─┤
                          └─ = ─┬─<alpha item name>───────────┤
                                └─<string>────────────────────┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual alpha item name>

A virtual alpha item name is an identifier that names the item. When a virtual item replaces a deleted item, the virtual item can assume the name of the deleted item. The virtual alpha item name cannot exceed 30 characters.

<item size>

Item size is an unsigned integer that specifies the length of the item in characters. A virtual alpha item can be at most 65535 characters in length.

<alpha item name> <string>

The alpha item name or string following the equal sign (=) is used to assign a value to the item.

When a string is specified, the contents of the string are assigned to the item. The string length must not exceed the item length. If the string is shorter than the item, then the string is left-justified and extended with blanks.

<alpha item name> <string> (cont.)

When an alpha item name is specified, the value is left‑justified. If the alpha item and virtual item are not the same length, the value of the alpha item is truncated or extended with trailing blanks as necessary. The alpha item assigned to the virtual item need not be present in the remap; however, it must be declared in the original data set. The alpha item must be referred to by its name in the data set.

Virtual items which specify a value are initialized when a create operation is performed. Therefore, if the virtual item is to have a meaningful initial value, any alpha item it references should also have an appropriate initial value. If the alpha item being referenced has an initial value in both the data set and the remap, then the value specified in the remap is used. Similarly, when a record is stored, the alpha item assigned to the virtual item should contain valid information so that the virtual item has a meaningful value when the record is next retrieved.

When the OCCURS option is specified, neither a string nor an alpha item can be assigned to the virtual item. All occurring items, and those nonoccurring items which do not specify a value, are initialized to all bits on.

OCCURS

The OCCURS option is used to establish an ordered collection of items, all of which have identical attributes. The unsigned integer following the OCCURS keyword controls the number of times the item is repeated. The value of the unsigned integer must not exceed 1023. Whenever the occurring item is referenced, its name must be followed by a subscript enclosed within parentheses. Valid subscripts range from 1 to the value of the unsigned integer.

Example

Record R contains four virtual alpha items: V, W, X, and Y.

D DATA SET
 (
  A ALPHA(4) INITIALVALUE "ABCD";
  P REAL;
 );
R REMAPS D
 (
  C = A;
  V VIRTUAL ALPHA(3) = A;
  W VIRTUAL ALPHA(4) = "JKLM";
  X VIRTUAL ALPHA(5) = "X";
  Y VIRTUAL ALPHA(6) OCCURS 7 TIMES;
 );

Virtual Boolean Item

Virtual Boolean items contain a logical value of either TRUE or FALSE. Each virtual Boolean item occupies one 4-bit digit and is aligned on a 4-bit boundary. Only the low‑order (rightmost) bit of the item contains information. The value TRUE is represented by 1, and the value FALSE by 0.

The following diagram illustrates the syntax for a virtual Boolean item:

<virtual Boolean item>

── <virtual Boolean item name> VIRTUAL ─┬───────────┬─ BOOLEAN ────────►
                                        └─<comment>─┘

►─┬───────────────────────────────────┬────────────────────────────────┤
  ├─ OCCURS <unsigned integer> TIMES ─┤
  └─ = <Boolean expression> ──────────┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual Boolean item name>

A virtual Boolean item name is an identifier that names the item. When a virtual item replaces a deleted item, the virtual item can assume the name of the deleted item. The virtual Boolean item name cannot exceed 30 characters.

<Boolean expression>

The Boolean expression following the equal sign (=) is used to assign a value to the item.

Each time a record is retrieved, the Boolean expression is reevaluated. Items referenced in the Boolean expression need not be present in the remap. However, they must be declared in the original data set. Items must be referred to by their names in the data set.

Virtual items which specify a value are initialized when a create operation is performed. Therefore, if the virtual item is to have a meaningful value, items referenced in the Boolean expression should have appropriate initial values. Similarly, when a record is stored, items appearing in the Boolean expression should contain valid information so that the virtual item has a meaningful value when the record is next retrieved.

When the OCCURS option is specified, a value cannot be specified. All occurring items, and those nonoccurring items which do not specify a value, are initialized to TRUE.

OCCURS

The OCCURS option is used to establish an ordered collection of items, all of which have identical attributes. The unsigned integer following the OCCURS keyword controls the number of times the item is repeated. The value of the unsigned integer must not exceed 1023. Whenever the occurring item is referenced, its name must be followed by a subscript enclosed within parentheses. Valid subscripts range from 1 to the value of the unsigned integer.

Example

Record R contains five virtual Boolean items: V, W, X, Y, and Z.

D DATA SET
 (
  A ALPHA(4);
  B BOOLEAN INITIALVALUE TRUE;
  N NUMBER(3) INITIALVALUE 0;
 );
R REMAPS D
 (
  C = A;
  V VIRTUAL BOOLEAN = TRUE;
  W VIRTUAL BOOLEAN = B;
  X VIRTUAL BOOLEAN = N GEQ 100;
  Y VIRTUAL BOOLEAN = A = "ABCD" OR N = 123 OR NOT B;
  Z VIRTUAL BOOLEAN OCCURS 10 TIMES;
 );

Virtual Field Item

Virtual field items can contain unsigned integer and Boolean values.

When an item size is specified, the field can contain unsigned integer values in binary form. Item size controls the number of bits allocated for the item. Item size must be an unsigned integer between 1 and 48.

When the individual bits within the field are named, each bit can be used to store a logical value of either TRUE or FALSE. The value TRUE is represented by 1 and the value FALSE by 0. This option can be used to minimize storage space when several virtual Boolean values are required. By referencing the virtual field item name, the entire field of Boolean values can be treated as an unsigned integer value.

A virtual field item always occupies an integral number of 4-bit digits. Thus, an item containing one to four bits is allocated one digit, an item containing five to eight bits is allocated two digits, and so on. If the item size is not a multiple of four, the extra bits allocated by the system are inaccessible and will not contain valid information.

The following diagrams illustrate the syntax for virtual field items:

<virtual field item>

── <virtual field item name> VIRTUAL ─┬───────────┬─ FIELD ────────────►
                                      └─<comment>─┘

►─ ( ─┬─<unsigned integer>─────────────────────────────┬─ ) ───────────►
      │ ┌◄───────────────── ; ─────────────────┐       │
      └─┴─/48\─<virtual field bit declaration>─┴─┬─────┤
                                                 └─ ; ─┘

►─┬───────────────────────────────────┬────────────────────────────────┤
  ├─ OCCURS <unsigned integer> TIMES ─┤
  └─ = <arithmetic expression> ───────┘

<virtual field bit declaration>

──<virtual field bit name>─┬───────────┬─┬───────────┬─────────────────►
                           └─ VIRTUAL ─┘ └─<comment>─┘

►─┬──────────────────────────────────────┬─────────────────────────────┤
  └─ BOOLEAN ─┬──────────────────────────┤
              └─ = <Boolean expression> ─┘

The following table explains the elements of the syntax diagrams:

Option

Description

<virtual field item name>

Virtual field item name is an identifier that names the item. The virtual field item name cannot exceed 30 characters.

When a virtual item replaces a deleted item, the virtual item can assume the name of the deleted item.

<virtual field bit name>

Each virtual field bit name is an identifier that names a bit in the field. From 1 to 48 names can appear. If the virtual field item is replacing a deleted item, each bit can assume the name of the bit it replaces. The word VIRTUAL is optional and serves only as a comment. The word BOOLEAN is required when a value is specified for the bit; it is optional otherwise.

<arithmetic expression> <Boolean expression>

The field can be assigned a value in one of two ways. A value can be assigned either to the entire field or to each bit individually.

When a value is specified for the entire field, the value is stored right-justified in the field. DASDL ensures constants are the correct size for the field. If the field contains N bits, the constant must be an unsigned integer with a value between 0 and (2**N)–1. Nonconstant arithmetic expressions are evaluated, converted to integers, and truncated on the left, if necessary. The result is then stored in the field.

Alternatively, if the bits in the field are named, a value can also be assigned to each bit individually. When values are assigned to individual bits, no value can be assigned to the field as a whole, and when a value is assigned to the field as a whole, no values can be assigned to individual bits. The Boolean expression following the equal sign (=) controls the value of the bit.

<arithmetic expression> <Boolean expression> (cont.)

Each time a record is retrieved, the expression is reevaluated. Items which are referenced in the arithmetic expression or Boolean expression need not be present in the remap. However, they must be declared in the original data set. Items in expressions must be referred to using their names in the data set.

When a create operation is performed, virtual items that specify a value are initialized based upon the value of the expression. Therefore, items referenced in expressions should have appropriate initial values, either by default or as a result of an initial value specified in the original data set or the remap. If an item referenced in an expression has an initial value in both the original data set and the remap, then the value specified in the remap is used. When a record is stored, items referenced in expressions should contain valid values so that the computations will be meaningful when the record is next retrieved.

When the OCCURS option is specified, a value cannot be specified for either the individual Boolean values or the field as a whole. All occurring items, and those nonoccurring items which do not specify a value, are initialized to all bits on.

OCCURS

The OCCURS option is used to establish an ordered collection of items, all of which have identical attributes. The unsigned integer following the OCCURS keyword controls the number of times the item is repeated. The value of the unsigned integer must not exceed 1023. Whenever the occurring item is referenced, its name must be followed by a subscript enclosed within parentheses. Valid subscripts range from 1 to the value of the unsigned integer.

The following examples use virtual field items.

Example 1

Record R maps items A and P in data set D. In addition, the remap contains four virtual fields: F, G, H, and I.

D DATA SET
 (
  A ALPHA(4);
  P REAL;
  N NUMBER(3);
 );
R REMAPS D
 (
  A;
  Q = P;
  F VIRTUAL FIELD(8) = 255;
  G VIRTUAL FIELD(10) = P;
  H VIRTUAL FIELD(16) = (P * N);
  I VIRTUAL FIELD(4) OCCURS 10 TIMES;
 );

Example 2

The virtual fields in record R consist of virtual and nonvirtual items.

D DATA SET
 (
  A ALPHA(4);
  B BOOLEAN INITIALVALUE FALSE;
  F FIELD
   (
    F1 BOOLEAN;
    F2 BOOLEAN;
   );
 );
R REMAPS D
 (
  C = A;
  V VIRTUAL FIELD
   (
    V1;
    V2 BOOLEAN = TRUE;
    V3 BOOLEAN = B;
    V4 BOOLEAN = NOT B;
    V5 VIRTUAL BOOLEAN = F1 OR F2;
    V6 VIRTUAL BOOLEAN = A = "ABCD";
   );
  W VIRTUAL FIELD
   (
    W1;
    W2 VIRTUAL;
    W3 VIRTUAL BOOLEAN;
    W4 BOOLEAN;
   ) = 9;
 );

Virtual Numeric Item

Virtual numeric items contain signed or unsigned fractional or integer values. Values are represented in 4-bit packed decimal form. Each decimal digit is converted to its binary equivalent and stored in a 4-bit digit.

Signed items contain a 4-bit packed decimal sign in the leftmost digit. Negative numbers are denoted by the binary value 1101 (hexadecimal D). Any other value in the sign digit indicates the number is positive. Virtual numeric items are aligned on 4-bit digit boundaries.

The following diagram illustrates the syntax for a virtual numeric item:

<virtual numeric item>

── <virtual numeric item name> VIRTUAL ─┬───────────┬─ NUMBER ─────────►
                                        └─<comment>─┘

►─ ( ─┬─────┬─<precision>─┬────────────────────┬─ ) ───────────────────►
      └─ S ─┘             └─ , <scale factor> ─┘

►─┬───────────────────────────────────┬────────────────────────────────┤
  ├─ OCCURS <unsigned integer> TIMES ─┤
  └─ = <arithmetic expression> ───────┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual numeric item name>

A virtual numeric item name is an identifier that names the item. The virtual numeric item name cannot exceed 30 bytes. When a virtual item replaces a deleted item, the virtual item can assume the name of the deleted item.

<precision>, <scale factor>

Precision specifies the total number of numeric digits in the item. Scale factor specifies the number of digits to the right of the decimal point. Precision and scale factor must be unsigned integers. When an S appears before the precision, the item will include a sign. The digit allocated for the sign is not counted in the precision; thus, the sign increases the size of the item by one digit. Maximum precision for unsigned items is 23 and for signed items is 22. The scale factor must not exceed the precision.

<arithmetic expression>

The arithmetic expression following the equal sign (=) is used to assign a value to the item.

Each time a record is retrieved, the arithmetic expression is reevaluated and the result is stored in the item. Items referenced in the arithmetic expression need not be present in the remap; however, they must be present in the original data set. Items must be referred to by their names in the data set.

The DASDL compiler ensures that constants are within the range of values permitted by the precision and scale factor of the item. Nonconstant arithmetic expressions are evaluated and truncated on the left, if necessary. The result is then stored in the item.

When the OCCURS option is specified, a value cannot be specified for the item. All occurring items, and those nonoccurring items which do not specify a value, are initialized to all bits on.

OCCURS

The OCCURS option is used to establish an ordered collection of items, all of which have identical attributes. The unsigned integer following the OCCURS keyword controls the number of times the item is repeated. The value of the unsigned integer must not exceed 1023. Whenever the occurring item is referenced, its name must be followed by a subscript enclosed within parentheses. Valid subscripts range from 1 to the value of the unsigned integer.

Example

The following example uses a virtual numeric item:

D DATA SET
 (
  A ALPHA(4);
  N NUMBER(S6,1);
 );
R REMAPS D
 (
  M = N;
  P VIRTUAL NUMBER(S5,2);
  Q VIRTUAL NUMBER(S3) = -123;
  S VIRTUAL NUMBER(4,1) = N;
  T VIRTUAL NUMBER(6,2) = N * 2;
  U VIRTUAL NUMBER(S7,2) OCCURS 10 TIMES;
 );

Virtual Real Item

Virtual real items contain signed or unsigned fractional or integer values. Values are represented in single precision floating point form. The size of a virtual real item is 1 word (twelve 4-bit digits) regardless of the precision or scale factor. Virtual real items are aligned on 8-bit byte boundaries.

The following diagram illustrates the syntax for a virtual real item:

<virtual real item>

── <virtual real item name> VIRTUAL ─┬───────────┬─ REAL ──────────────►
                                     └─<comment>─┘

►─┬────────────────────────────────────────────────────┬───────────────►
  └─ ( ─┬─────┬─<precision>─┬────────────────────┬─ ) ─┘
        └─ S ─┘             └─ , <scale factor> ─┘

►─┬───────────────────────────────────┬────────────────────────────────┤
  ├─ OCCURS <unsigned integer> TIMES ─┤
  └─ = <arithmetic expression> ───────┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual real item name>

A virtual real item name is an identifier that names the item. The virtual real item name cannot exceed 30 bytes. When a virtual item replaces a deleted item, the virtual item can assume the name of the deleted item.

<precision>, <scale factor>

Precision specifies the total number of numeric digits in the item. Scale factor specifies the number of digits to the right of the decimal point. Precision and scale factor must be unsigned integers. When an S appears before the precision, the item includes a sign. Maximum precision for unsigned items is 12 and for signed items is 11. The scale factor must not exceed the precision.

Precision and scale factor are optional. They only affect the way the item is declared and accessed in host language programs. Precision and scale factor do not affect the space allocated for the item, the form in which numbers are represented, or the range of values which can be stored.

<arithmetic expression>

The arithmetic expression following the equal sign (=) is used to assign a value to the item.

Each time a record is retrieved, the arithmetic expression is reevaluated and the result is stored in the item. Items referenced in the arithmetic expression need not be present in the remap. However, they must be present in the original data set. Items must be referred to by their names in the data set.

The DASDL compiler ensures that constants are within the range of values permitted by the precision and scale factor of the item. Nonconstant arithmetic expressions are evaluated and the result is stored in the item.

When the OCCURS option is specified, a value cannot be specified for the item. All occurring items, and those nonoccurring items which do not specify a value, are initialized to all bits on.

OCCURS

The OCCURS option is used to establish an ordered collection of items, all of which have identical attributes. The unsigned integer following the OCCURS keyword controls the number of times the item is repeated. The value of the unsigned integer must not exceed 1023. Whenever the occurring item is referenced, its name must be followed by a subscript enclosed within parentheses. Valid subscripts range from 1 to the value of the unsigned integer.

Example

The following example illustrates the DASDL syntax for a virtual real item:

D DATA SET
 (
  A ALPHA(4);
  P REAL(S5,2);
  Q REAL;
 );
R REMAPS D
 (
  A;
  S = P;
  V VIRTUAL REAL(S7,2);
  W VIRTUAL REAL(5,2) = 123.45;
  X VIRTUAL REAL(8)   = Q;
  Y VIRTUAL REAL      = Q * Q;
  Z VIRTUAL REAL OCCURS 10 TIMES;
 );

Virtual Group Item

A virtual group item names a collection of related virtual items. Virtual group items contain only virtual data items and virtual group items. All items contained in a virtual group will be virtual items, whether the word VIRTUAL appears when the item is declared.

Virtual group items are aligned on 8-bit byte boundaries.

The following diagram illustrates the syntax for a virtual group item:

<virtual group item>

── <virtual group item name> VIRTUAL ─┬───────────┬─ GROUP ────────────►
                                      └─<comment>─┘
      ┌◄─────────── ; ───────────┐
►─ ( ─┴─┬─<virtual data item>──┬─┴─┬─────┬─ ) ─────────────────────────►
        └─<virtual group item>─┘   └─ ; ─┘

►─┬───────────────────────────────────┬────────────────────────────────┤
  └─ OCCURS <unsigned integer> TIMES ─┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual group item name>

A virtual group item name is an identifier that names the item. The virtual group item name cannot exceed 30 bytes. When a virtual group item replaces a deleted item, the virtual group item can assume the name of the deleted item.

OCCURS

The OCCURS option is used to establish an ordered collection of items, all of which have identical attributes. The unsigned integer following the OCCURS keyword controls the number of times the item is repeated. The value of the unsigned integer must not exceed 1023. Whenever the occurring item is referenced, its name must be followed by a subscript enclosed within parentheses. Valid subscripts range from 1 to the value of the unsigned integer.

Occurring virtual group items can contain virtual data items and virtual group items which themselves include the OCCURS clause. Whenever an item within an occurring group is referenced, its name must be followed by one or more subscripts enclosed within parentheses. The number of subscripts specified must match the number of OCCURS clauses which apply to the item. The first (leftmost) subscript applies to the outermost OCCURS clause, the second subscript applies to the next to outermost OCCURS clause, and so on.

Items declared in an occurring virtual group item must not specify values.

Example

The following example illustrates the DASDL syntax for a virtual group item:

D DATA SET
 (
  A ALPHA(4);
  P REAL;
 );
R REMAPS D
 (
  A;
  V VIRTUAL GROUP
   (
    V1 ALPHA(3) = "   ";
    V2 VIRTUAL NUMBER(S5,2) = +1.2;
    V3 BOOLEAN = A = "XXX";
   );
 );

Virtual Population Item

Virtual population items can be used to replace population items deleted using a DASDL update operation.

The following diagram illustrates the syntax for a virtual population item:

<virtual population item>

── <virtual population item name> VIRTUAL ─┬───────────┬───────────────►
                                           └─<comment>─┘

►─ POPULATION ( <unsigned integer> ) ─┬───────┬────────────────────────┤
                                      └─ = 0 ─┘

The following table explains the elements of the syntax diagram:

Option

Description

<virtual population item name>

A virtual population item name is an identifier that names the item. The virtual population item name cannot exceed 30 bytes. When a virtual population item replaces a deleted item, the virtual population item can assume the name of the deleted item.

<unsigned integer>

The unsigned integer specifies the size of the virtual population item. The item always occupies an integral number of 4-bit digits, and sufficient digits are allocated to contain the binary representation of the unsigned integer.

Virtual population items are always initialized to 0 (zero). The value part serves only as documentation.

Example

The following example illustrates the DASDL syntax for a virtual population item:

D DATA SET
 (
  A ALPHA(4);
 );
R REMAPS D
 (
  A;
  P VIRTUAL POPULATION(100) = 0;
 );