HP 3000 Manuals

Operation Definitions [ HP RPG/iX Reference Manual ] MPE/iX 5.0 Documentation


HP RPG/iX Reference Manual

Operation Definitions 

The definitions in this section are listed in alphabetical order, not by
type of operation.

ADD 

This arithmetic operation adds Factor 1 to Factor 2 and places the sum in
the Result Field.  If Factor 1 is blank, it adds Factor 2 to the Result
Field and places the sum in the Result Field.

BEGSR 

This internal subroutine operation marks the entry point to an internal
subroutine (see figures 8-7 and 8-26).  Enter the name (label) of the
subroutine in the Factor 1 Field.  The label can be up to six characters
long, and must begin with a letter or the special character @, $, or #.
The remaining characters can be letters, digits, or the special
characters @, $, or # in any combination.  Use this label only in an EXSR
operation to perform the subroutine (do not use it in a GOTO operation,
in or out of the subroutine.)  Enter only one BEGSR operation per
subroutine.

BITOF 

This indicator and bit setting operation turns OFF bits in the Result
Field.  The bits that are turned OFF are determined by the bit settings
of the Factor 2 Field.

The Result Field must be a one-character alphanumeric field.  You can
enter an alphanumeric literal, a field, a table, or an array element in
the Factor 2 Field.  In all these cases, Factor 2 must be a single
character.  If you enter a field, table, or array element in Factor 2,
the bits that are turned OFF in the Result Field are the ones that are
OFF in the Factor 2 field.  If you enter an alphanumeric literal, each
digit in it identifies a bit to be turned OFF. Enter up to eight digits
for the literal enclosed in quotation marks.  Enter a digit for each bit
position you want to turn OFF. Zero (0) stands for the high-order bit and
seven for the low-order bit.  You can enter the bit numbers in any order;
if you do not enter a number for a bit, it remains unchanged.  For
example, "02" turns bits 0 and 2 OFF.

Do not use the Factor 1, Decimal Positions (column 52), Half Adjust
(column 53), or Resulting Indicators (columns 54-59) Fields.

See figure 8-8 for an example of how to use BITOF.

BITON 

This indicator and bit setting operation turns ON bits in the Result
Field.  The bits that are turned ON are determined by the Factor 2 Field.

The Result Field must be a one-character alphanumeric field.  You can
enter an alphanumeric literal, a field, a table, or an array element in
the Factor 2 Field.  In all these cases, Factor 2 must be a single
character.  If you enter a field, table, or array element in Factor 2,
the bits that are turned ON in the Result Field are the ones that are ON
in the Factor 2 field.  If you enter an alphanumeric literal, each digit
in it identifies a bit to be turned ON. Enter up to eight digits for the
literal enclosed in quotation marks.  Enter a digit for each bit position
you want to turn ON. Zero (0) stands for the high-order bit and seven for
the low-order bit.  You can enter the bit numbers in any order; if you do
not enter a number for a bit, it remains unchanged.  For example, "02"
turns bits 0 and 2 ON.

Do not use the Factor 1, Decimal Positions (column 52), Half Adjust
(column 53), or Resulting Indicators (columns 54-59) Fields.

Example 

Figure 8-8 shows how to use the BITON and BITOF operations.  The BITON
operation in line 1 turns ON bits 3 and 4 (the fourth and fifth bits) in
the field BITFLD. The BITOF operation in line 2 turns OFF the bits in
BITFLD that are also OFF in the field MYFLD.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     1     C                     BITON"34"      BITFLD                           |
|            C                      .                                             |
|            C                      .                                             |
|     2     C                     BITOFMYFLD     BITFLD                           |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-8.  Using the BITON and BITOF Operations 

CABxx 

This structured programming operation (Compare And Branch) compares
Factor 1 to Factor 2.  If the results of the comparison match the
condition specified by xx, control branches to the TAG label entered in
the Result Field.

          Table 8-4.  CABxx Operations 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|            Enter this operation:            |           To test if Factor 1 is:           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
