home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv4.zip
/
VACPP
/
IBMCPP
/
HELP
/
EVFERLSH.HLP
(
.txt
)
< prev
next >
Wrap
OS/2 Help File
|
1995-05-11
|
436KB
|
13,714 lines
ΓòÉΓòÉΓòÉ 1. RPG/400 Help ΓòÉΓòÉΓòÉ
Introduction to RPG/400
Control Specifications
File Description Specifications
Extension Specifications
Line Counter Specifications
Input Specifications
Calculation Specifications
Output Specifications
Operation Codes
RPG/400 Words with Special Functions
RPG/400 Restrictions
The Structured Query Language
RPG/400 Reserved Fields
ΓòÉΓòÉΓòÉ 1.1. How This Product Has Changed ΓòÉΓòÉΓòÉ
Optional factor 1 on CAT and SUBST. For details and examples see String
Operations, CAT (Concatenate Two Character Strings), and SUBST (Substring).
CHEKR provides the same function as CHECK but in the reverse direction (right
to left). This function can be used to determine the length of a string. For
details and examples see CHEKR (Check Reverse).
P in the operation extender field for MOVE, MOVEA, and MOVEL allowing padding
of the result after the operation. For details and examples see Move
Operations, MOVE (Move), MOVEA (Move Array), and MOVEL (Move Left).
Support for hexadecimal literals. For details and examples see Bit
Operations.
Support for a 4-digit year. For details and examples see User Date Special
Words, and TIME (Time of Day).
ΓòÉΓòÉΓòÉ 1.2. Introduction to RPG/400 ΓòÉΓòÉΓòÉ
The valid character set for the RPG/400 language consists of:
The letters A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
The numbers 0 1 2 3 4 5 6 7 8 9
The characters + - * , . ' & / $ # : @
The blank character
RPG/400 code is written on a variety of specifications. Each specification has
a specific set of functions. See Common Entries for details on specification
types. The RPG/400 language is a position-dependent language. Each entry must
start in a specific column. To represent this, each illustration of RPG/400
code will be in listing format with a scale drawn across the top. You may find
it helpful to use your RPG/400 Debugging Template (GX21-9129).
This help contains a detailed description of the individual RPG/400
specifications. Each field and its possible entries are described. Operation
Codes describes the operation codes that are coded on the Calculation
specification, which is described in Calculation Specifications.
In addition, there is information on indicators, the logic cycle, arrays and
tables, edit codes and edit words, file translation, multifile processing, and
match fields.
ΓòÉΓòÉΓòÉ 1.2.1. Compiler Directives ΓòÉΓòÉΓòÉ
The compiler directive statements /TITLE, /EJECT, /SPACE, and /COPY allow you
to specify heading information for the compiler listing, to control the spacing
of the compiler listing, and to insert records from other file members during a
compile. The compiler directive statements must precede any arrays, tables,
translation records, and alternate collating sequence records (that is, **
records).
ΓòÉΓòÉΓòÉ 1.2.1.1. /TITLE (Positions 7-12) ΓòÉΓòÉΓòÉ
Use the compiler directive /TITLE to specify heading information (such as
security classification or titles) that is to appear at the top of each page of
the compiler listing. The following entries are used for /TITLE:
Positions Entry
7-12 /TITLE
13 Blank
14-74 Title information
A program can contain more than one /TITLE statement. Each /TITLE statement
provides heading information for the compiler listing until another /TITLE
statement is encountered. A /TITLE statement must be the first RPG/400
specification encountered to print information on the first page of the
compiler listing. The information specified by the /TITLE statement is printed
in addition to compiler heading information.
The /TITLE statement causes a skip to the next page before the title is
printed. The /TITLE statement is not printed on the compiler listing.
ΓòÉΓòÉΓòÉ 1.2.1.2. /EJECT (Positions 7-12) ΓòÉΓòÉΓòÉ
Enter /EJECT in positions 7 through 12 to indicate that subsequent
specifications are to begin on a new page of the compiler listing. Positions
13 through 74 of the /EJECT statement must be blank. /EJECT is not printed on
the compiler listing.
ΓòÉΓòÉΓòÉ 1.2.1.3. /SPACE (Positions 7-12) ΓòÉΓòÉΓòÉ
Use the compiler directive /SPACE to control line spacing within the compiler
listing. The following entries are used for /SPACE:
Positions Entry
7-12 /SPACE
13 Blank
14-16 A positive integer value from 1 through 112 that defines the
number of lines to space on the compiler listing. The number must
be left-adjusted.
If the number specified in positions 14 through 16 is greater than the number
of lines remaining on the current page, subsequent specifications begin on a
new page.
/SPACE is not printed on the compiler listing, but is replaced by the specified
line spacing. The line spacing caused by /SPACE is in addition to the two
lines that are skipped between specification types. If position 6 is blank, it
is considered to be equal to the preceding specification and the two lines are
not skipped.
ΓòÉΓòÉΓòÉ 1.2.1.4. /COPY (Positions 7-11) ΓòÉΓòÉΓòÉ
The /COPY compiler directive causes records from other files to be inserted, at
the point where the /COPY occurs, with the file being compiled. The inserted
files may contain any valid specification except /COPY.
The /COPY statement is entered in the following way:
Positions Entry
7-11 /COPY
12 Blank
13-44 Identifies the location of the member to be copied (merged). The
format is:
libraryname/filename,membername (RPG/400 AS/400 environment)
A member name must be specified.
If a file name is not specified, QRPGSRC is assumed.
If a library is not specified, the library list is searched for the file.
All occurrences of the specified source file in the library list are
searched for the member until it is located or the search is complete.
If a library is specified, a file name must also be specified.
45-49 Blank
50-80 Comments
Examples of the /COPY Compiler Directive Statement shows some examples of the
/COPY directive statement.
Note: Programs compiled under the AS/400 environment can use the extended
naming convention. If extended names are used, each part of the qualified name
must be enclosed in quotation marks.
For more information see How the Compiler Recognizes a Compiler /COPY,
Conditions on the Members That Are Copied, Sequence Numbering of the Listing
after a Compile, and Results of the /COPY during Compile.
ΓòÉΓòÉΓòÉ 1.2.1.4.1. How the Compiler Recognizes a Compiler /COPY ΓòÉΓòÉΓòÉ
Use the rules for RPG/400 symbolic names, to specify the library files and
member.
1. The CRTRPGPGM command will treat any /COPY directive encountered in the
source code as a compiler copy and does not accept the sorting or string
replacement functions.
Examples of the /COPY Compiler Directive Statement
C/COPY MBR1 1
I/COPY SRCFIL,MBR2 2
O/COPY SRCLIB/SRCFIL,MBR3 3
O/COPY "SRCLIB!"/"SRC>3","MBR^3" 4
1 Copies from member MBR1 in source file QRPGSRC. The current library list
is used to search for file QRPGSRC.
2 Copies from member MBR2 in file SRCFIL. The current library list is used
to search for file SRCFIL. Note that the comma is used to separate the
file name from the member name.
3 Copies from member MBR3 in file SRCFIL in library SRCLIB.
4 Copies from member "MBR^3" in file "SRC>3" in library "SRCLIB!"
ΓòÉΓòÉΓòÉ 1.2.1.4.2. Conditions on the Members That Are Copied ΓòÉΓòÉΓòÉ
If the member being copied from is not a source type file, meaning that the
file was not created with the filetype *SRC, then a message is issued. This
condition does not stop compilation and the copy function is still processed.
The members being copied can contain any valid RPG/400 specifications except
another /COPY directive.
The member being copied can contain a control specification (form type H),
which is then processed as if it were part of the source code. Therefore, the
first statement in the program can be a /COPY directive pointing to the member
containing the control specification. The H specification must still follow the
rules governing its use (refer to Control Specifications) and precede any other
RPG/400 specification.
ΓòÉΓòÉΓòÉ 1.2.1.4.3. Results of the /COPY during Compile ΓòÉΓòÉΓòÉ
During compilation, the specified file members are merged into the program at
the point where the /COPY statement occurs. Any overrides defined that apply to
the specified file and member are ignored.
ΓòÉΓòÉΓòÉ 1.2.1.4.4. Sequence Numbering of the Listing after a Compile ΓòÉΓòÉΓòÉ
For an RPG/400 compile, the low-order 6 digits of the 8-character sequence
number in the listing reflect the original source sequence number of the /COPY
member. In this way you can correlate the compiler listing sequence numbers
(the last 6 digits) to the source member sequence numbers (in SEU).
The high order 2 digits of the sequence number are made up of the characters A
through Z and 0 through 9 in the following order: A, B, C, ..., Z, 1, 2, ...,
9, A0, AA, AB, ..., AZ, A1, A2, ..., A9, B0, BA, ..., ZZ, ..., Z9, 10, ..., 99.
This structure allows for up to 1295 different increments of the high order
sequence number.
Each /COPY directive causes the high order 2 characters of the sequence number
for all the code lines brought in by this /COPY to be incremented in value.
If the copied code contains specifications for externally defined files, each
externally defined file may cause the high-order characters of the sequence
number to be incremented in value two more times: once for input
specifications, and once for output specifications.
If more than 1295 increments result from /COPY directives and/or externally
defined files, a message is issued. A message is also issued if more than 50
externally defined files are specified. Remember that one externally defined
file can take up two increments: for input and output specifications.
The low order 6 digits of the sequence number is incremented by one for each I
specification generated for an externally defined file.
If the program is compiled by RPG/400, records that are copied into the program
in this way contain a "+" adjacent to the sequence number field on the left
side of the listing, between the sequence number and the form type field. If
the Program Verifier is used, the lines from the copied file are identified on
the listing by line numbers which start at 100001. For example, the third line
in the first copied file would be 100003 and the seventh line of the fourth
copied file would be 400007.
Note: The /COPY directive is treated as a comment line. Because the compiler
may have to read ahead to gather sufficient information about specifications,
comments, or /COPY directives, certain lines may appear on the listing out of
sequence.
ΓòÉΓòÉΓòÉ 1.2.2. Common Entries ΓòÉΓòÉΓòÉ
The following entries are common to all RPG specifications:
Page (positions 1-2) and Line (positions 3-5). These are the equivalent of
source line number.
Specification type (position 6). The following letter codes can be used:
Entry Specification Type
H Control
F File description
E Extension
L Line counter
I Input
C Calculation
O Output
Program Identification (positions 75-80). Must be blank or program name on
the Control specification.
Comment Statements (* in position 7). On a comment statement or a compiler
directive, position 6 may be blank.
ΓòÉΓòÉΓòÉ <hidden> Specification Type Not Known ΓòÉΓòÉΓòÉ
The entry in position 6 of your specification is not valid. Select from the
following valid types.
Specification type. The following letter codes can be used:
Entry Specification Type
H Control
F File description
E Extension
L Line counter
I Input
C Calculation
O Output
Comment Statements (* in position 7). On a comment statement or a compiler
directive, position 6 may be blank.
Compiler Directive (blank in position 6). Select from the following entries
for positions 7-12.
- /COPY
- /EJECT
- /SPACE
- /TITLE
SQL delimeters (blank in position 6). You may use the following starting and
ending delimeters in positions 7-15.
- /EXEC SQL
- /END-EXEC
ΓòÉΓòÉΓòÉ 1.3. Control Specifications ΓòÉΓòÉΓòÉ
The control specification statement, identified by an H in column 6, provides
information about generating and running programs. Only one control
specification is allowed per program. In the OS/400 system, you can create a
data area named RPGHSPEC to contain the information to be used for all RPG/400
programs that do not contain a control specification.
The data area must be a character string 80 positions long. Use the CL command
CRTDTAARA (Create Data Area) to create the data area. Specify as the initial
value of the data area the entries for the control specification that are to be
used. For example, if the DEBUG operation is to be used for all RPG/400
programs, place an initial value of 1 in position 15 of the data area. (See
the Programming: Control Language Reference for a description of the Create
Data Area command.) The library in which the data area is placed must be in
the library list when the program is compiled.
If you are using Program Verifier on a program which uses the data area
RPGHSPEC you must create a file called RPGHSPEC.RPG and place it in the CODE
base directory. The installation default for that directory is D:|CODE. The
file should contain the same specifications as are in the RPGHSPEC data area
you would be using on the host.
The RPG/400 language uses the control specification that is present in the
program. In the OS/400 system, if a control specification is not present, the
RPG/400 compiler checks for the data area RPGHSPEC in *LIBL. If the data area
is not found, the RPG/400 compiler checks for the data area DFTHSPEC in QRPG.
If it is not found, a default specification with blanks in positions 7 through
74 is used, (no data area is created). Since QRPG is the product library for
the CRTRPGPGM command, if a data area called RPGHSPEC exists in QRPG it will
always be found. Use the data area DFTHSPEC in QRPG to create a common control
specification for your installation, and use RPGHSPEC in your library to
override this specification.
If a control specification is not present, Program Verifier will search for the
file RPGHSPEC.RPG in the CODE base directory. If that file is not found, a
default blank H specification will be used.
See the description of the individual entries for the meaning of blank entries
and for an explanation of the program name. If the default blank specification
is used, asterisks are printed on the compiler listing under the Page/Line
heading. Compiler-generated symbols are placed in the symbol table.
ΓòÉΓòÉΓòÉ 1.3.1. Control Specification Statement ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Positions 7-14 (Reserved)
Position 15 (Debug)
Positions 16-17 (Reserved)
Position 18 (Currency Symbol)
Position 19 (Date Format)
Position 20 (Date Edit)
Position 21 (Decimal Notation)
Positions 22-25 (Reserved)
Position 26 (Alternate Collating Sequence)
Positions 27-39 (Reserved)
Position 40 (Sign Handling)
Position 41 (Forms Alignment)
Position 42 (Reserved)
Position 43 (File Translation)
Positions 44-56 (Reserved)
Position 57 (Transparency Check)
Positions 58-74 (Reserved)
Positions 75-80 (Program Identification)
ΓòÉΓòÉΓòÉ 1.3.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An H must appear in position 6 to identify this line as the control
specification (or header) statement.
ΓòÉΓòÉΓòÉ 1.3.1.2. Positions 7-14 (Reserved) ΓòÉΓòÉΓòÉ
Positions 7 through 14 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.3. Position 15 (Debug) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank DEBUG and DUMP operations are not done. Compiler-generated symbols
are not placed in the symbol table.
1 DEBUG and DUMP operations are done. Compiler-generated symbols are
placed in the symbol table.
Use position 15 to indicate whether the DEBUG (Debug Function) and DUMP
(Program Dump) operations will be done. A 1 in position 15 when the source
program is compiled causes the compiler to generate the object code for these
operations. When the program is run, DEBUG and DUMP are performed.
The DEBUG entry also controls the contents of the symbol table that is produced
with the program. If position 15 contains a 1, the compiler-generated symbols,
starting with a period (.), are placed in the symbol table. If position 15 is
blank, the compiler-generated symbols are not placed in the symbol table. The
symbol table is printed with a program dump. You can then use the
compiler-generated symbols in debugging a program.
See the DEBUG and DUMP operations in Operation Codes for more information.
ΓòÉΓòÉΓòÉ 1.3.1.4. Positions 16-17 (Reserved) ΓòÉΓòÉΓòÉ
Positions 16 and 17 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.5. Position 18 (Currency Symbol) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank A dollar sign is used as the currency symbol in editing
(edit words and edit codes).
Currency Symbol Any character except zero (0), asterisk (*), comma (,),
period (.), ampersand (&), minus sign (-), the letter C,
or the letter R may be specified as the currency symbol.
The specification of a currency symbol does not affect the user-defined edit
codes 5 through 9.
ΓòÉΓòÉΓòÉ 1.3.1.6. Position 19 (Date Format) ΓòÉΓòÉΓòÉ
The entry in this position specifies the format of the RPG/400 user dates.
Entry Explanation
Blank Defaults to month/day/year if position 21 is blank. Defaults to
day/month/year if position 21 contains a D, I, or J.
M Month/day/year.
D Day/month/year.
Y Year/month/day.
ΓòÉΓòÉΓòÉ 1.3.1.7. Position 20 (Date Edit) ΓòÉΓòÉΓòÉ
Entry Explanation
Ampersand (&) Blank is used as the separator character
Any nonblank character The character entered is used as a separator
character
Blank The separator character follows the specification in
position 21.
The entry in this position specifies the separator character to be used with
the Y edit code.
ΓòÉΓòÉΓòÉ 1.3.1.8. Position 21 (Decimal Notation) ΓòÉΓòÉΓòÉ
The entry in this position specifies the notation for the user date. It also
specifies the decimal notation and the separator used for numeric literals and
edit codes. The term decimal notation refers to the character that separates
whole numbers from decimal fractions. The word separator refers to the
character that separates the hundreds position from the thousands position, the
hundred thousands position from the millions position, and so on. Below is an
example of a number using a period for the decimal notation character and
commas for the separator characters.
12,342,343.00
Γöé Γöé ΓööΓöÇΓöÇDecimal Notation
Separators
An entry in this position does not affect the edit words.
Entry Explanation
Blank Uses a period for the decimal notation, and a comma for the
separator. If position 19 is blank, uses the month/day/year
format for user date. If position 20 is blank, uses a slash as the
separator for the Y edit code.
I Uses a comma for the decimal notation, and a period for the
separator. If position 19 is blank, uses the day/month/year
format for user date. If position 20 is blank, uses a period as
the separator for the Y edit code.
J Uses a comma for the decimal notation, and a period for the
separator. If position 19 is blank, uses the day/month/year
format for user date. If position 20 is blank, uses a period as
the separator for the Y edit code. When you use edit codes that
cause zero balances to be printed, zero is written to the left of
the decimal notation (comma): 0,00. If the number of decimal
positions in the field is equal to the length of the field, the
decimal notation (comma) is the leftmost character printed.
D Uses a period for the decimal notation, and a comma for the
separator. If position 19 is blank, uses the day/month/year
format for user date. If position 20 is blank, uses a slash as the
separator for the Y edit code.
ΓòÉΓòÉΓòÉ 1.3.1.9. Positions 22-25 (Reserved) ΓòÉΓòÉΓòÉ
Positions 22 through 25 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.10. Position 26 (Alternate Collating Sequence) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Normal collating sequence is used.
S Alternate collating sequence is used.
Use position 26 to indicate whether an alternate collating sequence is to be
used for character compare operations or match fields.
ΓòÉΓòÉΓòÉ 1.3.1.11. Positions 27-39 (Reserved) ΓòÉΓòÉΓòÉ
Positions 27 through 39 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.12. Position 40 (Sign Handling) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The sign is always forced on input and output of zoned numeric
fields.
Position 40 must be blank to ensure a consistent + or - sign when data is
extracted or moved from or to numeric input or output fields. When data is
moved to unpacked numeric fields in output records, the valid external signs
are forced.
ΓòÉΓòÉΓòÉ 1.3.1.13. Position 41 (Forms Alignment) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank First line is printed only once.
1 First line can be printed repeatedly allowing the operator to
adjust the printer forms.
If the program contains more than one printer file, the entry in position 41
applies to each printer file that has 1P (first-page) output. This function may
also be specified by the CL command OVRPRTF (Override to Print File) or in the
printer device file and can be affected by the ALIGN option on the STRPRTWTR
command.
Use column 41 only when the first output line is written to a printer file.
When forms are first put in the printer, they may not be in the correct
position. Sometimes several lines must be printed to determine the correct
position. If you specify the 1P forms position, the system prints the first
line of output and issues a message. The operator can then line up the forms
and select the option from the message to print the line again or to continue
printing. The 1P forms specification is also valid if the output is spooled.
The page counter is not increased until the forms are positioned correctly.
ΓòÉΓòÉΓòÉ 1.3.1.14. Position 42 (Reserved) ΓòÉΓòÉΓòÉ
Position 42 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.15. Position 43 (File Translation) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No file translation is requested.
F Files are to be translated.
An entry of F indicates that a file translation table is to be used to
translate all data in specified files.
ΓòÉΓòÉΓòÉ 1.3.1.16. Positions 44-56 (Reserved) ΓòÉΓòÉΓòÉ
Positions 44 through 56 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.17. Position 57 (Transparency Check) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No check for transparency.
1 Check for transparency.
If you specify 1 in position 57 of the control specification, the RPG/400
compiler scans literals and constants for DBCS characters. It does not check
hexadecimal literals. For more information on transparency and DBCS data, see
Where You Can Use DBCS Data in RPG/400 Programs, Transparent Literals and
Constants, and Additional Considerations for Using DBCS Data in RPG/400
Programs.
ΓòÉΓòÉΓòÉ 1.3.1.18. Positions 58-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 58 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.3.1.19. Positions 75-80 (Program Identification) ΓòÉΓòÉΓòÉ
The symbolic name entered in these positions is the name of the program that
can be run. You can override this name with the PGM parameter in the CL command
CRTRPGPGM (Create RPG Program).
If you do not specify a name in positions 75 through 80 of the control
specification or on the CRTRPGPGM command, but the source is from a database
file, the member name is used as the program name. If the source is not from a
database file, the program name defaults to RPGOBJ.
If you specify the program name on the control specification, its maximum
length is 6 characters. If you specify the program name in the CRTRPGPGM
command, its maximum length is 10 characters.
Note: Names entered here must follow the RPG/400 symbolic name rules.
Extended names are not allowed. However, the name specified on the CRTRPGPGM
command can follow the extended naming rules.
ΓòÉΓòÉΓòÉ 1.4. File Description Specifications ΓòÉΓòÉΓòÉ
File description specifications identify each file used by a program. One
file-description specification statement is required for each file in the
program.
A maximum of 50 files can be described per program. Only one primary file can
be specified; however, the presence of a primary file is not required.
Only one record-address file is allowed per program. You can specify a maximum
of eight PRINTER files. The maximum number of other file types is limited only
by the maximum number of files allowed for the program.
Program-described files require more entries on the file-description
specifications than externally described files. Many of the entries required
for a program-described file are part of the external description for an
externally described file.
Enter the file-description specifications on the RPG/400 Control and File
Description Specifications.
You can specify the following file types:
Input
Output
Update
Combined (input/output).
You enter file-description specifications on the main file description line.
Additional details can be entered on the continuation lines.
ΓòÉΓòÉΓòÉ 1.4.1. File Description Specification Statement ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Positions 7-14 (File Name)
Position 15 (File Type)
- Input Files
- Output Files
- Update Files
- Combined Files
Position 16 (File Designation)
- Primary File
- Secondary File
- Record Address File
- Array or Table File
- Full Procedural File
Position 17 (End of File)
Position 18 (Sequence)
Position 19 (File Format)
Positions 20-23 (Reserved)
Positions 24-27 (Record Length)
Position 28 (Limits Processing)
Positions 29-30 (Length of Key or Record Address)
Position 31 (Record Address Type)
- Blank = Non-keyed Processing
- A = Character Keys
- P = Packed Keys
- K = Key
Position 32 (File Organization)
- Indexed Files
- Nonkeyed Program-Described File
- Record Address File
Positions 33-34 (Overflow Indicator)
Positions 35-38 (Key Field Starting Location)
Position 39 (Extension Code)
Positions 40-46 (Device)
Positions 47-52 (Reserved)
Position 53 (Continuation Lines)
Positions 54-59 (Routine)
Positions 60-65 (Reserved)
Position 66 (File Addition)
Positions 67-70 (Reserved)
Positions 71-72 (File Condition)
Positions 73-74 (Reserved)
Positions 75-80 (Comments)
Continuation Line
Continuation Line Summary Chart
Continuation Line Options Summary Chart
PRTCTL Data Structure
ΓòÉΓòÉΓòÉ 1.4.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An F must be entered in this position for file-description specifications.
ΓòÉΓòÉΓòÉ 1.4.1.2. Positions 7-14 (File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
A valid file name Every file used in a program must have a unique name. The
file name can be from 1 to 8 characters long, and must
begin in position 7.
Each file used in the program is identified by a unique symbolic name in
positions 7 through 14.
The file name specified in positions 7 through 14 must be an existing file name
that has been defined to the OS/400 system, or one of the OS/400 system
override commands must be used to associate the RPG/400 file name to the file
name defined to the OS/400 system. For an externally-described file, the file
must exist at both compilation time and at run time. For a program-described
file, the file need exist only at run time. The file name specified in these
positions, rather than the device name specified in positions 40 through 46, is
used to point to the file. When the files are opened at run time, they are
opened in the reverse order to that specified in the file-description
specifications. The RPG/400 device name defines the functions that can be
processed on the associated file.
You can specify file names in positions 7 through 14 that correspond to
predefined device-file definitions supplied by IBM.
ΓòÉΓòÉΓòÉ 1.4.1.2.1. Program Described File ΓòÉΓòÉΓòÉ
For program-described files, the file name entered in positions 7 through 14
must also be entered on:
Input specifications if the file is a primary, secondary, or full procedural
file
Output specifications or an output calculation operation line if the file is
an output, update, or combined file, or if the file is an input file and
records are also being added to the file
Extension specifications if the file is a table, array, or record address
file, or a file processed by a record-address file
Calculation specifications if the file name is required for the operation
code specified
Line counter specifications if the device is a printer and default values are
to be overridden.
ΓòÉΓòÉΓòÉ 1.4.1.2.2. Externally Described File ΓòÉΓòÉΓòÉ
For externally described files, the file name entered in positions 7 through 14
is the name used to locate the record descriptions for the file. The following
rules apply to externally described files:
Input and output specifications for externally described files are optional.
They are required only if you are adding RPG/400 functions, such as control
fields or record identifying indicators, to the external description
retrieved.
When an external description is retrieved, the record definition can be
referred to by its record format name on the input, output, or calculation
specifications.
A record format name must be a unique symbolic name.
A logical file with two record formats of the same name cannot have the
duplicate format names renamed and cannot be externally described. However,
such a file can be accessed if it is program described.
ΓòÉΓòÉΓòÉ 1.4.1.3. Position 15 (File Type) ΓòÉΓòÉΓòÉ
Entry Explanation
I Input file
O Output file
U Update file
C Combined (input/output) file.
ΓòÉΓòÉΓòÉ 1.4.1.3.1. Input Files ΓòÉΓòÉΓòÉ
An input file is one from which a program reads information. It can contain
data records, arrays, or tables, or it can be a record-address file.
ΓòÉΓòÉΓòÉ 1.4.1.3.2. Output Files ΓòÉΓòÉΓòÉ
An output file is a file to which information is written.
ΓòÉΓòÉΓòÉ 1.4.1.3.3. Update Files ΓòÉΓòÉΓòÉ
An update file is an input file whose records can be updated. Updating alters
the data in one or more fields of any record contained in the file and writes
that record back to the same file from which it was read. If records are to be
deleted, the file must be specified as an update file.
ΓòÉΓòÉΓòÉ 1.4.1.3.4. Combined Files ΓòÉΓòÉΓòÉ
A combined file is both an input file and an output file. When a combined file
is processed, the output record contains only the data represented by the
fields in the output record. This differs from an update file, where the
output record contains the input record modified by the fields in the output
record.
A combined file is valid for a SPECIAL or WORKSTN file. A combined file is also
valid for a DISK or SEQ file if position 16 contains T (an array or table
replacement file).
ΓòÉΓòÉΓòÉ 1.4.1.4. Position 16 (File Designation) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Output file
P Primary file
S Secondary file
R Record address file
T Array or table file
F Full procedural file
ΓòÉΓòÉΓòÉ 1.4.1.4.1. Primary File ΓòÉΓòÉΓòÉ
When several files are processed by cycle processing, one must be designated as
the primary file. In multifile processing, processing of the primary file takes
precedence. Only one primary file is allowed per program.
ΓòÉΓòÉΓòÉ 1.4.1.4.2. Secondary File ΓòÉΓòÉΓòÉ
When more than one file is used during cycle-controlled programming, secondary
files are input files. The processing of secondary files is determined by the
order in which they are specified in the file-description specifications and on
the rules of multifile logic.
ΓòÉΓòÉΓòÉ 1.4.1.4.3. Record Address File ΓòÉΓòÉΓòÉ
A record-address file is a sequentially organized file used to select records
from another file. Only one file in a program can be specified as a
record-address file. This file is described on the file-description and
extension specifications and not on the input specifications. The file
processed by the record-address file must also be specified on the extension
specifications and must be a primary, secondary, or full procedural file.
You cannot specify a record-address file for the device SPECIAL. You cannot
specify an externally described file as a record-address file; however, you can
use a record-address file to process a program described file or an externally
described file.
A record-address file that contains relative-record numbers must also have a T
specified in position 32 and an F in position 19.
ΓòÉΓòÉΓòÉ 1.4.1.4.4. Array or Table File ΓòÉΓòÉΓòÉ
Array and table files specified by a T in position 16 are loaded at program
initialization time. The array or table file can be input or combined. Leave
this entry blank for array or table output files. You cannot specify SPECIAL as
the device for array and table input files. You cannot specify an externally
described file as an array or table file.
If T is specified in position 16, you can specify C in position 15 for a DISK
or SEQ file. This C allows an array or table file to be read from or written to
the same file (an array or table replacement file). The To and From file names
on the extension specifications must specify this file name.
ΓòÉΓòÉΓòÉ 1.4.1.4.5. Full Procedural File ΓòÉΓòÉΓòÉ
This entry is used when the input is controlled by calculation operations. File
operation codes such as CHAIN or READ are used to do input functions.
ΓòÉΓòÉΓòÉ 1.4.1.5. Position 17 (End of File) ΓòÉΓòÉΓòÉ
Entry Explanation
E All records from the file must be processed before the program can
end. This entry is not valid for files processed by a
record-address file.
Blank If position 17 is blank for all files, all records from all files
must be processed before end of program (LR) can occur. If
position 17 is not blank for all files, all records from this file
may or may not be processed before end of program occurs in
multifile processing.
Use position 17 to indicate whether the program can end before all records from
the file are processed. An E in position 17 applies only to input, update, or
combined files specified as primary, secondary, or record-address files.
If the records from all primary and secondary files must be processed, position
17 must be blank for all files or must contain E's for all files. For multiple
input files, the end-of-program (LR) condition occurs when all input files for
which an E is specified in position 17 have been processed. If position 17 is
blank for all files, the end-of-program condition occurs when all input files
have been processed.
When match fields are specified for two or more files and an E is specified in
position 17 for one or more files, the LR indicator is set on after:
The end-of-file condition occurs for the last file with an E specified in
position 17.
The program has processed all the records in other files that match the last
record processed from the primary file.
The program has processed the records in those files without match fields up
to the next record with nonmatching match fields.
When no file or only one file contains match field specifications, no records
of other files are processed after end of file occurs on all files for which an
E is specified in position 17.
ΓòÉΓòÉΓòÉ 1.4.1.6. Position 18 (Sequence) ΓòÉΓòÉΓòÉ
Entry Explanation
A or blank Match fields are in ascending sequence.
D Match fields are in descending sequence.
Position 18 specifies the sequence of input fields used with the match fields
specification (positions 61 and 62 of the input specifications). Position 18
applies only to input, update, or combined files used as primary or secondary
files. Use positions 61 and 62 of the input specifications to identify the
fields containing the sequence information.
If more than one input file with match fields is specified in the program, a
sequence entry in position 18 can be used to check the sequence of the match
fields and to process the file using the matching record technique. The
sequence need only be specified for the first file with match fields specified.
If sequence is specified for other files, the sequence specified must be the
same; otherwise, the sequence specified for the first file is assumed.
If only one input file with match fields is specified in the program, a
sequence entry in position 18 can be used to check fields of that file to
ensure that the file is in sequence. By entering one of the codes M1 through
M9 in positions 61 and 62 of the input specifications, and by entering an A or
D in position 18, you specify sequence checking of these fields.
Sequence checking is required when match fields are used in the records from
the file. When a record from a matching input file is found to be out of
sequence, the RPG/400 exception/error handling routine is given control.
ΓòÉΓòÉΓòÉ 1.4.1.7. Position 19 (File Format) ΓòÉΓòÉΓòÉ
Entry Explanation
F Program described file
E Externally described file
An F in position 19 indicates that the records for the file are described
within the RPG/400 program on input/output specifications.
An E in position 19 indicates that the record descriptions for the file are
external to the RPG/400 source program. The compiler obtains these descriptions
at compilation time and includes them in the source program.
An entry is required in position 19.
ΓòÉΓòÉΓòÉ 1.4.1.8. Positions 20-23 (Reserved) ΓòÉΓòÉΓòÉ
Positions 20 through 23 must be blank. (Block length, if allowed, is specified
outside the RPG/400 program.)
ΓòÉΓòÉΓòÉ 1.4.1.9. Positions 24-27 (Record Length) ΓòÉΓòÉΓòÉ
Use positions 24 through 27 to indicate the length of the logical records
contained in a program-described file. The maximum record size that can be
specified is 9999; however, record-size constraints of any device may override
this value. This entry must be blank for externally described files.
If the file being defined is a record-address file and the record length
specified is 3, it is assumed that each record in the file consists of a 3-byte
binary field for the relative-record numbers starting at offset 0. If the
record length is 4 or greater, each relative-record number in the
record-address file is assumed to be a 4-byte field starting at offset 1. If
the record length is left blank, the actual record length is retrieved at run
time to determine how to handle the record-address file.
If the file opened at run time has a primary record length of 3, then 3-byte
relative-record numbers (one per record) are assumed; otherwise, 4-byte
relative-record numbers are assumed. This support can be used to allow RPG/400
programs to use System/36 environment SORT files as record-address files.
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé Valid Combinations for a RAF Table File Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé RECORD LENGTH Γöé RAF LENGTH Γöé TYPE OF SUPPORT Γöé
Γöé POSITIONS Γöé POSITIONS Γöé Γöé
Γöé 24-27 Γöé 29-30 Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Blank Γöé Blank Γöé Support determined at run Γöé
Γöé Γöé Γöé time. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 3 Γöé 3 Γöé System/36 support. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé > = 4 Γöé 4 Γöé Native support. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.4.1.10. Position 28 (Limits Processing) ΓòÉΓòÉΓòÉ
Entry Explanation
L Sequential-within-limits processing by a record-address file
Blank Sequential or random processing
Use position 28 to indicate whether the file is processed by a record-address
file that contains limits records.
A record-address file used for limits processing contains records that consist
of upper and lower limits. Each record contains a set of limits that consists
of the lowest record key and the highest record key from the segment of the
file to be processed. Limits processing can be used for keyed files specified
as primary, secondary, or full procedural files.
The L entry in position 28 is valid only if the file is processed by a
record-address file containing limits records. Random and sequential
processing of files is implied by a combination of positions 16 and 31 of the
file-description specifications, and by the calculation operation specified.
The operation codes SETLL (Set Lower Limit) and SETGT (Set Greater Than) can be
used to position a file; however, the use of these operation codes does not
require an L in position 28.
For more information on limits processing, refer to the RPG/400* User's Guide.
ΓòÉΓòÉΓòÉ 1.4.1.11. Positions 29-30 (Length of Key or Record Address) ΓòÉΓòÉΓòÉ
Entry Explanation
1-99 The number of positions required for the key field in a program
described file or the length of the entries in the record-address
file (which must be a program-described file).
If the program-described file being defined uses keys for record
identification, enter the number of positions occupied by each
record key. This entry is required for indexed files.
If the keys are packed, the key field length should be the packed
length; this is the number of digits in DDS divided by 2 plus 1
and ignoring any fractions.
If the file being defined is a record-address file, enter the
number of positions that each entry in the record-address file
occupies.
Blank These positions must be blank for externally described files.
(The key length is specified in the external description.) For a
program-described file, a blank entry indicates that keys are not
used. Positions 29-30 can also be blank for a record-address file
with a blank in positions 24-27 (record length).
ΓòÉΓòÉΓòÉ 1.4.1.12. Position 31 (Record Address Type) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Relative record numbers are used to process the file.
Records are read consecutively.
Record address file contains relative-record numbers.
Keys in record-address-limits file are in the same format as keys
in the file being processed.
A Character keys (valid only for program-described files specified
as indexed files or as a record-address-limits file).
P Packed keys (valid only for program-described files specified as
indexed files or as a record-address-limits file).
K Key values are used to process the file. This entry is valid only
for externally described files.
ΓòÉΓòÉΓòÉ 1.4.1.12.1. Blank = Non-keyed Processing ΓòÉΓòÉΓòÉ
A blank indicates that the file is processed without the use of keys, that the
record-address file contains relative-record numbers (a T in position 32), or
that the keys in a record-address-limits file are in the same format as the
keys in the file being processed.
A file processed without keys can be processed consecutively or randomly by
relative-record number.
Input processing by relative-record number is determined by a blank in position
31 and by the use of the CHAIN, SETLL, or SETGT operation code. Output
processing by relative-record number is determined by a blank in position 31
and by the use of the RECNO keyword on the file description specifications.
ΓòÉΓòÉΓòÉ 1.4.1.12.2. A = Character Keys ΓòÉΓòÉΓòÉ
The indexed file (I in position 32) defined on this line is processed by
character-record keys. (A numeric field used as the search argument is
converted to zoned decimal before chaining.) The A entry must agree with the
data format of the field identified as the key field (length in positions 29
and 30 and starting position in positions 35 through 38).
The record-address-limits file (R in position 16) defined on this line contains
character keys. The file being processed by this record address file can have
an A, P, or K in position 31.
ΓòÉΓòÉΓòÉ 1.4.1.12.3. P = Packed Keys ΓòÉΓòÉΓòÉ
The indexed file (I in position 32) defined on this line is processed by
packed-decimal-numeric keys. The P entry must agree with the data format of
the field identified as the key field (length in positions 29 and 30 and
starting position in positions 35 through 38).
Note: The sign of all decimal numeric input fields is forced to F or D. All
numeric result fields specified by calculation specifications also have an F or
D sign. Therefore, if the sign of the key field in the file is not F or D, a
record-not-found error occurs when you retrieve that file.
The record-address-limits file defined on this line contains record keys in
packed decimal format. The file being processed by this record address file
can have an A, P, or K in position 31.
ΓòÉΓòÉΓòÉ 1.4.1.12.4. K = Key ΓòÉΓòÉΓòÉ
A K entry indicates that the externally described file is processed on the
assumption that the access path is built on key values. If the processing is
random, key values are used to identify the records.
If this position is blank for a keyed file, the records are retrieved in
arrival sequence.
For more information on record address type, refer to the RPG/400* User's
Guide.
ΓòÉΓòÉΓòÉ 1.4.1.13. Position 32 (File Organization) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The program-described file is processed without keys, or the file
is externally described.
I Indexed file (valid only for program-described files).
T Record address file that contains relative-record numbers (valid
only for program-described files).
Use position 32 to identify the organization of program described files.
ΓòÉΓòÉΓòÉ 1.4.1.13.1. Indexed Files ΓòÉΓòÉΓòÉ
An indexed file can be processed:
Randomly or sequentially by key
By a record-address file (sequentially within limits). Position 28 must
contain an L.
ΓòÉΓòÉΓòÉ 1.4.1.13.2. Nonkeyed Program-Described File ΓòÉΓòÉΓòÉ
A program-described file that is processed without keys can be processed:
Randomly by relative-record numbers, positions 28 and 31 must be blank.
Entry Sequence, positions 28 and 31 must be blank.
As a record-address file, position 28 must be blank.
ΓòÉΓòÉΓòÉ 1.4.1.13.3. Record Address File ΓòÉΓòÉΓòÉ
A record-address file (indicated by an R in position 16) that contains
relative-record numbers must be identified by a T in position 32. (A
record-address file must be program described.) Each record retrieved from the
file being processed is based on the relative record number in the
record-address file. (Relative record numbers cannot be used for a
record-address-limits file.)
Each relative-record number in the record-address file is a 4-byte binary
field; therefore, each 4-byte unit of a record-address file contains a
relative-record number. A minus one (-1 or hexadecimal FFFFFFFF )
relative-record number value causes the record to be skipped. End of file
occurs when all record-address file records have been processed.
For more information on how to handle System/36 Environment record-address
files, see the RPG/400* User's Guide.
ΓòÉΓòÉΓòÉ 1.4.1.14. Positions 33-34 (Overflow Indicator) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No overflow indicator is used.
OA-OG, OV Specified overflow indicator conditions the lines to be
printed when overflow occurs.
01-99 Set on when a line is printed on the overflow line, or the
overflow line is reached or passed during a space or skip
operation.
Indicators OA through OG, and OV are not valid for externally described files.
Use positions 33 and 34 to specify an overflow indicator to condition which
lines in each PRINTER file will be printed when overflow occurs. This entry is
valid only for a PRINTER device. Overflow only occurs if defined.
Only one overflow indicator can be assigned to a file. If more than one PRINTER
file in a program is assigned an overflow indicator, that indicator must be
unique for each file.
ΓòÉΓòÉΓòÉ 1.4.1.15. Positions 35-38 (Key Field Starting Location) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Key fields are not used for this program-described file, or the
file is externally described.
1-9999 Record position in a program described indexed file in which the
key field begins.
Use positions 35 through 38 to identify the record position in which the key
field for a program described indexed file begins. An entry must be made in
these positions for a program described indexed file. The key field of a record
contains the information that identifies the record. The key field must be in
the same location in all records in the file. The entry in these positions must
be right-adjusted. Leading zeros can be omitted.
ΓòÉΓòÉΓòÉ 1.4.1.16. Position 39 (Extension Code) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No extension or line-counter specifications are used.
E Extension specifications further describe the file.
L Line counter specifications further describe the file.
Use position 39 to indicate whether the program-described file is further
described on the extension specifications or on the line counter
specifications. An E in position 39 applies only to array or table files or to
record-address files; an L in position 39 applies to files assigned to the
PRINTER device.
ΓòÉΓòÉΓòÉ 1.4.1.17. Positions 40-46 (Device) ΓòÉΓòÉΓòÉ
Entry Explanation
PRINTER File is a printer file, a file with control characters that can be
sent to a printer.
DISK File is a disk file. This device supports sequential and random
read/write functions. These files can be accessed on a remote
system by Distributed Data Management (DDM).
WORKSTN File is a workstation file. Input/output is through a display or
ICF file.
SPECIAL This is a special file. Input or output is on a device that is
accessed by a user-supplied routine. The name of the routine must
be specified in positions 54 through 59. A parameter list is
created for use with this routine, including an option code
parameter and a status code parameter. The file must be a fixed
unblocked format.
SEQ File is a sequentially organized file. The actual device is
specified in a CL command or in the file description, which is
accessed by the file name.
Use positions 40 through 46 to specify the RPG/400 device name to be associated
with the file. On the AS/400 system the file name in positions 7 through 14,
rather than the device name specified in positions 40 through 46, is used to
point to the file. The RPG/400 device name defines the RPG/400 functions that
can be done on the associated file. Certain functions are valid only for a
specific RPG/400 device name, such as the EXFMT operation for WORKSTN. The file
name specified in positions 7 through 14 can be overridden at compilation time
or run time, allowing you to change the input/output device used in the
program.
Note that the RPG/400 device names are not the same as the system device names.
ΓòÉΓòÉΓòÉ 1.4.1.18. Positions 47-52 (Reserved) ΓòÉΓòÉΓòÉ
Positions 47 through 52 must be blank.
ΓòÉΓòÉΓòÉ 1.4.1.19. Position 53 (Continuation Lines) ΓòÉΓòÉΓòÉ
A K in position 53 indicates a continuation line. See Continuation Line for
more information.
ΓòÉΓòÉΓòÉ 1.4.1.20. Positions 54-59 (Routine) ΓòÉΓòÉΓòÉ
When SPECIAL is the device entry (positions 40 through 46), the routine named
in positions 54 through 59 handles the support for the special I/O device. The
routine name must be left-adjusted. The name is used by the compiler to produce
the linkage to the routine.
ΓòÉΓòÉΓòÉ 1.4.1.21. Positions 60-65 (Reserved) ΓòÉΓòÉΓòÉ
Positions 60 through 65 must be blank.
ΓòÉΓòÉΓòÉ 1.4.1.22. Position 66 (File Addition) ΓòÉΓòÉΓòÉ
Position 66 indicates whether records are to be added to a DISK file.
Entry Explanation
Blank No records can be added to an input or update file (I or U in
position 15). For an output file (O in position 15), a blank is
equivalent to an A.
A Add records to the file. Positions 16 through 18 of the output
record specifications for this file must contain ADD, or the WRITE
operation code must be used in the calculation specifications.
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé Processing Functions for Files Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Γöé FILE Γöé FILE Γöé Γöé
Γöé Γöé DESCRIPTIONΓöé DESCRIPTIONΓöé OUTPUT Γöé
Γöé Γöé SPECIFICA- Γöé SPECIFICA- Γöé SPECIFICA- Γöé
Γöé FUNCTION Γöé TIONS Γöé TIONS Γöé TIONS Γöé
Γöé Γöé POSITION Γöé POSITION Γöé POSITIONS Γöé
Γöé Γöé 15 Γöé 66 Γöé 16-18 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Create new file(1) Γöé O Γöé Blank Γöé Blank Γöé
Γöé Γöé Γöé Γöé Γöé
Γöé or Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Γöé Γöé
Γöé Add records to existing Γöé O Γöé A Γöé ADD Γöé
Γöé file Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Process file Γöé I Γöé Blank Γöé Blank Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Process file and add Γöé I Γöé A Γöé ADD Γöé
Γöé records to the existing Γöé Γöé Γöé Γöé
Γöé file Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Process file and update Γöé U Γöé Blank Γöé Blank Γöé
Γöé the records (update or Γöé Γöé Γöé Γöé
Γöé delete) Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Process file and add Γöé U Γöé A Γöé ADD Γöé
Γöé new records to an Γöé Γöé Γöé Γöé
Γöé existing file Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Process file and delete Γöé U Γöé Blank Γöé DEL Γöé
Γöé an existing record from Γöé Γöé Γöé Γöé
Γöé the file Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé (1)Within RPG, the term create a new file means to add records Γöé
Γöé to a newly created file. Thus, the first two entries in this Γöé
Γöé table perform the identical function. Both are listed to show Γöé
Γöé that there are two ways to specify that function. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.4.1.23. Positions 67-70 (Reserved) ΓòÉΓòÉΓòÉ
Positions 67 through 70 must be blank.
ΓòÉΓòÉΓòÉ 1.4.1.24. Positions 71-72 (File Condition) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The file can be used by the program, and, if it is an input file,
the file is opened.
U1-U8 The file can be used by the program when the indicator is on; it
is ignored when the indicator is off.
UC Programmer control of first open. If a file is to be initially
opened by the OPEN operation in the calculation specifications,
then a UC entry causes the file not to be opened at program
initialization. This entry is not valid for input files
designated as primary, secondary, table, or record-address files,
or for output files conditioned by the 1P indicator.
An entry of U1 through U8 in positions 71 and 72 lets the programmer control
the operation of input, output, update, and combined files at run time. If the
specified indicator is on at program initialization, the file is opened. If
the indicator is not on, the file is not opened and is ignored during
processing. The U1 through U8 indicators can be set as follows:
By the OS/400 control language.
When used as a resulting indicator for a calculation operation or as field
indicators on the input specifications. Setting the U1 through U8 indicators
in this manner has no effect on file conditioning.
The UC entry is required for programmer control of only the first file opening.
If a file is opened and later is closed by the CLOSE operation, the programmer
can reopen the file (by the OPEN operation) and the UC entry is not required in
positions 71 and 72.
ΓòÉΓòÉΓòÉ 1.4.1.25. Positions 73-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 73 and 74 must be blank.
ΓòÉΓòÉΓòÉ 1.4.1.26. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 to 80 can be used for comments, or left blank. These positions are
not printed contiguously with positions 6-74 on the compiler listing.
ΓòÉΓòÉΓòÉ 1.4.2. File Types and Processing Methods ΓòÉΓòÉΓòÉ
The following table shows the valid entries for positions 28, 31, and 32 of the
file-description specifications for the various file types and processing
methods. The methods of disk file processing include:
Relative-record-number processing
Consecutive processing
Sequential-by-key processing
Random-by-key processing
Sequential-within-limits processing.
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé Processing Methods for DISK Files Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ACCESSΓöé METHODΓöé OPCODEΓöé POSI- Γöé POSI- Γöé POSI- Γöé EXPLANATION Γöé
Γöé Γöé Γöé Γöé TION Γöé TION Γöé TION Γöé Γöé
Γöé Γöé Γöé Γöé 28 Γöé 31 Γöé 32 Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé RandomΓöé RRN Γöé CHAIN Γöé Blank Γöé Blank Γöé Blank Γöé Access by Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé physical Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé order of Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé records Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SequenΓöéiKey Γöé READ Γöé Blank Γöé Blank Γöé I Γöé Access by key Γöé
Γöé Γöé Γöé READE Γöé Γöé Γöé Γöé sequentially Γöé
Γöé Γöé Γöé READP Γöé Γöé Γöé Γöé Γöé
Γöé Γöé Γöé REDPE Γöé Γöé Γöé Γöé Γöé
Γöé Γöé Γöé cycle Γöé Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SequenΓöéiWithinΓöé READ Γöé L Γöé A or Γöé I Γöé Access by key Γöé
Γöé Γöé LimitsΓöé READE Γöé Γöé P Γöé Γöé sequentially Γöé
Γöé Γöé Γöé READP Γöé Γöé Γöé Γöé controlled by Γöé
Γöé Γöé Γöé REDPE Γöé Γöé Γöé Γöé record- Γöé
Γöé Γöé Γöé cycle Γöé Γöé Γöé Γöé address- Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé limits file Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SequenΓöéiRRN Γöé READ Γöé Blank Γöé Blank Γöé T Γöé Access Γöé
Γöé Γöé Γöé READE Γöé Γöé Γöé Γöé sequentially Γöé
Γöé Γöé Γöé READP Γöé Γöé Γöé Γöé restricted to Γöé
Γöé Γöé Γöé REDPE Γöé Γöé Γöé Γöé RRN numbers Γöé
Γöé Γöé Γöé cycle Γöé Γöé Γöé Γöé in RAF file Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.4.2.1. Random-by-Key Processing ΓòÉΓòÉΓòÉ
For the random-by-key method of processing, you specify a search argument that
identifies the key of the record to be read in factor 1 of the calculation
specifications for the CHAIN operation. See the section on "Keyed Processing
Examples" in Chapter 7 of the RPG/400* User's Guide for an example of an
externally described DISK file being processed randomly by key. The specified
record can be read from the file either during detail calculations or during
total calculations.
The random-by-key method of processing is valid for a full-procedural file
designated as an input file or an update file.
For an externally described file, position 31 of the file description
specifications must contain K, which indicates that the file is processed
according to an access path that is built on keys. The data description
specifications for the file specifies the field that contains the key value
(the key field). Position 32 of the file-description specifications must be
blank.
You must designate a program-described file as an indexed file (I in position
32), and position 31 of the file-description specifications must contain an A
or a P. The length of the key field is identified in positions 29 and 30 of the
file-description specifications, and the starting location of the key field is
identified in positions 35 through 38. Data description specifications must be
used to create the access path for a program-described input file. Refer to the
section "Indexed File" in chapter 7 of the RPG/400* User's Guide.
ΓòÉΓòÉΓòÉ 1.4.3. Continuation Line ΓòÉΓòÉΓòÉ
Continuation lines can be specified on the file description specification to
provide additional information about the file being defined. Any number of
continuation lines can be specified. A continuation line is indicated by a K in
position 53.
A continuation line can be specified on the main file-description specification
line if the functions use positions 54 through 65 for their definition;
however, the keywords SFILE, RENAME, IGNORE, and PLIST cannot be defined there.
To specify the continuation line information on the main file description
specification line, enter K in position 53 and the valid entries in positions
54 through 67. See Continuation Line Summary Chart for more information.
ΓòÉΓòÉΓòÉ 1.4.3.1. Continuation Line Summary Chart ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé Continuation Line Summary Chart Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé POSI- Γöé NAME Γöé ENTRY Γöé EXPLANATION Γöé
Γöé TIONS Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 1-2 Γöé Page Γöé Page Γöé Entry assigns a page number Γöé
Γöé Γöé Γöé number Γöé to each specification form. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 3-5 Γöé Line Γöé Line Γöé Entry numbers the specifica- Γöé
Γöé Γöé Γöé number Γöé tion line. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 6 Γöé Form Γöé F Γöé Identification for a file Γöé
Γöé Γöé type Γöé Γöé description specification. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 7-18 Γöé Γöé Blank Γöé These positions must be blank Γöé
Γöé Γöé Γöé Γöé for a separate continuation Γöé
Γöé Γöé Γöé Γöé line. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 19-28 Γöé Γöé External Γöé These positions are used to Γöé
Γöé Γöé Γöé name of Γöé specify the external name of Γöé
Γöé Γöé Γöé record Γöé the record format that is to Γöé
Γöé Γöé Γöé format Γöé be renamed ("RENAME") or Γöé
Γöé Γöé Γöé Γöé ignored ("IGNORE"). Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 29-46 Γöé Γöé Blank Γöé These positions must be blank Γöé
Γöé Γöé Γöé Γöé for a separate continuation Γöé
Γöé Γöé Γöé Γöé line. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 47-52 Γöé Record Γöé Numeric Γöé For the "SFILE" options, Γöé
Γöé Γöé number Γöé field Γöé these positions must specify Γöé
Γöé Γöé field Γöé name Γöé the name of a Relative Record Γöé
Γöé Γöé for Γöé Γöé Number ("RECNO") field. For Γöé
Γöé Γöé "SFILE" Γöé Γöé other continuation line Γöé
Γöé Γöé Γöé Γöé options, these positions must Γöé
Γöé Γöé Γöé Γöé be blank. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 53 Γöé Contin- Γöé K Γöé Indicates a continuation Γöé
Γöé Γöé uation Γöé Γöé line. Γöé
Γöé Γöé line Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 54-59, Γöé Γöé Γöé These positions are used Γöé
Γöé 60-67 Γöé Γöé Γöé together. Positions 54 Γöé
Γöé Γöé Γöé Γöé through 59 specify the Γöé
Γöé Γöé Γöé Γöé option, while positions 60 Γöé
Γöé Γöé Γöé Γöé through 67 provide further Γöé
Γöé Γöé Γöé Γöé explanation of the option. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 68-74 Γöé Γöé Blank Γöé These positions must be blank Γöé
Γöé Γöé Γöé Γöé for a separate continuation Γöé
Γöé Γöé Γöé Γöé line. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 75-80 Γöé Γöé Optional Γöé This space is available for Γöé
Γöé Γöé Γöé Γöé comments. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.4.3.2. Continuation Line Options Summary Chart ΓòÉΓòÉΓòÉ
The valid entries for positions 54 through 67 are:
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé Continuation Line Options Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé OPTION Γöé ENTRY Γöé EXPLANATION Γöé
Γöé (54-59) Γöé (60-67) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "COMIT" Γöé Blank Γöé This file is specified for commitment Γöé
Γöé Γöé Γöé control. Use the "COMIT" and "ROLBK" Γöé
Γöé Γöé Γöé operation codes to group changes to this Γöé
Γöé Γöé Γöé file so that the changes all happen Γöé
Γöé Γöé Γöé together, or do not happen at all. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "ID" Γöé Field Γöé Positions 60-65 contain the left- Γöé
Γöé Γöé name Γöé justified name of a 10-character alpha- Γöé
Γöé Γöé Γöé numeric field which need not be further Γöé
Γöé Γöé Γöé defined. This field contains the name Γöé
Γöé Γöé Γöé of the program device that supplied the Γöé
Γöé Γöé Γöé record processed in the file. The field Γöé
Γöé Γöé Γöé is updated each time a record is read Γöé
Γöé Γöé Γöé from a file. Also, you may move a Γöé
Γöé Γöé Γöé program device name into this field to Γöé
Γöé Γöé Γöé direct an output or device-specific Γöé
Γöé Γöé Γöé input operation (other than a Γöé
Γöé Γöé Γöé "READ"-by-file-name or an implicit cycle Γöé
Γöé Γöé Γöé read) to a different device. When Γöé
Γöé Γöé Γöé moving a literal into the field, blank Γöé
Γöé Γöé Γöé the field first, and use the "MOVEL" Γöé
Γöé Γöé Γöé operation to place the literal left- Γöé
Γöé Γöé Γöé justified in the field. Initially, the Γöé
Γöé Γöé Γöé field is blank. A blank field indicates Γöé
Γöé Γöé Γöé the requester device. If the requester Γöé
Γöé Γöé Γöé device is not acquired for your file, Γöé
Γöé Γöé Γöé you must not use a blank field. The Γöé
Γöé Γöé Γöé "ID" field is maintained for each call Γöé
Γöé Γöé Γöé to a program. If you call program B Γöé
Γöé Γöé Γöé from within program A, the "ID" field Γöé
Γöé Γöé Γöé for program A is not affected. Program Γöé
Γöé Γöé Γöé B uses a separate "ID" field. When you Γöé
Γöé Γöé Γöé return to program A, its "ID" field has Γöé
Γöé Γöé Γöé the same value as it had before you Γöé
Γöé Γöé Γöé called program B. If program B needs to Γöé
Γöé Γöé Γöé know which devices are acquired to Γöé
Γöé Γöé Γöé program A, program A must pass this Γöé
Γöé Γöé Γöé information (as a parameter list) when Γöé
Γöé Γöé Γöé it calls program B. When you specify Γöé
Γöé Γöé Γöé "ID" but not "NUM", the RPG/400 program Γöé
Γöé Γöé Γöé assumes "NUM" is present with a value of Γöé
Γöé Γöé Γöé 1. To determine the name of the Γöé
Γöé Γöé Γöé requester device, you may look in the Γöé
Γöé Γöé Γöé appropriate area of the file information Γöé
Γöé Γöé Γöé data structure. Or, you may process one Γöé
Γöé Γöé Γöé of the input or output operations Γöé
Γöé Γöé Γöé described above with the "ID" field Γöé
Γöé Γöé Γöé blank. After the operation, the "ID" Γöé
Γöé Γöé Γöé field has the name of the requester Γöé
Γöé Γöé Γöé device. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "IGNORE" Γöé Blank Γöé This option lets you ignore a record Γöé
Γöé Γöé Γöé format from an externally described Γöé
Γöé Γöé Γöé file. On the continuation line, posi- Γöé
Γöé Γöé Γöé tions 19 through 28 specify the external Γöé
Γöé Γöé Γöé name of the record format to be ignored, Γöé
Γöé Γöé Γöé and positions 60 through 67 must be Γöé
Γöé Γöé Γöé blank. The program runs as if the Γöé
Γöé Γöé Γöé record format did not exist. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "IND" Γöé Indi- Γöé Indicators from 01 to the number speci- Γöé
Γöé Γöé cator Γöé fied are saved and restored for each Γöé
Γöé Γöé number Γöé device attached to a mixed or multiple Γöé
Γöé Γöé Γöé device file. Before an input operation, Γöé
Γöé Γöé Γöé the indicators for the device associated Γöé
Γöé Γöé Γöé with the previous input or output opera- Γöé
Γöé Γöé Γöé tion are saved. After the input opera- Γöé
Γöé Γöé Γöé tion, the indicators for the device Γöé
Γöé Γöé Γöé associated with this current input oper- Γöé
Γöé Γöé Γöé ation are restored. Specify a number Γöé
Γöé Γöé Γöé from 01 through 99, right-justified, in Γöé
Γöé Γöé Γöé positions 60 through 65. No indicators Γöé
Γöé Γöé Γöé are saved and restored if "IND" is not Γöé
Γöé Γöé Γöé specified or if the option "NUM" has the Γöé
Γöé Γöé Γöé entry 1. If you specified the keyword Γöé
Γöé Γöé Γöé "INDARA", the number you specify for Γöé
Γöé Γöé Γöé "IND" must be less than any response Γöé
Γöé Γöé Γöé indicator you use in your DDS. For Γöé
Γöé Γöé Γöé example, if you specify "INDARA" and Γöé
Γöé Γöé Γöé CF01(55) in your DDS, the maximum value Γöé
Γöé Γöé Γöé for "IND" is 54. "IND" must not be used Γöé
Γöé Γöé Γöé with shared files. When you specify Γöé
Γöé Γöé Γöé "IND" but not "NUM", the RPG/400 program Γöé
Γöé Γöé Γöé assumes "NUM" is present with a value of Γöé
Γöé Γöé Γöé 1. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "INFDS" Γöé Data Γöé This entry lets you define and name a Γöé
Γöé Γöé struc- Γöé data structure to contain the Γöé
Γöé Γöé ture Γöé exception/error information. The data Γöé
Γöé Γöé name Γöé structure name is entered in positions Γöé
Γöé Γöé Γöé 60 through 65 and left justified. If Γöé
Γöé Γöé Γöé "INFDS" is specified for more than one Γöé
Γöé Γöé Γöé file, each associated data structure Γöé
Γöé Γöé Γöé must have a unique name. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "INFSR" Γöé Subrou- Γöé The file exception/error subroutine Γöé
Γöé Γöé tine Γöé named (left justified) in positions 60 Γöé
Γöé Γöé name Γöé through 65 may receive control following Γöé
Γöé Γöé Γöé file exception/errors. The subroutine Γöé
Γöé Γöé Γöé name may be "*PSSR", which indicates the Γöé
Γöé Γöé Γöé user defined program exception/error Γöé
Γöé Γöé Γöé subroutine is to be given control for Γöé
Γöé Γöé Γöé errors on this file. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "NUM" Γöé Maximum Γöé The number specified must be greater Γöé
Γöé Γöé number Γöé than zero and right-justified in posi- Γöé
Γöé Γöé of Γöé tions 60 through 65. The lesser of this Γöé
Γöé Γöé devices Γöé number and the number of devices defined Γöé
Γöé Γöé Γöé for the "WORKSTN" file on the create- Γöé
Γöé Γöé Γöé file command is the maximum number of Γöé
Γöé Γöé Γöé devices that this file can acquire. Γöé
Γöé Γöé Γöé With a shared file, the "NUM" value is Γöé
Γöé Γöé Γöé not used to restrict the number of Γöé
Γöé Γöé Γöé acquired devices. When you specify Γöé
Γöé Γöé Γöé "ID", "IND", or "SAVDS" but not "NUM", Γöé
Γöé Γöé Γöé the RPG/400 program assumes "NUM" is Γöé
Γöé Γöé Γöé present with a value of 1. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "PASS" Γöé "*NOIND" Γöé Specify "PASS *NOIND" on the file Γöé
Γöé Γöé Γöé description specification continuation Γöé
Γöé Γöé Γöé line for a program described "WORKSTN" Γöé
Γöé Γöé Γöé file if you are taking responsibility Γöé
Γöé Γöé Γöé for passing indicators on input and Γöé
Γöé Γöé Γöé output. With "PASS *NOIND", the RPG/400 Γöé
Γöé Γöé Γöé language does not pass indicators to Γöé
Γöé Γöé Γöé data management on output and does not Γöé
Γöé Γöé Γöé receive them on input. Pass indicators Γöé
Γöé Γöé Γöé by describing them as fields (in the Γöé
Γöé Γöé Γöé form "*INxx, *IN," or "*IN,xx") in the Γöé
Γöé Γöé Γöé input or output record. They must be Γöé
Γöé Γöé Γöé specified in the sequence required by Γöé
Γöé Γöé Γöé the data description specifications Γöé
Γöé Γöé Γöé (DDS). You can use the DDS listing to Γöé
Γöé Γöé Γöé determine this sequence. If you do not Γöé
Γöé Γöé Γöé specify "PASS *NOIND" and you use the Γöé
Γöé Γöé Γöé keyword "INDARA" in the DDS for the Γöé
Γöé Γöé Γöé "WORKSTN" file, indicators are not Γöé
Γöé Γöé Γöé passed to data management on output nor Γöé
Γöé Γöé Γöé received from data management on input. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "PLIST" Γöé Param- Γöé This entry is valid only when the device Γöé
Γöé Γöé eter Γöé specified in positions 40 through 46 of Γöé
Γöé Γöé list Γöé the main file-description line is Γöé
Γöé Γöé name Γöé "SPECIAL". Positions 60 through 65 give Γöé
Γöé Γöé Γöé the left-justified name of the parameter Γöé
Γöé Γöé Γöé list to be passed to the special Γöé
Γöé Γöé Γöé routine. The parameters identified by Γöé
Γöé Γöé Γöé this entry are added to the end of the Γöé
Γöé Γöé Γöé parameter list passed by the program. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "PRTCTL" Γöé Data Γöé The dynamic printer control option is Γöé
Γöé Γöé struc- Γöé being used. The data structure speci- Γöé
Γöé Γöé ture Γöé fied left-justified in positions 60 Γöé
Γöé Γöé name Γöé through 65 refers to the forms control Γöé
Γöé Γöé Γöé information and line count value. The Γöé
Γöé Γöé Γöé "PRTCTL" option is valid only for a Γöé
Γöé Γöé Γöé program described file. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "RECNO" Γöé Field Γöé This entry is optional for disk files to Γöé
Γöé Γöé name Γöé be processed by relative-record number. Γöé
Γöé Γöé Γöé A "RECNO" field must be specified for Γöé
Γöé Γöé Γöé output files processed by relative- Γöé
Γöé Γöé Γöé record number, output files that are Γöé
Γöé Γöé Γöé referenced by a random "WRITE" calcu- Γöé
Γöé Γöé Γöé lation operation, or output files that Γöé
Γöé Γöé Γöé are used with "ADD" on the output spec- Γöé
Γöé Γöé Γöé ifications. Γöé
Γöé Γöé Γöé Γöé
Γöé Γöé Γöé "RECNO" can be specified for Γöé
Γöé Γöé Γöé input/update files. The relative-record Γöé
Γöé Γöé Γöé number of the record retrieved is placed Γöé
Γöé Γöé Γöé in the field named, left justified, in Γöé
Γöé Γöé Γöé positions 60 through 65 for all oper- Γöé
Γöé Γöé Γöé ations that reposition the file (such as Γöé
Γöé Γöé Γöé "READ, SETLL", or "OPEN"). It must be Γöé
Γöé Γöé Γöé defined as numeric with zero decimal Γöé
Γöé Γöé Γöé positions. Γöé
Γöé Γöé Γöé Γöé
Γöé Γöé Γöé The field length must be sufficient to Γöé
Γöé Γöé Γöé contain the longest record number for Γöé
Γöé Γöé Γöé the file. "RECNO" is valid for "DISK" Γöé
Γöé Γöé Γöé files only. The contents of positions Γöé
Γöé Γöé Γöé 60 through 65 may be not valid when the Γöé
Γöé Γöé Γöé RPG/400 compiler does the blocking and Γöé
Γöé Γöé Γöé unblocking of records. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "RENAME" Γöé Record Γöé This entry, which is optional, allows Γöé
Γöé Γöé format Γöé you to rename record formats in an Γöé
Γöé Γöé name Γöé externally described file. Positions 19 Γöé
Γöé Γöé Γöé through 28 of the continuation line Γöé
Γöé Γöé Γöé specify the external name of the record Γöé
Γöé Γöé Γöé format that is to be renamed. Positions Γöé
Γöé Γöé Γöé 60 through 67 specify the left-justified Γöé
Γöé Γöé Γöé name of the record as it is used in the Γöé
Γöé Γöé Γöé program. The external name is replaced Γöé
Γöé Γöé Γöé by this name in the program. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "SAVDS" Γöé Data Γöé Positions 60-65 contain the left- Γöé
Γöé Γöé struc- Γöé justified name of the data structure Γöé
Γöé Γöé ture Γöé saved and restored for each device. Γöé
Γöé Γöé name Γöé Before an input operation, the data Γöé
Γöé Γöé Γöé structure for the device operation is Γöé
Γöé Γöé Γöé saved. After the input operation, the Γöé
Γöé Γöé Γöé data structure for the device associated Γöé
Γöé Γöé Γöé with this current input operation is Γöé
Γöé Γöé Γöé restored. This data structure cannot be Γöé
Γöé Γöé Γöé a data area data structure, file infor- Γöé
Γöé Γöé Γöé mation data structure, or program status Γöé
Γöé Γöé Γöé data structure, and it cannot contain a Γöé
Γöé Γöé Γöé compile-time array or prerun-time array. Γöé
Γöé Γöé Γöé Γöé
Γöé Γöé Γöé If "SAVDS" is not specified, no saving Γöé
Γöé Γöé Γöé and restoring is done. "SAVDS" must not Γöé
Γöé Γöé Γöé be specified for shared files. When you Γöé
Γöé Γöé Γöé specify "SAVDS" but not "NUM", the Γöé
Γöé Γöé Γöé RPG/400 program assumes "NUM" is present Γöé
Γöé Γöé Γöé with a value of 1. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "SFILE" Γöé Record Γöé If the main file-description line con- Γöé
Γöé Γöé format Γöé tains E in position 19 and "WORKSTN" in Γöé
Γöé Γöé name Γöé positions 40 through 46, this option Γöé
Γöé Γöé Γöé must be used to define any subfiles to Γöé
Γöé Γöé Γöé be used in the file. Positions 60 Γöé
Γöé Γöé Γöé through 67 must specify, left justified Γöé
Γöé Γöé Γöé the RPG/400 name of the record format to Γöé
Γöé Γöé Γöé be processed as a subfile. Γöé
Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Positions 47 through 52 must specify the Γöé
Γöé Γöé Γöé name of the relative-record number field Γöé
Γöé Γöé Γöé for this subfile. The relative-record Γöé
Γöé Γöé Γöé number of any record retrieved by a Γöé
Γöé Γöé Γöé "READC" or "CHAIN" operation is placed Γöé
Γöé Γöé Γöé into the field named in positions 47 Γöé
Γöé Γöé Γöé through 52. This field is also used to Γöé
Γöé Γöé Γöé specify the record number that RPG/400 Γöé
Γöé Γöé Γöé uses for a "WRITE" operation to the Γöé
Γöé Γöé Γöé subfile or for output operations that Γöé
Γöé Γöé Γöé use "ADD". The field name specified in Γöé
Γöé Γöé Γöé positions 47 through 52 must be defined Γöé
Γöé Γöé Γöé as numeric with zero decimal positions. Γöé
Γöé Γöé Γöé The field must have enough positions to Γöé
Γöé Γöé Γöé contain the largest record number for Γöé
Γöé Γöé Γöé the file. (See the "SFLSIZ" keyword in Γöé
Γöé Γöé Γöé the Data Description Specifications Ref- Γöé
Γöé Γöé Γöé erence.) Γöé
Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Relative record number processing is Γöé
Γöé Γöé Γöé implicitly defined as part of the Γöé
Γöé Γöé Γöé "SFILE" definition. If multiple sub- Γöé
Γöé Γöé Γöé files are defined, each subfile requires Γöé
Γöé Γöé Γöé a separate continuation line. Do not Γöé
Γöé Γöé Γöé use SFILE with SLN. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé "SLN" Γöé Field Γöé Positions 60-65 contain the left- Γöé
Γöé Γöé name Γöé justified name of a start line number Γöé
Γöé Γöé Γöé ("SLN") field. The "SLN" field deter- Γöé
Γöé Γöé Γöé mines where a record format is written Γöé
Γöé Γöé Γöé to a display file. The main file- Γöé
Γöé Γöé Γöé description line must contain "WORKSTN" Γöé
Γöé Γöé Γöé in positions 40 through 46 and a C or O Γöé
Γöé Γöé Γöé in positions 15. The data description Γöé
Γöé Γöé Γöé specifications for the file must specify Γöé
Γöé Γöé Γöé the keyword "SLNO(*VAR)" for one or more Γöé
Γöé Γöé Γöé record formats. When you specify "SLN" Γöé
Γöé Γöé Γöé on the continuation line, the "SLN" Γöé
Γöé Γöé Γöé field will automatically be defined in Γöé
Γöé Γöé Γöé the program as a numeric field with Γöé
Γöé Γöé Γöé length of 2 and with 0 decimal posi- Γöé
Γöé Γöé Γöé tions. Do not use SLN with SFILE. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.4.3.3. PRTCTL Data Structure ΓòÉΓòÉΓòÉ
Data Structure Positions Subfield Contents
1 A one-position character field that contains the
space-before value
2 A one-position character field that contains the
space-after value
3-4 A two-position character field that contains the
skip-before value
5-6 A two-position character field that contains the
skip-after value
7-9 A three-digit numeric field with zero decimal
positions that contains the current line count
value.
The values contained in the first four subfields of the data structure are the
same as those allowed in positions 17 through 22 (space and skip entries) of
the output specifications. If the space and skip entries (positions 17 through
22) of the output specifications are blank, and if subfields 1 through 4 are
also blank, the default is to space 1 after. If the PRTCTL option is specified,
it is used only for the output records that have blanks in positions 17 through
22. You can control the space and skip value (subfields 1 through 4) for the
PRINTER file by changing the values in these subfields while the program is
running.
Subfield 5 contains the current line count value. The RPG/400 compiler does not
initialize subfield 5 until after the first output line is printed. The RPG/400
compiler then changes subfield 5 after each output operation to the file.
ΓòÉΓòÉΓòÉ 1.5. Extension Specifications ΓòÉΓòÉΓòÉ
Extension specifications describe all record address files, arrays, and tables.
A maximum of 200 arrays and tables can be used in a program.
ΓòÉΓòÉΓòÉ 1.5.1. Extension Specification Statement ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Positions 7-10 (Reserved)
Positions 11-18 (From File Name)
Positions 19-26 (To File Name)
Positions 27-32 and 46-51 (Array or Table Name)
Positions 33-35 (Entries per Record)
Positions 36-39 (Entries per Array or Table)
Positions 40-42 and 52-54 (Length of Entry)
Positions 43 and 55 (Data Format)
Positions 44 and 56 (Decimal Positions)
Position 45 and 57 (Sequence)
Positions 46-57 (Second Array Description)
Positions 58-74 (Comments)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.5.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An E must appear in position 6 to identify this line as an extension
specifications statement.
ΓòÉΓòÉΓòÉ 1.5.1.2. Positions 7-10 (Reserved) ΓòÉΓòÉΓòÉ
Positions 7 through 10 must be blank.
ΓòÉΓòÉΓòÉ 1.5.1.3. Positions 11-18 (From File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The array or table is loaded at compilation time,
or the array is loaded by input or calculation
specifications.
Record address file name Name of the record address file.
Array or table file name Name of the array or table file loaded at prerun
time.
Use positions 11 through 18 to name an array file, table file, or record
address file. File names must begin in position 11. The record address file
name must always be entered in these positions. The file name of every
prerun-time array or table used in the program must be entered in these
positions. Leave positions 11 through 18 blank for compile-time arrays or
tables and for run-time arrays loaded with input and/or calculation
specifications.
Table "From and To File Name Entries" shows the relationship between positions
11 through 18 and positions 19 through 26.
When an array or table is loaded at compilation time, it is compiled along with
the source program and included in the program. Such an array or table does
not need to be loaded separately every time the program is run. Only those
arrays and tables that contain constant data should be compiled with the
program.
ΓòÉΓòÉΓòÉ 1.5.1.4. Positions 19-26 (To File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The array or table is not written at end of
program.
Input or update file with data File processed with the record address file
named in positions 11 through 18.
Output or combined file Output file to which an array or table is to be
written, or the same file name (must be a
combined table file) specified in positions 11
through 18 if the output array or table is to
replace input in the same file. The file should
be externally described as a physical file.
If a record address file is named in positions 11 through 18, the name of the
input or update file that contains the data records to be processed must be
entered in positions 19 through 26.
If an array or table is to be written, enter the file name of the output or
combined file in positions 19 through 26. This file must also be named in the
file description specifications. An array or table can be written to only one
output device. Leave positions 19 through 26 blank if the array or table is not
to be written.
If an array or table is assigned to an output file, it is automatically written
if LR is on. The array or table is written after all other records are written
in the format used when it was entered.
If an array or table is to be written to the same file from which it was read,
the same file name must be entered in positions 11 through 18 and in positions
19 through 26. This file must be specified as a combined file (C in position
15) in the file description specifications.
Table "From and To File Name Entries" describes the possible entries.
ΓòÉΓòÉΓòÉ 1.5.1.4.1. From and To File Name Table ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé From and To File Name Entries Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé TYPE OF FILE Γöé FROM FILE NAME Γöé TO FILE NAME (POSITIONS Γöé
Γöé Γöé (POSITIONS Γöé 19-26) Γöé
Γöé Γöé 11-18) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Array or Γöé If an array or Γöé If the array or table being Γöé
Γöé table files Γöé table loaded Γöé defined is being written out Γöé
Γöé loaded at Γöé at prerun time Γöé after it is updated, enter Γöé
Γöé prerun time Γöé is being Γöé the name of the output file Γöé
Γöé Γöé defined (posi- Γöé or the combined array file if Γöé
Γöé Γöé tions 27 Γöé it is to be written to the Γöé
Γöé Γöé through 57), Γöé same file that was assigned Γöé
Γöé Γöé enter the name Γöé to it in the file description Γöé
Γöé Γöé of the file Γöé specifications.(1) If the Γöé
Γöé Γöé that contains Γöé array or table is not being Γöé
Γöé Γöé the array or Γöé written out, leave these Γöé
Γöé Γöé table.(1) Γöé positions blank. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Arrays or Γöé Blank. Γöé Enter the name of the output Γöé
Γöé tables loaded Γöé Γöé file if the array or table is Γöé
Γöé at compile Γöé Γöé to be written out at the end Γöé
Γöé time Γöé Γöé of the program.(1) Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Arrays loaded Γöé Blank. Γöé Blank. Γöé
Γöé by input or Γöé Γöé Γöé
Γöé calculation Γöé Γöé Γöé
Γöé specifica- Γöé Γöé Γöé
Γöé tions Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Record Γöé Enter the name Γöé Enter the name of the file Γöé
Γöé address file Γöé of the record Γöé that contains the data Γöé
Γöé Γöé address Γöé records to be processed by Γöé
Γöé Γöé file.(1) Γöé the record address file.(1) Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé (1)These entries must be left-adjusted. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.5.1.5. Positions 27-32 and 46-51 (Array or Table Name) ΓòÉΓòÉΓòÉ
Entry Explanation
Array or table name The name of the array or table used in the program.
Use positions 27 through 32 to name the array or table.
ΓòÉΓòÉΓòÉ 1.5.1.6. Positions 33-35 (Entries per Record) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The array is loaded by input or calculation specifications.
1-999 Number of array or table entries in each array or table input
record.
Use positions 33 through 35 to indicate the exact number of array or table
entries in each array or table input record. The number must end in position
35. Every array or table input record except the last must contain the number
of entries indicated in positions 33 through 35. The last record can contain
fewer entries than indicated, but not more. Comments can be entered on table
input records in the positions following the table entries.
If two arrays or tables are in alternating format in one file, each array or
table input record must contain the corresponding entries from each array or
table. The corresponding entries from the two arrays or tables are considered
one entry and must be on the same record.
If positions 27 through 32 contain an array name, the following rules apply to
the use of positions 11 through 18 and 33 through 35:
For a prerun-time array, positions 11 through 18 must contain a file name and
positions 33 through 35 must have an entry.
For a compile-time array, positions 11 through 18 must be blank and positions
33 through 35 must have an entry.
For an run-time array, positions 11 through 18 and positions 33 through 35
must be blank.
ΓòÉΓòÉΓòÉ 1.5.1.7. Positions 36-39 (Entries per Array or Table) ΓòÉΓòÉΓòÉ
Entry Explanation
1-9999 Maximum number of array or table entries.
Use positions 36 through 39 to indicate the maximum number of entries that can
be contained in the array or table named in positions 27 through 32. This
number applies to one array or table or to two arrays or tables in alternating
format. The number entered must end in position 39.
Because the number of entries for two arrays or tables written in alternating
format must be the same, the number in these positions also gives the number of
entries in the second array or table specified in positions 46 through 51.
ΓòÉΓòÉΓòÉ 1.5.1.8. Positions 40-42 and 52-54 (Length of Entry) ΓòÉΓòÉΓòÉ
Entry Explanation
1-256 Length of each element in the array or table named in positions 27
through 32.
If L or R is specified in positions 43 or 55, the length includes the sign
position.
If two arrays or tables are entered in alternating format, the specification in
positions 40 through 42 applies to the array or table whose entry appears first
in the record.
ΓòÉΓòÉΓòÉ 1.5.1.9. Positions 43 and 55 (Data Format) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The data for the array or table (1) is in zoned decimal format, or
(2) is character data, or (3) is loaded through input or
calculation specifications.
P The data for the array or table is in packed decimal format.
B The data for the array or table is in binary format.
L The data for a numeric array or table element has a preceding
(left) plus or minus sign.
R The data for a numeric array or table element has a following
(right) plus or minus sign.
The entry in position 43 specifies the format of the data in the records in the
file. This entry has no effect on the format used for internal processing of
the array or table in the program.
ΓòÉΓòÉΓòÉ 1.5.1.10. Positions 44 and 56 (Decimal Positions) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Character array or table.
0-9 Number of positions to the right of the decimal in numeric array
or table elements.
Use position 44 to indicate the number of decimal positions in a numeric array
or table element. Position 44 must always have an entry for a numeric array or
table. If the entries in an array or table have no decimal positions, enter a
0.
If two arrays or tables are entered in alternating format, the specification in
this position applies to the array or table containing the entry that appears
first on the record.
ΓòÉΓòÉΓòÉ 1.5.1.11. Position 45 and 57 (Sequence) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No particular sequence
A Ascending sequence
D Descending sequence.
Use position 45 to describe the sequence (either ascending or descending) of
the data in an array or table loaded at prerun time or compile time.
When an entry is made in position 45, the array or table is checked for the
specified sequence at the time the array or table is loaded with data. If a
prerun-time array or table is out of sequence, control passes to the RPG/400
exception/error handling routine.
Ascending sequence means that the array or table entries start with the lowest
data entry (according to the collating sequence) and go to the highest.
Descending sequence means that the array or table entries start with the
highest data entry and go to the lowest. Items with equal values are allowed.
If two arrays or tables are entered in alternating format, the entry in
position 45 applies to the array or table containing the entry that appears
first on the record.
When the LOKUP operation is used to search an array or table for an entry to
determine whether the entry is high or low compared with the search argument, a
sequence must have been specified (A or D) for the array or table. See LOKUP
(Look Up) for more information.
A run-time array (loaded by input and/or calculation specifications) is not
sequence checked. However, an A or D entry must be specified if a high or low
LOKUP operation is processed. Sequence must be specified if the SORTA
operation code is used with the array.
ΓòÉΓòÉΓòÉ 1.5.1.12. Positions 46-57 (Second Array Description) ΓòÉΓòÉΓòÉ
The fields in positions 46 through 57 have the same significance and require
the same type of entries as the fields with corresponding titles in positions
27 through 32 and 40 through 45.
Positions 46 through 57 can be used to describe a second array:
For compile-time and prerun-time arrays, the array described in positions 46
through 57 is loaded in alternating format with the array named in positions
27 through 32.
For run-time arrays, positions 46 through 57 can be used to describe a second
run-time array that is loaded independently of the array named in positions
27 through 32.
See the discussion on positions 27 through 45 for information about correct
specifications. Leave positions 46 through 57 blank for a single array or
table.
ΓòÉΓòÉΓòÉ 1.5.1.13. Positions 58-74 (Comments) ΓòÉΓòÉΓòÉ
Positions 58 through 74 can be used for comments.
ΓòÉΓòÉΓòÉ 1.5.1.14. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank.
These positions are not printed contiguously with positions 6-74 on the
compiler listing.
ΓòÉΓòÉΓòÉ 1.6. Line Counter Specifications ΓòÉΓòÉΓòÉ
Line counter specifications can be used for each program described PRINTER file
to indicate the length of the form and the number of lines to print on a page.
These entries are specified on the RPG/400 Extension and Line Counter
Specifications. Line counter specifications may be used for each PRINTER file
in your program. If line counter specifications are used, position 39 of the
file description specifications for the PRINTER device must contain an L.
A form length and an overflow line specified by the OS/400 system override
commands override any program specifications. If no override commands are used
for the PRINTER file, the program specification of form length and overflow
line is used. If there are no overrides and no program specifications, the
form length and the overflow line specified in the device file are used.
ΓòÉΓòÉΓòÉ 1.6.1. Line Counter Specification Statement ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Positions 7-14 (File Name)
Positions 15-17 (Lines Per Page)
Positions 18-19 (Form Length)
Positions 20-22 (Overflow Line Number)
Positions 23-24 (Overflow Line)
Positions 25-74 (Reserved)
ΓòÉΓòÉΓòÉ 1.6.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An L must be entered in position 6 to identify this line as a line counter
specifications statement.
ΓòÉΓòÉΓòÉ 1.6.1.2. Positions 7-14 (File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
A valid file name File name of the program described PRINTER file as
previously defined on the file description specifications.
The file name must begin in position 7.
ΓòÉΓòÉΓòÉ 1.6.1.3. Positions 15-17 (Lines Per Page) ΓòÉΓòÉΓòÉ
Entry Explanation
2-112 The number of printing lines available is 2 through 112.
Use positions 15 through 17 to specify the exact number of lines available on
the form or page to be used. The entry must end in position 17. Leading zeros
can be omitted.
ΓòÉΓòÉΓòÉ 1.6.1.4. Positions 18-19 (Form Length) ΓòÉΓòÉΓòÉ
Entry Explanation
FL Form length.
Use positions 18 and 19 to indicate that the preceding entry (positions 15
through 17) is the form length. Positions 18 and 19 must contain the entry FL
if positions 15 through 17 contain an entry.
Changing the form length does not require recompiling the program. The override
to the compiled value can be specified by an OS/400 system override command.
ΓòÉΓòÉΓòÉ 1.6.1.5. Positions 20-22 (Overflow Line Number) ΓòÉΓòÉΓòÉ
Entry Explanation
2-112 The line number specified is the overflow line.
Use positions 20 through 22 to specify the overflow line number. The overflow
line number must be less than or equal to the form length. The entry must end
in position 22. Leading zeros can be omitted. When the line that is specified
as the overflow line is printed, the overflow indicator turns on. In the OS/400
system, changing the overflow line does not require recompiling the program.
The override to the compiled value can be specified by an OS/400 system
override command.
ΓòÉΓòÉΓòÉ 1.6.1.6. Positions 23-24 (Overflow Line) ΓòÉΓòÉΓòÉ
Entry Explanation
OL Overflow line.
Use positions 23 and 24 to indicate that the preceding entry (positions 20
through 22) is the overflow line number. Positions 23 and 24 must contain OL
if positions 20 through 22 contain an entry.
ΓòÉΓòÉΓòÉ 1.6.1.7. Positions 25-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 25 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.6.1.8. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank. These
positions are not printed contiguously with positions 6-74 on the compiler
listing.
ΓòÉΓòÉΓòÉ 1.7. Input Specifications ΓòÉΓòÉΓòÉ
For a program described input file, input specifications describe the types of
records within the file, the sequence of the types of records, the fields
within a record, the data within the field, indicators based on the contents of
the fields, control fields, fields used for matching records, and fields used
for sequence checking. For an externally described file, input specifications
are optional and can be used to add RPG/400 functions to the external
description. Input specifications are also used to describe data structures and
named constants.
Entries on input specifications are divided into the following categories:
Record identification entries (positions 7 through 42), which describe the
input record and its relationship to other records in the file.
Field description entries (positions 43 through 70), which describe the
fields in the records. Each field is described on a separate line, below its
corresponding record identification entry.
For externally described files, entries on input specifications are divided
into the following categories:
Record identification entries (positions 7 through 14, and 18 and 19), which
identify the record (the externally described record format) to which RPG/400
functions are to be added.
Field description entries (positions 21 through 30, 53 through 62, and 65
through 70), which describe the RPG/400 functions to be added to the fields
in the record. Field description entries are written on the lines following
the corresponding record identification entries.
For data structures, entries on input specifications are divided into the
following categories:
Data structure statements (positions 7 through 12, 17 through 30, and 44
through 51), which define data structures.
Data structure subfield specifications (positions 8, and 21 through 58),
which describe the subfields of the data structures. Data structure subfield
specifications are written on the lines following the data structure
statements.
Detailed information for the input specifications is given in:
Entries for program described files
Entries for externally described files
Entries for data structures
Entries for named constants.
ΓòÉΓòÉΓòÉ 1.7.1. Program Described Files ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Record Identification Entries
Field Description Entries
ΓòÉΓòÉΓòÉ 1.7.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An I must appear in position 6 to identify this line as an input specification
statement.
ΓòÉΓòÉΓòÉ 1.7.2. Record Identification Entries ΓòÉΓòÉΓòÉ
Record identification entries (positions 7 through 42) for a program described
file describe the input record and its relationship to other records in the
file.
Positions 7-14 (File Name)
Positions 14-16 (Logical Relationship)
Positions 15-16 (Sequence)
- Alphabetic Entries
- Numeric Entries
Position 17 (Number)
Position 18 (Option)
Positions 19-20 (Record Identifying Indicator, or **)
- Indicators
- Lookahead Fields
Positions 21-41 (Record Identification Codes)
- Positions 21-24, 28-31, and 35-38 (Position)
- Positions 25, 32, and 39 (Not)
- Positions 26, 33, and 40 (Code Part)
- Character (C)
- Zone (Z)
- Digit (D)
- Positions 27, 34, and 41 (Character)
- AND Relationship
- OR Relationship
Position 42 (Reserved)
ΓòÉΓòÉΓòÉ 1.7.2.1. Positions 7-14 (File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
A valid file name Same file name that appears on the file description
specifications for the input file.
Enter the name of the file to be described in these positions. This name must
be the same name defined for the file on the file description specifications.
This file must be an input file, an update file, or a combined file. The file
name must be entered on the first record identification line for each file and
can be entered on subsequent record identification lines for that file. All
entries describing one input file must appear together; they cannot be mixed
with entries for other files.
ΓòÉΓòÉΓòÉ 1.7.2.2. Positions 14-16 (Logical Relationship) ΓòÉΓòÉΓòÉ
Entry Explanation
AND More than three identification codes are used.
OR Two or more record types have common fields.
An unlimited number of AND/OR lines can be used. For more information see AND
Relationship and OR Relationship.
ΓòÉΓòÉΓòÉ 1.7.2.3. Positions 15-16 (Sequence) ΓòÉΓòÉΓòÉ
Entry Explanation
Any two alphabetic characters The program does not check for special
sequence.
Any two-digit number The program checks for special sequence within
the group.
The numeric sequence entry combined with the number (position 17) and option
(position 18) entries causes the program to check the sequence of input records
within a file. If the sequence is not correct, control passes to the RPG/400
exception/error handling routine. If AND or OR lines are specified, the
sequence entry is made on the main record line of the group, not on the AND or
OR lines.
Alphabetic and numeric entries can be made for different records (different
record identification lines) in the same file, but records with alphabetic
entries must be specified before records with numeric entries.
ΓòÉΓòÉΓòÉ 1.7.2.3.1. Alphabetic Entries ΓòÉΓòÉΓòÉ
Enter any two alphabetic characters in these positions when no sequence
checking is to be done. It is common programming practice to specify these
codes in a sequence that aids in program documentation. However, it is not
necessary to use unique alphabetic entries.
ΓòÉΓòÉΓòÉ 1.7.2.3.2. Numeric Entries ΓòÉΓòÉΓòÉ
Enter a unique numeric code in positions 15 and 16 if one record type must be
read before another record type in a file. Numeric entries must be in ascending
order, starting with 01, but need not be consecutive. When a numeric entry is
used, the appropriate entries must be made in positions 17 and 18.
To specify sequence checking, each record type must have a record
identification code, and the record types must be numbered in the order in
which they should appear. This order is checked as the records are read. If a
record type is out of sequence, control passes to the RPG/400 exception/error
handling routine.
Sequence numbers ensure only that all records of each record type precede the
records of senior sequence numbered record types. The sequence numbers do not
ensure that records within a record type are in any certain order. Sequence
numbers are unrelated to control levels and do not provide for checking data in
fields of a record for a special sequence. Use positions 61 and 62 (matching
fields) to indicate that data in fields of a record should be checked for a
special sequence.
ΓòÉΓòÉΓòÉ 1.7.2.4. Position 17 (Number) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The program does not check record types for a special sequence
(positions 15 and 16 have alphabetic entries).
1 Only one record of this type can be present in the sequenced
group.
N One or more records of this type can be present in the sequenced
group.
This entry must be used when a numeric entry is made in positions 15 and 16. If
an alphabetic entry is made in positions 15 and 16, this entry must be blank.
ΓòÉΓòÉΓòÉ 1.7.2.5. Position 18 (Option) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The record type must be present if sequence checking is specified.
O The record type is optional (that is, it may or may not be
present) if sequence checking is specified.
This entry must be blank if positions 15 and 16 contain an alphabetic entry.
Sequence checking of record types has no meaning when all record types within a
file are specified as optional (alphabetic entry in positions 15 and 16 or O
entry in position 18).
ΓòÉΓòÉΓòÉ 1.7.2.6. Positions 19-20 (Record Identifying Indicator, or **) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No indicator is used.
01-99 General indicator.
L1-L9 or LR Control level indicator used for a record identifying
indicator.
H1-H9 Halt indicator.
U1-U8 External indicator.
RT Return indicator.
** Lookahead field (not an indicator). Lookahead can be used only
with a primary or secondary file.
The indicators specified in these positions are used in conjunction with the
record identification codes (positions 21 through 41).
ΓòÉΓòÉΓòÉ 1.7.2.6.1. Indicators ΓòÉΓòÉΓòÉ
Positions 19 and 20 associate an indicator with the record type defined on this
line. The normal entry is one of the indicators 01 to 99; however, the control
level indicators L1 through L9 and LR can be used to cause certain total steps
to be processed. If a control level indicator is specified, lower control level
indicators are not set on. The halt indicators H1 through H9 can be used to
stop processing. The return indicator (RT) is used to return to the calling
program.
When a record is selected for processing and satisfies the conditions indicated
by the record identification codes, the appropriate record identifying
indicator is set on. This indicator can be used to condition calculation and
output operations. Record identifying indicators can be set on or set off by
the programmer. However, at the end of the cycle, all record identifying
indicators are set off before another record is selected.
ΓòÉΓòÉΓòÉ 1.7.2.6.2. Lookahead Fields ΓòÉΓòÉΓòÉ
The entry of ** is used for the lookahead function. This function lets you
look at information in the next record in a file. You can look not only at the
file currently selected for processing but also at other files present but not
selected during this cycle.
Field description lines must contain From and To entries in the record, a field
name, and decimal positions if the field is numeric. Note that a lookahead
field may not be specified as a field name or as a data structure name on Input
Specifications or as a Result Field on Calculation Specifications.
Positions 15 and 16 must contain an alphabetic entry. The lookahead fields are
defined in positions 53 through 58 of the lines following the line containing
** in positions 19 and 20. Positions 59 through 74 must be blank.
Any or all of the fields in a record can be defined as lookahead fields. This
definition applies to all records in the file, regardless of their type. If a
field is used both as a lookahead field and as a normal input field, it must be
defined twice with different names.
The lookahead function can be specified only for primary and secondary files
and can be specified only once for a file. It cannot be used for full
procedural files (identified by an F in position 16 of the file description
specifications), or with AND or OR lines.
When a record is being processed from a combined file or an update file, the
data in the lookahead field is the same as the data in the record being
processed, not the data in the next record.
The lookahead function causes information in the file information data
structure to be updated with data pertaining to the lookahead record, not to
the current primary record.
If an array element is specified as a lookahead field, the entire array is
classified as a lookahead field.
Lookahead fields are filled with nines when all records in the file have been
processed so that the end of the file can be recognized.
ΓòÉΓòÉΓòÉ 1.7.2.7. Positions 21-41 (Record Identification Codes) ΓòÉΓòÉΓòÉ
Entries in positions 21 through 41 identify each record type in the input file.
One to three identification codes can be entered on each specification line.
More than three record identification codes can be specified on additional
lines with the AND/OR relationship. If the file contains only one record type,
the identification codes can be left blank; however, a record identifying
indicator entry (positions 19 and 20) and a sequence entry (positions 15 and
16) must be made.
Three sets of entries can be made in positions 21 through 41: 21 through 27, 28
through 34, and 35 through 41. Each set is divided into four groups: position,
not, code part, and character.
The following table shows which categories use which positions in each set.
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CATEGORY Γöé 21-27 Γöé 28-34 Γöé 35-41 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Position Γöé 21-24 Γöé 28-31 Γöé 35-38 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Not Γöé 25 Γöé 32 Γöé 39 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Code Part Γöé 26 Γöé 33 Γöé 40 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Character Γöé 27 Γöé 34 Γöé 41 Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Entries in these sets need not be in sequence. For example, an entry can be
made in positions 28 through 34 without requiring an entry in positions 21
through 27. Entries for record identification codes are not necessary if input
records within a file are of the same type. An input specification containing
no record identification code defines the last record type for the file, thus
allowing the handling of any record types that are undefined. If no record
identification codes are satisfied, control passes to the RPG/400
exception/error handling routine.
ΓòÉΓòÉΓòÉ 1.7.2.7.1. Positions 21-24, 28-31, and 35-38 (Position) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No record identification code is present.
1-9999 The position that contains the record identification code in the
record.
In these positions enter the position that contains the record identification
code in each record. The position containing the code must be within the
record length specified for the file. This entry must be right-adjusted, but
leading zeros can be omitted.
ΓòÉΓòÉΓòÉ 1.7.2.7.2. Positions 25, 32, and 39 (Not) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Record identification code must be present.
N Record identification code must not be present.
Enter an N in this position if the code described must not be present in the
specified record position.
ΓòÉΓòÉΓòÉ 1.7.2.7.3. Positions 26, 33, and 40 (Code Part) ΓòÉΓòÉΓòÉ
Entry Explanation
C Entire character
Z Zone portion of character
D Digit portion of character.
This entry specifies what part of the character in the record identification
code is to be tested.
ΓòÉΓòÉΓòÉ 1.7.2.7.3.1. Character (C) ΓòÉΓòÉΓòÉ
The C entry indicates that the complete structure (zone and digit) of the
character is to be tested.
ΓòÉΓòÉΓòÉ 1.7.2.7.3.2. Zone (Z) ΓòÉΓòÉΓòÉ
The Z entry indicates that the zone portion of the character is to be tested.
The zone entry causes the four high-order bits of the character entry (position
27) to be compared with the zone portion of the character in the record
position specified in the position entry (positions 21 through 24). The
following three special cases are exceptions:
The hexadecimal representation of an & (ampersand) is 50. However, when an
ampersand is coded in the character entry, it is treated as if its
hexadecimal representation were C0, that is, as if it had the same zone as A
through I. An ampersand in the input data satisfies two zone checks: one for
a hexadecimal 5 zone, the other for a hexadecimal C zone.
The hexadecimal representation of a - (minus sign) is 60. However, when a
minus sign is coded in the character entry, it is treated as if its
hexadecimal representation were D0, that is, as if it had the same zone as J
through R. A minus sign in the input data satisfies two zone checks: one for
a hexadecimal 6 zone, the other for a hexadecimal D zone.
The hexadecimal representation of a blank is 40. However, when a blank is
coded in the character entry, it is treated as if its hexadecimal
representation were F0, that is, as if it had the same zone as 0 through 9. A
blank in the input data satisfies two zone checks: one for a hexadecimal 4
zone, the other for a hexadecimal F zone.
ΓòÉΓòÉΓòÉ 1.7.2.7.3.3. Digit (D) ΓòÉΓòÉΓòÉ
The D entry indicates that the digit portion of the character is to be tested.
The four low-order bits of the character are compared with the character
specified by the position entry.
ΓòÉΓòÉΓòÉ 1.7.2.7.4. Positions 27, 34, and 41 (Character) ΓòÉΓòÉΓòÉ
In this position enter the identifying character that is to be compared with
the character in the position specified in the input record.
The check for record type always starts with the first record type specified.
If data in a record satisfies more than one set of record identification codes,
the first record type satisfied determines the record types.
When more than one record type is specified for a file, the record
identification codes should be coded so that each input record has a unique set
of identification codes.
ΓòÉΓòÉΓòÉ 1.7.2.7.5. AND Relationship ΓòÉΓòÉΓòÉ
The AND relationship is used when more than three record identification codes
identify a record.
To use the AND relationship, enter at least one record identification code on
the first line and enter the remaining record identification codes on the
following lines with AND coded in positions 14 through 16 for each additional
line used. Positions 7 through 13, 17 through 20, and 42 through 74 of each
line with AND in positions 14 through 16 must be blank. Sequence, and
record-identifying-indicator entries are made in the first line of the group
and cannot be specified in the additional lines.
An unlimited number of AND/OR lines can be used on the input specifications.
ΓòÉΓòÉΓòÉ 1.7.2.7.6. OR Relationship ΓòÉΓòÉΓòÉ
The OR relationship is used when two or more record types have common fields.
To use the OR relationship, enter OR in positions 14 and 15. Positions 7
through 13, 16 through 18, and 42 through 74 must be blank. A record
identifying indicator can be entered in positions 19 and 20. If the indicator
entry is made and the record identification codes on the OR line are satisfied,
the indicator specified in positions 19 and 20 on that line is set on. If no
indicator entry is made, the indicator on the preceding line is set on.
An unlimited number of AND/OR lines can be used on the input specifications.
ΓòÉΓòÉΓòÉ 1.7.2.8. Position 42 (Reserved) ΓòÉΓòÉΓòÉ
Position 42 must be blank.
ΓòÉΓòÉΓòÉ 1.7.3. Field Description Entries ΓòÉΓòÉΓòÉ
The field description entries (positions 43 through 74) must follow the record
identification entries (positions 7 through 42) for each file.
Position 43 (Data Format)
Positions 44-51 (Field Location)
Position 52 (Decimal Positions)
Positions 53-58 (Field Name)
Positions 59-60 (Control Level)
Positions 61-62 (Matching Fields)
Positions 63-64 (Field Record Relation)
Positions 65-70 (Field Indicators - Program Described)
Positions 71-74 (Reserved)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.7.3.1. Position 43 (Data Format) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The input field is in zoned decimal format or is a character
field.
P The input field is in packed decimal format.
B The input field is in binary format.
L The numeric input field has a preceding (left) plus or minus sign.
R The number input field has a following (right) plus or minus sign.
The entry in position 43 specifies the format of the data in the records in the
file. This entry has no effect on the format used for internal processing of
the input field in the program.
See Chapter 9 in the RPG/400* User's Guide for information on internal field
formats.
ΓòÉΓòÉΓòÉ 1.7.3.2. Positions 44-51 (Field Location) ΓòÉΓòÉΓòÉ
Entry Explanation
Two 1- to 4-digit numbers Beginning of a field (from) and end of a field
(to).
This entry describes the location and size of each field in the input record.
Positions 44 through 47 specify the location of the field's beginning position;
positions 48 through 51 specify the location of the field's end position. To
define a single-position field, enter the same number in positions 44 through
47 and in positions 48 through 51. Numeric entries must be right-adjusted;
leading zeros can be omitted.
The maximum number of positions in the input record for each type of field is
as follows:
Number of Positions Type of Field
30 Zoned decimal numeric (30 digits)
16 Packed numeric (30 digits)
4 Binary (9 digits)
256 Character (256 characters)
31 Numeric with leading or trailing sign (30 digits)
9999 Data structure.
For arrays, enter the beginning position of the array in positions 44 through
47 and the ending position in positions 48 through 51. The array length must be
an integral multiple of the length of an element. The From-To position does
not have to account for all the elements in the array. The placement of data
into the array starts with the first element.
ΓòÉΓòÉΓòÉ 1.7.3.3. Position 52 (Decimal Positions) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Character field
0-9 Number of decimal positions in numeric field.
This entry, used with the data format entry in position 43, describes the
format of the field. This entry indicates whether the field described on this
line is a character field or a numeric field. If the field is numeric, an entry
must be made. The number of decimal positions specified for a numeric field
cannot exceed the length of the field. For an array or an array element, this
entry must be the same as the entry made on the extension specifications
(position 44 or 56) for the array. (If this entry is blank for a numeric array
or array element, the decimal positions specified in the extension
specification are used.)
ΓòÉΓòÉΓòÉ 1.7.3.4. Positions 53-58 (Field Name) ΓòÉΓòÉΓòÉ
Entry Explanation
Symbolic name Field name, data structure name, data structure subfield
name, array name, array element, PAGE, PAGE1-PAGE7, *IN,
*INxx, or *IN,xx.
These positions name the fields of an input record that are used in an RPG/400
program. This name must follow the rules for symbolic names.
To refer to an entire array on the input specifications, enter the array name
in positions 53 through 58. If an array name is entered in positions 53
through 58, control level (positions 59 and 60), matching fields (positions 61
and 62), and field indicators (positions 65 through 70) must be blank.
To refer to an element of an array, specify the array name, followed by a
comma, followed by an index. The index is either a numeric field with zero
decimal positions or the actual number of the array element to be used. The
value of the index can vary from 1 to n, where n is the number of elements
within the array.
ΓòÉΓòÉΓòÉ 1.7.3.5. Positions 59-60 (Control Level) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank This field is not a control field. Control level indicators cannot
be used with full procedural files.
L1-L9 This field is a control field.
Positions 59 and 60 indicate the fields that are used as control fields. A
change in the contents of a control field causes all operations conditioned by
that control level indicator and by all lower level indicators to be processed.
A split control field is a control field that is made up of more than one
field, each having the same control level indicator. The first field specified
with that control level indicator is placed in the high-order position of the
split control field, and the last field specified with the same control level
indicator is placed in the low-order position of the split control field.
ΓòÉΓòÉΓòÉ 1.7.3.6. Positions 61-62 (Matching Fields) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank This field is not a match field.
M1-M9 This field is a match field.
This entry is used to match the records of one file with those of another or to
sequence check match fields within one file. Match fields can be specified
only for fields in primary and secondary files.
Match fields within a record are designated by an M1 through M9 code entered in
positions 61 and 62 of the appropriate field description specification line. A
maximum of nine match fields can be specified.
The match field codes M1 through M9 can be assigned in any sequence. For
example, M3 can be defined on the line before M1, or M1 need not be defined at
all.
When more than one match field code is used for a record, all fields can be
considered as one large field. M1 or the lowest code used is the rightmost or
low-order position of the field. M9 or the highest code used is the leftmost or
high-order position of the field.
Entries in position 26 (alternate collating sequence) and position 43 (file
translation) of the control specification can be used to alter the collating
sequence for match fields.
If match fields are specified for only a single sequential file (input, update,
or combined), match fields within the file are sequence checked. The MR
indicator is not set on and cannot be used in the program. An out-of-sequence
record causes the RPG/400 exception/error handling routine to be given control.
In addition to sequence checking, match fields are used to match records from
the primary file with those from secondary files.
ΓòÉΓòÉΓòÉ 1.7.3.7. Positions 63-64 (Field Record Relation) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The field is common to all record types.
01-99 General indicators.
L1-L9 Control level indicators.
MR Matching record indicator.
U1-U8 External indicators.
H1-H9 Halt indicators.
RT Return indicator.
Field record relation indicators are used to associate fields within a
particular record type when that record type is one of several in an OR
relationship. This entry reduces the number of lines that must be written.
The field described on a line is extracted from the record by the RPG/400
program only when the indicator coded in positions 63 and 64 is on or when
positions 63 and 64 are blank. When positions 63 and 64 are blank, the field is
common to all record types defined by the OR relationship.
Field record relation indicators can be used with control level fields
(positions 59 and 60) and matching fields (positions 61 and 62).
ΓòÉΓòÉΓòÉ 1.7.3.8. Positions 65-70 (Field Indicators - Program Described) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No indicator specified
01-99 General indicators
H1-H9 Halt indicator
U1-U8 External indicators
RT Return indicator.
Entries in positions 65 through 70 test the status of a field or of an array
element as it is read into the program. Field indicators are specified on the
same line as the field to be tested. Depending on the status of the field
(plus, minus, zero, or blank), the appropriate indicator is set on and can be
used to condition later specifications. The same indicator can be specified in
two positions, but it should not be used for all three positions. Field
indicators cannot be used with arrays that are not indexed or look-ahead
fields.
Positions 65 and 66 (plus) and positions 67 and 68 (minus) are valid for
numeric fields only. Positions 69 and 70 can be used to test a numeric field
for zeros or a character field for blanks.
The field indicators are set on if the field or array element meets the
condition specified when the record is read. Each field indicator is related
to only one record type; therefore, the indicators are not reset (on or off)
until the related record is read again or until the indicator is defined in
some other specification.
ΓòÉΓòÉΓòÉ 1.7.3.9. Positions 71-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 71 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.7.3.10. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank. These
positions are not printed contiguously with positions 6-74 on the compiler
listing.
ΓòÉΓòÉΓòÉ 1.7.4. Externally Described Files ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Record Identification Entries
Field Description Entries
ΓòÉΓòÉΓòÉ 1.7.4.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An I must appear in position 6 to identify this line as an input specifications
statement.
ΓòÉΓòÉΓòÉ 1.7.5. Record Identification Entries ΓòÉΓòÉΓòÉ
Positions 7-14 (Record Name)
Positions 15-18 (Reserved)
Positions 19-20 (Record Identifying Indicator)
Positions 21-41 (Record Identification Code)
Positions 42-74 (Reserved)
Positions 75-80 (Comments)
When the description of an externally described file is retrieved by the
compiler, the record definitions are also retrieved. To refer to the record
definitions, specify the record format name in the input, calculation, and
output specifications of the program. Input specifications for an externally
described file are required if:
Record identifying indicators are to be specified.
A field within a record is to be renamed for the program.
Control level or matching field indicators are to be used.
Field indicators are to be used.
The field description specifications must immediately follow the record
identification specification for an externally described file.
A record line for an externally described file defines the beginning of the
override specifications for the record. All specifications following the
record line are part of the record override until another record format name or
file name is found in positions 7 through 14 of the input specifications. All
record lines that pertain to an externally described file must appear together;
they cannot be mixed with entries for other files.
ΓòÉΓòÉΓòÉ 1.7.5.1. Positions 7-14 (Record Name) ΓòÉΓòÉΓòÉ
Enter one of the following:
The external name of the record format. (The file name cannot be used for an
externally described file.)
The RPG/400 name specified by the RENAME option on the file description
specifications continuation line if the external record format was renamed.
A record format name can appear only once in positions 7 through 14 of the
input specifications for a program.
ΓòÉΓòÉΓòÉ 1.7.5.2. Positions 15-18 (Reserved) ΓòÉΓòÉΓòÉ
Positions 15 through 18 must be blank.
ΓòÉΓòÉΓòÉ 1.7.5.3. Positions 19-20 (Record Identifying Indicator) ΓòÉΓòÉΓòÉ
The specification of record identifying indicators in these positions is
optional but, if present, follows the rules as described under Program
Described Files except for look-ahead specifications, which are not allowed for
an externally described file.
ΓòÉΓòÉΓòÉ 1.7.5.4. Positions 21-41 (Record Identification Code) ΓòÉΓòÉΓòÉ
Positions 21 through 41 must be blank. Record format names are used to
determine the record types used in an externally described file.
ΓòÉΓòÉΓòÉ 1.7.5.5. Positions 42-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 42-74 must be blank.
ΓòÉΓòÉΓòÉ 1.7.5.6. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75-80 can be used for comments, or left blank. These positions are
not printed contiguously with positions 6-74 on the compiler listing.
ΓòÉΓòÉΓòÉ 1.7.6. Field Description Entries ΓòÉΓòÉΓòÉ
Positions 7-20 (Reserved)
Positions 21-30 (External Field Name)
Positions 31-52 (Reserved)
Positions 53-58 (Field Name)
Positions 59-60 (Control Level)
Positions 61-62 (Matching Fields)
Positions 63-64 (Reserved)
Positions 65-70 (Externally Described Field Indicators)
Positions 71-74 (Reserved)
Positions 75-80 (Comments)
The field description specifications for an externally described file can be
used to rename a field within a record for a program or to specify control
level, field indicator, and match field functions. The field definitions
(attributes) are retrieved from the externally described file and cannot be
changed by the program. If the attributes of a field are not valid to an
RPG/400 program (such as numeric length greater than 30 digits), the field
cannot be used. Diagnostic checking is done on fields contained in an external
record format in the same way as for source statements.
ΓòÉΓòÉΓòÉ 1.7.6.1. Positions 7-20 (Reserved) ΓòÉΓòÉΓòÉ
Positions 7 through 20 must be blank.
ΓòÉΓòÉΓòÉ 1.7.6.2. Positions 21-30 (External Field Name) ΓòÉΓòÉΓòÉ
If a field within a record in an externally described file is to be renamed,
enter the external name of the field in these positions. A field may have to
be renamed because the external name is longer than 6 characters or because the
name is the same as a field name specified in the program and two different
names are required.
ΓòÉΓòÉΓòÉ 1.7.6.3. Positions 31-52 (Reserved) ΓòÉΓòÉΓòÉ
Positions 31 through 52 must be blank.
ΓòÉΓòÉΓòÉ 1.7.6.4. Positions 53-58 (Field Name) ΓòÉΓòÉΓòÉ
The field name entry is made only when it is required for the RPG/400 function
(such as control levels) added to the external description. The field name
entry contains one of the following:
The name of the field as defined in the external record description (if 6
characters or less).
The name specified to be used in the program that replaced the external name
specified in positions 21 through 30.
The field name must follow the rules for using symbolic names.
ΓòÉΓòÉΓòÉ 1.7.6.5. Positions 59-60 (Control Level) ΓòÉΓòÉΓòÉ
This entry indicates whether the field is to be used as a control field in the
program.
Entry Explanation
Blank This field is not a control field.
L1-L9 This field is a control field.
Note: For externally described files, split control fields are combined in
the order in which the fields are specified on the data description
specifications (DDS), not in the order in which the fields are specified on the
input specifications.
ΓòÉΓòÉΓòÉ 1.7.6.6. Positions 61-62 (Matching Fields) ΓòÉΓòÉΓòÉ
This entry indicates whether the field is to be used as a match field.
Entry Explanation
Blank This field is not a match field.
M1-M9 This field is a match field.
See Positions 61-62 (Matching Fields) for more information on match fields.
ΓòÉΓòÉΓòÉ 1.7.6.7. Positions 63-64 (Reserved) ΓòÉΓòÉΓòÉ
Positions 63 and 64 must be blank.
ΓòÉΓòÉΓòÉ 1.7.6.8. Positions 65-70 (Externally Described Field Indicators) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No indicator specified
01-99 General indicators
H1-H9 Halt indicators
U1-U8 External indicators
RT Return indicator.
See Positions 65-70 (Field Indicators - Program Described) for more
information.
ΓòÉΓòÉΓòÉ 1.7.6.9. Positions 71-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 71 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.7.6.10. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank. These
positions are not printed contiguously with positions 6-74 on the compiler
listing.
ΓòÉΓòÉΓòÉ 1.7.7. Data Structure Specifications ΓòÉΓòÉΓòÉ
A data structure can be used to:
Allow the division of a field into subfields without using the MOVE or MOVEL
operations.
Operate on a subfield and change the contents of a subfield.
Redefine the same internal area more than once using different data formats.
Data structures are defined on the input specifications the same way records
are defined. The record specification line contains the data structure
statement (DS in positions 19 and 20) and the data structure name (optional).
The field specification lines contain the subfield specifications for the data
structure.
Data structure specifications must follow the input specifications for records.
All entries describing a data structure and its subfields must appear together.
For more detail see Data Structure Specification Entries.
ΓòÉΓòÉΓòÉ 1.7.8. Data Structure Specification Entries ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Positions 7-12 (Data Structure Name)
Positions 13-16 (Reserved)
Position 17 (External Description)
Position 18 (Option)
Positions 19-20 (Record Identifying Indicator)
Positions 21-30 (External File Name)
Positions 31-43 (Reserved)
Positions 44-47 (Data Structure Occurrences)
Positions 48-51 (Length)
Positions 52-74 (Reserved)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.7.8.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
Position 6 must contain an I for input specifications.
ΓòÉΓòÉΓòÉ 1.7.8.2. Positions 7-12 (Data Structure Name) ΓòÉΓòÉΓòÉ
Positions 7 through 12 can contain the name of the data structure being
defined. The data structure name is optional, and is limited to 6 characters.
A data structure name must follow the rules for using symbolic names. A data
structure name can be specified anywhere a character field can be specified. If
the data structure is externally described and positions 21-30 are blank, this
entry must contain the name of an externally described file.
ΓòÉΓòÉΓòÉ 1.7.8.3. Positions 13-16 (Reserved) ΓòÉΓòÉΓòÉ
Positions 13 through 16 must be blank.
ΓòÉΓòÉΓòÉ 1.7.8.4. Position 17 (External Description) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Subfield definitions for this data structure follow this
specification.
E Subfield definitions are described externally. Positions 7 through
12 must contain the name of an externally described file if
positions 21 through 30 are blank. The file name must be limited
to 6 characters.
ΓòÉΓòÉΓòÉ 1.7.8.5. Position 18 (Option) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank This data structure is not a program status or data area data
structure, and this data structure is not globally initialized.
I Data structure initialization. All subfields in the data structure
are initialized; characters to blank, numerics to zero, in the
order in which they are defined, during program initialization.
S This data structure is the program status data structure. Only
one data structure can be specified as the program status data
structure.
U This is a data area data structure. The external data area (named
in positions 7 through 12) is retrieved when the program starts
and rewritten when the program ends. If you put blanks in
positions 7 through 12, the local data area is used.
ΓòÉΓòÉΓòÉ 1.7.8.6. Positions 19-20 (Record Identifying Indicator) ΓòÉΓòÉΓòÉ
Positions 19 and 20 must contain DS to indicate a data structure.
ΓòÉΓòÉΓòÉ 1.7.8.7. Positions 21-30 (External File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The data structure subfields are defined in the program.
File name This is the name of the file whose first record format contains
the field descriptions used as the subfield descriptions for this
data structure.
ΓòÉΓòÉΓòÉ 1.7.8.8. Positions 31-43 (Reserved) ΓòÉΓòÉΓòÉ
Positions 31 through 43 must be blank.
ΓòÉΓòÉΓòÉ 1.7.8.9. Positions 44-47 (Data Structure Occurrences) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank This is not a multiple-occurrence data structure.
1-9999 The number (right-adjusted) indicating the number of occurrences
of a multiple-occurrence data structure.
These positions must be blank if the data structure is the program status data
structure (indicated by an S in position 18), a file information data structure
(INFDS), or a data area data structure.
ΓòÉΓòÉΓòÉ 1.7.8.10. Positions 48-51 (Length) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Length of the data structure is either the length specified on the
input field specifications if the data structure is an input field
or the highest To position specified for a subfield within the
data structure if the data structure is not an input field.
1-9999 Length of the data structure.
The length of the data structure can be specified in positions 48 through 51.
This entry is optional but, if used, must be right-adjusted. If this entry is
not made, the length of the data structure is one of the following:
The length specified on the input field specifications if the data structure
name is an input field.
The highest To position specified for a subfield within the data structure if
the data structure name is not an input field.
ΓòÉΓòÉΓòÉ 1.7.8.11. Positions 52-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 52 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.7.8.12. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 may be used for comments or left blank. These positions
are not printed contiguously with positions 6-74 on the compiler listing.
ΓòÉΓòÉΓòÉ 1.7.9. Data Structure Subfield Specifications ΓòÉΓòÉΓòÉ
Specifications for subfields, if used, must follow the data structure
specification statement to which they apply.
Position 7 (Reserved)
Position 8 (Initialization Option)
Positions 9-20 (Reserved)
Positions 21-30 (External Field Name)
Positions 21-42 (Initialization Value)
Positions 31-42 (Reserved)
Position 43 (Internal Data Format)
Positions 44-51 (Field Location)
Position 52 (Decimal Positions)
Positions 53-58 (Field Name)
Positions 59-74 (Reserved)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.7.9.1. Position 7 (Reserved) ΓòÉΓòÉΓòÉ
Position 7 must be blank.
ΓòÉΓòÉΓòÉ 1.7.9.2. Position 8 (Initialization Option) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No subfield initialization.
I Subfield is initialized to value specified in positions 21 to 42.
ΓòÉΓòÉΓòÉ 1.7.9.3. Positions 9-20 (Reserved) ΓòÉΓòÉΓòÉ
Positions 9 through 20 must be blank.
ΓòÉΓòÉΓòÉ 1.7.9.4. Positions 21-30 (External Field Name) ΓòÉΓòÉΓòÉ
To rename a subfield in an externally described data structure, specify the
external name in positions 21 through 30, and specify the name to be used in
the program in positions 53 through 58. The remaining positions must be blank.
ΓòÉΓòÉΓòÉ 1.7.9.5. Positions 21-42 (Initialization Value) ΓòÉΓòÉΓòÉ
If a subfield is to be initialized, specify a literal value or a named constant
in these positions. If no value is specified and position 8 contains I, the
subfield is initialized to zero or blanks, depending on the field type. The
value may be continued on the next line. See Named Constant Continuation
Specifications for more information on continuation.
See the RPG/400* User's Guide for more information on how to specify the
initialization value.
ΓòÉΓòÉΓòÉ 1.7.9.6. Positions 31-42 (Reserved) ΓòÉΓòÉΓòÉ
Positions 31 through 42 must be blank, if an external field name is specified
in positions 21 to 30.
ΓòÉΓòÉΓòÉ 1.7.9.7. Position 43 (Internal Data Format) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Subfield is in zoned decimal format or is character data if
position 52 is blank.
P Subfield is in packed decimal format.
B Subfield is in binary format.
Note: Unlike the external data format field, the entry determines the
internal format of the data.
ΓòÉΓòÉΓòÉ 1.7.9.8. Positions 44-51 (Field Location) ΓòÉΓòÉΓòÉ
Entry Explanation
Two 1- to 4-digit numbers Beginning of a subfield (from) and end of a
subfield (to).
Keywords For the program status data structure or for a
file information data structure, special keywords
define the location of the subfields in the data
structures. Keywords for the program status data
structure are *STATUS, *PROGRAM, *PARMS, and
*ROUTINE. Keywords for the file information data
structure are *FILE, *RECORD, *OPCODE, *STATUS,
and *ROUTINE.
Positions 44-47 are the From position. Positions 48-51 are the To position.
Both From and To must be right-justified, and leading zeroes may be omitted.
ΓòÉΓòÉΓòÉ 1.7.9.9. Position 52 (Decimal Positions) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Character subfield
0-9 Number of decimal positions in a numeric subfield.
Position 52, along with position 43, determines the format of the subfield. An
entry must be made in position 52 for a numeric subfield.
ΓòÉΓòÉΓòÉ 1.7.9.10. Positions 53-58 (Field Name) ΓòÉΓòÉΓòÉ
In positions 53 through 58, enter the name of the subfield that is being
defined. The name can be an array name, but cannot be an array element name.
ΓòÉΓòÉΓòÉ 1.7.9.11. Positions 59-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 59 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.7.9.12. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank. These
positions are not printed contiguously with positions 6-74 on the compiler
listing.
ΓòÉΓòÉΓòÉ 1.7.10. Named Constant Specifications ΓòÉΓòÉΓòÉ
Positions 7-20 (Reserved)
Positions 21-42 (Constant)
Position 43 (Data Type)
Positions 44-52 (Reserved)
Positions 53-58 (Constant Name)
Positions 59-74 (Reserved)
ΓòÉΓòÉΓòÉ 1.7.10.1. Positions 7-20 (Reserved) ΓòÉΓòÉΓòÉ
Positions 7 through 20 must be blank.
ΓòÉΓòÉΓòÉ 1.7.10.2. Positions 21-42 (Constant) ΓòÉΓòÉΓòÉ
In positions 21-42 enter the constant or edit word being declared. The constant
may be continued on subsequent lines by coding a hyphen as the last character.
For character named constants the hyphen replaces the ending quote. A continued
numeric constant must result in a valid decimal number with at most 30 digits,
a maximum of 9 being to the right of the decimal point. Named constants can be
declared anywhere in the input specifications.
ΓòÉΓòÉΓòÉ 1.7.10.3. Position 43 (Data Type) ΓòÉΓòÉΓòÉ
Entry Explanation
C Type of name is constant
Blank Constant continuation line
ΓòÉΓòÉΓòÉ 1.7.10.4. Positions 44-52 (Reserved) ΓòÉΓòÉΓòÉ
Positions 44-52 must be blank.
ΓòÉΓòÉΓòÉ 1.7.10.5. Positions 53-58 (Constant Name) ΓòÉΓòÉΓòÉ
Positions 53-58 contain the name of the constant. The normal rules for RPG/400
names apply.
ΓòÉΓòÉΓòÉ 1.7.10.6. Positions 59-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 59-74 must be blank.
ΓòÉΓòÉΓòÉ 1.7.11. Named Constant Continuation Specifications ΓòÉΓòÉΓòÉ
Positions 7-20 (Reserved)
Positions 21-42 (Constant)
Positions 43-74 (Reserved)
ΓòÉΓòÉΓòÉ 1.7.11.1. Positions 7-20 (Reserved) ΓòÉΓòÉΓòÉ
Positions 7 through 20 must be blank.
See Named Constant Examples
ΓòÉΓòÉΓòÉ 1.7.11.2. Positions 21-42 (Constant) ΓòÉΓòÉΓòÉ
In positions 21-42 enter the constant or edit word being continued. A character
or transparent literal constant may be continued over as many lines as desired
so long as the total length of the constant does not exceed 256 characters. A
continued numeric constant must result in a valid decimal number with at most
30 digits, a maximum of 9 being to the right of the decimal point.
See Named Constant Examples
ΓòÉΓòÉΓòÉ 1.7.11.3. Positions 43-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 43-74 must be blank.
See Named Constant Examples
ΓòÉΓòÉΓòÉ 1.7.11.3.1. Named Constant Examples ΓòÉΓòÉΓòÉ
Named Constant Examples
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme.............
I*
I*The following is an example of a character constant:
I 'MICKEY' C MOUSE
I*
I*The following is an example of a continued character constant:
I*
I 'ABCDEF- C CHAR
I 'GHIJK'
I*
I*The following is an example of a numeric constant:
I*
I 123456789 C INTEGER
I*
I*
I*The following is an example of a continued numeric constant:
I*
I 123456- C NUM
I 789
I*
I*The following is an example of a hexadecimal constant:
I*
I X'010203' C HEX1
I*
I*The following is an example of a continued hexadecimal constant:
I*
I X'010- C HEX2
I '202'
I*
I*The following is an example of a continued transparent
I*constant. The Shift Out (SO) and Shift In (SI) characters
I*are represented by o and i. The value of the combined literal
I*is 'oK1K2K3K4K5i' if the transparent literal option is specified
I*(1 in position 57 of the control specification).
I*
I 'oK1K2K3i- C TRANS
I 'oK4K5i'
ΓòÉΓòÉΓòÉ 1.8. Calculation Specifications ΓòÉΓòÉΓòÉ
Calculation specifications indicate the operations to be done on the data in a
program. Two general rules govern the writing of calculation entries:
Each operation is specified on one line, except when there are AND/OR lines
in the calculation.
Calculation entries must be grouped in the following order:
- Detail calculations
- Total calculations
- Subroutines.
Calculations within the groups must be specified in the order in which they are
to be done.
Each calculation specifications statement is divided into three parts that
specify the following:
When calculations are to be done: The conditioning indicators specified in
positions 7 through 17 determine when and under what conditions the
calculations are to be done.
What kind of calculations are to be done: The entries specified in positions
18 through 53 determine the kind of calculations to be done, specify the data
(such as fields or files) upon which the operation is to be done, and specify
the field that is to contain the results of the calculation.
What tests are to be made on the results of the operation: Indicators
specified in positions 54 through 59 are used to test the results of the
calculations and can condition subsequent calculations or output operations.
The resulting indicator positions have various uses, depending on the
operation code.
The calculation specifications are entered on the RPG/400 Calculation
Specifications. See Operation Codes for details on how these positions must be
specified for individual calculation operations.
The calculation specification can also be used to enter SQL statements into an
RPG/400 program. See RPG/400* User's Guide and SQL/400* Reference for more
information.
ΓòÉΓòÉΓòÉ 1.8.1. Calculation Specification Statement ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Positions 7-8 (Control Level)
- Control Level Indicators
- Last Record Indicator
- Subroutine Identifier
- AND/OR Lines Identifier
Positions 9-17 (Indicators)
Positions 18-27 (Factor 1)
Positions 28-32 (Operation)
Positions 33-42 (Factor 2)
Positions 43-48 (Result Field)
Positions 49-51 (Field Length)
Position 52 (Decimal Positions)
Position 53 (Operation Extender)
Positions 54-59 (Resulting Indicators)
Positions 60-74 (Comments)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.8.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
A C must appear in position 6 to identify this line as a calculation
specifications statement.
ΓòÉΓòÉΓòÉ 1.8.1.2. Positions 7-8 (Control Level) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The calculation operation is done at detail calculation time for
each program cycle if the indicators in positions 9 through 17
allow it; or the calculation is part of a subroutine.
L0 The calculation operation is done at total calculation time for
each program cycle.
L1-L9 The calculation operation is done when the appropriate control
break occurs at total calculation time, or when the indicator is
set on.
LR The calculation operation is done after the last record has been
processed or after the LR indicator has been set on.
SR The calculation operation is part of an RPG/400 subroutine. A
blank entry is also valid for calculations that are part of a
subroutine.
AN, OR Indicators on more than one line condition the calculation.
ΓòÉΓòÉΓòÉ 1.8.1.2.1. Control Level Indicators ΓòÉΓòÉΓòÉ
The L0 entry is used in positions 7 and 8 to indicate that the calculation is
to be done during total time and is not dependent on the occurrence of a
control break.
If indicators L1 through L9 are specified in positions 7 and 8, the calculation
is processed at total time only when the specified indicator is on. Remember
that, if L1 through L9 are set on by a control break, all lower level
indicators are also set on. If positions 7 and 8 are blank, the calculation is
done at detail time, is a statement within a subroutine, or is a declarative
statement.
The following operations can be specified within total calculations with
positions 7 and 8 blank: PLIST, PARM, KLIST, KFLD, TAG, DEFN, and ELSE.
(Conditioning indicators in positions 9 through 17 are not allowed with these
operations.) In addition, all the preceding operations except TAG and ELSE can
be specified anywhere within the calculations, even between an ENDSR operation
of one subroutine and the BEGSR operation of the next subroutine or after the
ENDSR operation for the last subroutine.
ΓòÉΓòÉΓòÉ 1.8.1.2.2. Last Record Indicator ΓòÉΓòÉΓòÉ
The LR Indicator, if specified in positions 7 and 8, causes the calculation to
be done during the last total time.
If there is a primary file but no secondary files in the program, the LR
indicator is set on after the last input record has been read, the calculations
specified for the record have been done, and the detail output for the last
record read has been completed.
If there is more than one input file (primary and secondary), the RPG/400
programmer determines which files are to be checked for end-of-file by entering
an E in position 17 of the file description specifications. LR is set on when
all files with an end-of-file specification have been completely read, when
detail output for the last record in these files has been completed, and after
all matching secondary records have been processed.
When the LR indicator is set on after the last input record has been read, the
control level indicators L1 through L9 are also set on. If the indicators L1
through L9 have not been defined by an entry in positions 59 and 60 of the
input specifications or by *INxx when used in a result field, the indicators
are set on when LR is on, but they cannot be used in other specifications.
ΓòÉΓòÉΓòÉ 1.8.1.2.3. Subroutine Identifier ΓòÉΓòÉΓòÉ
An SR entry in positions 7 and 8 indicates that the specification is part of a
subroutine. The SR entry is not required. Subroutine lines must appear after
the total calculation specifications. The operation codes BEGSR and ENDSR
serve as delimiters for a subroutine.
ΓòÉΓòÉΓòÉ 1.8.1.2.4. AND/OR Lines Identifier ΓòÉΓòÉΓòÉ
Positions 7 and 8 can contain AN or OR to define additional indicators
(positions 9 through 17) for a calculation. Indicators in positions 9 through
17 contained in one line are always in an AND relationship. Indicators
contained on more than one line can be a combination of AND and OR
relationships. A maximum of seven AND/OR lines can be specified in one group.
The entry in positions 7 and 8 of the line immediately preceding an AND/OR line
or a group of AND/OR lines determines when the calculation is to be processed.
The entry in positions 7 and 8 on the first line of a group applies to all
AND/OR lines in the group. A control level indicator (L1 through L9, L0, or
LR) is entered for total calculations, an SR or blanks for subroutines, and a
blank for detail calculations.
ΓòÉΓòÉΓòÉ 1.8.1.3. Positions 9-17 (Indicators) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The operation is processed on every record if the condition
specified in positions 7 and 8 is satisfied.
01-99 General indicators.
KA-KN, KP-KY Function key indicators.
L1-L9 Control level indicators.
LR Last record indicator.
MR Matching record indicator.
H1-H9 Halt indicators.
RT Return indicator.
U1-U8 External indicators.
OA-OG, OV Overflow indicator.
Positions 10 and 11, 13 and 14, and 16 and 17 contain indicators that are
tested to determine if a particular calculation is to be processed. A blank in
positions 9, 12, and 15 designates that the indicator must be on for a
calculation to be done. An N in positions 9, 12, and 15 designates that the
associated indicator must be off for a calculation to be done.
One to three indicators can be entered in positions 9 through 17 on one line.
Indicators on the same line are in an AND relationship. The AND relationship
means that all three indicator conditions must be satisfied before the
calculation can take place. If fewer than three indicators are specified,
entries need not be made in sequence; that is, an indicator can be specified in
positions 16 and 17, and positions 10 through 15 can be blank. When more than
three indicators are needed to condition a calculation, AND/OR must be used.
Seven is the maximum number of AND/OR lines that can be specified on
calculation specifications. Positions 9 through 17 can contain a combination of
the type of indicators discussed in the preceding text.
ΓòÉΓòÉΓòÉ 1.8.1.4. Positions 18-27 (Factor 1) ΓòÉΓòÉΓòÉ
Factor 1 names a field or gives actual data (literals) or RPG/400 special words
(*NAMVAR DEFN) on which an operation is to be done. The entry must begin in
position 18. The entries that are valid for factor 1 depend on the operation
code specified in positions 28 through 32. For the specific entries for factor
1 for a particular operation code, see Operation Codes. With some operation
codes, a colon can be used to separate parts of the factor, but must be
preceded by and followed by a valid entry.
ΓòÉΓòÉΓòÉ 1.8.1.5. Positions 28-32 (Operation) ΓòÉΓòÉΓòÉ
Positions 28 through 32 specify the kind of operation to be done using factor
1, factor 2, and the result field entries. The operation code must begin in
position 28. For further information on the operation codes, see Operation
Codes. For a list of the operation codes, see Operation Codes List.
The program processes the operations in the order specified on the calculation
specifications form.
ΓòÉΓòÉΓòÉ 1.8.1.6. Positions 33-42 (Factor 2) ΓòÉΓòÉΓòÉ
Factor 2 names a field or gives the actual data (literals) on which a
calculation is to be done. For the file operation codes, factor 2 names a file
or record format to be used. The entry must begin in position 33. The entries
that are valid for factor 2 depend on the operation code specified in positions
28 through 32. With some operation codes, a colon can be used to separate parts
of the factor, but must be preceded by and followed by a valid entry. For the
specific entries for factor 2 for a particular operation code, see Operation
Codes.
ΓòÉΓòÉΓòÉ 1.8.1.7. Positions 43-48 (Result Field) ΓòÉΓòÉΓòÉ
The result field names the field that contains the result of the calculation
operation specified in positions 28 through 32. Array elements are treated as
fields. A look-ahead field, user date special word a literal, or a named
constant cannot appear as the result field of a calculation. See Operation
Codes for the result field rules for individual operation codes.
ΓòÉΓòÉΓòÉ 1.8.1.8. Positions 49-51 (Field Length) ΓòÉΓòÉΓòÉ
Entry Explanation
1-30 Numeric field length.
1-256 Character field length.
Blank The result field is defined elsewhere.
Positions 49 through 51 specify the length of the result field. This entry is
optional, but can be used to define a field not defined elsewhere in the
program. These definitions of the field entries are allowed if the result
field contains a field name.
The entry specifies the number of positions to be reserved for the result
field. The entry must be right-adjusted. The unpacked length (number of digits)
must be specified for numeric fields.
If the length of an arithmetic result to the left of the decimal point exceeds
the specified length, the excess leftmost digits and any excess decimal
positions are dropped. No diagnostic message occurs if the result is
truncated.
If the result field is defined elsewhere in the program, no entry is required
for the length. However, if the length is specified, and if the result field
is defined elsewhere, the length must be the same as the previously defined
length.
If half-adjustment is specified in position 53 of the calculation
specifications, the entries for field length (positions 49 through 51) and
decimal positions (position 52) refer to the length of the result field after
half-adjustment.
ΓòÉΓòÉΓòÉ 1.8.1.9. Position 52 (Decimal Positions) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The result field is character data or has been defined elsewhere
in the program.
0-9 Number of decimal positions in a numeric result field.
Position 52 indicates the number of positions to the right of the decimal in a
numeric result field. If the numeric result field contains no decimal
positions, enter a '0' (zero). This position must be blank if the result field
is character data. This position can be left blank if the result field is
numeric but was described by input or calculation specifications or in an
external description. In this case, field length (positions 49 through 51)
must also be left blank. The number of decimal positions specified cannot
exceed the length of the field.
ΓòÉΓòÉΓòÉ 1.8.1.10. Position 53 (Operation Extender) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No operation extension supplied.
H Half adjust.
N Record is read but not locked.
P Pad the result field with blanks.
The operation extenders are single-character entries that provide additional
attributes to the operations that they accompany. Operation extenders are
specified in position 53 of calculation specifications.
An H indicates whether the contents of the result field are to be half adjusted
(rounded). Half-adjusting is done by adding 5 (-5 if the field is negative) one
position to the right of the last specified decimal position in the result
field. The half adjust entry is allowed only with arithmetic operations, but
not with an MVR operation or with a DIV operation followed by the MVR
operation. Half adjust can be specified only if the number of decimal positions
in the generated result is greater than the number of decimal positions in the
result field. Resulting indicators are set according to the value of the result
field after half-adjusting has been done.
An N in a READ, READE, READP, REDPE, or CHAIN operation on an update disk file
indicates that a record is to be read, but not locked. If no value is
specified, the default action of locking occurs.
A P indicates that, for CAT, SUBST, MOVEA, MOVEL, or XLATE, the result field is
padded on the right after executing the instruction if the result field is
longer than the result of the operation. Padding is done from the left for
MOVE.
ΓòÉΓòÉΓòÉ 1.8.1.11. Positions 54-59 (Resulting Indicators) ΓòÉΓòÉΓòÉ
These positions can be used, for example, to test the value of a result field
after the completion of an operation, or to indicate an end-of-file, error, or
record-not-found condition. The resulting indicator positions have different
uses, depending on the operation code specified. See the individual operation
codes in Operation Codes for a description of the associated resulting
indicators. For arithmetic operations, the result field is tested only after
the field is truncated and half-adjustment is done (if specified). The setting
of indicators depends on the results of the tests specified.
Entry Explanation
Blank No resulting indicator specified
01-99 General indicators
KA-KN, KP-KY Function key indicators
H1-H9 Halt indicators
L1-L9 Control level indicators
LR Last record indicator
OA-OG, OV Overflow indicators
U1-U8 External indicators
RT Return indicator.
Resulting indicators cannot be used when the result field uses a non-indexed
array.
If the same indicator is used as a resulting indicator on more than one
calculation specification, the last calculation specification processed
determines the status of that indicator.
Remember the following points when specifying resulting indicators:
When the calculation operation is done, the specified resulting indicators
are set off, and, if a condition specified by a resulting indicator is
satisfied, that indicator is set on.
When a control level indicator (L1 through L9) is set on, the lower level
indicators are not set on.
When a halt indicator (H1 through H9) is set on, the program ends unless the
halt indicator is set off before the indicator is tested.
ΓòÉΓòÉΓòÉ 1.8.1.12. Positions 60-74 (Comments) ΓòÉΓòÉΓòÉ
Positions 60 through 74 of each calculation specification line can be used for
comments to document the purpose of that calculation.
ΓòÉΓòÉΓòÉ 1.8.1.13. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank. These
positions are not printed contiguously with positions 6-74 on the compiled
listing.
ΓòÉΓòÉΓòÉ 1.9. Output Specifications ΓòÉΓòÉΓòÉ
Output specifications describe the record and the format of fields in a program
described output file and when the record is to be written. Output
specifications are optional for an externally described file. Output
specifications can be divided into two categories: record identification and
control (positions 7 through 37), and field description and control (positions
23 through 70). These specifications are entered on the RPG/400 Output
Specifications.
Detailed information for the output specifications is given in:
Entries for program described files
Entries for externally described files
ΓòÉΓòÉΓòÉ 1.9.1. Program Described Files ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Record Identification and Control Entries
Field Description and Control Entries
ΓòÉΓòÉΓòÉ 1.9.1.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An O must appear in position 6 to identify this line as an output
specifications statement.
ΓòÉΓòÉΓòÉ 1.9.2. Record Identification and Control Entries ΓòÉΓòÉΓòÉ
Positions 7-14 (File Name)
Positions 14-16 (Logical Relationship)
Position 15 (Type - Program Described File)
Positions 16-18 (Record Addition/Deletion)
Position 16 (Fetch Overflow/Release)
- Fetch Overflow
- Release
Positions 17-22 (Space and Skip)
Position 17 (Space Before)
Position 18 (Space After)
Positions 19-20 (Skip Before)
Positions 21-22 (Skip After)
Positions 23-31 (File Record ID Indicators)
Positions 32-37 (EXCPT Name)
Entries in positions 7 through 37 identify the output records that make up the
files, provide the correct spacing on printed reports, and determine under what
conditions the records are to be written.
ΓòÉΓòÉΓòÉ 1.9.2.1. Positions 7-14 (File Name) ΓòÉΓòÉΓòÉ
Entry Explanation
A valid file name Same file name that appears on the file description
specifications for the output file.
Specify the file name on the first line that defines an output record for the
file. The file name specified must be the same file name assigned to the
output, update, or combined file on the file description specifications. If
records from files are interspersed on the output specifications, the file name
must be specified each time the file changes.
For files specified as output, update, combined or input with ADD, at least one
output specification is required unless an explicit file operation code with a
data structure name specified in the result field is used in the calculations.
For example, a WRITE operation does not require output specifications.
ΓòÉΓòÉΓòÉ 1.9.2.2. Positions 14-16 (Logical Relationship) ΓòÉΓòÉΓòÉ
Entry Explanation
AND or OR AND/OR indicates a relationship between lines of output
indicators. AND/OR lines are valid for output records, but not for
fields.
Positions 14 through 16 specify AND/OR lines for output operations. To specify
this relationship, enter AND/OR in positions 14 through 16 on each additional
line following the line containing the file name. At least one indicator must
be specified on each AND line. For an AND relationship and fetch overflow
position 16 must be specified on the first line only (file name line). A fetch
overflow entry is required on OR lines for record types requiring the fetch
overflow routine.
Positions 17 through 22 (spacing and skipping) must be blank on an AND line.
In an OR relationship, positions 17 through 22 can be used; if they are blank,
the definitions from the preceding line are used. Positions 7 through 13 must
be blank when AND/OR is specified.
An unlimited number of AND/OR lines can be specified on the output
specifications.
ΓòÉΓòÉΓòÉ 1.9.2.3. Position 15 (Type - Program Described File) ΓòÉΓòÉΓòÉ
Entry Explanation
H or D Detail records usually contain data that comes directly from the
input record or that is the result of calculations processed at
detail time. Heading records usually contain constant identifying
information such as titles, column headings, page number, and
date. No distinction is made between heading and detail records.
The H/D specifications are available to help the programmer
document the program.
T Total records usually contain data that is the end result of
specific calculations on several detail records.
E Exception records are written during calculation time. Exception
records can be specified only when the operation code EXCPT is
used. See Operation Codes for further information on the EXCPT
operation code.
Position 15 indicates the type of record to be written. Position 15 must have
an entry for every output record. Heading (H) and detail (D) lines are both
processed as detail records. No special sequence is required for coding the
output records; however, all lines of each record type (H, D, T, or E) are
handled at separate times within the program cycle.
ΓòÉΓòÉΓòÉ 1.9.2.4. Positions 16-18 (Record Addition/Deletion) ΓòÉΓòÉΓòÉ
Entry Explanation
ADD Add a record to the file or subfile.
DEL Delete the last record read from the file. The deleted record
cannot be retrieved; the record is deleted from the system.
An entry of ADD is valid for input, output, or update files. DEL is valid for
update DISK files only.
Note: The file description specifications for a file using the ADD function
for DISK files must have an A in position 66.
This entry must appear on the same line that contains the record type (H, D, T,
E) specification (position 15). If an OR line is used following an ADD or DEL
entry, this entry applies to the OR line also.
ΓòÉΓòÉΓòÉ 1.9.2.5. Position 16 (Fetch Overflow/Release) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank Must be blank for all files except printer files (PRINTER
specified in positions 40 through 46 of the file description
specifications). If position 16 is blank for printer files,
overflow is not fetched.
F Fetch overflow.
R Release a device (workstation) after output.
ΓòÉΓòÉΓòÉ 1.9.2.5.1. Fetch Overflow ΓòÉΓòÉΓòÉ
An F in position 16 specifies fetch overflow for the printer file defined on
this line. This file must be a printer file that has overflow lines. Fetch
overflow is processed only when an overflow occurs and when all conditions
specified by the indicators in positions 23 through 31 are satisfied. An
overflow indicator cannot be specified on the same line as fetch overflow.
If an overflow indicator has not been specified in positions 33 and 34 of the
file description specifications for a printer file, the compiler assigns one to
the file. An overflow line is generated by the compiler for the file, except
when no other output records exist for the file or when the printer uses
externally described data. This compiler-generated overflow can be fetched.
Overflow lines can be written during detail, total, or exception output time.
When the fetch overflow is specified, only overflow output associated with the
file containing the processed fetch is output. The fetch overflow entry (F) is
required on each OR line for record types that require the overflow routine.
The fetch overflow routine does not automatically advance forms.
The form length and overflow line can be specified on the line counter
specifications, in the printer device file, or through an OS/400 override
command.
ΓòÉΓòÉΓòÉ 1.9.2.5.2. Release ΓòÉΓòÉΓòÉ
After an output operation is complete, the device used in the operation is
released if you have specified an R in position 16 of the corresponding output
specifications. See the REL (Release) operation for further information on
releasing devices.
ΓòÉΓòÉΓòÉ 1.9.2.6. Positions 17-22 (Space and Skip) ΓòÉΓòÉΓòÉ
Use positions 17 through 22 to specify line spacing and skipping for a printer
file. Spacing refers to advancing one line at a time, and skipping refers to
jumping from one print line to another.
If spacing and skipping are specified for the same line, the spacing and
skipping operations are processed in the following sequence:
Skip before
Space before
Print a line
Skip after
Space after.
If PRTCTL (printer control option) is not specified on the file description
specifications, an entry must be made in one of the following positions when
the device is PRINTER: 17 (space before), 18 (space after), 19 and 20 (skip
before), or 21 and 22 (skip after). If a space/skip entry is left blank, the
particular function with the blank entry (such as space before or space after)
does not occur. If entries are made in position 17 (space before) or in
positions 19 through 22 (skip before and skip after) and no entry is made in
position 18 (space after), no space occurs after printing. When PRTCTL is
specified, it is used only on records with blanks specified in positions 17
through 22.
If a skip before or a skip after a line on a new page is specified, but the
printer is on that line, the skip does not occur.
ΓòÉΓòÉΓòÉ 1.9.2.7. Position 17 (Space Before) ΓòÉΓòÉΓòÉ
Entry Explanation
0 or Blank No spacing
1 Single spacing
2 Double spacing
3 Triple spacing.
ΓòÉΓòÉΓòÉ 1.9.2.8. Position 18 (Space After) ΓòÉΓòÉΓòÉ
Entry Explanation
0 or Blank No spacing
1 Single spacing
2 Double spacing
3 Triple spacing.
ΓòÉΓòÉΓòÉ 1.9.2.9. Positions 19-20 (Skip Before) ΓòÉΓòÉΓòÉ
Entry Explanation
0 or Blank No skipping occurs.
01-99 Skip to lines 1 to 99 before printing for printer files.
A0-A9 Skip to lines 100 to 109 before printing for printer files.
B0-B2 Skip to lines 110 to 112 before printing for printer files.
ΓòÉΓòÉΓòÉ 1.9.2.10. Positions 21-22 (Skip After) ΓòÉΓòÉΓòÉ
Entry Explanation
0 or Blank No skipping occurs.
01-99 Skip to lines 1 to 99 after printing for printer files.
A0-A9 Skip to lines 100 to 109 after printing for printer files.
B0-B2 Skip to lines 110 to 112 after printing for printer files.
ΓòÉΓòÉΓòÉ 1.9.2.11. Positions 23-31 (File Record ID Indicators) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The line or field is output every time the record
(heading, detail, total, or exception) is checked for
output.
01-99 A general indicator that is used as a resulting
indicator, field indicator, or record identifying
indicator.
KA-KN, KP-KY Function key indicators.
L1-L9 Control level indicators.
H1-H9 Halt indicators.
U1-U8 External indicator set before running the program or set
as a result of a calculation operation.
OA-OG, OV Overflow indicator previously assigned to this file.
MR Matching record indicator.
LR Last record indicator.
RT Return indicator.
1P First-page indicator. Valid only on heading or detail
lines.
Conditioning indicators are not required on output lines. If conditioning
indicators are not specified, the line is output every time that record is
checked for output. Up to three indicators can be entered on one specification
line to control when a record or a particular field within a record is written.
The indicators that condition the output are coded in positions 24 and 25, 27
and 28, and 30 and 31. When an N is entered in positions 23, 26, or 29, the
indicator in the associated position must be off for the line or field to be
written. Otherwise, the indicator must be on for the line or field to be
written.
If more than one indicator is specified on one line, all indicators are
considered to be in an AND relationship.
If the output record must be conditioned by more than three indicators in an
AND relationship, enter the letters AND in positions 14 through 16 of the
following line and specify the additional indicators in positions 23 through 31
on that line.
For an AND relationship, fetch overflow (position 16) can only be specified on
the first line. Positions 17 through 22 (spacing and skipping) must be blank
for all AND lines.
An overflow indicator must be defined on the file description specifications
(positions 33 and 34) before it can be used as a conditioning indicator. If a
line is to be conditioned as an overflow line, the overflow indicator must
appear on the main specification line or on the OR line. If an overflow
indicator is used on an AND line, the line is not treated as an overflow line,
but the overflow indicator is checked before the line is written. In this case,
the overflow indicator is treated like any other output indicator.
If the output record is to be written when any one of two or more sets of
conditions exist (an OR relationship), enter the letters OR in positions 14 and
15 of the following specification line, and specify the additional OR
indicators on that line.
When an OR line is specified for a printer file, the skip and space entries
(positions 17 through 22) can all be blank, in which case the space and skip
entries of the preceding line are used. If they differ from the preceding
line, enter space and skip entries on the OR line. If fetch overflow (position
16) is used, it must be specified on each OR line.
ΓòÉΓòÉΓòÉ 1.9.2.12. Positions 32-37 (EXCPT Name) ΓòÉΓòÉΓòÉ
When the record type is an exception record (indicated by an E in position 15),
a name can be placed in these positions of the record line. The EXCPT
operation can specify the name assigned to a group of the records to be output.
This name is called an EXCPT name. An EXCPT name must follow the rules for
using symbolic names. A group of any number of output records can use the same
EXCPT name, and the records do not have to be consecutive records.
When the EXCPT operation is specified without an EXCPT name, only those
exception records without an EXCPT name are checked and written if the
conditioning indicators are satisfied.
When the EXCPT operation specifies an EXCPT name, only the exception records
with that name are checked and written if the conditioning indicators are
satisfied.
The EXCPT name is specified on the main record line and applies to all AND/OR
lines.
If an exception record with an EXCPT name is conditioned by an overflow
indicator, the record is written only during the overflow portion of the
RPG/400 cycle or during fetch overflow. The record is not written at the time
the EXCPT operation is processed.
An EXCPT operation with no fields can be used to release a record lock in a
file. The UNLCK operation can also be used for this purpose. In the following
figure, the record lock in file RCDA is released by the EXCPT operation.
Record Lock in File Released by EXCPT Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C KEY CHAINRCDA
C EXCPTRELESE
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
O
O*
ORCDA E RELESE
O* (no fields)
ΓòÉΓòÉΓòÉ 1.9.3. Field Description and Control Entries ΓòÉΓòÉΓòÉ
Entries in positions 23 through 70 determine under what conditions and in what
format fields of a record are to be written.
Each field is described on a separate line. No entries are permitted in
positions 7 through 22 of a field description line. Field description and
control information for a field begins on the line following the record
identification line.
Positions 23-31 (File Field Description Indicators)
Positions 32-37 (Field Name)
- Field Names, Blanks, Tables and Arrays
- PAGE, PAGE1-PAGE7
- *PLACE
- User Date Reserved Words
- *IN, *INxx, *IN,xx
Position 38 (Edit Codes)
Position 39 (Blank After)
Positions 40-43 (End Position)
Position 44 (Data Format)
Positions 45-70 (Constant or Edit Word)
- Constants
- Edit Words
- Format Name
Positions 71-74 (Reserved)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.9.3.1. Positions 23-31 (File Field Description Indicators) ΓòÉΓòÉΓòÉ
Indicators specified on the field description lines determine whether a field
is to be included in the output record, except for PAGE reserved fields. See
PAGE, PAGE1-PAGE7 for information on how output indicators affect the PAGE
fields. The same types of indicators can be used to control fields as are used
to control records, see Positions 23-31 (File Record ID Indicators). Indicators
used to condition field descriptions lines cannot be specified in an AND/OR
relationship. Conditioning indicators cannot be specified on format name
specifications for program described WORKSTN files.
ΓòÉΓòÉΓòÉ 1.9.3.2. Positions 32-37 (Field Name) ΓòÉΓòÉΓòÉ
In positions 32 through 37, use one of the following entries to specify each
field that is to be written out:
A field name
Blanks if a constant is specified in positions 45 through 70
A table name, array name, or array element
A named constant
The RPG/400 reserved words PAGE, PAGE1 through PAGE7, *PLACE, UDATE, *DATE,
UDAY, *DAY, UMONTH, *MONTH, UYEAR, *YEAR, *IN, *INxx, or *IN,xx
A data structure name or data structure subfield name.
ΓòÉΓòÉΓòÉ 1.9.3.2.1. Field Names, Blanks, Tables and Arrays ΓòÉΓòÉΓòÉ
The field names used must be defined in the program. Do not enter a field name
if a constant or edit word is used in positions 45 through 70. If a field name
is entered in positions 32 through 37, positions 7 through 22 must be blank.
Fields can be specified in any order because the sequence in which they appear
on the output records is determined by the entry in positions 40 through 43.
If fields overlap, the last field specified is the only field completely
written.
When a non-indexed array name is specified, the entire array is written. An
array name with a constant index or variable index causes one element to be
written. When a table name is specified, the element last found in a LOKUP
(Look Up) operation is written. The first element of a table is written if no
successful LOKUP operation was done.
The conditions for a field and the conditions for the record it is contained in
must be satisfied before the field is written out.
ΓòÉΓòÉΓòÉ 1.9.3.2.2. PAGE, PAGE1-PAGE7 ΓòÉΓòÉΓòÉ
To use automatic page numbering, code PAGE in positions 32 through 35 as the
name of the output field. Indicators specified in positions 23 though 31 do not
condition the field, but rather control the resetting of the PAGE field. When
indicators are specified and their conditions are met, the PAGE field is set to
zero and incremented by 1 before output; when the conditions are not met, the
PAGE field is incremented by 1 and then output. If page numbers are needed for
several output files (or for different numbering within one file), the entries
PAGE1 through PAGE7 can be used. The PAGE fields are automatically
zero-suppressed by the Z edit code.
For more information on the PAGE reserved words, see RPG/400 Words with Special
Functions.
ΓòÉΓòÉΓòÉ 1.9.3.2.3. *PLACE ΓòÉΓòÉΓòÉ
*PLACE is an RPG/400 reserved word that is used to repeat data in an output
record. Fields or constants that have been specified on previous specification
lines can be repeated in the output record without having the field and end
positions named on a new specification line. When *PLACE is coded in positions
32 through 37, all data between the first position and the highest end position
previously specified for a field in that output record is repeated until the
end position specified in the output record on the *PLACE specification line is
reached. The end position specified on the *PLACE specification line must be
at least twice the highest end position of the group of fields to be
duplicated. *PLACE can be used with any type of output. Blank after (position
39), editing (positions 38, 45 through 70), data format (position 44), and
relative end positions cannot be used with *PLACE.
ΓòÉΓòÉΓòÉ 1.9.3.2.4. User Date Reserved Words ΓòÉΓòÉΓòÉ
The user date reserved words (UDATE, *DATE, UDAY, *DAY, UMONTH *MONTH, UYEAR,
*YEAR) allow the programmer to supply a date for the program at run time. For
more information on the user date reserved words, see Rules for User Date.
ΓòÉΓòÉΓòÉ 1.9.3.2.5. *IN, *INxx, *IN,xx ΓòÉΓòÉΓòÉ
The reserved words *IN, *INxx and *IN,xx allow the programmer to refer to and
manipulate RPG/400 indicators as data.
ΓòÉΓòÉΓòÉ 1.9.3.3. Position 38 (Edit Codes) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank No edit code is used.
1-9, A-D, J-Q, X, Y, Z Numeric fields are zero-suppressed and punctuated
according to a predefined pattern without the use of
edit words.
Position 38 is used to specify edit codes that suppress leading zeros in a
numeric field or to punctuate a numeric field without using an edit word.
Allowable entries are 1 through 9, A through D, J through Q, X, Y, Z, and
blank.
Edit codes 5 through 9 are user-defined edit codes and are defined externally
by an OS/400 function. The edit code is determined at compilation time.
Subsequent changes to a user-defined edit code will not affect the editing by
the RPG/400 compiler unless the program is recompiled.
For more information see Simple Edit Codes and Combination Edit Codes.
ΓòÉΓòÉΓòÉ 1.9.3.4. Position 39 (Blank After) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The field is not reset.
B The field specified in positions 32 through 37 is reset to blank
or zero after the output operation is complete.
Position 39 is used to reset a numeric field to zeros or a character field to
blanks. If the field is conditioned by indicators in positions 23 through 31,
the blank after is also conditioned. This position must be blank for
look-ahead, user date special words, *PLACE, named constants, and constants.
Resetting fields to zeros is useful when totals are accumulated and written for
each control group in a program. After the total is accumulated and written for
one control group, the total field can be reset to zeros before accumulation
begins on the total for the next control group.
If blank after (position 39) is specified for a field to be written more than
once, the B should be entered on the last line specifying output for that
field, or else the field named may be set to blanks or zeros after the field is
written to the output record.
ΓòÉΓòÉΓòÉ 1.9.3.5. Positions 40-43 (End Position) ΓòÉΓòÉΓòÉ
Entry Explanation
1-n End position
K1-K8 Length of format name for WORKSTN file.
Positions 40 through 43 define the end position of a field or constant on the
output record, or define the length of the data description specifications
record format name for a program described WORKSTN file.
The K identifies the entry as a length rather than an end position, and the
number following the K indicates the length of the record format name. For
example, if the format name is CUSPMT, the entry in positions 42 and 43 is K6.
Leading zeros are permitted following the K, and the entry must be
right-adjusted.
Valid entries for end positions are blanks, +nnn, -nnn, and nnnn. All entries
in these positions must end in position 43. Enter the position of the rightmost
character of the field or constant. The end position must not exceed the record
length for the file.
If an entire array is to be written, enter the end position of the last element
in the array in positions 40 through 43. If the array is to be edited, be
careful when specifying the end position to allow enough positions to write all
edited elements. Each element is edited according to the edit code or edit
word.
The +nnn or -nnn entry specifies the placement of the field or constant
relative to the end position of the previous field. The sign must be in
position 40. The number (nnn) must be right-adjusted, but leading zeros are
not required. To calculate the end position, use these formulas:
EP = PEP +nnn + FL
EP = PEP -nnn + FL
EP is the calculated end position. PEP is the previous end position. For the
first field specification in the record, PEP is equal to zero. FL is the length
of the field after editing, or the length of the constant specified in this
specification. The use of +nnn is equivalent to placing nnn positions between
the fields. A -nnn causes an overlap of the fields by nnn positions. For
example, if the previous end position (PEP) is 6, the number of positions to be
placed between the fields (nnn) is 5, and the field length (FL) is 10, the end
position (EP) equals 21.
When *PLACE is used, an actual end position must be specified; it cannot be
blank or a displacement.
An entry of blank is treated as an entry of +000. No positions separate the
fields.
ΓòÉΓòÉΓòÉ 1.9.3.6. Position 44 (Data Format) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The field is to be written in zoned decimal numeric or character
format; numeric data is edited, or a constant is specified on this
line.
P The field is to be written in packed decimal format.
B The field is to be written in binary format.
L The numeric output field is to have a preceding (left) plus or
minus sign.
R The numeric output field is to have a following (right) plus or
minus sign.
This position must be blank if editing is specified.
The entry in position 44 specifies the format of the data in the records in the
file. This entry has no effect on the format used for internal processing of
the output field in the program.
ΓòÉΓòÉΓòÉ 1.9.3.7. Positions 45-70 (Constant or Edit Word) ΓòÉΓòÉΓòÉ
Positions 45 through 70 are used to specify a constant, a format name, or an
edit word for a program described file.
ΓòÉΓòÉΓòÉ 1.9.3.7.1. Constants ΓòÉΓòÉΓòÉ
Constants consist of character data (literals) that does not change from one
processing of the program to the next. A constant is the actual data used in
the output record rather than a name representing the location of the data.
A constant of up to 24 characters can be placed in positions 45 through 70.
The constant must begin in position 46 (apostrophe in position 45), and it must
end with an apostrophe even if it contains only numeric characters. Any
apostrophe used within the constant must be entered twice; however, only one
apostrophe appears when the constant is written out. The field name (positions
32 through 37) must be blank. Instead of entering a constant, you can use a
named constant containing a maximum of 256 characters.
ΓòÉΓòÉΓòÉ 1.9.3.7.2. Edit Words ΓòÉΓòÉΓòÉ
An edit word specifies the punctuation of numeric fields, including the
printing of dollar signs, commas, periods, and sign status. See Parts of an
Edit Word for details.
ΓòÉΓòÉΓòÉ 1.9.3.7.3. Format Name ΓòÉΓòÉΓòÉ
The name of the data description specifications record format that is used by a
program described WORKSTN file must be specified in positions 45 through 54.
One format name is required for each output record for the WORKSTN file;
specifying more than one format name per record is not allowed. Conditioning
indicators cannot be specified on format name specifications for program
described WORKSTN files. The format name must be enclosed in apostrophes. You
must also enter Kn in positions 40 through 43, where n is the length of the
format name. For example, if the format name is 'CUSPMT', enter K6 in
positions 42 and 43. A named constant can also be used.
ΓòÉΓòÉΓòÉ 1.9.3.8. Positions 71-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 71 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.9.3.9. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank.
ΓòÉΓòÉΓòÉ 1.9.4. Externally Described Files ΓòÉΓòÉΓòÉ
Position 6 (Form Type)
Record Identification and Control Entries
Field Description and Control Entries
ΓòÉΓòÉΓòÉ 1.9.4.1. Position 6 (Form Type) ΓòÉΓòÉΓòÉ
An O must appear in position 6 to identify this line as an output
specifications statement.
ΓòÉΓòÉΓòÉ 1.9.5. Record Identification and Control Entries ΓòÉΓòÉΓòÉ
Output specifications for an externally described file are optional. Entries
in positions 7 through 37 of the record identification line identify the record
format and determine under what conditions the records are to be written.
Positions 7-14 (Record Name)
Positions 14-16 (External Logical Relationship)
Position 15 (Type - Externally Described File)
Position 16 (Release)
Positions 16-18 (Record Addition)
Positions 16-22 (Fetch Overflow/Space/Skip)
Positions 23-31 (External File Record ID Indicators)
Positions 32-37 (EXCPT Name)
ΓòÉΓòÉΓòÉ 1.9.5.1. Positions 7-14 (Record Name) ΓòÉΓòÉΓòÉ
Entry Explanation
A valid record format name A record format name must be specified for an
externally described file.
ΓòÉΓòÉΓòÉ 1.9.5.2. Positions 14-16 (External Logical Relationship) ΓòÉΓòÉΓòÉ
Entry Explanation
AND or OR AND/OR indicates a relationship between lines of output
indicators. AND/OR lines are valid for output records, but not for
fields.
See Positions 14-16 (Logical Relationship) for more information.
ΓòÉΓòÉΓòÉ 1.9.5.3. Position 15 (Type - Externally Described File) ΓòÉΓòÉΓòÉ
Entry Explanation
H or D Detail records
T Total records
E Exception records.
Position 15 indicates the type of record to be written. See Position 15 (Type -
Program Described File) for more information.
ΓòÉΓòÉΓòÉ 1.9.5.4. Position 16 (Release) ΓòÉΓòÉΓòÉ
Entry Explanation
R Release a device after output.
See Release for more information.
ΓòÉΓòÉΓòÉ 1.9.5.5. Positions 16-18 (Record Addition) ΓòÉΓòÉΓòÉ
Entry Explanation
ADD Add a record to a file.
DEL Delete an existing record from the file.
For more information on record addition, see Positions 16-18 (Record
Addition/Deletion).
ΓòÉΓòÉΓòÉ 1.9.5.6. Positions 16-22 (Fetch Overflow/Space/Skip) ΓòÉΓòÉΓòÉ
The fetch overflow, space, and skip entries for an externally described file
must be blank. Space and skip entries for an externally described printer file
are specified in the data description specifications.
ΓòÉΓòÉΓòÉ 1.9.5.7. Positions 23-31 (External File Record ID Indicators) ΓòÉΓòÉΓòÉ
Output indicators for externally described files are specified in the same way
as those for program described files. The overflow indicators OA-OG, OV are not
valid for externally described files. For more information on output
indicators, see Positions 23-31 (File Record ID Indicators).
ΓòÉΓòÉΓòÉ 1.9.5.8. Positions 32-37 (EXCPT Name) ΓòÉΓòÉΓòÉ
An EXCPT name can be specified in these positions for an exception record line.
See Positions 32-37 (EXCPT Name) for more information.
ΓòÉΓòÉΓòÉ 1.9.6. Field Description and Control Entries ΓòÉΓòÉΓòÉ
For externally described files, the only valid field description and control
entries are conditioning indicators (positions 23 through 31), field name
(positions 32 through 37), and blank after (position 39).
Positions 23-31 (External Field Description Indicators)
Positions 32-37 (Field Name)
Position 38 (Edit Codes)
Position 39 (Blank After)
Positions 40-43 (End Position)
Position 44 (Data Format)
Positions 45-70 (Constant or Edit Word)
Positions 71-74 (Reserved)
Positions 75-80 (Comments)
ΓòÉΓòÉΓòÉ 1.9.6.1. Positions 23-31 (External Field Description Indicators) ΓòÉΓòÉΓòÉ
Indicators specified on the field description lines determine whether a field
is to be included in the output record. The same types of indicators can be
used to control fields as are used to control records. See Positions 23-31
(File Record ID Indicators) for more information.
ΓòÉΓòÉΓòÉ 1.9.6.2. Positions 32-37 (Field Name) ΓòÉΓòÉΓòÉ
Entry Explanation
Valid field name A field name specified for an externally described file must
be present in the external description unless the external
name was renamed for the program.
*ALL Specifies the inclusion of all the fields in the record.
For externally described files, only the fields specified are placed in the
output record. *ALL can be specified to include all the fields in the record.
If *ALL is specified, no other field description lines can be specified for
that record. In particular, you cannot specify a B (blank after) in position
39.
For an update record, only those fields specified in the output field
specifications and meeting the conditions specified by the output indicators
are placed in the output record to be rewritten. The values that were read are
used to rewrite all other fields.
For the creation of a new record, the fields specified are placed in the output
record. Those fields not specified or not meeting the conditions specified by
the output indicators are written as zeros or blanks, depending on the data
format specified in the external description.
ΓòÉΓòÉΓòÉ 1.9.6.3. Position 38 (Edit Codes) ΓòÉΓòÉΓòÉ
Position 38 must be blank because edit codes for externally described files are
specified in the data description specifications.
ΓòÉΓòÉΓòÉ 1.9.6.4. Position 39 (Blank After) ΓòÉΓòÉΓòÉ
Entry Explanation
Blank The field is not reset.
B The field specified in positions 32 through 37 is reset to blanks
or zeros after the output operation is complete. Do not specify
*ALL in positions 32 through 37.
For more information on blank after, see Position 39 (Blank After).
ΓòÉΓòÉΓòÉ 1.9.6.5. Positions 40-43 (End Position) ΓòÉΓòÉΓòÉ
These positions must be blank because the field is placed in the output record
in the positions specified by the data description specifications.
ΓòÉΓòÉΓòÉ 1.9.6.6. Position 44 (Data Format) ΓòÉΓòÉΓòÉ
This position must be blank because the data format is defined in the data
description specifications.
ΓòÉΓòÉΓòÉ 1.9.6.7. Positions 45-70 (Constant or Edit Word) ΓòÉΓòÉΓòÉ
These positions must be blank because editing is specified in the data
description specifications. If a constant is to be placed in an externally
described file, it must be done by a calculation operation.
ΓòÉΓòÉΓòÉ 1.9.6.8. Positions 71-74 (Reserved) ΓòÉΓòÉΓòÉ
Positions 71 through 74 must be blank.
ΓòÉΓòÉΓòÉ 1.9.6.9. Positions 75-80 (Comments) ΓòÉΓòÉΓòÉ
Positions 75 through 80 can be used for comments, or left blank.
ΓòÉΓòÉΓòÉ 1.10. Operation Codes ΓòÉΓòÉΓòÉ
The RPG/400 programming language allows you to do many different types of
operations on your data. Operation codes, which are entered on the calculation
specifications, indicate the operation to be done. Usually they are
abbreviations of the name of the operation.
For a list of the operation codes, see Operation Codes List.
ΓòÉΓòÉΓòÉ 1.10.1. Arithmetic Operations ΓòÉΓòÉΓòÉ
The arithmetic operations are:
ADD (Add)
DIV (Divide)
MULT (Multiply)
MVR (Move Remainder)
SQRT (Square Root)
SUB (Subtract)
XFOOT (Summing the Elements of an Array)
Z-ADD (Zero and Add)
Z-SUB (Zero and Subtract).
For examples of arithmetic operations, see Figure "Summary of Arithmetic
Operations".
Remember the following when specifying arithmetic operations:
Arithmetic operations can be done only on numeric fields (including numeric
subfields, numeric arrays, numeric array elements, numeric table elements,
numeric named constants, numeric figurative constants, and numeric literals).
Arithmetic operations are done on data in packed decimal format. Data
maintained in other formats is converted to or from packed decimal format.
Decimal alignment is done for all arithmetic operations. Even though
truncation can occur, the position of the decimal point in the result field
is not affected.
An arithmetic operation does not change factor 1 and factor 2 unless they are
the same as the result field.
Any data placed in the result field replaces the data that was there.
The result field must be large enough to accommodate the results of the
arithmetic operation because an RPG/400 program does not cause an error on an
arithmetic overflow. If the result field is not large enough to accommodate
the results, digits are dropped from either or both ends, depending on the
location of the decimal point.
If you use conditioning indicators, it is your responsibility to ensure that
the DIV operation occurs immediately before the MVR operation. If the MVR
operation occurs before the DIV operation, undesirable results occur. An
error message may be issued.
Half adjust (position 53) can be specified for all the arithmetic operations
except for the MVR operation or for a DIV operation immediately followed by
an MVR operation.
For arithmetic operations in which all three fields are used:
Factor 1, factor 2, and the result field can be three different fields.
Factor 1, factor 2, and the result field can all be the same field.
Factor 1 and factor 2 can be the same field but different from the result
field.
Either factor 1 or factor 2 can be the same as the result field.
The length of any field specified in an arithmetic operation cannot exceed 30
digits. If the result exceeds 30 digits, digits are dropped from either or both
ends, depending on the location of the decimal point.
All arithmetic operations are done algebraically.
The results of all operations are signed (a plus sign is a hexadecimal F and a
minus sign is a hexadecimal D) according to the following rules. The sign is in
the zone portion of the low-order byte.
For information on using arrays with arithmetic operations, see Specifying an
Array in Calculations.
Addition: If factor 1 and factor 2 have like signs, the result field sign is
the same. If factor 1 and factor 2 have unlike signs, the result field sign is
the same as the sign of the factor with the larger absolute value.
Subtraction: Change the sign of factor 2, and apply the rules for addition.
Multiplication: If factor 1 and factor 2 have like signs, the result field sign
is plus (+). If factor 1 and factor 2 have unlike signs, the result field sign
is minus (-).
Division: If factor 1 and factor 2 have like signs, the result field sign is
plus (+). If factor 1 and factor 2 have unlike signs, the result field sign is
minus (-). The sign of the remainder is the same as the factor 1 sign.
For the ADD, SUB, MULT, and DIV operations, factor 1 is not required. If factor
1 is not specified, the operation is done as though factor 1 and the result
field were the same field.
ΓòÉΓòÉΓòÉ 1.10.1.1. Arithmetic Operations Examples ΓòÉΓòÉΓòÉ
Summary of Arithmetic Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++*
C* Before the operations are processed, the field values are:
C* A = 1.00 G = 2.77
C* B = 10.0 H = 70
C* C = 32 J = .6
C* D = -20 K = 25
C* E = 6. L = 1.0, 1.7, -1.1 RESULTS
C* F = 10.0 -------
C ADD 1 A 30 002
C B ADD C V 52 042.00
C B ADD D V -10.00
C*
C Z-ADDC V 032.00
C*
C SUB 1 E 30 005
C C SUB B W 51 0022.0
C C SUB D W 0052.0
C*
C Z-SUBC W -0032.0
C*
C MULT E F 30 060
C B MULT G X 84 0027.7000
C B MULT D X -200.0000
C*
C DIV B H 30 007
C C DIV J Y 62 0053.33
C*
C MVR Z 53 00.020
C*
C SQRT K Z 05.000
C*
C XFOOTL Z 01.600
ΓòÉΓòÉΓòÉ 1.10.2. Array Operations ΓòÉΓòÉΓòÉ
The array operations are:
LOKUP (Look Up)
MOVEA (Move Array)
SORTA (Sort an Array)
XFOOT (Summing the Elements of an Array).
See each operation for an explanation of its function.
ΓòÉΓòÉΓòÉ 1.10.3. Bit Operations ΓòÉΓòÉΓòÉ
The bit operations are:
BITOF (Set Bits Off)
BITON (Set Bits On)
TESTB (Test Bit).
The BITOF and BITON operations allow you to turn off and on specific bits in a
field specified in the result field. The specified field must be a one-position
character field.
The TESTB operation compares the bits identified in factor 2 with the
corresponding bits in the field named as the result field.
In these operations, if factor 2 contains a 1-byte hexadecimal literal, the
bits in the factor 2 entry will affect the result field entry in the same way a
1-byte character field would affect it.
Note: You can also format one or more characters at a time using move
operations with hexadecimal literals. See Move Operations for more detail.
ΓòÉΓòÉΓòÉ 1.10.4. Branching Operations ΓòÉΓòÉΓòÉ
The branching operations are:
CABxx (Compare and Branch)
ENDSR (End of Subroutine)
EXCPT (Calculation Time Output)
GOTO (Go To)
ITER (Iterate)
LEAVE (Leave a Do Group)
TAG (Tag).
The GOTO operation (when used with a TAG operation) allows branching. For
example:
Several operations can be skipped when certain conditions occur.
Certain operations can be done for several, but not all, record types.
Several operations can be repeated.
The EXCPT operation allows records to be written during calculation time
instead of at output time.
The TAG operation names the label that identifies the destination of a GOTO or
CABxx operation.
The ITER operation transfers control from within a DO-group to the ENDDO
statement of the DO-group.
The LEAVE operation is similar to the ITER operation; however, LEAVE transfers
control to the statement following the ENDDO operation.
See each operation for an explanation of its function.
ΓòÉΓòÉΓòÉ 1.10.5. Call Operations ΓòÉΓòÉΓòÉ
The call operations are:
CALL (Call a Program)
FREE (Deactivate a Program)
PARM (Identify Parameters)
PLIST (Identify a Parameter List)
RETRN (Return to Caller).
The CALL, FREE, and RETRN operations allow an RPG/400 program to transfer
control to other programs. With the CALL, FREE, and RETRN function, the PLIST
and PARM operations can be used to allow the calling and called programs to
address the same data.
See each operation for an explanation of its function.
ΓòÉΓòÉΓòÉ 1.10.6. Compare Operations ΓòÉΓòÉΓòÉ
The compare operations are:
ANDxx (And)
COMP (Compare)
CABxx (Compare and Branch)
CASxx (Conditionally Invoke Subroutine)
DOUxx (Do Until)
DOWxx (Do While)
IFxx (If)
ORxx (Or)
WHxx (When True Then Select).
In the ANDxx, CABxx, CASxx, DOUxx, DOWxx, IFxx, ORxx, and WHxx operations, xx
can be:
xx Meaning
GT Factor 1 is greater than factor 2.
LT Factor 1 is less than factor 2.
EQ Factor 1 is equal to factor 2.
NE Factor 1 is not equal to factor 2.
GE Factor 1 is greater than or equal to factor 2.
LE Factor 1 is less than or equal to factor 2.
Blanks Unconditional processing (CASxx or CABxx).
The compare operations test fields for certain conditions. Resulting indicators
assigned in positions 54 through 59 are set according to the results of the
operation, or a branch occurs based on the results of the operation. No fields
are changed by these operations.
Remember the following when using the compare operations:
If numeric fields are compared, fields of unequal length are aligned at the
implied decimal point. The fields are filled with zeros to the left and/or
right of the decimal point making the field lengths and number of decimal
positions equal for comparison.
If character fields are compared, fields of unequal length are aligned to
their leftmost character. The shorter field is filled with blanks to equal
the length of the longer field so that the field lengths are equal for
comparison.
All numeric comparisons are algebraic. A plus (+) value is always greater
than a minus (-) value.
Blanks within numeric fields are assumed to be zeros.
Numeric fields are converted to packed decimal format, if necessary, before
they are compared.
If an alternate collating sequence (position 26 of the control specification)
has been specified for the comparison of character fields, the fields are
converted to the alternate sequence and then compared. If *HIVAL and *LOVAL
are used to set up the comparison, the alternate collating sequence may alter
the value before the compare operation. However, the actual field value will
not change.
A character field cannot be compared with a numeric field.
An array name cannot be specified in a compare operation, but an array
element may be specified.
The ANDxx and ORxx operations can be used with DOUxx, DOWxx, IFxx, and WHxx.
ΓòÉΓòÉΓòÉ 1.10.7. Data-Area Operations ΓòÉΓòÉΓòÉ
The data area operations are:
IN (Retrieve a Data Area)
OUT (Write a Data Area)
UNLCK (Unlock a Data Area or Release a Record).
The IN and OUT operations allow you to retrieve and write one or all data areas
in a program, depending on the factor 2 entry.
The IN and OUT operations also allow you to control the locking or unlocking of
a data area. When a data area is locked, it can be read but not updated by
other programs.
The following lock states are used:
For an IN operation with *LOCK specified, an exclusive allow read lock state
is placed on the data area.
For an OUT or UNLCK operation, the exclusive allow read lock state is
released.
During the actual transfer of data into or out of a data area, there is a
system-internal lock on the data area. If several users are contending for the
same data area, a user may get an error message indicating that the data area
is not available.
Remember the following when using the IN, OUT, and UNLCK operations:
A data-area operation cannot be done on a data area that is not defined to
the operating system.
Before the IN, OUT, and UNLCK operations can be done on a data area, you must
specify that data area in the result field of an *NAMVAR DEFN statement.
(For further information on the DEFN statement, see DEFN (Field Definition).)
The data-area operations can be done on a data-area data structure that is
implicitly retrieved only if the data-area data structure name is specified
in the result field of an *NAMVAR DEFN statement.
A locked data area cannot be updated or locked by another RPG/400 program;
however, the data area can be retrieved in your own program by an IN
operation with factor 1 blank.
A data-area name cannot be the name of a multiple-occurrence data structure,
an input record field, an array, an array element, or a table.
A data area cannot be the subfield of a multiple occurrence data structure, a
data-area data structure, a program-status data structure, a file-information
data structure (INFDS), or a data structure that appears on an *NAMVAR DEFN
statement.
A data structure defined with a U in position 18 of the input specifications
form indicates that the data structure is a data area. The data area is
automatically read and locked at program initialization time, and the contents
of the data structure are written to the data area when the program ends with
LR on.
Specify *LDA in factor 2 of a *NAMVAR DEFN statement to define the LDA data
structure.
Use the *NAMVAR DEFN operation with *PDA in factor 2 to define the name in the
result field as the PDA data area. The result field follows the current
conventions for *NAMVAR DEFN.
ΓòÉΓòÉΓòÉ 1.10.8. Declarative Operations ΓòÉΓòÉΓòÉ
The declarative operations do not cause action to occur; they can be specified
anywhere within calculations. The control level entry (positions 7 and 8) can
be blank or can contain an entry to group the statements within the appropriate
section of the program. The control level entry is for documentation purposes
only. The declarative operations are:
DEFN (Field Definition)
KFLD (Define Parts of a Key)
KLIST (Define a Composite Key)
PARM (Identify Parameters)
PLIST (Identify a Parameter List)
TAG (Tag).
The DEFN operation either defines a field based on the attributes (length and
decimal positions) of another field or defines a field as a data area.
The KLIST and KFLD operations are used to indicate the name by which a
composite key field may be referred and the fields that compose the composite
key. A composite key is a key that contains a list of key fields. It is built
from left to right, with the first KFLD specified being the leftmost
(high-order) field of the composite key.
The PLIST and PARM operations are used with the CALL operation to allow a
called program access to parameters from a calling program.
The TAG operation names the destination of a branching operation such as GOTO
or CABxx.
ΓòÉΓòÉΓòÉ 1.10.9. File Operations ΓòÉΓòÉΓòÉ
The file operation codes are:
ACQ (Acquire)
CHAIN (Random Retrieval from a File)
CLOSE (Close Files)
COMIT (Commit)
DELET (Delete Record)
EXCPT (Calculation Time Output)
EXFMT (Write/Then Read Format)
FEOD (Force End of Data)
FORCE (Force a Certain File to Be Read Next Cycle)
NEXT (Next)
OPEN (Open File for Processing)
POST (Post)
READ (Read a Record)
READC (Read Next Changed Record)
READE (Read Equal Key)
READP (Read Prior Record)
REDPE (Read Prior Equal)
REL (Release)
ROLBK (Roll Back)
SETGT (Set Greater Than)
SETLL (Set Lower Limit)
UNLCK (Unlock a Data Area or Release a Record)
UPDAT (Modify Existing Record)
WRITE (Create New Records).
File operations can be used with both program described and externally
described files (F or E respectively in position 19 of the file description
specifications).
When an externally described file is used with certain file operations, a
record format name, rather than a file name, can be specified in factor 2.
Thus, the processing operation code retrieves and/or positions the file at a
record format of the specified type according to the rules of the calculation
operation code used.
When the OVRDBF command is used with the MBR (*ALL) parameter specified, the
SETLL, SETGT and CHAIN operations only process the current file member. For
more information, refer to the Programming: Data Base Guide.
The WRITE and UPDAT operations that specify a program described file name in
factor 2 must have a data structure name specified in the result field. The
CHAIN, READ, READE, READP, and REDPE operations that specify a program
described file name in factor 2 may have a data structure name specified in the
result field. With the CHAIN, READ, READE, READP, and REDPE operations, data
is transferred directly between the file and the data structure, bypassing the
normal field extract function. Thus, no record identifying or field indicators
are set on as a result of an input operation to a data structure. If all input
and output operations to the file have a data structure specified in the result
field, input and output specifications are not required. However, the data
structure must be defined on the input specifications. If an input operation
(CHAIN, EXFMT, READ, READC, READE, READP, REDPE) does not retrieve a record
because no record was found, because an error occurred in the operation, or
because the last record was already retrieved (end of file), then no data is
extracted and all fields in the program remain unchanged.
If you specify an N in position 53 of a CHAIN, READ, READE, READP, or REDPE
operation for an update disk file, a record is read without locking. If no
value is specified in position 53, the record is locked if the file is an
update disk file.
Exception/errors that occur during file operations can be handled by the
programmer (by coding an error indicator or specifying a file-error
subroutine), or by the RPG/400 error handler.
ΓòÉΓòÉΓòÉ 1.10.10. Indicator-Setting Operations ΓòÉΓòÉΓòÉ
The SETON (Set On) and SETOF (Set Off) operations set (on or off) indicators
specified in positions 54 through 59. At least one resulting indicator must be
specified in these positions. Remember the following when setting indicators:
The 1P, MR, KA through KN, and KP through KY indicators cannot be set on by
the SETON operation.
The 1P and MR indicators cannot be set off by the SETOF operation.
Setting L1 through L9 on or off with a SETON or SETOF operation does not
automatically set any lower control level indicators.
ΓòÉΓòÉΓòÉ 1.10.11. Information Operations ΓòÉΓòÉΓòÉ
The information operations are:
DEBUG (Debug Function)
DUMP (Program Dump)
SHTDN (Shut Down)
TIME (Time of Day).
The DEBUG operation writes the following information that you can use to debug
an RPG/400 program:
The source statement sequence number of the DEBUG operation
The contents of factor 1 (if factor 1 is specified) that identifies the DEBUG
written information
All indicators that are on at the time the operation is encountered
The contents of the result field (if the result field contains an entry).
The information is sent to the file named in factor 2, or, if factor 2 is
blank, the information is sent to a system defined file.
The DUMP operation provides a dump of all indicators, fields, data structures,
arrays, and tables used in a program.
The SHTDN operation allows the program to determine whether the system operator
has requested shutdown. If so, the resulting indicator that must be specified
in positions 54 and 55 is set on.
The TIME operation allows the program to access the system time of day and
system date at any time during program running.
ΓòÉΓòÉΓòÉ 1.10.12. Initialization Operations ΓòÉΓòÉΓòÉ
The initialization operations provide run-time clearing and resetting of all
elements in a structure (record format, data structure, array, or table) or a
variable (field, subfield, or indicator).
The initialization operations are:
CLEAR (Clear)
RESET (Reset).
The CLEAR operation sets all elements in a structure or variable to zero,
blank, or '0', depending on the field type (numeric, character, or indicator).
This allows you to clear structures globally, instead of element by element.
The RESET operation sets all elements in a structure or variable to their
initial values (the values they had at the end of the initialization step in
the program cycle).
The RESET operation is used with data structure initialization and the
initialization subroutine (*INZSR). You can use both data structure
initialization and the *INZSR to set the initial value of a variable. The
initial value will be used to set the variable if it appears in factor 2 of a
RESET operation.
When these operation codes are applied to record formats, only fields which are
output are affected. See CLEAR (Clear) and RESET (Reset) for more detail.
For more information see "Initialization" in Chapter 9 of the RPG/400* User's
Guide.
ΓòÉΓòÉΓòÉ 1.10.13. Message Operation ΓòÉΓòÉΓòÉ
The message operation DSPLY (Display Function) allows communication between the
program and the system console or between the program and the display
workstation that requested the program.
ΓòÉΓòÉΓòÉ 1.10.14. Move Operations ΓòÉΓòÉΓòÉ
The move operations are:
MOVE (Move)
MOVEA (Move Array)
MOVEL (Move Left).
Move operations transfer all or part of factor 2 to the result field. Factor 2
remains unchanged. Factor 1 must be blank. Resulting indicators can be
specified in positions 54 through 59., except for the MOVE and MOVEL operations
if the result field is an array, or for the MOVEA operation if the result field
is an array or array element.
In the move operations, factor 2 and the result field are generally of the same
type (both numeric or both character). However, you can use the move operations
to change numeric fields to character fields and character fields to numeric
fields. To change a numeric field to a character field, enter the name of the
numeric field in factor 2 and specify a character result field. To change a
character field to a numeric field, enter the name of the character field in
factor 2 and specify a numeric result field.
When a character field is moved into a numeric result field, the digit portion
of each character is converted to its corresponding numeric character and then
moved to the result field. Blanks are transferred as zeros. For the MOVE
operation, the zone portion of the rightmost character is converted to its
corresponding sign and moved to the rightmost position of the numeric result
field. It becomes the sign of the field. (See Figure "MOVE Operation" for an
example.) For the MOVEL operation, the zone portion of the rightmost character
of factor 2 is converted and used as the sign of the result field (unless
factor 2 is shorter than the result field) whether or not the rightmost
character is included in the move operation. (See Figure "MOVEL Operation" for
an example.)
If move operations are specified to move data into numeric fields, the decimal
positions specified for the factor 2 field are ignored. For example, if 1.00 is
moved into a three-position numeric field with one decimal position, the result
is 10.0.
If you specify P in position 53 for a move operation, the result field is
padded from the right for MOVEL and MOVEA and from the left for MOVE. The pad
characters are blank for character, 0 for numeric and '0' for indicator. The
padding takes place after the operation. If you use MOVE or MOVEL to move a
field to an array, each element of the array will be padded. If you use these
operations to move an array to an array and the result contains more elements
than the factor 2 array, the same padding takes place but the extra elements
are not affected. A MOVEA operation with an array name in the result field will
pad the last element affected by the operation plus all subsequent elements.
When resulting indicators are specified for move operations, the result field
determines which indicator is set on. If the result field is a character field,
only the resulting indicator in positions 58 and 59 can be specified. This
indicator is set on if the result field is all blanks. When the result field is
numeric, all three resulting indicator positions may be used. These indicators
are set on as follows:
High (54-55) Set on if the result field is greater than 0.
Low (56-57) Set on if the result field is less than 0.
Equal (58-59) Set on if the result field is equal to 0.
ΓòÉΓòÉΓòÉ 1.10.15. Move Zone Operations ΓòÉΓòÉΓòÉ
The move zone operations are:
MHHZO (Move High to High Zone)
MHLZO (Move High to Low Zone)
MLHZO (Move Low to High Zone)
MLLZO (Move Low to Low Zone).
The move zone operations move only the zone portion of a character.
A minus (-) sign in a move zone operation does not result in a negative
character in the result field, because a minus sign is represented by a
hexadecimal 60 internally and a D zone is required for a negative character.
Characters J through R have D zones and can be used to obtain a negative value
(J = hexadecimal D1, ..., R = hexadecimal D9).
Note: Whenever the word high is used in a move zone operation, the field
involved must be a character field; whenever low is used, the field involved
can be either a character or a numeric field.
Function of MOVE Zone Operations
Character Γöé Γöé Γöé Γöé Γöé Γöé Factor
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Two
Γöé ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ
Γöé ΓöéΓöé MLHZO ΓöéΓöé
Γöé MHHZOΓöéΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿΓöéMLLZO
Γöé ΓöéΓööΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé
Γöé ΓöéΓöîΓöÿ MHLZO ΓöéΓöé
Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Result
Character ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ Field
Character Γöé Γöé Γöé Γöé Γöé Γöé Factor
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Two
Γöé ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ
Γöé Γöé Γöé
Γöé Γöé ΓöéMLLZO
Γöé ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé
Γöé MHLZO ΓöéΓöé
Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Result
Numeric ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ Field
Numeric Γöé Γöé Γöé Γöé Γöé Γöé Factor
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Two
Γöé ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ
Γöé MLHZO ΓöéΓöé
Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿΓöéMLLZO
Γöé Γöé Γöé
Γöé Γöé Γöé
Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Result
Character ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ Field
Numeric Γöé Γöé Γöé Γöé Γöé Γöé Factor
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Two
Γöé ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ
Γöé Γöé
Γöé ΓöéMLLZO
Γöé Γöé
Γöé Γöé
Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Result
Numeric ΓööΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÿ Field
ΓòÉΓòÉΓòÉ 1.10.16. String Operations ΓòÉΓòÉΓòÉ
The string operations include concatenation, scanning, substringing,
translation, and verification. String operations can only be used on character
fields.
The string operations are:
CAT (Concatenate Two Character Strings)
CHECK (Check Characters)
CHEKR (Check Reverse)
SCAN (Scan Character String)
SUBST (Substring)
XLATE (Translate).
The CAT operation concatenates two character strings to form one.
The CHECK and CHEKR operations verify that each character in factor 2 is among
the valid characters in factor 1. CHECK verifies from left to right and CHEKR
from right to left.
The SCAN operation scans a base character string for occurrences of a second
specified character string.
The SUBST operation extracts a specified character string from a base character
string.
The XLATE operation translates characters in factor 2 according to the from and
to strings in factor 1.
Note: Figurative constants cannot be used in the factor 1, factor 2, or
result fields. No overlapping in a data structure is allowed for factor 1 and
the result field, or factor 2 and the result field.
In the string operations, factor 1 and factor 2 may have two parts. If both
parts are specified, they must be separated by a colon. This option applies to
all but the CAT, CHECK, CHEKR, and SUBST operations (where it applies only to
factor 2).
If you specify P in position 53 for the CAT, SUBST, or XLATE operations, the
result field is padded from the right with blanks after the operation.
See each operation for a more detailed explanation.
ΓòÉΓòÉΓòÉ 1.10.17. Structured Programming Operations ΓòÉΓòÉΓòÉ
The structured programming operations are:
ANDxx (And)
CASxx (Conditionally Invoke Subroutine)
DO (Do)
DOUxx (Do Until)
DOWxx (Do While)
ELSE (Else)
ENDyy (End a Group)
IFxx (If)
ITER (Iterate)
LEAVE (Leave a Do Group)
ORxx (Or)
OTHER (Otherwise Select)
SELEC (Begin a Select Group)
WHxx (When True Then Select).
The DO operation allows the processing of a group of calculations zero or more
times starting with the value in factor 1, incrementing each time by a value on
the associated ENDDO operation until the limit specified in factor 2 is
reached.
The DOUxx operation allows the processing of a group of calculations one or
more times based on the results of comparing factor 1 and factor 2. The end of
a DOUxx operation is indicated by an ENDDO operation.
The DOWxx operation allows the processing of a group of calculations zero or
more times based on the results of comparing factor 1 and factor 2. The end of
a DOWxx operation is indicated by an ENDDO operation.
The LEAVE operation interrupts control flow prematurely and transfers control
to the statement following the ENDDO operation of an iterative structured
group. The ITER operation causes the next loop iteration to occur immediately.
An IFxx operation allows the processing of a group of calculations based on the
results of comparing factor 1 and factor 2. The ELSE operation allows you to
specify a group of calculations to be processed if the IFxx condition is not
satisfied. The end of an IFxx group is indicated by ENDIF.
The SELEC, WHxx, and OTHER group of operations are used to conditionally
process one of several alternative sequences of operations. The beginning of
the select group is indicated by the SELEC operation. The WHxx operations are
used to choose the operation sequence to process. The OTHER operation is used
to indicate an operation sequence that is processed when none of the WHxx
conditions are fulfilled. The end of the select group is indicated by the
ENDSL operation.
The ANDxx and ORxx operations are used with the DOUxx, DOWxx, WHxx, and IFxx
operations to specify a more complex condition than the comparison of a single
factor 1 and factor 2 pair. The ANDxx operation has higher precedence than the
ORxx operation.
Example of AND/OR Precedence
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* In the following example, indicator 25 will be set on only if the
C* first two conditions are true or the third condition is true.
C* Algebraically, this would be represented as:
C* ( ( (FIELDA > FIELDB) & (FIELDA >= FIELDC) ) | (FIELDA < FIELDD) )
C*
C FIELDA IFGT FIELDB
C FIELDA ANDGEFIELDC
C FIELDA ORLT FIELDD
C SETON 25
C ENDIF
The CASxx operation allows a subroutine to be conditionally selected for
processing. An ENDCS operation ends a CASxx group. For more information about
the CASxx operation, see Compare Operations.
A DO, DOUxx, DOWxx, IFxx, or SELEC operation (with or without ANDxx or ORxx
operations), and an ENDyy operation, delimit a structured group. The ENDDO
operation ends each DO, DOUxx, and DOWxx group or causes the structured group
to be reprocessed until the specified ending conditions are met. The SELEC must
end with an ENDSL. An IFxx operation and an IFxx operation with an ELSE
operation must end with an ENDIF operation. Using END gives you the same
results as using ENDIF, ENDSL, or ENDDO.
The rules for making the comparison on the ANDxx, DOUxx, DOWxx, IFxx, ORxx and
WHxx operation codes are the same as those given under Compare Operations.
In the ANDxx, CASxx, DOUxx, DOWxx, IFxx, ORxx, and WHxx operations, xx can be:
xx Meaning
GT Factor 1 is greater than factor 2.
LT Factor 1 is less than factor 2.
EQ Factor 1 is equal to factor 2.
NE Factor 1 is not equal to factor 2.
GE Factor 1 is greater than or equal to factor 2.
LE Factor 1 is less than or equal to factor 2.
Blanks Unconditional processing (CASxx only).
In the ENDyy operation, yy can be:
yy Meaning
CS End for CASxx operation.
DO End for DO, DOUxx, and DOWxx operation.
IF End for IFxx operation.
SL End for SELEC operation.
Blanks End for any structured operation.
Note: The yy in the ENDyy operation is optional.
If a structured group, in this case a do group, contains another complete
structured group, together they form a nested structured group. Structured
groups can be nested to a maximum depth of 100 levels. The following is an
example of nested structured groups, three levels deep:
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇDO
Γöé ΓöîΓöÇΓöÇΓöÇDO
Γöé ΓööΓöÇΓöÇΓöÇENDDO
Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇIFxx
Γöé Γöé ΓöîΓöÇΓöÇΓöÇSELEC
Γöé Γöé Γöé WHxx
Γöé Γöé ΓööΓöÇΓöÇΓöÇENDSL
Γöé Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇELSE
Γöé ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇENDIF
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇENDDO
Remember the following when specifying structured groups:
Each nested structured group must be completely contained within the outer
level structured group.
Each structured group must contain one of a DO, DOUxx, DOWxx, IFxx, or SELEC
operation and its associated ENDyy operation.
A structured group can be contained in detail, total, or subroutine
calculations, but it cannot be split among them.
Branching into a structured group from outside the structured group may cause
undesirable results.
ΓòÉΓòÉΓòÉ 1.10.18. Subroutine Operations ΓòÉΓòÉΓòÉ
An RPG/400 subroutine is a group of calculation specification statements in a
program that can be processed several times in that program. The RPG/400
subroutine operations are:
BEGSR (Beginning of Subroutine)
ENDSR (End of Subroutine)
EXSR (Invoke Subroutine)
CASxx (Conditionally Invoke Subroutine).
RPG/400 subroutine specifications must follow all other calculation operations
that can be processed for a program; however, the PLIST, PARM, KLIST, KFLD, and
DEFN operations may be specified between an ENDSR operation (the end of one
subroutine) and a BEGSR operation (the beginning of another subroutine) or
after all subroutines. A subroutine can be called from any point in the
calculation operations. Subroutine lines can be identified by SR in positions
7 and 8. The only valid entries in positions 7 and 8 of a subroutine line are
SR, AN, OR, or blanks.
For information on how to code a subroutine, see Coding Subroutines.
ΓòÉΓòÉΓòÉ 1.10.19. Test Operations ΓòÉΓòÉΓòÉ
The test operations are:
TESTB (Test Bit)
TESTN (Test Numeric)
TESTZ (Test Zone).
The TESTx operations allow you to test character fields specified in the result
field.
ΓòÉΓòÉΓòÉ <hidden> Operation Codes List ΓòÉΓòÉΓòÉ
The contents of the operation field on the referenced line are not valid. The
valid operation codes are:
ACQ (Acquire)
ADD (Add)
ANDxx (And)
BEGSR (Beginning of Subroutine)
BITOF (Set Bits Off)
BITON (Set Bits On)
CABxx (Compare and Branch)
CALL (Call a Program)
CASxx (Conditionally Invoke Subroutine)
CAT (Concatenate Two Character Strings)
CHAIN (Random Retrieval from a File)
CHECK (Check Characters)
CHEKR (Check Reverse)
CLEAR (Clear)
CLOSE (Close Files)
COMIT (Commit)
COMP (Compare)
DEBUG (Debug Function)
DEFN (Field Definition)
DELET (Delete Record)
DIV (Divide)
DO (Do)
DOUxx (Do Until)
DOWxx (Do While)
DSPLY (Display Function)
DUMP (Program Dump)
ELSE (Else)
ENDyy (End a Group)
ENDSR (End of Subroutine)
EXCPT (Calculation Time Output)
EXFMT (Write/Then Read Format)
EXSR (Invoke Subroutine)
FEOD (Force End of Data)
FORCE (Force a Certain File to Be Read Next Cycle)
FREE (Deactivate a Program)
GOTO (Go To)
IFxx (If)
IN (Retrieve a Data Area)
ITER (Iterate)
KFLD (Define Parts of a Key)
KLIST (Define a Composite Key)
LEAVE (Leave a Do Group)
LOKUP (Look Up)
MHHZO (Move High to High Zone)
MHLZO (Move High to Low Zone)
MLHZO (Move Low to High Zone)
MLLZO (Move Low to Low Zone)
MOVE (Move)
MOVEA (Move Array)
MOVEL (Move Left)
MULT (Multiply)
MVR (Move Remainder)
NEXT (Next)
OCUR (Set/Get Occurrence of a Data Structure)
OPEN (Open File for Processing)
ORxx (Or)
OTHER (Otherwise Select)
OUT (Write a Data Area)
PARM (Identify Parameters)
PLIST (Identify a Parameter List)
POST (Post)
READ (Read a Record)
READC (Read Next Changed Record)
READE (Read Equal Key)
READP (Read Prior Record)
REDPE (Read Prior Equal)
REL (Release)
RESET (Reset)
RETRN (Return to Caller)
ROLBK (Roll Back)
SCAN (Scan Character String)
SELEC (Begin a Select Group)
SETGT (Set Greater Than)
SETLL (Set Lower Limit)
SETOF (Set Off)
SETON (Set On)
SHTDN (Shut Down)
SORTA (Sort an Array)
SQRT (Square Root)
SUB (Subtract)
SUBST (Substring)
TAG (Tag)
TESTB (Test Bit)
TESTN (Test Numeric)
TESTZ (Test Zone)
TIME (Time of Day)
UNLCK (Unlock a Data Area or Release a Record)
UPDAT (Modify Existing Record)
WHxx (When True Then Select)
WRITE (Create New Records)
XFOOT ( Summing the Elements of an Array)
XLATE (Translate)
Z-ADD (Zero and Add)
Z-SUB (Zero and Subtract)
ΓòÉΓòÉΓòÉ 1.10.20. Operation Codes List ΓòÉΓòÉΓòÉ
The operation codes are:
ACQ (Acquire)
ADD (Add)
ANDxx (And)
BEGSR (Beginning of Subroutine)
BITOF (Set Bits Off)
BITON (Set Bits On)
CABxx (Compare and Branch)
CALL (Call a Program)
CASxx (Conditionally Invoke Subroutine)
CAT (Concatenate Two Character Strings)
CHAIN (Random Retrieval from a File)
CHECK (Check Characters)
CHEKR (Check Reverse)
CLEAR (Clear)
CLOSE (Close Files)
COMIT (Commit)
COMP (Compare)
DEBUG (Debug Function)
DEFN (Field Definition)
DELET (Delete Record)
DIV (Divide)
DO (Do)
DOUxx (Do Until)
DOWxx (Do While)
DSPLY (Display Function)
DUMP (Program Dump)
ELSE (Else)
ENDyy (End a Group)
ENDSR (End of Subroutine)
EXCPT (Calculation Time Output)
EXFMT (Write/Then Read Format)
EXSR (Invoke Subroutine)
FEOD (Force End of Data)
FORCE (Force a Certain File to Be Read Next Cycle)
FREE (Deactivate a Program)
GOTO (Go To)
IFxx (If)
IN (Retrieve a Data Area)
ITER (Iterate)
KFLD (Define Parts of a Key)
KLIST (Define a Composite Key)
LEAVE (Leave a Do Group)
LOKUP (Look Up)
MHHZO (Move High to High Zone)
MHLZO (Move High to Low Zone)
MLHZO (Move Low to High Zone)
MLLZO (Move Low to Low Zone)
MOVE (Move)
MOVEA (Move Array)
MOVEL (Move Left)
MULT (Multiply)
MVR (Move Remainder)
NEXT (Next)
OCUR (Set/Get Occurrence of a Data Structure)
OPEN (Open File for Processing)
ORxx (Or)
OTHER (Otherwise Select)
OUT (Write a Data Area)
PARM (Identify Parameters)
PLIST (Identify a Parameter List)
POST (Post)
READ (Read a Record)
READC (Read Next Changed Record)
READE (Read Equal Key)
READP (Read Prior Record)
REDPE (Read Prior Equal)
REL (Release)
RESET (Reset)
RETRN (Return to Caller)
ROLBK (Roll Back)
SCAN (Scan Character String)
SELEC (Begin a Select Group)
SETGT (Set Greater Than)
SETLL (Set Lower Limit)
SETOF (Set Off)
SETON (Set On)
SHTDN (Shut Down)
SORTA (Sort an Array)
SQRT (Square Root)
SUB (Subtract)
SUBST (Substring)
TAG (Tag)
TESTB (Test Bit)
TESTN (Test Numeric)
TESTZ (Test Zone)
TIME (Time of Day)
UNLCK (Unlock a Data Area or Release a Record)
UPDAT (Modify Existing Record)
WHxx (When True Then Select)
WRITE (Create New Records)
XFOOT (Summing the Elements of an Array)
XLATE (Translate)
Z-ADD (Zero and Add)
Z-SUB (Zero and Subtract)
ΓòÉΓòÉΓòÉ 1.10.20.1. ACQ (Acquire) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ACQ Γöé Device name Γöé WORKSTN file Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ACQ operation acquires the program device specified in factor 1 for the
WORKSTN file specified in factor 2. If the device is available, ACQ attaches
it to the file. If it is not available or is already attached to the file, an
error occurs. If an indicator is specified in positions 56 and 57, the
indicator is set on. If no indicator is specified, but the INFSR subroutine is
specified, the INFSR receives control when an error/exception occurs. If no
indicator or INFSR subroutine is specified, the default error/exception handler
receives control when an error/exception occurs.
No input or output operation occurs when the ACQ operation is processed. ACQ
must only be used with a multiple device file. See the section on
"Multiple-Device Files" in the chapter about using WORKSTN files in the
RPG/400* User's Guide.
ΓòÉΓòÉΓòÉ 1.10.20.2. ADD (Add) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ADD(1/2)Γöé Addend Γöé Addend Γöé Sum Γöé + - Z Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
If factor 1 is specified, the ADD operation adds it to factor 2 and places the
sum in the result field. If factor 1 is not specified, the contents of factor
2 are added to the result field and the sum is placed in the result field.
Factor 1 and factor 2 must be numeric and can contain one of: an array, array
element, constant, field name, literal, subfield, or table name. For the rules
for specifying an ADD operation, see Arithmetic Operations.
ADD Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The value 1 is added to RECNO.
C ADD 1 RECNO
C* The contents of EHWRK are added to CURHRS.
C ADD EHWRK CURHRS
C* The contents of OVRTM and REGHRS are added together and
C* placed in TOTPAY.
C OVRTM ADD REGHRS TOTPAY
ΓòÉΓòÉΓòÉ 1.10.20.3. ANDxx (And) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ANDXX Γöé Comparand Γöé Comparand Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
If you specify this optional operation, it must immediately follow a ANDxx,
DOUxx, DOWxx, IFxx, ORxx, or WHxx operation. With ANDxx, you can specify a
complex condition for the DOUxx, DOWxx, IFxx, and WHxx operations. The ANDxx
operation has higher precedence than the ORxx operation.
The control level entry (positions 7 and 8) can be blank or can contain an L1
through L9 indicator, an LR indicator, or an L0 entry to group the statement
within the appropriate section of the program. The control level entry must be
the same as the control level entry for the associated DOUxx, DOWxx, IFxx, or
WHxx operation. Conditioning indicator entries (positions 9 through 17) are not
permitted.
Factor 1 and factor 2 must contain a literal, a named constant, a figurative
constant, a table name, an array element, a data structure name, or a field
name. Factor 1 and factor 2 must be either both character data or both numeric
data. The comparison of factor 1 and factor 2 follows the same rules as those
given for the compare operations. See Compare Operations.
ANDxx Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* If ACODE is equal to A and indicator 50 is on, the MOVE
C* and WRITE operations are processed.
C ACODE IFEQ 'A'
C *IN50 ANDEQ*ON
C MOVE 'A' ACREC
C WRITERCRSN
C* If the previous conditions were not met but ACODE is equal
C* to A, indicator 50 is off, and ACREC is equal to D, the
C* following MOVE operation is processed.
C ELSE
C ACODE IFEQ 'A'
C *IN50 ANDEQ*OFF
C ACREC ANDEQ'D'
C MOVE 'A' ACREC
C ENDIF
C ENDIF
ΓòÉΓòÉΓòÉ 1.10.20.4. BEGSR (Beginning of Subroutine) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé BEGSR Γöé Subroutine Γöé Γöé Γöé Γöé
Γöé Γöé name Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The BEGSR operation identifies the beginning of an RPG/400 subroutine. Factor 1
contains the subroutine name. You must specify the same name in factor 2 of the
EXSR operation referring to the subroutine, in the result field of the CASxx
operation referring to the subroutine, or in the entry of an INFSR file
continuation option if the subroutine is a file-error subroutine. The control
level entry (positions 7 and 8) can be SR or blank. Conditioning indicator
entries are not permitted.
Every subroutine must have a unique symbolic name. The keyword *PSSR used in
factor 1 specifies that this is a program exception/error subroutine to handle
program-detected exception/errors. Only one subroutine can be defined by this
keyword. *INZSR in factor 1 specifies a subroutine to be run during the
initialization step. Only one subroutine can be defined *INZSR.
See Figure "Example of Coding Subroutines" for an example of coding
subroutines; see Subroutine Operations for general information on subroutine
operations.
ΓòÉΓòÉΓòÉ 1.10.20.5. BITOF (Set Bits Off) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé BITOF Γöé Γöé Bit numbers Γöé Char- Γöé Γöé
Γöé Γöé Γöé Γöé acter Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The BITOF operation causes bits identified in factor 2 to be set off (set to 0)
in the result field. Bits not identified in factor 2 remain unchanged.
Therefore, when using BITOF to format a character, you should use both BITON
and BITOF: BITON to specify the bits to be set on (=1), and BITOF to specify
the bits to be set off (=0). Unless you explicitly set on or off all the bits
in the character, you might not get the character you want.
Factor 2 can contain:
Bit numbers 0-7: From 1 to 8 bits can be set off per operation. They are
identified by the numbers 0 through 7. (0 is the leftmost bit.) Enclose the
bit numbers in apostrophes, and begin the entry in position 33. For example,
to set off bits 0, 2, and 5, enter '025' in factor 2.
Field name: You can specify the name of a one-position character field, table
element, or array element in factor 2. The bits that are on in the field,
table element, or array element are set off in the result field; bits that
are off are not affected.
Hexadecimal literal or named constant: You can specify a 1-byte hexadecimal
literal or hexadecimal named constant. Bits that are on in factor 2 are set
off in the result field; bits that are off are not affected.
Named constant: A character named constant up to eight positions long
containing the bit numbers to be set off.
In the result field, specify a one-position character field. It can be an array
element if each element in the array is a one-position character field.
See Figure "BITON and BITOF Operations" for an example of the BITOF operation.
ΓòÉΓòÉΓòÉ 1.10.20.6. BITON (Set Bits On) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé BITON Γöé Γöé Bit numbers Γöé Char- Γöé Γöé
Γöé Γöé Γöé Γöé acter Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The BITON operation causes bits identified in factor 2 to be set on (set to 1)
in the result field. Bits not identified in factor 2 remain unchanged.
Therefore, when using BITON to format a character, you should use both BITON
and BITOF: BITON to specify the bits to be set on (=1), and BITOF to specify
the bits to be set off (=0). Unless you explicitly set on or off all the bits
in the character, you might not get the character you want.
Factor 2 can contain:
Bit numbers 0-7: From 1 to 8 bits can be set on per operation. They are
identified by the numbers 0 through 7. (0 is the leftmost bit.) Enclose the
bit numbers in apostrophes, and begin the entry in position 33. For example,
to set bits 0, 2, and 5 on, enter '025' in factor 2.
Field name: You can specify the name of a one-position character field, table
element, or array element in factor 2. The bits that are on in the field,
table element, or array element are set on in the result field; bits that are
off are not affected.
Hexadecimal literal or named constant: You can specify a 1-byte hexadecimal
literal. Bits that are on in factor 2 are set on in the result field; bits
that are off are not affected.
Named constant: A character named constant up to eight positions long
containing the bit numbers to be set on.
In the result field, specify a one-position character field. It can be an array
element if each element in the array is a one-position character field.
Figure "BITON and BITOF Operations" illustrates uses of the BITON operation.
ΓòÉΓòÉΓòÉ 1.10.20.6.1. BITON and BITOF Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I '01234567' C BITNC
I X'0F' C HEXNC
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* Before the operations are processed, the bit settings are:
C* FLDA = 00000000
C* FLDB = 00000000
C* FLDC = 11111111
C* FLDD = 11000000
C* FLDE = 11000000
C* FLDF = 10000001
C* FLDG = 11111111 AFTER
C* FLDH = 00000000 OPERATIONS
C* FLDI = 11001010 ----------
C*
C BITON'04567' FLDA = 10001111
C BITON'3' FLDB = 00010000
C BITON'3' FLDC = 11111111
C BITON'3' FLDD = 11010000
C BITONFLDE FLDF = 11000001
C BITONX'01' FLDH = 00000001
C*
C BITOF'0' FLDG = 01111111
C*
C BITOFBITNC FLDI = 00001110
C BITONHEXNC FLDI = 00001111
BITON and BITOF Operations
ΓòÉΓòÉΓòÉ 1.10.20.7. CABxx (Compare and Branch) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CABXX Γöé Comparand Γöé Comparand Γöé Label Γöé HI LO Γöé
Γöé Γöé Γöé Γöé Γöé EQ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CABxx operation compares factor 1 with factor 2. If the condition
specified by xx is true, the program branches to the TAG operation associated
with the label specified in the result field. Otherwise, the program continues
with the next operation in the sequence. If the result field is not specified,
the resulting indicators (positions 54-59) are set accordingly, and the program
continues with the next operation in the sequence.
You can specify conditioning indicators. Factor 1 and factor 2 must contain a
character literal, a numeric literal, a named constant, a figurative constant,
a field name, a table name, an array element, or a data structure name. Both
the factor 1 and the factor 2 entries must be character data, or both must be
numeric.
The CABxx operation can specify a branch:
To a previous or a succeeding specification line
From a detail calculation line to another detail calculation line
From a total calculation line to another total calculation line
From a detail calculation line to a total calculation line
From a subroutine to a detail calculation line or a total calculation line.
The CABxx operation cannot specify a branch from outside a subroutine to a TAG
or ENDSR operation within that subroutine. Branching from one part of the
RPG/400 logic cycle to another may result in an endless loop. You must ensure
that the logic of your program does not produce undesirable results. The label
specified in the result field must be associated with a unique TAG operation
and must be a unique symbolic name.
Resulting indicators are optional. When specified, they are set to reflect the
results of the compare operation. For example, the HI indicator is set when
F1>F2, LO is set when F1<F2, and EQ is set when F1=F2.
See Compare Operations for the rules for comparing factor 1 with factor 2.
Figure "CABxx Operations" illustrates uses of the CABxx operation.
ΓòÉΓòÉΓòÉ 1.10.20.7.1. CABxx Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The field values are:
C* FLDA = 100.00
C* FLDB = 105.00
C* FLDC = ABC
C* FLDD = ABCDE
C*
C* Branch to TAGX.
C FLDA CABLTFLDB TAGX
C*
C* Branch to TAGX.
C FLDA CABLEFLDB TAGX
C*
C* Branch to TAGX; indicator 16 is off.
C FLDA CABLEFLDB TAGX 16
C*
C* Branch to TAGX; indicator 17 is off, indicator 18 is on.
C FLDA CAB FLDB TAGX 1718
C*
C* Branch to TAGX; indicator 19 is on.
C FLDA CAB FLDA TAGX 19
C*
C* No branch occurs.
C FLDA CABEQFLDB TAGX
C*
C* No branch occurs; indicator 20 is on.
C FLDA CABEQFLDB TAGX 20
C*
C* No branch occurs; indicator 21 is off.
C FLDC CABEQFLDD TAGX 21
C TAGX TAG
CABxx Operations
ΓòÉΓòÉΓòÉ 1.10.20.8. CALL (Call a Program) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CALL Γöé Γöé Program name Γöé Plist Γöé _ ER LR Γöé
Γöé Γöé Γöé Γöé name Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CALL operation passes control to the program specified in factor 2.
Factor 2 must contain a character entry specifying the name of the program to
be called. If you specify the library name, it must be immediately followed by
a slash and then the program name (for example, 'LIB/PROG'.). Factor 2 must
contain the name of a field, a literal, a named constant, or an array element
that contains the name of the program to be called and that optionally contains
the name of the library in which the program is located. If a library is not
specified, the library list is used to find the program.
The total length of a literal, including the slash, cannot exceed 8 characters.
The total length of a field or named constant, including the slash, cannot
exceed 21 characters. If either the program or the library name exceeds 10
characters, it is truncated to 10 characters. The program name is used exactly
as specified in the literal, field, named constant, or array element to
determine the program to be called. Any blanks found before or after the slash
are included in the program or library name. If the first or last character in
the entry is a slash, a blank library or program name, respectively, is
assumed. (Lowercase characters are not shifted to uppercase. A name enclosed in
quotation marks, for example, "ABC", always includes the quotation marks as
part of the name of the program to be called.) *LIBL and *CURLIB are not
supported.
Program references are grouped to avoid the overhead of resolving to the target
program. All references (using a CALL or FREE operation) to a specific program
using a named constant or literal are grouped so that the program is resolved
to only once, and all subsequent references to that program (by way of named
constant or literal only) do not cause a resolve to recur.
The references are grouped if both the program and the library name are
identical. All program references by variable name are grouped by the variable
name. When a program reference is made with a variable, its current value is
compared to the value used on the previous program reference operation that
used that variable. If the value did not change, no resolve is done. If it did
change, a resolve is done to the new program specified. If your program depends
on a resolve taking place on a reference by variable name, code a FREE
operation using that variable name. This causes a subsequent reference, using
that variable, to resolve to the program whether or not the value has changed.
Note that this rule applies only to references using a variable name.
References using a named constant or literal are never re-resolved, and they do
not affect whether or not a program reference by variable is re-resolved.
Figure "Example of Grouping of Program References" illustrates the grouping of
program references.
ΓòÉΓòÉΓòÉ 1.10.20.8.1. CALL Example ΓòÉΓòÉΓòÉ
Example of Grouping of Program References
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I 'LIB1/PGM1' C CALLA
I 'PGM1' C CALLB
I 'LIB/PGM2' C CALLC
I*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C CALL CALLA
C*
C* The following two calls will be grouped together because both
C* have the same program name (PGM1) and the same library name
C* (none). Note that these will not be grouped with the call using
C* CALLA above because CALLA has a different library name specified
C* (LIB1).
C*
C CALL 'PGM1'
C CALL CALLB
C*
C* The following two program references will be grouped together
C* because both have the same program name (PGM2) and the same
C* library name (LIB).
C*
C CALL 'LIB/PGM2'
C FREE CALLC
C*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The first call in the program using CALLV below will result in
C* a resolve being done for the variable CALLV to the program PGM1.
C* This is independent of any calls by a literal or named constant
C* to PGM1 that may have already been done in the program. The
C* second call using CALLV will not result in a resolve to PGM1
C* because the value of CALLV has not changed. The call following
C* the free operation will result in a resolve taking place because
C* the free operation will force that to occur. Note that the free
C* operation itself will not result in a resolve occurring. (That
C* is, that operation will use the current program object pointer
C* for calls using variable CALLV.)
C*
C MOVE 'PGM1' CALLV 21
C CALL CALLV
C CALL CALLV
C FREE CALLV
C CALL CALLV
In the result field, specify the name of a PLIST to communicate values between
the calling program and the called program. The result field can be blank if
the called program does not access parameters or if the PARM statements
directly follow the CALL operation.
Positions 54 and 55 must be blank. Any valid resulting indicator can be
specified in positions 56 and 57 to be set on for an error returned from the
called program and in positions 58 and 59 to be set on if the called program is
an RPG/400 program that returns with the LR indicator on.
The DSPPGMREF command is a CL command that is used to display information about
the external references made by a program. A referenced program is referenced
on a CALL operation only. Using DSPPGMREF, you can query the names of programs
called by way of named constants or literals. To make this information
available to DSPPGMREF, recompile your program.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C* The CALL operation calls PROGA and allows PROGA to access
C* FLDA and FLDB, defined elsewhere. PROGA is processed using the
C* contents of FLDA and FLDB. After PROGA is processed, control
C* returns to the next statement to be processed after the last
C* PARM statement.
C*
C*
C CALL 'PROGA'
C PARM FLDA
C PARM FLDB
CALL Operation
ΓòÉΓòÉΓòÉ 1.10.20.9. CASxx (Conditionally Invoke Subroutine) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CASXX Γöé Comparand Γöé Comparand Γöé Subrou- Γöé HI LO Γöé
Γöé Γöé Γöé Γöé tine Γöé EQ Γöé
Γöé Γöé Γöé Γöé name Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CASxx operation allows you to conditionally select a subroutine for
processing. The selection is based on the relationship between factor 1 and
factor 2, as specified by xx. If the relationship denoted by xx exists between
factor 1 and factor 2, the subroutine specified in the result field is
processed.
You can specify conditioning indicators. Factor 1 and factor 2 can contain a
literal, a named constant, a figurative constant, a field name, a table name,
an array element, a data structure name, or blanks (blanks are valid only if xx
is blank and no resulting indicators are specified in positions 54 through 59).
If factor 1 and factor 2 are not blanks, both must be character data, or both
must be numeric. In a CASbb operation, factor 1 and factor 2 are required only
if resulting indicators are specified in positions 54 through 59.
The result field must contain the name of a valid RPG/400 subroutine, including
*PSSR, the program exception/error subroutine, and *INZSR, the program
initialization subroutine. If the relationship denoted by xx exists between
factor 1 and factor 2, the subroutine specified in the result field is
processed. If the relationship denoted by xx does not exist, the program
continues with the next CASxx operation in the CAS group. A CAS group can
contain only CASxx operations. An ENDCS operation must follow the last CASxx
operation to denote the end of the CAS group. After the subroutine is
processed, the program continues with the next operation to be processed
following the ENDCS operation, unless the subroutine passes control to a
different operation.
The CASbb operation with no resulting indicators specified in positions 54
through 59 is functionally identical to an EXSR operation, because it causes
the unconditional running of the subroutine named in the result field of the
CASbb operation. Any CASxx operations that follow an unconditional CASbb
operation in the same CAS group are never tested. Therefore, the normal
placement of the unconditional CASbb operation is after all other CASxx
operations in the CAS group.
You cannot use conditioning indicators on the ENDCS operation for a CAS group.
See Compare Operations for further rules for the CASxx operation. Figure "CASxx
Operation" shows the coding for a group of CASxx operations.
ΓòÉΓòÉΓòÉ 1.10.20.9.1. CASxx Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The CASGE operation compares FIELDA with FIELDB. If FIELDA is
C* greater than or equal to FIELDB, SUBR01 is processed and the
C* program continues with the operation after the ENDCS operation.
C*
C FIELDA CASGEFIELDB SUBR01
C*
C* If FIELDA is not greater than or equal to FIELDB, the program
C* next compares FIELDA with FIELDC. If FIELDA is equal to FIELDC,
C* SUBR02 is processed and the program continues with the operation
C* after the ENDCS operation.
C*
C FIELDA CASEQFIELDC SUBR02
C*
C* If FIELDA is not equal to FIELDC, the CAS operation causes SUBR03
C* to be processed before the program continues with the operation
C* after the ENDCS operation.
C* The CAS statement is used to provide a subroutine if none of
C* the previous CASxx operations have been met.
C*
C CAS SUBR03
C*
C* The ENDCS operation denotes the end of the CAS group.
C*
C ENDCS
CASxx Operation
ΓòÉΓòÉΓòÉ 1.10.20.10. CAT (Concatenate Two Character Strings) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CAT (P) Γöé Source string Γöé Source string Γöé Target Γöé Γöé
Γöé Γöé 1 Γöé 2: number of Γöé string Γöé Γöé
Γöé Γöé Γöé blanks Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CAT operation concatenates the character string specified in factor 2 to
the end of the character string specified in factor 1 and places it in the
result field. If no factor 1 is specified, factor 2 is concatenated to the end
of the result field string.
Factor 1 can contain a character string, which can be one of: a field name,
array element, named constant, data structure name, table name, or literal. If
factor 1 is not specified, the result field is used. In the following
discussion, references to factor 1 apply to the result field if factor 1 is not
specified.
Factor 2 must contain a character string, and may contain the number of blanks
to be inserted between the concatenated strings. Its format is the character
string, followed by a colon, followed by the number of blanks. The character
string portion can contain one of: a field name, array element, named constant,
data structure name, table name, literal, or data structure subfield name. The
number of blanks portion must be numeric with zero decimal positions, and can
contain one of: a named constant, array element, literal, table name, or field
name.
If a colon is specified, the number of blanks must be specified. If no colon is
specified, concatenation occurs with the trailing blanks, if any, in factor 1,
or the result field if factor 1 is not specified.
If the number of blanks, N, is specified, factor 1 is copied to the result
field left-justified. If factor 1 is not specified the result field string is
used. Then N blanks are added following the last nonblank character. Then
factor 2 is appended to this result. Leading blanks in factor 2 are not
counted when N blanks are added to the result; they are just considered to be
part of factor 2.
If the number of blanks is not specified, the trailing and leading blanks of
factor 1 and factor 2 are included in the result. If the number of blanks is
specified, however, the trailing blanks of factor 1 are ignored and only as
many blanks as specified are included in the result between the last nonblank
character in factor 1 and the first character of factor 2. Leading blanks in
factor 2 are always included. For example, if you have:
C 'bMIKEbb' CAT 'bbSMITHb':1 Name
the value of the result field after this statement is executed is:
'bMIKEbbbSMITHb'
Note: The leading blanks in factors 1 and 2 and the trailing blanks in factor
2 are placed in the result unchanged. Since one was specified as the number of
blanks, factor 1 was copied left justified to the result field, a blank was
added following the rightmost nonblank character, and factor 2 was appended to
the result. Since factor 2 had two leading blanks, the total number of blanks
between the two now concatenated fields is three.
The result field must be character, and can contain one of: a field name, array
element, data structure name, or table name. Its length should be the length of
factor 1 and factor 2 combined plus any intervening blanks; if it is not,
truncation occurs from the right.
A P specified in the operation extender field (position 53) indicates that the
result field should be padded on the right with blanks after the concatenation
occurs if the result field is longer than the result of the operation. If
padding is not specified, only the leftmost part of the field is affected.
At run time, if the number of blanks is fewer than zero, the compiler defaults
the number of blanks to zero.
Figurative constants cannot be used in the factor 1, factor 2, or result
fields. No overlapping is allowed in a data structure for factor 1 and the
result field, or for factor 2 and the result field.
See Figure "CAT Operation" for examples of the CAT operation.
ΓòÉΓòÉΓòÉ 1.10.20.10.1. CAT Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* CAT concatenates LAST to NAME and inserts one blank as specified
C* in factor 2. TEMP contains 'Mr.bSmith'.
C MOVE 'Mr. ' NAME 6
C MOVE 'Smith ' LAST 6
C NAME CAT LAST:1 TEMP 9
C*
C* CAT concatenates 'RPG' to STRING and places 'RPG/400' in TEMP.
C MOVE '/400' STRING 4
C 'RPG' CAT STRING TEMP 7
C*
C* The following example is the same as the previous example except
C* that TEMP is defined as a 10 byte field. P in position 53
C* specifies that blanks will be used in the rightmost positions
C* of the result field that the concatenation result, 'RPG/400',
C* does not fill. As a result, TEMP contains 'RPG/400bbb'
C* after concatenation.
C MOVE *ALL'*' TEMP 10
C MOVE '/400' STRING 4
C 'RPG' CAT STRING TEMP P
C*
C* After this CAT operation, the field TEMP contains 'RPG/4'.
C* Because the field TEMP was not large enough, truncation occurred.
C MOVE '/400' STRING 4
C 'RPG' CAT STRING TEMP 5
C*
C* Note that the trailing blanks of NAME are not included because
C* NUM=0. The field TEMP contains 'RPGIIIbbbb'.
C MOVE 'RPG ' NAME 5
C MOVE 'III ' LAST 5
C Z-ADD0 NUM 10
C NAME CAT LAST:NUM TEMP 10P
CAT Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following example shows leading blanks in factor 2. After
C* the CAT the RESULT contains 'MR.bSMITH'.
C*
C MOVE 'MR.' NAME 3
C MOVE ' SMITH' FIRST 6
C NAME CAT FIRST RESULT 9
C*
C* The following example shows the use of CAT without factor 1.
C* FLD2 is a 9 character string. Prior to the concatenation, it
C* contains 'ABCbbbbbb.' FLD1 contains 'XYZ'. After the
C* concatenation FLD2 contains 'ABCbbXYZb'.
C*
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVE 'ABC' FLD2 9 P
C MOVE 'XYZ' FLD1
C CAT FLD1:2 FLD2
CAT Operation
ΓòÉΓòÉΓòÉ 1.10.20.11. CHAIN (Random Retrieval from a File) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CHAIN Γöé Search argu- Γöé File name Γöé Data Γöé NR ER _ Γöé
Γöé (N) Γöé ment Γöé Γöé struc- Γöé Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CHAIN operation retrieves a record from a full procedural file (F in
position 16 of the file description specifications), sets a record identifying
indicator on (if specified on the input specifications), and places the data
from the record into the input fields.
Factor 1, the search argument, must contain the key or relative record number
used to retrieve the record. If access is by key, factor 1 can be a field name,
a named constant, a figurative constant, or a literal. In addition, a KLIST
(Define a Composite Key) name can be specified in factor 1 for an externally
described file. If access is by relative record number, factor 1 must contain
an integer literal or a numeric field with zero decimal positions.
Factor 2 specifies the file or record format name that is to be read. A record
format name is valid with an externally described file. If factor 2 is a file
name and access is by key, the CHAIN operation retrieves the first record that
matches the search argument.
If factor 2 is a record format name and access is by key, the CHAIN operation
retrieves the first record of the specified record type whose key matches the
search argument. If no record is found of the specified record type that
matches the search argument, a no-record-found condition exists.
You can specify a data-structure name in the result field only if the file
named in factor 2 is a program described file (identified by an F in position
19 of the file description specification). When you specify a data-structure
name in the result field, the CHAIN operation retrieves the first record whose
record identifier matches the search argument in factor 1 and places it in the
data structure. See File Operations for information on transferring data
between the file and the data structure.
For a WORKSTN file, the CHAIN operation retrieves a subfile record.
For a multiple device file, you must specify a record format in factor 2. Data
is read from the program device identified by the field specified in the ID
entry of the file specifications continuation line. If there is no such entry,
data is read from the device for the last successful input operation to the
file.
If the file is specified as input, all records are read without locks and
position 53 must be blank. If the file is specified as update, all records are
locked if position 53 is blank.
If you are reading from an update disk file, you can specify an N in position
53 to indicate that no lock should be placed on the record when it is read. See
the RPG/400* User's Guide for more information.
Positions 54 and 55 must contain an indicator that is set on if no record in
the file matches the search argument. Positions 56 and 57 can contain an
indicator to be set on if the CHAIN operation is not completed successfully.
Positions 58 and 59 must be blank.
When the CHAIN operation is successful, the file specified in factor 2 is
positioned such that a subsequent read operation retrieves the next sequential
record following the retrieved record. When the CHAIN operation is not
completed successfully (for example, an error occurs or no record is found),
the file specified in factor 2 must be repositioned (for example, by a CHAIN or
SETLL operation) before a subsequent read operation can be done on that file.
If an update (on the calculation or output specifications) is done on the file
specified in factor 2 immediately after a successful CHAIN operation to that
file, the last record retrieved is updated.
Figure "CHAIN Operation with a File Name in Factor 2" and Figure "CHAIN
Operation with a Record Format Name and with No Lock" illustrate uses of the
CHAIN operation.
ΓòÉΓòÉΓòÉ 1.10.20.11.1. CHAIN Examples (File Name and Record Format Name) ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The CHAIN operation retrieves the first record from the file,
C* FILEX, that has a key field with the same value as the search
C* argument KEY (factor 1).
C*
C KEY CHAINFILEX 60 INDICATOR 60
C* IF NOT FOUND
C*
C* If a record with a key value equal to the search argument is not
C* found, indicator 60 is set on and the GOTO operation conditioned
C* by indicator 60 is processed. If a record is found with a key
C* value equal to the search argument, the program continues with
C* the calculations after the GOTO operation.
C*
C 60 GOTO NOTFND
CHAIN Operation with a File Name in Factor 2
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The CHAIN operation uses the value contained in the search
C* argument KEY to retrieve a record of the record type REC1 from
C* an externally described file. If no record is found of the
C* specified type that has a key field equal to the search
C* argument, indicator 72 is set on. A complex key with a KLIST is
C* used to retrieve records from files that have a composite key.
C* If a record of the specified type is found that has a key field
C* equal to the search argument, the calculations after the GOTO
C* operation are processed.
C*
C KEY CHAINREC1 72 INDICATOR 72
C* IF NOT FOUND
C KEY KLIST
C KFLD FLD1
C KFLD FLD2
C *IN72 IFEQ *OFF
C*
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The UPDAT operation modifies all the fields in the REC1 record.
C*
C UPDATREC1 UPDATE
C ENDIF
C*
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following example shows a CHAIN with no lock.
C*
C MOVE 3 KEY
C KEY CHAININPUT N
CHAIN Operation with a Record Format Name and with No Lock
ΓòÉΓòÉΓòÉ 1.10.20.12. CHECK (Check Characters) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CHECK Γöé Comparator Γöé Base Γöé Left- Γöé _ ER FD Γöé
Γöé Γöé string Γöé string:start Γöé position Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CHECK operation verifies that each character in the base string (factor 2)
is among the characters indicated in the comparator string (factor 1).
Verifying begins at the leftmost character of factor 2 and continues character
by character, from left to right. Each character of the base string is compared
with the characters of factor 1. If a match for a character in factor 2 exists
in factor 1, the next base string character is verified. If a match is not
found, an integer value is placed in the result field to indicate the position
of the incorrect character.
You can specify a start position in factor 2, separating it from the base
string by a colon. The start position is optional and defaults to 1. If the
start position is greater than 1, the value in the result field is relative to
the leftmost position in the base string, regardless of the start position.
The operation stops checking when it finds the first incorrect character or
when the end of the base string is encountered. If no incorrect characters are
found, the result field is set to zero.
If the result field is an array, the operation continues checking after the
first incorrect character is found for as many occurrences as there are
elements in the array. If there are more array elements than incorrect
characters, all of the remaining elements are set to zeros.
Factor 1 must be character, and can contain one of: a field name, array
element, named constant, data structure name, data structure subfield, literal,
or table name.
Factor 2 must contain either the base string or the base string, followed by a
colon, followed by the start location. The base string portion of factor 2 must
be character, and can contain: a field name, array element, named constant,
data-structure name, literal, or table name. The start location portion of
factor 2 must be numeric with no decimal positions, and can be a named
constant, array element, field name, literal, or table name. If no start
location is specified, a value of 1 is used.
The result field can be a numeric variable, numeric array element, numeric
table name, or numeric array. Define the field or array specified with no
decimal positions. The result field is an optional field; if you do not specify
it, you must specify the found indicator in position 58-59.
Figurative constants cannot be used in the factor 1, factor 2, or result
fields. No overlapping is allowed in a data structure for factor 1 and the
result field or for factor 2 and the result field.
Any valid indicator can be specified in positions 7 to 17.
The indicator in positions 56-57 is turned on if an error occurs. The indicator
in positions 58-59 is turned on if any incorrect characters are found.
Figure "CHECK Operation" shows examples of the CHECK operation.
ΓòÉΓòÉΓòÉ 1.10.20.12.1. CHECK Examples ΓòÉΓòÉΓòÉ
CHECK Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* Because factor 1 is a blank, CHECK indicates the position
C* of the first nonblank character. If STRING contains 'bbbthe',
C* NUM will contain the value 4.
C*
C ' ' CHECKSTRING NUM 20
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I*
I* After the following example, N=6 and the found indicator 90
I* is on. Because the start position is 2, the first nonnumeric
I* character found is the '.'.
I*
I '0123456789' C DIGITS
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C MOVE '$2000.' SALARY
C DIGITS CHECKSALARY:2 N 90
CHECK Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I*
I* The following example checks that FIELD contains only the letters
I* A to J. As a result, ARRAY=(136000) after the CHECK operation.
I* Indicator 90 turns on.
I*
I 'ABCDEFGHIJ' C LETTER
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C MOVE '1A=BC*' FIELD 8
C LETTER CHECKFIELD ARRAY 90
C*
C* In the following example, because FIELD contains only the
C* letters A to J, ARRAY=(000000). Indicator 90 turns off.
C*
C MOVE 'FGFGFG' FIELD 8
C LETTER CHECKFIELD ARRAY 90
ΓòÉΓòÉΓòÉ 1.10.20.13. CHEKR (Check Reverse) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CHEKR Γöé Comparator Γöé Base Γöé Right- Γöé _ ER FD Γöé
Γöé Γöé string Γöé string:start Γöé position Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CHEKR operation verifies that each character in the base string (factor 2)
is among the characters indicated in the comparator string (factor 1).
Verifying begins at the rightmost character of factor 2 and continues character
by character, from right to left. Each character of the base string is compared
with the characters of factor 1. If a match for a character in factor 2 exists
in factor 1, the next source character is verified. If a match is not found,
an integer value is placed in the result field to indicate the position of the
incorrect character. Although checking is done from the right, the position
placed in the result field will be relative to the left.
You can specify a start position in factor 2, separating it from the base
string by a colon. The start position is optional and defaults to the length of
the string. The value in the result field is relative to the leftmost position
in the source string, regardless of the start position.
If the result field is not an array, the operation stops checking when it finds
the first incorrect character or when the end of the base string is
encountered. If no incorrect characters are found, the result field is set to
zero.
If the result field is an array, the operation continues checking after the
first incorrect character is found for as many occurrences as there are
elements in the array. If there are more array elements than incorrect
characters, all of the remaining elements are set to zeros.
Factor 1 must be character, and can contain one of: a field name, array
element, named constant, data structure name, data structure subfield, literal,
or table name.
Factor 2 must contain either the base string or the base string, followed by a
colon, followed by the start location. The base string portion of factor 2 must
be character, and can contain: a field name, array element, named constant,
data structure name, data structure subfield name, literal, or table name. The
start location portion of factor 2 must be numeric with no decimal positions,
and can be a named constant, array element, field name, literal, or table name.
If no start location is specified, the length of the string is used.
The result field can be a numeric variable, numeric array element, numeric
table name, or numeric array. Define the field or array specified with no
decimal positions. The result field is an optional field; if you do not specify
it, you must specify the found indicator in position 58-59.
Figurative constants cannot be used in the factor 1, factor 2, or result
fields. No overlapping is allowed in a data structure for factor 1 and the
result field, or for factor 2 and the result field.
Any valid indicator can be specified in positions 7 to 17.
The indicator in positions 56-57 is turned on if an error occurs. The indicator
in positions 58-59 is turned on if any incorrect characters are found.
Figure "CHEKR Operation" shows examples of the CHEKR operation.
ΓòÉΓòÉΓòÉ 1.10.20.13.1. CHEKR Examples ΓòÉΓòÉΓòÉ
CHEKR Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* Because factor 1 is a blank character, CHEKR indicates the
C* position of the first nonblank character. This use of CHEKR
C* allows you to determine the length of a string. If STRING
C* contains 'ABCDEF ', NUM will contain the value 6.
C*
C ' ' CHEKRSTRING NUM 20
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I*
I* After the following example, N=1 and the found indicator 90
I* is on. Because the start position is 5, the operation begins
I* with the rightmost 0 and the first nonnumeric found is the '$'.
I*
I '0123456789' C DIGITS
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C MOVE '$2000.' SALARY 6
C DIGITS CHEKRSALARY:5 N 90
E*
E* The following example checks that FIELD contains only the letters
E* A to J. As a result, ARRAY=(876310) after the CHEKR operation.
E* Indicator 90 turns on.
E*
E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments
E ARRAY 6 1 0
I..............Namedconstant+++++++++C.........Fldnme......... ....
I 'ABCDEFGHIJ' C LETTER
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C MOVE '1A=BC***'FIELD 8
C LETTER CHEKRFIELD ARRAY 90
ΓòÉΓòÉΓòÉ 1.10.20.14. CLEAR (Clear) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CLEAR Γöé *NOKEY Γöé Structure or Γöé Γöé Γöé
Γöé Γöé Γöé Variable Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The CLEAR operation sets elements in a structure (record format, data
structure, array, or table) or a variable (field, subfield, or indicator), to
zero, blank or '0', depending on field type (numeric, character, or indicator).
It allows you to clear structures on a global basis, as well as element by
element, during run time.
Factor 1 must be blank unless factor 2 contains a DISK record format name; in
which case, it can contain *NOKEY to indicate that all fields except key fields
are to be cleared.
Factor 2 contains the structure or variable that is set to zero, blank, or '0'.
It can contain: a record-format name, data-structure name, array name, table
name, field name, subfield, array element, or indicator name. If you specify a
record-format name or data structure, all fields are cleared in the order they
are defined within the structure. If you have partially overlapping fields of
different definitions, data that is not valid could exist in numeric fields.
With a multiple-occurrence data structure, only those fields in the current
occurrence are cleared. If you specify a table name, the current table element
is cleared; if an array name, the entire array is cleared. If you specify an
array element (including indicators) in factor 2 using an array index, only the
element specified is cleared.
Note that when the CLEAR operation is applied to a record-format name, only
output fields in the record format are affected. For WORKSTN file record
formats, only fields with a usage of output or both are affected. All
field-conditioning indicators are affect by this operation. Fields in DISK,
SEQ, or PRINTER file record formats are affected only if those record formats
are output in the program. Input-only fields are not affected by the CLEAR
operation. By definition, they assume new values at the next input operation.
For more information see "Initialization" in chapter 9 of the RPG/400* User's
Guide.
Figure "CLEAR Operation" shows an example of the CLEAR operation.
ΓòÉΓòÉΓòÉ 1.10.20.14.1. CLEAR Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I....................................PFromTo++DField+L1M1FrPlMnZr...
I*
I* In the following example, CLEAR sets all subfields in the data
I* structure DS1 to their defaults, CHAR to blank, NUM to zero.
IDS1 DS
I 2 50NUM
I 20 30 CHAR
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C CLEARDS1
CLEAR Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
A* FLD1 and FLD2 are defined as output fields and can be
A* affected by the CLEAR operation. Indicator 10 can also be
A* changed by the CLEAR operation even though it conditions an
A* input only field because field indicators are all treated
A* as output fields.
A*
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++++*
A R FMT01
A 10 FLD1 10A I 2 30
A FLD2 10A O 3 30
A FLD3 10A B 4 30
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U1.
FWORKSTN CF E WORKSTN
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I 'INPUT DATA' C IN
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C CLEARFMT01
C WRITEFMT01
C*
C* The program will loop until PF03 is pressed.
C*
C *IN03 DOWEQ'0'
C READ FMT01 LR
C*
C* PF04 will transfer input fields to output fields.
C*
C *IN04 IFEQ '1'
C MOVELFLD003 FLD002
C MOVELFLD001 FLD003
C CLEAR*IN04
C ENDIF
C MOVELIN FLD001
C*
C* When PF11 is pressed, all the fields in the record format
C* defined as output or both will be reset to the values they
C* held after the initialization step.
C*
C *IN11 IFEQ '1'
C RESETFMT01
C CLEAR*IN11
C ENDIF
C* When PF12 is pressed, all the fields in the record
C* format defined as output or both will be cleared.
C*
C *IN12 IFEQ '1'
C CLEARFMT01
C CLEAR*IN12
C ENDIF
C N03 WRITEFMT01
C ENDDO
C SETON LR
Field Initialization for the CLEAR Record Format
ΓòÉΓòÉΓòÉ 1.10.20.15. CLOSE (Close Files) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé CLOSE Γöé Γöé File name Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The explicit CLOSE operation closes one or more files or devices and
disconnects them from the program. The file cannot be used again in the program
unless you specify an explicit OPEN for that file. A CLOSE operation to an
already closed file does not produce an error.
Factor 2 names the file to be closed. You can specify the keyword *ALL in
factor 2 to close all the files at once. You cannot specify an array or table
file (identified by a T in position 16 of the file description specifications)
in factor 2.
You can specify a resulting indicator in positions 56 and 57 to be set on if
the CLOSE operation is not completed successfully. Positions 54, 55, 58, and 59
must be blank.
Multiple CLOSE operations to a file already closed are valid. A second close
to the same file has no effect on that file.
If an array or table is to be written to an output file (specified in positions
19 through 26 of the extension specifications), the array or table dump does
not occur if the file is closed (by a CLOSE operation) at LR time when the file
is written. If the file is closed, it must be reopened for the dump to occur.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The explicit CLOSE operation closes FILEB.
C*
C CLOSEFILEB
C*
C* The explicit CLOSE *ALL operation closes all files in the
C* program. To reopen the files, you must specify an explicit
C* OPEN for each file. If the CLOSE operation is not completed
C* completed successfully, indicator 17 is set on and the
C* program branches to the label specified in the GOTO statement.
C CLOSE*ALL 17
C 17 GOTO NOCOMP CLOSE FAILED
C :
C :
C :
C NOCOMP TAG
CLOSE Operation
ΓòÉΓòÉΓòÉ 1.10.20.16. COMIT (Commit) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé COMIT Γöé Boundary Γöé Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The COMIT operation:
Makes all the changes to your files that have been specified in output
operations since the previous COMIT or ROLBK (Roll Back) operation (or since
the beginning of operations under commitment control if there has been no
previous COMIT or ROLBK operation).
Releases all the record locks for files you have under commitment control.
The file changes and the record-lock releases apply to all the files you have
under commitment control, whether the changes have been requested by the
program issuing the COMIT operation, or by another program in the same routing
step. The program issuing the COMIT operation does not need to have any files
under commitment control. The COMIT operation does not change the file
position.
Commitment control starts when the COMIT operation is executed or when the CL
command STRCMTCTL is executed. See the chapter on "Commitment Control" in the
RPG/400* User's Guide for more information.
In factor 1, you can specify a literal, named constant, array element, table
name, data structure, or data structure subfield to identify the boundary
between the changes made by this COMIT operation and subsequent changes. If you
leave factor 1 blank, the identifier is null.
The optional indicator in positions 56 and 57 is set on if the operation is not
completed successfully. For example, the indicator is set on if commitment
control is not active.
ΓòÉΓòÉΓòÉ 1.10.20.17. COMP (Compare) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé COMP Γöé Comparand Γöé Comparand Γöé Γöé HI LO Γöé
Γöé Γöé Γöé Γöé Γöé EQ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The COMP operation compares factor 1 with factor 2. Factor 1 and factor 2 can
contain a literal, a named constant, a field name, a table name, an array
element, a data structure, or a figurative constant. Factor 1 and factor 2 must
be either both character or both numeric. As a result of the comparison,
indicators are set on as follows:
High: (54-55) Factor 1 is greater than factor 2.
Low: (56-57) Factor 1 is less than factor 2.
Equal: (58-59) Factor 1 equals factor 2.
You must specify at least one resulting indicator in positions 54 through 59.
Do not specify the same indicator for all three conditions. When specified, the
resulting indicators are set on or off (for each cycle) to reflect the results
of the compare.
For further rules for the COMP operation, see Compare Operations.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* Initial field values are:
C* FLDA = 100.00
C* FLDB = 105.00
C* FLDC = 100.00
C* FLDD = ABC
C* FLDE = ABCDE
C*
C* Indicator 12 is set on; indicators 11 and 13 are set off.
C FLDA COMP FLDB 111213
C*
C* Indicator 15 is set on; indicator 14 is set off.
C FLDA COMP FLDB 141516
C*
C* Indicator 19 is set on; indicator 17 is set off.
C FLDA COMP FLDC 171819
C*
C* Indicator 21 is set on; indicators 20 and 22 are set off
C FLDD COMP FLDE 202122
COMP Operation
ΓòÉΓòÉΓòÉ 1.10.20.18. DEBUG (Debug Function) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DEBUG Γöé Identifier Γöé Output file Γöé Debug Γöé Γöé
Γöé Γöé Γöé Γöé info Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DEBUG operation helps the programmer debug a program that is not working
properly. One or more records containing information helpful for finding
programming errors are written as a result of this operation. You can use the
DEBUG operation independently of or in combination with the OS/400 testing and
debugging functions.
You can specify the operation at any point or at several points in the
calculation specifications. Whenever the program encounters the DEBUG
operation, one or more records are written. The first record contains the
source-statement sequence number of the DEBUG operation in the program, factor
1 if any, and a list of all indicators that were on at the time the DEBUG
operation was encountered. It can contain the contents of a field, an array
element, a table element, or a literal that identifies the written information
that describes the DEBUG operation. The contents of factor 1 identify the
written information that describes the DEBUG operation. It can contain a field
name, an array element, a table name, a named constant, or a literal. The
length of the specified field can be from 1 to 8 characters. Factor 1 cannot
contain a figurative constant. If factor 1 contains an entry, the sequence
number and the contents of the entry are written to the first record. If factor
1 is not used, the source statement sequence number of the DEBUG operation is
written to the first record.
Factor 2 can contain the name of the output file to which the DEBUG output is
written. This file must have a record length of at least 80 positions. Only
program-defined output files are allowed with the DEBUG operation; externally
described files are not permitted. If factor 2 is blank, the output goes to the
display work station that requested the program (the requester). The same entry
must appear in factor 2 of all DEBUG operations in a program.
The contents of the result field are written to a separate record. The result
field can contain a field name, an array name, a table name, or a KLIST (Define
a Composite Key) name.
If factor 1 and the result field are not specified, only the indicators and the
source statement sequence number of the DEBUG operation are written.
Note: If a KLIST is specified in the result field of a DEBUG operation, all
numeric fields in the KLIST are printed or displayed in zoned decimal format.
The DEBUG operation is performed only if a 1 is specified in position 15 of the
control specification. Otherwise, the DEBUG statement is checked for errors at
compile time, but the DEBUG operation is not processed at run time.
ΓòÉΓòÉΓòÉ 1.10.20.18.1. Records Written for DEBUG ΓòÉΓòÉΓòÉ
For a DEBUG operation, one record is always written in the following format:
Positions Information
1-8 DEBUG=
9-16 Source statement sequence number of the DEBUG operation code in
the program. This entry permits you to identify the individual
DEBUG operation (if more than one is used) without making an entry
in factor 1.
17-18 Blank.
19-26 Contents of factor 1, if specified.
27 Minus (-) sign if factor 1 contains a negative value. Blank if
factor 1 contains a positive value.
28 Blank.
29-43 The words INDICATORS ON=
44 Blank.
45-47, ... The names of all indicators that are on, each separated by a
blank. If more than one record is needed to write all the
indicators, positions 1 through 43 are used only by the first
record. The indicators are written starting in position 45 of the
remaining records.
Note: If an indicator contains a character that is not valid
(not '0' or '1'), the indicator is listed followed by the
hexadecimal representation of the value in the indicator. For
example, if indicators 01 and 88 are on, and indicator 33 contains
the character A, the indicator line appears as: ON = 01 33 (C1)
88.
When the result field contains an entry, a separate record is written in the
following format:
Positions Information
1-14 The words FIELD VALUE=
15- (any position) The contents of the result field. The first 66 characters
of the result field are written in positions 15 through
80 of this record. If the field is greater than 66
characters, the additional characters are written in
positions 15 through 80 of additional records.
Numeric fields are written out in unpacked format and are zero-suppressed. The
sign is always written to the right of the field; a minus (-) sign is written
to the right of negative fields, and a blank is written to the right of
positive fields. Zero fields are written with the last zero and the sign. No
other editing is done. If the result field is an array name, the elements are
written in order, one record for each element. When a multiple occurrence data
structure is specified, only the current occurrence is written.
ΓòÉΓòÉΓòÉ 1.10.20.19. DEFN (Field Definition) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DEFN Γöé *LIKE Γöé Referenced Γöé Defined Γöé Γöé
Γöé Γöé Γöé field Γöé field Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DEFN Γöé *NAMVAR Γöé Internal Γöé External Γöé Γöé
Γöé Γöé Γöé program area Γöé data Γöé Γöé
Γöé Γöé Γöé Γöé area Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Depending on the factor 1 entry, the declarative DEFN operation can do either
of the following:
Define a field based on the attributes (length and decimal positions) of
another field.
Define a field as a data area.
You can specify the DEFN operation anywhere within calculations. The control
level entry (positions 7 and 8) can be blank or can contain an L1 through L9
indicator, the LR indicator, or an L0 entry to group the statement within the
appropriate section of the program. The control level entry is used for
documentation only. Conditioning indicator entries (positions 9 through 17)
are not permitted. See *LIKE DEFN and *NAMVAR DEFN.
See Figure "DEFN Operation" for examples of the DEFN operation.
ΓòÉΓòÉΓòÉ 1.10.20.19.1. *LIKE DEFN ΓòÉΓòÉΓòÉ
The DEFN (Field Definition) operation with *LIKE in factor 1 defines a field
based upon the attributes (length and decimal positions) of another field.
Factor 2 must contain the name of the field being referenced, and the result
field must contain the name of the field being defined. The field specified in
factor 2 , which can be defined in the program or externally, provides the
attributes for the field being defined. Factor 2 cannot be a literal or a
named constant. If factor 2 is an array, an array element, or a table name,
the attributes of an element of the array or table are used to define the
field. The result field cannot be an array, an array element, a data structure,
or a table name.
You can use positions 49 through 51 (field length) to make the result field
entry longer or shorter than the factor 2 entry. A plus sign (+) in position
49 indicates a length increase; a minus sign (-) in position 49 indicates a
length decrease. Positions 50 and 51 can contain the increase or decrease in
length (right-adjusted) or can be blank. If positions 49 through 51 are blank,
the result field entry is defined with the same length as the factor 2 entry.
You cannot change the number of decimal positions for the field being defined.
See Figure "DEFN Operation" for examples of *LIKE DEFN.
ΓòÉΓòÉΓòÉ 1.10.20.19.2. *NAMVAR DEFN ΓòÉΓòÉΓòÉ
The DEFN (Field Definition) operation with *NAMVAR in factor 1 associates a
field, a data structure, a data-structure subfield, or a data-area data
structure (within your RPG/400 program) with an AS/400 data area (outside your
RPG/400 program).
In factor 2, specify the external name of a data area. Use *LDA for the name of
the local data area or use *PDA for the Program Initialization Parameters (PIP)
data area. If you leave factor 2 blank, the result field entry is both the
RPG/400 name and the external name of the data area.
In the result field, specify the name of one of the following that you have
defined in your program: a field, a data structure, a data structure subfield,
or a data-area data structure. You use this name with the IN and OUT operations
to retrieve data from and write data to the data area specified in factor 2.
When you specify a data-area data structure in the result field, the RPG/400
program implicitly retrieves data from the data area at program start and
writes data to the data area when the program ends.
The result field entry must not be the name of a file, a program-status data
structure, a file-information data structure (INFDS), a multiple-occurrence
data structure, an input record field, an array, an array element, or a table.
It cannot be the name of a subfield of a multiple-occurrence data structure, of
a data area data structure, of a program-status data structure, of a
file-information data structure (INFDS), or of a data structure that appears on
a *NAMVAR DEFN statement.
In positions 49 through 52, you can define the length and number of decimal
positions for the entry in the result field. These specifications must match
those for the external description of the data area specified in factor 2. The
local data area is character data of length 1024, but within your program you
can access the local data area as if it has a length of 1024 or less.
See Figure "DEFN Operation" for examples of the *NAMVAR DEFN statement.
ΓòÉΓòÉΓòÉ 1.10.20.19.3. DEFN Examples ΓòÉΓòÉΓòÉ
DEFN Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
*
C* FLDA is a 7-position character field.
C* FLDB is a 5-digit field with 2 decimal positions.
C*
C*
C* FLDP is a 7-position character field.
C *LIKE DEFN FLDA FLDP
C*
C* FLDQ is a 9-position character field.
C *LIKE DEFN FLDA FLDQ + 2
C*
C* FLDR is a 6-position character field.
C *LIKE DEFN FLDA FLDR - 1
C*
C* FLDS is a 5-position numeric field with 2 decimal positions.
C *LIKE DEFN FLDB FLDS
C*
C* FLDT is a 6-position numeric field with 2 decimal positions.
C *LIKE DEFN FLDB FLDT + 1
C*
C* FLDU is a 3-position numeric field with 2 decimal positions.
C *LIKE DEFN FLDB FLDU - 2
C*
C* FLDX is a 3-position numeric field with 2 decimal positions.
C *LIKE DEFN FLDU FLDX
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* If specified, the attributes (length and decimal positions) of
C* the data area (TOTGRS) must be the same as those for the
C* external data area.
C *NAMVAR DEFN TOTGRS 102
C*
C* The result field entry (TOTNET) is the name of the data area to
C* be used within the RPG/400 program. The factor 2 entry (TOTAL)
C* is the name of the data area as defined to the system.
C *NAMVAR DEFN TOTAL TOTNET
C*
C* The result field entry (SAVTOT) is the name of the data area to
C* be used within the RPG/400 program. The factor 2 entry (*LDA)
C* indicates the use of the local data area.
C *NAMVAR DEFN *LDA SAVTOT
ΓòÉΓòÉΓòÉ 1.10.20.20. DELET (Delete Record) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DELET Γöé Search argu- Γöé File name Γöé Γöé NR ER _ Γöé
Γöé Γöé ment Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DELET operation deletes a record from a database file. The file must be an
update file (identified by a U in position 15. of the file description
specifications) The deleted record can never be retrieved.
If factor 1 contains no entry, the DELET operation deletes the current record
(the last record retrieved). The record must have been locked by a previous
input operation (for example, CHAIN or READ).
Factor 1, the search argument, can contain a key or relative record number that
identifies the record to be deleted. If access is by key, factor 1 can be a
field name, a named constant, or a literal. In addition, a KLIST name can be
specified in factor 1 for an externally described file. If duplicate records
exist for the key, only the first of the duplicate records is deleted from the
file. If access is by relative record number, factor 1 must contain an integer
literal or a numeric field with zero decimal positions.
Factor 2 must contain the name of the update file or the name of a record
format in the file from which a record is to be deleted. A record format name
is valid only with an externally described file. If factor 1 is not specified,
the record format name must be the name of the last record read from the file;
otherwise, an error occurs.
If factor 1 has an entry, you must specify a resulting indicator in positions
54 and 55. If factor 1 does not have an entry, leave these positions blank.
This indicator is set on if the record to be deleted is not found in the file.
You can specify a resulting indicator in positions 56 and 57; it is set on if
the DELET operation is not completed successfully. (For example, an
unauthorized user tries to delete the record) Leave positions 58 and 59 blank.
Under the OS/400 operating system, if a read operation is done on the file
specified in factor 2 after a successful DELET operation to that file, the next
record after the deleted record is obtained.
ΓòÉΓòÉΓòÉ 1.10.20.21. DIV (Divide) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DIV(1/2)Γöé Dividend Γöé Divisor Γöé Quotient Γöé + - Z Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
If factor 1 is specified, the DIV operation divides factor 1 by factor 2;
otherwise, it divides the result field by factor 2. The quotient (result) is
placed in the result field. If factor 1 is 0, the result of the divide
operation is 0. Factor 2 cannot be 0. If it is, an error occurs and the
RPG/400 exception/error handling routine receives control. When factor 1 is not
specified, the result field (dividend) is divided by factor 2 (divisor), and
the result (quotient) is placed in the result field. Factor 1 and factor 2 must
be numeric; each can contain one of: an array, array element, field, figurative
constant, literal, named constant, subfield, or table name.
Any remainder resulting from the divide operation is lost unless the move
remainder (MVR) operation is specified as the next operation. If you use
conditioning indicators, you must ensure that the DIV operation is processed
immediately before the MVR operation. If the MVR operation is processed before
the DIV operation, undesirable results occur. If move remainder is the next
operation, the result of the divide operation cannot be half-adjusted
(rounded).
For further rules for the DIV operation, see Arithmetic Operations.
Figure "Summary of Arithmetic Operations" shows examples of the DIV operation.
ΓòÉΓòÉΓòÉ 1.10.20.22. DO (Do) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DO Γöé Starting Γöé Limit value Γöé Index Γöé Γöé
Γöé Γöé value Γöé Γöé value Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DO operation begins a group of operations and indicates the number of times
the group will be processed. To indicate the number of times the group of
operations is to be processed, specify an index field, a starting value, and a
limit value. An associated ENDDO statement marks the end of the group. For
further information on DO groups, see Structured Programming Operations.
In factor 1, specify a starting value with no decimal positions, using a
numeric literal, named constant, or field name. If you do not specify factor
1, the starting value is 1.
In factor 2, specify the limit value with no decimal positions, using a numeric
field name, literal, or named constant. If you do not specify factor 2, the
limit value is 1.
In the result field, specify a numeric field name that will contain the current
index value. The result field must be large enough to contain the limit value
plus the increment. If you do not specify an index field, one is generated for
internal use. Any value in the index field is replaced by factor 1 when the DO
operation begins.
Factor 2 of the associated ENDDO operation specifies the value to be added to
the index field. It can be a numeric literal or a numeric field with no decimal
positions. If it is blank, the value to be added to the index field is 1.
In addition to the DO operation itself, the conditioning indicators on the DO
and ENDDO statements control the DO group. The conditioning indicators on the
DO statement control whether or not the DO operation begins. These indicators
are checked only once, at the beginning of the DO loop. The conditioning
indicators on the associated ENDDO statement control whether or not the DO
group is repeated another time. These indicators are checked at the end of each
loop.
The DO operation follows these 7 steps:
1. If the conditioning indicators on the DO statement line are satisfied, the
DO operation is processed (step 2). If the indicators are not satisfied,
control passes to the next operation to be processed following the
associated ENDDO statement (step 7).
2. The starting value (factor 1) is moved to the index field (result field)
when the DO operation begins.
3. If the index value is greater than the limit value, control passes to the
calculation operation following the associated ENDDO statement (step 7).
Otherwise, control passes to the first operation after the DO statement
(step 4).
4. Each of the operations in the DO group is processed.
5. If the conditioning indicators on the ENDDO statement are not satisfied,
control passes to the calculation operation following the associated ENDDO
statement (step 7). Otherwise, the ENDDO operation is processed (step 6).
6. The ENDDO operation is processed by adding the increment to the index
field. Control passes to step 3. (Note that the conditioning indicators on
the DO statement are not tested again (step 1) when control passes to step
3.)
7. The statement after the ENDDO statement is processed when the conditioning
indicators on the DO or ENDDO statements are not satisfied (step 1 or 5),
or when the index value is greater than the limit value (step 3).
Remember the following when specifying the DO operation:
The index, increment, limit value, and indicators can be modified within the
loop to affect the ending of the DO group.
A DO group cannot span both detail and total calculations.
See LEAVE (Leave a Do Group) and ITER (Iterate) for information on how those
operations affect a DO operation.
See DO Examples
ΓòÉΓòÉΓòÉ 1.10.20.22.1. DO Examples ΓòÉΓòÉΓòÉ
DO Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The DO group is processed 10 times when indicator 17 is on;
C* it stops running when the index value in field X, the result
C* field, is greater than the limit value (10) in factor 2. When
C* the DO group stops running, control passes to the operation
C* immediately following the ENDDO operation. Because factor 1
C* in the DO operation is not specified, the starting value is 1.
C* Because factor 2 of the ENDDO operation is not specified, the
C* incrementing value is 1.
C 17 DO 10 X 30 DO 10 TIMES
C :
C :
C ENDDO
C*
C* The DO group can be processed 10 times. The DO group stops
C* running when the index value in field X is greater than
C* the limit value (20) in factor 2, or if indicator 50 is not on
C* when the ENDDO operation is encountered. When indicator 50
C* is not on, the ENDDO operation is not processed; therefore,
C* control passes to the operation following the ENDDO operation.
C* The starting value of 2 is specified in factor 1 of the DO
C* operation, and the incrementing value of 2 is specified in
C* factor 2 of the ENDDO operation.
C*
C 2 DO 20 X 30 DO 10 TIMES
C :
C :
C :
C 50 ENDDO 2
ΓòÉΓòÉΓòÉ 1.10.20.23. DOUxx (Do Until) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DOUXX Γöé Comparand Γöé Comparand Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DOUxx operation begins a group of operations you want to process more than
once (but always at least once). An associated ENDDO statement marks the end
of the group. For further information on DO groups and the meaning of xx, see
Structured Programming Operations.
Factor 1 and factor 2 must contain a literal, a named constant, a field name, a
table name, an array element, a figurative constant, or a data structure name.
Factor 1 and factor 2 must be either both character or both numeric.
On the DOUxx statement, you indicate a relationship xx. To specify a more
complex condition, immediately follow the DOUxx statement with ANDxx or ORxx
statements. The operations in the DO group are processed once, and then the
group is repeated while the relationship exists between factor 1 and factor 2
or the condition specified by a combined DOUxx, ANDxx, or ORxx operation
exists. The group is always processed at least once even if the condition is
not true at the start of the group.
In addition to the DOUxx operation itself, the conditioning indicators on the
DOUxx and ENDDO statements control the DO group. The conditioning indicators on
the DOUxx statement control whether or not the DOUxx operation begins. The
conditioning indicators on the associated ENDDO statement can cause a DO loop
to end prematurely.
The DOUxx operation follows these steps:
1. If the conditioning indicators on the DOUxx statement line are satisfied,
the DOUxx operation is processed (step 2). If the indicators are not
satisfied, control passes to the next operation that can be processed
following the associated ENDDO statement (step 6).
2. The DOUxx operation is processed by passing control to the next operation
that can be processed (step 3). The DOUxx operation does not compare factor
1 and factor 2 or test the specified condition at this point.
3. Each of the operations in the DO group is processed.
4. If the conditioning indicators on the ENDDO statement are not satisfied,
control passes to the next calculation operation following the associated
ENDDO statement (step 6). Otherwise, the ENDDO operation is processed
(step 5).
5. The ENDDO operation is processed by comparing factor 1 and factor 2 of the
DOUxx operation or testing the condition specified by a combined operation.
If the relationship xx exists between factor 1 and factor 2 or the
specified condition exists, the DO group is finished and control passes to
the next calculation operation after the ENDDO statement (step 6). If the
relationship xx does not exist between factor 1 and factor 2 or the
specified condition does not exist, the operations in the DO group are
repeated (step 3).
6. The statement after the ENDDO statement is processed when the conditioning
indicators on the DOUxx or ENDDO statements are not satisfied (steps 1 or
4), or when the relationship xx between factor 1 and factor 2 or the
specified condition exists at step 5.
See LEAVE (Leave a Do Group) and ITER (Iterate) for information on how those
operations affect a DOUxx operation.
See DOUxx Examples.
ΓòÉΓòÉΓòÉ 1.10.20.23.1. DOUxx Examples ΓòÉΓòÉΓòÉ
DOUxx Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The DOUEQ operation runs the operation within the DO group at
C* least once.
C FLDA DOUEQFLDB
C*
C* At the ENDDO operation, a test is processed to determine whether
C* FLDA is equal to FLDB. If FLDA does not equal FLDB, the
C* preceding operations are processed again. This loop continues
C* processing until FLDA is equal to FLDB. When FLDA is equal to
C* FLDB, the program branches to the operation immediately
C* following the ENDDO operation.
C SUB 1 FLDA
C ENDDO
C*
C* The combined DOUEQ ANDEQ OREQ operation processes the operation
C* within the DO group at least once.
C FLDA DOUEQFLDB
C FLDC ANDEQFLDD
C FLDE OREQ 100
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* At the ENDDO operation, a test is processed to determine whether
C* the specified condition, FLDA equal to FLDB and FLDC equal to
C* FLDD, exists. If the condition exists, the program branches to
C* the operation immediately following the ENDDO operation. There
C* is no need to test the OREQ condition, FLDE equal to 100, if the
C* DOUEQ and ANDEQ conditions are met. If the specified condition
C* does not exist, the OREQ condition is tested. If the OREQ
C* condition is met, the program branches to the operation
C* immediately following the ENDDO. Otherwise, the operations
C* following the OREQ operation are processed and then the program
C* processes the conditional tests starting at the second DOUEQ
C* operation. If neither the DOUEQ and ANDEQ condition nor the
C* OREQ condition is met, the operations following the OREQ
C* operation are processed again.
C SUB 1 FLDA
C ADD 1 FLDC
C ADD 5 FLDE
C ENDDO
ΓòÉΓòÉΓòÉ 1.10.20.24. DOWxx (Do While) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DOWXX Γöé Comparand Γöé Comparand Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DOWxx operation begins a group of operations you want to process while the
relationship xx exists between factor 1 and factor 2. To specify a more complex
condition, immediately follow the DOWxx statement with ANDxx or ORxx
statements. An associated ENDDO statement marks the end of the group. For
further information on DO groups and the meaning of xx, see Structured
Programming Operations.
Factor 1 and factor 2 must contain a literal, a named constant, a figurative
constant, a field name, a table name, an array element, or a data structure
name. Factor 1 and factor 2 must be either both character or both numeric. The
comparison of factor 1 and factor 2 follows the same rules as those given for
the compare operations. See Compare Operations.
In addition to the DOWxx operation itself, the conditioning indicators on the
DOWxx and ENDDO statements control the DO group. The conditioning indicators
on the DOWxx statement control whether or not the DOWxx operation is begun.
The conditioning indicators on the associated ENDDO statement control whether
the DO group is repeated another time.
The DOWxx operation follows these steps:
1. If the conditioning indicators on the DOWxx statement line are satisfied,
the DOWxx operation is processed (step 2). If the indicators are not
satisfied, control passes to the next operation to be processed following
the associated ENDDO statement (step 6).
2. The DOWxx operation is processed by comparing factor 1 and factor 2 or
testing the condition specified by a combined DOWxx, ANDxx, or ORxx
operation. If the relationship xx between factor 1 and factor 2 or the
condition specified by a combined operation does not exist, the DO group is
finished and control passes to the next calculation operation after the
ENDDO statement (step 6). If the relationship xx between factor 1 and
factor 2 or the condition specified by a combined operation exists, the
operations in the DO group are repeated (step 3).
3. Each of the operations in the DO group is processed.
4. If the conditioning indicators on the ENDDO statement are not satisfied,
control passes to the next operation to run following the associated ENDDO
statement (step 6). Otherwise, the ENDDO operation is processed (step 5).
5. The ENDDO operation is processed by passing control to the DOWxx operation
(step 2). (Note that the conditioning indicators on the DOWxx statement
are not tested again at step 1.)
6. The statement after the ENDDO statement is processed when the conditioning
indicators on the DOWxx or ENDDO statements are not satisfied (steps 1 or
4), or when the relationship xx between factor 1 and factor 2 of the
specified condition does not exist at step 2.
See LEAVE (Leave a Do Group) and ITER (Iterate) for information on how those
operations affect a DOWxx operation.
See DOWxx Examples.
ΓòÉΓòÉΓòÉ 1.10.20.24.1. DOWxx Examples ΓòÉΓòÉΓòÉ
DOWxx Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The DOWLT operation allows the operation within the DO group
C* to be processed only if FLDA is less than FLDB. If FLDA is
C* not less than FLDB, the program branches to the operation
C* immediately following the ENDDO operation. If FLDA is less
C* than FLDB, the operation within the DO group is processed.
C FLDA DOWLTFLDB
C*
C* The ENDDO operation causes the program to branch to the first
C* DOWLT operation where a test is made to determine whether FLDA
C* is less than FLDB. This loop continues processing until FLDA
C* is equal to or greater than FLDB; then the program branches
C* to the operation immediately following the ENDDO operation.
C MULT 2.08 FLDA
C ENDDO
C* In this example, multiple conditions are tested. The combined
C* DOWLT ORLT operation allows the operation within the DO group
C* to be processed only while FLDA is less than FLDB or FLDC. If
C* neither specified condition exists, the program branches to
C* the operation immediately following the ENDDO operation. If
C* either of the specified conditions exists, the operation after
C* the ORLT operation is processed.
C FLDA DOWLTFLDB
C FLDA ORLT FLDC
C* The ENDDO operation causes the program to branch to the second
C* DOWLT operation where a test determines whether specified
C* conditions exist. This loop continues until FLDA is equal to
C* or greater than FLDB and FLDC; then the program branches to the
C* operation immediately following the ENDDO operation.
C MULT 2.08 FLDA
C ENDDO
ΓòÉΓòÉΓòÉ 1.10.20.25. DSPLY (Display Function) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DSPLY Γöé Message iden- Γöé Output queue Γöé Response Γöé _ ER _ Γöé
Γöé Γöé tifier Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DSPLY operation allows the program to communicate with the display work
station that requested the program. The operation can display a message and
accept a response.
The value in factor 1 is used to create the message to be displayed. If factor
1 is specified, it can contain a field name, a literal, a named constant, a
table name, or an array element whose value is used to create the message to be
displayed. Factor 1 can also contain *M, followed by a message identifier that
identifies the message to be retrieved from the message file, QUSERMSG.
QUSERMSG must be in a library in the library list of the job receiving the
message.
The message identifier can be from 1 to 7 characters in length and can include
an optional alphabetic prefix of 3 characters followed immediately by 1 to 4
digits. If the alphabetic prefix is not specified, the default is USR. The
numeric portion of the message identifier (1) must immediately follow either *M
or the optional alphabetic prefix, (2) cannot include embedded blanks, and (3)
must be left-adjusted (high-order zeros can be omitted). If the numeric portion
of the message identifier is not specified, the default is 0000. Valid
examples are:
Factor 1 Message
Entry Identifier
Used
*M USR0000
*MABC ABC0000
*M1 USR0001
*MABC5 ABC0005
If specified, factor 2 can contain a character field, a literal, a named
constant, a table name, or an array element whose value is the symbolic name of
the object meant to receive the message and from which the optional response
can be sent. Any queue name except a program message queue name can be the
value contained in the factor 2 entry. The queue must be declared to the
OS/400 system before it can be specified in factor 2. (For information on how
to create a queue, see the Programming: Control Language Programmer's Guide.)
There are two predefined queues:
Queue Value
QSYSOPR The message is sent to the system operator. Note that the QSYSOPR
message queue severity level must be zero (00) to enable the DSPLY
operation to immediately display a message to the system operator.
*EXT The message is sent to the requester.
Note: For a batch job, if factor 2 is blank, the default is QSYSOPR. For an
interactive job, if factor 2 is blank, the default is *EXT.
The result field is optional. If it is specified, the response is placed in it.
It can contain a field name, a table name, or an array element in which the
response is placed. If no data is entered, the result field is unchanged.
Positions 56 and 57 can contain an indicator to be set on if an error occurs on
the operation. If an error occurs when the workstation user enters the
response, the message is displayed again a maximum of five times. After the
fifth display, the indicator in positions 56 and 57, if specified, is set on.
If this indicator is not specified, the exception/error handling routine
receives control.
When you specify the DSPLY operation with no message identifier in factor 1,
the operation functions as follows:
When factor 1 contains an entry and the result field is blank, the contents
of the factor 1 entry are displayed. The program does not wait for a
response unless a display file with the parameter RSTDSP (*NO) specified was
used to display a format at the workstation. Then the program waits for the
user to press Enter.
When factor 1 is blank and the result field contains an entry, the contents
of the result field entry are displayed and the program waits for the user to
enter data for the response. The reply is placed in the result field.
When both factor 1 and the result field contain entries, the contents of the
factor 1 and result field entries are combined and displayed. The program
waits for the user to enter data for the response. The response is placed in
the result field.
The maximum length of information that can be displayed is 52 characters.
The format of the record written by the DSPLY operation with no message
identifier in factor 1 follows:
(1)The maximum length of information that can be displayed is
52 characters.
Variable Length(1) Variable Length(1)
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
DSPLY
ΓööΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
blank Contents of blank Contents of the result
factor 1 if field if both factor 1
it is and the result field
specified are specified.
or
contents of
the result field
if factor 1 is
not specified.
When you specify the DSPLY operation with a message identifier in factor 1, the
operation functions as follows: the message identified by the factor 1 entry
is retrieved from QUSERMSG, the message is displayed, and the program waits for
the user to respond by entering data if the result field is specified. The
response is placed in the result field. For information on how to format the
display, see the Data Management Guide.
When replying to a message, remember the following:
Numeric fields sent to the display are right-adjusted and zero-suppressed.
If a numeric field is keyed with a length greater than the number of digits
in the result field and the rightmost character is not a minus sign (-), an
error is detected and a second wait occurs. The user must key in the field
again.
To enter a null response to the system operator queue (QSYSOPR), the user
must enter the characters *N and then press Enter.
Character fields are padded on the right with blanks after all characters are
keyed.
Numeric fields are right-adjusted and padded on the left with zeros after all
characters are keyed.
Lowercase characters are not converted to uppercase.
ΓòÉΓòÉΓòÉ 1.10.20.26. DUMP (Program Dump) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé DUMP Γöé Identifier Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The DUMP operation provides a dump (all fields, all files, indicators, data
structures, arrays, and tables defined) of the program. It can be used
independently of or in combination with the OS/400 testing and debugging
functions.
The contents of factor 1 identify the DUMP operation. It must contain a
character entry that can be one of: a field name, literal, named constant,
table name, or array element whose contents identify the dump. Factor 1 cannot
contain a figurative constant.
The program continues processing the next calculation statement following the
DUMP operation.
The DUMP operation is performed only if a 1 is specified in position 15 of the
control specification. If the control specification entry is not made, the DUMP
operation is checked for errors and the statement is printed on the listing,
but the DUMP operation is not processed.
If you have specified a POST operation code, with factor 1 blank, anywhere in
your program, no file information data structures (INFDS) are updated until you
do an appropriate POST operation. For up-to-date information, do a POST
operation for each file before you do the DUMP operation. (This action is not
required for a dump that the system does in response to an inquiry message.)
ΓòÉΓòÉΓòÉ 1.10.20.27. ELSE (Else) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ELSE Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ELSE operation is an optional part of the IFxx operation. If the IFxx
comparison is met, the calculations before ELSE are processed; otherwise, the
calculations after ELSE are processed.
Within total calculations, the control level entry (positions 7 and 8) can be
blank or can contain an L1 through L9 indicator, an LR indicator, or an L0
entry to group the statement within the appropriate section of the program. The
control level entry is for documentation purposes only. Conditioning indicator
entries (positions 9 through 17) are not permitted.
To close the IFxx/ELSE group use an ENDIF operation.
Figure "IFxx/ENDIF and IFxx/ELSE/ENDIF Operations" shows an example of an ELSE
operation with an IFxx operation.
ΓòÉΓòÉΓòÉ 1.10.20.28. ENDyy (End a Group) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé END Γöé Γöé Increment value Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ENDCS Γöé Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ENDDO Γöé Γöé Increment value Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ENDIF Γöé Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ENDSL Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ENDyy operation ends a CASxx, DO, DOUxx, DOWxx, IFxx, or SELEC group of
operations.
The ENDyy operations are listed below:
END End a CASxx, DO, DOUxx, DOWxx, IFxx, or SELEC group
ENDCS End a CASxx group
ENDDO End a DO, DOUxx, or DOWxx group
ENDIF End an IFxx group
ENDSL End a SELEC group
Factor 2 is allowed only on an ENDyy operation that delimits a DO group. It
contains the incrementing value of the DO group. It can be positive or
negative, must have no decimal positions, and can be one of: an array element,
table name, data structure, field, named constant, or numeric literal. If
factor 2 is not specified on the ENDDO, the increment defaults to 1.
Conditioning indicators are optional for ENDDO and not allowed for ENDCS,
ENDIF, and ENDSL.
Resulting indicators are not allowed. Factor 1, factor 2, and the result field
must all be blank for ENDCS, ENDIF,and ENDSL.
If one ENDyy form is used with a different operation group (for example, ENDIF
with a structured group), an error results at compilation time.
See the CASxx, DO, DOUxx, DOWxx, IFxx, and SELEC operations for examples that
use the ENDyy operation.
ΓòÉΓòÉΓòÉ 1.10.20.29. ENDSR (End of Subroutine) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ENDSR Γöé Label Γöé Return point Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ENDSR operation defines the end of an RPG/400 subroutine and the return
point to the main program. ENDSR must be the last statement in the subroutine.
Factor 1 can contain a label that can be used as a point to which a GOTO
operation within the subroutine can branch. The control level entry (positions
7 and 8) can be SR or blank. Conditioning indicator entries are not allowed.
The ENDSR operation ends a subroutine and causes a branch back to the statement
immediately following the EXSR operation unless the subroutine is a program
exception/error subroutine (*PSSR) or a file exception/error subroutine
(INFSR). For these subroutines, factor 2 of the ENDSR operation can contain an
entry that specifies where control is to be returned following processing of
the subroutine. This entry can be a field name that contains a reserved
keyword or a literal or named constant that is a reserved keyword. If a return
point that is not valid is specified, the RPG/400 error handler receives
control.
See Figure "Example of Coding Subroutines" for an example of coding an RPG/400
subroutine.
ΓòÉΓòÉΓòÉ 1.10.20.30. EXCPT (Calculation Time Output) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé EXCPT Γöé Γöé EXCPT name Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The EXCPT operation has two major functions:
It allows records to be written during calculation time.
It allows a variable number of records to be written in one program cycle at
either detail calculation or total calculation time.
See Figure "EXCPT Operation with/without Factor 2 Specified" for examples of
the EXCPT operation.
When specifying the EXCPT operation remember:
The exception records that are to be written during calculation time are
indicated by an E in position 15 of the output specifications. An EXCPT name,
which is the same name as specified in factor 2 of an EXCPT operation, can be
specified in positions 32 through 37 of the output specifications of the
exception records.
Only exception records, not heading, detail, or total records, can contain an
EXCPT name.
When the EXCPT operation with a name in factor 2 is processed, only those
exception records with the same EXCPT name are checked and written if the
conditioning indicators are satisfied.
When factor 2 is blank, only those exception records with no name in
positions 32 through 37 of the output specifications are checked and written
if the conditioning indicators are satisfied.
If an exception record is conditioned by an overflow indicator on the output
specification, the record is written only during the overflow portion of the
RPG/400 cycle or during fetch overflow. The record is not written at the time
the EXCPT operation is processed.
If an exception output is specified to a format that contains no fields, the
following occurs:
- If an output file is specified, a record is written with default values.
- If a record is locked, the system treats the operation as a request to
unlock the record. This is the alternative form of requesting an unlock.
The preferred method is with the UNLCK operation.
ΓòÉΓòÉΓòÉ 1.10.20.30.1. EXCPT Examples ΓòÉΓòÉΓòÉ
EXCPT Operation with/without Factor 2 Specified
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* When the EXCPT operation with HDG specified in factor 2 is
C* processed, all exception records with the EXCPT name HDG are
C* written. In this example, UDATE and PAGE would be printed
C* and then the printer would space 2 lines.
C EXCPTHDG
C*
C* When the EXCPT operation with no entry in factor 2 is
C* processed, all exception records that do not have an EXCPT
C* name specified in positions 32 through 37 are written if the
C* conditioning indicators are satisfied. Any exception records
C* without conditioning indicators and without an EXCPT name
C* are always written by an EXCPT operation with no entry in
C* factor 2. In this example, if indicator 10 is on, TITLE and
C* AUTH would be printed and then the printer would space 1 line.
C EXCPT
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
OName++++DFBASbSaN01N02N03Excnam....................................
O*
O E 1 10
O TITLE
O AUTH
O E 2 HDG
O UDATE
O PAGE
O E 1 DETAIL
O AUTH
O VERSNO
ΓòÉΓòÉΓòÉ 1.10.20.31. EXFMT (Write/Then Read Format) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé EXFMT Γöé Γöé Record format Γöé Γöé _ ER _ Γöé
Γöé Γöé Γöé name Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The EXFMT operation is a combination of a WRITE followed by a READ to the same
record format. EXFMT is valid only for a WORKSTN file defined as a full
procedural (F in position 16 of the file description specifications) combined
file (C in position 15 of the file description specifications) that is
externally described (E in position 19. of the file description specifications)
Factor 2 must contain the name of the record format to be written and then
read. A resulting indicator can be specified in positions 56 and 57 to be set
on if the EXFMT operation is not completed successfully. When the indicator is
set on, the read portion of the operation is not processed (record identifying
indicators and fields are not modified). Positions 54, 55, 58, and 59 must be
blank.
For the use of EXFMT with multiple device files, see the descriptions of the
READ (by format name) and WRITE operations.
ΓòÉΓòÉΓòÉ 1.10.20.32. EXSR (Invoke Subroutine) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé EXSR Γöé Γöé Subroutine name Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The EXSR operation causes the RPG/400 subroutine named in factor 2 to be
processed. The subroutine name must be a unique symbolic name and must appear
as factor 1 of a BEGSR operation. The EXSR operation can appear anywhere in the
calculation specifications. Whenever it appears, the subroutine that is named
is processed. After operations in the subroutine are processed, the statement
following the EXSR operation is processed except when a GOTO within the
subroutine is given to a label outside the subroutine or when the subroutine is
an exception/error subroutine with an entry in factor 2 of the ENDSR operation.
*PSSR used in factor 2 specifies that the program exception/error subroutine is
to be processed. *INZSR used in factor 2 specifies that the program
initialization subroutine is to be processed.
See Coding Subroutines for more information.
ΓòÉΓòÉΓòÉ 1.10.20.33. Coding Subroutines ΓòÉΓòÉΓòÉ
An RPG/400 subroutine can be processed from any point in the calculation
operations. All RPG/400 operations can be processed within a subroutine, and
these operations can be conditioned by any valid indicators in positions 9
through 17. SR or blanks can appear in positions 7 and 8. Control level
indicators (L1 through L9) cannot be used in these positions. However, AND/OR
lines within the subroutine can be indicated in positions 7 and 8.
Fields used in a subroutine can be defined either in the subroutine or in the
rest of the program. In either instance, the fields can be used by both the
main program and the subroutine.
You can include a maximum of 254 subroutines in a program; however, a
subroutine cannot contain another subroutine. One subroutine can call another
subroutine; that is, a subroutine can contain an EXSR or CASxx. However, an
EXSR or CASxx specification within a subroutine cannot directly call itself.
Indirect calls to itself through another subroutine should not be performed,
because unpredictable results can occur. Use the GOTO and TAG operation codes
if you want to branch to another point within the same subroutine.
Subroutines do not have to be specified in the order they are used. Each
subroutine must have a unique symbolic name and must contain a BEGSR and an
ENDSR statement.
The use of the GOTO (branching) operation is allowed within a subroutine. GOTO
can specify the label on the ENDSR operation associated with that subroutine;
it cannot specify the name of a BEGSR operation. A GOTO outside the subroutine
cannot be issued to a BEGSR, ENDSR, or TAG within a subroutine. A GOTO within
a subroutine can be issued to a TAG within either detail or total calculations.
See Figure "Example of Coding Subroutines" for an example of coding a
subroutine.
ΓòÉΓòÉΓòÉ 1.10.20.33.1. Subroutine Coding Examples ΓòÉΓòÉΓòÉ
Example of Coding Subroutines
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* For a subroutine, positions 7 and 8 can be blank or contain SR.
C*
C :
C :
C EXSR SUBRTB
C :
C : CALCULATIONS
C :
CL2 EXSR SUBRTA
C :
C : CALCULATIONS
C :
C SUBRTA BEGSR
C :
C : CALCULATIONS
C :
C*
C* One subroutine can call another subroutine.
C*
C EXSR SUBRTC
C :
C : CALCULATIONS
C :
C ENDSR
C SUBRTB BEGSR
C : CALCULATIONS
C :
C :
C*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* GOTO and TAG operations can be used within a subroutine.
C*
C START TAG
C :
C : CALCULATIONS
C :
C 23 GOTO END
C :
C : CALCULATIONS
C :
C 24 GOTO START
C END ENDSR
C SUBRTC BEGSR
C :
C : CALCULATIONS
C :
C ENDSR
C*
ΓòÉΓòÉΓòÉ 1.10.20.34. FEOD (Force End of Data) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé FEOD Γöé Γöé File name Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The FEOD operation signals the logical end of data for a primary, secondary, or
full procedural file. The FEOD function differs, depending on the file type and
device. (For an explanation of how FEOD differs per file type and device, see
the Database Guide, SC41-9659.)
FEOD differs from the CLOSE operation: the program is not disconnected from the
device or file; the file can be used again for subsequent file operations
without an explicit OPEN operation being specified to the file.
You can specify conditioning indicators. Factor 2 names the file to which FEOD
is specified. You can specify a resulting indicator in positions 56 and 57 to
be set on if the operation is not completed successfully.
To process any further sequential operations to the file after the FEOD
operation (for example, READ or READP), you must reposition the file.
ΓòÉΓòÉΓòÉ 1.10.20.35. FORCE (Force a Certain File to Be Read Next Cycle) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé FORCE Γöé Γöé File name Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The FORCE operation allows selection of the file from which the next record is
to be read. It can be used only for primary or secondary files.
Factor 2 must contain the name of a file from which the next record is to be
selected.
If the FORCE operation is processed, the record is read at the start of the
next program cycle. If more than one FORCE operation is processed during the
same program cycle, all but the last is ignored. FORCE must be issued at detail
time, not total time.
FORCE operations override the multifile processing method by which the program
normally selects records. However, the first record to be processed is always
selected by the normal method. The remaining records can be selected by FORCE
operations. For information on how the FORCE operation affects match-field
processing, see -- Reference detlobj not found --.
If FORCE is specified for a file that is at end of file, no record is retrieved
from the file. The program cycle determines the next record to be read.
ΓòÉΓòÉΓòÉ 1.10.20.36. FREE (Deactivate a Program) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé FREE Γöé Γöé Program name Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The FREE operation removes a program from the list of activated programs, frees
static storage, and ensures program initialization (first cycle processing) the
next time the program is called. It does not close files or unlock data areas.
Factor 2 contains the name of the program to be deactivated. It must contain
the name of a field, named constant, literal, or array element that contains
the name of the program to be deactivated. The entry in factor 2 must be
character data; it can include a qualified name such as LIB/PGM. The name
preceding the slash is the library that contains the program to be freed from
the activated program list. Specify only the program name if you want to search
the library list. The RPG/400 language uses the program name exactly as
specified in the literal, field, or array element to determine the program to
be called. (Lowercase characters are not shifted to uppercase, and a name
enclosed in quotation marks (for example 'ABC') always includes the quotation
marks as part of the name of the program to be freed.) *LIBL and *CURLIB are
not supported (for example, '*LIBL/PROG').
You can specify any valid resulting indicator in positions 56 and 57 to be set
on if FREE is not completed successfully. No error occurs if the program to be
freed is not active (for example, the program does not exist).
See the CALL (Call a Program) operation for details on how program references
are grouped.
Note: Issuing a FREE operation and then a CALL operation to the same program
reopens the program's files and may use additional temporary storage.
Repeatedly issuing FREE and CALL operations to a program, without closing the
program's files in between, may use enough temporary storage to degrade the
system's performance, and ultimately cause an AS/400 machine check. This
problem can be avoided if the files have shared open data paths SHARE(*YES).
However, using SHARE(*YES) can cause other problems. Read the section on
"Sharing an Open Data Path" in the RPG/400* User's Guide for complete details.
Figure "CALL/FREE Operations" shows the FREE operation being used with the CALL
operation.
ΓòÉΓòÉΓòÉ 1.10.20.36.1. FREE Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* When the CALL operation is processed, the data in the result
C* fields of the parameter list can be accessed by PROGA. The
C* parameter list ends when the first calculation operation other
C* than a PARM operation is encountered.
C CALL 'PROGA'
C PARM FLDA 30
C PARM FLDB 30
C PARM FLDC 50
C*
C* When the FREE operation is processed, PROGA is removed from the
C* list of activated programs. Removing it from the list ensures
C* a fresh copy of all fields in PROGA the next time the program is
C* called. Indicator 55 is set on if the FREE operation is not
C* completed successfully.
C*
C FREE 'PROGA' 55 55 = NO SUCCESS
CALL/FREE Operations
ΓòÉΓòÉΓòÉ 1.10.20.37. GOTO (Go To) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé GOTO Γöé Γöé Label Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The GOTO operation allows calculation operations to be skipped by instructing
the program to go to (or branch to) another calculation operation in the
program. A TAG (Tag) operation names the destination of a GOTO operation. Use a
GOTO operation to specify a branch:
To a previous or a succeeding specification line
From a detail calculation line to another detail calculation line
From a total calculation line to another total calculation line
From a detail calculation line to a total calculation line
From a subroutine to a detail calculation line or to a total calculation
line.
A GOTO operation outside a subroutine cannot specify a branch to a TAG or ENDSR
operation within that subroutine.
A branch cannot be made from a total calculation line to a detail calculation
line. (A total calculation line is defined as one that is conditioned by a
control level indicator in positions 7 and 8 of the calculation
specifications.)
Branching from one part of the RPG/400 logic cycle to another may result in an
endless loop. You are responsible for ensuring that the logic of your program
does not produce undesirable results.
Factor 2 must contain the label to which the program is to branch. This label
is entered in factor 1 of a TAG or ENDSR operation. The label must be a unique
symbolic name.
See Figure "GOTO and TAG Operations" for examples of the GOTO operation.
ΓòÉΓòÉΓòÉ 1.10.20.37.1. GOTO Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* If indicator 10, 15, or 20 is on, the program branches to
C* the TAG label specified in the GOTO operations.
C* A branch within detail calculations.
C 10 GOTO RTN1
C*
C* A branch from detail to total calculations.
C 15 GOTO RTN2
C*
C RTN1 TAG
C*
C : Calculations
C :
C
C 20 GOTO END
C*
C :
C : Calculations
C :
C END TAG
C* A branch within total calculations.
CL1 GOTO RTN2
CL1
CL1 RTN2 TAG
GOTO and TAG Operations
ΓòÉΓòÉΓòÉ 1.10.20.38. IFxx (If) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé IFXX Γöé Comparand Γöé Comparand Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The IFxx operation allows a group of calculations to be processed if a certain
relationship, specified by xx, exists between factor 1 and factor 2. When ANDxx
(And) and ORxx (Or) operations are used with IFxx, the group of calculations is
performed if the condition specified by the combined operations exists. (For
the meaning of xx, see Structured Programming Operations.)
You can use conditioning indicators. Factor 1 and factor 2 must contain a
literal, a named constant, a figurative constant, a table name, an array
element, a data structure name, or a field name. Both the factor 1 and factor 2
entries must be character, or both must be numeric.
If the relationship specified by the IFxx and any associated ANDxx or ORxx
operations does not exist, control passes to the calculation operation
immediately following the associated ENDIF operation. If an ELSE (Else)
operation is specified as well, control passes to the first calculation
operation that can be processed following the ELSE operation.
Conditioning indicator entries on the ENDIF operation associated with IFxx must
be blank.
An ENDIF statement must be used to close an IFxx group. If an IFxx statement
is followed by an ELSE statement, an ENDIF statement is required after the ELSE
statement but not after the IFxx statement.
You have the option of indenting DO statements, IF-ELSE clauses, and
SELEC-WHxx-OTHER clauses for readability.
Figure "IFxx/ENDIF and IFxx/ELSE/ENDIF Operations" illustrates uses of the IFxx
operation.
ΓòÉΓòÉΓòÉ 1.10.20.38.1. IFxx/ELSE/ENDIF Examples ΓòÉΓòÉΓòÉ
IFxx/ENDIF and IFxx/ELSE/ENDIF Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* If FLDA equals FLDB, the calculation after the IFEQ operation
C* is processed. If FLDA does not equal FLDB, the program
C* branches to the operation immediately following the ENDIF.
C FLDA IFEQ FLDB IF EQUAL
C :
C :
C :
C ENDIF
C*
C* If FLDA equals FLDB, the calculation after the IFEQ operation
C* is processed and control passes to the operation immediately
C* following the ENDIF statement. If FLDA does not equal FLDB,
C* control passes to the ELSE statement and the calculation
C* immediately following is processed.
C*
C FLDA IFEQ FLDB IF EQUAL
C :
C :
C :
C ELSE IF NOT EQUAL
C :
C :
C :
C ENDIF
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* If FLDA is equal to FLDB and greater than FLDC, or, if FLDD
C* is equal to FLDE and greater than FLDF, the calculation
C* after the ANDGT operation is processed. If neither of the
C* specified conditions exists, the program branches to the
C* operation immediately following the ENDIF statement.
C FLDA IFEQ FLDB
C FLDA ANDGTFLDC
C FLDD OREQ FLDE
C FLDD ANDGTFLDF
C :
C :
C :
C ENDIF
ΓòÉΓòÉΓòÉ 1.10.20.39. IN (Retrieve a Data Area) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé IN Γöé *LOCK Γöé Data area name Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The IN operation retrieves a data area and optionally allows you to specify
whether the data area is to be locked from update by another program. For a
data area to be retrieved by the IN operation, it must be specified in the
result field of an *NAMVAR DEFN statement.
Factor 1 can contain the reserved word *LOCK or can be blank. *LOCK indicates
that the data area cannot be updated or locked by another program until (1) an
UNLCK (Unlock a Data Area or Release a Record) operation is processed, (2) an
OUT (Write a Data Area) operation with no factor 1 entry is processed, or (3)
the RPG/400 program implicitly unlocks the data area when the program ends.
Factor 1 must be blank when factor 2 contains the name of the local data area
or the Program Initialization Parameters (PIP) data area.
You can specify a *LOCK IN statement for a data area that the program has
locked. When factor 1 is blank, the lock status is the same as it was before
the data area was retrieved: If it was locked, it remains locked; if unlocked,
it remains unlocked.
Factor 2 must be either the name of the data area to be retrieved or the
reserved word *NAMVAR. When *NAMVAR is specified, all data areas defined in
the program are retrieved. If an error occurs on the retrieval of a data area
(for example, a data area can be retrieved but cannot be locked), an error
occurs on the IN operation and the RPG/400 exception/error handling routine
receives control. If a program exception/error subroutine (*PSSR) is specified,
the program status data structure contains information on the data area in
error. If a message is issued to the requester, the message identifies the data
area in error.
You can specify a resulting indicator in positions 56 and 57 to be set on if an
error occurs during the operation. Positions 54-55 and 58-59 must be blank.
For further rules for the IN operation, see Data-Area Operations. See Figure
"IN and OUT Operations" for an example of the IN operation.
ΓòÉΓòÉΓòÉ 1.10.20.39.1. In and Out Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* TOTAMT, TOTGRS, and TOTNET are defined as data areas. The IN
C* operation retrieves all the data areas defined in the program
C* and locks them. The program processes calculations, and at
C* LR time it writes and unlocks all the data areas.
C* The data areas can then be used by other programs.
C*
C *LOCK IN *NAMVAR
C*
C ADD AMOUNT TOTAMT
C ADD GROSS TOTGRS
C ADD NET TOTNET
C*
CLR OUT *NAMVAR
C*
C *NAMVAR DEFN TOTAMT 82
C *NAMVAR DEFN TOTGRS 102
C *NAMVAR DEFN TOTNET 102
IN and OUT Operations
ΓòÉΓòÉΓòÉ 1.10.20.40. ITER (Iterate) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ITER Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ITER operation transfers control from within a do group to the ENDDO
statement of the do group. It can be used in DO, DOUxx, and DOWxx loops to
transfer control immediately to a loop ENDDO statement. It causes the next
iteration of the loop to be executed immediately. ITER affects the innermost
loop.
If conditioning indicators are present on the ENDDO statement to which control
is passed, and the condition is not satisfied, processing continues with the
statement following the ENDDO operation.
The LEAVE (Leave a Do Group) operation is similar to the ITER operation;
however, LEAVE transfers control to the statement following the ENDDO
operation.
ITER Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following example uses a DOU loop containing a DOW loop.
C* The IF statement checks indicator 01. If indicator 01 is ON,
C* the LEAVE operation is executed, transferring control out of
C* the innermost DOW loop to the Z-ADD instruction. If indicator
C* 01 is not ON, subroutine PROC1 is processed. Then indicator
C* 12 is checked. If it is OFF, ITER transfers control to the
C* innermost ENDDO and the condition on the DOW is evaluated
C* again. If indicator 12 is ON, subroutine PROC2 is processed.
C :
C FLDA DOUEQFLDB Outer loop
C :
C NUM DOWLT10 Inner loop
C *IN01 IFEQ *ON
C LEAVE
C ENDIF
C EXSR PROC1
C *IN12 IFEQ *OFF
C ITER ITER
C ENDIF
C EXSR PROC2
C ENDDO Inner ENDDO
C Z-ADD20 RSLT 20 Z-ADD
C :
C ENDDO Outer ENDDO
C :
C*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following example uses a DOU loop containing a DOW loop.
C* The IF statement checks indicator 1. If indicator 1 is ON, the
C* MOVE operation is executed, followed by the LEAVE operation,
C* transferring control from the innermost DOW loop to the Z-ADD
C* instruction. If indicator 1 is not ON, ITER transfers control
C* control to the innermost ENDDO and the condition on the DOW is
C* evaluated again.
C :
C FLDA DOUEQFLDB
C :
C NUM DOWLT10
C *IN01 IFEQ *ON
C MOVE 'UPDATE' FIELD 20
C LEAVE
C ELSE
C ITER
C ENDIF
C ENDDO Inner ENDDO
C Z-ADD20 RSLT 20
C :
C ENDDO
C :
ΓòÉΓòÉΓòÉ 1.10.20.41. KFLD (Define Parts of a Key) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé KFLD Γöé Γöé Γöé Key Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The KFLD operation is a declarative operation that indicates that a field is
part of a search argument identified by a KLIST name.
The KFLD operation can be specified anywhere within calculations, including
total calculations. The control level entry (positions 7 and 8) can be blank
or can contain an L1 through L9 indicator, an LR indicator, or an L0 entry to
group the statement within the appropriate section of the program.
Conditioning indicator entries (positions 9 through 17) are not permitted.
The result field must contain the name of a field that is to be part of the
search argument. The result field cannot contain an array name or a table
name. Each KFLD field must agree in length, data type (character or numeric),
and decimal position with the corresponding field in the composite key of the
record or file. However, each KFLD field need not have the same name as the
corresponding field in the composite key. The order the KFLD fields are
specified in the KLIST determines which KFLD is associated with a particular
field in the composite key. For example, the first KFLD field following a
KLIST operation is associated with the leftmost (high-order) field of the
composite key.
Figure "KLIST and KFLD Operations" shows an example of the KLIST operation with
KFLD operations.
ΓòÉΓòÉΓòÉ 1.10.20.42. KLIST (Define a Composite Key) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé KLIST Γöé KLIST name Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The KLIST operation is a declarative operation that gives a name to a list of
KFLDs. This list can be used as a search argument to retrieve records from
files that have a composite key.
You can specify a KLIST anywhere within calculations. The control level entry
(positions 7 and 8) can be blank or can contain an L1 through L9 indicator, an
LR indicator, or an L0 entry to group the statement within the appropriate
section of the program. Conditioning indicator entries (positions 9 through 17)
are not permitted. Factor 1 must contain a unique name.
Remember the following when specifying a KLIST operation:
If a search argument is composed of more than one field (a composite key),
you must specify a KLIST with multiple KFLDs.
A KLIST name can be specified as a search argument only for externally
described files.
A KLIST and its associated KFLD fields can appear anywhere in calculations.
A KLIST must be followed immediately by at least one KFLD.
A KLIST is ended when a non-KFLD operation is encountered.
A KLIST name can appear in factor 1 of a CHAIN, DELET, READE, REDPE, SETGT,
or SETLL operation.
The same KLIST name can be used as the search argument for multiple files, or
it can be used multiple times as the search argument for the same file.
Figure "KLIST and KFLD Operations" shows an example of the KLIST operation.
ΓòÉΓòÉΓòÉ 1.10.20.42.1. KLIST and KFLD Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
A* DDS source
A R RECORD
A FLDA 4
A SHIFT 1 0
A FLDB 10
A CLOCK# 5 0
A FLDC 10
A DEPT 4
A FLDD 8
A K DEPT
A K SHIFT
A K CLOCK#
A*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The KLIST operation indicates the name, FILEKY, by which the
C* search argument can be specified.
C FILEKY KLIST
C KFLD DEPT
C KFLD SHIFT
C KFLD CLOCK#
KLIST and KFLD Operations
ΓòÉΓòÉΓòÉ 1.10.20.43. LEAVE (Leave a Do Group) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé LEAVE Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The LEAVE operation transfers control from within a do group to the statement
following the ENDDO operation.
You can use LEAVE within a DO, DOUxx, or DOWxx loop to transfer control
immediately from the innermost loop to the statement following the innermost
loop's ENDDO operation. Using LEAVE to leave a do group does not increment the
index.
In nested loops, LEAVE causes control to transfer "outwards" by one level only.
LEAVE is not allowed outside a do group.
The ITER (Iterate) operation is similar to the LEAVE operation; however, ITER
transfers control to the ENDDO statement.
Figure "LEAVE Operation" shows an example of the LEAVE operation.
ΓòÉΓòÉΓòÉ 1.10.20.43.1. LEAVE Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following example uses an infinite loop. When the user
C* types 'q', control transfers to the LEAVE operation, which in
C* turn transfers control out of the loop to the Z-ADD operation.
C*
C 2 DOWNE1
C :
C ANSWER IFEQ 'q'
C LEAVE
C ENDIF
C :
C ENDDO
C Z-ADDA B
C*
C*
C* The following example uses a DOUxx loop containing a DOWxx.
C* The IF statement checks indicator 1. If it is ON, indicator
C* 99 is turned ON, control passes to the LEAVE operation and
C* out of the inner DOWxx loop.
C*
C* A second LEAVE instruction is then executed because indicator 99
C* is ON, which in turn transfers control out of the DOUxx loop.
C :
C FLDA DOUEQFLDB
C NUM DOWLT10
C *IN01 IFEQ *ON
C SETON 99
C LEAVE
C :
C ENDIF
C ENDDO
C 99 LEAVE
C :
C ENDDO
C :
LEAVE Operation
ΓòÉΓòÉΓòÉ 1.10.20.44. LOKUP (Look Up) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé LOKUP Γöé Γöé Γöé Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé (array) Γöé Search argu- Γöé Array name Γöé Γöé HI LO Γöé
Γöé Γöé ment Γöé Γöé Γöé EQ Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé (table) Γöé Search argu- Γöé Table name Γöé Table Γöé HI LO Γöé
Γöé Γöé ment Γöé Γöé name Γöé EQ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The LOKUP operation causes a search to be made for a particular element in an
array or table. Factor 1 is the search argument (data for which you want to
find a match in the array or table named). It can be: a character or numeric
literal, a field name, an array element, a table name, a named constant, or a
figurative constant.
If a table is named in factor 1, the search argument used is the element of the
table last selected in a LOKUP operation, or it is the first element of the
table if a previous LOKUP has not been processed. The array or table to be
searched is specified in factor 2.
For a table LOKUP, the result field can contain the name of a second table from
which an element (corresponding positionally with that of the first table) can
be retrieved. The name of the second table can be used to reference the
element retrieved. The result field must be blank if factor 2 contains an
array name.
Decimal alignment is not processed for LOKUP operations.
Resulting indicators specify the search condition for LOKUP. One must be
specified in positions 54 through 59 first to determine the search to be done
and then to reflect the result of the search. Any specified indicator is set on
only if the search is successful. No more than two indicators can be used.
Resulting indicators can be assigned to equal and high or to equal and low. The
program searches for an entry that satisfies either condition with equal given
precedence; that is, if no equal entry is found, the nearest lower or nearest
higher entry is selected.
Resulting indicators can be assigned to equal and low, or equal and high. The
LOKUP operation searches for an entry that satisfies either condition with
equal given priority.
High (54-55): Instructs the program to find the entry that is nearest to, yet
higher in sequence than, the search argument. The first higher entry found
sets the indicator assigned to high on.
Low (56-57): Instructs the program to find the entry that is nearest to, yet
lower in sequence than, the search argument. The first such entry found sets
the indicator assigned to low on.
Equal (58-59): Instructs the program to find the entry equal to the search
argument. The first equal entry found sets the indicator assigned to equal on.
When you use the LOKUP operation, remember:
The search argument and array element or table element must have the same
length and the same format (character or numeric).
When LOKUP is processed on an array and an index is used, the LOKUP begins
with the element specified by the index. The index value is set to the
position number of the element located. An error occurs if the index is
equal to zero or is higher than the number of elements in the array when the
search begins. The index is set equal to one if the search is unsuccessful.
If the index is a named constant, the index value will not change.
A search can be made for high, low, high and equal, or low and equal only if
a sequence is specified for the array or table in the extension
specifications. For further information on the sequence entry, see Position
45 and 57 (Sequence).
No resulting indicator is set on if the search is not successful.
If only an equal indicator (positions 58-59) is used, the LOKUP operation
will search the entire array or table. If your array or table is in ascending
sequence and you want only an equal comparison, you can avoid searching the
entire array or table by specifying a high indicator.
The LOKUP operation can produce unexpected results when the array is not
strictly in ascending or descending sequence.
Figure "LOKUP Operation with Arrays" shows examples of the LOKUP operation with
arrays.
ΓòÉΓòÉΓòÉ 1.10.20.44.1. LOKUP Example ΓòÉΓòÉΓòÉ
LOKUP Operation with Arrays
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* In this example, the programmer wants to know which element in
C* ARY the LOKUP operation locates. The Z-ADD operation sets the
C* field X to 1. The LOKUP starts at the element ARY that is
C* indicated by field X and continues running until it finds the
C* first element equal to SRCHWD. The index value, X, is set to
C* the position number of the element located.
C Z-ADD1 X 30
C SRCHWD LOKUPARY,X 26 EQUAL
C*
C* In this example, the programmer wants to know if an element
C* is found that is equal to SRCHWD. LOKUP searches ARY until it
C* finds the first element equal to SRCHWD. When this occurs,
C* indicator 26 is set on.
C SRCHWD LOKUPARY 26 EQUAL
C*
C* The LOKUP starts at a variable index number specified by field
C* X. Field X does not have to set to 1 before the LOKUP
C* operation. When LOKUP locates the first element in ARY equal
C* to SRCHWD, indicator 26 is set on. The index value, X, is
C* set to the position number of the element located.
C*
C SRCHWD LOKUPARY,X 26 EQUAL
ΓòÉΓòÉΓòÉ 1.10.20.45. MHHZO (Move High to High Zone) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MHHZO Γöé Γöé Source field Γöé Target Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MHHZO operation moves the zone portion of a character from the leftmost
zone in factor 2 to the leftmost zone in the result field. Factor 2 and the
result field must both be defined as character fields. For further information
on the MHHZO operation, see Move Zone Operations.
The function of the MHHZO operation is shown in Figure "Function of MOVE Zone
Operations".
ΓòÉΓòÉΓòÉ 1.10.20.46. MHLZO (Move High to Low Zone) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MHLZO Γöé Γöé Source field Γöé Target Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MHLZO operation moves the zone portion of a character from the leftmost
zone in factor 2 to the rightmost zone in the result field. Factor 2 must be
defined as a character field. The result field can be character or numeric
data. For further information on the MHLZO operation, see Move Zone
Operations.
The function of the MHLZO operation is shown in Figure "Function of MOVE Zone
Operations".
ΓòÉΓòÉΓòÉ 1.10.20.47. MLHZO (Move Low to High Zone) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MLHZO Γöé Γöé Source field Γöé Target Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MLHZO operation moves the zone portion of a character from the rightmost
zone in factor 2 to the leftmost zone in the result field. Factor 2 can be
defined as a numeric field or as a character field, but the result field must
be a character field. For further information on the MLHZO operation, see Move
Zone Operations.
The function of the MLHZO operation is shown in Figure "Function of MOVE Zone
Operations".
ΓòÉΓòÉΓòÉ 1.10.20.48. MLLZO (Move Low to Low Zone) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MLLZO Γöé Γöé Source field Γöé Target Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MLLZO operation moves the zone portion of a character from the rightmost
zone in factor 2 to the rightmost zone in the result field. Factor 2 and the
result field can be either character data or numeric data. For further
information on the MLLZO, see Move Zone Operations.
The function of the MLLZO operation is shown in Figure "Function of MOVE Zone
Operations".
ΓòÉΓòÉΓòÉ 1.10.20.49. MOVE (Move) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MOVE Γöé Γöé Source field Γöé Target Γöé + - ZB Γöé
Γöé (P) Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MOVE operation transfers characters from factor 2 to the result field.
Moving starts with the rightmost character of factor 2.
If factor 2 is longer than the result field, the excess leftmost characters of
factor 2 are not moved. If the result field is longer than factor 2, the excess
leftmost characters in the result field are unchanged, unless padding is
specified.
You cannot specify resulting indicators if the result field is an array; you
can specify them if it is an array element, or a nonarray field.
If factor 2 is shorter than the length of the result field, a P specified in
the operation extender position (position 53) causes the result field to be
padded on the left after the move occurs.
For further information on the MOVE operation, see Move Operations. It is
summarized in Figure "MOVE Operation".
ΓòÉΓòÉΓòÉ 1.10.20.49.1. Move Example ΓòÉΓòÉΓòÉ
MOVE Operation
Factor 2 Shorter Than Result Field
Factor 2 Result Field
+
P H 4 S N Before MOVE 1 2 3 4 5 6 7 8 4
a. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to P H 4 S N After MOVE 1 2 3 4 P H 4 S N
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+
P H 4 S N Before MOVE 1 2 3 4 5 6 7 8 4
b. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric P H 4 S N After MOVE 1 2 3 4 7 8 4 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
1 2 7 8 4 2 5 Before MOVE 1 2 3 4 5 6 7 8 9
c. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to 1 2 7 8 4 2 5 After MOVE 1 2 1 2 7 8 4 2 5
Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
1 2 7 8 4 2 5 Before Move A C F G P H 4 S N
d. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to 1 2 7 8 4 2 5 After MOVE A C 1 2 7 8 4 2 5
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Factor 2 Longer Than Result Field
Factor 2 Result Field
A C E G P H 4 S N Before MOVE 5 6 7 8 4
a. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to A C E G P H 4 S N After MOVE P H 4 S N
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+
A C E G P H 4 S N Before MOVE 5 6 7 8 4
b. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric A C E G P H 4 S N After MOVE 7 8 4 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
1 2 7 8 4 2 5 Before MOVE 5 6 7 4 8
c. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to 1 2 7 8 4 2 5 After MOVE 7 8 4 2 5
Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
1 2 7 8 4 2 5 Before MOVE P H 4 S N
d. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to 1 2 7 8 4 2 5 After MOVE 7 8 4 2 5
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Factor 2 Shorter Than Result Field
With P in Operation Extender Field
Factor 2 Result Field
+
P H 4 S N Before MOVE 1 2 3 4 5 6 7 8 4
a. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to P H 4 S N After MOVE P H 4 S N
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+
P H 4 S N Before MOVE 1 2 3 4 5 6 7 8 4
b. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric P H 4 S N After MOVE 0 0 0 0 7 8 4 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
1 2 7 8 4 2 5 Before MOVE 1 2 3 4 5 6 7 8 9
c. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to 1 2 7 8 4 2 5 After MOVE 0 0 1 2 7 8 4 2 5
Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
1 2 7 8 4 2 5 Before Move A C F G P H 4 S N
d. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to 1 2 7 8 4 2 5 After MOVE 1 2 7 8 4 2 5
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Factor 2 and Result Field Same Length
Factor 2 Result Field
P H 4 S N Before MOVE 5 6 7 8 4
a. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to P H 4 S N After MOVE P H 4 S N
Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
P H 4 S N Before MOVE 5 6 7 8 4
b. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric P H 4 S N After MOVE 7 8 4 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓöÇ
7 8 4 2 5 Before MOVE A L T 5 F
c. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ ΓöÇ
Numeric 7 8 4 2 5 After MOVE 7 8 4 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓöÇ
7 8 4 2 5 Before MOVE A L T 5 F
d. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Character 7 8 4 2 5 After MOVE 7 8 4 2 N
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+ ΓöÇ
Note: 4 = letter D , and 5 = letter N.
ΓòÉΓòÉΓòÉ 1.10.20.50. MOVEA (Move Array) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MOVEA Γöé Γöé Source Γöé Target Γöé + - ZB Γöé
Γöé (P) Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MOVEA operation transfers character or numeric values from factor 2 to the
result field. (Certain restrictions apply when moving numeric values.) Factor 2
or the result field must contain an array. Factor 2 and the result field cannot
specify the same array even if the array is indexed.
You can use MOVEA with a packed, binary, zoned, or character array. You can:
Move several contiguous character array elements to a single character field
Move a single character field to several contiguous character array elements
Move contiguous array elements to contiguous elements of another array.
Movement of data starts with the first element of an array if the array is not
indexed or with the element specified if the array is indexed. The movement of
data ends when the last array element is moved or filled. When the result field
contains the indicator array, all indicators affected by the MOVEA operation
are noted in the cross-reference listing.
The coding for and results of MOVEA operations are shown in Figure "MOVEA
Operation". See Character MOVEA Operations and Numeric MOVEA Operations for
more information.
ΓòÉΓòÉΓòÉ 1.10.20.50.1. Character MOVEA Operations ΓòÉΓòÉΓòÉ
Both factor 2 and the result field must be defined as character.
On a character MOVEA operation, movement of data ends when the number of
characters moved equals the shorter length of the fields specified by factor 2
and the result field; therefore, the character MOVEA operation could end in the
middle of an array element.
ΓòÉΓòÉΓòÉ 1.10.20.50.2. Numeric MOVEA Operations ΓòÉΓòÉΓòÉ
Moves are only valid between fields and array elements with the same numeric
length defined. Factor 2 and the result field entries can specify numeric
fields, numeric array elements, or numeric arrays; at least one must be an
array or array element. The numeric types can be binary, packed decimal, or
zoned decimal but need not be the same between factor 2 and the result field.
Factor 2 can contain a numeric literal if the result field entry specifies a
numeric array or numeric array-element:
The numeric literal cannot contain a decimal point.
The length of the numeric literal cannot be greater than the element length
of the array or array element specified in the result field.
Decimal positions are ignored during the move and need not correspond. Numeric
values are not converted to account for the differences in the defined number
of decimal places.
The figurative constants *BLANK, *ALL, *ON and *OFF are not valid in factor 2
of a MOVEA operation on a numeric array.
ΓòÉΓòÉΓòÉ 1.10.20.50.3. General MOVEA Operations ΓòÉΓòÉΓòÉ
If you need to use a MOVEA operation in your application, but restrictions on
numeric MOVEA operations prevent you, you might be able to use character MOVEA
operations. If the numeric array is in zoned decimal format:
Define the numeric array as a subfield of a data structure
Redefine the numeric array in the data structure as a character array.
If a figurative constant is specified with MOVEA, the length of the constant
generated is equal to the portion of the array specified. For figurative
constants in numeric arrays, the element boundaries are ignored except for the
sign that is put in each array element. Examples are:
MOVEA *BLANK ARR,X
Beginning with element X, the remainder of ARR will contain blanks.
MOVEA *ALL'XYZ' ARR,X
ARR has 4-byte character elements. Element boundaries are ignored, as is
always the case with character MOVEA. Beginning with element X, the remainder
of the array will contain 'XYZXYZXYZXYZ. . .'.
Note that the results of MOVEA are different from those of the MOVE example
above.
For both character and numeric MOVEA operations, you can specify a P in
position 53 to pad the result from the right.
For further information on the MOVEA operation, see Move Operations.
MOVEA Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRX ARRY
C* Array-to-array move. No indexing; different length array,
C* same element length.
ARRX ARRY
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé Before ΓöéAΓöéAΓöéBΓöéBΓöéCΓöéCΓöéDΓöéDΓöéEΓöéEΓöéFΓöéFΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓö¼Γöÿ ΓööΓö¼Γöÿ
Γöé Γöé
One Element One Element
Γöé Γöé
ΓöîΓö┤ΓöÉ ΓöîΓö┤ΓöÉ
Γöé Γöé Γöé Γöé
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé After Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0ΓöéFΓöéFΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRX ARRY,3
C* Array-to-array move with index result field.
ARRX ARRY
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé Before ΓöéAΓöéAΓöéBΓöéBΓöéCΓöéCΓöéDΓöéDΓöéEΓöéEΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓö¼Γöÿ ΓööΓö¼Γöÿ
Γöé Γöé
One Element One Element
Γöé Γöé
ΓöîΓö┤ΓöÉ ΓöîΓö┤ΓöÉ
Γöé Γöé Γöé Γöé
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé After ΓöéAΓöéAΓöéBΓöéBΓöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRX ARRY
C* Array-to-array move, no indexing and different length array
C* elements.
ARRX ARRY
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé Before ΓöéAΓöéAΓöéAΓöéBΓöéBΓöéBΓöéCΓöéCΓöéCΓöéDΓöéDΓöéDΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓö¼Γöÿ ΓööΓöÇΓö¼ΓöÇΓöÿ
Γöé Γöé
One Element One Element
Γöé Γöé
ΓöîΓö┤ΓöÉ ΓöîΓöÇΓö┤ΓöÇΓöÉ
Γöé Γöé Γöé Γöé
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé After Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0ΓöéDΓöéDΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRX,4 ARRY
C* Array-to-array move, index factor 2 with different length array
C* elements.
ARRX ARRY
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé Before ΓöéAΓöéAΓöéAΓöéBΓöéBΓöéBΓöéCΓöéCΓöéCΓöéDΓöéDΓöéDΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓö¼Γöÿ ΓööΓöÇΓö¼ΓöÇΓöÿ
Γöé Γöé
One Element One Element
Γöé Γöé
ΓöîΓö┤ΓöÉ ΓöîΓöÇΓö┤ΓöÇΓöÉ
Γöé Γöé Γöé Γöé
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé After Γöé7Γöé8Γöé9Γöé0ΓöéBΓöéBΓöéCΓöéCΓöéCΓöéDΓöéDΓöéDΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAFIELDA ARRY
C* Field-to-array move, no indexing on array.
FIELDA ARRY
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé Before Γöé9Γöé8Γöé6Γöé5Γöé4Γöé3Γöé2Γöé1Γöé0ΓöéAΓöéBΓöéCΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé
ΓööΓöÇΓö¼ΓöÇΓöÿ
Γöé
One Element
Γöé
ΓöîΓöÇΓö┤ΓöÇΓöÉ
Γöé Γöé
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé After Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé1Γöé0ΓöéAΓöéBΓöéCΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* In the following example, N=3. Array-to-field move with variable
C* indexing.
C MOVEAARRX,N FIELD
C*
ARRX FIELD
Γöé0Γöé1Γöé0ΓöéAΓöé0Γöé2Γöé0ΓöéBΓöé0Γöé3Γöé0ΓöéCΓöé Before Γöé0Γöé1Γöé0ΓöéAΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé
ΓööΓö¼Γöÿ
Γöé
One Element
Γöé
ΓöîΓö┤ΓöÉ
Γöé Γöé
Γöé0Γöé1Γöé0ΓöéAΓöé0Γöé2Γöé0ΓöéBΓöé0Γöé3Γöé0ΓöéCΓöé After Γöé0Γöé2Γöé0ΓöéBΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRB ARRZ
C*
C* An array-to-array move showing numeric elements.
Γöé1.0 Γöé1.1 Γöé1.2 Γöé1.3Γöé Before MOVEA Γöé2.0 Γöé3.0 Γöé4.0 Γöé5.0 Γöé6.0Γöé
ΓööΓöÇΓö¼ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓö¼ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ
One Element One Element
Γöé Γöé
Γöé Γöé
Γöé1.0 Γöé1.1 Γöé1.2 Γöé1.3Γöé After MOVEA Γöé1.0 Γöé1.1 Γöé1.2 Γöé1.3 Γöé6.0Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRX ARRY P
C* Array-to-array move. No indexing; different length array with
C* same element length.
ARRX ARRY
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé Before ΓöéAΓöéAΓöéBΓöéBΓöéCΓöéCΓöéDΓöéDΓöéEΓöéEΓöéFΓöéFΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓö¼Γöÿ ΓööΓö¼Γöÿ
Γöé Γöé
One Element One Element
Γöé Γöé
ΓöîΓö┤ΓöÉ ΓöîΓö┤ΓöÉ
Γöé Γöé Γöé Γöé
Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé After Γöé1Γöé2Γöé3Γöé4Γöé5Γöé6Γöé7Γöé8Γöé9Γöé0Γöé Γöé Γöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRB ARRZ P
C*
C* An array-to-array move showing numeric elements with padding.
Γöé1.0 Γöé1.1 Γöé1.2 Γöé1.3Γöé Before MOVEA Γöé2.0 Γöé3.0 Γöé4.0 Γöé5.0 Γöé6.0Γöé
ΓööΓöÇΓö¼ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓö¼ΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ
One Element One Element
Γöé Γöé
Γöé Γöé
Γöé1.0 Γöé1.1 Γöé1.2 Γöé1.3Γöé After MOVEA Γöé1.0 Γöé1.1 Γöé1.2 Γöé1.3 Γöé0.0Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVEAARRX,3 ARRY P
C* Array-to-array move. No indexing; different length array with
C* same element length.
ARRX ARRY
ΓöéPΓöéPΓöéPΓöéQΓöéQΓöéQΓöéRΓöéRΓöéRΓöé Before ΓöéAΓöéAΓöéBΓöéBΓöéCΓöéCΓöéDΓöéDΓöéEΓöéEΓöéFΓöéFΓöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓö¼ΓöÇΓöÿ ΓööΓö¼Γöÿ
Γöé Γöé
One Element One Element
Γöé Γöé
ΓöîΓöÇΓö┤ΓöÇΓöÉ ΓöîΓö┤ΓöÉ
Γöé Γöé Γöé Γöé
ΓöéPΓöéPΓöéPΓöéQΓöéQΓöéQΓöéRΓöéRΓöéRΓöé After ΓöéRΓöéRΓöéRΓöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ MOVEA ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.10.20.51. MOVEL (Move Left) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MOVEL Γöé Γöé Source field Γöé Target Γöé + - ZB Γöé
Γöé (P) Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MOVEL operation transfers characters from factor 2 to the result field.
Moving begins with the leftmost character in factor 2. You cannot specify
resulting indicators if the result field is an array. You can specify them if
the result field is an array element, or a nonarray field.
When data is moved to a numeric field, the sign (+ or -) of the result field is
retained except when factor 2 is as long as or longer than the result field. In
this case, the sign of factor 2 is used as the sign of the result field.
If factor 2 is longer than the result field, the excess rightmost characters of
factor 2 are not moved. If the result field is longer than factor 2, the excess
rightmost characters in the result field are unchanged, unless padding is
specified.
The MOVEL operation is summarized in Figure "MOVEL Operation".
A summary of the rules for MOVEL operation for four conditions based on field
lengths:
1. Factor 2 is the same length as the result field:
a) If factor 2 and the result field are numeric, the sign is moved with the
rightmost position.
b) If factor 2 is numeric and the result field is character, the sign is
moved with the rightmost position.
c) If factor 2 is character and the result field is numeric, a minus zone
is moved into the rightmost position of the result field if the zone
from the rightmost position of factor 2 is a hexadecimal D (minus zone).
However, if the zone from the rightmost position of factor 2 is not a
hexadecimal D, a positive zone is moved into the rightmost position of
the result field. Digit portions are converted to their corresponding
numeric characters. If the digit portions are not valid digits, a data
exception error occurs.
d) If factor 2 and the result field are character, all characters are
moved.
2. Factor 2 is longer than the result field:
a) If factor 2 and the result field are numeric, the sign from the
rightmost position of factor 2 is moved into the rightmost position of
the result field.
b) If factor 2 is numeric and the result field is character, the result
field contains only numeric characters.
c) If factor 2 is character and the result field is numeric, a minus zone
is moved into the rightmost position of the result field if the zone
from the rightmost position of factor 2 is a hexadecimal D (minus zone).
However, if the zone from the rightmost position of factor 2 is not a
hexadecimal D, a positive zone is moved into the rightmost position of
the result field. Other result field positions contain only numeric
characters.
d) If factor 2 and the result field are character, only the number of
characters needed to fill the result field are moved.
3. Factor 2 is shorter than the result field:
a) If factor 2 is either numeric or character and the result field is
numeric, the digit portion of factor 2 replaces the contents of the
leftmost positions of the result field. The sign in the rightmost
position of the result field is not changed.
b) If factor 2 is either numeric or character and the result field is
character data, the characters in factor 2 replace the equivalent number
of leftmost positions in the result field. No change is made in the zone
of the rightmost position of the result field.
4. Factor 2 is shorter than the result field and P is specified in the
operation extender field:
a) The move is performed as described above.
b) The result field is padded from the right. See Move Operations for more
information on the rules for padding.
For further information on the MOVEL operation, see Move Operations.
ΓòÉΓòÉΓòÉ 1.10.20.51.1. MOVEL Example ΓòÉΓòÉΓòÉ
MOVEL Operation
Factor 2 and Result Field Same Length
Factor 2 Result Field
ΓöÇ +
7 84 2 5 Before MOVEL 5 6 78 4
a. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ ΓöÇ
Numeric 7 84 2 5 After MOVEL 7 8 42 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
7 84 2 5 Before MOVEL A K T 4 D
b. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Character 7 84 2 5 After MOVEL 7 8 4 2 N
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+
P H 4 S N Before MOVEL 5 6 7 8 4
c. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric P H 4 S N After MOVEL 7 8 4 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
P H 4 S N Before MOVEL A K T 4 D
d. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to
Character P H 4 S N After MOVEL P H 4 S N
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Factor 2 Longer Than Result Field
Factor 2 Result Field
ΓöÇ +
0 0 0 2 5 8 4 2 5 Before MOVEL 56 7 8 4
a. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric 0 0 0 2 5 8 4 2 5 After MOVEL 00 0 2 5
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓöÇ
9 0 3 1 7 8 4 2 5 Before MOVEL A K T 4 D
b. Numeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Character 9 0 3 1 7 8 4 2 5 After MOVEL 9 0 3 1 7
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+
B R W C X H 4 S N Before MOVEL 5 6 7 84
c. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to ΓöÇ
Numeric B R W C X H 4 S N After MOVEL 2 9 6 37
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
B R W C X H 4 S N Before MOVEL A K T 4 D
d. Character ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
to
Character B R W C X H 4 S N After MOVEL B R W C X
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Factor 2 Shorter Than Result Field
Factor 2 Result Field
ΓöÇ +
ΓöîΓöÇ 7 8 4 2 5 Before MOVEL 13 0 9 4 3 2 1 0
ΓöéNumeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé to ΓöÇ +
ΓöéNumeric 7 8 4 2 5 After MOVEL 78 4 2 5 3 2 1 0
a.ΓöéΓöñ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé +
Γöé C P T 5 N Before MOVEL 1 3 0 9 4 3 2 1 0
ΓöéCharacter ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓööΓöÇ to +
Numeric C P T 5 N After MOVEL 3 7 3 5 5 3 2 1 0
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓöÇ
ΓöîΓöÇ 7 8 4 2 5 Before MOVEL B R W C X H 4 S A
ΓöéNumeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé to ΓöÇ
ΓöéCharacter 7 8 4 2 5 After MOVEL 7 8 4 2 N H 4 S A
b.ΓöéΓöñ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé
Γöé C P T 5 N Before MOVEL B R W C X H 4 S A
ΓöéCharacter ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓööΓöÇ to
Character C P T 5 N After MOVEL C P T 5 N H 4 S A
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+ ΓöÇ
Note: 4 = letter D, and 5 = letter N; arrow is decimal point.
Factor 2 Shorter Than Result Field
With P in Operation Extender Field
Factor 2 Result Field
ΓöÇ +
ΓöîΓöÇ 7 8 4 2 5 Before MOVEL 13 0 9 4 3 2 1 0
ΓöéNumeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé to ΓöÇ +
ΓöéNumeric 7 8 4 2 5 After MOVEL 78 4 2 5 0 0 0 0
a.ΓöéΓöñ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé +
Γöé C P T 5 N Before MOVEL 1 3 0 9 4 3 2 1 0
ΓöéCharacter ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓööΓöÇ to +
Numeric C P T 5 N After MOVEL 3 7 3 5 5 0 0 0 0
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓöÇ
ΓöîΓöÇ 7 8 4 2 5 Before MOVEL B R W C X H 4 S A
ΓöéNumeric ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé to ΓöÇ
ΓöéCharacter 7 8 4 2 5 After MOVEL 7 8 4 2 N
b.ΓöéΓöñ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
Γöé
Γöé C P T 5 N Before MOVEL B R W C X H 4 S A
ΓöéCharacter ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
ΓööΓöÇ to
Character C P T 5 N After MOVEL C P T 5 N
ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ ΓööΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓö┤ΓöÇΓöÿ
+ ΓöÇ
Note: 4 = letter D, and 5 = letter N; arrow is decimal point.
ΓòÉΓòÉΓòÉ 1.10.20.52. MULT (Multiply) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MULT Γöé Multiplicand Γöé Multiplier Γöé Product Γöé + - Z Γöé
Γöé (1/2) Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
If factor 1 is specified, factor 1 is multiplied by factor 2 and the product is
placed in the result field. Be sure that the result field is large enough to
hold it. Use the following rule to determine the maximum result field length:
result field length equals the length of factor 1 plus the length of factor 2.
If factor 1 is not specified, factor 2 is multiplied by the result field and
the product is placed in the result field. Factor 1 and factor 2 must be
numeric, and each can contain one of: an array, array element, field,
figurative constant, literal, named constant, subfield, or table name. The
result field must be numeric, but cannot be a named constant. You can specify
half adjust (position 53).
For further information on the MULT operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for examples of the MULT
operation.
ΓòÉΓòÉΓòÉ 1.10.20.53. MVR (Move Remainder) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé MVR Γöé Γöé Γöé RemainderΓöé + - Z Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The MVR operation moves the remainder from the previous DIV operation to a
separate field named in the result field. Factor 1 and factor 2 must be blank.
The MVR operation must immediately follow the DIV operation. If you use
conditioning indicators, ensure that the MVR operation is processed immediately
after the DIV operation. If the MVR operation is processed before the DIV
operation, undesirable results occur. The result field must be numeric and can
contain one of: an array, array element, subfield, or table name.
Leave sufficient room in the result field if the DIV operation uses factors
with decimal positions. The number of significant decimal positions is the
greater of:
The number of decimal positions in factor 1 of the previous divide operation
The sum of the decimal positions in factor 2 and the result field of the
previous divide operation.
The sign (+ or -) of the remainder is the same as the dividend (factor 1).
You cannot specify half adjust (position 53) on a DIV operation that is
immediately followed by an MVR operation.
The maximum number of whole number positions in the remainder is equal to the
whole number of positions in factor 2 of the previous divide operation.
The MVR operation cannot be used if the previous divide operation has an array
specified in the result field.
For further information on the MVR operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for an example of the MVR
operation.
ΓòÉΓòÉΓòÉ 1.10.20.54. NEXT (Next) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé NEXT Γöé Program Γöé File name Γöé Γöé _ ER _ Γöé
Γöé Γöé device Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The NEXT operation code forces the next input for a multiple device file to
come from the program device specified in factor 1, providing the input
operation is a cycle read or a READ-by-file-name. Any read operation, including
CHAIN, EXFMT, READ, and READC, ends the effect of the previous NEXT operation.
If NEXT is specified more than once between input operations, only the last
operation is processed. The NEXT operation code can be used only for a
multiple device file.
In factor 1, enter the name of a 10-character field that contains the program
device name or a character literal or named constant that is the program device
name. In factor 2, enter the name of the multiple device WORKSTN file for
which the operation is requested.
You can specify an indicator in positions 56 and 57. It is set on if an
exception/error occurs on the NEXT operation. If the INFSR subroutine is
specified and positions 56 and 57 do not contain an indicator, the subroutine
automatically receives control when an exception/error occurs. If the INFSR
subroutine is not specified and positions 56 and 57 do not contain an
indicator, the default error handler takes control.
ΓòÉΓòÉΓòÉ 1.10.20.55. OCUR (Set/Get Occurrence of a Data Structure) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé OCUR Γöé Occurrence Γöé Data structure Γöé Occur- Γöé _ ER _ Γöé
Γöé Γöé value Γöé Γöé rence Γöé Γöé
Γöé Γöé Γöé Γöé value Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The OCUR operation code specifies the occurrence of the data structure that is
to be used next within an RPG/400 program. If a data structure with multiple
occurrences or a subfield of that data structure is specified in an operation,
the first occurrence of the data structure is used until an OCUR operation is
specified. After an OCUR operation is specified, the occurrence of the data
structure that was established by the OCUR operation is used.
Factor 1 is optional; if specified, it can contain a numeric, zero decimal
position literal, field name, named constant, or a data structure name. Factor
1 is used during the OCUR operation to set the occurrence of the data structure
specified in factor 2. If factor 1 is blank, the value of the current
occurrence of the data structure in factor 2 is placed in the result field
during the OCUR operation.
If factor 1 is a data structure name, it must be a multiple occurrence data
structure. The current occurrence of the data structure in factor 1 is used to
set the occurrence of the data structure in factor 2.
Factor 2 is required and must be the name of a multiple occurrence data
structure.
The result field is optional; if specified, it must be a numeric field name
with no decimal positions. During the OCUR operation, the value of the current
occurrence of the data structure specified in factor 2, after being set by any
value or data structure that is optionally specified in factor 1, is placed in
the result field.
You can specify a resulting indicator in positions 56 and 57 to be set on if
the occurrence specified is outside the valid range set for the data structure.
If the occurrence is outside the valid range, the occurrence of the data
structure in factor 2 remains the same as before the OCUR operation was
processed.
The OCUR operation establishes which occurrence of a multiple occurrence data
structure is used next in a program. Only one occurrence can be used at a
time.
Figure "Uses of the OCUR Operation" illustrates uses of the OCUR operation.
ΓòÉΓòÉΓòÉ 1.10.20.55.1. OCUR Examples ΓòÉΓòÉΓòÉ
Uses of the OCUR Operation
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ 50th ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé FLDA Γöé FLDB ΓöéΓöéΓöÇΓöÇΓöÇΓöÇOccurrenceΓöÇΓöÇΓöÇΓöÇΓöé FLDC Γöé FLDD Γöé
Γöé Γöé Γöé Γöé Γöé Γöé
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ 49th ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ
Γöé FLDA Γöé FLDB ΓöéΓöéΓöÇΓöÇΓöÇΓöÇOccurrenceΓöÇΓöÇΓöÇΓöÇΓöé FLDC Γöé FLDD Γöé
Γöé Γöé Γöé Γöé Γöé Γöé
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ 3rd ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé FLDA Γöé FLDB ΓöéΓöéΓöÇΓöÇΓöÇΓöÇOccurrenceΓöÇΓöÇΓöÇΓöÇΓöé FLDC Γöé FLDD Γöé
Γöé Γöé Γöé Γöé Γöé Γöé
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ 2nd ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ
Γöé FLDA Γöé FLDB ΓöéΓöéΓöÇΓöÇΓöÇΓöÇOccurrenceΓöÇΓöÇΓöÇΓöÇΓöé FLDC Γöé FLDD Γöé
Γöé Γöé Γöé Γöé Γöé Γöé
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ 1st ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöÇΓöÿ
Γöé FLDA Γöé FLDB ΓöéΓöéΓöÇΓöÇΓöÇΓöÇOccurrenceΓöÇΓöÇΓöÇΓöÇΓöé FLDC Γöé FLDD Γöé
Γöé Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
DS1 DS2
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I....................................PFromTo++DField+L1M1FrPlMnZr...
I*
I* DS1 and DS2 are multiple occurrence data structures.
I* Each data structure has 50 occurrences.
IDS1 DS 50
I 1 5 FLDA
I 6 80FLDB
I*
IDS2 DS 50
I 1 6 FLDC
I 7 11 FLDD
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C* DS1 is set to the third occurrence. The subfields FLDA
C* and FLDB of the third occurrence can now be used. The MOVE
C* and Z-ADD operations change the contents of FLDA and FLDB,
C* respectively, in the third occurrence of DS1.
C 3 OCUR DS1
C MOVE 'ABCDE' FLDA
C Z-ADD22 FLDB
C*
C* DS1 is set to the fourth occurrence. Using the values in
C* FLDA and FLDB of the fourth occurrence of DS1, the MOVE
C* operation places the contents of FLDA in the result field,
C* FLDX, and the Z-ADD operation places the contents of FLDB
C* in the result field, FLDY.
C 4 OCUR DS1
C MOVE FLDA FLDX
C Z-ADDFLDB FLDY
C*
C* DS1 is set to the occurrence specified in field X.
C* For example, if X = 10, DS1 is set to the tenth occurrence.
C X OCUR DS1
C*
C* DS1 is set to the current occurrence of DS2. For example, if
C* the current occurrence of DS2 is the twelfth occurrence, DSI
C* is set to the twelfth occurrence.
C DS2 OCUR DS1
C*
C* The value of the current occurrence of DS1 is placed in the
C* result field, Z. Field Z must be numeric with zero decimal
C* positions. For example, if the current occurrence of DS1
C* is 15, field Z contains the value 15.
C OCUR DS1 Z
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* DS1 is set to the current occurrence of DS2. The value of the
C* current occurrence of DS1 is then moved to the result field,
C* Z. For example, if the current occurrence of DS2 is the fifth
C* occurrence, DS1 is set to the fifth occurrence. The result
C* field, Z, contains the value 5.
C DS2 OCUR DS1 Z
C*
C* DS1 is set to the current occurrence of X. For example, if
C* X = 15, DS1 is set to the fifteenth occurrence. If X equals
C* 0 or is greater than 50, an error occurs and indicator 20 is
C* set on. If indicator 20 is on, the LR indicator is set on.
C X OCUR DS1 20
C*
C *IN20 IFEQ *ON
C SETON LR
C END
ΓòÉΓòÉΓòÉ 1.10.20.56. OPEN (Open File for Processing) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé OPEN Γöé Γöé File name Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The explicit OPEN operation opens the file named in factor 2. The factor 2
entry cannot be designated as a primary, secondary, or table file. You can
specify a resulting indicator in positions 56 and 57 to be set on if the OPEN
operation is not successful. If no indicator is specified, but the INFSR
subroutine is specified, the INFSR automatically receives control when an
error/exception occurs. If no indicator or INFSR subroutine is specified, the
default error/exception handler receives control when an error/exception
occurs.
To open the file specified in factor 2 for the first time in a program with an
explicit OPEN operation, specify UC (user control) in positions 71 and 72 of
the file description specifications. (See File Description Specifications for
restrictions when using the UC entry.)
If a file is opened and later closed by the CLOSE operation in the program, the
programmer can reopen the file with the OPEN operation and the UC entry is not
required in positions 71 and 72. When UC is not specified, the file is opened
at program initialization. If an OPEN operation is specified for a file that
is already open, an error occurs.
Multiple OPEN operations in a program to the same file are valid as long as the
file is closed when the OPEN operation is issued to it.
When you open a file with the ID option specified (on the file description
specifications continuation line), the ID field is set to blanks. See the
description of the ID option, in File Description Specifications.
Figure "OPEN Operation with CLOSE Operation" shows the OPEN operation used with
the CLOSE operation.
ΓòÉΓòÉΓòÉ 1.10.20.56.1. OPEN Example ΓòÉΓòÉΓòÉ
OPEN Operation with CLOSE Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U..
FEXCPTN O E DISK UC
FFILEX I E DISK
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The explicit OPEN operation opens the EXCPTN file for
C* processing if indicator 97 is on and indicator 98 is off.
C* Note that the EXCPTN file on the file description
C* specifications has UC specified in positions 71 and 72.
C*
C 97N98 OPEN EXCPTN 99 99=NO SUCCESS
C 97N98N99 WRITEERREC
C*
C* FILEX is opened at program initialization. The explicit
C* CLOSE operation closes FILEX before control is passed to RTNX.
C* RTNX or another program can open and use FILEX. Upon return,
C* the OPEN operation reopens the file. Because FILEX is opened
C* at program initialization, UC is not specified in positions 71
C* and 72 of the file description specifications.
C*
C CLOSEFILEX
C CALL 'RTNX'
C OPEN FILEX
ΓòÉΓòÉΓòÉ 1.10.20.57. ORxx (Or) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ORXX Γöé Comparand Γöé Comparand Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ORxx operation is optional with the DOUxx, DOWxx, IFxx, WHxx, and ANDxx
operations. ORxx is specified immediately following a DOUxx, DOWxx, IFxx, WHxx,
ANDxx or ORxx statement. Use ORxx to specify a more complex condition for the
DOUxx, DOWxx, IFxx, and WHxx operations.
The control level entry (positions 7 and 8) can be blank or can contain an L1
through L9 indicator, an LR indicator, or an L0 entry to group the statement
within the appropriate section of the program. The control level entry must be
the same as the entry for the associated DOUxx, DOWxx, IFxx, or WHxx operation.
Conditioning indicator entries (positions 9 through 17) are not allowed.
Factor 1 and factor 2 must contain a literal, a named constant, a figurative
constant, a table name, an array element, a data structure name, or a field
name. Factor 1 and factor 2 must be either both character data or both numeric
data. The comparison of factor 1 and factor 2 follows the same rules as those
given for the compare operations. See Compare Operations.
Figure "DOUxx Operations" shows an example of ORxx and ANDxx operations with a
DOUxx operation.
ΓòÉΓòÉΓòÉ 1.10.20.58. OTHER (Otherwise Select) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé OTHER Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The OTHER operation begins the sequence of operations to be processed if no
WHxx condition is satisfied in a SELEC group. The sequence ends with the ENDSL
or END operation.
Rules to remember when using the OTHER operation:
The OTHER operation is optional in a SELEC group.
Only one OTHER operation can be specified in a SELEC group.
No WHxx operation can be specified after an OTHER operation in the same SELEC
group.
The sequence of calculation operations in the OTHER group can be empty; the
effect is the same as not specifying an OTHER statement.
Within total calculations, the control level entry (positions 7 and 8) can be
blank or can contain an L1 through L9 indicator, an LR indicator, or an L0
entry to group the statement within the appropriate section of the program.
The control level entry is for documentation purposes only. Conditioning
indicator entries (positions 9 through 17) are not allowed.
Figure "OTHER Operation" shows an example of the OTHER operation.
ΓòÉΓòÉΓòÉ 1.10.20.58.1. OTHER Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* Example of a SELEC group with WHxx and OTHER. If X equals 1,
C* do the operations in sequence 1; if X does not equal 1 and Y
C* equals 2, do the operations in sequence 2. If neither
C* condition is true, do the operations in sequence 3.
C*
C SELEC
C X WHEQ 1
C : seq 1
C Y WHEQ 2
C : seq 2
C OTHER
C : seq 3
C ENDSL
OTHER Operation
ΓòÉΓòÉΓòÉ 1.10.20.59. OUT (Write a Data Area) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé OUT Γöé *LOCK Γöé Data area name Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The OUT operation updates the data area specified in factor 2. To specify a
data area in factor 2 of an OUT operation, you must ensure two things:
The data area must also be specified in the result field of a *NAMVAR DEFN
statement.
The data area must have been locked previously by a *LOCK IN statement or it
must have been specified as a data area data structure by a U in position 18
of the input specifications. (The RPG/400 language implicitly retrieves and
locks data area data structures at program initialization.)
Factor 1 can contain the reserved word *LOCK or can be blank. When factor 1
contains *LOCK, the data area remains locked after it is updated. When factor 1
is blank, the data area is unlocked after it is updated.
Factor 1 must be blank when factor 2 contains the name of the local data area
or the Program Initialization Parameters (PIP) data area.
Factor 2 must be the name of the data area to be updated or must be the
reserved word *NAMVAR. When *NAMVAR is specified, all data areas defined in the
program are updated. If an error occurs when one or more data areas are updated
(for example, if you specify an OUT operation to a data area that has not been
locked by the program), an error occurs on the OUT operation and the RPG/400
exception/error handling routine receives control. If you specify a program
exception/error subroutine (*PSSR), the program status data structure contains
information on the data area in error. If a message is issued to the requester,
the message identifies the data area in error.
You can specify a resulting indicator in positions 56 and 57 to be set on if an
error occurs during the operation. Positions 54-55 and 58-59 must be blank.
For further rules for the OUT operation, see Data-Area Operations.
See Figure "IN and OUT Operations" for an example of the OUT operation.
ΓòÉΓòÉΓòÉ 1.10.20.60. PARM (Identify Parameters) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé PARM Γöé Target field Γöé Source field Γöé Param- Γöé Γöé
Γöé Γöé Γöé Γöé eter Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The declarative PARM operation defines the parameters that compose a parameter
list (PLIST). PARM operations can appear anywhere in calculations as long as
they immediately follow the PLIST or CALL operation they refer to. PARM
statements must be in the order expected by the called program. One PARM
statement, or as many as 255 PARM statements, can follow a PLIST or CALL.
The PARM operation can be specified anywhere within calculations, including
total calculations. The control level entry (positions 7 and 8) can be blank
or can contain an L1 through L9 indicator, an LR indicator, or an L0 entry to
group the statement in the appropriate section of the program. Conditioning
indicator entries (positions 9 through 17) are not allowed.
Factor 1 and factor 2 entries are optional. If specified, the entries must be
the same type (character or numeric) as specified in the result field. A
literal or named constant cannot be specified in factor 1. Factor 1 and factor
2 must be blank if the result field contains the name of a multiple-occurrence
data structure.
The result field must contain the name of a field, data structure, or array
that is to be the parameter. Also, the result field of a non-*ENTRY PLIST can
contain an array element. The result field can be numeric or character. The
result field cannot contain *IN, *INxx, *IN,xx, a label, a literal, a data-area
name, a data-area data structure name, a globally initialized data structure, a
data structure with initialized subfields, a data structure with a compile time
array as a subfield, or a table name. In addition, an array element, a
data-structure subfield name, the name of a compile-time array and the name of
a program status or file information data structure (INFDS) are not allowed in
the result field of PARM specified for an *ENTRY PLIST. A field name can be
specified only once in an *ENTRY PLIST.
If an array is specified in the result field, the area defined for the array is
passed to the called program. When a data structure with multiple occurrences
is passed to the called program, all occurrences of the data structure are
passed as a single field. However, if a subfield of a multiple occurrence data
structure is specified in the result field, only the current occurrence of the
subfield is passed to the called program.
Each parameter field has only one storage location; it is in the calling
program. The address of the storage location of the result field is passed to
the called program on a PARM operation. If the called program changes the value
of a parameter, it changes the data at that storage location. When control
returns to the calling program, the value of the parameter in the calling
program (that is, the result field) has changed. Even if the called program
ends in error after it changes the value of a parameter, the changed value
exists in the calling program. To preserve the information passed to the called
program for later use, specify in factor 2 the name of the field that contains
the information you want to pass to the called program. Factor 2 is copied into
the result field, and the storage address of the result field is passed to the
called program.
Because the program accesses the parameter fields by address, not field name,
the calling and called parameters do not have to use the same field names for
fields that are passed. The attributes of the corresponding parameter fields
in the calling and called programs should be the same. If they are not,
undesirable results may occur.
When a CALL operation runs, the following occurs:
1. In the calling program, the contents of the factor 2 field of a PARM
operation are copied into the result field (receiver field) of the same
PARM operation.
2. In the called program, after it receives control and after any normal
program initialization, the contents of the result field of a PARM
operation are copied into the factor 1 field (receiver field) of the same
PARM operation.
3. In the called program, when control is returned to the calling program, the
contents of the factor 2 field of a PARM operation are copied into the
result field (receiver field) of the same PARM operation. This move does
not occur if the called program ends abnormally.
4. Upon return to the calling program, the contents of the result field of a
PARM operation in the calling program are copied into the factor 1 field
(receiver field) of the same PARM operation. This move does not occur if
the called program ends abnormally or if an error occurs on the CALL
operation.
Note: If the receiver field is numeric, the value of the field to be placed
in the receiver field is added to a field of zeros and the sum is placed in the
receiver field. If the receiver field is character, the field to be placed in
the receiver field is moved (left-adjusted) into the receiver field, and the
receiver field is padded with blanks. For a discussion of how to call and pass
parameters to a program through CL, see the Programming: Control Language
Programmer's Guide.
Figure "PLIST/PARM Operations" illustrates the PARM operation.
ΓòÉΓòÉΓòÉ 1.10.20.61. PLIST (Identify a Parameter List) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé PLIST Γöé PLIST name Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The declarative PLIST operation defines a unique symbolic name for a parameter
list to be specified in a CALL operation.
You can specify a PLIST operation anywhere within calculations, including
within total calculations and between subroutines. The control level entry
(positions 7 and 8) can be blank or can contain an L1 through L9 indicator, an
LR indicator, or an L0 entry to group the statement in the appropriate section
of the program. The PLIST operation must be immediately followed by at least
one PARM operation. Conditioning indicator entries (positions 9 through 17) are
not allowed.
Factor 1 must contain the name of the parameter list. If the parameter list is
the entry parameter list of a called program, factor 1 must contain *ENTRY.
Only one *ENTRY parameter list can occur in a program. A parameter list is
ended when an operation other than PARM is encountered.
Figure "PLIST/PARM Operations" illustrates the PLIST operation.
ΓòÉΓòÉΓòÉ 1.10.20.61.1. PLIST Example ΓòÉΓòÉΓòÉ
PLIST/PARM Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* In the calling program, the CALL operation calls PROG2 and
C* allows PROG2 to access the data in the parameter list fields.
C CALL 'PROG2' PLIST1
C*
C* In the second PARM statement, when CALL is processed, the
C* contents of factor 2, *IN27, are placed in the result field,
C* BYTE. When PROG2 returns control, the contents of the result
C* field, BYTE, are placed in the factor 1 field, *IN30. Note
C* that factor 1 and factor 2 entries on a PARM are optional.
C*
C PLIST1 PLIST
C PARM AMT 52
C *IN30 PARM *IN27 BYTE 1
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C CALL 'PROG2'
C* In this example, the PARM operations immediately follow a
C* CALL operation instead of a PLIST operation.
C PARM AMT 52
C *IN30 PARM *IN27 BYTE 1
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C* In the called program, PROG2, *ENTRY in factor 1 of the
C* PLIST statement identifies it as the entry parameter list.
C* When control transfers to PROG2, the contents of the result
C* fields (FLDC and FLDG) of the parameter list are placed in
C* the factor 1 fields (FLDA and FLDD). When the called program
C* returns, the contents of the factor 2 fields of the parameter
C* list (FLDB and FLDE) are placed in the result fields (FLDC
C* and FLDG). All of the fields are defined elsewhere in the
C* program.
C *ENTRY PLIST
C FLDA PARM FLDB FLDC
C FLDD PARM FLDE FLDG
ΓòÉΓòÉΓòÉ 1.10.20.62. POST (Post) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé POST Γöé Program Γöé File name Γöé INFDS Γöé _ ER _ Γöé
Γöé Γöé device Γöé Γöé name Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The POST operation puts information in an INFDS (file information data
structure). The information is either on the status of a specific program
device or I/O feedback associated with a file.
In factor 1, you can specify a program device name to get information about
that specific program device. Use either a character field of length 10 or
less, a character literal, or a character named constant. If you leave factor 1
blank, you get I/O feedback information.
In factor 2, specify the name of a file. Information for this file is posted
in the INFDS associated with this file. If you specify a program device in
factor 1, the file must be defined as a WORKSTN file.
If you specify a file in factor 2, you can leave the result field blank. The
INFDS associated with this file will be used. You can specify a file in factor
2 and its associated INFDS in the result field. If you leave factor 2 blank,
you must specify an INFDS in the result field; information from the file
associated with this INFDS will be posted.
In positions 56 and 57, you can specify an indicator that is set on if there is
an error. If no indicator is specified, control passes to your INFSR
subroutine (if you have specified one) or the default error/exception handler
when an error/exception occurs.
Even when a POST operation code is not processed, its existence in your program
can affect the way the RPG/400 language operates. Usually, the INFDS is updated
at each input and output operation or block of operations. However, if anywhere
in your program, you have specified a POST operation with factor 1 blank, then
RPG/400 updates the I/O Feedback Information area and the Device Dependent
Feedback Information area in the INFDS of any file only when you process a POST
operation for that file (except for the area *STATUS which is always updated).
To ensure that the DUMP operation code provides up-to-date information in this
case, issue a POST operation before the DUMP operation.
If a program has no POST operation code, or if it has only POST operation codes
with factor 1 specified, the INFDS is updated with each input/output operation
or block of operations. If RPG is blocking records, the information in the
INFDS will be valid for the last block of records processed. If you require
more accurate information, do not use record blocking. If you do not require
feedback information after every input/output operation, you may be able to
improve performance by using the POST operation only when you require the
feedback information.
When a POST operation is processed, the associated file must be open. If you
specify a program device on the POST operation, it does not have to be acquired
by the file.
ΓòÉΓòÉΓòÉ 1.10.20.63. READ (Read a Record) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé READ Γöé Γöé File name, Γöé Data Γöé _ ER Γöé
Γöé (N) Γöé Γöé Record name Γöé struc- Γöé EOF Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The READ operation reads the record, currently pointed to, from a full
procedural file (identified by an F in position 16 of the file description
specifications).
Factor 2 must contain the name of a file. A record format name in factor 2 is
allowed only with an externally described file (E in position 19 of the file
description specifications). It may be the case that a READ-by-format-name
operation will receive a different format than the one you specified in factor
2. If so, your READ operation ends in error.
The result field can contain the name of a data structure into which the record
is read only if the file named in factor 2 is a program described file
(identified by an F in position 19 of the file description specifications).
See File Operations for information on how data is transferred between the file
and the data structure.
If a READ operation is successful, the file is positioned at the next record
that satisfies the read. If either indicator is set on, you must reposition the
file (by a CHAIN (Random Retrieval from a File), SETLL (Set Lower Limit), or
SETGT (Set Greater Than) operation).
If the file from which you are reading is an update disk file, you can specify
an N in position 53 to indicate that no lock should be placed on the record
when it is read. See the RPG/400* User's Guide for more information.
You can specify an indicator in positions 56 and 57 to be set on if the READ
operation is not completed successfully. If an error occurs when no indicator
is specified, control passes to your INFSR subroutine (if specified) or the
default error/exception handler.
You must specify an indicator in positions 58 and 59 to signal whether end of
file occurred on the READ operation. The file must be repositioned after the
indicator is set on to process any further successful sequential operation (for
example, READ or READP) to the file. This indicator is set on or off every
time the READ operation is performed.
Figure "READ Operation" illustrates the READ operation.
When you specify a multiple device file in factor 2, the READ operation does
one of:
Reads data from the device specified in the most recent NEXT operation (if
such a NEXT operation has been processed).
Accepts the first response from any device that has been acquired for the
file, and that was specified for "invite status" with the DDS keyword INVITE.
If there are no invited devices, the operation receives an end of file. The
input is processed according to the corresponding format. If the device is a
workstation, the last format written to it is used. If the device is a
communications device, you can select the format.
Refer to the ICF Programmer's Guide for more information on format selection
processing for an ICF file.
The READ operation will stop waiting after a period of time in which no input
is provided, or when one of the following CL commands has been entered with
the controlled option specified:
- ENDJOB (End Job)
- ENDSBS (End Subsystem)
- PWRDWNSYS (Power Down System)
- ENDSYS (End System).
The error indicator specified in positions 56 and 57 is set on. See the
Communications: Intersystem Communications Function Programmer's Guide for a
discussion of the WAITRCD parameter on the commands to create or modify a
file. This parameter controls the length of time the READ operation waits for
input.
When you specify a format name in factor 2, and the format name is associated
with a multiple device file, data is read from the device identified by the
field specified in the ID entry on the file continuation specifications. If
there is no such entry, data is read from the device used in the last
successful input operation.
ΓòÉΓòÉΓòÉ 1.10.20.63.1. READ Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* READ retrieves the next record from the file FILEA, which must
C* be a full procedural file. Indicator 61 is set on if end of
C* file occurs on READ, or if end of file has occurred previously
C* and the file has not been repositioned. When indicator 61
C* is set on, the program branches to the label (EOF) specified
C* in the GOTO statement.
C READ FILEA 61 END OF FILE
C 61 GOTO EOF
C*
C* READ retrieves the next record of the type REC1 (factor 2)
C* from an externally described file. (REC1 is a record format
C* name.) Indicator 64 is set on if end of file occurs on READ, or
C* or if it has occurred previously and the file has not been
C* repositioned. When indicator 64 is set on, the program
C* branches to the label (EOF) specified in the GOTO statement.
C* N in position 53 indicates that the record is not locked.
C*
C READ REC1 N 64 END OF FILE
C 64 GOTO EOF
C*
C EOF TAG
READ Operation
ΓòÉΓòÉΓòÉ 1.10.20.64. READC (Read Next Changed Record) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé READC Γöé Γöé Record name Γöé Γöé _ ER Γöé
Γöé Γöé Γöé Γöé Γöé EOF Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The READC operation can be used only with an externally described WORKSTN file
to obtain the next changed record in a subfile. Factor 2 is required and must
be the name of a record format defined as a subfile by the SFILE keyword on the
file description specifications. (See Continuation Line Summary Chart for
information on the SFILE keyword.)
For a multiple device file, data is read from the subfile record associated
with a program device; the program device is identified by the field specified
in the ID entry (on the file specifications continuation line). If there is no
such entry, data is read from the program device used for the last successful
input operation.
You can specify a resulting indicator in positions 56 and 57 to be set on if an
error occurs while the operation is running. A resulting indicator in
positions 58 and 59 is required; it is set on when there are no more changed
records in the subfile.
ΓòÉΓòÉΓòÉ 1.10.20.65. READE (Read Equal Key) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé READE Γöé Search argu- Γöé File name, Γöé Data Γöé _ ER Γöé
Γöé (N) Γöé ment Γöé Record name Γöé struc- Γöé EOF Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The READE operation retrieves the next sequential record from a full procedural
file (identified by an F in position 16 of the file description specifications)
if the key of the record matches the search argument. If the key of the record
does not match the search argument, the indicator that must be specified in
positions 58 and 59 is set on, and the record is not returned to the program.
Factor 1, the search argument, is optional and identifies the record to be
retrieved. It can be a field name, a literal, a named constant, or a figurative
constant. You can also specify a KLIST name in factor 1 for an externally
described file. If factor 1 is left blank and the full key of the next record
is equal to that of the current record, the next record in the file is
retrieved. The full key is defined by the record format or file used in factor
2.
Note: If factor 1 equals the key of the current record or if factor 1 is not
specified, the key comparison takes place at the Data Management level;
otherwise, it takes place within the RPG/400 program. If the file being read is
defined as update and the compare is by RPG, a temporary lock on the next
record is requested and the search argument is compared to the key of that
record. If the record is already locked, the program must wait until the record
is available before obtaining the temporary lock and making the comparison. If
the comparison is unequal, the record-not-found indicator is turned on, and the
temporary record lock is removed. If no lock (N in position 53) is specified, a
temporary lock is not requested.
Factor 2 must contain the name of the file or record format to be retrieved. A
record format name in factor 2 is allowed only with an externally described
file (identified by an E in position 19 of the file description
specifications).
The result field can contain the name of a data structure into which the record
is read only if the file named in factor 2 is a program described file
(identified by an F in position 19 of the file description specifications). See
File Operations for a description of the way data is transferred between the
file and data structure.
If the file you are reading is an update disk file, you can specify an N in
position 53 to indicate that no lock should be placed on the record when it is
read. See the RPG/400* User's Guide for more information.
You can specify a resulting indicator in positions 56 and 57 to be set on if
the operation does is completed successfully. You must specify a resulting
indicator in positions 58 and 59. The indicator is set on if a record is not
found with a key equal to the search argument or if end of file occurs. If a
READE operation is not successful, you must reposition the file (for example,
by a CHAIN (Random Retrieval from a File), SETGT (Set Greater Than), or SETLL
(Set Lower Limit) operation).
If factor 1 is specified and one or more key fields in the file being read from
are defined with ALTSEQ, ABSVAL, DIGIT, or ZONE, the result of the read
operation may differ from that expected. The reason is the content of the field
on which the access path is built may not be the same as the content that the
READE operation is using for its internal comparison.
A READE (with factor 1 specified) that immediately follows an OPEN operation or
an EOF condition retrieves the first record in the file if the key of the
record matches the search argument. A READE (with no factor 1 specified) that
immediately follows an OPEN operation or an EOF condition results in an error
condition. The error indicator, if specified, in positions 56 and 57 is set on.
No further I/O operations can be issued against the file until it is
successfully closed and reopened.
Note: If the key used contains a numeric (packed or zoned) field, the search
argument must exactly match the key field. For example, if the physical file
uses a packed key of X'123C' for +123. and the search argument is 123, READE
will use X'123F' and EOF will be returned.
Figure "READE Operation" shows READE operations with a file name and record
format name specified in factor 2.
ΓòÉΓòÉΓòÉ 1.10.20.65.1. READE Examples ΓòÉΓòÉΓòÉ
READE Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* With Factor 1 Specified...
C*
C* The READE operation retrieves the next record from the file
C* FILEA and compares its key to the search argument, KEYFLD.
C* Indicator 55 is set on if KEYFLD is not equal to the key of
C* the record read or if end of file is encountered.
C*
C KEYFLD READEFILEA 55 NOT EQUAL
C*
C* The READE operation retrieves the next record of the type REC1
C* from an externally described file and compares the key of the
C* record read to the search argument, KEYFLD. (REC1 is a record
C* format name.) Indicator 56 is set on if KEYFLD is not equal to
C* the key of the record read or if end of file is encountered.
C KEYFLD READEREC1 56 NOT EQUAL
C*
C* With No Factor 1 Specified...
C*
C* The READE operation retrieves the next record in the access
C* path from the file FILEA if the key value is equal to
C* the key value of the record at the current cursor position.
C* If the key values are not equal, indicator 55 is set on.
C READEFILEA 55 NOT EQUAL
C*
C* The READE operation retrieves the next record in the access
C* path from the file FILEA if the key value equals the key value
C* of the record at the current position. REC1 is a record format
C* name. Indicator 56 is set on if the key values are unequal.
C* N in position 53 indicates that the record is not locked.
C READEREC1 N 56 NOT EQUAL
ΓòÉΓòÉΓòÉ 1.10.20.66. READP (Read Prior Record) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé READP Γöé Γöé File name, Γöé Data Γöé _ ER Γöé
Γöé (N) Γöé Γöé Record name Γöé struc- Γöé BOF Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The READP operation reads the prior record from a full procedural file
(identified by an F in position 16 of the file description specifications).
Factor 2 must contain the name of a file or record format to be read. A record
format name in factor 2 is allowed only with an externally described file. If
a record format name is specified in factor 2, the record retrieved is the
first prior record of the specified type. Intervening records are bypassed.
The result field can contain the name of a data structure into which the record
is read only if the file named in factor 2 is a program described file
(identified by an F in position 19 of the file description specifications). See
File Operations for how data is transferred between the file and data
structure.
If a READP operation is successful, the file is positioned at the next record
that satisfies the read. If a READP operation is not successful, you must
reposition the file (for example, by a CHAIN (Random Retrieval from a File) or
SETLL (Set Lower Limit) operation). You can specify an indicator in positions
56 and 57 to be set on if the READP operation is not completed successfully.
If the file from which you are reading is an update disk file, you can specify
an N in position 53 to indicate that no lock should be placed on the record
when it is read. See the RPG/400* User's Guide for more information.
You must specify an indicator in positions 58 and 59 to be set on when no prior
records exist in the file (beginning of file condition). If the file is not
repositioned after this indicator is set on, the indicator is set for every
subsequent READP operation to the file.
You must be reposition the file after the indicator is set on to process any
further successful sequential operation (for example, READ (Read a Record)) to
the file.
Figure "READP Operation" shows READP operations with a file name and record
format name specified in factor 2.
ΓòÉΓòÉΓòÉ 1.10.20.66.1. READP Examples ΓòÉΓòÉΓòÉ
READP Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The READP operation reads the prior record from FILEA.
C* Indicator 71 is set on if beginning of file is encountered.
C* When indicator 71 is set on, the program branches to the
C* label BOF specified in the GOTO operation.
C READPFILEA 71 BOF
C 71 GOTO BOF BEG OF FILE
C*
C* The READP operation reads the next prior record of the type
C* REC1 from an externally described file. (REC1 is a record
C* format name.) Indicator 72 is set on if beginning of file is
C* encountered during processing of the READP operation. When
C* indicator 72 is set on, the program branches to the label BOF
C* specified in the GOTO operation.
C READPREC1 7272 = BOF
C 72 GOTO BOF
C*
C BOF TAG
ΓòÉΓòÉΓòÉ 1.10.20.67. REDPE (Read Prior Equal) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé REDPE Γöé Search argu- Γöé File name, Γöé Data Γöé _ ER Γöé
Γöé (N) Γöé ment Γöé Record name Γöé struc- Γöé BOF Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The REDPE operation retrieves the next prior sequential record from a full
procedural file if the key of the record matches the search argument. If the
key of the record does not match the search argument, the indicator in
positions 58-59 is set on and the record is not returned to the program.
Factor 1, the search argument, is optional and identifies the record to be
retrieved. It can be a field name, a literal, a named constant, or a figurative
constant. You can also specify a KLIST name in factor 1 for an externally
defined file. If factor 1 is left blank and the full key of the next prior
record is equal to that of the current record, the next prior record in the
file is retrieved. The full key is defined by the record format or file used in
factor 2.
Factor 2 must contain the name of the file or record format to be retrieved. A
record format name in factor 2 is allowed only with an externally described
file (identified by an E in position 19 of the file description
specifications). The Result Field can contain the name of a data structure into
which the record is read only if the file named in factor 2 is a program
described file (identified by an F in position 19 of the file description
specifications). See File Operations for a description of the way data is
transferred between the file and data structure.
If the file from which you are reading is an update disk file, you can specify
an N in position 53 to indicate that no lock should be placed on the record
when it is read. See the RPG/400* User's Guide for more information.
You can specify a resulting indicator in positions 56 and 57 to be set on if
the operation is not completed successfully. You must specify a resulting
indicator positions 58 and 59. The indicator is set on if a record is not found
with a key equal to the search argument, or if beginning of file is
encountered. If a REDPE operation is not successful, you must reposition the
file (for example, by a CHAIN (Random Retrieval from a File) or SETLL (Set
Lower Limit) operation).
Note: If factor 1 equals the key of the current record or if factor 1 is not
specified, the key comparison takes place at the Data Management level;
otherwise, it takes place within the RPG/400 program. If the file being read is
defined as update and the compare is by RPG, a temporary lock on the prior
record is requested and the search argument is compared to the key of that
record. If the record is already locked, the program must wait until the record
is available before obtaining the temporary lock and making the comparison. If
the comparison is unequal, the record-not-found indicator is turned on, and the
temporary record lock is removed. If no lock (N in position 53) is specified, a
temporary lock is not requested.
If factor 1 is specified and one or more key fields in the file being read from
are defined with ALTSEQ, ABSVAL, DIGIT, or ZONE, the result of the read
operation may differ from that expected. The reason is that the content of the
field on which the access path is built may not be the same as the content that
the REDPE operation is using for its internal comparison.
A REDPE (with factor 1 specified) that immediately follows an OPEN operation or
a BOF condition returns BOF. A REDPE (with no factor 1 specified) that
immediately follows an OPEN operation or a BOF condition results in an error
condition. The error indicator, if specified, in positions 56 and 57 is set on.
The file must be positioned (using CHAIN (Random Retrieval from a File), SETLL
(Set Lower Limit), READ (Read a Record), READP (Read Prior Record), or READE
(Read Equal Key) (with factor 1 specified) ) prior to issuing a REDPE operation
with factor 1 blank. A SETGT operation code should not be used to position the
file prior to issuing a REDPE as this results in a record-not-found condition
(because the record previous to the current record never has the same key as
the current record after a SETGT is issued).
If the key used contains a numeric (packed or zoned) field, the search argument
must exactly match the key field. For example, if the physical file uses a
packed key of X'123C' for +123. and the search argument is 123, REDPE will use
X'123F' and BOF will be returned.
Figure "REDPE Operation" shows an example of the REDPE operation.
ΓòÉΓòÉΓòÉ 1.10.20.67.1. REDPE Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* With Factor 1 Specified...
C*
C* The previous record is read and the key compared to FIELDA.
C* Indicator 99 is set on if the record's key does not match
C* FIELDA.
C FIELDA REDPEFILEA 99
C*
C* The previous record is read from FILEB and the key compared
C* to FIELDB. The record is placed in data structure DS1. If
C* the record key does not match FIELDB, indicator 99 is set on.
C FIELDB REDPEFILEB DS1 99
C*
C* The previous record from record format RECA is read, and
C* the key compared to FIELDC. Indicator 88 is set on if the
C* operation is not completed successfully, and 99 is set on if
C* the record key does not match FIELDC.
C FIELDC REDPERECA 8899
C*
C* With No Factor 1 Specified...
C*
C* The previous record in the access path is retrieved if its
C* key value equals the key value of the current record.
C* Indicator 99 is set on if the key values are not equal.
C REDPEFILEA 99
C*
C* The previous record is retrieved from FILEB if its key value
C* matches the key value of the record at the current position
C* in the file. The record is placed in data structure DS1.
C* Indicator 99 is set on if the key values are not equal.
C REDPEFILEB DS1 99
C*
C* The previous record from record format RECA is retrieved if
C* its key value matches the key value of the current record in
C* the access path. Indicator 88 is set on if the operation is
C* not successful; 99 is set on if the key values are unequal.
C REDPERECA 8899
REDPE Operation
ΓòÉΓòÉΓòÉ 1.10.20.68. REL (Release) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé REL Γöé Program Γöé File name Γöé Γöé _ ER _ Γöé
Γöé Γöé device Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The REL operation releases the program device specified in factor 1 from the
multiple device WORKSTN file specified in factor 2.
In factor 1, specify the program device name. Use either a character field of
length 10 or less, a character literal, or a named constant. In factor 2,
specify the file name.
You can specify an indicator in positions 56 and 57 that is set on when an
error occurs. If you do not specify one and an error occurs, control passes to
your INFSR subroutine (if specified) or the default error/exception handler.
When there are no program devices acquired to a WORKSTN file, the next
READ-by-file-name or cycle-read gets an end-of-file condition. You must decide
what the program does next.
To release a record lock, use the UNLCK operation. See the UNLCK operation for
more information about unlocking data areas and releasing record locks for
update disk files.
The REL operation is valid only for multiple device WORKSTN files.
ΓòÉΓòÉΓòÉ 1.10.20.69. RESET (Reset) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé RESET Γöé *NOKEY Γöé Structure or Γöé Γöé Γöé
Γöé Γöé Γöé Variable Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The RESET operation sets elements in a structure (record format, data
structure, array, or table), or a variable (field, subfield, or indicator) to
its initial value. The initial value for a variable is the value the variable
had at the end of the *INIT operation of the program. This value can be set
using data structure initialization, or you can use the initialization
subroutine to assign an initial value to the structure or variable. When RESET
is specified for a structure or variable, a snapshot of the initial value of
that variable or structure is taken at the end of the *INIT operation after
*INZSR (initialization subroutine) is processed. This value is then used to
reset the structure or variable.
Factor 1 must be blank unless factor 2 contains a record format name. In this
case, factor 1 can contain *NOKEY, which indicates that all fields except key
fields are to be reset to their initial values.
Factor 2 contains the structure or variable to be reset to its initial value.
It can contain one of: a record format, data structure name, array name, table
name, field name, subfield, array element, or indicator name. If a record
format name or a single occurrence data structure is specified, all fields are
reset (in the order they are declared within the structure). In the case of a
multiple-occurrence data structure, all fields in the current occurrence are
reset. If a table name is specified, the current table element is reset; in
the case of an array name, the entire array is reset. If an array element
(including indicators) is specified in factor 2 using an array index, only the
element specified is reset.
When the RESET operation is applied to a record format name, only those fields
that are output in that record format are affected. For WORKSTN (positions
40-46) file record formats, only those fields with a usage of output or both
are affected. All field-conditioning indicators are affected by the operation.
Fields in DISK, SEQ, or PRINTER file record formats are affected only if the
record format is output in the program. Input-only fields are not affected by
the RESET operation. By definition, they assume new values at the next input
operation.
The RESET operation is used in conjunction with data structure initialization
and the initialization subroutine (*INZSR). You can use both data structure
initialization and the *INZSR to set the initial value of a field or structure.
The value is then used to reset the field or structure if it appears in factor
2 of a RESET operation. For example, you can use the *INZSR to set the values
of several fields in a record format, and then later in the program use the
RESET operation against the record format to reset the values of the fields.
The snapshot of the field value for the RESET operation is taken at the end of
the initialization step in the program, after the *INZSR is run. Any changes
made to the values of variables in the *INZSR override any data structure
initialization, and the value the variable has at the end of the initialization
step is used to save the reset snapshot.
This operation results in an increase in the amount of storage required by the
program because the initial values of all structures and variables that are
reset must be saved. However, the amount of storage declared is reduced where
possible. For example, if a data structure is reset and a subfield within that
data structure is also reset, the save area for the subfield is based on the
same storage as the data structure save area. Note that, if a single
occurrence of a multiple-occurrence data structure is reset, a save area for
the entire data structure (all occurrences) is declared. A save area is created
for a structure or variable only if it appears in factor 2 of a RESET
operation. If no RESET operations are coded in the program, then no additional
storage is required. If a RESET occurs during the initialization routine of the
program, an error message will be issued at run time. If a GOTO or CABxx is
used to leave subroutine calculations during processing of the *INZSR, or if
control passes to another part of the cycle as the result of error processing,
the part of the initialization step which initializes the save areas will never
be reached. In this case, an error message will be issued for all RESET
operations in the program at run time.
Figure "RESET Operation" shows an example of the RESET operation.
ΓòÉΓòÉΓòÉ 1.10.20.69.1. RESET Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U..
FEXTFILE O E DISK
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme.............
I*
I* The file EXTFILE contains one record format RECFMT containing
I* the character fields CHAR1 and CHAR2 and the numeric fields
I* NUM1 and NUM2.
IDS1 IDS
I I 'MONDAY' 1 8 DAY1
I I 'THURSDAY' 9 16 DAY2
I 17 22 JDATE
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following operation blank DAY1, DAY2, and JDATE.
C CLEARDS1
C* The following operation will set DAY1, DAY2, and JDATE to their
C* initial values of 'MONDAY', 'THURSDAY', and UDATE respectively.
C* The initial value of UDATE for JDATE is set in the *INZSR.
C RESETDS1
C* The following operation will set CHAR1 and CHAR2 to blanks and
C* NUM1 and NUM2 to zero.
C CLEARRECFMT
C* The following operation will set CHAR1, CHAR2, NUM1, and
C* NUM2 to their initial values of 'NAME', 'ADDRESS', 1, and 2
C* respectively. These initial values are set in the *INZSR.
C*
C RESETRECFMT
C*
C *INZSR BEGSR
C MOVELUDATE JDATE
C MOVEL'NAME 'CHAR1
C MOVEL'ADDRESS 'CHAR2
C Z-ADD1 NUM1
C Z-ADD2 NUM2
C ENDSR
RESET Operation
ΓòÉΓòÉΓòÉ 1.10.20.70. RETRN (Return to Caller) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé RETRN Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The RETRN operation causes a return to the caller as follows:
1. The halt indicators are checked. If a halt indicator is on, the program
ends abnormally. (All open files are closed, an error return code is set to
indicate to the calling routine that the program has ended abnormally, and
control returns to the calling routine.)
2. If no halt indicators are on, the LR indicator is checked. If LR is on, the
program ends normally. (Locked data area structures, arrays, and tables are
written, and external indicators are reset.)
3. If no halt indicator is on and LR is not on, the program returns to the
calling routine. Data is preserved for the next time the program is run.
Files and data areas are not written out.
ΓòÉΓòÉΓòÉ 1.10.20.71. ROLBK (Roll Back) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé ROLBK Γöé Γöé Γöé Γöé _ ER _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The ROLBK operation:
Eliminates all the changes to your files that have been specified in output
operations since the previous COMIT or ROLBK operation (or since the
beginning of operations under commitment control if there has been no
previous COMIT or ROLBK operation).
Releases all the record locks for the files you have under commitment
control.
Repositions the file to its position at the time of the previous COMIT
operation (or at the time of the file OPEN, if there has been no previous
COMIT operation.)
The file changes and the record-lock releases apply to all the files under
commitment control in your routing step, whether the changes have been
requested by the program issuing the ROLBK operation or by another program in
the same routing step. The program issuing the ROLBK operation does not need to
have any files under commitment control. For example, suppose program A calls
program B and program C. Program B has files under commitment control, and
program C does not. A ROLBK operation in program C still affects the files
changed by program B.
The optional indicator in positions 56 and 57 is set on if the operation is not
successfully completed.
ΓòÉΓòÉΓòÉ 1.10.20.72. SCAN (Scan Character String) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SCAN Γöé Comparator Γöé Base Γöé Left- Γöé _ ER FD Γöé
Γöé Γöé string:length Γöé string:start Γöé most Γöé Γöé
Γöé Γöé Γöé Γöé position Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SCAN operation scans a character string (base string) contained in factor 2
for a substring (compare string) contained in factor 1. The scan begins at a
specified location contained in factor 2 and continues for the length of the
compare string which is specified in factor 1.
Factor 1 must contain either the compare string or the compare string, followed
by a colon, followed by the length. The compare string portion of factor 1 must
be character, and can contain one of: a field name, array element, named
constant, data structure name, literal, or table name. The length portion must
be numeric with no decimal positions and can contain one of: a named constant,
array element, field name, literal, or table name. If no length is specified,
it is that of the compare string.
Factor 2 must contain either the base string or the base string, followed by a
colon, followed by the start location of the SCAN. The base string portion of
factor 2 must be character, and can contain one of: a field name, array
element, named constant, data structure name, literal, or table name. The
start location portion of factor 2 must be numeric with no decimal positions
and can be a named constant, array element, field name, literal, or table name.
If no start location is specified, a value of 1 is used.
The result field contains the numeric value of the leftmost position of the
compare string in the base string, if found. It must be numeric with no
decimal positions and can contain one of: a field name, array element, array
name, or table name. If no result field is specified, a resulting indicator in
positions 58 and 59 must be specified. The result field is set to 0 if the
string is not found. If the result field contains an array, each occurrence of
the compare string is placed in the array with the leftmost occurrence in
element 1. The array elements following the element containing the rightmost
occurrence are all zero. The result array should be as large as the character
field length of the base string specified in factor 2.
Note: The strings are indexed from position 1. If the start position is
greater than 1, the result field contains the position of the compare string
relative to the beginning of the source string, not relative to the start
position. Figurative constants cannot be used in the factor 1, factor 2, or
result fields. No overlapping within data structures is allowed for factor 1
and the result field or factor 2 and the result field.
A resulting indicator in positions 58 and 59 can be specified to be set on if
the string being scanned for is found. A resulting indicator in positions 56
and 57 can be specified to be set on if there is an error during the SCAN
operation. An error occurs if the start position is greater than the length of
factor 2 or if the value of factor 1 is too large. If no error indicator is
specified and an error condition occurs, *PSSR, the error/exception handling
subroutine runs (if it is specified in the program). If it is not specified, an
error message is issued.
The SCAN begins at the leftmost character of factor 2 (as specified by the
start location) and continues character by character, from left to right,
comparing the characters in factor 2 to those in factor 1. If the result field
is not an array, the SCAN operation will locate only the first occurrence of
the compare string. To continue scanning beyond the first occurrence, use the
result field from the previous SCAN operation to calculate the starting
position of the next SCAN. If the result field is a numeric array, as many
occurrences as there are elements in the array are noted. If no occurrences
are found, the result field is set to zero; if the result field is an array,
all its elements are set to zero.
Leading, trailing, or embedded blanks specified in the compare string are
included in the SCAN operation.
The SCAN operation is case-sensitive. A compare string specified in lowercase
will not be found in a base string specified in uppercase.
Figure "SCAN Operation" shows examples of the SCAN operation.
ΓòÉΓòÉΓòÉ 1.10.20.72.1. SCAN Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The SCAN operation finds the substring 'ABC' starting in
C* position 3 in factor 2; 3 is placed in the result field.
C* Indicator 90 is set on because the string is found. Because
C* no starting position is specified, the default of 1 is used.
C 'ABC' SCAN 'XCABCD' RESULT 90
C*
C* This SCAN operation scans the string in factor 2 for an
C* occurrence of the string in factor 1 starting at position 3.
C* The operation places the values 5 and 6 in the first and
C* second elements of the array. Indicator 90 is set on.
C MOVE 'ARRAYY' FIELD1 6
C MOVE 'Y' FIELD2 1
C FIELD2 SCAN FIELD1:3 ARRAY 90
C*
C* This SCAN operation scans the string in factor 2, starting
C* at position 2, for an occurrence of the string in factor 1
C* for a length of 4. Because 'TOOL' is not found in FIELD1,
C* INT is set to zero and indicator 90 is set off.
C MOVE 'TESTING' FIELD1 7
C Z-ADD2 X 10
C MOVEL'TOOL' FIELD2 5
C FIELD2:4 SCAN FIELD1:X INT 20 90
C*
SCAN Operation
ΓòÉΓòÉΓòÉ 1.10.20.73. SELEC (Begin a Select Group) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SELEC Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The select group conditionally processes one of several alternative sequences
of operations. It consists of:
A SELEC statement
Zero or more WHxx groups
An optional OTHER group
ENDSL or END statement.
After the SELEC operation, control passes to the statement following the first
WHxx condition that is satisfied. All statements are then executed until the
next WHxx operation. Control passes to the ENDSL statement (only one WHxx is
executed). If no WHxx condition is satisfied and an OTHER operation is
specified, control passes to the statement following the OTHER operation. If no
WHxx condition is satisfied and no OTHER operation is specified, control
transfers to the statement following the ENDSL operation of the select group.
Conditioning indicators can be used on the SELEC operation. If they are not
satisfied, control passes immediately to the statement following the ENDSL
operation of the select group.
The select group can be specified anywhere in calculations. It can be nested
within IF, DO, or other select groups. The IF and DO groups can be nested
within select groups.
If a SELEC operation is specified inside a select group, the WHxx and OTHER
operations apply to the new select group until an ENDSL is specified.
Figure "SELEC Operation" shows an example of the SELEC operation.
ΓòÉΓòÉΓòÉ 1.10.20.73.1. SELEC Example ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* In the following example, if X equals 1, do the operations in
C* sequence 1 (note that no END operation is needed before the
C* next WHxx); if X does NOT equal 1, and if Y=2 and X<10, do the
C* operations in sequence 2. If neither condition is true, do
C* the operations in sequence 3.
C*
C SELEC
C X WHEQ 1
C Z-ADDA B
C MOVE C D
C : seq 1
C Y WHEQ 2
C X ANDLT10
C : seq 2
C OTHER
C : seq 3
C ENDSL
C*
C* The following example shows a select group with conditioning
C* indicators. After the CHAIN operation, if indicator 10 is on,
C* then control passes to the ADD operation. If indicator 10 is
C* off, then the select group is processed.
C*
C KEY CHAINFILE 10
C N10 SELEC
C X WHEQ 1
C : seq 1
C Y WHEQ 2
C : seq 2
C ENDSL
C ADD 1 N
SELEC Operation
ΓòÉΓòÉΓòÉ 1.10.20.74. SETGT (Set Greater Than) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SETGT Γöé Search argu- Γöé File name Γöé Γöé NR ER _ Γöé
Γöé Γöé ment Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SETGT operation positions a file at the next record with a key or relative
record number that is greater than the key or relative record number specified
in factor 1. The file must be a full procedural file (identified by an F in
position 16 of the file description specifications).
Factor 1 is required. If the file is accessed by key, factor 1 can be a field
name, a named constant, a figurative constant, or a literal that is used as the
search argument in positioning a file. You can also specify a KLIST (Define a
Composite Key) name in factor 1 for an externally described file that is
positioned by key. If the file is accessed by relative record number, factor 1
must be an integer literal, named constant, or field.
Factor 2 is required and must be either a file name or, in the OS/400 system, a
record format name. A record format name in factor 2 is allowed only with an
externally described file.
You can specify a resulting indicator in positions 54 and 55 to be set on if no
record is found with a key or relative record number that is greater than the
search argument specified in factor 1. You can specify any valid resulting
indicator in positions 56 and 57 to be set on if an error occurs during
processing of the operation.
If the SETGT operation is not successful (no-record-found condition), the file
is positioned to the end of the file.
Figurative constants can also be used to position the file. When used with a
file with a composite key, figurative constants are treated as though each
field of the key contained the figurative constant value. In most cases, *LOVAL
positions the file so that the first read retrieves the record with the lowest
key. In most cases, *HIVAL positions the file so that a READ receives an
end-of-file indication; a subsequent READP retrieves the last record in the
file. However, note the following cases for using *LOVAL and *HIVAL with
numeric keys:
With an externally described file that has a key in descending order, *HIVAL
positions the file so that the first read operation retrieves the first
record in the file (the record with the highest key), and *LOVAL positions
the file so that a READP operation retrieves the last record in the file (the
record with the lowest key).
If a record is added or a key field is altered after a SETGT operation with
either *LOVAL or *HIVAL, the file may no longer be positioned to the record
with the lowest or highest key.
*LOVAL represents a key value X'99...9D' and *HIVAL represents a key value
X'99...9F'. When a program described file has a packed decimal key specified
in the file specifications but the actual file key field contains character
data, records may have keys that are less than *LOVAL or greater than *HIVAL.
When a key field contains unsigned binary data, *LOVAL may not be the lowest
key.
Following the SETGT operation, a file is positioned so that it is immediately
before the first record whose key or relative record number is greater than the
search argument specified in factor 1. You retrieve this record by reading the
file. Before you read the file, however, records may be deleted from the file
by another job or through another file in your job. Thus, you may not get the
record you expected. For information on preventing unexpected modification of
your files, see the discussion of allocating objects in the Programming:
Control Language Reference.
Figure "SETGT Operation" illustrates the SETGT operation.
ΓòÉΓòÉΓòÉ 1.10.20.74.1. SETGT Example ΓòÉΓòÉΓòÉ
SETGT Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C* This example shows how to position the file so READ will read
C* the next record. The search argument, KEY, specified for the
C* SETGT operation has a value of 98; therefore, SETGT positions
C* the file before the first record of file format FILEA that
C* has a key field value greater than 98. The file is positioned
C* before the first record with a key value of 100. The READ
C* operation reads the record that has a value of 100 in its key
C* field.
C KEY SETGTFILEA GREATER THAN
C READ FILEA 64READ NEXT
C*
C*
C* This example shows how to read the last record of a group of
C* records with the same key value and format from a program
C* described file. The search argument, KEY, specified for the
C* SETGT operation positions the file before the first record of
C* file FILEB that has a key field value greater than 70.
C* The file is positioned before the first record with a key
C* value of 80. The READP operation reads the last record that
C* has a value of 70 in its key field.
C KEY SETGTFILEB GREATER THAN
C READPFILEB 64READ LAST
Key Field Key Field
Values Values
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé 97 Γöé Γöé 50 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 97 Γöé Γöé 60 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 97 Γöé Γöé 70 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 97 Γöé (READP)ΓöÇΓöÇΓöé 70 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñFILEA (SETGT)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñFILEB
Γöé 98 Γöé Γöé 80 Γöé
(SETGT)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
(READ)ΓöÇΓöÇΓöÇΓöé 100 Γöé Γöé 80 Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 100 Γöé Γöé 80 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 100 Γöé Γöé 90 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 101 Γöé Γöé 90 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 101 Γöé Γöé 91 Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* This example shows the use of *LOVAL. The SETGT operation
C* positions the file before the first record of a file in
C* ascending order. The READ operation reads the first record
C* (key value 97).
C *LOVAL SETGTRECDA GREATER THAN
C READ RECDA 64READ NEXT
C*
C*
C* This example shows the use of *HIVAL. The SETGT operation
C* positions the file after the last record of a file in ascending
C* order. The READP operation reads the last record (key value 91).
C *HIVAL SETGTRECDB GREATER THAN
C READPRECDB 64READ LAST
Key Field Key Field
Values Values
(SETGT)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
(READ)ΓöÇΓöÇΓöÇΓöÇ 97 Γöé Γöé 50 Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 97 Γöé Γöé 60 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 97 Γöé Γöé 70 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 97 Γöé Γöé 70 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñRECDA Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñRECDB
Γöé 98 Γöé Record Γöé 80 Γöé Record
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Format Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Format
Γöé 100 Γöé Γöé 80 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 100 Γöé Γöé 80 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 100 Γöé Γöé 90 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 101 Γöé Γöé 90 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé 101 Γöé (READP)ΓöÇΓöÇΓöÇΓöÇ 91 Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ (SETGT)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.10.20.75. SETLL (Set Lower Limit) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SETLL Γöé Search argu- Γöé File name Γöé Γöé NR ER Γöé
Γöé Γöé ment Γöé Γöé Γöé EQ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SETLL operation positions a file at the next record that has a key or
relative record number that is greater than or equal to the search argument
(key or relative record number) specified in factor 1. The file must be a full
procedural file (identified by an F in position 16 of the file description
specifications).
Factor 1 is required. If the file is accessed by key, factor 1 can be a field
name, a named constant, a figurative constant, or a literal that is used as the
search argument in positioning the file. You can also specify a KLIST name in
factor 1 for an externally described file that is positioned by key. If the
file is accessed by relative record number, factor 1 must contain an integer
literal, named constant, or numeric field with no decimal positions.
Factor 2 is required and can contain either a file name or a record format
name. A record format name in factor 2 is allowed only with an externally
described file.
The resulting indicators reflect the status of the operation. If an indicator
is specified in positions 54 and 55, it is set on when the search argument is
greater than the highest key or relative record number in the file. If an
indicator is specified in positions 56 and 57, it is set on when an error
occurs during running of the operation. If an indicator is specified in
positions 58 and 59, it is set on when a record is present whose key or
relative record number is equal to the search argument.
If factor 2 contains a file name for which the lower limit is to be set, the
file is positioned at the first record with a key or relative record number
equal to or greater than the search argument specified in factor 1.
If factor 2 contains a record format name for which the lower limit is to be
set, the file is positioned at the first record of the specified type that has
a key equal to or greater than the search argument specified in factor 1.
Figurative constants can be used to position the file. When used with a file
with a composite key, figurative constants are treated as though each field of
the key contained the figurative constant value. In most cases, *LOVAL
positions the file so that the first read retrieves the record with the lowest
key. In most cases, *HIVAL positions the file so that a READP retrieves the
last record in the file, or a READ receives an end-of-file indication.
However, note the following cases for using *LOVAL and *HIVAL with numeric
keys:
With an externally described file that has a key in descending order, *HIVAL
positions the file so that the first read operation retrieves the first
record in the file (the record with the highest key), and *LOVAL positions
the file so that a READP operation retrieves the last record in the file (the
record with the lowest key).
If a record is added or a key field altered after a SETLL operation with
either *LOVAL or *HIVAL, the file may no longer be positioned to the record
with the lowest or highest key.
*LOVAL represents a key value X'99...9D' and *HIVAL represents a key value
X'99...9F'. When a program described file has a packed decimal key specified
in the file specifications but the actual file key field contains character
data, records may have keys that are less than *LOVAL or greater than *HIVAL.
When a key field contains unsigned binary data, *LOVAL may not be the lowest
key.
Figure "SETGT Operation" shows the use of figurative constants with the SETGT
operation. Figurative constants are used the same way with the SETLL
operation.
Remember the following when using the SETLL operation:
If the SETLL operation is not successful (no records found condition), the
file is positioned to the end of the file.
When end of file is reached on a file being processed by SETLL, another SETLL
can be issued to reposition the file.
After a SETLL operation successfully positions the file at a record, you
retrieve this record by reading the file. Before you read the file, however,
records may be deleted from the file by another job or through another file
in your job. Thus, you may not get the record you expected. Even if the
resulting indicator in positions 58 and 59 is set on to indicate you found a
matching record, you may not get that record.
SETLL does not cause the system to access a data record. If you are only
interested in verifying that a key actually exists, SETLL with an equal
indicator (positions 58-59) is a better performing solution than the CHAIN
operation in most cases. Under special cases of a multiple format logical
file with sparse keys, CHAIN can be a faster solution than SETLL.
Figure "SETLL Operation" illustrates the SETLL operation.
ΓòÉΓòÉΓòÉ 1.10.20.75.1. SETLL Example ΓòÉΓòÉΓòÉ
In this example, the file ORDFIL contains order records. The key field is the
order number (ORDER) field. There are multiple records for each order. ORDFIL
looks like this in the calculation specifications:
SETLL Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* All the 101 records in ORDFIL are to be printed. The value 101
C* has previously been placed in ORDER. The SETLL operation
C* positions the file at the first 101 record. Because there are
C* 101 records, indicator 55 is set on and the GOTO operation is
C* not processed.
C ORDER SETLLORDFIL 55 101 PRESNT
C N55 GOTO NOTFND
C LOOP TAG
C* The READE operation reads the first 101 record. Because
C* indicator 56 is not on, the lines conditioned by N56 are
C* processed.
C ORDER READEORDFIL 56 END OF GRP
C* The EXCPT operation is processed, and the program branches to the
C* label specified in the GOTO operation.
C N56 EXCPTDETAIL PRINT A LINE
C N56 GOTO LOOP
C* The READE operation reads the second, third, and fourth 101
C* records in the same manner as the first 101 record was read.
C* After the fourth 101 record is read, the READE operation is
C* attempted. Because the 102 record is not of the same group,
C* indicator 56 is set on and the two following operations are
C* bypassed.
C NOTFND TAG
ORDFIL
ORDER Other Fields
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé100 Γöé 1st record of 100Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé100 Γöé 2nd record of 100Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé100 Γöé 3rd record of 100Γöé
(SETLL)ΓöÇΓöÇΓöÇΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé101 Γöé 1st record of 101Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé101 Γöé 2nd record of 101Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé101 Γöé 3rd record of 101Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé101 Γöé 4th record of 101Γöé
ΓöéΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé102 Γöé 1st record of 102Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.10.20.76. SETOF (Set Off) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SETOF Γöé Γöé Γöé Γöé OF OF Γöé
Γöé Γöé Γöé Γöé Γöé OF Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SETOF operation sets off any indicators specified in positions 54 through
59. You must specify at least one resulting indicator in positions 54 through
59. Entries of 1P and MR are not valid. Setting off L1 through L9 indicators
does not automatically set off any lower control-level indicators.
Figure "SETON and SETOF Operations" illustrates the SETOF operation.
ΓòÉΓòÉΓòÉ 1.10.20.77. SETON (Set On) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SETON Γöé Γöé Γöé Γöé ON ON Γöé
Γöé Γöé Γöé Γöé Γöé ON Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SETON operation sets on any indicators specified in positions 54 through
59. You must specify at least one resulting indicator in positions 54 through
59. Entries of 1P, MR, KA through KN, and KP through KY are not valid. Setting
on L1 through L9 indicators does not automatically set on any lower
control-level indicators.
Figure "SETON and SETOF Operations" illustrates the SETON operation.
ΓòÉΓòÉΓòÉ 1.10.20.77.1. SETON and SETOF Operations Example ΓòÉΓòÉΓòÉ
SETON and SETOF Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The SETON and SETOF operations set from one to three indicators
C* specified in positions 54 through 59 on and off.
C* The SETON operation sets indicator 17 on.
C SETON 17
C* The SETON operation sets indicators 17 and 18 on.
C SETON 1718
C* The SETOF operation sets indicator 21 off.
C SETOF 21
ΓòÉΓòÉΓòÉ 1.10.20.78. SHTDN (Shut Down) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SHTDN Γöé Γöé Γöé Γöé ON _ _ Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SHTDN operation allows the programmer to determine whether the system
operator has requested shutdown. If the system operator has requested
shutdown, the resulting indicator specified in positions 54 and 55 is set on.
Positions 54 and 55 must contain one of the following indicators: 01 through
99, L1 through L9, U1 through U8, H1 through H9, LR, or RT.
The system operator can request shutdown by specifying the *CNTRLD option on
the following CL commands: ENDJOB (End Job), PWRDWNSYS (Power Down System),
ENDSYS (End System), and ENDSBS (End Subsystem).
Positions 56 through 59 must be blank.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* When the SHTDN operation is run, a test is made to determine
C* whether the system operator has requested shutdown. If so,
C* indicator 27 is set on and the GOTO END operation is processed.
C SHTDN 27
C 27 GOTO END
SHTDN Operation
ΓòÉΓòÉΓòÉ 1.10.20.79. SORTA (Sort an Array) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SORTA Γöé Γöé Array name Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Factor 2 contains the name of an array to be sorted. The array is sorted into
sequence (ascending or descending), depending on the sequence specified for the
array in position 45 of the extension specifications. If no sequence is
specified, the array is sorted into ascending sequence. The array *IN cannot
be specified in factor 2 of a SORTA operation. A related array, such as a
second array defined on the same extension specification, is not sorted. Only
the array specified in factor 2 is sorted.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments
E ARRY 8 1 A
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C* The SORTA operation sorts ARRY into ascending sequence because A
C* is specified in position 45 of the extension specifications.
C* If the nonsorted ARRY contents were GT1BA2L0, the sorted ARRY
C* contents would be ABGLT012.
C*
C SORTAARRY
SORTA Operation
ΓòÉΓòÉΓòÉ 1.10.20.80. SQRT (Square Root) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SQRT Γöé Γöé Value Γöé Root Γöé Γöé
Γöé (1/2) Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SQRT operation derives the square root of the field named in factor 2. The
square root of factor 2 is placed in the result field.
Factor 2 must be numeric, and can contain one of: an array, array element,
field, figurative constant, literal, named constant, subfield, or table name.
The result field must be numeric, and can contain one of: an array, array
element, subfield, or table element.
An entire array can be used in a SQRT operation if factor 2 and the result
field contain array names.
The number of decimal positions in the result field can be either less than or
greater than the number of decimal positions in factor 2. However, the result
field should not have fewer than half the number of decimal positions in factor
2.
If the value of the factor 2 field is zero, the result field value is also
zero. If the value of the factor 2 field is negative, the RPG/400
exception/error handling routine receives control.
For further rules on the SQRT operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for an example of the SQRT
operation.
ΓòÉΓòÉΓòÉ 1.10.20.81. SUB (Subtract) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SUB(1/2)Γöé Minuend Γöé Subtrahend Γöé Differ- Γöé + - Z Γöé
Γöé Γöé Γöé Γöé ence Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
If factor 1 is specified, factor 2 is subtracted from factor 1 and the
difference is placed in the result field. If factor 1 is not specified, the
contents of factor 2 are subtracted from the contents of the result field.
Factor 1 and factor 2 must be numeric, and each can contain one of: an array,
array element, field, figurative constant, literal, named constant, subfield,
or table name.
The result field must be numeric, and can contain one of: an array, array
element, subfield, or table name.
For rules for the SUB operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for examples of the SUB
operation.
ΓòÉΓòÉΓòÉ 1.10.20.82. SUBST (Substring) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé SUBST Γöé Length to Γöé Base Γöé Target Γöé _ ER _ Γöé
Γöé (P) Γöé extract Γöé string:start Γöé string Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The SUBST operation returns a substring from factor 2, starting at the location
specified in factor 2 for the length specified in factor 1, and places this
substring in the result field. If factor 1 is not specified, the length of the
string from the start position is used.
Factor 1 can contain the length value of the string to be extracted from the
string specified in factor 2. It must be numeric with no decimal positions and
can contain one of: a field name, array element, table name, literal, or named
constant.
Factor 2 must contain either the base character string, or the base character
string followed by ':', followed by the start location. The base string portion
must be character, and can contain one of: a field name, array element, named
constant, data structure name, table name, or literal. The start position must
be numeric with zero decimal positions, and can contain one of the following:
a field name, array element, table name, literal or named constant. If it is
not specified, SUBST starts in position 1 of the base string.
The start location and the length of the substring to be extracted must be
positive integers. The start location must not be greater than the length of
the base string, and the length must not be greater than the length of the base
string from the start location. If either or both of these conditions is not
satisfied, the operation will not be performed, and if you specified an error
indicator in positions 56 and 57 it will be set on. If you did not specify an
error indicator, the exception/error handling routine receives control.
The result field must be character, and can contain one of the following: a
field name, array element, data structure, or table name. The substring is
left-justified, and its length should be at least as large as the length
specified in factor 1. If the substring is longer than the field specified in
the result field, the substring will be truncated from the right.
Note: You cannot use figurative constants in the factor 1, factor 2, or
result fields. No overlapping is allowed for factor 1 and the result field or
factor 2 and the result field.
If factor 1 is shorter than the length of the result field, a P specified in
the operation extender position (position 53) indicates that the result field
should be padded on the right with blanks after the substring occurs.
Figure "SUBST Operation" shows examples of the SUBST operation.
ΓòÉΓòÉΓòÉ 1.10.20.82.1. SUBST Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The SUBST operation extracts the substring from factor 2 starting
C* at position 3 for a length of 2. The value 'CD' is placed in the
C* result field RESULT. Indicator 90 is not set on because no error
C* occurred.
C Z-ADD3 T 20
C MOVEL'ABCDEF' STRING 10
C 2 SUBSTSTRING:T RESULT 90
C*
C* In this SUBST operation, the length is greater than the length
C* of the string minus the start position plus 1. As a result,
C* indicator 90 is set on and the result field is not changed.
C*
C MOVE 'ABCDEF' STRING 6
C Z-ADD4 T 10
C 5 SUBSTSTRING:T RESULT 90
C*
C* In this SUBST operation, 3 characters are substringed starting
C* at the fifth position of the base string. Because P is not
C* specified in position 53, only the first 3 characters of RESULT
C* are changed. RESULT contains '123XXXXX'.
C Z-ADD3 LENGTH 20
C Z-ADD5 T 20
C MOVE 'TEST123' STRING 8
C MOVE *ALL'X' RESULT
C LENGTH SUBSTSTRING:T RESULT 8 90
C*
C* This example is the same as the previous one except P is
C* specified in position 53, and the result is padded with blanks.
C* RESULT equals '123bbbbb'.
C Z-ADD3 LENGTH 20
C Z-ADD5 T 20
C MOVE 'TEST123' STRING 8
C MOVE *ALL'X' RESULT
C LENGTH SUBSTSTRING:T RESULT 8 P 90
C*
C* In the following example, CITY contains the string
C* 'Toronto, Ontario'. The SCAN operation is used to locate the
C* separating blank, position 9 in this illustration. SUBST
C* without factor 1 places the string starting at position 10 and
C* continuing for the length of the string in field TCNTRE.
C* TCNTRE contains 'Ontario'.
C ' ' SCAN CITY C
C ADD 1 C
C SUBSTCITY:C TCNTRE
C*
C* Before the operations STRING='bbbJohnbbbbbb'.
C* RESULT is a 10 character field which contains 'ABCDEFGHIJ'.
C* The CHECK operation locates the first nonblank character
C* and sets on indicator 10 if such a character exists. If *IN10
C* is on, the SUBST operation substrings STRING starting from the
C* 'J' to the end of STRING. Padding is used to ensure that
C* nothing is left from the previous contents of the result
C* field.
C* After the operations RESULT='Johnbbbbbb'.
C*
C ' ' CHECKSTRING ST 10
C 10 SUBSTSTRING:ST RESULT P
SUBST Operation
ΓòÉΓòÉΓòÉ 1.10.20.83. TAG (Tag) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé TAG Γöé Label Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The declarative TAG operation names the label that identifies the destination
of a GOTO (Go To) or CABxx (Compare and Branch) operation.
It can be specified anywhere within calculations, including within total
calculations. The control level entry (positions 7 and 8) can be blank or can
contain an L1 through L9 indicator, the LR indicator, or the L0 entry to group
the statement within the appropriate section of the program. Conditioning
indicator entries (positions 9 through 17) are not allowed.
Factor 1 must contain the name of the destination of a GOTO or CABxx operation.
This name must be a unique symbolic name, which is specified in factor 2 of a
GOTO operation or in the result field of a CABxx operation. The name can be
used as a common point for multiple GOTO or CABxx operations.
Branching to the TAG from a different part of the RPG/400 logic cycle may
result in an endless loop. For example, if a detail calculation line specifies
a GOTO operation to a total calculation TAG operation, an endless loop may
occur.
See Figure "GOTO and TAG Operations" for examples of the TAG operation.
ΓòÉΓòÉΓòÉ 1.10.20.84. TESTB (Test Bit) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé TESTB Γöé Γöé Bit numbers Γöé Char- Γöé OF ON Γöé
Γöé Γöé Γöé Γöé acter Γöé EQ Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The TESTB operation compares the bits identified in factor 2 with the
corresponding bits in the field named as the result field. The result field
must be a one-position character field. Resulting indicators in positions 54
through 59 reflect the status of the result field bits. Factor 2 is always a
source of bits for the result field.
Factor 2 can contain:
Bit numbers 0-7: From 1 to 8 bits can be tested per operation. The bits to
be tested are identified by the numbers 0 through 7. (0 is the leftmost bit.)
The bit numbers must be enclosed in apostrophes, and the entry must begin in
position 33. For example, to test bits 0, 2, and 5, enter '025' in factor 2.
Field name: You can specify the name of a one-position character field,
table name, or array element in factor 2. The bits that are on in the field,
table name, or array element are compared with the corresponding bits in the
result field; bits that are off are not affected. The field specified in
factor 2 or in the result field can be an array element if each element of
the array is a one-position character field.
Hexadecimal literal or named constant: You can specify a 1-byte hexadecimal
literal or hexadecimal named constant. Bits that are on in factor 2 are
compared with the corresponding bits in the result field; bits that are off
are not considered.
Figure "TESTB Operation" illustrates uses of the TESTB operation.
Indicators assigned in positions 54 through 59 reflect the status of the result
field bits. At least one indicator must be assigned, and as many as three can
be assigned for one operation. For TESTB operations, the resulting indicators
are set on as follows:
Positions 54 and 55: An indicator in these positions is set on if the bit
numbers specified in factor 2 or each bit that is on in the factor 2 field is
off in the result field. That is, all of the specified bits are equal to
off.
Positions 56 and 57: An indicator in these positions is set on if the bit
numbers specified in factor 2 or the bits that are on in the factor 2 field
are of mixed status (some on, some off) in the result field. That is, some of
the specified bits are equal to on.
Note: If only one bit is to be tested, these positions must be blank. If a
field name is specified in factor 2 and it has only one bit on, an indicator
in positions 56 and 57 is not set on.
Positions 58 and 59: An indicator in these positions is set on if the bit
numbers specified in the factor 2 or each bit that is on in factor 2 field is
on in the result field. That is, all of the specified bits are equal to on.
Note: If the field in factor 2 has no bits on, then no indicators are set
on.
ΓòÉΓòÉΓòÉ 1.10.20.84.1. TESTB Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The field bit settings are FLDF = 00000001, and FLDG = 11110001.
C*
C* Indicator 16 is set on because bit 3 is off (0) in FLDF.
C* Indicator 17 is set off.
C TESTB'3' FLDF 16 17
C*
C* Indicator 16 is set on because both bits 3 and 6 are off (0) in
C* FLDF. Indicators 17 and 18 are set off.
C TESTB'36' FLDF 161718
C*
C* Indicator 17 is set on because bit 3 is off (0) and bit 7 is on
C* (1) in FLDF. Indicators 16 and 18 are set off.
C TESTB'37' FLDF 161718
C*
C* Indicator 17 is set on because bit 7 is on (1) in FLDF.
C* Indicator 16 is set off.
C TESTB'7' FLDF 16 17
C*
C* Indicator 17 is set on because bits 0,1,2, and 3 are off (0) and
C* bit 7 is on (1). Indicators 16 and 18 are set off.
C TESTBFLDG FLDF 161718
C*
C* The hexadecimal literal X'88' (10001000) is used in factor 2.
C* Indicator 17 is set on because bit 0 is on and bit 4 is off.
C* Indicators 16 and 18 are set off.
C TESTBX'88' FLDG 161718
TESTB Operation
ΓòÉΓòÉΓòÉ 1.10.20.85. TESTN (Test Numeric) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé TESTN Γöé Γöé Γöé Char- Γöé NU BN Γöé
Γöé Γöé Γöé Γöé acter Γöé BL Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The TESTN operation tests a character result field for the presence of zoned
decimal digits and blanks. The result field must be a character field. To be
considered numeric, each character in the field, except the low-order
character, must contain a hexadecimal F zone and a digit (0 through 9). The
low-order character is numeric if it contains a hexadecimal C, hexadecimal D,
or hexadecimal F zone, and a digit (0 through 9). Note that the alphabetic
characters J through R, should they appear in the low-order position of a
field, are treated as negative numbers by TESTN. As a result of the test,
resulting indicators are set on as follows:
Positions 54 and 55: Either the result field contains numeric characters, or
it contains a 1-character field that consists of a letter from A to R.
Positions 56 and 57: The result field contains both numeric characters and
at least one leading blank. For example, the values b123 or bb123 set this
indicator on. However, the value b1b23 is not a valid numeric field because
of the embedded blanks, so this value does not set this indicator on.
Note: An indicator cannot be specified in positions 56 and 57 when a field
of length one is tested because the character field must contain at least one
numeric character and one leading blank.
Positions 58 and 59: The result field contains all blanks.
The same indicator can be used for more than one condition. If any of the
conditions exist, the indicator is set on.
To prevent undesirable results or an abnormal end of a program, the TESTN
operation validates data in fields before arithmetic or editing operations are
processed on the fields. Following validation, the field must be moved to a
numeric field to process the arithmetic and editing operations.
Figure "TESTN Operation" illustrates uses of the TESTN operation.
ΓòÉΓòÉΓòÉ 1.10.20.85.1. TESTN Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The field values are FLDA = 123, FLDB = 1X4, FLDC = 004,
C* FLDD = bbb, FLDE = b1b3, and FLDF = b12.
C*
C* Indicator 21 is set on because FLDA contains all numeric
C* characters.
C TESTN FLDA 21
C* Indicator 22 is set on because FLDA contains all numeric
C* characters. Indicators 23 and 24 remain off.
C TESTN FLDA 222324
C* All indicators are off because FLDB does not contain valid
C* numeric data.
C TESTN FLDB 252627
C* Indicator 28 is set on because FLDC contains valid numeric data.
C* Indicators 29 and 30 remain off.
C TESTN FLDC 282930
C* Indicator 33 is set on because FLDD contains all blanks.
C* Indicators 31 and 32 remain off.
C TESTN FLDD 313233
C* Indicators 34, 35, and 36 remain off. Indicator 35 remains off
C* off because FLDE contains a blank after a digit.
C TESTN FLDE 343536
C* Indicator 38 is set on because FLDF contains leading blanks and
C* low order digits. Indicators 37 and 39 remain off.
C TESTN FLDF 373839
TESTN Operation
ΓòÉΓòÉΓòÉ 1.10.20.86. TESTZ (Test Zone) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé TESTZ Γöé Γöé Γöé Char- Γöé Γöé
Γöé Γöé Γöé Γöé acter Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The TESTZ operation tests the zone of the leftmost character in the result
field. The result field must be a character field. Resulting indicators are
set on according to the results of the test. You must specify at least one
resulting indicator positions 54 through 59. The characters &, A through I, and
any character with the same zone as the character A set on the indicator in
positions 54 and 55. The characters - (minus), J through R, and any character
with the same zone as the character J set on the indicator in positions 56 and
57. Characters with any other zone set on the indicator in positions 58 and 59.
ΓòÉΓòÉΓòÉ 1.10.20.87. TIME (Time of Day) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé TIME Γöé Γöé Γöé Numeric Γöé Γöé
Γöé Γöé Γöé Γöé field Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The TIME operation accesses the system time of day and, if specified, the
system date at any time during program processing. The system time is based on
the 24-hour clock.
The result field must specify the name of a 6-, 12- or 14-digit numeric field
(no decimal positions) into which the time of day or the time of day and the
system date are written.
To access the time of day only, specify the result field as a 6-digit numeric
field. To access both the time of day and the system date, specify the result
field as a 12- (2-digit year portion) or 14-digit (4-digit year portion)
numeric field. The time of day is always placed in the first six positions of
the result field in the following format:
hhmmss (hh=hours, mm=minutes, and ss=seconds)
If the system date is included, it is placed in positions 7 through 12 or 7
through 14 of the result field. The date format depends on the date format job
attribute QDATFMT and can be mmddyy, ddmmyy, yymmdd, or Julian. The Julian
format for 2-digit year portion contains the year in positions 7 and 8, the day
(1 through 366, right-adjusted, with zeros in the unused high-order positions)
in positions 9 through 11, and 0 in position 12. For 4-digit year portion, it
contains the year in positions 7 through 10, the day (1 through 366,
right-adjusted, with zeros in the unused high-order positions) in positions 11
through 13, and 0 in position 14.
The special fields UDATE and *DATE contain the job date. These values are not
updated when midnight is passed, or when the job date is changed during the
running of the program.
TIME Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* When the TIME operation is processed (with a 6-digit numeric
C* field), the current time (in the form hhmmss) is placed in the
C* result field CLOCK. The TIME operation is based on the 24-hour
C* clock, for example, 132710. (In the 12-hour time system, 132710
C* is 1:27:10 p.m.) CLOCK can then be specified in the output
C* specifications.
C TIME CLOCK 60 TIME OF DAY
C* When the TIME operation is processed (with a 12-digit numeric
C* field), the current time and day is placed in the result field
C* TIMSTP. The first 6 digits are the time, and the last 6 digits
C* are the date; for example, 093315121579 is 9:33:15 a.m. on
C* December 15, 1979. TIMSTP can then be specified in the output
C* specifications.
C TIME TIMSTP 120 TIME STAMP
C MOVELTIMSTP TIME 60
C MOVE TIMSTP SYSDAT 60
C* This example duplicates the 12-digit example above but uses a
C* 14-digit field. The first 6 digits are the time, and the last
C* 8 digits are the date; for example, 13120001101992
C* is 1:12:00 p.m. on January 10, 1992.
C* TIMSTP can then be specified in the output specifications.
C TIME TIMSTP 140 TIME STAMP
C MOVELTIMSTP TIME 60
C MOVE TIMSTP SYSDAT 80
ΓòÉΓòÉΓòÉ 1.10.20.88. UNLCK (Unlock a Data Area or Release a Record) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé UNLCK Γöé Γöé Data area or Γöé Γöé _ ER _ Γöé
Γöé Γöé Γöé file name Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The UNLCK operation is used to unlock data areas and release record locks in a
program. The data area must already be specified in the result field of an
*NAMVAR DEFN statement. If the UNLCK operation is specified to an already
unlocked data area, an error does not occur.
In addition, the UNLCK operation allows the most recently locked record to be
unlocked for an update disk file.
Factor 2 must contain the name of the data area to be unlocked, the name of an
update disk file, or the reserved word *NAMVAR. When *NAMVAR is specified in
factor 2, all data areas in the program that are locked are unlocked. Factor 2
must not refer to the local data area or the Program Initialization Parameters
(PIP) data area.
The file specified in factor 2 must be an UPDATE disk file.
You can specify a resulting indicator in positions 56 and 57 to be set on if an
error occurs on the operation. Positions 54, 55, 58, and 59 must be blank.
UNLCK Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U
F*
FUPDATA UF E DISK
F*
C* Assume that the file UPDATA contains record format VENDOR.
C* A record is read from UPDATA. Since the file is an update
C* file, the record is locked. If *IN50 is on, the record is
C* updated; otherwise the record is unlocked using the UNLCK
C* operation. Note that factor 2 of the UNLCK operation is the
C* file name, UPDATA, not the record name, VENDOR.
C*
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C READ VENDOR 12
:
C* *IN50 IFEQ *ON
C* UPDATVENDOR Update record
C ELSE
C UNLCKUPDATA 99 Release record
C ENDIF
C*
ΓòÉΓòÉΓòÉ 1.10.20.89. UPDAT (Modify Existing Record) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé UPDAT Γöé Γöé File name Γöé Data Γöé _ ER _ Γöé
Γöé Γöé Γöé Γöé struc- Γöé Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The UPDAT operation modifies the last record retrieved for processing from an
update disk file or subfile. No other operation should be performed on the file
between the input operation that retrieved the record and the UPDAT operation.
Factor 2 must contain the name of a file or record format to be updated. A
record format name in factor 2 is required with an externally described file.
The record format name must be the name of the last record read from the file;
otherwise, an error occurs. A file name in factor 2 is required with a program
described file.
The result field must contain a data structure name if factor 2 contains a file
name. The updated record is written directly from the data structure to the
file. The result field must be blank if factor 2 contains a record format name.
You can specify a resulting indicator in positions 56 and 57 to be set on if
the UPDAT operation is not completed successfully.
Remember the following when using the UPDAT operation:
When a record format name is specified in factor 2, the current values in the
program for the fields in the record definition are used to modify the
record.
If some but not all fields in a record are to be updated, use the output
specifications and not the UPDAT operation.
Before UPDAT is issued to a file or record, a valid input operation with lock
(READ, READC, READE, READP, REDPE, CHAIN, or primary/secondary file) must be
issued to the same file or record. If the read operation returns with an
error condition or if it was read without locking, the record is not locked
and UPDAT cannot be issued. The record must be read again with the default of
blank in position 53 to specify a lock request.
Consecutive UPDAT operations to the same file or record are not valid.
Intervening successful read operations must be issued.
Beware of using the UPDAT operation on primary or secondary files during
total calculations. At this stage in the RPG/400 cycle, the fields from the
current record (the record that is about to be processed) have not yet been
moved to the processing area. Therefore, the UPDAT operation updates the
current record with the fields from the preceding record. Also, when the
fields from the current record are moved to the processing area, they are the
fields that were updated from the preceding record.
For multiple device files, specify a subfile record format in factor 2. The
operation is processed for the program device identified in the field
specified in the ID entry of the file specifications continuation line. (If
there is no such entry, the device for the last successful input operation is
used.) This device must be the same one you specified for the input
operation that must precede the UPDAT operation. You must not process input
or output operations to other devices in between the input and UPDAT
operations. If you do, your UPDAT operation will fail.
For a display file which has multiple subfile record formats, you must not
process read-for-update operations to one subfile record in between the input
and UPDAT operations to another subfile in the same display file. If you do,
the UPDAT operation will fail.
ΓòÉΓòÉΓòÉ 1.10.20.90. WHxx (When True Then Select) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé WHXX Γöé Comparand Γöé Comparand Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The WHxx operations of a select group determine where control passes after the
SELEC (Begin a Select Group) operation is processed.
The WHxx conditional operation is true if factor 1 and factor 2 have the
relationship specified by xx If the condition is true, the operations following
the WHxx are processed until the next WHxx, OTHER, ENDSL, or END operation.
When performing the WHxx operation remember:
After the operation group is processed, control passes to the statement
following the ENDSL operation.
You can code complex WHxx conditions using ANDxx and ORxx. Calculations are
processed when the condition specified by the combined WHxx, ANDxx, and ORxx
operations is true.
The WHxx group can be empty.
Within total calculations, the control level entry (positions 7 and 8) can be
blank or can contain an L1 through L9 indicator, an LR indicator, or an L0
entry to group the statement within the appropriate section of the program.
The control level entry is for documentation purposes only. Conditioning
indicator entries (positions 9 through 17) are not allowed.
Refer to Compare Operations for valid values for xx.
Figure "WHxx Operation" shows an example of the WHxx operation.
ΓòÉΓòÉΓòÉ 1.10.20.90.1. WHxx Example ΓòÉΓòÉΓòÉ
WHxx Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following example shows nested SELEC groups. The employee
C* type can be one of 'C' for casual, 'T' for retired, 'R' for
C* regular, and 'S' for student. Depending on the employee type
C* (EMPTYP), the number of days off per year (DAYS) will vary.
C*
C SELEC
C EMPTYP WHEQ 'C'
C EMPTYP OREQ 'T'
C Z-ADD0 DAYS
C EMPTYP WHEQ 'R'
C*
C* When the employee type is 'R', the days off depend also on the
C* number of years of employment. The base number of days is 14.
C* For less than 2 years, no extra days are added. Between 2 and
C* 5 years, 5 extra days are added. Between 6 and 10 years, 10
C* extra days are added, and over 10 years, 20 extra days are added.
C*
C Z-ADD14 DAYS
C*
C* Nested select group.
C SELEC
C YEARS WHLT 2
C YEARS WHLE 5
C ADD 5 DAYS
C YEARS WHLE 10
C ADD 10 DAYS
C OTHER
C ADD 20 DAYS
C ENDSL
C* End of nested select group.
C*
C EMPTYP WHEQ 'S'
C Z-ADD5 DAYS
C ENDSL
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C* Example of a SELEC group with complex WHxx expressions. Assume
C* that a record and an action code have been entered by a user.
C* Select one of the following:
C* * When F3 has been pressed, do subroutine QUIT.
C* * When action code A (add) was entered and the record does not
C* exist (*IN50=1), write the record.
C* * When action code A is entered, the record exists, and the
C* active record code for the record is D (deleted); update
C* the record with active rec code=A. When action code D is
C* entered, the record exists, and the ACREC code is A; mark
C* the record as deleted.
C* * When action code is C (change), the record exists, and the
C* ACREC code is A; update the record.
C* * Otherwise, do error processing.
C*
C RSCDE CHAINFILE 50
C SELEC
C *INKC WHEQ *ON
C EXSR QUIT
C ACODE WHEQ 'A'
C *IN50 ANDEQ*ON
C WRITEREC
C ACODE WHEQ 'A'
C *IN50 ANDEQ*OFF
C ACREC ANDEQ'D'
C ACODE OREQ 'D'
C *IN50 ANDEQ*OFF
C ACREC ANDEQ'A'
C MOVE ACODE ACREC
C UPDATREC
C ACODE WHEQ 'C'
C *IN50 ANDEQ*OFF
C ACREC ANDEQ'A'
C UPDATREC
C OTHER
C EXSR ERROR
C ENDSL
ΓòÉΓòÉΓòÉ 1.10.20.91. WRITE (Create New Records) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé WRITE Γöé Γöé File name Γöé Data Γöé _ ER _ Γöé
Γöé Γöé Γöé Γöé struc- Γöé Γöé
Γöé Γöé Γöé Γöé ture Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
The WRITE operation writes a new record to a file.
Factor 2 must contain the name of a file. A record format name is required in
factor 2 with an externally described file. A file name in factor 2 is required
with a program described file, and the result field must contain the name of a
data structure. The record is written directly from the data structure to the
file. The result field must be blank if factor 2 contains a record format name.
The result field must be a data structure name.
Positions 56 and 57 can contain an indicator to be set on if the WRITE
operation is not completed successfully. The indicator in positions 56 and 57
will be set on if overflow is reached to an externally described print file and
no overflow indicator has been specified on the File description specification.
On a WRITE to a subfile (SFILE) record name, you can specify an indicator in
positions 58 and 59; it is set on when the subfile is filled.
When using the WRITE operation remember:
When factor 2 contains a record format name, the current values in the
program for all the fields in the record definition are used to construct the
record.
When records that use relative record numbers are written to a file, you must
update the RECNO (relative record number) field so it contains the relative
record number of the record to be written.
When you use the WRITE operation to add records to a DISK file, you must
specify an A in position 66 of the file description specifications. (See
Position 66 (File Addition).)
Device dependent functions are not available. For example, if a WRITE is
issued to a PRINTER device, there is no spacing or skipping (normally
specified in columns 17 through 22 of the output specifications). If the file
is externally described, these functions are part of the external
description.
For a multiple device file, data is written to the program device named in
the field specified in the ID entry on the file specifications continuation
line. If there is no such entry, data is written to the program device for
which the last successful input operation was processed.
See Figure "WRITE Operation" for an example of the WRITE operation.
ΓòÉΓòÉΓòÉ 1.10.20.91.1. WRITE Example ΓòÉΓòÉΓòÉ
WRITE Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The WRITE operation writes the fields in the data structure
C* DS1 to the file, FILE1.
C*
C WRITEFILE1 DS1 ADD RECORD
ΓòÉΓòÉΓòÉ 1.10.20.92. XFOOT (Summing the Elements of an Array) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé XFOOT Γöé Γöé Array name Γöé Sum Γöé + - Z Γöé
Γöé (1/2) Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
XFOOT adds the elements of an array together and places the sum into the field
specified as the result field. Factor 2 contains the name of the array.
If half-adjust (position 53) is specified, the rounding occurs after all
elements are summed and before the results are moved into the result field. If
the result field is an element of the array specified in factor 2, the value of
the element before the XFOOT operation is used to calculate the total of the
array.
For further rules for the XFOOT operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for an example of the XFOOT
operation.
ΓòÉΓòÉΓòÉ 1.10.20.93. XLATE (Translate) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé XLATE Γöé From:To Γöé String:start Γöé Target Γöé _ ER _ Γöé
Γöé (P) Γöé Γöé Γöé String Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Characters in the source string (factor 2) are translated according to the From
and To strings (both in factor 1) and put into a receiver field (result field).
Source characters with a match in the From string are translated to
corresponding characters in the To string. XLATE starts translating the source
at the location specified in factor 2 and continues character by character,
from left to right. If a character of the source string exists in the From
string, the corresponding character in the To string is placed in the result
field. Any characters in the source field before the starting position are
placed unchanged in the result field.
Factor 1 must contain the From string, followed by a colon, followed by the To
string. The From and To strings can contain one of the following: a field
name, array element, named constant, data structure name, literal, or table
name.
Factor 2 must contain either the source string or the source string followed by
a colon and the start location. The source string portion of factor 2 must be
character, and can contain one of the following: a field name, array element,
named constant, data structure name, data structure subfield, literal, or table
name. The start location portion of factor 2 must be numeric with no decimal
positions and can be a named constant, array element, field name, literal, or
table name. If no start location is specified, a value of 1 is used.
The result field can be a character field, character array element, data
structure or a character table. The length of the result field should be as
large as the source string specified in factor 2. If the result field is larger
than the source string, the result will be left adjusted. If the result field
is shorter than the source string, the result field will contain the leftmost
part of the translated source.
If a character in the From string is duplicated, the first occurrence
(leftmost) is used.
Note: Figurative constants cannot be used in factor 1, factor 2, or result
fields. No overlapping in a data structure is allowed for factor 1 and the
result field, or factor 2 and the result field.
Any valid indicator can be specified in columns 7 to 17.
If factor 2 is shorter than the result field, a P specified in the operation
extender position (position 53) indicates that the result field should be
padded on the right with blanks after the translation.
Columns 54 and 55 must be blank. An indicator in positions 56-57 turns on if an
error occurs on the operation. Columns 58-59 must be blank.
Both factor 2 and the result field must be character or both must be DBCS. See
XLATE Examples.
ΓòÉΓòÉΓòÉ 1.10.20.93.1. XLATE Examples ΓòÉΓòÉΓòÉ
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following translates the blank in NUMBER to '-'. The result
C* in RESULT will be '999-9999'.
C*
C MOVE '999 9999'NUMBER 8
C ' ':'-' XLATENUMBER RESULT 8
XLATE Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme.............
I*
I* In the following example, all values in STRING are translated to
I* uppercase. As a result, RESULT='RPG DEP'.
I*
I 'ABCDEFGHIJKLMNOPQRS- C UP
I 'TUVWXYZ'
I 'abcdefghijklmnopqrs- C LO
I 'tuvwxyz'
C*
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C MOVE 'RpG Dep' STRING 7
C LO:UP XLATESTRING RESULT 90
C*
C* In the following example all values in the string are translated
C* to lowercase. As a result, RESULT='rpg dep'.
C*
C MOVE 'RpG Dep' STRING 7
C UP:LO XLATESTRING RESULT 90
XLATE Operation With Named Constants
AlternateCodePageExampleofXLATE
I..............Namedconstant+++++++++C.........Fldnme.............
I* US English alphabet.
I 'aaaaae- C US
I 'c-
I 'eee-
I 'iiii-
I 'n'
I* Extended alphabet.
I 'аГЕaДС- C XA
I 'З-
I 'ВИК-
I 'бМЛН-
I '╨┤'
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* The following examples change characters only supported in
C* certain languages to characters more widely supported.
C* The field FRANC contains names of employees in the European offices
C* of an international corporation. The program translates those
C* characters that are not printable with a US English printer.
C* Assuming the FRANC field contains the names 'FranЗois',
C* 'HВlene', and 'Niдa', they will be translated to
C* 'Francois', 'Helene', and 'Nina'.
C*
C XA:US XLATEFRANC INTER1 20
ΓòÉΓòÉΓòÉ 1.10.20.94. Z-ADD (Zero and Add) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Z-ADD Γöé Γöé Addend Γöé Sum Γöé + - Z Γöé
Γöé (1/2) Γöé Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Factor 2 is added to a field of zeros. The sum is placed in the result field.
Factor 1 is not used. Factor 2 must be numeric and can contain one of: an
array, array element, field, figurative constant, literal, named constant,
subfield, or table name.
The result field must be numeric, and can contain one of: an array, array
element, subfield, or table name.
Half-adjust (position 53) can be specified.
For the rules for the Z-ADD operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for an example of the Z-ADD
operation.
ΓòÉΓòÉΓòÉ 1.10.20.95. Z-SUB (Zero and Subtract) ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé CODE Γöé FACTOR 1 Γöé FACTOR 2 Γöé RESULT Γöé INDICA- Γöé
Γöé Γöé Γöé Γöé FIELD Γöé TORS Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Z-SUB Γöé Γöé Subtrahend Γöé Differ- Γöé + - Z Γöé
Γöé (1/2) Γöé Γöé Γöé ence Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Factor 2 is subtracted from a field of zeros. The difference, which is the
negative of factor 2, is placed in the result field. You can use the operation
to change the sign of a field. Factor 1 is not used. Factor 2 must be numeric
and can contain one of the following: an array, array element, field,
figurative constant, literal, named constant, subfield, or table name.
The result field must be numeric, and can contain one of the following: an
array, array element, subfield, or table name.
Half-adjust (position 53) can be specified.
For the rules for the Z-SUB operation, see Arithmetic Operations.
See Figure "Summary of Arithmetic Operations" for an example of the Z-SUB
operation.
ΓòÉΓòÉΓòÉ 1.11. RPG/400 Words with Special Functions ΓòÉΓòÉΓòÉ
The following RPG/400 reserved words have special functions within a program:
UDATE, *DATE, UMONTH, *MONTH, UYEAR, *YEAR, UDAY, and *DAY allow you to
access the system date, or a portion of it, to be used in the program.
PAGE, PAGE1-PAGE7 can be used for numbering the pages of a report, for record
sequence numbering, or to sequentially number output fields.
Figurative constants (*BLANK/*BLANKS, *ZERO/*ZEROS, *HIVAL, *LOVAL, *ON/*OFF,
*ALLX'x1..', and *ALL'X..') are implied literals that allow specifications
without referring to length.
*IN and *INxx allow indicators to be referred to as data.
The following reserved words define symbolic locations within the file
information data structure (INFDS) and the program status data structure.
*FILE
*OPCODE
*PARMS
*PROGRAM
*RECORD
*ROUTINE
*STATUS
The following reserved words provide symbolic labels for the ENDSR operation
for the file and program exception/error subroutines or for the INFDS.
*CANCL Cancel the program
*DETC Detail calculations
*DETL Detail lines
*GETIN Get input record
*INIT Program initialization
*OFL Overflow lines
*TERM Program ending
*TOTC Total calculations
*TOTL Total lines
Special words used with operation codes.
*DEFN
*ENTRY
*INZSR
*LDA
*LIKE
*LOCK
*NAMVAR
*OFF
*ON
*PDA
*PSSR
Special words used with translation.
*FILE
*EQUATE
*PLACE allows repetitive placement of fields in an output record. (See *PLACE
for more information.)
*ALL allows all fields that are defined for an externally described file to
be written on output. (See Rules for Figurative Constants for more
information on *ALL)
ΓòÉΓòÉΓòÉ 1.11.1. User Date Special Words ΓòÉΓòÉΓòÉ
The user date special words (UDATE, *DATE, UMONTH, *MONTH, UDAY, *DAY, UYEAR,
*YEAR) allow the programmer to supply a date for the program at run time. The
user date special words access the job date that is specified in the job
description. The user dates can be written out at output time, and are written
in the format specified by the control specification.
See Rules for User Date for more information.
ΓòÉΓòÉΓòÉ 1.11.1.1. Rules for User Date ΓòÉΓòÉΓòÉ
Remember the following rules when using the user date:
UDATE, when specified in positions 32 through 37 of the output
specifications, prints a 6-character numeric date field. *DATE, when
similarly specified, prints an 8-character (4-digit year portion) numeric
date field. Both special words can produce three different date formats:
Month/day/year
Year/month/day
Day/month/year
Use positions 19 and 20 of the control specification to specify the date format
and the editing to be done. If positions 19 and 20 are blank, the date format
is determined by the contents of position 21.
For an interactive program, the user date special words are set when the job
starts running. For a batch program, they are set when the job is sent to the
job queue. In neither case are they updated when the program runs over
midnight or when the job date changes. Use the TIME operation code to obtain
the time and date while the program is running.
UMONTH, *MONTH, UDAY, *DAY, and UYEAR when specified in positions 32 through
37 of the output specifications, print a 2-position numeric date field. *YEAR
can be used to print a 4-position numeric date field. Use UMONTH or *MONTH to
print the month only, UDAY or *DAY to print the day only, and UYEAR or *YEAR
to print the year only.
UDATE and *DATE can be edited when they are written if the Y edit code is
specified in position 38 of the output specifications. The control
specification entry in position 20 determines the separator character to be
inserted; for example, 12/31/88, 31.12.88., 12/31/1988.
UMONTH, *MONTH, UDAY, *DAY, UYEAR and *YEAR cannot be edited by the Y edit
code in position 38 of the output specifications.
The user date special words can be used in factor 1 or factor 2 of the
calculation specifications for operation codes that use numeric fields.
Note: The operation codes CLEAR and RESET, the array index for factor 2 of
LOKUP, and factor 1 of PARM are exceptions to this rule. The user date
special words cannot be used with them.
The user date special words cannot appear as the result field in a
calculation or as an input field.
Blank-after (position 39 of the output specifications) cannot be used with
user date special words.
*YEAR is a 4-digit numeric field containing the year portion of the job date.
*MONTH and *DAY function precisely as UMONTH and UDAY, respectively.
ΓòÉΓòÉΓòÉ 1.11.2. PAGE, PAGE1-PAGE7 ΓòÉΓòÉΓòÉ
PAGE is used to number the pages of a report, to serially number the output
records in a file, or to sequentially number output fields. It does not cause a
page eject. PAGE1 through PAGE7 are used to serially number several output
files.
The eight possible PAGE entries (PAGE, PAGE1, PAGE2, PAGE3, PAGE4, PAGE5,
PAGE6, and PAGE7) may be needed for numbering different types of output pages
or for numbering pages for different printer files.
PAGE and PAGE1 through PAGE7 can be specified in positions 32 through 37 of the
output specifications or in the input or calculation specifications.
See Rules for PAGE, PAGE1-PAGE7 for more information.
ΓòÉΓòÉΓòÉ 1.11.2.1. Rules for PAGE, PAGE1-PAGE7 ΓòÉΓòÉΓòÉ
Remember the following rules when using the PAGE fields:
When a PAGE field is specified in the output specifications, without being
defined elsewhere, it is assumed to be a four-digit, numeric field with zero
decimal positions.
Page numbering, unless otherwise specified, starts with 0001; and 1 is
automatically added for each new page.
To start at a page number other than 1, enter that page number in a field of
an input record and name that field PAGE in positions 53 through 58, or use a
calculation operation such as Z-ADD. The number entered in the PAGE field
should be one less than the starting page number. For example, if numbering
starts with 24, enter a 23 in the PAGE field. The PAGE field can be of any
length but must have zero decimal positions (see Figure "Page Record
Description"). Any entry in the PAGE field should be right-adjusted, such as
0023.
Page numbering can be restarted at any point in a job. The following methods
can be used to reset the PAGE field:
- Specify blank-after (position 39 of the output specifications).
- Specify the PAGE field as the result field of an operation in the
calculation specifications.
- Specify output indicators in the output specifications (see Figure
"Resetting the PAGE Fields to Zero"). Output indicators cannot be used to
control the printing of a PAGE field, because a PAGE field is always
written.
- Specify the PAGE field as an input field as shown in Figure "Page Record
Description".
Leading zeros are automatically suppressed (Z edit code is assumed) when a
PAGE field is printed unless an edit code, edit word, or data format (P/B/L/R
in position 44) has been specified. Editing and the data format override the
suppression of leading zeros.
PAGE can be specified in input or calculation specifications, and can be of
any length. When the PAGE field is defined in input and calculation
specifications, it is treated as a field name in the output specifications
and zero suppression is not automatic.
ΓòÉΓòÉΓòÉ 1.11.2.1.1. Page Record Description ΓòÉΓòÉΓòÉ
Page Record Description
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
IFilenameSqNORiPos1NCCPos2NCCPos3NCC.PFromTo++DField+L1M1FrPlMnZr...
IINPUT PG 50 1 CP
I 2 50PAGE
ΓòÉΓòÉΓòÉ 1.11.2.1.2. Resetting the PAGE Fields to Zero ΓòÉΓòÉΓòÉ
Resetting the PAGE Fields to Zero
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
OName++++DFBASbSaN01N02N03Field+YBEnd+PConstant/editword+++++++++...
O* When indicator 15 is on, the PAGE field is set to zero and 1 is
O* added before the field is printed. When indicator 15 is off, 1
O* is added to the contents of the PAGE field before it is printed.
OPRINT H 01 L1
O 15 PAGE 1 75
ΓòÉΓòÉΓòÉ 1.11.3. Figurative Constants ΓòÉΓòÉΓòÉ
The figurative constants *BLANK/*BLANKS, *ZERO/*ZEROS, *HIVAL, *LOVAL,
*ALL'x..', *ALLX'x1..' and *ON/*OFF are implied literals that can be specified
without a length, because the implied length and decimal positions of a
figurative constant are the same as those of the associated field. (For
exceptions, see the following section, Rules for Figurative Constants.)
Figurative constants can be specified in positions 18 through 27 (factor 1) and
in positions 33 through 42 (factor 2) of the calculation specifications. The
following shows the reserved words and implied values for figurative constants:
Reserved Words Implied Values
*BLANK/*BLANKS All blanks. Valid only for character fields.
*ZERO/*ZEROS Character/numeric fields: All zeros.
*HIVAL Character fields: The highest collating character for the
system (hexadecimal FFs).
Numeric fields: All nines with a positive sign.
*LOVAL Character fields: The lowest collating character for the
system (hexadecimal zeros).
Numeric fields: All nines with a negative sign.
*ALL'x..' Character/numeric fields: Character string x . . is
cyclically repeated to a length equal to the associated
field. If the field is a numeric field, all characters
within the string must be numeric (0 through 9). No sign or
decimal point can be specified when *ALL'x..' is used as a
numeric constant.
*ALLX'x1..' Character fields: The hexadecimal literal X'x1..' is
cyclically repeated to a length equal to the associated
field.
*ON/*OFF *ON is all ones. *OFF is all zeros. Both are only valid
for character fields.
ΓòÉΓòÉΓòÉ 1.11.3.1. Rules for Figurative Constants ΓòÉΓòÉΓòÉ
Remember the following rules when using figurative constants:
Figurative constants are considered elementary items. Except for MOVEA,
figurative constants act like a field if used in conjunction with an array.
For example: MOVE *ALL'XYZ' ARR.
If ARR has 4-byte character elements, then each element will contain 'XYZX'.
MOVEA is considered to be a special case. The constant is generated with a
length equal to the portion of the array specified. For example:
- MOVEA *BLANK ARR,X
Beginning with element X, the remainder of ARR will contain blanks.
- MOVEA *ALL'XYZ' ARR,X
ARR has 4-byte character elements. Element boundaries are ignored, as is
always the case with character MOVEA operations. Beginning with element X,
the remainder of the array will contain 'XYZXYZXYZ...'.
Note that the results of MOVEA are different from those of the MOVE example
above.
After figurative constants are set/reset to their appropriate length, their
normal collating sequence can be altered if an alternate collating sequence
is specified.
The move operations MOVE and MOVEL produce the same result when moving the
figurative constants *ALL'x..' and *ALLX'x1..'. The character string is
cyclically repeated character by character (starting on the left) until the
length of the associated field is the same as the length of the character
string.
Figurative constants are valid in compare operations such as COMP, CAB, DOU,
DOW, and IF; when the associated field in the compare operations is the field
with which the figurative constant is to be compared.
Figurative constants are not allowed in factor 1 of a DEBUG or DSPLY
operation or in factor 2 of MHLZO, MLHZO, MHHZO, MLLZO, BITON, BITOF, TESTB,
or SQRT operations.
The figurative constants, *BLANK/*BLANKS, are moved as zeros to a numeric
field in a MOVE operation.
*BLANK/*BLANKS do not cause any storage allocation if used in factor 2.
Otherwise, storage equivalent to the implied length of blanks is used. The
performance of *BLANK/*BLANKS is equal to using spaces when the implied
length of blanks is less than or equal to 140.
ΓòÉΓòÉΓòÉ 1.11.3.2. Specifying an Array in Calculations ΓòÉΓòÉΓòÉ
An entire array or individual elements in an array can be specified in
calculation specifications. You can process individual elements like fields.
Remember, if an array element is to be used as a result field, the array name
with the comma and index cannot exceed 6 characters.
To specify an entire array, use only the array name, which can be used as
factor 1, factor 2, or the result field. The following operations can be used
with an array name: ADD, Z-ADD, SUB, Z-SUB, MULT, DIV, SQRT, MOVE, MOVEL,
MOVEA, MLLZO, MLHZO, MHLZO, MHHZO, DEBUG, XFOOT, LOKUP, SORTA, PARM, DEFN,
CLEAR, RESET, CHECK, CHEKR, and SCAN.
Several other operations can be used with an array element only but not with
the array name alone. These operations include but are not limited to: BITON,
BITOF, COMP, CABxx, TESTZ, TESTN, TESTB, MVR, DOUxx, DOWxx, IFxx, SUBST, and
CAT.
When specified with an array name without an index, certain operations are
repeated for each element in the array. These are ADD, Z-ADD, SUB, Z-SUB,
MULT, DIV, SQRT, MOVE, MOVEL, MLLZO, MLHZO, MHLZO and MHHZO. The following
rules apply to these operations when an array name without an index is
specified:
When factors 1 and 2 and the result field are arrays with the same number of
elements, the operation uses the first element from every array, then the
second element from every array until all elements in the arrays are
processed. If the arrays do not have the same number of entries, the
operation ends when the last element of the array with the fewest elements
has been processed. When factor 1 is not specified for the ADD, SUB, MULT,
and DIV operations, factor 1 is assumed to be the same as the result field.
When one of the factors is a field, a literal, or a figurative constant and
the other factor and the result field are arrays, the operation is done once
for every element in the shorter array. The same field, literal, or
figurative constant is used in all of the operations.
The result field must always be an array.
If an operation code uses factor 2 only (for example, Z-ADD, Z-SUB, SQRT,
ADD, SUB, MULT, or DIV do not have factor 1 specified) and the result field
is an array, the operation is done once for every element in the array. The
same field or constant is used in all of the operations.
Resulting indicators (positions 54 through 59) cannot be used because of the
number of operations being processed.
ΓòÉΓòÉΓòÉ 1.11.4. Where You Can Use DBCS Data in RPG/400 Programs ΓòÉΓòÉΓòÉ
In an RPG/400 program, you can use DBCS data:
In any comment statement (a statement with an asterisk in position 7)
In the comment field of the extension specification (positions 58-74)
In the comment field of the calculation specification (positions 60-74)
In literals and constants (including named constants)
As data in any character field, subfield, array, or table.
You may mix DBCS data with alphanumeric data. The RPG/400 language treats DBCS
data in the same way as Single Byte Character Set (SBCS) data.
The RPG/400 language uses the value 10 in the *OUT field in the file
information data structure (INFDS) to indicate that the national language
output capability of the device makes it possible for you to use DBCS data with
it.
ΓòÉΓòÉΓòÉ 1.11.4.1. Transparent Literals and Constants ΓòÉΓòÉΓòÉ
A constant or literal is transparent if the constant or literal:
Begins with an apostrophe followed by a shift-out character.
Ends with a shift-in character followed by an apostrophe.
Contains no embedded shift control characters.
Contains only DBCS data.
If you are specifying a transparent constant using hexadecimal literals, you
must specify the shift-out and shift-in characters in hexadecimal.
The following is an example of a DBCS named constant. The constant is continued
by placing a hyphen instead of an apostrophe at the end of each continued line.
When concatenated, the internal SO/SI characters will be dropped and only the
starting SO and ending SI will remain. For more information on named constants
see Named Constant Specifications.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme.............
I 'oK1K2K3i- C DOUBLE
I 'oK4K5i'
Using DBCS data in a constant or literal that is not transparent may produce
unwanted results. The DBCS data may include a character representing an
apostrophe. This character ends your constant or literal where you did not
expect it to end. With a transparent constant or literal, the RPG/400 language
ensures this result does not occur.
If you specify 1 in position 57 of the control specification, transparent
literals and constants are scanned. Your literal or constant is checked to be
transparent, when an apostrophe followed by a shift-out character is found. If
it is not, a warning message is issued on the compiler listing. The literal or
constant is then treated as a literal or constant that is not transparent.
Note: If you specify the shift-out and shift-in characters in a hexadecimal
literal, it will not be considered a transparent literal, and will not be
checked if you specify a 1 in column 57 of the control specification.
All RPG/400 restrictions on the length of constants or literals apply to
transparent constants and literals, including the apostrophes and control
characters.
You may use transparent constants and literals in any of the places you use
constants or literals:
In factor 1 and factor 2 of the calculation specifications. However, it may
not be meaningful to use DBCS data in all of these places. For example, a
move zone operation with a transparent literal in factor 2 will move only the
zone of the shift control character. See the description of each operation
code in Operation Codes to decide if it is appropriate to use a transparent
literal.
As a constant in the constant or edit word field (positions 45-70) of the
output specifications.
ΓòÉΓòÉΓòÉ 1.11.4.2. Additional Considerations for Using DBCS Data in RPG/400 Programs ΓòÉΓòÉΓòÉ
Fields with DBCS data from externally defined files are defined by the RPG/400
language as character fields. These fields are treated in the same manner as
other character fields. However, on the cross-reference listing, the DBCS
fields are indicated by IGC in the key field section, or by G in the field
section.
ΓòÉΓòÉΓòÉ 1.11.4.3. Example of Coding DBCS Data in an RPG/400 Program ΓòÉΓòÉΓòÉ
Here are some RPG/400 specifications that include DBCS data.
In this figure, 'Kn' represents a DBCS character, 'o' represents shift-out
character, and 'i' represents a shift-in character.
This is an EBCDIC example.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
H........1..CDYI....S..............1.F..............................
H 1
You may check transparent literals and constants by specifying a 1 in column 57
of the control specification.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
E*
E*oK1K2K3K4iABoK1K2K3K4iCDEFGHoK1K2K3K4K5K6K7K8K9i
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments
E ARR 4 5 0 oK1K2i ARRoK1i
E*
DBCS data may be mixed with alphanumeric data in comments.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C 'oK1K2K3i'COMP FLDA 161718
C MOVE 'oK1K2K3i'FLDB
C LABELA TAG 'oK1K2K3K4i'
C*
Transparent constants and literals are DBCS data enclosed in apostrophes.
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
OName++++DFBASbSaN01N02N03Field+YBEnd+PConstant/editword+++++++++...
O 7 'oK1K2i'
O 48 'oK1K2K3K4K5K6K7i'
O FLDC 57 '$ 0. oK1K2K3i'
You may use DBCS constants in your output specifications.
Error status code 450 will be returned if shift-out and shift-in characters are
not properly used.
Here are some sample entries from a compile listing. FLDK1 is a DBCS field in
an externally described file.
Sample Key Field Information
PHYSICAL LOGICAL
FILE/RCD FIELD FIELD ATTRIBUTES
FLDK1 IGC 6
AFLD CHAR 3
Sample Cross-Reference Listing
FIELD ATTR REFERENCE (M=MODIFIED D=DEFINED)
FLDK1 G(6) 1000010D
AFLD A(2) 1000004D
ΓòÉΓòÉΓòÉ 1.12. RPG/400 Restrictions ΓòÉΓòÉΓòÉ
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
Γöé FUNCTION Γöé RESTRICTION Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé AN/OR lines (positions 7 and 8 Γöé Maximum of 7 per operation. Γöé
Γöé of calculation specifications) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Arrays and tables Γöé Maximum of 200 per program. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Array/table input record Γöé Maximum length is 80. Γöé
Γöé length for compile time Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Character field length Γöé Maximum length is 256. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Control fields (position 59 Γöé Maximum length is 256. Γöé
Γöé and 60 of input specifica- Γöé Γöé
Γöé tions) length Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Data structure length Γöé Maximum of 9999. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Data structure occurrences Γöé Maximum of 9999 per data Γöé
Γöé (number of) Γöé structure. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Edit Word Γöé Maximum length of 24 for Γöé
Γöé Γöé literals or 115 for named Γöé
Γöé Γöé constants. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Elements in an array/table Γöé Maximum of 9999 per Γöé
Γöé (positions 36 through 39 of Γöé array/table. Γöé
Γöé extension specifications) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé File Γöé Maximum of 50 per program. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Levels of nesting in struc- Γöé Maximum of 100. Γöé
Γöé tured groups Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Look-ahead Γöé Can be specified only once Γöé
Γöé Γöé for a file. Can be specified Γöé
Γöé Γöé only for primary and sec- Γöé
Γöé Γöé ondary files. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Named Constant Γöé Maximum length of 256 for Γöé
Γöé Γöé character named constant, 512 Γöé
Γöé Γöé for hexadecimal named con- Γöé
Γöé Γöé stant, constant, 128 for DBCS Γöé
Γöé Γöé named constant, and 30 digits Γöé
Γöé Γöé with 9 decimal positions for Γöé
Γöé Γöé numeric named constant. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Overflow indicator Γöé Only 1 unique overflow indi- Γöé
Γöé Γöé cator can be specified per Γöé
Γöé Γöé printer file. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Parameters Γöé Maximum of 255 Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Primary file (P in position 16 Γöé Maximum of 1 per program. Γöé
Γöé of file description specifica- Γöé Γöé
Γöé tions) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Printer file (PRINTER in posi- Γöé Maximum of 8 per program. Γöé
Γöé tions 40 through 46 of file Γöé Γöé
Γöé description specifications) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Printing lines per page Γöé Minimum of 2; maximum of 112. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Program status data structure Γöé Only 1 allowed per program. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Record address file (R in Γöé Only 1 allowed per program. Γöé
Γöé position 16 of file Γöé Γöé
Γöé description specifications) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Record length for program Γöé Maximum length is 9999. (1) Γöé
Γöé described file (positions 24 Γöé Γöé
Γöé through 27 of file description Γöé Γöé
Γöé specifications) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Structured groups (see levels Γöé Γöé
Γöé of nesting) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Subroutines Γöé Maximum of 254 per program. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé Tables (see arrays) Γöé Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
Γöé (1)Any device record size restraints override this value. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
ΓòÉΓòÉΓòÉ 1.13. The Structured Query Language ΓòÉΓòÉΓòÉ
The AS/400 system allows you to insert SQL/400 statements into RPG/400
programs. You enter SQL/400 statements on a calculation specification. The
syntax is shown in Figure "Syntax for Entering SQL/400 Statements into an
RPG/400 Program". You must observe the following rules:
The starting delimiter /EXEC SQL must be entered into columns 7-15, with the
slash in column 7.
SQL/400 statements can be started on the same line as the starting delimiter.
SQL/400 statements can be continued on any number of subsequent continuation
lines. The continuation line delimiter is the + in column 7.
SQL/400 statements cannot go past column 74.
The ending delimiter /END-EXEC must be entered in columns 7-15, with the
slash in column 7, on a separate line. This signals the end of the SQL/400
statements. It must be entered by itself, with no SQL/400 statements
following it.
You must enter a separate command to process the SQL/400 statements.
Refer to the SQL/400* Programmer's Guide and the SQL/400* Reference for the
descriptions of how to code SQL/400 statements.
For information on restrictions governing SQL statements in RPG/400 programs,
see Restrictions.
ΓòÉΓòÉΓòÉ 1.13.1. SQL/400 Syntax ΓòÉΓòÉΓòÉ
Syntax for Entering SQL/400 Statements into an RPG/400 Program
C :
C :
C :
C/EXEC SQL (the starting delimiter)
C+
C+ (continuation lines containing SQL statements)
C+
.
.
.
C/END-EXEC (the ending delimiter)
C :
C :
C :
ΓòÉΓòÉΓòÉ 1.13.2. Restrictions ΓòÉΓòÉΓòÉ
In the RPG/400 programming language, the only restriction is that SQL/400
statements cannot be specified in the referred source member of a /COPY
statement.
ΓòÉΓòÉΓòÉ 1.14. Simple Edit Codes ΓòÉΓòÉΓòÉ
You can use simple edit codes to edit numeric fields without adding any
punctuation. The simple edit codes and their functions are:
The X edit code ensures a hexadecimal F sign for positive fields. However,
because the system does this, you normally do not have to specify this code.
Leading zeros are not suppressed. The X edit code does not modify negative
numbers.
The Y edit code is normally used to edit a three- to seven-digit date field.
The Y edit code suppresses only the leftmost zero; however, if the field is
seven positions long, the two leftmost positions are zero-suppressed.
Positions 20 (date edit) and 21 (decimal notation) of the control
specification can be used to alter edit formats.
The Z edit code removes the sign (plus or minus) from and suppresses the
leading zeros of a numeric field. The decimal point is not placed in the
field and is not printed.
ΓòÉΓòÉΓòÉ 1.14.1. Combination Edit Codes ΓòÉΓòÉΓòÉ
The combination edit codes (1 through 4, A through D, J through Q) punctuate a
numeric field.
All of the edit codes suppress leading zeros to the left of the decimal
notation except when J is specified in position 21 (decimal notation) of the
control specification The decimal position of the source field determines
whether and where a decimal point is printed. If decimal positions are
specified for the source field and the zero balance is to be suppressed, the
decimal notation prints only if the field is not zero. If a zero balance is not
to be printed, a zero field prints as blanks.
When a zero balance is to be printed and the field is equal to zero, either of
the following is printed:
A decimal notation followed by n zeros, where n is the number of decimal
places in the field
A zero in the units position of a field if no decimal places are specified.
You can use a floating currency symbol or asterisk protection with any of the
12 combination edit codes. To specify a floating currency symbol, code the
currency symbol in positions 45 through 47 of the output specifications, along
with an edit code in position 38 for the field to be edited. The floating
currency symbol appears to the left of the first significant digit. The
floating currency symbol does not print on a zero balance when an edit code is
used that suppresses the zero balance. (A dollar sign ($) is used as the
currency symbol unless a currency symbol is specified in position 18 of the
control specification.)
An asterisk constant coded in positions 45 through 47 of the output
specifications ('*'), along with an edit code for the field to be edited causes
an asterisk to be printed for each zero suppressed. A complete field of
asterisks is printed on a zero balance source field.
Asterisk fill and the floating currency symbol cannot be used with the simple
(X, Y, Z) or with the user-defined (5 through 9) edit codes.
A currency symbol can appear before the asterisk fill (fixed currency symbol).
This requires the following coding:
1. Place an edit code in position 38.
2. Place a currency symbol constant one space before the beginning of the
edited field.
3. Place '*' in positions 45 through 47 of the line containing the edit code.
When an edit code is used to print an entire array, two blanks precede each
element of the array (except the first element).
One of the decimal notation formats for output is a J entry in position 21 of
the control specification. If you specify J, the use of commas and periods is
reversed; that is, a period is used as the grouping separator character and a
comma is used as the decimal notation. The zero-suppression character is in the
second position (rather than the first) to the left of the decimal notation.
This writes all zero balances and balances with zero values to the left of the
comma with one leading zero (0,00 or 0,04). The J entry also overrides any
edit codes that might suppress the leading zero. Remember that the decimal
positions of the source field determine whether and where a decimal notation is
printed.
Another decimal notation format is an I in position 21 of the control
specification. If you specify I, a period is used as the grouping separator
character and a comma is used as the decimal notation.
ΓòÉΓòÉΓòÉ 1.14.2. Parts of an Edit Word ΓòÉΓòÉΓòÉ
An edit word (coded into positions 45 to 70 of the output specifications)
consists of three parts: the body, the status, and the expansion. The
following shows the three parts of an edit word:
E D I T W O R D
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé
Γöé b Γöé b Γöé b Γöé , Γöé b Γöé b Γöé 0 Γöé . Γöé b Γöé b Γöé
ΓööΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ
Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé
Body
Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé Γöé
Γöé & Γöé C Γöé R Γöé & Γöé & Γöé T Γöé O Γöé T Γöé
ΓööΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÿ
Γöé Γöé Γöé Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Γöé Γöé
Status Expansion
The body is the space for the digits transferred from the source data field to
the output record. The body begins at the leftmost position of the edit word.
The number of blanks (plus one zero or an asterisk) in the edit word body must
be equal to or greater than the number of digits of the source data field to be
edited. The body ends with the rightmost character that can be replaced by a
digit.
The status defines a space to allow for a negative indicator, either the two
letters CR or a minus sign (-). The negative indicator specified is output only
if the source data is negative. All characters in the edit word between the
last replaceable character (blank, zero suppression character) and the negative
indicator are also output with the negative indicator only if the source data
is negative; if the source data is positive, these status positions are
replaced by blanks. Edit words without the CR or - indicators have no status
positions.
The status must be entered after the last blank in the edit word. If more than
one CR follows the last blank, only the first CR is treated as a status; the
remaining CRs are treated as constants. For the minus sign to be considered as
a status, it must be the last character in the edit word.
The expansion is a series of ampersands and constant characters entered after
the status. Ampersands are replaced by blank spaces in the output; constants
are output as is. If status is not specified, the expansion follows the body.
ΓòÉΓòÉΓòÉ 1.15. Array Data ΓòÉΓòÉΓòÉ
The first entry for each input record must begin in position 1. The entire
record need not be filled with entries. The unused entries are filled with
zeroes or blanks for numeric and character arrays respectively.
ΓòÉΓòÉΓòÉ <hidden> Full Line ΓòÉΓòÉΓòÉ
You can use this line to enter any of the following:
Control
File description
Extension
Line counter
Input
Calculation
Output
Compiler Directive
SQL Statement
Array Data
Comment (* in position 7).
ΓòÉΓòÉΓòÉ <hidden> Creating RPGHSPEC.RPG ΓòÉΓòÉΓòÉ
You can use any editor to create RPGHSPEC.RPG provided the file is 80
characters long, a properly coded control specification, and in the CODE base
directory. If you wish to use the CODE/400 editor, you can follow this
procedure:
1. Start CODE.
2. Click on File Pull-down and create a new file.
3. Select LOCAL from the Servers list. e
4. Select the RPG_400 Language profile.
5. Enter the desired H specification fields. You can use the H specification
prompt.
6. Save the file as RPGHSPEC.RPG if the CODE base directory.
7. Exit the edit session.
Rename the file or move it to another directory if you wish to use the default
blank H specification.
ΓòÉΓòÉΓòÉ 1.16. RPG/400 Reserved Fields ΓòÉΓòÉΓòÉ
Control Specification Reserved Fields
File Description Specification Reserved Fields
File Description Specification Externally Described Files Reserved Fields
File Description Specification Continuation Line Reserved Fields
File Description Specification Continuation (SFILE/RENAME)
Extension Specification Reserved Fields
Line Counter Specification Reserved Fields
Input Specification Record Reserved Fields
Input Specification Record AND/OR Reserved Fields
Input Specification Externally Described Record Reserved Fields
Input Specification Data Structure Reserved Fields
Input Specification Data Structure Subfield Reserved Fields
Input Specification Data Structure Subfield *KEYWORD Reserved Fields
Input Specification Initialization Reserved Fields
Input Specification Named Constant Reserved Fields
Output Specification Record Reserved Fields
Output Specification Record AND/OR Reserved Fields
Output Specification File Reserved Fields
Output Specification Externally Described Record Reserved Fields
Output Specification Externally Described File Reserved Fields
ΓòÉΓòÉΓòÉ 1.16.1. Control Specification Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-14, 16-17, 22-25, 27-40, 42, 44-56, and 58-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.2. File Description Specification Reserved Fields ΓòÉΓòÉΓòÉ
Positions 20-23, 47-52, 67-70 and 73-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.3. File Description Specification Externally Described Files Reserved Fields ΓòÉΓòÉΓòÉ
Positions 20-27, 29-30, 32-39, 47-52, 67-70, and 73-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.4. File Description Specification Continuation Line Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-18, 29-46, and 68-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.5. File Description Specification Continuation (SFILE/RENAME) ΓòÉΓòÉΓòÉ
Positions 7-18, 29-46, and 66-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.6. Extension Specification Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-10 must be blank.
ΓòÉΓòÉΓòÉ 1.16.7. Line Counter Specification Reserved Fields ΓòÉΓòÉΓòÉ
Positions 25-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.8. Input Specification Record Reserved Fields ΓòÉΓòÉΓòÉ
Positions 42-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.9. Input Specification Record AND/OR Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-13, 17-18, and 42-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.10. Input Specification Externally Described Record Reserved Fields ΓòÉΓòÉΓòÉ
Positions 15-18, 21-41, and 42-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.11. Input Specification File Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-42, and 71-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.12. Input Specification Externally Described File Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-20, 31-52, 63-64, and 71-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.13. Input Specification Data Structure Reserved Fields ΓòÉΓòÉΓòÉ
Positions 13-16, 31-43, and 52-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.14. Input Specification Data Structure Subfield Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7, 9-20, 31-42, and 59-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.15. Input Specification Data Structure Subfield *KEYWORD Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-43, 52, and 59-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.16. Input Specification Initialization Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7, 9-20, and 59-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.17. Input Specification Named Constant Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-20, 44-52, and 59-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.18. Output Specification Record Reserved Fields ΓòÉΓòÉΓòÉ
Positions 38-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.19. Output Specification Record AND/OR Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-13 and 32-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.20. Output Specification File Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-22, and 71-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.21. Output Specification Externally Described Record Reserved Fields ΓòÉΓòÉΓòÉ
Positions 19-22, and 38-74 must be blank.
ΓòÉΓòÉΓòÉ 1.16.22. Output Specification Externally Described File Reserved Fields ΓòÉΓòÉΓòÉ
Positions 7-22, 38, and 40-74 must be blank.