Decimal positions for physical and logical files (positions 36 and 37)

Use these positions to specify the decimal placement within a packed decimal, zoned decimal, binary, or floating-point field.

If you specify the CONCAT keyword for the field you are defining, you cannot specify decimal positions. A field in the physical file that contains decimal positions cannot be included in a concatenated field.

Note: High-level languages can impose specific length and value restrictions on the decimal positions. Observe these restrictions for files used by those high-level languages.

Use decimal position with physical files

For a physical file, use these positions to specify the decimal placement within a packed decimal, zoned decimal, binary, or floating-point field. Specify a decimal number from 0 through 63 for the number of decimal positions to the right of the decimal point. (The number must not be greater than the number of digits specified in the field length.) The Positional entries for physical and logical files (positions 1 through 44) topic shows how to code the decimal positions field. If the field length is greater than 9 for a binary field, the decimal positions value must be 0.

The data is actually stored in the system without a decimal point. The decimal point is only implied. For example, the value stored for 1.23 is 123. This is what appears in display or printer files if editing is not specified.

To override the position of a referenced field (R in position 29), specify either a new value or a change in position. To increase the position, specify +n, where n is the amount of increase. To decrease the position, specify -n, where n is the amount of decrease. For example, an entry of +4 indicates that there are 4 more digits to the right of the decimal point than were in the referenced field. An error message is sent if the number of decimal positions is greater than the maximum allowed.

Use decimal position with logical files

For logical files, specify decimal positions only to override or change the decimal positions of the corresponding field in the physical file on which this logical file is based. If you leave these positions blank, the field you are defining has the same decimal positions as the corresponding field in the physical file on which this logical file is based.

To override or change the placement of the decimal point within a packed decimal or zoned decimal field, specify a number from 0 through 63 to indicate the number of decimal positions to the right of the decimal point. The number here must not be greater than the number of digits specified in the field length. You cannot override or change decimals when the corresponding field in the physical file is binary (data type B) and contains decimal positions greater than zero. When the logical file field is binary and the corresponding field in the physical file is not binary (B specified in position 35 in the logical file), the decimal positions must be zero for the binary field.

You can override the position of the field by specifying a new value or by specifying an increase or decrease in position. To increase the position, specify +n, where n is the amount of increase. To decrease the position, specify -n, where n is the amount of decrease. For example, an entry of +4 indicates that there are 4 more digits to the right of the decimal point than were in the referenced field.

If you specify a value in positions 36 through 37 and your program writes or retrieves data through the logical file field to the physical file field, the operating system aligns the data on the decimal point. Depending on the case, this can cause the decimal values to be truncated, or it can cause a data conversion error. Decimal values are truncated in the following cases:
  • When reading from a logical file that reduces the number of decimal positions specified in the physical file
  • When writing to a logical file that increases the number of decimal positions specified in the physical file

For example, if the physical file field is defined as 4 digits long with 2 decimal positions, and the logical file field decreases the decimal positions to 0 decimal positions, a value of 0.20 in the physical file becomes a value of 0 in the logical file, and a value of 2.52 in the physical file becomes a value of 2 in the logical file.

When decimal values are truncated, the left side of the field is filled with zeros.

A data conversion error can occur in the following cases:
  • When writing to a logical file that reduces the number of decimal positions specified in the physical file
  • When reading from a logical file that increases the number of decimal positions specified in the physical file

The data conversion error occurs because too many digits might be moved into the space available to the left of the decimal point. For example, if, as in the previous example, the physical file field is defined as 4 digits long with 2 decimal positions and the logical file field decreases the decimal positions to 0 decimal positions, a value of 3322 written to the logical file cannot fit in the physical file. This value does not fit because only 2 digits are allowed left of the decimal point in the physical file.

To avoid data conversion errors, increase or decrease the length (positions 30 through 34) of the logical file field by the same amount that you increase or decrease the decimal positions.

Related reference
Positional entries for physical and logical files (positions 1 through 44)
JFLD (Joined Fields) keyword—join logical files only