|                     CAB                     | No test takes place; the branch is          |
|                                             | unconditional.                              |
|                                             |                                             |
|                    CABEQ                    | Equal to Factor 2.                          |
|                                             |                                             |
|                    CABGE                    | Greater than or equal to Factor 2.          |
|                                             |                                             |
|                    CABGT                    | Greater than Factor 2.                      |
|                                             |                                             |
|                    CABLE                    | Less than or equal to Factor 2.             |
|                                             |                                             |
|                    CABLT                    | Less than Factor 2.                         |
|                                             |                                             |
|                    CABNE                    | Not equal to Factor 2.                      |
|                                             |                                             |
---------------------------------------------------------------------------------------------

If you want to condition the operation, enter one or more indicators in
the Indicators Field (columns 9-17).

You can enter a field name or a literal in the Factor 1 and Factor 2
Fields.  Numeric fields are aligned by decimal point before they are
compared.  Shorter fields are padded with zeros (to the left and right)
to make them the same size.  Blanks in numeric fields are treated as
zeros.  The maximum numeric field length is 15 digits.  Alphanumeric
fields are aligned starting with their high-order (leftmost) characters.
Shorter fields are padded with blanks (on the right) to make them the
same size.  If you specified an alternate collating sequence, it is used.

You can compare a numeric field to an alphanumeric field.  The numeric
field is temporarily converted to alphanumeric format and the two fields
are compared as if they both were alphanumeric.  The numeric field is not
aligned by decimal point before the compare.  Negative signs are ignored.
For example, the number -123.45 becomes "12345".  To avoid problems when
comparing the numeric field, make sure it does not have decimal places,
is the same length and is not negative.  When you compare a numeric field
to an alphanumeric field, you see this compiler message:

9016I NUMERIC FIELD TEMPORARILY CONVERTED TO ALPHANUMERIC FOR
ALPHANUMERIC COMPARE

You may enter one or more resulting indicators in the Resulting
Indicators Field (columns 54-59).  The resulting indicators are turned ON
or OFF depending on the results of the compare and are unaffected by
whether a branch is performed.  If you use the CAB operation, you must
enter at least one resulting indicator.

Example 

Figure 8-9 shows how to enter the CABGE operation.  The field CODE is
compared to the literal 21.  If CODE is greater than or equal to 21,
control skips to the label SELECT. Indicator 20 is turned ON when CODE is
less than 21.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     1     C           CODE      CABGE21        SELECT       20                  |
|            C                       .                                            |
|            C                       .                                            |
|     2     C           SELECT    TAG                                             |
|            C                       .                                            |
|            C                       .                                            |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-9.  Using the CABGE Operation 

CASxx 

This structured programming operation (CASe) compares Factor 1 to Factor
2.  If the results of the comparison match the condition specified by xx,
control branches to the internal subroutine named in the Result Field.

          Table 8-5.  CASxx Operations 

--------------------------------------------------------------------------------------------
|                           |                                                              |
|   Enter this operation:   |                   To test if Factor 1 is:                    |
|                           |                                                              |
--------------------------------------------------------------------------------------------
|                           |                                                              |
|            CAS            | No test takes place; the subroutine is performed             |
|                           | unconditionally.                                             |
|                           |                                                              |
|           CASEQ           | Equal to Factor 2.                                           |
|                           |                                                              |
|           CASGE           | Greater than or equal to Factor 2.                           |
|                           |                                                              |
|           CASGT           | Greater than Factor 2.                                       |
|                           |                                                              |
|           CASLE           | Less than or equal to Factor 2.                              |
|                           |                                                              |
|           CASLT           | Less than Factor 2.                                          |
|                           |                                                              |
|           CASNE           | Not equal to Factor 2.                                       |
|                           |                                                              |
--------------------------------------------------------------------------------------------

Enter all CASxx operations together as a group without other operations
interspersed.  Terminate the group with an END operation.  When the CASxx
operations are executed, each Factor 1 Field is compared to each Factor 2
Field in the operations until a condition being tested is satisfied or
until a CAS operation is encountered.  The subroutine in the Result Field
of that line is executed and control returns to the line following the
END operation for the CASxx group.

