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 |
---|---|
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. |
|
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 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:
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:
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:
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:
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 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. |
|
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. |
|
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:
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:
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; );