Appendix D: Data Formats

The format specification is a sequence of characters that depicts how the contents of a field will look. The characters listed in the table below have special meanings. Other characters that appear in a format string are inserted directly into the field.

If the format size (number of data characters) is larger than the field size, an alpha field is left-justified and the format string truncated, while a decimal field is right-justified and the format string truncated. If the format size is smaller than the field size, the data is truncated.

Character

Meaning

@

Represents a single alpha character.

X

Represents a single digit. It causes a digit from the source data to be inserted into the specified position in the field. Digits are extracted from the source data beginning at the right and continuing to the left; the rightmost X in the format is loaded with the rightmost digit in the source data. If there are more X characters than there are significant digits in the source data, the leftmost X positions are loaded with zeros.

Z

Represents a single digit. Z differs from X when there are more Z characters than significant digits to be transferred from the source data. The Z position is loaded with a blank if no X character or period appears to the left of it in the format. If a period appears to the left but not to the right, the Z position is loaded with a zero. A zero is also loaded if an X appears to the left of the Z.

*

(asterisk)

Represents a digit position. The * is similar to an X, except that when there are no more significant digits, the position is loaded with an asterisk rather than a zero.

money sign

Represents a digit position. If there are more significant digits to be transferred, the position is loaded with the next digit. If no more significant digits remain to be transferred, the position is loaded with a blank. The rightmost money character is changed to a dollar sign when field loading is concluded.

The default money sign is “$”, but you can use the MONEY routine to change it to any character.

Causes a minus sign to be inserted at the corresponding position in the field if the – is the first or last character of a format. If the source data is positive, a blank will be inserted. If the – is used within the format, a hyphen is inserted at the corresponding position in the field.

.

(period)

Causes a decimal point to be inserted at the corresponding position in the field. In addition, any Z that appears to the right of the decimal point is treated as an X.

,

(comma)

Causes a comma to be inserted at the corresponding destination position, but only if one of the following conditions is true:

  • More significant source digits remain to be transferred.
  • There is an X character to the left of the comma.

Using European numeric formatting

The RPTDATE environment variable tells ReportWriter to apply European formatting conventions, instead of American conventions, to numeric values. If RPTEURO is set to any value, commas are used as decimal points, and periods are used as separators.