If you want to condition the CASxx operation, enter one or more
indicators in the Indicators Field (columns 9-17).

You can enter a field name or a literal in the Factor 1 and Factor 2
Fields.  Numeric fields are aligned by decimal point before they are
compared.  Shorter fields are padded with zeros (to the left and right)
to make them the same size.  Blanks in numeric fields are treated as
zeros.  The maximum numeric field length is 15 digits.  Alphanumeric
fields are aligned starting with their high-order (leftmost) characters.
Shorter fields are padded with blanks (on the right) to make them the
same size.  If you specified an alternate collating sequence, it is used.

You can compare a numeric field to an alphanumeric field.  The numeric
field is temporarily converted to alphanumeric format and the two fields
are compared as if they both were alphanumeric.  The numeric field is not
aligned by decimal point before the compare.  Negative signs are ignored.
For example, the number -123.45

becomes "12345".  To avoid problems when comparing the numeric field,
make sure it does not have decimal places, is the same length and is not
negative.  When you compare a numeric field to an alphanumeric field, you
see this compiler message:

9016I NUMERIC FIELD TEMPORARILY CONVERTED TO ALPHANUMERIC FOR
ALPHANUMERIC COMPARE

You may enter one or more resulting indicators in the Resulting
Indicators Field (columns 54-59).  If you use a CASxx operation with one
or more resulting indicators, you must use the Factor 1 and Factor 2
Fields.

Example 

Figure 8-10 shows how to enter the CASxx operation.  The CASxx group of
operations are entered in lines 3-5 and are executed by the GOTO
operation in line 1.  The CASEQ operation in line 3 performs the
subroutine SUB21 when indicator 20 is OFF and the field CODE equals 21.
The CASGE operation in line 4 performs the subroutine SUB5X when
indicator 20 is ON and the field CODE2 is greater than or equal to 5.  If
neither of the CASxx conditions in lines 3-4 are satisfied, the CAS
operation in line 5 executes the subroutine SUBXXX.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C                     SETON                     20                   |
|            C                       .                                            |
|            C                       .                                            |
|     1     C                     GOTO SELECT                                     |
|            C                       .                                            |
|            C                       .                                            |
|     2     C           SELECT    TAG                                             |
|     3     C  N20      CODE      CASEQ21        SUB21                            |
|     4     C   20      CODE2     CASGE5         SUB5X                            |
|     5     C                     CAS            SUBXXX                           |
|            C                     END                                            |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-10.  Using the CASxx Operation 

CHAIN 

This operation reads a record from a KSAM, TurboIMAGE, or MPE
direct-access file.  CHAIN lets you retrieve records randomly; you enter
identifying information for the record you want to read.  Similarly, you
can use CHAIN to write records randomly to these files.

There are two ways to access records with CHAIN. You can access a file by
relative record number or record key.  A relative record number is a
record number that is "relative" to the first record in the file.  For
example, record 5 is the fifth physical record in a file.  For KSAM and
TurboIMAGE files, you can access records by entering a record's key
value.  For example, to access the record having a key value of 06355,
enter the number 06355.  You can calculate the record number or key value
in the program or you can get it from records in other input files.

You must define the file that you're chaining to with a D
(direct-access), I or X (KSAM), or M (TurboIMAGE) in the File
Organization Field (column 32) of the File Description Specification.
Enter C (chained) in the File Designation/Additional I/O Area (column 32)
of that specification and if this is an output file, enter O in the
File Type Field (column 15).  When you chain successfully to a
file, the record-identifying indicators (entered in the Record
Indicator/Look-Ahead/Trailer/Data Structure Field (columns 19-20) of the
Input Specification) for the file remain ON throughout the cycle.  If you
chain to the same output file more than once in the same cycle, only the
last record is updated unless you use exception lines with each CHAIN
operation.

To condition this operation, enter indicators in the Control Level
(columns 7-8) or the Indicators Field (columns 9-17), or both.

