For alphanumeric (type X) data items, field size is simply the number of characters. For variable length alphanumeric (type V) data items, field size is the number of characters plus two. However, for numeric and date data items, the field size depends on the internal type.
Generally, you do not need to know the internal representation of numeric data items. CA Ideal handles all storage and conversion operations automatically. (See the $STRING and $EDIT functions for details.) However, you might need to know the internal representation of numeric items when using identical parameter matching or to reserve enough space to pass numeric data to a non‑ideal subprogram. You might also need to know the internal format when copying a non‑alphanumeric group into an alphanumeric field or group by a SET or MOVE statement or a REDEFINITION.
For types N, U, and D, the Digits field indicates the number of digits (base‑10) the field can contain. The total number of digits is the sum of the integer places and the decimal (fraction) places.
For example, a digits specification of 7.2 means 7 integer places and 2 decimal (fraction) places, for a total of 9 digits. Thus, for the CA Ideal numeric fields described as follows:
=>
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑‑‑‑‑ IDEAL: PARAMETER DEFINITION PGM DEMO$01 (001) TEST SYS: DEM FILL‑IN COMMAND LEVEL FIELD NAME T I CH/DG OCCUR U M COMMENTS/DEP ON/COPY ‑‑‑‑‑‑ ‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑‑‑‑‑ ‑‑‑‑‑ ====== ===== ====== T O P ====== = = ===== ===== = = ======================= ...... 1 IDEAL‑SIGN‑NUM N 5 U D ...... 1 IDEAL‑UNSIGN‑NU U 5 U D ...... 1 IDEAL‑DATE‑NUM D 5 U D
IDEAL‑SIGN‑NUM can contain any five‑digit number from ‑99,999 to +99,999.
IDEAL‑UNSIGN‑NUM can contain any five‑digit number from 0 to 99,999.
IDEAL‑DATE‑NUM can contain any five‑digit number from ‑99,999 to 99,999 (representing 273 years from the base year).
The CA Ideal internal formats for numeric and date types follow:
Z Zoned decimal
P Packed decimal
B Binary
For full descriptions, see IBM System/370 Principles of Operation.
For all three internal formats, CA Ideal still uses the convention that indicates the number of decimal (base‑10) digits that can be contained in the item. If the digits specification contains any decimal (fraction) places, CA Ideal makes sure that the numeric value is aligned properly (according to the digits specification), but without the implied decimal point. For example, if the digits specification is 3.2 and the value is 123.45 in packed decimal format, the internal value is X'12345C'.
For zoned decimal data items, the number of bytes needed to store the item is exactly the same as the number of decimal (base‑10) digits. The sign is stored in the high‑order four bits of the last byte. Thus, data item ZONED‑4, defined on the following sample panel, requires four bytes of storage.
=>
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑‑‑‑‑ IDEAL: PARAMETER DEFINITION PGM DEMO$01 (001) TEST SYS: DEM FILL‑IN COMMAND LEVEL FIELD NAME T I CH/DG OCCUR U M COMMENTS/DEP ON/COPY ‑‑‑‑‑‑ ‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑‑‑‑‑ ‑‑‑‑‑ ====== ===== ====== T O P ====== = = ===== ===== = = ======================= ...... 1 ZONED‑4 N Z 4 U I :COBOL: S9(4) DISPLAY ...... : ASM: DS ZL4 ...... :Format: |Fd|Fd|Fd|sd| ...... ...... : d=digit (X'0'‑X'9') ...... : s=SIGN (X'A'‑X'F') ...... : F=X'F'
For packed decimal data items, the number of bytes needed to store the item is half the number of decimal (base‑10) digits, except that one half‑byte (the low‑order four bits of the last byte) must be reserved for the sign. Thus, for the data item defined as follows:
=> ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL: PARAMETER DEFINITION PGM DEMO$01 (001) TEST SYS: DEM FILL‑IN COMMAND LEVEL FIELD NAME T I CH/DG OCCUR U M COMMENTS/DEP ON/COPY ‑‑‑‑‑‑ ‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑‑‑‑‑ ‑‑‑‑‑ ====== ===== ====== T O P ====== = = ===== ===== = = ======================= 000100 1 PACKED‑5 N P 5 U I :COBOL: S9(5) COMP‑3 000200 : ASM: DS PL3 000300 :Format: |dd|dd|ds| 000400 000500 1 PACKED‑4 N P 4 U I :COBOL: S9(4) COMP‑3 000600 : ASM: DS PL3 000700 :Format: |0d|dd|ds| 000800 000900 : d=digit (X'0'‑X'9') 001000 : s=SIGN (X'A'‑X'F') 001100 : 0=X'0'
The field named PACKED‑5 requires three bytes for storage (five half‑bytes‑one for each digit, plus one half‑byte for the sign, equals six half‑bytes or three bytes). The field named PACKED‑4 also requires three bytes for storage because: A four‑digit packed numeric field actually can be contained in two and one-half bytes. Since fields are always allocated in whole bytes, this value is rounded up to three bytes. This means that there is an unused half‑byte (the high‑order four bits of the first byte) that could contain a decimal digit. In fact, CA Ideal returns a run-time error if this position ever exceeds zero.
Binary fields present a special problem. CA Ideal supports only two types of binary fields: Half word (two bytes) and full word (four bytes). CA Ideal (like COBOL) still uses the convention that the field size is represented in number of decimal (base‑10) digits. However, since binary numbers are base‑2, there is no simple conversion from number of binary bytes to number of decimal (base‑10) digits.
For example, the largest number that can be contained in a binary half word is 0111111111111111 (base‑2), or 32,767 (base‑10). All four‑digit (base‑10) numbers (up to 9,999) can thus be represented in a binary half word, but not all five‑digit (base‑10) numbers can. Specifically, the five‑digit (base‑10) numbers 32,768 through 99,999 cannot be represented in a binary half word.
Therefore, the algorithm for CA Ideal (and for COBOL) reasons as follows: If you specify four decimal (base‑10) digits, a binary half word is sufficient, so two bytes (not aligned) are allocated. However, if you specify five decimal (base‑10) digits, a half word is not sufficient for all five‑digit (base‑10) numbers, so the next largest size (a full word) is required. Therefore, four bytes (not aligned) are allocated.
Since the smallest machine format binary field size is a half word, two bytes (not aligned) are also allocated for fields specified with decimal (base‑10) digits of 1, 2, and 3. This reasoning leads to the following algorithm: 1 to 4 decimal (base‑10) digits require a binary half word (2 bytes) and 5 to 9 decimal (base‑10) digits require a binary full word (4 bytes). Thus, the data item definition follows:
=>
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL: PARAMETER DEFINITION PGM DEMO$01 (001) TEST SYS: DEM FILL‑IN COMMAND LEVEL FIELD NAME T I CH/DG OCCUR U M COMMENTS/DEP ON/COPY ‑‑‑‑‑‑ ‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑‑‑‑‑ ‑‑‑‑‑ ‑ ‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ====== ===== ====== T O P ====== = = ===== ===== = = ======================= 000100 1 BINARY_1 N B 1 U I :COBOL: S9(1) COMP 000200 : ASM: DS XL2 000300 000500 1 BINARY_4 N B 4 U I :COBOL: S9(4) COMP 000600 : ASM: DS XL2 000800 000900 1 BINARY_5 N B 5 U I :COBOL: S9(5) COMP 001000 : ASM DS XL4 001100 ...... 1 BINARY_9 N B 9 U I :COBOL: S9(9) COMP ...... : ASM DS XL4
The fields named BINARY_1 and BINARY_4 each are allocated two bytes (not aligned) and the fields named BINARY_5 and BINARY_9 each are allocated four bytes (not aligned).
To be flexible with other language conventions, CA Ideal does not align binary operands in data item definitions.
CA Ideal does not support binary numbers larger than nine decimal (base‑10) digits. If it is necessary to pass a larger number to a non‑ideal subprogram, it must be passed as a zoned decimal or packed decimal field.
CA Ideal does not support binary fields other than half word (two bytes) and full word (four bytes). If such a non‑standard binary field is contained in a dataview created for a CA Datacom/DB table, CA Ideal flags the field with a warning message and treats the field as alphanumeric. This warning message allows the program to run and compile. If it is necessary to pass a binary dataview field other than two or four bytes, the field must be passed as an alphanumeric field and handled appropriately by the subprogram.
Equivalent specifications for the CA Ideal digits column (number of decimal or base‑10 digits) and number of bytes of storage for each internal type are summarized in the following table.
|
|
DG Column in CA Ideal (Number of Decimal or Base‑10 Digits) |
|
|
Zoned decimal |
n |
n |
|
Packed decimal |
n |
(n+1)/2 (round .5 up to next whole integer) |
|
Binary |
1‑4 5‑9 |
2 bytes (not aligned) 4 bytes (not aligned) |
At run time, unlike COBOL, CA Ideal enforces the limit on the number of decimal digits specified in the DG column, regardless of the number of bytes of storage.
Panel fields are zoned.
To calculate the internal storage required for nullable fields, add two to the number of digits.
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|