Contents
Use the DEFINE statement to:
- Define a work field
- Define a new field based on the input data
- Revise the display format or column heading of a previously defined field
Place any DEFINE statements near the top of the control file. Each VMRGRW data definition table has a set of associated DEFINE statements. These are activated automatically when VMRGRW finds a FILE statement. The parameters of the DEFINE statement must be coded in the order shown for each function.
Defining a Work Field
Use a work field to hold computed data or other temporary data.
DEFINE "Parms".
Parms:
Fldname SPACE LENGTH nnn [[DISPLAY ‘dcon’] TYPE tcon] [HEADING | ‘heading’ ...]
Defining a New Field
The format for defining a new field using data from the input file is:
DEFINE "Parms".
Parms:
fldname [START nnn] LENGTH nnn [[DISPLAY ‘dcon’] TYPE tcon] [HEADING | ‘heading’ ...]
Revising the Display Format or Column Heading
You can use the DEFINE statement to revise the display format or change any of the column headings of a previously defined field or a field from the input file.
DEFINE fldname [DISPLAY 'dcon'] [HEADING | 'heading']
- fldname
Indicates the name of the work field, new field, or previously defined field. Field names can be from one to nine characters long. They can contain alphanumeric characters (A-Z and 0-9), as well as these special characters: $ (dollar sign), ¢ (cent sign), # (pound sign), and @ (at sign). The first character cannot be a digit (0-9). - SPACE
Designates a work field. Work fields are set to a null value (blank or zero, depending on the data type) at the beginning of every processing step unless the field name begins with GLOBAL. A GLOBAL field retains its value from one processing step to the next. You can use these fields to communicate between processing steps. Values in GLOBAL fields are always available to any step, even if not written to an output file created by a previous step. - LENGTH nnn
Indicates the length of the new field in bytes. Refer to the table about Field Types in Building the Control File for the maximum allowable length for each field type. - DISPLAY 'dcon'
Specifies how numeric data is displayed. You must use this parameter if you are defining a numeric field (TYPEs P/D, Z/D, P/N, and BIT).
The DISPLAY parameter also controls the display of totaled and summarized values. Therefore, if the field will contain totaled or summarized data, choose a DISPLAY value ('dcon') large enough to contain the largest expected result.
Valid 'dcon' values are:
9 | Is a place holder for a numeric digit. |
0 | Is a place holder that specifies that automatic zero suppression ends with the next digit. |
. | Is a period, which specifies the decimal point position. |
- | Is a minus sign, which is a sign indicator when it follows the last 9 or 0 in the 'dcon' value. |
If you use any other character in 'dcon', VMRGRW interprets it as punctuation. Any character that follows the last 9 or 0 is interpreted as a sign indicator. Use a minus sign (-) if the field contains negative numbers.
A decimal position tells VMRGRW that the digits to the right of the decimal point are decimals and not integers. VMRGRW uses this information to align decimal points when fields are added or subtracted, and to place the decimal point in the product or quotient of two fields.
If you revise the DISPLAY 'dcon' value for a field, be aware that relocating the decimal point affects values, not just the way they are displayed. If a field was originally defined as having three decimal places (DISPLAY value ending '.999'), and you revised it to one decimal place (DISPLAY value ending '.9'), you have, in effect, multiplied the data by 100.
VMRGRW reserves enough space in the print line to hold the longest value to appear on the report. This is the field value, as defined by the DISPLAY 'dcon' value, or the longest column heading for the field.
If the totaled value of a field (computed by the PRINT TOTAL statement) does not fit into the space reserved by its DISPLAY 'dcon' value, it is truncated and preceded by an asterisk. For this reason, VMRGRW reserves at least one blank space before every numeric field, even if the WIDE and BLANK values in the PRINT statement indicate otherwise.
Specifies the data type for the field. For a description of each field type, see the table about Field Types in Building the Control File.
If you specify the TYPE BIT parameter, the only valid value for the DISPLAY 'dcon' parameter is an even number of x's (for example, DISPLAY 'xxxx').
Indicates that it is to be used if you want to use the field name (fldname) as the column heading in the report. This is the default.
Designates a literal for a column heading. Column headings are left justified for alphanumeric fields and right justified for all other data types.
Indicates that it is the starting position of the new field in the input record. The first position available is position 1. The default start position is immediately after the end of the previously defined field. Use the data definition tables to determine the value for this parameter.
Indicates the ending position of the field in the input record. As with the starting position, this is relative to 1. Use the data definition tables to determine the value for this parameter.
Examples
- To use the DEFINE statement to define a two-byte, packed data work field with the default column heading:
DEFINE WORKFLD SPACE LENGTH 2 DISPLAY '909' TYPE P/D.
- To use the DEFINE statement to change OLDFIELD's field display characteristics and its column heading:
DEFINE OLDFIELD DISPLAY '99,909.99' 'NEW FIELD' 'HEADER'.
- To use the DEFINE statement to define a five-character, zoned data field using data from the input file starting with the tenth byte:
DEFINE NEWFIELD START 10 LENGTH 5 DISPLAY '99,909'
TYPE Z/D 'NEW INPUT' 'FIELD'.