Enter a relative record number or record key in the Factor 1 Field.  If
reading by record number or packed record key, use a numeric literal or
field.  If reading by record key, use an alphanumeric literal, field,
array, or table.  You can enter a partial key when reading by record key.
(A partial key contains characters that are compared to the corresponding
characters in the high-order, leftmost, position of the record key.  As
long as the characters in the partial key match, a record is selected for
processing regardless of whether the remaining characters in the key
match.)  Additionally, you can enter a relational operator in the Result
Field that specifies the relationship that the record key value must have
with Factor 1 to be selected for processing.  For example, to select a
record whose key value is equal to or less than Factor 1, enter the
relational operator *LT in the Result Field.

Enter the name of the chained or full procedural file in the Factor 2
Field.

Enter the indicator in the High Subfield (columns 54-55) that you want to
turn ON when a record is not found.  For TurboIMAGE files, enter the
indicator in the Low Subfield that you want to turn ON when the
end-of-chain is reached.  (A chain is a group of records having the same
key value.)  When you leave either or both the High and Low Subfields
blank, H0 is turned ON.

Use the Low Subfield for chained sequential (the input/output mode field
for the file in the File Description Specification is C) and backward
chained sequential (the input/output mode field is R) operations.  When
performing these operations, RPG sequentially retrieves all of the
records in a chain.  You initiate a chained sequential read by placing a
new key value in Factor 1.  RPG finds and reads the first record in the
chain (or the last record if reading backward).  For TurboIMAGE files,
RPG uses the master data set to find the head of chain in the detail data
set.  (Do not, however, define the master data set in a File Description
Specification.)  If you leave the contents of Factor 1 unaltered, a
subsequent CHAIN operation reads the next record in the chain.  When the
end-of-chain is reached, the Low Subfield indicator is turned ON. Table
8-6 summarizes when the High and Low Subfield indicators are turned ON
and OFF.

          Table 8-6.  How CHAIN Sets the High and Low Resulting Indicators 
-----------------------------------------------------------------------------------------------
|                       |                       |                                             |
|    High Resulting     |     Low Resulting     |                 Description                 |
|       Indicator       |       Indicator       |                                             |
|    (Columns 54-55)    |    (Columns 56-57)    |                                             |
|                       |                       |                                             |
-----------------------------------------------------------------------------------------------
|                       |                       |                                             |
|          OFF          |          OFF          | Successful retrieval of the next record in  |
|                       |                       | the chain.                                  |
|                       |                       |                                             |
|          OFF          |          ON           | End-of-chain for the current group of       |
|                       |                       | records with the same key value (the second |
|                       |                       | or subsequent CHAIN operation for the same  |
|                       |                       | key value has failed).                      |
|                       |                       |                                             |
|          ON           |          ON           | No records for this key value exist in this |
|                       |                       | detail data set, but an entry for this key  |
|                       |                       | was found in the master data set (the first |
|                       |                       | CHAIN operation with a new key value has    |
|                       |                       | failed).                                    |
|                       |                       |                                             |
|          ON           |          OFF          | No records for this key value exist in the  |
|                       |                       | master and detail data sets (the first      |
|                       |                       | CHAIN operation with a new key value has    |
|                       |                       | failed).                                    |
|                       |                       |                                             |
-----------------------------------------------------------------------------------------------

Example 

Figure 8-11 shows how to use the CHAIN operation to read records from the
direct-access file CHAINFL (line 2).  Records are read by record number.
The CHAIN operation in line 4 reads records in CHAINFL using the field ID
(line 3) to identify the record numbers.  The record numbers in ID are
obtained from the input file INFILE (line 1).
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|       1   FINFILE  IPE F      80            DISK                                |
|       2   FCHAINFL UC  F     256    D       DISK                                |
|                                                                                 |
|            IINFILE  AA  01  80 CX                                               |
|            I                                        1  10 NAME                  |
|       3   I                                       11  150ID                     |
|            I                                       16  20 PROD                  |
|            I                                       21  25 AMT                   |
|            I                                                                    |
|            ICHAINFL BB  02  01 CY                                               |
|            I                                       05  100ID                    |
|            I                                       11  20 STREET                |
|            I                                       21  30 CITY                  |
|            I                                       31  35 STATE                 |
|            I                                       36  40 ZIP                   |
|                                                                                 |
|       4   C           ID        CHAINCHAINFL              50                    |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-11.  Chaining to an Input File 

