INDICATOR CLASSIFICATION


Depending on the type of RPG specifications being used, indicators have various definitions. A list of the indicator classifications and definitions follows.

Overflow Indicator. An indicator that is specified as an overflow indicator (i.e., the OFLIND keyword on the file specification for a printer device file) is set on automatically when the overflow line for a printer file is printed. The overflow line is identified by the FORMOFL keyword on the file specification.

Record-Identifying Indicator. The record-identifying indicator is an indicator specified for the record identification position of the input record specification. RPG automatically sets on a record-identifying indicator when a record is read that matches the record type for the record-identifying indicator.

Level-Break and Control-Level Indicator. An indicator that is specified in positions 63 and 64 of the input specification is called a level-break indicator. In addition, an indicator specified in positions 7 and 8 of the calculation specification is called a control-level indicator. A special set of nine indicators is reserved for level breaks; they are L1 through L9.

A control-level or level-break indicator is set on automatically by the RPG cycle when the cycle reads a record and the value of the field that is associated with the level-break indicator changes. If the RPG cycle is avoided—as is normally the case with new application programs—and the READ and CHAIN op codes are used to access data files, level-break indicators are not changed and become less useful.

Field Record-Relation Indicator. An indicator specified in positions 67 to 68 of the input specifications is called a field-record relation indicator. A field-record relation indicator associates an input field with a specific input record format. For example, when a file contains several record-identifying indicators, the fields within the record are associated with the record format containing the record-identifying indicator. RPG initializes the field only when its corresponding record-identifying indicator is on.

Field Indicator. An indicator specified in positions 69 and 70, 71 and 72, and 73 and 74 of the input specification is called a field indicator. A field indicator is set on or off automatically by RPG when a record is read. A numeric field can be assigned all three field indicators, and a character field can be assigned only one indicator (the "blank or zero" indicator in positions 72 and 73). The field indicator in positions 69 and 70 is set on if the numeric field to which it is assigned is greater than zero. The field indicator in positions 71 and 72 is set on if the numeric field to which it is assigned is less than zero. The field indicator in positions 73 and 74 is set on if the numeric field to which it is assigned is equal to zero or if the character field to which it is assigned is blank.

Controlling and Conditioning Indicator. An indicator specified in positions 10 and 11 of the calculation specification is called a controlling or conditioning indicator. It controls the logic flow of the calculation specifications. For example, indicator 38 can be used to control when an amount is added to a total field. In structured programming, conditioning indicators are not a viable programming tool and, therefore, should be avoided. Specifying the letter N prior to the indicator, in position 9, can reverse the test condition for the indicator.

Resulting Indicator. An indicator specified in positions 71 and 72, 73 and 74, or 75 and 76 of the calculation specification is called a resulting indicator. The purpose of a resulting indicator is to signal various conditions as the result of a calculation operation. For example, the CHAIN operation is used to access a database record. When the CHAIN operation doesn't find a record, the resulting indicator specified in positions 71 and 72 is set on. In RPG III and RPG IV, resulting indicators are set off before the operation is performed. (See chapter 5 for a description of the resulting indicators for each operation.)

First Page Indicator. The single first page indicator, 1P, is set on at the beginning of the RPG program, and it is then set off by the cycle just prior to the first detail cycle.

Last Record Indicator. The last record indicator, LR, is used in old-style RPG to signal that the RPG cycle has read the last record from a primary or secondary input file that has the end-of-file indication on the file specification. This indicates that the program will end after the current cycle is completed. In modern RPG III and RPG IV, the LR indicator is used to cause program termination (i.e., to return to its calling program). Normally, the LR indicator is explicitly set on in the program by a MOVE or SETON operation.

Matching Record Indicator. The matching record indicator, MR, is set on by the RPG cycle when all matching fields of a secondary file match all the matching fields in the primary file. Match fields are identified by specifying the match field identifiers M1 to M9 in positions 65 to 66 of the input specification.

Indicator Variables. Indicator variables allow the RPG programmer to refer to an indicator as if it were a data variable. Indicators are addressed using the convention *INxx where xx is the indicator being addressed. For example, *IN01 is indicator 01 and *INOF is the overflow indicator OF.

Indicator Array. The indicator array is a 99-element array of the 99 general-purpose indicators. The indicator array is addressed like any other array or array element, with the convention *IN(xx) where xx is the indicator being addressed. For example, *IN(38) addresses indicator 38. If no array index is used, the reference is to the entire 99-element array. For example, *IN refers to the entire indicator array.

Named Indicators. The RPG data-type, named indicator allows a variable to be declared that can be used like any other indicator. Typically, this kind of variable is used as the return value for procedures or as the storage location for numeric indicators




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net