Figure 8-12 shows how to create a direct-access chained file CHFILE from
a sequential input file INFILE. During each logic cycle, a record is read
from INFILE (line 1).  When the CHAIN operation (line 3) is executed the
field DATA is written to CHFILE (line 4) using the record number in the
field RECNO (see line 2).  The first time CHAIN is executed, it sets the
five extents allocated for the chained file to blanks.

The HP RPG/iX Programmer's Guide gives additional examples on chaining to
a KSAM file.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|       1   FINFILE  IPE F      80            DISK                                |
|            FCHFILE  OC  F 240  80R   D       DISK                               |
|                                                                                 |
|            IINFILE  AA  01                                                      |
|       2   I                                        1   50RECNO                  |
|            I                                        1  80 DATA                  |
|                                                                                 |
|       3   I           RECNO     CHAINCHFILE                                     |
|                                                                                 |
|            OCHFILE           01                                                 |
|            O                         DATA      80                               |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-12.  Creating a Chained File 

CLOSE 

This file operation closes an open file.  It performs normal end-of-file
actions before the program actually ends.  Use CLOSE to release a file so
that others can gain access to it or to release system resources used by
a file that you've finished processing.  You can also use CLOSE to
release printer files for printing.  Once you use CLOSE for a file, you
cannot use the file in subsequent input/output operations.

To use CLOSE, enter the name of the file to close in the Factor 2 Field
and enter an indicator in the Low Subfield (columns 56-57).  The Low
Subfield indicator is turned ON if the file cannot be closed.

CLOSE is similar to the Release Option (see the Fetch Overflow/Release
Field (column 16) of the Output Specification).

COMP 

This compare and test operation compares Factor 1 to Factor 2.  You can
enter a field name, literal, or figurative constant into either field.
When COMP is executed, the resulting indicators that you enter in columns
54-59 are turned ON according to the results of the compare.

Table 8-7 briefly describes the COMP operations.

          Table 8-7.  COMP Operations 
---------------------------------------------------------------------------------------------
|                                             |                                             |
|                    When:                    |            This Resulting Field             |
|                                             |           Indicator is Turned ON:           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| Factor 1 is greater than Factor 2           |            High (columns 54-55).            |
|                                             |                                             |
| Factor 1 is less than Factor 2              |            Low (columns 56-57).             |
|                                             |                                             |
| Factor 1 equals Factor 2                    |           Equal (columns 58-59).            |
|                                             |                                             |
---------------------------------------------------------------------------------------------

Numeric fields are aligned by decimal point before they are compared.
Shorter fields are padded with zeros (to the left and right) to make them
the same size.  Blanks in numeric fields are treated as zeros.  The
maximum numeric field length is 15 digits.

Alphanumeric fields are aligned starting with their high-order (leftmost)
characters.  Shorter fields are padded with blanks (on the right) to make
them the same size.  If you specified an alternate collating sequence, it
is used.

You can compare a numeric field to *ZERO(S) and an alphanumeric field to
*BLANK(S) or *ZERO(S). You can also compare a numeric field to an
alphanumeric field.  The numeric field is temporarily converted to
alphanumeric format, and the two fields are compared as if they both were
alphanumeric.  The numeric field is not aligned by decimal point before
the compare.  Negative signs are ignored.  For example, the number
-123.45 becomes "12345".  To avoid problems when comparing the numeric
field, make sure it does not have decimal places, is the same length, and
is not negative.  When you compare a numeric field to an alphanumeric
field, you see this compiler message:

9016I NUMERIC FIELD TEMPORARILY CONVERTED TO ALPHANUMERIC FOR
ALPHANUMERIC COMPARE

Example 

Figure 8-13 shows two COMP operations.  The COMP operation in line 1
compares FIELD1 to FIELD2.  If they are equal, indicator 03 turns ON. If
FIELD1 is greater than FIELD2, indicator 01 turns ON. If FIELD1 is less
than FIELD2, indicator 03 turns ON. The COMP operation in line 2 compares
the field STATUS to the word EXEMPT. If they are equal, indicator 05
turns ON.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     1     C           FIELD1    COMP FIELD2               010203                |
|            C                      .                                             |
|            C                      .                                             |
|     2     C           "EXEMPT"  COMP STATUS                   05                |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-13.  Using the COMP Operation 

DEBUG 

This debugging operation assists you in debugging a program by showing
the indicators that are turned ON and optionally, a field in the program.
Place the DEBUG operation at one or more points in the Calculation
Specifications where you want to capture DEBUG information.  The captured
information is saved in a file that you name.

To enable DEBUG, enter 1 in the Debug Field (column 15) of the Header
Specification.  If you leave this field blank, DEBUG operations in the
program are ignored and compiler warning messages are printed.

To condition this operation, enter indicators in the Control Level Field
(columns 7-8) or the Indicators Field (columns 9-17), or both.  Leave
columns 48-59 blank.

When you use DEBUG, you can enter a literal, field, or array element in
the Factor 1 Field that contains up to eight characters.  This value
identifies the DEBUG information and is helpful when you use more than
one DEBUG operation or when DEBUG is included in a loop.  Enter the name
of the file to which you want to write the debugging information in the
Factor 2 Field (make sure that you define this file with File Description
Specifications, just as you would any other file).  You may use different
files for each DEBUG operation if you wish.

You may enter a field, table, array name, or array element in the Result
Field (the maximum number of characters that it can contain is 256); its
value is displayed after the indicator settings.

Table 8-8 describes how RPG displays the indicators and field
information.  The "Indicator lines" show the indicators that are ON and
the contents of the field or literal you entered in the Factor 1 Field.
If there are more indicators than will fit on one line, additional lines
are written (positions 1-40 are blank on these lines, and the indicators
values start in position 41).  The "Result Field lines" show the contents
of the field, table element, array, or array element entered in the
Result Field.

          Table 8-8.  Output from the DEBUG Operation 

--------------------------------------------------------------------------------------------
|                           |                                                              |
|         Position          |                           Contents                           |
|                           |                                                              |
--------------------------------------------------------------------------------------------
|                           |                                                              |
|     Indicator lines:      |                                                              |
|                           |                                                              |
|           1 - 8           | DEBUG=                                                       |
|                           |                                                              |
|          9 - 12           | The source program sequence number assigned to this DEBUG    |
|                           | Calculation Specification.  Along with the Factor 1 Field,   |
|                           | this number helps to identify this particular DEBUG          |
|                           | operation.                                                   |
|                           |                                                              |
|          13 - 14          | Blank.                                                       |
|                           |                                                              |
|          15 - 22          | The contents of the field literal entered in the Factor 1    |
|                           | Field.                                                       |
|                           |                                                              |
|            23             | A minus sign if the Factor 1 Field is negative; a blank if   |
|                           | it is zero or positive.                                      |
|                           |                                                              |

|            24             | Blank.                                                       |
|                           |                                                              |
|          25 - 39          | INDICATORSON=                                                |
|                           |                                                              |
|            40             | Blank.                                                       |
|                           |                                                              |
|          41 - 80          | The indicators that are ON. The indicator values are         |
|                           | separated by blanks.                                         |
|                           |                                                              |
|    Result Field Lines:    |                                                              |
|                           |                                                              |
|          1 - 13           | FIELDVALUE=                                                  |
|                           |                                                              |
|            14             | Blank.                                                       |
|                           |                                                              |
|          15 - 80          | Th contents of the field, table, array, or array element     |
|                           | specified in the Result Field.  The first 66 characters of   |
|                           | this field appear in positions 15 - 80 of the first line     |
|                           | following the indicator listing.  If this data exceeds 667   |
|                           | characters, it is continued in positions 15 - 80 of as many  |
|                           | additional lines as required, up to a maximum of 256         |
|                           | characters.  If this is numeric data, it is written in       |
|                           | unpacked format and zero surpressed, with an sign appearing  |
|                           | to the right of the field (a minus sign for negative values  |
|                           | and a blank for positive values).  Fields containing zeros   |
|                           | show only the rightmost zero and the sign.  No other editing |
|                           | is performed.  If the Result Field contains an array name,   |
|                           | the elements are written in order, each on an individual     |
|                           | line.                                                        |
|                           |                                                              |
--------------------------------------------------------------------------------------------

Example 

Figure 8-14 shows how to use DEBUG to display the indicators that are ON
and to display the contents of an array element.  This information is
written to a file rather than being displayed on the terminal.  The DEBUG
operation writes the debug information to the file BADFILE and tags this
output with the word FIRST. The contents of the third array element of
ARR1 is also written.  Sample DEBUG output for this example is shown
below:

     DEBUG= 0019   FIRST     INDICATORS ON= 01 02 03 05 07 11 L0 L1 MR OF
     FIELD VALUE= 370

___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C           'FIRST'   DEBUGBADFILE   ARR1,3                          |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-14.  Using the DEBUG Operation 

DIV 

This arithmetic operation divides Factor 1 (dividend) by Factor 2
(divisor), and places the quotient in the Result Field.  If Factor 1 is
blank, the Result Field is divided by Factor 2 and the quotient is placed
in the Result Field.  If Factor 1 is zero, the result is zero.  If Factor
2 is zero, an error occurs (you can determine the action to take by
entering the appropriate code in column 66 of the Header Specification).
If DIV produces a remainder, it is lost unless you immediately follow DIV
with an MVR operation that moves it to the Result Field.  (When you use
MVR, you cannot half adjust the quotient.)

The result of DIV must not exceed 15 digits.  If it does, excess digits
are truncated.

Example 

Figure 8-15 shows how to perform a divide operation and save the
remainder.  The DIV operation divides DIVIDN by DIVSOR saves the result
in QUOTNT. The remainder is saved in the field REMAIN by the MVR
operation.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C   26      DIVIDN    DIV  DIVSOR    QUOTNT 102                      |
|            C   26                MVR            REMAIN  52                      |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-15.  Using the DIV and MVR Operations 

DO 

This structured programming operation executes the Do Block following it
until a specified condition is met.  With the DO operator you specify the
initial value for the loop variable in Factor 1 and the limit value in
Factor 2.  These values must be numeric if specified.  You may leave
Factor 1 or Factor 2 blank.  RPG will assume a value of 1 for either or
both Factors which are left blank.

In the Result Field you specify the name of a numeric field to control
the loop.[REV BEG] Make sure this field is large enough to hold a number
that is one larger than the limit value for the loop (or the loop will
never end).  For example, a two-digit field is not large enough for the
control variable when the loop limit is 99 (99 plus 1 does not fit in two
digits).[REV END] If you leave the Result Field blank, RPG will generate
an internal field as the loop counter.

The DO loop must be terminated with an END statement.  To determine the
loop increment for the DO loop, specify a numeric value in Factor 2 of
the END statement.  If no numeric value is specified, the loop increment
will default to 1.

RPG will compare the loop control variable (Result Field) with the limit
(Factor 2).  If the index exceeds the limit, control will pass to the
statement following END. Otherwise, the loop contents will be executed,
the loop control variable will be incremented at the bottom of the loop,
and the DO loop will repeat.

Note that a conditioning indicator on the DO statement will condition the
entire loop.  If such a conditioning indicator, or indicators, evaluate
to false, control will skip to the statement following END, not to the
statement following DO.

Leave resulting indicators blank for the DO operator.

Example 

In Figure 8-16 the DO loop will execute four times, for INDX values 18,
20, 22, and 24.  When INDX is incremented to 26, the test 26 <= 25 will
fail and control will pass to the instruction following END.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C           18        DO   25        INDX    30                      |
|            C                     .                                              |
|            C                     .                                              |
|            C                     END  2                                         |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-16.  Using the DO Operation 



MPE/iX 5.0 Documentation