Professional Documents
Culture Documents
Unisys: Clearpath Enterprise Servers
Unisys: Clearpath Enterprise Servers
You should be very careful to ensure that the use of this information and/or software material complies with the
laws, rules, and regulations of the jurisdictions with respect to which it is used.
The information contained herein is subject to change without notice. Revisions may be issued to advise of such
changes and/or additions.
Notice to U.S. Government End Users: This is commercial computer software or hardware documentation developed
at private expense. Use, reproduction, or disclosure by the Government is subject to the terms of Unisys standard
commercial license for the products, and where applicable, the restricted/limited rights provisions of the contract
data rights clauses.
Unisys and ClearPath are registered trademarks of Unisys Corporation in the United States and other countries.
All other brands and products referenced in this document are acknowledged to be the trademarks or registered
trademarks of their respective holders.
Contents
iv 8600 0544–103
Contents
Section 5. Internationalization
8600 0544–103 v
Contents
CNVNAME..........................................................................5–61
CNVSYMBOLS ...................................................................5–62
CNVTIME............................................................................5–67
CNVTPLT ............................................................................5–70
CSMSG...............................................................................5–72
MCPLANGS........................................................................5–76
TPLTDATE ..........................................................................5–78
TPLTDATTIM......................................................................5–80
TPLTTIME...........................................................................5–82
VSNCOMPTXT ...................................................................5–85
VSNESCAPE.......................................................................5–89
VSNGETORD1....................................................................5–92
VSNINSPTXT ......................................................................5–95
VSNTRANTXT.....................................................................5–98
Errors .................................................................................................5–102
vi 8600 0544–103
Contents
8600 0544–103 ix
Contents
x 8600 0544–103
Contents
8600 0544–103 xi
Contents
Index ............................................................................................. 1
8600 0544–103 xv
Contents
4–1. File Specifications: Indexed File or Alternate Index File .................................. 4–30
4–2. File Specifications: Limits File.......................................................................... 4–31
4–3. Extension Specifications: Limits File................................................................ 4–31
4–4. File Specifications: SETLL Operation ............................................................... 4–33
4–5. File Specifications: Addrout Processed Files ................................................... 4–41
4–6. File Specifications: Addrout File....................................................................... 4–42
4–7. Extension Specifications: Addrout File ............................................................ 4–42
xx 8600 0544–103
Examples
2–1. Coding a Page Field ......................................................................................... 2–12
2–2. Coding *INxx Indicators ................................................................................... 2–14
2–3. Coding an *IN Array ......................................................................................... 2–14
4–1. Specifying ALLOCATION and EXTEND Attributes with RPG ............................ 4–5
4–2. Creating a BFS Sequential Disk File................................................................. 4–13
4–3. Creating an EFS Sequential Disk File ............................................................... 4–14
4–4. Creating a BFS Direct File ................................................................................ 4–15
4–5. Creating a Delete-Capable EFS Direct File....................................................... 4–17
4–6. Creating an EFS Direct File (Not Delete-Capable)............................................ 4–18
4–7. Creating a BFS Indexed File............................................................................. 4–19
4–8. Creating an EFS Indexed File ........................................................................... 4–21
4–9. Processing Sequential and Direct Files Consecutively .................................... 4–23
4–10. Processing an Indexed File Consecutively....................................................... 4–24
4–11. Processing an Indexed File Sequentially by Key.............................................. 4–25
4–12. Processing an Alternate Index File Sequentially by Key .................................. 4–26
4–13. Processing an Alternate Index File with a Noncontiguous Key ....................... 4–27
4–14. Processing an Indexed File with a Limits File.................................................. 4–29
4–15. Processing an Indexed File with the SETLL Operation Code .......................... 4–33
4–16. Randomly Processing a Disk File by Relative Record Numbers...................... 4–35
4–17. Randomly Processing an Indexed File with Primary or Alternate Keys ........... 4–37
4–18. Loading a Noncontiguous Key with a CHAIN Operation.................................. 4–38
4–19. Randomly Processing a Disk File with an Addrout File.................................... 4–40
4–20. Adding Records to BFS Sequential or Direct Files .......................................... 4–43
4–21. Adding Records to the End of an EFS Sequential File .................................... 4–44
4–22. Adding Records to Sequential Files by Relative Record Number .................... 4–46
4–23. Adding Records to Direct Files by Relative Record Number .......................... 4–47
4–24. Adding Records without Checking for Duplicate Keys .................................... 4–49
4–25. Adding Records and Checking for Duplicate Keys........................................... 4–50
4–26. Using the DEL Entry to Delete Records from a BFS Direct File...................... 4–51
4–27. Deleting Records from an EFS Sequential or Direct File ................................. 4–52
4–28. Using the DEL Entry to Delete Records from an Indexed File ........................ 4–53
4–29. Using the DELET Operation Code to Delete Records from an Indexed
File ............................................................................................................... 4–54
4–30. Releasing Locked Records by Performing a Free Operation ........................... 4–55
20–1. Loading Three Compile-Time Vectors Without Using the SEQ Field ...............20–5
20–2. Loading a Compile-Time Vector Using the SEQ Field ......................................20–6
20–3. Loading Three Compile-Time Vectors Using ** Specifications........................20–7
Documentation Updates
This document contains all the information that was available at the time of publication.
Changes identified after release of this document are included in problem list entry (PLE)
18565374. To obtain a copy of the PLE, contact your Unisys representative or access
the current PLE from the Unisys Product Support Web site:
http://www.support.unisys.com/all/ple/18565374
Note: If you are not logged into the Product Support site, you will be asked to do so.
Purpose
This manual describes Report Program Generator I and II. It is a reference document for
the applications programmer using the RPG language to develop programs. This manual
is not a tutorial.
Scope
This manual describes
Additional publications relate directly to RPG and can be helpful to RPG programmers.
For more information, see the list of related product information in this section.
RPG coding forms are available for each type of RPG specification. A list of the RPG
coding forms and their form numbers follows. Programs can be written on these forms
before they are entered into the computer.
The Report Program Generator (RPG) Programming Reference Manual is divided into two
volumes. In this manual, the Report Program Generator (RPG) Reference Manual,
Volume 2: Product Interfaces is referred to as Volume 2.
Audience
The RPG programmer in need of a reference document for programming with RPG
should read this manual.
For the experienced RPG programmer, this manual is a good source of reference
information about available options and features.
Prerequisites
A basic understanding of the RPG language is required. In addition, a basic knowledge of
the system is necessary.
Acronyms are spelled out the first time they occur in the manual.
Organization
The first three sections of this manual are a general introduction to RPG programming.
Section 4 provides many examples of programming with disk files. Section 5 explains
internationalization features that can customize applications to the language and
conventions of a particular locale. Sections 6 through 20 explain the fields of each coding
form. Section 21 describes the compiler control records. Two appendixes are included to
provide related information.
Section 5. Internationalization
The internationalization features that can be used to customize an application for the
language and conventions of a particular locality are described.
The following documents are included with the software release documentation and
provide general reference information:
• The Glossary includes definitions of terms used in this document.
• The Documentation Road Map is a pictorial representation of the Product Information
(PI) library. You follow paths through the road map based on tasks you want to
perform. The paths lead to the documents you need for those tasks. The Road Map
is available on the PI Library CD-ROM. If you know what you want to do, but don't
know where to find the information, start with the Documentation Road Map.
• The Information Availability List (IAL) lists all user documents, online help, and HTML
files in the library. The list is sorted by title and by part number.
The following documents provide information that is directly related to the primary
subject of this publication.
The following documents are included with the software release documentation and
provide general reference information:
This section provides an overview of the Report Program Generator (RPG) language and
describes the basic concepts of programming in RPG.
Because of program logic cycle (PLC) processing, the programmer can focus on the
problem to be solved by the system, rather than on the details of system operation.
Basically, RPG specifies the type of data to be processed and the type of output desired.
The compiler translates the specifications into instructions that do all that is necessary to
produce the required output.
RPG Applications
RPG programs are often used to produce customized reports from data contained in
files; however, RPG can be used for a variety of data processing applications that do not
involve report production in the traditional sense. Primarily, these other applications
update data files stored on magnetic tape, disk, or other machine-readable media.
File Creation
The Command and Edit (CANDE) message control system (MCS) creates the program
file. CANDE facilitates the editing and management of programs. Additional information
on CANDE is provided in the CANDE Operations Reference Manual.
Either of the following methods can be used to compile and run the program:
RPG Dialects
RPG for MCP based systems supports two dialects: RPG I and RPG II. The RPG I dialect
is compatible with the IBM 360/20 RPG. The RPG II dialect is compatible with the IBM
System/36 RPG II. Both dialects support MCP based extensions.
If RPG I features are needed, a 1 must be entered in the Source Dialect field (column 51)
of the Control Specification; otherwise, this column should be blank. The source program
is not checked against the syntax of the chosen dialect; this option is used only to
resolve conflicts between the dialects. Provided that no conflict exists, RPG II features
can be used when the RPG I dialect is specified; similarly, RPG I features can be used
when the RPG II dialect is specified.
In this manual, all references to RPG that do not specify a particular dialect refer to
RPG II.
The specifications shown in Figure 1–1 are described and must be used in the order
listed in the following table:
Specifications Description
The coded information contained on the specification forms is recorded in the disk or
tape files that constitute the source program. The arrangement of these records in the
source is illustrated in Figure 1–1. Note that either Alternate Collating Sequence or File
Translation Specifications can follow Output Specifications.
If source corrections are necessary, appropriate changes can be made to the program,
and the program can be recompiled.
Character Set
The RPG character set consists of the characters shown in Table 2–1.
In addition, the characters shown in Table 2–2 can be used in edit words and
alphanumeric literals.
Character Name
The standard characters used in creating identifiers (such as file names, vector names,
field names, and labels) are the letters A through Z and the digits 0 through 9. Additional
characters might be necessary for international usage because of an expanded character
set.
An identifier must start with an alphabetic character, a dollar sign ($), an at sign (@), or a
pound sign (#). When an embedded comma is used to form an indexed vector, the
characters following the comma are assumed to be a subscript for that vector.
Definition of Names
A name must be left-justified in the field; must begin with an alphabetic character, a
dollar sign ($), an at sign (@), or a pound sign (#); and must end with a space or the end of
the field (whichever comes first). After the first character, a name can contain any
combination of characters as defined in the discussion of characters used for names in
this section. Blanks must not appear between the characters in a name.
Field Names
A field name identifies an individual element of data. A field name is 6 characters or less
and must be unique among vector and field names. A separate memory area is reserved
for each field name.
A field name is defined by the first occurrence of the name that specifies length and
decimal attributes. Any attempt to redefine the name with different attributes results in a
warning.
Signed and unsigned numeric fields can be up to 23 digits long (not including the sign).
The size of alphanumeric fields is restricted by the specification on which they occur. The
largest alphanumeric field allowed in RPG is 9999 bytes.
File Names
A file name designates a set of data items. A file name is 8 characters or less and must
be unique among file and output group names. The length of the file name can be
extended by using the TITLE file attribute. Additional information on the TITLE file
attribute is provided in Section 9, “Attribute Specifications.” The contents of a file are
divided into logical records made up of any consecutive set of data items. A file name
must not contain any special characters other than the hyphen (-), a pound sign (#), a
dollar sign ($), or an at sign (@).
Labels
A label identifies either a point in the Calculation Specifications where a GOTO operation
branches or the beginning of a subroutine. Labels cannot exceed 6 characters in length
and must be unique among labels.
Library Names
A library name identifies the name of a library that provides procedure entry points that
the program intends to call. Library names follow the rules for the definition of names.
The length of the name cannot exceed 10 characters and must be unique among library
names.
Subfield Names
A subfield is an element of a data structure. Subfield names follow the same rules of
formation as field names. In addition, a subfield name cannot be the same as a data
structure name, an array element, a table name, an output group name, or a look-ahead
field. Subfield names must be unique within data structures; the same subfield name
cannot be used in more than one data structure. A data structure name can not be used
as a subfield name in another data structure.
Vector Names
A vector name identifies data that is a table or an array. The vector is loaded with a
number of elementary data items. The entire vector can be accessed by using the vector
name. A vector name is 6 characters or less, and must be unique among vector and field
names. For more information on tables and arrays, see the discussion of using vectors in
Section 10, “Extension Specifications.”
A vector element is referred to by the vector name followed by a comma (,) and an index.
The index can be a numeric literal or a field name defined elsewhere in the program.
Definition of Literals
A literal is an item of data that contains a value identical to the characters being
described. The four classes of literals are figurative constant, numeric, alphanumeric, and
hexadecimal.
Figurative Constants
Figurative constants are literals that have predefined values and implied lengths.
Figurative constants are
• *BLANK and *BLANKS are synonyms. *ZERO and *ZEROS are synonyms.
• *BLANK, *BLANKS, *ZERO, and *ZEROS can be used as alphanumeric or numeric
fields.
• The result of moving *BLANK or *BLANKS into an alphanumeric field is a field filled
with blanks (for example, ' '). The result of moving *BLANK or *BLANKS into a
numeric field is a field filled with zeros (for example, '00').
• The result of moving *ZERO or *ZEROS into a numeric field is a field filled with zeros
(for example, '00'). The result of moving *ZERO or *ZEROS into an alphanumeric
field is a field filled with blanks (for example, ' ').
• Figurative constants can be used only in Calculation Specifications.
• The length of the figurative constant is the same as the length of the other factor
field, if it is present. If no other factor field is present, the length of the figurative
constant is equal to the length of the Result Field.
• Figurative constants are considered to be individual items and are like fields when
used with arrays. For example, if the 6-element numeric array NUM contains 1 2 3 4
5 6, then using the ADD operation with *ZERO in Factor 2 causes zero to be added
to each element of the array. The result is 1 2 3 4 5 6.
If the figurative constant *BLANK is used with the MOVEA operation, blanks are moved
into every element of an alphanumeric array, beginning with the specified element, to the
end of the array. For example, the MOVEA operation with *BLANK in Factor 2 and ALP,1
in the Result Field causes the entire array ALP to be filled with blanks.
A figurative constant is placed in the collating sequence where the corresponding blank
or zero is placed; therefore, its placement can be modified by an alternating collating
sequence.
Figurative constants can be used in Factor 1 and Factor 2 of all operations that allow
alphanumeric or numeric fields except as follows:
• Figurative constants are not allowed in Factor 1 of either the DEBUG or the DSPLY
operation.
• Figurative constants are not allowed in Factor 2 of the following operations:
BITOF MHLZO SQRT
MHHZO MLLZO
Numeric Literal
A numeric literal is defined as an item composed of characters chosen from the digits 0
through 9, the plus (+) or minus (–) sign, and the decimal point or the decimal comma.
Alphanumeric Literal
An alphanumeric literal is composed of any allowable characters enclosed in
apostrophes ('). Consequently, all spaces enclosed in the apostrophes are considered
part of the literal. Two consecutive apostrophes in an alphanumeric literal cause a single
apostrophe to be inserted into the literal string. An alphanumeric literal that consists of
only four consecutive apostrophes results in a literal of a single apostrophe.
'ACTUAL' ACTUAL
'-1234.56' -1234.56
'WEEK''S' WEEK'S
'TODAY''S DATE' TODAY'S DATE
'''' '
'A''B' A'B
'A''''B' A''B
Hexadecimal Literal
A hexadecimal literal is used in the formation of alphanumeric characters. This literal can
be used to form bit patterns that cannot otherwise be represented in the RPG source
image.
0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111
@0F@ @3C@
Special Words
These reserved words are used in the Input, Calculation, and Output Specifications.
UDATE UTIME
JDATE PAGE
UDAY *IN
UDAYNM *PLACE
Each special word has its own defined usage, as described in the following paragraphs.
The UDATE date field produces a 6-digit numeric field in one of the following formats,
depending on the entry in the Inverted Print field (column 21) and the Date Format field
(column 23) in the Control Specification:
The JDATE date field is the Julian date. JDATE is 5 digits long with no decimal places
and has the format YYDDD.
The other three fields, UMONTH, UDAY, and UYEAR, consist of a 2-digit field
representing the month, day, and year, respectively.
The following rules apply to UDATE, JDATE, UMONTH, UDAY, and UYEAR:
• These fields must not be changed by any operation within the program. They must
not be used in Input Specifications, in the Calculation Specifications Result Field, or in
the Output Specifications with the Blank After field specified. These fields are
generally used in compare, test, and output operations, and they can be used as
subscripts.
• The current value of the date is captured at beginning of job (BOJ) and does not
change during the execution of the program.
UDAYNM
The special word UDAYNM enables the program to obtain the name of the current day at
BOJ. UDAYNM is a left-justified, 9-character alphanumeric field. This field cannot be
changed by the RPG program.
UTIME
The special word UTIME enables the program to obtain the time at BOJ. UTIME is a 6-
digit numeric field with the format HHMMSS (where HH, MM, and SS represent hours,
minutes, and seconds, respectively). This field cannot be changed by the RPG program.
The field can be defined as any length (refer to the discussion of field lengths earlier in
this section), but it cannot contain any decimal positions. When a page field is specified
without being previously defined in the Input or Calculation Specifications, the field is
assumed to be 4 digits long with no decimal positions. During output, leading zeros are
suppressed and the sign is not printed (unless an edit word or an edit code is specified).
The page field begins at 0 (unless otherwise specified) and is automatically incremented
by 1 before each new page is written.
A page field can be reset at any point during the program by setting it to 0 before it is
printed (refer to Example 2–1).
• Using the Blank After field (column 39) in the Output Specifications to clear the field
to 0 after output.
• Assigning an output indicator to the page field. If the indicator is on, the field is set to
0 before normal incrementing takes place. The indicator is only used to determine
whether to set the field to 0; it does not condition the printing of the field.
It is not recommended that the same PAGE and PAGEn entry be used for different
output files. Page fields are not restricted to printer files.
Example
Example 2–1 shows the use of page fields, as follows:
• PAGE1, associated with the file FILEOUT, is incremented by 1 before each page of
FILEOUT is printed.
• PAGE2, associated with the file PRINT, is cleared to 0 after each page of PRINT is
printed because B is inserted in the Blank After field.
• PAGE3, associated with the file PRINT2, is set to 0 before each page of PRINT2 is
printed if the output indicator 01 is on. If the output indicator 01 is not on for a given
output, PAGE3 is not reset to 0. The value of PAGE3 is written to PRINT2 regardless
of the value of indicator 01.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
02000FFILEIN IP 80 80 DISK
04000FFILEOUT O 132 132 PRINTER
06000FPRINT O 132 132 PRINTER
08000FPRINT2 O 132 132 PRINTER
10000IFILEIN AA 01
12000OFILEOUT D
14000O PAGE1 5
16000OPRINT D
18000O PAGE2 B 5
20000OPRINT2 D
22000O 01 PAGE3 5
*INxx Alias
An indicator can be referred to as a 1–character alphanumeric field having the name
*INxx, where xx is the indicator name. For example, *IN22 refers to indicator 22.
Likewise, *INLR refers to the LR indicator. Allowing indicators to be used as an
alphanumeric field creates the alias for the indicator.
The status of the indicator (on or off) is determined by the low-order bit of the
alphanumeric field. If the low-order bit is on, the indicator is on. If the low-order bit is off,
the indicator is off.
The alphanumeric aliases for the following indicators are declared automatically by the
compiler and are available for every RPG program. It is not necessary to declare them
individually.
Type Indicators
User 01–99
Control L0–L9, LR
Data Management DA–DH, DJ--DU, D1
Exception
Overflow OA–OG, OV
External U1–U8
Halt H0–H9
Matching Record MR
Example
Example 2–2 shows the use of alphanumeric aliases for indicators 01 through 05 to set
them according to the first 5 bytes of an input data record.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
00100IINFILE 10
00200I 1 1 *IN01
00300I 2 2 *IN02
00400I 3 3 *IN03
00500I 4 4 *IN04
00600I 5 5 *IN05
*IN Alias
Indicators 01 through 99 also can be referred to as elements of the *IN alphanumeric
array. For example, *IN,34 is a 1-byte alphanumeric array element corresponding to
indicator 34. The array *IN has ninety-nine 1-byte elements.
Using the *IN array has several advantages. For example, the *IN array can be used if
calling a subroutine might make undesirable changes to indicators. Using the *IN array
enables the state of the indicators (on or off) to be saved before a subroutine is
executed. The state of the indicators then can be restored after the subroutine has
completed execution.
Example
Example 2–3 shows the use of the *IN array. Indicators 01 through 20 are saved before a
subroutine call and are restored after the subroutine is completed.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
00100C MOVEA*IN SAVE20 20
00200C EXSR SUB1
00300C MOVEASAVE20 *IN
Like the alphanumeric aliases, the *IN array is declared automatically by the compiler and
is available for every RPG program. The *IN array cannot be declared explicitly.
*PLACE
The special word *PLACE enables the same fields to be written in more than one place
in an output record. *PLACE is valid only in Output Specifications. Information on
*PLACE is provided in the discussion of constants in Section 17, “Output-Format
Specifications.”
Operation Codes
The following reserved words specify operations that can be performed on data items:
CLOSE (Close file for processing) PARAM (Specify parameters for EEXSR)
These reserved words are used in the Calculation Specifications. A complete description
of the operation codes is presented in Section 16, “Operation Codes.”
To understand RPG, it is essential to understand the program logic cycle (PLC) because
the RPG object program goes through the same cycle of operations for each record.
After the program reads a record, calculation operations and output occur at two different
times. First, the program performs all total calculation operations and all total output
operations. Total calculations are those conditioned by control level indicators in the
Control Level field (columns 7–8) in the Calculation Specifications. Total output operations
are those with a T in the Type field (column 15) in the Output Specifications. Second, the
program performs all detail calculations and detail output operations.
The program performs total calculations before it makes available the information on the
record selected for processing. It performs detail calculations after it makes available the
information on the selected record (refer to Figure 3–1). The following paragraphs
describe this important concept in more detail.
Whenever the program reads a record with a control field specified, it determines if
information in the control field is different from the control field information in the
previous record. A change in the control field information indicates that all records from a
particular control group have been read and that a new group is starting.
When the program has read all the records from a group, it turns on the control level
indicators. Then, the program can perform operations, using information accumulated
from all records in that group. At this time, the program performs all calculations
conditioned by control level indicators. Similarly, the program performs total output
immediately after it completes all total calculation operations. The program uses the
information from the records in the previous control group, not the information from the
record in the current cycle.
Detail calculations occur after the information in the selected record becomes available
(refer to Figure 3–1). Detail calculations are used to calculate values that are needed each
time a record is processed and to calculate totals for the current control group if control
fields are specified. After the program completes detail calculation operations, it
performs detail output operations.
The following descriptions apply to Figure 3–1. Operations performed at each step in the
PLC are described in order under the heading corresponding to each step.
• The data space is initialized. All numeric fields are initialized to zero (0),and all
alphanumeric fields are initialized to blank. Control-field storage space is initialized to
binary zero (0). Match-field storage space is initialized to either the highest or the
lowest possible value, depending on whether the match sequence is descending or
ascending. Refer to the discussion about Match fields (columns 61–62) in Section 14,
“Input Specifications.” All indicators, except for 1P, are turned off. Table pointers are
initialized to point to the first entry in each table.
• If the Zero/Blank Indicator Setting field (column 42) in the Control Specification
contains an S or if the Zero/Blank Indicator Setting field is blank and the Source Input
Dialect field (column 51) in the Control Specification contains a 1, then Zero/Blank
indicators are turned on, unless the indicator is one of the halt indicators (H0–H9).
• The program obtains the system date and time and initializes the date and time fields
to the appropriate formats and values.
• The external indicators (U1–U8) are initialized based on the task attributes SW1
through SW8.
• Preexecution-time vector data are loaded from the input table files; then the input
table files are closed.
• Other files used by the program are opened, if appropriate.
• The program turns on the first-control-cycle switch. This switch is used to suppress
total output and calculations until the first record has been processed.
Forms alignment can be requested during the first cycle by designating 1 in the Forms
Positioning field (column 41) of the Control Specification. If so, the operator can repeat
this step as many times as necessary to align the form.
• All overflow indicators are turned off unless the overflow indicator was turned on
during detail output in the current cycle (step 2) or during detail calculations in the
previous cycle (step 16).
• For any file having an overflow indicator that was turned on during detail output or
calculations, the overflow indicator assigned to the file remains unchanged.
• The halt indicators are tested. If any halt indicators are on, the operator has the
option to stop or continue the program, unless this option has been overridden by an
entry in the Halt Indicator field (column 50) in the Control Specification.
• All of the following indicators are turned off: record identification, halt, first page and
control level.
• If the RPG I dialect is specified in the Source Input Dialect field (column 51) in the
Control Specification, the last record (LR) indicator is turned off.
• The L0 indicator is turned on.
• If the first-control-cycle switch is on, the program reads records from each primary
and secondary file. On subsequent cycles, the program reads a record from the file
processed during the previous cycle unless that file is declared as an input look-
ahead file.
• If all the required files have reached end of file (EOF)as specified in the End of File
field (column 17) in the File Specifications, the program branches to step 8.
• If all the required files have not reached EOF, the program checks the Record
Identification Codes field (columns 21–41) in the Input Specifications and carries out
the record-type sequence checking specified in the Sequence field (columns 15–16)
in the Input Specifications.
• If the FORCE operation was performed during the previous program cycle, the
program selects the forced file for processing and then branches to step 7. If the
FORCE operation was not performed during the previous cycle, the program inspects
the current records from each primary and secondary file in the order that the files
were specified in the File Specifications. The program selects for processing the first
file that has no match fields specified and then branches to step 7.
• If all records have match fields, the program selects for processing the record with
the highest-priority matching field value. This value is either the highest collating
value for the descending matching sequence or the lowest collating value for the
ascending matching sequence. If two or more files have equal highest-priority
matching field values, the program selects the file that was specified first in the File
Specifications.
If the record does not have match fields specified, the program branches to step 7.
• The program compares the match field value of the selected record to the match
field value of the previous record with match fields. If the selected record is in
sequence, the program branches to step 7; otherwise, the program displays an error
message indicating that a match sequence error has occurred. If the Run-Time Error
field (column 49) in the Control Specification was used to override the error handling
option, the operator indicates whether the program should end (by branching to step
17) or should continue reading the next record (by branching to the restart point at
step 18.)
• If there is a record identifying indicator for the record selected in step 6, it is turned
on.
• If any file read in step 5 of this cycle was defined as an update or combined file with
a look-ahead option, the program extracts look-ahead fields.
• If the record selected has control fields specified, the program tests the values of the
fields for control breaks. The program extracts the control fields from the record and
tests for each level against the control field storage area. If the contents are unequal,
a control break has occurred. The program turns on the appropriate control level
indicators and stores the new control field values in the control field storage area.
• If the first-control-cycle switch is on, it is turned off and the program branches to
step 11; otherwise, the program branches to step 9.
• The program requires final totals and end of job (EOJ) processing as the result of
normal processing.
• An abnormal condition causes the operator or the program to have the program end
in an orderly manner.
The program turns on the indicators L0 through L9 and LR and branches to step 9.
• The program selects a total calculation line that appears with a control level indicator
(L0–L9 or LR).
• The program branches to step 10 if all the total calculations have been processed or
if none appear.
• If the control level indicator is on and the conditions specified in the Indicators field
(columns 9–17) of the Calculation Specifications are satisfied, the program performs
the operation specified by the Operation field (columns 28–32) in the Calculation
Specifications.
• The program repeats step 9.
Data are extracted from the current record and made available to the program for
processing. Any field indicators specified are turned on or off to reflect the status of the
data field values.
This section contains discussions of the disk file systems, organization of disk files,
creation of disk files, processing of disk files, and addition and deletion of records from
disk files.
The discussions of disk files in this manual assume that KEYEDIOII is installed on the
system. If this is not the case, the syntax for the file system enabled is the same as BFS.
However, record-level locking and alternate index files for indexed files exist only with
KEYEDIOII.
There are few differences between BFS and EFS files. For the differences that do exist,
BFS and EFS disk files require slightly different syntax in an RPG program. These
differences are indicated at appropriate places in the manual.
Both kinds of files can be used in the same RPG program. It is the responsibility of the
user to remember the type of file being used.
• Both BFS and EFS disk files support sequential, direct, and indexed file organizations.
The file organization reflects how records are placed in the file when the file is
created. BFS and EFS handle direct file support differently. For additional information,
refer to “Disk File Organization” later in this section.
• Alternate index files are files that contain indexes for another file (the parent file).
Alternate index files enable an EFS sequential or direct file to be accessed by a key
field in each record. Alternate index files also enable a BFS or an EFS indexed file to
be accessed by a key other than the primary key that was declared when the
indexed file was created.
Alternate index files can be created with SYSTEM/KEYEDIOII/UTILITY once the
parent file is created. All alternate index files are updated when the parent file is
updated.
The keys created by the utilities are called alternate keys or alternate indexes. The keys
are stored in key files called alternate index files. Each new key that is defined is stored
in its own alternate index file.
An alternate index file is specified in the File Specifications exactly like an EFS indexed
file or a BFS indexed file. Although alternate index files are used and accessed like
indexed files, they have the following additional features:
• Alternate index files can be created for EFS sequential and direct files. If either an
EFS sequential or direct file needs to be accessed by a field in each record, alternate
index files can be created to access the data file by using alternate keys. Each
alternate index file defines one alternate key.
The application then can process the EFS sequential file randomly by key, while still
retaining the ability to process the file consecutively or randomly by relative record
number. SYSTEM/KEYEDIOII/UTILITY must be used to create an alternate index file.
Sequential and direct files do not have primary keys. After the alternate index file for
an EFS sequential or direct file is created, the data file retains the basic
characteristics and properties of either an EFS sequential file or direct file.
• The key defined for an alternate index file can be either a single field or up to three
noncontiguous fields. Each alternate index file uses one or more parts of a record to
define a key. If the key comes from noncontiguous fields, the Key Field Starting
Location field (columns 35–38) in the File Specifications must contain the letters
EXTK. The Record Address Field Length field (columns 29–30) is used to define the
total length of all parts of the key. Fields of a noncontiguous key must not overlap.
• Alternate index files can be removed or re-created without destroying records in the
data file; however, if a data file is opened for processing after an alternate index file
was removed, the system waits until an alternate index file with the same title
becomes available. If this occurs, the program must be ended and
SYSTEM/KEYEDIOII/UTILITY must be run to re-create the alternate index file. Then
the program is run again.
• When a file is updated, the keys in all associated alternate index files are also
updated. For example, suppose that a program reads a record and changes a field in
it. When the record is written back to the data file, all associated alternate index files
are also updated by the system. As the number of alternate index files increases,
system performance degrades.
An attribute is specified in the program and its values is assigned at compile time. The
$KEYEDIOIIOUTPUT compiler control option must be TRUE for EFS attributes to be
assigned their values.
The coding required for the EFS file attributes is described on the following pages.
ALLOCATION Attribute
The ALLOCATION attribute is required only for EFS files. The ALLOCATION attribute
must be specified when an EFS file is created. The value of this attribute describes how
many records can initially be stored in a file when it is created. For example, if the
ALLOCATION attribute of a file is 10 records, then 10 records can be stored in the file
before it becomes full, at which time the file must be extended before any additional
records can be stored.
The value for the ALLOCATION attribute is designated in the Attribute Specifications. For
example, if ALLOCATION 1000 is coded in the Attribute Specifications and a direct file is
being created, then the direct file initially contains enough disk space to hold 1000
records. The value is in units of records, not blocks. If the value is not specified, the
default value is 0. For more information on the ALLOCATION attribute, refer to the
discussion of creating disk files in this section.
DELETE-CAPABLE Attribute
The DELETE-CAPABLE attribute is valid only for EFS files. DELETE-CAPABLE is specified
TRUE by entering a D in the Delete-Capable field (column 69) of the File Specifications
when the EFS file is created. When the DELETE-CAPABLE attribute is TRUE, the
program can delete records from the file and reuse the space. The value of the DELETE-
CAPABLE attribute cannot be changed after the file has been created. The default value
of the DELETE-CAPABLE attribute is FALSE.
EXTEND Attribute
The EXTEND attribute is valid only for EFS files. EXTEND can be specified either when a
file is created, or after a file is created. The value of EXTEND is always described in units
of records. The value of the EXTEND attribute describes how many records of additional
space to give to a file. This additional space is called the extend area. For example, if a
file has an EXTEND value of 5, space is made for five additional records each time the file
needs to be extended. An EXTEND value of 0 indicates that the file cannot be extended.
The default value of EXTEND is 0. EXTEND is examined by the system each time the file
is opened. If a value for EXTEND is not specified when a file is opened, a value of 0 is
assumed.
The value for the EXTEND attribute is designated in the Attribute Specifications. For
example, if EXTEND 100 is coded in the Attribute Specifications, room for 100 additional
records is added. For more information on the EXTEND attribute, refer to the discussion
of creating disk files in this section.
Example
Example 4–1 shows how an EFS direct file DIRDISK is created with an ALLOCATION
attribute of 10 records and an EXTEND attribute area of 5 records.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01500F*
02000F* The compiler control option $KEYEDIOIIOUTPUT must be TRUE to
03000F* create an EFS file.
03500F*
04000FDIRDISK OC 400 80R DISK
05000A*
06000A* The Attribute Specifications for a file must immediately
07000A* follow its File Specifications. The following two Attribute
08000A* Specifications indicate that DIRDISK will have an EXTEND
09000A* area of 5 and an ALLOCATION of 10. A value must be specified
09500A* for ALLOCATION when an EFS disk file is created.
10000A*
11000A ALLOCATION 10
12000A EXTEND 5
13000F*
14000FINPUT IPE 80 80 DISK
15000IINPUT AA 01
16000I 1 50DIRKEY
17000I 1 70 DATA
18000C DIRKEY CHAINDIRDISK 99
19000ODIRDISK D 01
20000O DATA 70
The organization of a disk file is specified by RPG syntax when the file is created. It is
important to consider the organization of a file before writing a program to read or modify
the file.
Sequential Organization
Records in sequential files are organized chronologically according to the order in which
each record is placed in the file. For example, the first record written to the file is placed
in the first record position, the second record written to the file is placed in the second
record position, and so on.
Records in sequential files can be accessed sequentially, randomly, or both randomly and
sequentially. Refer to the discussion of disk file processing in this section for more
information.
A sequential file is best suited for an application that processes a file in order, from
beginning to end. Figure 4–2 illustrates the organization of a sequential file.
There are differences between BFS and EFS sequential files in terms of the location of
added records. Following is a summary of those differences:
Direct Organization
Files that have a direct organization are called direct files. In a direct file, records are
assigned specific record positions, regardless of the chronological order in which they are
placed in the file. Relative record numbers specify the position of each record in the file in
relation to the beginning of the file as shown in the following figure.
Records in direct files can be accessed sequentially, randomly, or both randomly and
sequentially. For more information, refer to “Disk File Processing” in this section.
Figure 4–3 illustrates the organization of a direct file.
Direct files are useful for applications in which unordered transactions are processed and
an immediate inquiry capability is required.
There are differences between BFS and EFS direct files in terms of record processing.
Following is a summary of those differences:
Indexed Organization
It is important to understand the structure of indexed files before using them. Note that
an indexed file is composed of the following two files:
The key fields are sorted so that they are in ascending order. The key fields in the records
are described when the indexed file is declared. Refer to the discussion of the Record-
Address Field Length field (columns 29–30) and the Key Field Starting Location
(columns 35–38) field in Section 8, “File Description Specifications,” for more
information.
The primary key in a record cannot be modified. If alternate keys exist, they can be
changed, except when the file is processed by addrout. If an invalid key modification
occurs, an ATTEMPT TO MODIFY A PRIMARY KEY WITH A REWRITE error message is
displayed. Refer to Appendix A, “System Messages,” for an explanation of the error.
Once an indexed file is created, none of the attributes of the key can be changed when
the file is subsequently accessed. At run time, coded key information is checked. If it is
not correct, a run-time RECORD KEY MISMATCH error message is displayed. Refer to
Appendix A, “System Messages,” for information about the error.
The advantage of an indexed file is that the indexes enable the program to locate data
records quickly by key without searching sequentially through the file. Indexed files also
make it possible to retrieve records either randomly or within specified ranges.
BFS and EFS indexed files have the following different requirements for specifying
alternate keys and group keys. A group key is composed of multiple, noncontiguous key
fields. The key fields are concatenated to form a key for accessing files. Duplicate
primary keys cannot be used for BFS and EFS indexed files.
The File Specifications must contain the following information for a disk file to be
created:
• The File Type field (column 15) must contain the letter O to indicate that records are
to be written to the file.
• The Block Length and Record Length fields (columns 20–27) are used to specify the
number of characters contained in each record and block of the file. After a file has
been created, its record length cannot be changed.
Records are grouped together on disk in entities called blocks. Grouping records this way
makes the system run faster by reducing I/O operations. The Block Length field
(columns 20–23) must be a multiple of the Record Length field (columns 24–27). For
example, if the record length is 80 characters, an acceptable block length is 640
characters (because 80 * 8 = 640). In general, when a file is processed consecutively, the
execution time improves as the block length increases. If the Block Length field is not
specified, the system chooses a block length.
For EFS files only, the file attributes described in the following list are specified when the
file is created:
• The ALLOCATION attribute designates the number of records that are stored in the
file when the file is full. For example, if ALLOCATION is 10, then 10 records can be
stored in the file before it becomes full. This attribute must be specified.
• The EXTEND attribute identifies the number of additional records to assign to a file if
the file is extended when it becomes full. For example, if EXTEND is 2, space for two
records is added to the end of the file each time it becomes full.
• The DELETE-CAPABLE attribute, when specified, enables records to be deleted from
a file.
The RECORDLEVELLOCK attribute is allowed for all EFS files and BFS indexed files.
Refer to “Freeing Locked Records” later in this section.
The following pages show many examples of creating BFS and EFS sequential, direct,
and indexed files.
• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) and the File Organization Type field
(column 32) must be blank.
• The Record Length field (columns 24–27) must indicate how long each record will be
in the new file.
• The Device field (columns 40–46) must contain DISK.
Example
Example 4–2 shows the creation of a BFS sequential file called SEQ. The records in SEQ
are 80 characters long. Records are read from two files, NAMEFIL and ADDRFIL. Fields
are extracted from records in NAMEFIL and ADDRFIL, and combined to form SEQ.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FNAMEFIL IP 540 60 DISK
02000FADDRFIL IS 160 40 DISK
02500F*
03000F* Column 15 must contain the letter O to create a sequential
04000F* file. Column 16 (File Designation) and column 32 (File
05000F* Organization) must both be blank. Columns 24-27 (Record
06000F* Length) indicate that the records of SEQ are 80 bytes long
07000F* and blocked so that each block has three records (240/80=3).
07500F*
08000FSEQ O 240 80 DISK
09000INAMEFIL NS 01
10000I 2 8 EMPNO
11000I 10 29 NAME
12000IADDRFIL NS 02
13000I 2 8 EMPNO
14000I 10 39 ADDR
14500O*
15000O* The NAME and ADDR fields are extracted from NAMEFIL and
16000O* ADDRFIL. They are used to build the output record for SEQ.
16500O*
17000OSEQ D 02
18000O EMPNO 8
19000O NAME 28
20000O ADDR 58
• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) and the File Organization Type field
(column 32) must be blank.
• The Record Length field (columns 24–27) must indicate how long each record will be
in the new file.
• The Device field (columns 40–46) must contain DISK.
In addition, for EFS files, a value must be provided for the ALLOCATION attribute.
Specifying values for the EXTEND and DELETE-CAPABLE attributes is optional. Values
for the ALLOCATION, EXTEND, and DELETE-CAPABLE attributes are specified
programmatically in conjunction with the $KEYEDIOIIOUTPUT compiler control option.
Example
Example 4–3 shows how to create an EFS sequential disk file. The $KEYEDIOIIOUTPUT
compiler control option must be TRUE, the ALLOCATION and EXTEND attributes are
assigned using Attribute Specifications, and the DELETE-CAPABLE attribute is assigned
using the Delete-Capable field (column 69) of the File Specifications.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01500F*
02000F* The compiler control option $KEYEDIOIIOUTPUT must be TRUE
03000F* to create an EFS disk file. To create a sequential file,
04000F* the file is declared as an output file and column 16 (File
05000F* Designation) is blank. SEQ is delete-capable as indicated by
06000F* the D in column 69 (Delete-Capable field).
07000F*
08000FSEQ O 240 60 DISK D
09000A*
10000A* The Attribute Specifications for a file must immediately
11000A* follow the File Specifications. The following two Attribute
12000A* Specifications indicate that SEQ will have an EXTEND
13000A* area of 100 records and an ALLOCATION of 1200 records.
13500A* A value for ALLOCATION is required when an EFS disk
13250A* file is created.
14000A*
15000A ALLOCATION 1200
16000A EXTEND 100
17000F*
18000FNAMEFIL IP F 540 60 DISK
19000FADDRFIL IS F 160 40 DISK
20000INAMEFIL NS 01
21000I 2 8 EMPNO
22000I 10 29 NAME
23000IADDRFIL NS 02
24000I 2 8 EMPNO
25000I 10 39 ADDR
25500O*
26000O* The NAME and ADDR fields are extracted from NAMEFIL and
27000O* ADDRFIL. They are used to build the output record for SEQ.
27500O*
28000OSEQ D 02
29000O EMPNO 8
30000O NAME 28
31000O ADDR 58
• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) must contain the letter C.
• The Processing Mode field (column 28) must contain the letter R to indicate that the
file is processed randomly by relative record number.
• The Device field (columns 40–46) must contain DISK.
When a direct file is created, the CHAIN operation code is used with a relative record
number in Factor 1 to select a record location in the file. The record is then written to that
record location as defined in the Output Specifications.
Example
Example 4–4 shows the use of the CHAIN operation to create a BFS direct file.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F* When a direct file is created, the file must be defined as
02000F* an output chained file in columns 15 and 16, respectively.
03000F* Also, an R must be in the Processing Mode field (column 28).
04500F*
05000FDIRDISK OC 400 80R DISK
06000FINPUT IPE 80 80 DISK
07000IINPUT AA 01
08000I 1 50 DIRKEY
09000I 1 70 DATA
09500C*
10000C* The CHAIN operation code is used to select a record
11000C* position in the file based on the numeric value of DIRKEY.
13000C*
14000C DIRKEY CHAINDIRDISK
14500C*
15000O* The output goes to the record selected by the CHAIN.
15500O*
16000ODIRDISK D 01
17000O DATA 70
• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) must contain the letter C.
• The Processing Mode field (column 28) must contain the letter R to indicate that the
file is processed randomly by relative record number.
• The Device field (columns 40–46) must contain DISK.
In addition, for EFS direct files, a value must also be specified for the ALLOCATION
attribute. Values for the EXTEND and DELETE-CAPABLE attributes are optional. More
information on the ALLOCATION, EXTEND, and DELETE-CAPABLE attributes is provided
in the discussion of EFS disk file attributes in this section.
When an EFS direct file is created, the number of records initially in the file is determined
by the value of the ALLOCATION attribute. If the file is delete-capable, all records are
initially marked as deleted. If the file is not delete-capable, all records are automatically
initialized to blanks.
Deleted records occupy space in the file, but they cannot be read. An attempt to use the
CHAIN operation to read a deleted record results in a Not Found condition. When a file is
read sequentially, using a cycle-driven file or the READ operation, deleted records are
skipped.
Deleted records cannot be read with the CHAIN operation; instead, a relative record
number is entered in the RECNO field to indicate the position of the output record in the
file. Records can be written only to positions in the file containing deleted records.
Records can be written at exception, total, or detail output time. The RECNO field is
specified on a File Specifications continuation line. For more information on fields in
continuation lines, refer to Section 8, “File Description Specifications.”
Example
Example 4–5 shows how to use a RECNO continuation line to create an EFS direct file
that is delete-capable. The file must be specified as an output file in the File Type field
(column 15). In addition, the Processing Mode field (column 28) must contain the letter R.
The R indicates that the file is processed randomly by relative record number.
Additionally, a RECNO continuation line record must follow the File Specifications record.
This continuation line must have a K in column 53, followed by RECNO in columns 54
through 58. The RECNO identifier is placed in columns 60 through 65. This identifier
must be defined as a 7-digit numeric field with zero decimal positions. A relative record
number must be placed in this field. The system uses the value of the RECNO identifier
to determine the location to store the record in the file when the output occurs.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00400$SET KEYEDIOIIOUTPUT
00500FINFILE IP 80 80 DISK
00600F*
01000F* When a delete-capable EFS direct file is created,
02000F* the file must be defined as an output file (column 15)
03000F* that is processed randomly by relative record number
04000F* (an R in column 28). In addition, the file must have
05000F* a RECNO continuation line immediately following the main
05100F* file description.
05500F*
06000FDIRDISK O 80 80R DISK D
06500F*
07000F* The following line is a RECNO continuation line. A K in
08000F* column 53 denotes a continuation line. CUSTNO is the
09000F* RECNO identifier.
09500F*
10000F KRECNO CUSTNO
10500A ALLOCATION 1000
10800A EXTEND 200
11000IINFILE 011 98 1 C1
12000I 2 80CUSTNO
13000I 10 29 NAME
14010I 021 99 1 C2
15000I 2 39 DATA
15500O*
16000O* The record is output to the record specified by the value
17000O* of the RECNO identifier CUSTNO.
17500O*
18000ODIRDISK D 99
20000O NAME 28
21000O DATA 68
When a direct file is created, the file must be specified in the File Specifications as
output and chained (in columns 15 and 16, respectively). In addition, an R must be in the
Processing Mode field (column 28). The R indicates that the file is processed randomly
by a relative record number.
The CHAIN operation code is used with a relative record number in Factor 1 to select the
desired record location in the file. The record is then sent to the selected location as
defined in the Output Specifications.
Example
Example 4–6 shows the creation of a direct file that is not delete-capable; that is, the
DELETE-CAPABLE attribute is FALSE. The $KEYEDIOIIOUTPUT compiler control option
must be TRUE. The ALLOCATION and EXTEND attributes are designated in the Attribute
Specifications. All records are automatically initialized to blanks because the file is not
delete-capable. When a blank record is read with the CHAIN operation, the next output
operation updates that record, as specified by the Output Specifications. If a record is not
found with the CHAIN operation, indicator 30 turns on, and no output occurs.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300$SET KEYEDIOIIOUTPUT
00500FINFILE IP 80 80 DISK
01000F* When an EFS direct file is created, the file must be
02000F* defined as an output chained file in columns 15 and 16,
03000F* respectively. An R must be in column 28 (Processing Mode).
04500F*
06000FDIRDISK OC 80 80R DISK
06500A ALLOCATION 1000
06800A EXTEND 200
08000IINFILE 011 98 1 C1
09000I 2 80CUSTNO
10000I 10 29 NAME
11000I 021 99 1 C2
12000I 2 39 DATA
12500C*
13000C* CHAIN is used to read a record randomly by relative record
14000C* number. If a record is not found, indicator 30 turns on.
14500C*
15000C 99 CUSTNO CHAINDIRDISK 30
16100O*
16200O* If the CHAIN successfully reads a blank record, the contents
16300O* of the record are updated and written back to the file.
16400O*
17000ODIRDISK D 99N30
18000O CUSTNO 8
19000O NAME 28
20000O DATA 68
• The file must be an output file with a blank in the File Designation field (column 16).
• The File Organization Type field (column 32) must contain an I to indicate that the file
is an indexed file.
• All key fields must be defined when the file is created. The Key Field Starting
Location field (columns 35–38) defines the position in the record where the key field
begins.
• The Record-Address Field Length field (columns 29–30) defines the length of the key.
• The Record-Address Type field (column 31) describes whether the key is
alphanumeric or numeric.
There should be a key description for each alternate key. All alternate key descriptions
follow the main file description. For more information on describing multiple index keys
for BFS indexed files, refer to Section 8, “File Description Specifications.”
Example
Example 4–7 shows a program that reads records from a file called EMPDATA and
creates an BFS indexed file called INXDISK. The records in EMPDATA are not in primary
key order, so the File Addition/Unordered field (column 66) of INXDISK must contain a U.
Otherwise, records are written out of primary key order and a KEY OUT OF SEQUENCE
error can occur. Refer to Appendix A, “System Messages,” for more information on the
error. INXDISK contains two keys. The primary key is in packed decimal format and is
based on the CUSTNO field. The alternate key is in alphanumeric format and is based on
the ADDR field.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FEMPDATA IP 80 80 DISK
02000F* When an indexed file is created, column 15 must contain the
03000F* letter O, and column 16 (File Designation) must be blank.
04000F* Note the I in column 32 (File Organization). Column 66
05000F* contains a U because the records to be written to INXDISK
06000F* are not in primary key order. Note that the key starts in
07000F* position 2 of the record, and is 7 bytes long. The P in
08000F* column 31 indicates that the key is stored in packed decimal
08250F* format. (Seven bytes packed is 14 digits.)
08500F*
09000FINXDISK O 80 80 7PI 2 DISK U
09500F*
10000F* The following line describes the alternate key. The key
11000F* starts in column 29 and is 30 positions long. The A in
12000F* column 31 indicates that the key is in alphanumeric format.
12500F*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
13000F KEY 30A 29
14000IEMPDATA 011 98 1 C1
15000I 2 150CUSTNO
16000I 16 35 NAME
17000I 021 99 1 C2
18000I 2 150CUSTNO
19000I 16 45 ADDR
20000OINXDISK D 99
21000O CUSTNO 8P
22000O NAME 28
23000O ADDR 58
• The file must be an output file with a blank in the File Designation field (column 16).
• The File Organization Type field (column 32) must contain an I to indicate that the file
is an indexed file.
• Only the primary key is defined when an EFS indexed file is created.
• The Key Field Starting Location field (columns 35–38) defines the position in the
record where the primary key field begins.
• The Record-Address Field Length field (columns 29–30) defines the length of the
primary key.
• The Record-Address Type field (column 31) describes whether the key is
alphanumeric or numeric.
• If alternate keys for the file are necessary, they must be created separately with
SYSTEM/KEYEDIOII/UTILITY.
When any kind of EFS disk file is created, the ALLOCATION attribute must be specified.
The EXTEND and DELETE-CAPABLE attributes are optional. These attributes are set
programmatically in conjunction with the $KEYEDIOIIOUTPUT compiler control option.
Unlike BFS indexed files, EFS indexed files can have group keys. Group keys must be
specified with the KEYEDIOII utility when the file is created. For more information about
creating a file that enables group keys, refer to the discussion about the Add Index
screen in the KEYEDIOII Programming Reference Manual.
Example
Example 4–8 shows how to create an EFS indexed file. Values for the ALLOCATION,
EXTEND, and DELETE-CAPABLE attributes are assigned at compile time. For these
attributes to be assigned at compile time, the compiler control option
$KEYEDIOIIOUTPUT must be TRUE. Values for ALLOCATION and EXTEND are assigned
in the Attribute Specifications, and the value for DELETE-CAPABLE is assigned by putting
a D in column 69 in the File Specifications for the file. The program reads records from a
file called EMPDATA. The records in EMPDATA are already in primary key order, so the
File Addition/Unordered field (column 66) is blank. The primary key of INXDISK is in
alphanumeric format and is based on the NAME field.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100$SET KEYEDIOIIOUTPUT
00200F*
00300F* When $KEYEDIOIIOUTPUT is TRUE, all disk files
00400F* created in the program are EFS files.
00500F*
01000FEMPDATA IP 80 80 DISK
01500F*
01800F* When the indexed file called INXDISK is created, column 15
02000F* must contain the letter O, and column 16 (File Designation)
03000F* must be blank. Also, an I must be specified in column 32
04000F* (File Organization). Column 66 contains a blank because
05000F* the records being written to INXDISK are already in primary
06000F* key order. Note that the key starts in position 9 of the
07000F* record and is 20 positions long. The A in column 31 indicates
08000F* the key is stored in alphanumeric format. The D in column
09000F* 69 indicates that the file is delete-capable.
10000F*
11000FINXDISK O F 80 80 20AI 9 DISK D
12000A*
13000A* The ALLOCATION and EXTEND attributes for an EFS file follow
14000A* immediately after the File Specifications for the file.
16000A*
17000A ALLOCATION 100
18000A EXTEND 50
19000A*
20000IEMPDATA 011 98 1 C1
21000I 2 80CUSTNO
22000I 10 29 NAME
23000I 021 99 1 C2
24000I 2 80CUSTNO
25000I 10 39 ADDR
26000OINXDISK D 99
27000O CUSTNO 8
28000O NAME 28
29000O ADDR 58
• Consecutive
• Sequential-by-key
• Sequential-within-limits
• Random (which includes processing by addrout)
• Random-by-key
It is important not to confuse the way a file is processed with the way it is organized. A
file that is organized sequentially can still be processed either randomly by relative record
number or consecutively. Likewise, a direct file can be processed consecutively or
randomly by relative record number.
In general, EFS and BFS files are processed in the same manner.
The data records of an indexed file can be processed consecutively. For indexed files,
consecutive processing ignores the index and accesses records in the order in which
they physically appear in the file, starting from the beginning of the file. The records are
not guaranteed to be in any particular order. To process an indexed file consecutively, the
indexed file is defined as an input file with a blank in the File Organization Type field
(column 32). The indexed file can be designated as primary, secondary, demand, or full-
procedural. Refer to the discussion of sequential-by-key file processing in this section for
information on retrieving records sequentially by key.
Example
Example 4–9 shows consecutive file processing. SEQDISK is a sequential file declared as
the primary file. The PLC reads the file consecutively. DIRDISK is a demand direct file
that is read consecutively with the READ operation in the Calculation Specifications. In
this example, a record read from the primary file is used to update the record read from
the demand file.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00500F* By designating SEQDISK as a primary file, the program reads
00550F* consecutively using the PLC.
00600F*
00800FSEQDISK IP 80 80 DISK
00805F*
00810F* Designating DIRDISK as a demand file causes the program to
00820F* read consecutively using the READ operation.
00850F*
00900FDIRDISK UD 80 80 DISK
01100ISEQDISK AA 01
01200I 1 50AMT1
01400IDIRDISK BB 02
01410I 2 80AMT2
01500C 01 READ DIRDISK 36
01550C*
01600C* Calculate a new value for AMT2.
01650C*
01700C 01 02 AMT1 ADD AMT2 AMT2
01750C*
01800O* Update DIRDISK with new value of AMT2.
01850O*
01900ODIRDISK D 01 02
02000O AMT2 8
Example
Example 4–10 shows an indexed file processed consecutively. The indexed file, INXDISK,
is designated as full-procedural. Records are read with the READ operation in the
Calculation Specifications. When a record is read from INXDISK, its contents are
displayed on the ODT with the file SCREEN.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00490F*
00500F* INXDISK is an indexed file treated like a sequential file. For
00510F* this to occur, column 32 must be blank. If column 32 contained
00520F* an I, the records would be retrieved sequentially by key.
00530F* Note that the rest of the primary key description is also empty.
00540F*
00800FINXDISK IF 180 60 DISK
00840F*
00850F* SCREEN displays the contents of each record on the ODT.
00860F*
00900FSCREEN D ODT
01100IINXDISK AA 01
01200I 1 60 REC1
01300C LOOP TAG
01400C READ INXDISK LR
01500C NLR REC1 DSPLYSCREEN
01600C NLR GOTO LOOP
Example
Example 4–11 shows sequential-by-key file processing. INDX1 and INDX2 are both
indexed files. The letter I in the File Organization field (column 32) of the File
Specifications indicates that the files are read in key order.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00020F* INDX1 is an indexed file. It is the primary file and is
00030F* processed sequentially by key using the PLC. For an indexed
00040F* file to be processed sequentially by key, the file description
00050F* must contain a description of the key.
00060F*
00300FINDX1 IP A 80 80 6AI 1 DISK KEY1
00400F*
00500F* INDX2 is also an indexed file, but it is processed
00600F* sequentially by key using the READ operation code. The
00700F* key of the file must be described, and column 32 must
00800F* contain an I.
00900F*
00910FINDX2 UD A 132 132 5AI 1 DISK KEY2
00920IINDX1 AA 01
00930I 11 150FIELD1
00940I 16 200FIELD2
00950I 23 25 FIELD3
01000IINDX2 BB 02
01100I 11 170AMT1
01200I 20 22 NAME
01300C 01 READ INDX2 20
01500C 01 FIELD1 ADD FIELD2 TOTAL 100
01550C 01N20 NAME COMP FIELD3 03
01600C 01 03N20AMT1 ADD TOTAL TOTAL
01800OINDX2 D 01 03N20
01900O FIELD1 15
02000O FIELD2 25
02100O FIELD3 35
02200O TOTAL 45
Alternate index files, like indexed files, can be processed sequentially by key.
When a file is processed using an alternate index file, the alternate index file, not the data
file, is specified in the RPG program.
Example
Example 4–12 shows an indexed file that is processed sequentially by key. The alternate
index file used is called ALTINX. The records in the indexed file contain an employee
number (EMPNO) and the name of the employee (NAME), as well as other information
that is not used. The employee name is the primary key for the indexed file.
ALTINX reads the indexed file. The indexed file itself is not specified in the program.
ALTINX contains the alternate key based on an employee number.
The File Specifications for the alternate index file are the same as for an indexed file. The
program reads from the file ALTINX. The program returns the data records of the indexed
file, in order of employee number. As the records are read sequentially by key they are
written to a printer file.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F* Note that the alternate index file is treated just like an
00200F* indexed file. The letter I is in column 32. The alternate
00300F* index file must have the same record size as that of the data
00400F* file. The length of the alternate key is specified in columns
00500F* 29-30, and the starting position in columns 35-38.
00550F*
00600FALTINX IF 80 80 6AI 32 DISK
00700FPRINT O 132 132 PRINTER
00800IALTINX AA 01
00900I 1 30 NAME
01000I 32 37 EMPNO
01100I 40 80 ADDR
01150C*
01160C* Because ALTINX is designated as a full-procedural file, the
01200C* READ operation is used to read ALTINX sequentially by key.
01250C*
01300C READ ALTINX LR
01400C NLR EXCPTPRINT
01500OPRINT E 01
01600O EMPNO 6
01700O NAME 37
01800O ADDR 80
Up to three noncontiguous fields can be used as the key for an alternate index file. The
following entries in the File Specifications are required when noncontiguous fields are
used as the key for an alternate index file:
• The Record-Address Field Length field (column 29–30) must contain the total length
of all fields that define the key. For example, if the key consists of positions 1
through 6, 10 through 12, and 20 through 30 of the data record, then the total length
of the key is 20. The fields of the key must not overlap.
• The Record-Address Type field (column 31) must contain an A for an alphanumeric or
zoned-decimal key.
• The Key Field Starting Location field (columns 35–38) must contain EXTK to indicate
that a key has noncontiguous fields.
Example
Example 4–13 shows an alternate index file (ALT1) with noncontiguous keys. The code is
a modification of the example presented in Example 4–12. ALT1 uses positions 40
through 80 and positions 1 through 11 of the data record as the key.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F* Because ALT1 has a noncontiguous key, EXTK is designated in
00200F* columns 35-38. Column 31 must contain an A if the key is
00300F* noncontiguous. Columns 29-30 contain the total length of
00400F* the key.
00450F*
00500FALT1 IF 80 80 52AI EXTK DISK
00600FPRINT O 132 132 PRINTER
00700IALT1 AA 01
00800I 1 30 NAME
00900I 32 37 EMPNO
01000I 40 80 ADDR
01100I 1 80 REC
01150C*
01200C* Use the READ operation to read ALT1 sequentially by key.
01250C*
01300C READ ALT1 LR
01400C NLR EXCPTPRINT
01500OPRINT E 01
01600O REC 80
• Limits file
• SETLL operation
It is not possible to process the same file with both methods in the same program. Only
indexed and alternate index files can be processed sequentially within limits.
A limits file is a record-address file containing limits. It can be used only to process an
indexed file or an alternate index file designated as a primary, secondary, demand, or full-
procedural file. Each record of the limits file contains a pair of key values: a lower key
limit and an upper key limit.
When a data file is processed using a limits file, the following actions occur:
• Each record is read from the limits file. The lower and upper limits are set according
to the values of the record that are read.
• All records with keys greater than, or equal to, the lower limit and less than, or equal
to, the upper limit are read from the indexed or alternate index file in ascending key
sequence.
• When the upper key limit is exceeded, the next record that contains the next set of
limits is read from the limits file and processing of the indexed or alternate index file
continues. Records are read in this way until either the limits file reaches EOF or the
program ends.
The limits file has the following format restrictions:
Example
Example 4–14 shows sequential-within-limits file processing with a limits file. An indexed
file INXDISK is processed with the limits file LIMIT.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00190F*
00200F* INXDISK is processed using a limits file. Note the
00210F* L in the Processing Mode field.
00220F*
00290FINXDISK IP 80 80L 6AI 1 DISK
00300F*
00310F* LIMIT is the limits file. Note that column 16 contains
00320F* an R indicating that the file is a record-address file.
00330F* Also, E must be specified in column 39 to indicate that
00340F* the file is described in the Extension Specifications.
00350F*
00400FLIMIT IRE 80 80 6A EDISK
00490FPRINT O 132 132 PRINTER
00500E*
00510E* The limits file is associated with the file to be processed
00520E* sequentially within limits by using Extension Specifications.
00530E*
00550E LIMIT INXDISK
00600IINXDISK AA 01
00700I 11 150FIELD1
00800I 16 200FIELD2
00900I 23 280FIELD3
01800OPRINT D 01
01900O FIELD1 15
02000O FIELD2 25
02100O FIELD3 35
The fields listed in Table 4–1 are coding options in the File Specifications for an indexed
file or an alternate index file processed sequentially within limits.
The fields listed in Table 4–2 must be coded in the File Specifications for the limits file
used with an indexed or alternate index file.
The fields listed in Table 4–3 must be coded in the Extension Specifications when a limits
file is used.
11–18 From Filename The name of the limits file must be specified as it
appears in the File Specifications.
19–26 To Filename The name of the indexed or alternate index file
associated with the limits file must be specified as it
appears in the File Specifications.
The SETLL operation can also be used to process indexed files and alternate index files
sequentially within limits. The file must be designated as demand or full-procedural. The
lower key limit is set with the SETLL operation code in the Calculation Specifications. The
highest key value in the file is automatically treated as the upper key limit. The lower limit
can be changed either before or after the upper limit is reached. When the SETLL
operation is used, a limits file cannot be used. A CHAIN operation destroys the current
lower limit.
Processing an alternate index file sequentially within limits with the SETLL operation
uses the same method as the CHAIN operation of loading the key field in Factor 1 if the
key has noncontiguous fields.
Records are read in ascending key sequence, starting from the lower limit specified by
the SETLL operation. After each SETLL operation, records are read in ascending
sequence starting at the new lower limit. If a READ operation occurs before the first
SETLL operation, the record with the lowest key is read first. The file is processed
sequentially by key until a SETLL operation occurs.
The data file is at EOF when the record with the highest key is read. If another READ
operation occurs before a SETLL operation, the condition is treated like any other EOF
condition occurring on a READ operation.
Example
Example 4–15 shows sequential-within-limits file processing using the SETLL operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00240FINPUT IP 80 80 DISK
00250F*
00260F* INXDISK is an indexed file processed sequentially within
00270F* limits using the SETLL operation. Note that L is specified
00280F* in the Processing Mode field.
00290F*
00300FINXDISK ID 80 80L 6AI 1 DISK
00500FPRINT O 132 132 PRINTER
00610IINPUT AA 01
00620I 2 60AMT
00630I 10 151LOW
00700IINXDISK BB 02
00800I 11 150FIELD1
00900I 16 200FIELD2
00990I 23 280FIELD3
01000C*
01010C* SETLL sets the lower limit so that the following READ
01020C* operation reads the indexed file sequentially within limits.
01030C*
01050C 01 LOW SETLLINXDISK
01060C 01 READ INXDISK
01100C 01 02 FIELD1 ADD FIELD2 TOTAL 80
01300OPRINT D 01
01400O TOTAL 15
Example 4–15. Processing an Indexed File with the SETLL Operation Code
The fields listed in Table 4–4 must be coded in the File Specifications when the SETLL
operation code is used to process an indexed file or an alternate index file sequentially
within limits.
continued
Relative record numbers can be used to select records in sequential, direct, and indexed
files. A relative record number identifies the position of the record in the file relative to
the beginning of the file. For example, the relative record numbers for the first, third,
seventh, and eighth records are 1, 3, 7, and 8, respectively.
The CHAIN operation code in the Calculation Specifications is used to read randomly by
relative record number. Factor 1 specifies the relative record number. Factor 2 contains
the name of the file to be read randomly. The file must be designated as chained,
demand, or full-procedural. For more information, refer to the discussion of File
Designation field (column 16) in Section 8, “File Description Specifications.”
Indexed files also can be processed randomly using relative record numbers. The file
must be designated as a demand, a chained, or a full-procedural file, and column 32 of
the File Specifications must be blank. Refer to the discussion of the File Organization
Type field (column 32) in Section 8, “File Description Specifications,” for more
information. If a program treats an indexed file as a nonindexed file, then the file can be
accessed by relative record numbers and all indexes are ignored.
Example
Example 4–16 shows the processing of a sequential, a direct, and an indexed file
randomly by relative record number. The primaryfile contains a list of employee numbers
that are used as relative record numbers to read the HOURS, WAGE, and YRPAY files.
MAST and YRPAY are updated with new pay totals. HOURS is a sequential file
containing the number of hours worked by an employee during the week. WAGE is a
direct file that contains the hourly wages of the employees. YRPAY is an indexed file that
contains the year-to-date pay.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200FMAST UP 80 80 DISK
00290F*
00300F* Designate HOURS as a chained file. It is read using
00310F* the CHAIN operation.
00320F*
00390FHOURS IC 80 80 DISK
00400F*
00410F* Designate WAGE as a full-procedural file. It can be
00420F* processed randomly or consecutively.
00430F*
00450FWAGE UF 80 80 DISK
00490F*
00500F* Designate YRPAY (an indexed file) as a demand file. Like
00510F* full-procedural files, demand files can also be processed
00520F* randomly or sequentially. Note that column 32 is blank
00530F* so that the index is ignored.
00540F*
00550FYRPAY UD 80 80 DISK
00600IMAST AA 01
00700I 1 40EMPNO
00800I 10 172PAY
00815IHOURS BB 02
00820I 5 70HRS
00900IWAGE CC 03
01000I 1 62WAGE1
01010IYRPAY DD 04
01100I 10 202YRPY
01105C*
01110C* EMPNO contains the employee number that is used as a
01115C* relative record number to CHAIN to the correct record
01120C* IN HOURS, WAGE, AND YRPAY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01130C*
01200C 01 EMPNO CHAINHOURS
01300C 01 EMPNO CHAINWAGE 99
01310C 01 EMPNO CHAINYRPAY
01400C 02 03 04HRS MULT WAGE1 PAY
01500C 02 03 04PAY ADD YRPY YRPY
01600C 02 03 04 EXCPTYRPAY
01800OMAST D 02 03 04
01900O PAY 17
02000OYRPAY E
02100O YRPY 20
An indexed file or an alternate index file can be processed randomly with a key value.
Each record in an indexed file has a field that is designated as the key field. Each key
identifies a record in the file, and the key can be used to access that record randomly.
For an indexed or alternate index file to be processed randomly by key, the file must be
designated as a demand, chained, or full-procedural file. The CHAIN operation code in the
Calculation Specifications is used to read randomly by key. Factor 1 contains the value of
the key. Factor 2 contains the name of the file to be read. For indexed files with multiple
keys, the Result Field (columns 43–48) of the CHAIN operation specifies the name of the
key that is used. If an indexed file has only one key, the Result Field of the CHAIN
operation does not need to be specified.
Example
Example 4–17 shows an indexed file, INXDISK, that is processed randomly by key. This
program reads a master file, MAST, which contains records with employee names and
numbers and verifies that the data in INXDISK is correct. Each record in INXDISK
contains an employee number, the name of the employee, and other information about
the employee. The file has two keys. The primary key is the employee number. The
alternate key is the employee name.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FMAST IP 240 80 DISK
00350F*
00410F* Write any discrepancies between MAST and INXDISK
00420F* to the printer file.
00430F*
00450FPRINT O 132 132 PRINTER
00470F*
00500F* Designate INXDISK (an indexed file) as a chained file.
00510F* Note that the primary key is named EMPKEY, and that the
00520F* alternate key is named NAMKEY.
00530F*
00550FINXDISK IC 80 80 4AI 1 DISK EMPKEY
00555F*
00560F* Specify the alternate key.
00570F*
00580F KEY 20A 10 NAMKEY
00600IMAST AA 01
00700I 1 40ENUM
00710I 5 24 ENAM
00720I 1 50 RECORD
00815IINXDISK BB 02
00820I 1 40EMPNO
00900I 10 29 NAME
01000C*
01110C* Use the value of ENUM to CHAIN to INXDISK using the
01120C* primary key EMPKEY.
01150C*
01200C 01 ENUM CHAININXDISK EMPKEY 20
01250C N20 NAME COMP ENAM 50
01255C*
01260C* Use the value of ENAM to CHAIN to INXDISK using the
01270C* alternate key NAMKEY.
01280C*
01300C 01 ENAM CHAININXDISK NAMKEY 21
01400C N21 EMPNO COMP ENUM 51
01500C N50N51 EXCPTPRINT
01800OPRINT E
01900O 14 '*** mismatch:'
02000O RECORD 64
02010O 81 ': is in error ***'
The CHAIN operation code is used to read an alternate index file randomly by key. If the
key has noncontiguous fields, the field in Factor 1 of the CHAIN operation must be
specified. An easy way of designating the field is to use a data structure with subfields
for each part of the noncontiguous key.
Example
Example 4–18 shows how to use data structure subfields to load a noncontiguous key
for a CHAIN operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100FMASTER IP 80 80 DISK
00150F*
00200F* Because NONCONT has a noncontiguous key, EXTK is
00300F* specified in columns 35-38. Column 31 must contain an A
00400F* if the key is noncontiguous. Columns 29-30 contain the
00500F* total length of the key.
00550F*
00600FNONCONT IC 80 80 52AI EXTK DISK
00700FPRINT O 132 132 PRINTER
00800IMASTER AA 01
00900I 1 30 NAME
01000I 32 37 EMPNO
01100I 40 80 ADDR
01200INONCONT BB 02
01300I 1 80 REC
01400INAME DS
01450I*
01500I* This data structure is used to divide NAME into subfields.
01550I*
01600I 1 11 KEYNM
01700I 12 30 FILLR
01800I DS
01850I*
01900I* KEYDS is used to set up the noncontiguous key.
01950I*
02000I 1 40 ADDRS
02100I 41 52 NAM
02200I 1 52 KEYDS
02250C*
02300C* Move parts of the input record into KEYDS
02350C*
02400C 01 MOVE KEYNM NAM
02500C 01 MOVE ADDR ADDRS
02600C 01 KEYDS CHAINNONCONT 99
02700C 01N99 EXCPTPRINT
02800OPRINT E
02900O REC 80
Addrout files are record-address files that contain relative record numbers. SORT
programs create addrout files. An addrout file can be used to process any sequential,
direct, or indexed file.
A SORT program creates an addrout file by processing the data file with a certain key or
keys. The order of the relative record numbers in the addrout file is the same as the
record sequence based on that key. When the data file is processed as an addrout file,
records are retrieved in sequence by that key. If necessary, several addrout files can be
created based on different keys. An addrout file can thus process the data sequentially in
order of a particular key, without physically sorting the data records. For more
information on sorting records, refer to the SORT Language Programming Reference
Manual.
For example, suppose that a sequential file has three records and each record is 2
characters long. The first record contains AB, the second record contains BA, and the
third record contains CC. In addition, suppose that records must be retrieved in
alphabetic order based on the second character of each record. Record number 2 must
be retrieved first because A is the second character of this record; record 1 must be
retrieved second because B is the second character; and record 3 must be retrieved
third. The SORT program can create an addrout file that contains the numbers 2, 1, and
3. When the sequential file is processed by the addrout file, the records are retrieved by
the relative record numbers in the addrout file; that is, in alphabetic order based on the
second character of the record.
Records are read until either the addrout file reaches EOF or the program ends for some
other reason.
Update files can be processed by addrout files. If the data file is an indexed file, the key
fields specified at the time the data file was created are protected and cannot be updated
or changed.
Because an addrout file contains relative record numbers of records within a data file, the
user must ensure that the addrout file does not become outdated because of changes to
the data file.
The following are four actions that can cause a file to become outdated:
• The key within a data record is changed when the file is updated.
• Records are added to, or deleted from, the data file.
• The data file is sorted.
• The data file is an indexed sequential file and is consolidated (crunched).
If the addrout file becomes outdated, data records can no longer be retrieved in correct
key sequence. A new addrout file must be created.
Note: A data file can be processed in different programs by using several addrout files
based on different keys. If the value of any of these keys is changed in a data record, the
corresponding addrout file is outdated. Before modifying a key, consider whether the
data file is used by several programs and, by several different users. If an addrout file
contains a relative record number for a record that does not exist, a KEY NOT FOUND
run-time error occurs. Refer to Appendix A, “System Messages,” for the list of error
messages.
Example
Example 4–19 shows addrout file processing.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* INPUT is the file being processed using an addrout file.
00210F* An R in column 28 and the letter I in column 31 indicate
00220F* that relative record numbers from an addrout file are used
00230F* to process this file.
00250F*
00300FINPUT IP 80 80R I DISK
00305F*
00310F* RADDR is the addrout file. Column 16 must contain an R.
00320F* Columns 31 and 32 must contain an I and a T, respectively. In
00330F* this example, the relative record numbers are 6 positions long.
00350F* If the addrout file is produced with the GSORT compiler control
00360F* option of SORT, the record length and key field length is 3.
00380F*
00400FRADDR IRE 132 6 6IT EDISK
00500FPRINT O 132 132 PRINTER
00600E RADDR INPUT
00700IINPUT AA 01
00800I 2 60AMT1
00900I 10 140AMT2
02200C 01 AMT1 ADD TOTAL TOTAL 90
02600C 01 TOTAL COMP AMT2 L1
02800OPRINT T L1
02900O TOTAL 15
If an alternate index file is processed with an addrout file and if the alternate index file
contains a noncontiguous key, the Key Field Starting Location field (columns 35–38) must
contain EXTK. Otherwise, processing an alternate index file with an addrout file is like
processing an index file with an addrout file.
The fields listed in Table 4–5 must be coded in the File Specifications when an addrout
file is used to randomly process a disk file.
The fields listed in Table 4–6 must be coded in the File Specifications for an addrout file.
The fields listed in Table 4–7 must be coded in the Extension Specifications for a disk file
processed by an addrout file.
• Is the file either an EFS sequential file or an EFS direct file (rather than a BFS
sequential file or a BFS direct file)?
• If so, was the file created as a delete-capable file?
If the file is an EFS sequential or direct file that is delete-capable, then records can be
added between other records or at the end of the file. If the file is a BFS sequential or
direct file or an EFS sequential or direct file that is not delete-capable, then records can
be added only at the end of the file.
The File Addition field (column 66) in the File Specifications must contain an A or B to
specify that records are to be added to the file. In addition, the Record Addition/Deletion
field (columns 16–18) in the Output Specifications must contain ADD to indicate addition
to the file.
If the file is designated as a demand or full-procedural file, a READ operation cannot read
the added records. The READ operation encounters the original EOF if an attempt is
made to read the added records. However, the added records can be read with the
CHAIN operation.
Example
Example 4–20 shows one method of adding records to the end of a BFS sequential or
direct file.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FINFILE IP 80 80 DISK
02500F*
03000F* To add records, the File Specifications must have an A or B in
03500F* column 66.
03700F*
04000FDSKFILE UC 80 80 DISK A
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
10000IINFILE NS 20
10010I 2 7 CUSTNO
10020I 10 29 DATA
17000IDSKFILE NS 30
17010I 2 7 CUSTNO
17020I 10 39 NAME
17030I 40 59 DATA
17500O*
18000O* The Output Specifications must contain an ADD in columns 16-18
18100O* in order to add records.
19000O*
20000ODSKFILE DADD 20
21000O CUSTNO 7
22000O NAME 39
26000O DATA 59
Example
Example 4–21 shows how records are added to the end of an EFS sequential file.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYIOIIOUTPUT
02000FINFILE IP 80 80 DISK
02500F*
03000F* Note that column 16 (File Designation) must be blank and
03250F* column 66 contains an A.
03500F*
04000FSEQDISK O F 80 80 DISK A
05000A EXTEND 50
12000IINFILE 011 98 1 C1
14000I 2 7 CUSTNO
16000I 10 39 NAME
16010I 021 99 1 C2
Example 4–21. Adding Records to the End of an EFS Sequential File (cont.)
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
17000I 2 7 CUSTNO
17010I 10 29 DATA
17500O*
18000O* The Output Specifications must contain an ADD in columns 16-18
18100O* in order to add records.
18500O*
20000OSEQDISK DADD 99
21000O CUSTNO 7
22000O NAME 39
26000O DATA 59
• Deleted records cannot be read. A READ operation skips over deleted records until it
reaches EOF or finds a valid record (one that is not deleted). A CHAIN operation to a
deleted record returns a KEY NOT FOUND error message if no resulting indicator is
specified. If a resulting indicator is specified, the indicator is turned on.
• If an attempt is made to add a record to a record position that currently contains a
valid record, an ADD TO NON-DELETED RECORD error message occurs.
A continuation line record must be used to write a program that adds records between
existing records of an EFS sequential file. The continuation line is part of the File
Specifications for the file to which records are added.
The following entries for a continuation line must be entered on the File Specifications
immediately following the file definition:
The RECNO field contains the relative record number of the position in the file to which
the record is to be added. The RECNO identifier must contain the relative record number
of a record that is currently deleted. A record can be added between records only if the
relative record number contains a deleted record number. An error occurs if the record
position in the file contains a record that was not deleted.
To construct a program that adds records between records of a sequential file, the file
must be processed randomly (chained or full-procedural), and the continuation line syntax
must be used. The file must be declared as an input or update file with addition (an A or
B in column 66 of the File Specifications).
Example
Example 4–22 shows the RECNO field with a chained update file. The program attempts
to read a record with the CHAIN operation. If the record was deleted, the resulting
indicator is turned on. The next line is conditioned by the resulting indicator of the CHAIN
operation. The program places into the RECNO field the relative record number of the
failed CHAIN operation. When the program tries to write the record, it uses the relative
record number in the RECNO field to identify the relative position in the file to place the
record.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01050F*
01100F* For the continuation line syntax to be used, the
01200F* $KEYEDIOIIOUTPUT compiler control option must be TRUE.
01250F*
01500FINPUT IP 40 40 DISK
02000FSEQDISK UC 40 40 DISK A
02200F*
02500F* The following record is the continuation line.
02600F* The K in column 53 specifies a continuation line.
02700F*
03000F KRECNO RRN
10000IINPUT NS 01
10100I 2 70CUSTNO
10200I 8 37 REC
12000ISEQDISK NS 02
14000I 2 70NUM
16000I 10 39 RECORD
17000C 01 CUSTNO CHAINSEQDISK 20
17200C*
17500C* The following record defines the RECNO field RRN
17600C* and also places the relative record number of the
17700C* failed chain in RRN.
17750C*
18000C 01 20 Z-ADDCUSTNO RRN 70
20000O* The Output Specifications must contain ADD in
20100O* columns 16-18 in order to add records.
21000O*
22100OSEQDISK DADD 01 20
22200O CUSTNO 7
22300O REC 39
A program that adds records to a direct file should process an input or update file
randomly (chained, demand, or full-procedural). Because deleted records cannot be read,
a continuation line must follow the File Specifications of the file to which records are to
be added. The continuation line contains a K in column 53, RECNO in columns 54 through
58, and a 7-digit numeric field with no decimal positions in columns 60 through 65. The
RECNO field must contain the relative record number where the output record is to be
added. The syntax for a continuation line is valid only if the $KEYEDIOIIOUTPUT compiler
control option is TRUE. For more information on the syntax of continuation lines, refer to
Section 8, “File Description Specifications.”
Example
Example 4–23 shows the use of the RECNO field with a chained update EFS direct file.
The program reads the file NEWFL that contains customer numbers and data, and uses
the customer number to read a record with the CHAIN operation to the master customer
file CSTMAST. If the CHAIN operation is successful, the record is updated with
information in the NEWFL file. If the CHAIN operation is not successful (in other words, if
the CHAIN operation tried to read a deleted record), the customer number is placed into
the RECNO field, and the primary customer file record is added to the master customer
file (CSTMAST).
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01050F*
01100F* For the continuation line syntax to be used, the
01200F* $KEYEDIOIIOUTPUT compiler control option must be TRUE.
01300F*
01500FNEWFL IP 80 80 DISK
02000FCSTMAST UC 80 80 DISK A
02300F*
02500F* The following record is the continuation line.
02700F*
03000F KRECNO RRN
10000INEWFL NS 01
10100I 2 70RECNUM
10200I 8 77 RECDAT
12000ICSTMAST NS 02
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
14000I 2 70CUSTNO
16000I 8 77 DATA
17000C 01 RECNUM CHAINCSTMAST 10
17300C*
17500C* The following record defines the RECNO identifier RRN
17600C* and places the relative record number of the failed
17700C* CHAIN operation in RRN.
17800C*
18000C 01 10 Z-ADDRECNUM RRN 70
19000C 01 10 EXCPTCSTMAST
19500C*
20000O* The Output Specifications must contain an ADD in
20100O* columns 16-18 in order to add records.
20150O*
22100OCSTMAST EADD
22200O RECNUM 7
22300O RECDAT 77
23000OCSTMAST D 01 02N10
23100O RECNUM 7
23200O RECDAT 77
Duplicate keys can exist for indexed files. Duplicate keys are keys that contain the same
value. For example, if two keys contain a key value of A and there are records AB and
AC, the first key might point to AB (the first record) and the second key to AC (the
second record).
A program written to add records to an indexed file might have to handle duplicate key
errors if duplicate keys are not allowed in the key files. A DUPLICATE KEY error message
is displayed if an attempt is made to write a record with a duplicate key value to an
indexed file.
There are no duplicate keys, records can be added without checking for duplicates.
Example
Example 424 shows how to add records to a file when there is no need to check
for duplicate keys. The file is specified as an output file with addition (an A
or B in column 66 of the File Specifications for the file). Because the file is
indexed, the File Organization field must contain the letter I, and a primary
key must be described. If the indexed file has alternate keys, descriptions of
the alternate keys are not required in the program. For a record to be added,
ADD is entered in the Record Addition/Deletion field (columns 1618) of the
Output Specifications record description.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FINPUT IP F 80 80 DISK
01500F*
02000F* Records are added to INXDISK without checking for duplicate
03000F* keys. The file is declared as an output file with addition
04000F* (an A in column 66). Note that the primary key must be
05000F* described. INXDISK has a primary key that starts in
06000F* position 2 of the record and is 7 characters long.
06500F*
07000FINXDISK O 80 80 7AI 2 DISK A
08000IINPUT NS 20
09000I 2 60 RECORD
09500O*
10000O* In order for records to be added, ADD must be specified in
11000O* columns 16-18 of the Output Specifications record description.
11500O*
12000OINXDISK DADD 20
13000O RECORD 60
If duplicate keys are not allowed, it is a good idea to check for them before adding
records. To check for duplicate keys, the program reads records from the indexed file
and then checks to see if the key field in the record just read matches the key field of the
record to be added. If the key fields match, a duplicate record exists.
Example
Example 4–25 checks for duplicate keys. The program uses the key field of the record to
read randomly by key with the CHAIN operation. If the CHAIN operation is successful, a
record with the given key already exists in the file. If the CHAIN operation fails, records
can be added safely without causing a DUPLICATE KEY error.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F* INPUT contains the records to be added to INXDISK.
02000F* CUSTNO is the field of the INPUT record that contains the
03000F* key value for INXDISK.
03500F*
04000FINPUT IP 80 80 DISK
04500F*
05000F* Records are added to the indexed file INXDISK. Note that
06000F* INXDISK is an update file designated as full-procedural.
06500F*
07000FINXDISK UF 80 80 7AI 2 DISK A
08000FERROR O 132 132 PRINTER
09000IINPUT NS 01
10000I 1 70CUSTNO
11000I 8 37 INREC
12000IINXDISK NS 02
13000I 2 80NUM
14000I 10 39 RECORD
14500C*
15000C* CHAIN to a record using the key field of the record to
16000C* be added. The record addition is conditioned on the result
17000C* of the CHAIN. If the record to be added causes a DUPLICATE
18000C* KEY error, it is written to a printer file. If the addition
19000C* does not cause an error, the record is added to INXDISK.
20500C*
21000C 01 CUSTNO CHAININXDISK 99
22000C 01 EXCPT
23000OINXDISK EADD 99
24000O CUSTNO 8
25000O INREC 39
26000OERROR E N99
27000O 15 'Duplicate Key:'
28000O CUSTNO 25
For records to be deleted from a BFS sequential or direct file, the file must be declared in
the program as an input or update file with a blank, D, or B in the File Addition/Unordered
field (column 66) of the File Specifications; also the DEL entry must be coded in the
Record Addition/Deletion field (columns 16–18) of the Output Specifications. Coding the
DEL entry in the Output Specifications fills the current record in the file with blanks.
The DELET operation code cannot be used to delete records from a sequential or direct
file. It is used for indexed files only.
Example
Example 4–26 shows the use of the DEL entry in the Output Specifications to delete a
record from the direct file CSTMAST.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FINFILE IP F 180 10 DISK
02000FCSTMAST UC F 80 80 DISK
10000IINFILE NS 01
10100I 3 100RECNUM
12000ICSTMAST NS 02
14000I 2 70CUSTNO
16000I 8 77 DATA
17000C 01 RECNUM CHAINCSTMAST 99
18000OCSTMAST DDEL N99
Example 4–26. Using the DEL Entry to Delete Records from a BFS Direct
File
Records are deleted from a file in the sense that deleted records cannot be read. A READ
operation skips over deleted records until it encounters EOF or finds a valid (nondeleted)
record. A CHAIN operation returns a KEY NOT FOUND error message if the record in the
file is deleted. If a program attempts to delete a record from a file that is not delete-
capable, an error occurs. If a program attempts to delete a record from a BFS sequential
or direct file, unexpected results can occur. At best, a record filled with blanks is
returned. A discussion of this process is provided in the description of deleting records
from BFS sequential and direct files earlier in this section.
For a record to be deleted from an EFS sequential or direct file, the DEL entry must be
added in the Record-Addition/Deletion field (columns 16–18) of the Output Specifications.
(The DELET operation code is allowed with indexed files only.) Coding the DEL entry in
the Output Specifications deletes the current record in the file.
Example
Example 4–27 shows the use of the PLC to read records sequentially. Then, records are
deleted by using the DEL entry on the output record.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FSEQDISK IP F 80 80 DISK
02000ISEQDISK NS 02
02100I 1 80 DATA
02900O*
02910O* Note that the DEL entry is specified in columns 16-18.
02920O* Records are read consecutively using the PLC. This
029300* program deletes every record in SEQDISK.
02940O*
03000OSEQDISK DDEL 02
The following are two methods of deleting records from an indexed file:
The DELET operation code takes as input the key of the record to be deleted. If no key is
given (that is, no Factor 1 exists), then the current record is deleted.
The DEL entry on the Output Specifications deletes the current record in the file. The
DEL entry requires that the input record is read sequentially by key or randomly by key.
After the record is read, the subsequent update deletes the record.
Example
Examples 4–28 and 4–29 have the same function, but use different methods to delete
the record that was read.
Example 4–28 randomly reads records in an indexed file with the CHAIN operation. The
CHAIN operation uses keys that are read from the primary file. The program then deletes
the record that was read by using the DEL entry on the Output Specifications.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FINPUT IP 80 80 DISK
04000FINXDISK UC 80 80 6AI 2 DISK
05000IINPUT NS 01
05100I 2 7 NAME
05200I 10 80 RECORD
07000IINXDISK NS 02
07100I 1 80 DATA
08000C 01 NAME CHAININXDISK 20
09000OINXDISK DDEL N20
Example 4–28. Using the DEL Entry to Delete Records from an Indexed
File
Example 4–29 reads records in an indexed file with the CHAIN operation. The CHAIN
operation uses keys that are read from the primary file. Then the program deletes the
record that was read by using the DELET operation code.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FINPUT IP 80 80 DISK
04000FINXDISK IC 80 80 6AI 2 DISK
05000IINPUT NS 01
05100I 2 7 NAME
05200I 10 80 RECORD
07000IINXDISK NS 02
07100I 1 80 DATA
08000C 01 NAME DELETINXDISK 20
Performing a free operation unlocks a locked record. The free operation can be
performed with Output Specifications that have no field description.
Example
Example 4–30, the program reads and then frees records in the ORDMAST file. Because
there can be concurrent executions of this program (using different TRANS files), a
record should not be held while the result of the transaction is being printed. If a record is
held, other programs wanting access to the same record have to wait.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FTRANS IP F 80 80 DISK
02000FORDMAST UF F 80 80 10AI 1 DISK
03000FTRANLISTO 132 PRINTER
04000I*
05000I* If the first character of the record is U, update the
06000I* ORDMAST file.
07000I*
08000ITRANS 011 99 1 CU
09000I 2 110ICSTNO
10000I 12 160IQTY
11000IORDMAST NS 02
12000I 1 100CUSTNO
13000I 11 150QTY
14000I 16 200ORD#
15000C ICSTNO CHAINORDMAST 20
16000C 99N20 IQTY ADD QTY QTY
16500C*
17000C* The TRANLIST record is freed so other programs are not
18000C* denied access to the record while the result of the
19000C* transaction is printed.
19500C*
20000C* N20 EXCPTFREE
21000C EXCPTTRANLIST
21500O*
22000O* The free operation occurs here (output with no field
22300O* descriptions).
22500O*
23000OORDMAST E N20 FREE
24000O*
25000OTRANLISTE 20 ERROR
26000O ICSTNO 12
27000O 38 'ERROR: NO MATCH'
28000OTRANLISTE 99
29000O CUSTNO 10
30000O QTY 20
31000O ORD# 30
Other methods exist to unlock a locked record. For a list of these methods, refer to the
discussion of the RECORDLEVELLOCK attribute in this section.
Internationalization refers to the software, firmware, and hardware features that enable
you to develop and run application systems that can be customized to meet the needs of
a specific language, culture, or business environment. The internationalization features
provide support for several character sets, different international business and cultural
conventions, extensions to data communications protocols, and the ability to use one or
more natural languages concurrently.
This section describes the internationalization features you can use to customize an
application for the language and conventions of a particular locality. Using these features
to write or modify an application is termed localization. The MultiLingual System (MLS)
environment enables you to process information to localize your applications. Some of
the localization methods included in the MLS environment include translating messages
to another language, choosing a particular character set to be used for data processing,
and defining date, time, number, and currency formats for a particular business
application.
In addition to the information described in this section, refer to the MultiLingual System
(MLS) Administration, Operations, and Programming Guide for information. The MLS
Guide provides definitions for, and detailed information about, the ccsversions, character
sets, languages, and conventions provided in the system software. It also provides
procedures for setting system values for the internationalization features.
• RPG provides language syntax that enables localization of your program. For
example, when you specify a particular ccsversion in your program, the compiler
uses the collating sequence associated with the ccsversion for alphanumeric
comparisons.
• The system provides a system library, CENTRALSUPPORT, that contains procedures
for localizing a program. The procedures can be accessed through calls. When a call
occurs, input parameters describe the type of information that is needed of the
action that has to be performed. Output parameters are returned with the result of
the procedure call. For example, a program can call the procedure CNVTIME to
format the time according to the language and convention specified in a program.
A program must designate that it uses internationalization features; otherwise, it will not
access them. A program is not affected by the features described in this section unless a
program specifically invokes them. Any programs that already exist and do not make use
of internationalization features are not affected by the features.
The current system default settings can be determined by using one of the following two
methods:
Feature Default
Ccsversion ASeriesNative
Language English
Convention ASeriesNative
Before you change the default settings for localization, you must consider the feature
and the level at which the feature is defined. As an example, the ccsversion can be
changed only at the system operations level. A program can avoid making specific
settings by taking advantage of the default settings. For example, if the system default
ccsversion is France, the language is Francais, and the convention is FranceListing, the
program can use those default settings without coding the settings within the program.
A program can use the default settings with the use of predefined values as input
parameters. These parameters tell the procedure to use the current default setting. See
“Input Parameters” later in this section for specific information on those parameters.
There is a priority associated with these levels. A setting at the task level overrides a
setting at the session level. A setting at the session level overrides a setting at the
usercode level. A setting at the usercode level overrides a setting at the system level,
and so on. A language and convention can be established at any level, but the ccsversion
can be established only at the system level.
Two task attributes enable you to change the language, the convention, or both. These
attributes are the LANGUAGE and the CONVENTION task attributes. By using these
attributes, you have the option to select from among multiple languages and conventions
when running a program. Information on the use of task attributes is provided in the Task
Attributes Reference Manual.
The LANGUAGE task attribute establishes the language used by a program at run time.
The CONVENTION task attribute establishes the convention used by a program at run
time. For example, an international bank might have a program to print bank statements
for customers in different countries. This program could have a general routine to format
dates, times, currency, and numerics according to the selected conventions. To print a
bank statement for a French customer, this program could set the CONVENTION task
attribute to FranceBureautique and process the general routine. For a customer in
Sweden, the program could set the CONVENTION task attribute to Sweden and process
the general routine.
As you code your program you can use the defaults in both the source code and the calls
to the CENTRALSUPPORT library, or you can use the settings of your choice. The task
level and system level are probably the most useful levels for your program. Because the
language and convention features have task attributes defined, you can access or set
these task attributes in your program.
A coded character set name and number is given for each unique coded character set
definition. This name or number may also be used to set the INTMODE or EXTMODE file
attributes for a file. Refer to the File Attributes Reference Manual for information on how
to use these attributes.
Each SSR includes a data file, SYSTEM/CCSFILE, containing all coded character sets and
ccsversions that are supported on the system. You cannot choose a coded character set
directly, but by choosing a ccsversion, you implicitly designate the default coded
character set for your system.
Data can be entered and manipulated in only one coded character set and ccsversion at a
time. Although there are many ccsversions which can be accessed, there is only one
ccsversion active for the entire system at one time. This is called the system default
ccsversion. See “Using the Ccsversion, Language, and Convention Default Settings” and
“Understanding the Hierarchy for Default Settings” earlier in this section.
Several ways exist to determine which coded character sets and ccsversions are
available on your system.
• Look in the MLS Guide. Your system might have a subset of the ones defined in that
guide.
• Use the MARC menus and screens or the system command SYSTEMOPTIONS.
Refer to the MLS Guide or the System Commands Operations Reference Manual.
• Call the CCSVSNLIST procedure.
You might want to refer to the MLS Guide for a complete understanding of ccsversions
and the relationship of a coded character set and a ccsversion.
All coded character set and ccsversion information on your system can be accessed by
calling CENTRALSUPPORT library procedures. To call these CENTRALSUPPORT library
procedures, an RPG program should first include a file provided on the release media that
declares all the library procedures. This file is called *SYMBOL/INTL/RPG/PROPERTIES.
The procedures can then be used in the program. There are comments in this file that
describe parameter constants and their values as well as error values. The method for
including *SYMBOL/INTL/RPG/PROPERTIES in your RPG program is shown in each of
the CENTRALSUPPORT library procedures detailed later in this section. If the file is not
included, any library procedure that is used must be declared individually in the program.
Many of the procedures require the specification of a coded character set or ccsversion
as an input parameter. A program can choose a specific coded character set or
ccsversion by calling the procedures using the name or number of the coded character
set or the ccsversion as an input parameter. For example, by calling the VSNTRANTXT
procedure with the ccsversion name ASeriesNative, then calling the VSNTRANTXT
procedure again with the ccsversion name SWISS, your program could access data in the
ASeriesNative ccsversion and then access data in the Swiss ccsversion. A program can
also use the system default setting by using predefined values as input parameters. See
“Input Parameters” later in this section for information on these parameters.
Mapping Tables
A mapping table is used to map one group of characters to another group of characters
or another representation of the original characters. Many CENTRALSUPPORT library
procedures store coded character set and ccsversion information in ALGOL-type
translate tables as a way of defining, processing, and mapping data. For example, a
translate table can exist to translate lowercase characters to uppercase characters. It is
not necessary to understand the layout of an ALGOL-type translate table because the
table is usually not visible to your program. A description of translate tables is provided in
the ALGOL Programming Reference Manual, Volume 1: Basic Implementation.
The internationalization procedures provide you with access to mapping tables that apply
to data specified in coded character sets or specified ccsversions. These mapping tables
are as follows:
• Mapping data from one coded character set to another coded character set
• Mapping data from lowercase to uppercase characters
• Mapping data from uppercase to lowercase characters
• Mapping data from alternative numeric digits defined in a ccsversion to numeric
digits in U.S. EBCDIC
• Mapping data from numeric digits in U.S. EBCDIC to alternative numeric digits
defined in a ccsversion
• Mapping characters to their escapement values
You must use procedures from the CENTRALSUPPORT library to access these translate
tables or to process data using these tables. For example, you use the CCSTRANTXT
procedure to translate data from one coded character set to another coded character set.
You use the VSNTRANTXT procedure to map lowercase data to uppercase.
See the MLS Guide for definitions of mapping tables for each coded character set and
ccsversion.
Data Classes
A data class is a group of characters sharing common attributes such as alphabetic, upon
which membership tests can be made. Some characters might not have a data class
assigned to them. Many CENTRALSUPPORT library procedures store ccsversion
information in ALGOL-type truthset tables as a way to define ccsversion data classes. A
truthset is a method of storing the declared set of characters that defines a data class in
ALGOL. It is not necessary to understand the layout of an ALGOL-type truthset because
the truthset is usually not visible to your program. A description of truthsets is provided
in the ALGOL Programming Reference Manual, Volume 1: Basic Implementation.
The internationalization features provide you with access to truthsets that apply to a
ccsversion. These truthsets are:
• Ccsversion alphabetic
• Ccsversion numeric
• Ccsversion graphics
• Ccsversion spaces
• Ccsversion lowercase
• Ccsversion uppercase
The alphabetic truthset contains those characters which are considered alphabetic for a
specified ccsversion. The numeric truthset contains those characters which are
considered to be numbers for a specified ccsversion, and so on.
You can use procedures from the CENTRALSUPPORT library to access these truthsets
or to process data using these truthsets. For example, if a program manipulates an
employee identification number such as 555962364, it might then need to verify that the
text is all numeric. The program can call the VSNINSPTXT CENTRALSUPPORT library
procedure to compare the text to the numeric truthset. This procedure returns the
information that the text is all numeric.
Refer to the MLS Guide for definitions of ccsversions and data classes.
Text Comparisons
You might need to perform a text comparison to sort and merge text, to compare
relationships between two pieces of text, or to index a file. The traditional method for
handling text comparisons is based on a strict binary comparison of the character values.
The binary method of comparison is not meaningful when used for sorting text if the
binary ordering of the coded characters does not match the ordering sequence of the
alphabet of the language. This situation is the case for most coded character sets.
Because the binary method is not sufficient for all usage requirements, the system
software supports the definitions of two other levels of ordering.
The first level is called Ordering. Each character gets an ordering sequence value (OSV).
An OSV is an integer from 0 (zero) through 255, assigned to each code position in a
character set. The OSV signifies a relative ordering value of a character. An OSV of 0
(zero) indicates that the character comes before a character with an OSV of 1. More than
one character can be assigned the same OSV.
The second level is called Collating. Each character gets an OSV and a priority sequence
value (PSV). A PSV is an integer from 1 to 15 that is assigned to each code position in a
character set. The PSV is a relative priority value within each OSV. Each character with a
unique OSV has a PSV of 1; however, if 2 characters have the same OSV, they will have
different PSVs for additional differentiation.
When comparing two strings of data, we call a comparison which uses only 1 level, the
Ordering level, an equivalent comparison. A comparison which utilizes both levels,
Ordering and Collating, is called a logical comparison.
You can use the following three types of text comparisons by calling the VSNCOMPTXT
procedure of the CENTRALSUPPORT library.
In addition to the three types of ordering, the system also supports the following two
types of character substitution:
Substitution Orders . . .
You can also specify a collating sequence to be used for text comparisons. When an
internationalized collating sequence has been specified at the program level and you are
trying to compare two alphanumeric strings, the compiler generates the text comparison
routines.
To enable your RPG program to have automatic access to the system default collating
sequence, code the entry N in the Collating Sequence field (column 26 of the Control
Specification). This entry specifies that the system default internationalization collating
sequence should be applied to process alphanumeric data. This processing includes
match field sequence checking, match field processing, and the application of the COMP,
IFxx, DOUxx, DOWxx, CASxx, and LOKUP operation codes. You can define a specific
collating sequence by using an S entry in the Collating Sequence field and using the
Alternate Collating Sequence Specifications.
You can direct your RPG program to sort using a different collating sequence by entering
a C in the Decimal Positions field (column 52 of the Calculation Specifications) on the
same line as the SORTA operation. The C indicates that the collating sequence specified
in the Collating Sequence field (column 26 of the Control Specification) will be used.
Historically, text was sorted by using a standard system-provided method that is based
on a strict binary comparison of the character values. Within a program, you might also
specify a collating sequence to be used for text comparisons.
Often with international coded character sets, the binary method of comparison does not
result in a meaningful ordering of the text to be sorted. This situation occurs when the
binary ordering of the coded characters does not match the ordering sequence of the
alphabet. Your program can call the CENTRALSUPPORT library procedures listed in Table
5–1 under the category “Comparing and Sorting Text” to obtain ordering information of
the ccsversion, and to sort or compare text based on this information.
Like file attributes, you must code pseudo file attributes for a file in File Specifications
immediately after the specification for that file. However, the pseudo file attributes can
appear in any sequence in File Attribute Specifications. Because you cannot interrogate
or modify pseudo file attributes, you cannot declare them with a variable name.
A run-time error occurs when you open an indexed file for output if the system default
ccsversion does not match the system default ccsversion in effect at the time the
program was compiled.
You must code your RPG program in the subset of the standard U.S. EBCDIC character
set defined by the RPG language. Only the contents of string literals, data items with
variable character data, or comments can be in a character set other than that subset.
If your program interacts with a user, has a user interface (screens, forms), displays
messages or takes in user input, then those aspects of the program should be in the
natural language of the user. For example, French would be used in screen and system
message displays for users whose natural language is French.
Refer to the MLS Guide for a list of user interfaces that can be localized. The following
text explains how to develop an RPG application program which supports messages in
the natural language of the user.
Category Is a Message . . .
Output That an application program displays to the user. Some examples of output
message messages are error messages and prompts for input. An output message
is localized so that it can be displayed in the language of the user.
Input Received by an interactive program either from a user or from another
message program in response to a prompt for input. The input message might be in
a language that the program cannot recognize. In this case, the message
must be translated so that it can be understood by the program.
If you develop input and output messages within an output message array, you make the
localization process easier. When messages are in an output message array, the
translator can use the MSGTRANS utility to localize the messages into one or more
natural languages. The MSGTRANS utility finds all output message arrays in a program
and presents them to a translator for translation. If messages are not in output message
arrays, a translator searches the source file for each message and then translates the
message.
You can create an output message array by creating an ALGOL library that contains
OUTPUTMESSAGE ARRAY declarations.
There is a program on the release media that demonstrates how to create an ALGOL
library containing output message arrays. The program is called
EXAMPLE/MLS/ALGOL/LIBRARY. For more information on how to call an ALGOL library
from an RPG program, see the MLS Guide.
The release media contains standard convention definitions for many formatting styles.
For example, some of the conventions are Denmark, Italy, Turkey, and UnitedKingdom1.
These convention definitions contain information to create formats for time, date,
numbers, currency, and page size required by a particular locality.
Each SSR includes a data file named SYSTEM/CONVENTIONS that contains all the
convention definitions supported on the system. Although you can access many
conventions, only one convention is active at a time for the entire system. This
convention is called the system default convention.
• Look in the MLS Guide. Your system might have a subset of the ones defined in that
guide.
• Use the MARC menus and screens or the system command SYSTEMOPTIONS.
Refer to the MLS Guide or the System Commands Operations Reference Manual.
• Call the CENTRALSUPPORT library procedures. To display the names of the
conventions available on the host computer, use the CNVNAME CENTRALSUPPORT
library procedure.
The MLS Guide provides complete information on all of the conventions. There are
comments in the file SYMBOL/RPG/INTL/PROPERTIES that describe parameter
constants and their values. These constants and values can be used in your program. The
comments in the file also describe error values.
If none of the conventions provided on the release media meet your needs, you can
define a new convention. You must use a template to define a convention. A template is
a group of predefined control characters that describe the components for date, time,
numeric, or currency. For example, the data item 02251990 and the template
!0o!/!dd!/!yyyy! produce the formatted date, 02/25/1990. To use some of the
CENTRALSUPPORT library procedures, you must understand how templates are
defined. The MLS Guide describes how to define a template.
Each of the following features applies to date handling throughout the entire RPG
program:
• The Date Format field (column 23 of the Control Specification) provides MMDDYY,
DDMMYY, and YYMMDD date formats for the predefined field UDATE. JDATE is a
predefined field that contains the Julian date in YYDDD format.
• The Date Edit field (column 24 of the Control Specification) is used to specify any
character as a date separator, including blank.
In addition to using the features in RPG, you can call the CENTRALSUPPORT library
procedures to format your date and time items. The following types of procedures are
available to format the date and time:
Convention You supply the convention name and the value for the date or
time. The procedure returns the date or time value in the format
used by the convention. All the conventions are described in the
MLS Guide.
Template You supply the following: the format that you want for the date or
time in a template parameter; the value for the date or time. You
must use predefined control characters to create the template.
These control characters are described in the MLS Guide.
System The system supplies the date and time. There is a procedure that
formats the system date, the system time, or both according to a
convention and a procedure that formats the system date, the
system time, or both according to a template that you supply.
Example
You can use the CNVDATTIM procedure to display the system date and time according
to the language and convention you choose. If you designate the ASeriesNative
convention and the ENGLISH language, the date and time may be displayed as follows:
If you designate the FranceListing convention and the French language, the same date
and time may be displayed as follows:
Table 5–1 lists other procedures that can be called to inquire about the conventions
available on the system.
The RPG compiler provides you with the following ways to edit currency and numeric
displays:
• The Currency Edit field (column 22 of the Control Specification) is used to specify any
single character to be used as the currency symbol in place of the dollar sign ($).
• RPG also has a domestic, international, and United Kingdom format for numerics and
dates. You use the Inverted Print field (column 21 of the Control Specification) to use
these formats. Both the international and United Kingdom formats use a period (.) as
the thousands separator and a comma (,) as the decimal point. In addition, the
Inverted Print field changes the default date format and separator.
In addition to using the features in RPG, you can call the CENTRALSUPPORT library
procedures to inquire about numeric symbols or format currency amounts. All numeric or
currency symbols can be retrieved with a CENTRALSUPPORT library call. Monetary
amounts in real number form can be formatted according to different conventions.
You can use the CNVCURNCY procedure to format a monetary value according to the
convention you choose. For example, if you designate the Greece convention, the
monetary amount 12345.67 is formatted as follows:
DR.12 345,67
For example, the Netherlands convention definition specifies 70 lines as the default page
length and 82 characters as the default page width, while the Zimbabwe convention
definition specifies 66 lines as the default page length and 132 lines as the default page
width.
Following are some of the tasks your program can perform by calling
CENTRALSUPPORT library procedures:
CNVTPLT Returns the requested template for a designated convention. You can obtain
the template for the following:
• Long date format
• Short date format
• Numeric date format
• Long time format
• Numeric time format
• Monetary format
• Numeric format
Formatting Dates According to Convention
CNVDSPYMDL Returns either the date or time display model defined for the designated
convention. The components of the model are translated to the designated
language.
CNVDATE Formats a numeric date that has the form YYYYMMDD. The numeric date is
passed as a parameter to the procedure according to a designated convention
and language. The date can be formatted using the long, short, or numeric date
format defined in the convention.
TPLTDATTIM Returns the system date, the time, or both in the designated language,
formatted according to a template passed to this procedure.
CNVDATTIM Returns the system date, the time, or both, formatted according to the
designated convention template and language. You can choose from the
following types of formats:
• Long date and long time
• Long date and numeric time
• Short date and long time
• Short date and numeric time
• Numeric date and long time
• Numeric date and numeric time
• Long date only
• Short date only
• Long time only
• Numeric time only
TPLTDATE Formats a numeric date passed as a parameter to the procedure according to a
template and language passed as parameters of the procedure.
Formatting Times According to Convention
CNVDSPYMDL Returns either the date or time display model defined for the designated
convention. The components of the model are translated to the designated
language.
CNVTIME Formats a time with the form HHMMSSPPPP. The time is passed as a
parameter to the procedure according to a designated convention and
language. The time can be formatted using the long or numeric time format
defined in the convention.
TPLTTIME Formats a time passed as a parameter to the procedure according to a template
and language passed as parameters of the procedure.
TPLTDATTIM Returns the system date, the time, or both in the designated language,
formatted according to a template passed to this procedure.
CNVDATTIM Returns the system date, the time, or both, formatted according to the
designated convention template and language. You can choose from the
following types of formats:
• Long date and long time
• Long date and numeric time
• Short date and long time
• Short date and numeric time
• Numeric date and long time
• Numeric date and numeric time
• Long date only
• Short date only
• Long time only
• Numeric time only
Formatting Monetary Data According to Convention
CNVCURNCY Formats a monetary value passed as a parameter to the procedure according to
the monetary editing format template defined in the designated convention.
Determining Default Page Size
CNVFORMSIZ Returns the default lines-per-page and characters-per-line values defined in a
designated convention for presentation devices such as terminals or printers.
Library Calls
You can access the procedures in the CENTRALSUPPORT library by using the following
instructions:
1. Use the INCLUDE compiler control option to include part or all of the file
*SYMBOL/INTL/RPG/PROPERTIES. The library declarations must precede the Input
Specifications.
2. Use the EEXSR (Exit to External Subroutine) operation in the Operation field
(columns 28–32) of the Calculation Specifications to call a library subroutine. The
library subroutine name must be the name of the procedure in the
CENTRALSUPPORT library.
3. Use the PARAM (Specify Parameters for EEXSR) operation in the Operation field of
the Calculation Specifications to list the parameters of the procedure.
4. Specify the results of the procedure in the Result Field(columns 43–48) of the
Calculation Specifications.
An example of the declarations and the syntax necessary to invoke the
CENTRALSUPPORT library is provided in the description of each procedure later in this
section.
Table 5–2 lists a cross reference of CENTRALSUPPORT library procedure names. The
column on the left displays the procedure name to use when coding your RPG program.
The column on the right displays the procedure name as it appears in the
CENTRALSUPPORT library.
CCSTRANTXT CCSTOCCS_TRANS_TEXT_STAR
CCSVSNLIST CCSVSN_NAMES_NUMS_STAR
CCSVSNNAME VALIDATE_NUM_RETURN_NAME_STAR
CCSVSNNUM VALIDATE_NAME_RETURN_NUM_STAR
CENTSTATUS CENTRALSTATUS_STAR
CNVCURNCY CNV_CURRENCYEDIT_RPG
CNVDATE CNV_FORMATDATE_STAR
CNVDATTIM CNV_SYSTEMDATETIME_STAR
CNVDSPYMDL CNV_DISPLAYMODEL_STAR
CNVFORMSIZ CNV_FORMSIZE_STAR
CNVLIST CNV_NAMES_STAR
CNVNAME CNV_VALIDATENAME_STAR
CNVSYMBOLS CNV_SYMBOLS_STAR
CNVTIME CNV_FORMATTIME_STAR
CNVTPLT CNV_TEMPLATE_STAR
CSMSG GET_CS_MSG_STAR
MCPLANGS MCP_BOUND_LANGUAGES_STAR
TPLTDATE CNV_FORMATDATETMP_STAR
TPLTDATTIM CNV_SYSTEMDATETIMETMP_STAR
TPLTTIME CNV_FORMATTIMETMP_STAR
VSNCOMPTXT VSNCOMPARE_TEXT_STAR
VSNESCAPE VSNESCAPEMENT_STAR
VSNGETORD1 VSNGETORDERINGFORONE_TEXT_STAR
VSNINSPTXT VSNINSPECT_TEXT_STAR
VSNTRANTXT VSNTRANS_TEXT_STAR
Parameter Categories
Integer parameters are passed by both value and reference. The CENTRALSUPPORT
library procedures return output parameters and procedure result values.
Input Parameters
In many cases, you need to supply the ccsversion name or number, the language name,
or the convention name as input parameters. You can obtain this information in the
following ways:
• The MLS Guide describes all the possible ccsversions, languages, and conventions
that the system software release provides. However, your system might have a
subset of the ones provided. Some customized conventions may not be listed in the
MLS Guide. These conventions may be identified by the next two methods.
• If you are a system administrator, a privileged user, or are allowed to use the system
console, you can use MARC menus and screens, or the SYSOPS command to list
the options that exist on your system. The MLS Guide provides the instructions you
need to obtain this information.
• You can call procedures in the CENTRALSUPPORT library that will return this
information to you. If you are writing an application to be used on another system,
you might want to use these library procedures to verify that the ccsversion, the
language, or the convention specified by the user is valid on the system.
For any procedure which accepts a ccsversion number as an input parameter, you can
specify a –2 as input to indicate that the system default value should be used. For any
procedure that accepts a ccsversion name as an input parameter, you can specify all
blanks or all zeros as inputs to indicate that the system default value should be used. For
any procedure that accepts a language or convention name as an input parameter, you
can specify all blanks or all zeros as input to indicate that the task attribute should be
used. If the task attribute is not available, the CENTRALSUPPORT library searches down
the hierarchy until a usable value is found.
The MLS Guide provides complete information on all of the conventions. There are
comments in the file SYMBOL/RPG/INTL/PROPERTIES that describe parameter
constants and their values. These constants and values can be used in your program. The
comments in the file also describe error values.
For example, a parameter indicating the type of date or time formatting is used in a
number of the procedures. The type value indicates the type of format to be used. For
example, a value of 3 indicates the long time format.
Output Parameters
These parameters contain the output produced by the procedure. For example, the
output parameter of the CCSTRANTXT procedure contains the translated text produced
by the procedure.
Result Parameter
All the library procedures return a value as the procedure result that indicate whether an
error occurred during the execution of the procedure. In general, a returned value of 1
means that no error occurred and any other value means an error occurred. However,
the CNVNAME and VSNCOMPTXT procedures are exceptions to this rule. For these
procedures, the returned value can be 0 (zero), 1, or another value. A returned value of 0
(zero) means that no error occurred and the condition is FALSE. A returned value of 1
means that no error occurred and the condition is TRUE. Any other value means that an
error occurred.
Each procedure lists the values that can be returned by that procedure. The meanings of
these values are explained at the end of this section. You can use these values to call the
CSMSG procedure and display the error that occurred, or you can code error routines to
handle the possible errors.
Refer to the CSMSG procedure later in this section for more information about using that
procedure.
Example
Example 5–1 displays the procedure declaration portion of the CENTRALSUPPORT
Library Specifications file “SYMBOL/INTL/RPG/PROPERTIES”. The file is comprised of
Library Name Specifications, Library Subroutine Specifications and Library Parameter
Specifications. The Library Name declarations for type values and error message values
have been omitted from the example because these values are included in the individual
procedure descriptions. Table 5–3, located at the end of the section, displays the error
message values and their meaning.
All lines in the example with an asterisk (*) in column 7 are comment lines. Comment
lines are not used in the procedures; they are used for explanation and clarification.
Each time a program calls one of the RPG internationalization procedures in the
CENTRALSUPPORT procedure library, the procedure is loaded into the computer's main
processing unit. All of the procedures in the example are explained in detail later in this
section.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00010H*COPYRIGHT* * * * * * * * * * * * * * * * * * * * * * * * * * * *
:
Copyright information
:
00150L**************** CENTRALSUPPORT Library Declaration **************
00200L*
00250LIBRARY NAME CENTRALSUP F CENTRALSUPPORT
:
Error message and type value information
:
20000L* CentralSupport subroutine declarations:
20050L*
20100L******************************************************************
20150L*
20200LIBRARY SUBR CSMSG 110 GET_CS_MSG_STAR
20250L* ===== ===============
20300L*
20350L* Parameter ALGOL Equivalent
20400L* --------- ----------------
20450L* MSG_NUM INTEGER MSG_NUM
20500L* LANG EBCDIC ARRAY LANG [*]
20550L* INTEGER LANG_SIZE
20600L* MSG EBCDIC ARRAY MSG [*]
20650L* INTEGER MSG_SIZE
20700L* MSG_LEN INTEGER MSG_LEN
20750L*
20800LIBRARY PARAM MSG_NUM 110V
20850LIBRARY PARAM LANG RL
20900LIBRARY PARAM MSG RL
20950LIBRARY PARAM MSG_LEN 110R
21000L*
21050L******************************************************************
21100L*
21150LIBRARY SUBR CENTSTATUS 110 CENTRALSTATUS_STAR
21200L* ========== ==================
21250L*
21300L* Parameter ALGOL Equivalent
21350L* --------- ----------------
21400L* SYS_INFO EBCDIC ARRAY SYS_INFO [*]
21450L* INTEGER SYS_INFO_SIZE
21500L* CTL_INFO INTEGER ARRAY CONTROL_INFO [*]
21550L* INTEGER CONTROL_INFO_SIZE
21600L*
21650LIBRARY PARAM SYS_INFO RL
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
21700LIBRARY PARAM CTL_INFO 110RL
21750L*
21800L******************************************************************
21850L*
21900LIBRARY SUBR CCSVSNNUM 110 VALIDATE_NAME_RETURN_NUM_STAR
21950L* ========= =============================
22000L*
22050L* Parameter ALGOL Equivalent
22100L* --------- ----------------
22150L* CCSVSN INTEGER CCSVSN_TYPE
22200L* NAMEARY EBCDIC ARRAY NAME_ARY [*]
22250L* INTEGER NAME_SIZE
22300L* NUM INTEGER NUM
22350L*
22400LIBRARY PARAM CCSVSN 110V
22450LIBRARY PARAM NAMEARY RL
22500LIBRARY PARAM NUM 110R
22550L*
22600L******************************************************************
22650L*
22700LIBRARY SUBR CCSVSNNAME 110 VALIDATE_NUM_RETURN_NAME_STAR
22750L* ========== =============================
22800L*
22850L* Parameter ALGOL Equivalent
22900L* --------- ----------------
22950L* CCSVSN INTEGER CCSVSN_TYPE
23000L* NUM INTEGER NUM
23050L* NAMEARY EBCDIC ARRAY NAME_ARY [*]
23100L* INTEGER NAME_SIZE
23150L*
23200LIBRARY PARAM CCSVSN 110V
23250LIBRARY PARAM NUM 110V
23300LIBRARY PARAM NAMEARY RL
23350L*
23400L******************************************************************
23450L*
23500LIBRARY SUBR CCSVSNLIST 110 CCSVSN_NAMES_NUMS_STAR
23550L* ========== ======================
23600L*
23650L* Parameter ALGOL Equivalent
23700L* --------- ----------------
23750L* CCSVSN INTEGER CCSVSN_TYPE
23800L* TOTAL INTEGER TOTAL
23850L* NAMESARY EBCDIC ARRAY NAMES_ARY [*]
23900L* INTEGER NAMES_SIZE
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
23950L* NUMSARY EBCDIC ARRAY NUMS_ARY [*]
24000L* INTEGER NUMS_ARY
24050L*
24100LIBRARY PARAM CCSVSN 110V
24150LIBRARY PARAM TOTAL 110R
24200LIBRARY PARAM NAMESARY RL
24250LIBRARY PARAM NUMSARY 110RL
24300L*
24350L******************************************************************
24400L*
24450LIBRARY SUBR CCSTRANTXT 110 CCSTOCCS_TRANS_TEXT_STAR
24500L* ========== ========================
24550L*
24600L* Parameter ALGOL Equivalent
24650L* --------- ----------------
24700L* CCSFROM INTEGER CCSNUMFROM
24750L* CCSTO INTEGER CCSNUMTO
24800L* SOURCE EBCDIC ARRAY SOURCE [*]
24850L* INTEGER SOURCE_SIZE
24900L* STRT_SRCE INTEGER SOURCE_START
24950L* DEST EBCDIC ARRAY DEST [*]
25000L* INTEGER DEST_SIZE
25050L* STRT_DEST INTEGER DEST_START
25100L* TRANSLEN INTEGER TRANSLEN
25150L*
25200LIBRARY PARAM CCSFROM 110V
25250LIBRARY PARAM CCSTO 110V
25300LIBRARY PARAM SOURCE RL
25350LIBRARY PARAM STRT_SRCE 110V
25400LIBRARY PARAM DEST RL
25450LIBRARY PARAM STRT_DEST 110V
25500LIBRARY PARAM TRANSLEN 110V
25550L*
25600L******************************************************************
25650L*
25700LIBRARY SUBR VSNTRANTXT 110 VSNTRANS_TEXT_STAR
25750L* ========== ==================
25800L*
25850L* Parameter ALGOL Equivalent
25900L* --------- ----------------
25950L* VSNNUM INTEGER VSN_NUM
26000L* SOURCE EBCDIC ARRAY SOURCE [*]
26050L* INTEGER SOURCE_SIZE
26100L* SRCE_STRT INTEGER SOURCE_START
26150L* DEST EBCDIC ARRAY DEST [*]
26200L* INTEGER DEST_SIZE
26250L* DEST_STRT INTEGER DEST_START
26300L* TRANSLEN INTEGER TRANSLEN
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
26350L* TTABLETYP INTEGER TTABLE_TYPE
26400L*
26450LIBRARY PARAM VSNNUM 110V
26500LIBRARY PARAM SOURCE RL
26550LIBRARY PARAM SRCE_STRT 110V
26600LIBRARY PARAM DEST RL
26650LIBRARY PARAM DEST_STRT 110V
26700LIBRARY PARAM TRANSLEN 110V
26750LIBRARY PARAM TTABLETYP 110V
26800L*
26850L******************************************************************
26900L*
26950LIBRARY SUBR VSNINSPTXT 110 VSNINSPECT_TEXT_STAR
27000L* ========== ====================
27050L*
27100L* Parameter ALGOL Equivalent
27150L* --------- ----------------
27200L* VSNNUM INTEGER VSN_NUM
27250L* TEXT EBCDIC ARRAY TEXT [*]
27300L* INTEGER TEXT_SIZE
27350L* TEXT_STRT INTEGER TEXT_START
27400L* INSPLEN INTEGER INSPECT_LEN
27450L* TSET_TYPE INTEGER TSET_TYPE
27500L* FLAG INTEGER FLAG
27550L* NUMSEEN INTEGER SCANNED_CHARS
27600L*
27650LIBRARY PARAM VSNNUM 110V
27700LIBRARY PARAM TEXT RL
27750LIBRARY PARAM TEXT_STRT 110V
27800LIBRARY PARAM INSPLEN 110V
27850LIBRARY PARAM TSET_TYPE 110V
27900LIBRARY PARAM FLAG 110V
27950LIBRARY PARAM NUMSEEN 110R
28000L*
28050L******************************************************************
28100L*
28150LIBRARY SUBR VSNCOMPTXT 110 VSNCOMPARE_TEXT_STAR
28200L* ========== ====================
28250L*
28300L* Parameter ALGOL Equivalent
28350L* --------- ----------------
28400L* VSNNUM INTEGER VSN_NUM
28450L* TEXT1 EBCDIC ARRAY TEXT1 [*]
28500L* INTEGER TEXT1_SIZE
28550L* TXT1_STRT INTEGER TEXT1_START
28600L* TEXT2 EBCDIC ARRAY TEXT2 [*]
28650L* INTEGER TEXT2_SIZE
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
28700L* TXT2_STRT INTEGER TEXT2_STRT
28750L* COMPLEN INTEGER COMPARE_LEN
28800L* RLTN INTEGER RLTN
28850L* ORD_TYPE INTEGER ORD_TYPE
28900L*
28950LIBRARY PARAM VSNNUM 110V
29000LIBRARY PARAM TEXT1 RL
29050LIBRARY PARAM TXT1_STRT 110V
29100LIBRARY PARAM TEXT2 RL
29150LIBRARY PARAM TXT2_STRT 110V
29200LIBRARY PARAM COMPLEN 110V
29250LIBRARY PARAM RLTN 110V
29300LIBRARY PARAM ORD_TYPE 110V
29350L*
29400L******************************************************************
29450L*
29500LIBRARY SUBR VSNGETORD1 110 VSNGETORDERINGFOR_ONE_TEXT_STAR
29550L* ========== ===============================
29600L*
29650L* Parameter ALGOL Equivalent
29700L* --------- ----------------
29750L* VSNNUM INTEGER VSN_NUM
29800L* SOURCE EBCDIC ARRAY SOURCE [*]
29850L* INTEGER SOURCE_SIZE
29900L* SRC_STRT INTEGER SOURCE_START
29950L* ITEXTLEN INTEGER ITEXT_LEN
30000L* DEST EBCDIC ARRAY DEST [*]
30050L* INTEGER DEST_SIZE
30100L* DEST_STRT INTEGER DEST_START
30150L* MAXOSVS INTEGER MAX_OSVS
30200L* TOT_STRG INTEGER TOTAL_STORAGE
30250L* ORD_TYPE INTEGER ORD_TYPE
30300L*
30350LIBRARY PARAM VSNNUM 110V
30400LIBRARY PARAM SOURCE RL
30450LIBRARY PARAM SRC_STRT 110V
30500LIBRARY PARAM ITEXTLEN 110V
30550LIBRARY PARAM DEST RL
30600LIBRARY PARAM DEST_STRT 110V
30650LIBRARY PARAM MAXOSVS 110V
30700LIBRARY PARAM TOT_STRG 110V
30750LIBRARY PARAM ORD_TYPE 110V
30800L*
30805L******************************************************************
30810L*
30815LIBRARY SUBR MCPLANGS 110 MCP_BOUND_LANGUAGES_STAR
30820L* ======== ========================
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
30825L*
30830L* Parameter ALGOL Equivalent
30835L* --------- ----------------
30840L* TOTAL INTEGER TOTAL
30845L* LANGS_ARY EBCDIC ARRAY LANGUAGES_ARRAY [*]
30850L* INTEGER LANG_ARY_SIZE
30855L*
30860LIBRARY PARAM TOTAL 110
30865LIBRARY PARAM LANGS_ARY RL
30870L*
30875L******************************************************************
30880L*
30885LIBRARY SUBR VSNESCAPE 110 VSNESCAPEMENT_STAR
30890L* ========= ==================
30895L*
30900L* Parameter ALGOL Equivalent
30905L* --------- ----------------
30910L* VSNNUM INTEGER VSN_NUM
30915L* SOURCE EBCDIC ARRAY SOURCE [*]
30920L* INTEGER SOURCE_SIZE
30925L* SRC_STRT INTEGER SOURCE_START
30935L* DEST EBCDIC ARRAY DEST [*]
30940L* INTEGER DEST_SIZE
30950L* TRANSLEN INTEGER TRANS_LEN
30955L*
30960LIBRARY PARAM VSNNUM 110V
30965LIBRARY PARAM SOURCE RL
30970LIBRARY PARAM SRC_STRT 110V
30980LIBRARY PARAM DEST RL
30990LIBRARY PARAM TRANSLEN 110R
30995L*
40000L******************************************************************
40050L* CentralSupport Conventions procedures:
40100L*
40150L*
40200LIBRARY SUBR CNVLIST 110 CNV_NAMES_STAR
40250L* ======= ==============
40300L*
40350L* Parameter ALGOL Equivalent
40400L* --------- ----------------
40450L* TOTAL INTEGER TOTAL
40500L* NAMESARY EBCDIC ARRAY NAMES_ARY [*]
40550L* INTEGER NAMESARY_SIZE
40600L*
40650LIBRARY PARAM TOTAL 110R
40700LIBRARY PARAM NAMES_ARY RL
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
40750L*
40800L******************************************************************
40850L*
40900LIBRARY SUBR CNVTPLT 110 CNV_TEMPLATE_STAR
40950L* ======= =================
41000L*
41050L* Parameter ALGOL Equivalent
41100L* --------- ----------------
41150L* TYP INTEGER TYP
41200L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
41250L* INTEGER CNVNAME_SIZE
41300L* TPLT_LEN INTEGER TMP_LEN
41350L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
41400L*
41450LIBRARY PARAM TYP 110V
41500LIBRARY PARAM CNV_NAME RL
41550LIBRARY PARAM TPLT_LEN 110R
41600LIBRARY PARAM TPLT_ARY RL
41650L*
41700L******************************************************************
41750L*
41800LIBRARY SUBR CNVFORMSIZ 110 CNV_FORMSIZE_STAR
41850L* ========== =================
41900L*
41950L* Parameter ALGOL Equivalent
42000L* --------- ----------------
42050L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
42100L* INTEGER CNVNAME_SIZE
42150L* LPP INTEGER LPP (LINES PER PAGE)
42200L* CPL INTEGER CPL (CHARACTERS PER LINE)
42250L*
42300LIBRARY PARAM CNV_NAME RL
42350LIBRARY PARAM LPP 110R
42400LIBRARY PARAM CPL 110R
42450L*
42500L******************************************************************
42550L*
42600LIBRARY SUBR CNVSYMBOLS 110 CNV_SYMBOLS_STAR
42650L* ========== ================
42700L*
42750L* Parameter ALGOL Equivalent
42800L* --------- ----------------
42850L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
42900L* INTEGER CNVNAME_SIZE
42950L* TOTAL INTEGER TOTAL
42960L* SYM_LRY INTEGER ARRAY SYMLEN_ARY [*]
42980L* INTEGER SYMLYN_SIZE
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
43000L* SYM_ARY EBCDIC ARRAY SYM_ARY [*]
43050L* INTEGER SYMARY_SIZE
43100L*
43150L*LIBRARY PARAM CNV_NAME RL
43200L*LIBRARY PARAM TOTAL 110R
43220L*LIBRARY PARAM SYM_LRY 110RL
43250L*LIBRARY PARAM SYM_ARY RL
43300L*
43350L*********************************************************************
43400L*
43450LIBRARY SUBR CNVDSPYMDL 110 CNV_DISPLAYMODEL_STAR
43500L* ========== =====================
43550L*
43600L* Parameter ALGOL Equivalent
43650L* --------- ----------------
43700L* TYP INTEGER TYP
43750l* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
43800L INTEGER CNVNAME_SIZE *
43850L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
43900L* INTEGER LANGNAME_SIZE
43950L* DM_LEN INTEGER DM_LEN
44000L* DM_ARY EBCDIC ARRAY DM_ARY [*]
44050L* INTEGER DMARY_SIZE
44100L*
44150LIBRARY PARAM TYP 110V
44200LIBRARY PARAM CNV_NAME RL
44250LIBRARY PARAM LANG_NAME RL
44300LIBRARY PARAM DM_LEN 110R
44350LIBRARY PARAM DM_ARY RL
44400L*
44450L************************************************************************44
500L*
44550LIBRARY SUBR CNVDATTIM 110 CNV_SYSTEMDATETIME_STAR
44600L* ========= =======================
44650L*
44700L* Parameter ALGOL Equivalent
44750L* --------- ----------------
44800L* TYP INTEGER TYPE
44850L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
44900L* INTEGER CNVNAME_SIZE *
44950L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
45000L* INTEGER LANGNAME_SIZE
45050L* DATE_LEN INTEGER DATE_LEN (LENGTH OF DATE IN SDT_ARY)
45100L* SDT_LEN INTEGER SDT_LEN
45150L* SDT_ARY EBCDIC ARRARY SDT_ARY [*] (SYSTEM DATE/TIME ARRAY)
45200L* INTEGER SDTARY_SIZE
45250L*
45300LIBRARY PARAM TYPE 110V
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
45350LIBRARY PARAM CNV_NAME RL
45400LIBRARY PARAM LANG_NAME RL
45450LIBRARY PARAM DATE_LEN 110R
45500LIBRARY PARAM SDT_LEN 110R
45550LIBRARY PARAM SDT_ARY RL
45600L*
45650L************************************************************************
45700L*
45750LIBRARY SUBR TPLTDATTIM 110 CNV_SYSTEMDATETIMETMP_STAR
45800L* ========== ==========================
45850L*
45900L* Parameter ALGOL Equivalent
45950L* --------- ----------------
46000L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
46050L* INTEGER TMPARY_SIZE
46100L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
46150L* INTEGER LANGNAME_SIZE
46200L* DTPLT_LEN INTEGER DTEMP_LEN (LENGTH OF DATE IN TPLT_ARY)
46250L* DATE_LEN INTEGER DATE_LEN (LENGTH OF DATE IN SDT_ARY)
46300L* SDT_LEN INTEGER SDT_LEN
46350L* SDT_ARY EBCDIC ARRARY SDT_ARY [*] (SYSTEM DATE/TIME ARRAY)
46400L* INTEGER SDTARY_SIZE
46450L*
46500LIBRARY PARAM TPLT_ARY RL
46550LIBRARY PARAM LANG_NAME RL
46600LIBRARY PARAM DTPLT_LEN 110R
46650LIBRARY PARAM DATE_LEN 110R
46700LIBRARY PARAM SDT_LEN 110R
46750LIBRARY PARAM SDT_ARY RL
46800L*
46850L*************************************************************************4
6900L*
46950LIBRARY SUBR CNVDATE 110 CNV_FORMATDATE_STAR
47000L ======= ===================
47050L*
47100L* Parameter ALGOL Equivalent
47150L* --------- ----------------
47200L* TYP INTEGER TYP
47250L* DATE_ARY EBCDIC ARRAY DATE_ARY [*]
47300L* INTEGER DATEARY_SIZE
47350L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
47400L* INTEGER CNVNAME_SIZE *
47450L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
47500L* INTEGER LANGNAME_SIZE
47550L* FD_LEN INTEGER FD_LEN (FORMATTED DATE_LENGTH)
47600L* FD_ARY EBCDIC ARRAY FD_ARY [*]
47650L* INTEGER FDARY_SIZE
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
47700L*
47750LIBRARY PARAM TYPE 110V
47800LIBRARY PARAM DATE_ARY RL
47850LIBRARY PARAM CNV_NAME RL
47900LIBRARY PARAM LANG_NAME RL
47950LIBRARY PARAM FD_LEN 11OR
48000LIBRARY PARAM FD_ARY RL
48050L*
48100L************************************************************************48
150L*
48200LIBRARY SUBR TPLTDATE 110 CNV_FORMATDATETMP_STAR
48250L* ======== ======================
48300L*
48350L* Parameter ALGOL Equivalent
48400L* --------- ----------------
48450L* DATE_ARY EBCDIC ARRAY DATE_ARY [*]
48500L* INTEGER DATEARY_SIZE
48550L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
48600L* INTEGER TMPARY_SIZE
48650L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
48700L* INTEGER LANGNAME_SIZE
48750L* FD_LEN INTEGER FD_LEN (FORMATTED DATE LENGTH)
48800L* FD_ARY EBCDIC ARRAY FD_ARY [*]
48850L* INTEGER FDARY_SIZE
48900L*
48950LIBRARY PARAM DATE_ARY RL
49000LIBRARY PARAM TPLT_ARY RL
49050LIBRARY PARAM LANG_NAME RL
49100LIBRARY PARAM FD_LEN 110R
49150LIBRARY PARAM FD_ARY RL
49200L*
49250L******************************************************************
49300L*
49350LIBRARY SUBR CNVTIME 110 CNV_FORMATTIME_STAR
49400L* ======= ===================
49450L*
49500L* Parameter ALGOL Equivalent
49550L* --------- ----------------
49600L* TYP INTEGER TYP
49650L* TIME_ARY EBCDIC ARRAY TIME_ARY [*]
49700L* INTEGER TIMEARY_SIZE
49750L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
49800L* INTEGER CNVNAME_SIZE
49850L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
49900L* INTEGER LANGNAME_SIZE
49950L* FT_LEN INTEGER FT_LEN (FORMATTED TIME LENGTH)
50000L* FT_ARY EBCDIC ARRAY FT_ARY [*]
50050L* INTEGER FTARY_SIZE
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
50100L*
50150LIBRARY PARAM TYP 110V
50200LIBRARY PARAM TIME_ARY RL
50250LIBRARY PARAM CNV_NAME RL
50300LIBRARY PARAM LANG_NAME RL
50350LIBRARY PARAM FT_LEN 110R
50400LIBRARY PARAM FT_ARY RL
50450L*
50500L******************************************************************
50550L*
50600LIBRARY SUBR TPLTTIME 110 CNV_FORMATTIMETMP_STAR
50650L* ======== ======================
50700L*
50750L* Parameter ALGOL Equivalent
50800L* --------- ----------------
50850L* TIME_ARY EBCDIC ARRAY TIME_ARY [*]
50900L* INTEGER TIMEARY_SIZE
50950L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
51000L* INTEGER TMPARY_SIZE
51050L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
51100L* INTEGER LANGNAME_ARY
51150L* FT_LEN INTEGER FT_LEN (FORMATTED TIME LENGTH)
51200L* FT_ARY EBCDIC ARRAY FT_ARY [*]
51250L* INTEGER FTARY_SIZE
51300L*
51350LIBRARY PARAM TIME_ARY RL
51400LIBRARY PARAM TPLT_ARY RL
51450LIBRARY PARAM LANG_NAME RL
51500LIBRARY PARAM FT_LEN 110R
51550LIBRARY PARAM FT_ARY RL
51600L*
51650L******************************************************************
51700L*
51750LIBRARY SUBR CNVCURNCY 110 CNV_CURRENCYEDIT_RPG
51800L* ========= ====================
51850L*
51900L* Parameter ALGOL Equivalent
51950L* --------- ----------------
52000L* AMT INTEGER AMT
52050L* PRECISN INTEGER PRECISION
52100L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
52150L* INTEGER CNVNAME_SIZE
52200L* CE_LEN INTEGER CE_LEN (EDITTED CURRENCY VALUE LENGTH)
52250L* CE_ARY EBCDIC ARRAY CE_ARY [*]
52300L* INTEGER CEARY_SIZE
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
52350L*
52400LIBRARY PARAM AMT 110R
52450LIBRARY PARAM PRECSN 110V
52500LIBRARY PARAM CNV_NAME RL
52550LIBRARY PARAM CE_LEN 110R
52600LIBRARY PARAM CE_ARY RL
52650L*
52700L******************************************************************
53850L*
53900LIBRARY SUBR CNVNAME 110 CNV_VALIDATENAME_STAR
53950L* ======= =====================
54000L*
54050L* Parameter ALGOL Equivalent
54100L* --------- ----------------
54150L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
54200L* INTEGER CNVNAME_SIZE
54250L*
54300LIBRARY PARAM CNV_NAME RL
54350L*
Procedure Descriptions
The following pages describe the internationalization procedures accessible from an RPG
program. The procedures reside in the CENTRALSUPPORT library.
Each description includes a general overview of the procedure, an example showing how
to call the procedure, the output produced by the procedure and an explanation of the
parameters used in the example. Not all parameters used to produce the output will be
displayed in the output.
CCSTRANTXT
The CCSTRANTXT procedure translates text from the coded character set specified in
the first parameter to the coded character set specified in the second parameter by using
a translate table. Characters are translated using a one-to-one mapping between two
coded character sets.
For example, you might want to translate text from the LATIN1 EBCDIC coded character
set to the LATIN1 ISO coded character set. Refer to the MLS Guide for a list of the
character set numbers that are available as inputs to this procedure.
Although there are many coded character set numbers, there is not a mapping table
between every combination of coded character sets. The procedure returns an error
indicating the data was not found if you pass two valid coded character set numbers for a
table that does not exist.
Refer to the MLS Guide for a list of the coded character set numbers and the mapping
table available as inputs to this procedure.
Example
Example 5–2 shows the parameter declarations and the specifications required to call the
CCSTRANTXT library procedure. Each of the parameters is explained in the text following
the example.
This example takes the input string “pa¤uelo,” which is encoded in the Latin1EBCDIC
coded character set, and translates it to the Latin1ISO coded character set. The string
“pa¤uelo” is represented by the following hexadecimal codes in Latin1EBCDIC:
978149A4859396. In Latin1ISO, the hexadecimal codes are 83969586519985958385.
You can use the MLS Guide to determine that the coded character set number for
Latin1EBCDIC is 12 and Latin1ISO is 13. You can also retrieve these numbers by calling
the procedure CCSVSNNUM with the coded character set names.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FPRINT O DISK
01500A TITLE 'OUT/RPG/CCSTRANTXT'
05000$$ INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
18000C Z-ADD12 CCSFRM 110
20000C Z-ADD13 CCSTO 110
22000C*
24000C Z-ADD0 STRTS 110
26000C Z-ADD0 STRTD 110
28000C Z-ADD7 TLEN 110
28200C*
28300C MOVEL'pa¤uelo' SOURCE 10
30000C*
32000C EEXSRCCSTRANTXTRSLT 110
34000C PARAMCCSFRM
36000C PARAMCCSTO
38000C PARAM SOURCE
40000C PARAMSTRTS
42000C PARAM DEST 10
44000C PARAMSTRTD
46000C PARAMTLEN
48000C*
48500C EXCPT
48600C* If RSLT contains the value 1, DEST should contain the following
48800C* hex codes "7061F175656C6F"
49000C*
62000C SETON LR
64000OPRINT E
66000O 'RESULT = '
68000O RSLT 3
Explanation
CCSFRM is a numeric field passed to the procedure. It contains the number of the coded
character set from which you are translating.
CCSTO is a numeric field passed to the procedure. It contains the number of the coded
character set to which you are translating the text.
STRTS is a numeric field passed to the procedure. It contains the byte offset, relative to
0 (zero), in SOURCE where the translation starts.
DEST is an alphanumeric array returned by the procedure. It contains the translated text.
The recommended array size for DEST is the same as the size for SOURCE.
STRTD is a numeric field passed to the procedure. It contains the byte offset in DEST,
relative to 0 (zero), where the translated text is to be placed.
TLEN is a numeric field passed to the procedure. It specifies the number of characters in
SOURCE to be translated, beginning at STRTS.
RSLT is a numeric field returned as the value of the procedure. It indicates whether an
error occurred during the execution of the procedure. An explanation of the error result
values can be found under “Errors” at the end of this section. You should check the
value of the procedure result whenever you use this procedure.
1001 3001
1002 3003
Output
Sample output from Example 5–2 follows:
RESULT = 1
DEST-TEXT = pa¤uelo
See Also
For more information on the error result values, see Table 5–3 later in this section.
CCSVSNLIST
This procedure returns a list of the coded character set names and numbers or a list of
the ccsversion names and numbers that are available on your system. You specify which
list you want with the first parameter to the procedure. The names and numbers are
listed in two arrays. These arrays are ordered so that the names in the names array
correspond to the numbers in the numbers array.
You might use this procedure to create a menu that lists the ccsversions from which a
user can choose. You might also use this procedure to verify that the ccsversion to be
used by your program is available on the host computer.
Example
Example 5–3 shows the parameter declarations and the specifications required to call the
CCSVSNLIST procedure. Each of the parameters is explained in the text following the
example.
This example returns a list of available ccsversion names and numbers on a system. This
is an arbitrary list of ccsversions and might not be the same on every system.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CCSVSNLIST PROCEDURE. ALL THE CCSVERSION
00400F* NAMES AND NUMBERS ARE PRINTED IN FILE FILE1.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CCSVSNLIST'
02000E NAMS 20 17
04000E NUMS 20 11 0
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD1 CCSVSN 110
10000C*
12000C EEXSRCCSVSNLISTRSLT 110
14000C PARAMCCSVSN
16000C PARAM TOTAL 110
18000C PARAM NAMS
20000C PARAM NUMS
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C 1 DO TOTAL I 110
28000C EXCPT
30000C END DO
32000C END IF
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E HEAD
37000O 20 'CCSVERSION NAME'
37200O 45 'CCSVERSION NUMBER'
37400OFILE1 E HEAD
37600O 20 '---------------'
37800O 45 '-----------------'
38000OFILE1 E
42000O NAMS,I 22
44000O NUMS,I3 37
Explanation
CCSVSN is a numeric field passed to the procedure. It allows you to specify either of the
following two types of information to be returned in the output parameters:
Value Meaning
In the above example, the names and numbers of the ccsversions are requested.
TOTAL is a numeric field returned by the procedure. It contains the number of coded
character set or ccsversion entries that exist.
NAMS is an alphanumeric array returned by the procedure. Each entry contains the name
of a coded character set or ccsversion defined in the file SYSTEM/CCSFILE. Each name
uses one element of NAMS and is 17 characters long. The MLS Guide also lists all the
coded character sets and ccsversions. The recommended array size is 340 characters.
NUMS is a numeric array returned by the procedure. NUMS contains all the coded
character set or ccsversion numbers defined in the file SYSTEM/CCSFILE. Each number
uses one element of NUMS. Each element in NUMS corresponds to a parallel entry in
NAMS. The recommended array size for NUMS is 20 words. The MLS Guide also
provides all the numbers for the coded character sets and ccsversions.
RSLT is a numeric field returned as the value of the procedure. It indicates whether an
error occurred in the CCSVSNLIST procedure. Any values other than 1 indicate an error.
An explanation of the error result values can be found under “Errors” at the end of this
section. You should check the procedure result whenever you use this procedure.
1 1001 3000
3001
3006
Output
Sample output from Example 5–3 follows:
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
CCSVSNNAME
This procedure examines the number of a coded character set or ccsversion to
determine if it resides in the file SYSTEM/CCSFILE. The first parameter designates
whether a coded character set or ccsversion is to be examined. The second parameter
specifies the number to be validated. The procedure returns the name of the given coded
character set or ccsversion number. If you supply the value –2 in the NUM parameter
when you are checking a ccsversion, the procedure checks the name of the system
default ccsversion. Refer to the MLS Guide for the list of numbers for coded character
sets and ccsversions.
As an example, you can use this procedure to display the name of the coded character
set or the ccsversion being used.
Example
Example 5–4 shows the parameter declarations and the specifications required to call the
CCSVSNNAME procedure. Each of the parameters is explained in the text following the
example.
This example checks to see if the ccsversion number 75 is valid. Assume for this
example that 75 is valid and its associated name is CanadaGP.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CCSVSNNAME PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CCSVSNNAME'
02000E NAMARY 1 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD1 CCSVSN 110
09000C Z-ADD75 NUM 110
10000C*
12000C EEXSRCCSVSNNAMERSLT 110
14000C PARAMCCSVSN
16000C PARAMNUM
18000C PARAM NAMARY
20500C*
21000C EXCPTHEAD
22000C RSLT IFEQ 1
24000C EXCPT
26000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36220O RSLT 3
36400O 9 'RESULT = '
36800OFILE1 E
37000O 'NAME = '
37200O NAMARY
Explanation
CCSVSN is a numeric field passed to the procedure. It enables you to specify either of
the following two values to be returned in output parameters:
Value Meaning
1 Ccsversion name
In Example 5–4, a ccsversion name is requested. MOVEL initializes the ccsversion name
CANADAGP and left justifies it.
NUM is a numeric field passed to the procedure. It contains the number of the coded
character set or ccsversion for which the name is being requested. The ccsversion
number 75 is being requested in Example 5–4. A value of –2 indicates that the system
default ccsversion number is examined. Refer to the MLS Guide for more information on
ccsversions.
RSLT is a numeric field returned as the value of the procedure. It indicates whether an
error occurred in the CCSVSNNAME procedure. Any value other than 1 indicates an
error. An explanation of the error result values can be found under “Errors” at the end of
this section. You should check the value of the procedure result whenever you use this
procedure.
1002 3001
1002 3003
Output
Sample output from Example 5–4 follows:
RESULT = 1
NAME = CANADAGP
See Also
For more information on the error result values, see Table 5–3 later in this section.
CCSVSNNUM
This procedure examines a coded character set or ccsversion name to determine if it
resides in the file SYSTEM/CCSFILE. The first parameter specifies whether you want to
examine a coded character set or ccsversion. The next parameter specifies the name to
be validated. The procedure returns the number of the coded character set or ccsversion
in the last parameter.
You might use this procedure to obtain the ccsversion number needed as a parameter to
other CENTRALSUPPORT library procedures.
Example
Example 5–5 shows the parameter declarations and the specifications required to call the
CCSVSNNUM procedure. Each of the parameters is explained in the text following the
example.
This example checks to see if a ccsversion named CanadaGP is valid. Assume for this
example that CanadaGP is valid and its associated number is 75.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CCSVSNNUM PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CCSVSNNUM'
02000E NAMARY 1 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD1 CCSVSN 110
09000C MOVEL'CANADAGP'NAMARY
10000C*
12000C EEXSRCCSVSNNUM RSLT 110
14000C PARAMCCSVSN
16000C PARAM NAMARY
18000C PARAM NUM 110
20500C*
21000C EXCPTHEAD
22000C RSLT IFEQ 1
24000C EXCPT
26000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36800OFILE1 E
37000O 'NUM = '
37200O NUM 3
Explanation
CCSVSN is a numeric field passed to the procedure. It enables you to specify either of
the following two values to be returned in the output parameters:
Value Meaning
1 Ccsversion number
NAMARY is an alphanumeric array passed to the procedure that contains the coded
character set or ccsversion name for which a number is being requested. The name can
be up to 17 characters long. If this parameter contains zeros or blanks and type is equal
to 1, the procedure validates the system default ccsversion.
NUM is a numeric field returned by the procedure that contains the specified coded
character set or ccsversion number. The value –2 indicates that the system default
ccsversion is being validated.
RSLT is a numeric field returned by the procedure that indicates whether an error
occurred during the execution of the procedure. The meanings of the result values are
explained under “Errors” at the end of this section. You should check the value of the
procedure result whenever you use this procedure.
Output
Sample output from Example 5–5 follows:
RESULT = 1
NUM = 75
See Also
For more information on the error result values, see Table 5–3 later in this section.
CENTSTATUS
The CENTSTATUS procedure returns the name and number of the system default
ccsversion, the name of the system default language, and the name of the system
default convention.
You might use this procedure to provide a means for your application users to inquire
about the default settings on the host computer.
Example
Example 5–6 shows the parameter declarations and the specifications required to call the
CENTSTATUS procedure. Each of the parameters is explained in the text following the
example.
This example returns the current values for the system default ccsversion, language, and
convention. These are arbitrary system values and might not be the same on every
system.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CENTSTATUS PROCEDURE. THE CURRENT
00400F* CCSVERSION, LANGUAGE, AND CONVENTION ARE PRINTED IN FILE FILE1.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CENTSTATUS'
02000E CNTL 8 11 0
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
07000ISYSINF DS
08000I 1 17 VSNNAM
09000I 18 34 LNGNAM
10000I 35 51 CNVNAM
12000C EEXSRCENTSTATUSRSLT 110
14000C PARAM SYSINF
16000C PARAM CNTL
18000C*
20000C EXCPTHEAD1
22000C*
24000C RSLT IFEQ 1
25000C EXCPTSYSGP
26000C EXCPTHEAD2
28000C EXCPTCNTLGP
32000C END IF
34000C*
36000C SETON LR
36020OFILE1 E HEAD1
36040O 'RESULT = '
36060O RSLT 3
36065OFILE1 E HEAD1
36070O ' '
36080OFILE1 E HEAD1
36100O 'SYSTEM DEFAULTS'
36120OFILE1 E HEAD1
36140O '---------------'
36200OFILE1 E SYSGP
36400O 'CCSVERSION:'
36600O VSNNAM 30
36700OFILE1 E SYSGP
36800O 'LANGUAGE:'
37000O LNGNAM 30
37100OFILE1 E SYSGP
37200O 'CONVENTION:'
37400O CNVNAM 30
37420OFILE1 E HEAD2
37440O ' '
37450OFILE1 E HEAD2
37500O 'CONTROL ARRAY'
37550OFILE1 E HEAD2
37600O 'FIELD MEANING'
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
37650O 50 'LOCATION'
37700O 64 'VALUE'
37750OFILE1 E HEAD2
37800O '-------------'
37850O 50 '--------'
37900O 64 '-----'
38000OFILE1 E CNTLGP
38500O 'SYSTEM DEFAULT '
39000O 'CCSVERSION NUMBER'
40000O CNTL,13 62
42000O 47 '1'
Explanation
SYSINF is an alphanumeric field returned by the procedure. It contains three items, each
17 characters long, in the following order:
CNTL is an alphanumeric array returned by the procedure. It should be one word long. It
contains the following information:
Location Information
RSLT is a numeric field returned by the procedure. It indicates whether an error occurred
during the execution of the procedure. Any values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1 1001 3000
1002 3001
Output
Sample output from Example 5–6 follows:
RESULT = 1
SYSTEM DEFAULTS
---------------
CCSVERSION: ASERIESNATIVE
LANGUAGE: ENGLISH
CONVENTION: ASERIESNATIVE
CONTROL ARRAY
FIELD MEANING LOCATION VALUE
------------- -------- -----
SYSTEM DEFAULT CCSVERSION NUMBER 1 0
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVCURNCY
The CNVCURNCY procedure receives a monetary value and formats it to an edited
monetary value. The procedure uses the monetary template of the convention you
specify to accomplish the editing.
The MLS Guide describes all the conventions and the type of currency editing associated
with each convention.
You might want to print a report with the numeric and currency formats for the Costa
Rica conventions (for example, CRC 89.99), or for the Norway conventions (for example,
NKR 89.99).
Example
Example 5–7 shows the parameter declarations and the specifications required to call the
CNVCURNCY library procedure. Each of the parameters is explained in the text following
the example.
This example converts a real number and edits monetary symbols from convention
Denmark into an EBCDIC string.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100E CEARY 1100
00200$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
00110IINFODS DS
00120I 1 51 SYSINF
00130I 1 17 VSNNAM
00140I 18 34 LNGNAM
00150I 35 51 CNVNAM
00900C EEXSRCNVCURNCY RSLT 110
01000C PARAMAMT
01100C PARAMPRECISN
01200C PARAM CNVNAM
01300C PARAM CELEN 110
01400C PARAM CEARY
Explanation
AMT is a numeric field passed to the procedure. It contains the monetary value to be
formatted.
PRECISN is a numeric field that specifies the number of digits in AMT to be placed after
the decimal symbol. The value of PRECISN ranges from 0 (zero) through 9.
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to format the monetary value. If this parameter contains all blanks
or zeros, the procedure will use the hierarchy to determine the convention to be used.
Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy.
CELEN is a numeric field returned by the procedure. It contains the length of the
formatted integer value CEARY.
CEARY is an alphanumeric array returned by the procedure. It contains the value of the
formatted integer. The recommended array size for CEARY is 20 characters.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Any value other than 1 indicates an
error. An explanation of the error result values can be found under “Errors” at the end of
this section. You should check the value of the procedure result whenever you use this
procedure.
1002 3002
Output
Sample output from Example 5–7 follows:
RESULT = 1
CEARY = Kr.12 345,67
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVDATE
The CNVDATE procedure receives a date and formats it using the convention and
language you have specified.
You might use this procedure to output a date according to the Greek long-date format
and Greek language, for example.
Example
Example 5–8 shows the parameter declarations and the specifications required to call the
CNVDATE library procedure. Each of the parameters is explained in the text following the
example.
This example formats the date in numeric form using the ASeriesNative convention. The
system default language is specified.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVDATE PROCEDURE. IT FORMATS A DATE IN
00400F* NUMERIC FORM USING NETHERLANDS CONVENTION. THE SYSTEM DEFAULT
00600F* LANGUAGE IS SPECIFIED.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVDATE'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10000C*
10200C Z-ADD2 TYPE 110 NUMERIC DATE
10500C MOVE '17760704'DATARY 8
10600C MOVE 'NETHERLA'CNVSTR
10800C MOVE 'NDS 'CNVMID
11000C MOVE ' ' CNVEND
11200C*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
12000C EEXSRCNVDATE RSLT 110
16000C PARAMTYPE
17000C PARAM DATARY
18000C PARAM CNVNAM
18500C PARAM LNGNAM 17
19000C PARAM FDLEN 110
20000C PARAM FDARY 10
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FDARY = '
37600O FDARY
Explanation
TYPE is a numeric field that is passed to the procedure. The value in TYPE determines
which of the following three formats will be used to format the date:
Value Meaning
CNVNAM is an alphanumeric array passed to the procedure. It contains the name of the
convention to be used to edit the date value. If this parameter contains all blanks or 17
character zeros, the procedure uses the hierarchy to determine the convention to be
used. Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy.
FDLEN is a numeric field returned by the procedure. It contains the length of the
formatted date.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
3002 3046
3006 3047
Output
Sample output from Example 5–8 follows:
RESULT = 1
FDARY = 4.7.76
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVDATTIM
This procedure formats the system-provided date, the time, or both according to the
template retrieved from the specified convention. It translates the date and time
components to the specified natural language. The system computes both the date and
time from the result of a single function call. Thus, the possibility that the date and time
are split across midnight does not exist.
You might use this procedure to output the system date, the time, or both in the Spain
convention and the Spanish language, for example.
Example
Example 5–9 shows the parameter declarations and the specifications required to call the
CNVDATTIM library procedure. Each of the parameters is explained in the text following
the example.
This example formats system date and time according to formatting definitions in
ASeriesNative convention. The form of date and time is specified by TYPE (long date
format). The formatted date is translated to English and returned in SDTARY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVDATTIM PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVDATTIM'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10000C*
10200C Z-ADD6 TYPE 110 LNG DATE NUM
10400C MOVEL'ENGLISH' LNGNAM 17
10600C MOVE 'ASERIESN'CNVSTR
10800C MOVE 'ATIVE 'CNVMID
11000C MOVE ' ' CNVEND
11200C*
12000C EEXSRCNVDATTIM RSLT 110
16000C PARAMTYPE
18000C PARAM CNVNAM
18500C PARAM LNGNAM
19000C PARAM DATLEN 110
19500C PARAM SDTLEN 110
20000C PARAM SDTARY 60
20500C*
21000C EXCPTHEAD
22000C*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'SDTARY = '
37600O SDTARY
Explanation
TYPE is a numeric field passed to the procedure that indicates which of the following
date and time formats is used when the information is returned:
Value Meaning
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to edit the date and time value. If this parameter contains all
blanks or 17 character zeros, the procedure will use the hierarchy to determine the
convention to be used. Refer to the MLS Guide for the list of convention names and the
explanation of the hierarchy. Example 5–9 requests the ASeriesNative convention.
DATLEN is a numeric field returned by the procedure. It contains the length of the
formatted date portion of the date and time. If this parameter is 0 (zero), there is no
formatted date in the output.
SDTLEN is a numeric field returned by the procedure that contains the length of the
formatted date, the time, or both. Use the expression SDTLEN-DATLEN to determine the
length of the formatted time in the output array.
SDTARY is an alphanumeric array returned by the procedure that contains the formatted
date, the formatted time, or both.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
3011 3051
3045 3052
Output
Sample output from Example 5–9 follows:
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVDSPYMDL
This procedure returns a either a numeric date or numeric time display model. A display
model is a format that you can display to the user to show the form of the requested
input. For example, YYDDMM is a display model that shows a user that the date must be
entered in that form. The procedure creates the display model according to the
convention and language that you specify.
Example
Example 5–10 shows the parameter declarations and the specifications required to call
the CNVDSPYMDL library procedure. Each of the parameters is explained in the text
following the example.
This example obtains a date display model from the ASeriesNative convention. The
display model is translated to English and returned in DMARY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVDSPYMDL PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVDSPYMDL'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10200C Z-ADD0 TYPE 110
10500C MOVE 'ASERIESN'CNVSTR
10600C MOVE 'ATIVE 'CNVMID
10700C MOVE ' ' CNVEND
10800C MOVEL'ENGLISH' LNGNAM 17
11000C*
12000C EEXSRCNVDSPYMDLRSLT 110
14000C PARAMTYPE
16000C PARAM CNVNAM
17000C PARAM LNGNAM
18000C PARAM DMLEN 110
19000C PARAM DMARY 10
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C EXCPT
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
28000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
38000OFILE1 E HEAD
40000O ' '
42000OFILE1 E
44000O 'DMARY = '
46000O DMARY
Explanation
TYPE is a numeric field passed to the procedure. It indicates whether you want the
display model to be a numeric date or a numeric time, as follows:
Value Meaning
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention from which the date or time model is retrieved. If this parameter contains all
blanks or zeros, the procedure will use the hierarchy to determine the convention to be
used. Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy. Example 5–10 requests the ASeriesNative convention.
LNGNAM is an alphanumeric field passed to the procedure. It contains the name of the
language in which the date or time components are to be displayed. The language in
Example 5–10 is English. If this parameter contains all blanks or zeros, the procedure
uses the hierarchy to determine the language to be used. Refer to the MLS Guide for
information about determining the valid language names on your system and the
explanation of the hierarchy.
DMLEN is a numeric field returned by the procedure that contains the length of data in
DMARY.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
3002
3006
Output
Sample output from Example 5–10 follows:
RESULT = 1
DMARY = mm/dd/yyyy
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVFORMSIZ
This procedure returns the default lines-per-page and characters-per-line values from the
specified convention. Each convention provides these values for use with printed output.
Example
Example 5–11 shows the parameter declarations and the specifications required to call
the CNVFORMSIZ library procedure. Each of the parameters is explained in the text
following the example.
This example obtains paper dimensions (line per page and characters per line) from the
Denmark convention.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVFORMSIZ PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVFORMSIZ'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10600C MOVEL'DENMARK' CNVNAM 17
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
11200C*
12000C EEXSRCNVFORMSIZRSLT 110
14000C PARAM CNVNAM
18000C PARAM LPP 110
18500C PARAM CPL 110
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'LINES PER PAGE = '
37600O LPP 3
38000OFILE1 E
40000O 'CHARACTERS PER LINE = '
42000O CPL 3
Explanation
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to specify the default printer form sizes. If this parameter contains
all blanks or zeros, the procedure will use the hierarchy to determine the convention to
be used. Refer to the MLS Guide for the list of convention names and the explanation of
the hierarchy. Example 5–11 requests the Denmark convention.
LPP is a numeric field returned by the procedure. It contains the default number of lines
per page specified in the convention you referenced.
CPL is a numeric field returned by the procedure. It contains the default number of
characters per line specified in the convention you referenced.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1002
Output
Sample output from Example 5–11 follows:
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVLIST
This procedure returns a list of convention names and the total number of conventions
that are available on the system. The first name listed is the system default name.
You might use this procedure to obtain the name of a convention to be used as input to
another procedure.
Example
Example 5–12 shows the parameter declarations and the specifications required to call
the CNVLIST library procedure. Each of the parameters is explained in the text following
the example.
This example obtains the names of the conventions currently available on the system.
Note that this is an arbitrary list that may differ from system to system.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVLIST PROCEDURE. ALL THE CONVENTION
00400F* NAMES ARE PRINTED IN FILE FILE1.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVLIST'
02000E NAMS 45 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
12000C EEXSRCNVLIST RSLT 110
16000C PARAM TOTAL 110
18000C PARAM NAMS
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C 1 DO TOTAL I 110
28000C EXCPT
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
30000C END DO
32000C END IF
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E HEAD
37000O 20 'CONVENTION NAMES'
37400OFILE1 E HEAD
37600O 20 '----------------'
38000OFILE1 E
42000O NAMS,I 22
Explanation
TOTAL is a numeric field returned by the procedure. It contains the total number of
conventions that reside on the system.
NAMS is an alphanumeric array returned by the procedure. Each element of the array
contains the name of a convention defined in the SYSTEM/CONVENTIONS file. Each
name uses one element of NAMS. Each name can be up to 17 characters long and is
left-justified in the field. If there are less than 17 characters in the name, the field is filled
on the right with blanks.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1 1001 3001
Output
Sample output from Example 5–12 follows:
RESULT = 1
CONVENTION NAMES
----------------
ASERIESNATIVE
Netherlands
Denmark
UnitedKingdom1
Turkey
Norway
Sweden
Greece
FranceListing
FranceBureautique
EuropeanStandard
Belgium
Spain
Switzerland
Zimbabwe
Italy
UnitedKingdom2
KENYA
NIGERIA
SOUTHAFRICA
CYRILLIC
BRAZIL
NEWZEALAND
STNDYUGOSLAVIAN
FRENCHCANADA
ARGENTINA
CHILE
COLOMBIA
COSTARICA
MEXICO
PERU
VENEZUELA
AUSTRALIA
EGYPT
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVNAME
This procedure returns a value that indicates whether the convention name specified is
currently defined on the system.
You might use this procedure to ensure that a convention used as an input parameter
exists on the system on which your program is running.
Example
Example 5–13 shows the parameter declarations and the specifications required to call
the CNVNAME library procedure. Each of the parameters is explained in the text
following the example.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVNAME PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVNAME'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10500C MOVEL'SWEDEN' CNVNAM 17
11000C*
12000C EEXSRCNVNAME RSLT 110
16000C PARAM CNVNAM
20500C*
21000C EXCPT
34000C*
36000C SETON LR
36200OFILE1 E
36400O 'RESULT = '
36600O RSLT 3
Explanation
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention that is to be checked. The convention to be checked in Example 5–13 is
Sweden.
RSLT is a numeric field returned as the procedure result. It indicates whether a
convention name is valid. The possible values for RSLT and their meanings are as
follows:
Value Meaning
Output
Sample output from Example 5–13 follows:
RESULT = 1
CNVSYMBOLS
This procedure returns a list of numeric and monetary symbols defined for a specified
convention.
Example
Example 5–14 shows the parameter declarations and the specifications required to call
the CNVSYMBOLS library procedure. Each of the parameters is explained in the text
following the example.
This example obtains monetary and numeric symbols, monetary and numeric grouping
specifications, and international currency notation defined for the Norway convention.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVSYMBOLS PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVSYMBOLS'
02000E SLN 18 11 0
04000E SAR 18 12
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10500C MOVEL'NORWAY' CNVNAM 17
11000C*
12000C EEXSRCNVSYMBOLSRSLT 110
16000C PARAM CNVNAM
18000C PARAM TOTAL 110
19000C PARAM SLN
20000C PARAM SAR
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FIELD MEANING'
37100O 50 'SYMBOL LENGTH'
37200O 75 'CONVENTION SYMBOL'
37400OFILE1 E
37600O '-------------'
38000O 50 '-------------'
40000O 75 '-----------------'
41000OFILE1 E
42000O 'INTERNATIONAL CURRENCY '
42500O 'NOTATION:'
43000O SLN,1 3 45
43500O SAR,1 78
44000OFILE1 E
45000O 'NATIONAL CURRENCY '
45100O 'NOTATION:"
45200O SLN,2 3 45
45400O SAR,2 78
46000OFILE1 E
47000O 'MONETARY THOUSANDS '
47500O 'SEPARATOR:'
47600O SLN,3 3 45
47800O SAR,3 78
48000OFILE1 E
49000O 'MONETARY DECIMAL SYMBOL:'
49200O SLN,4 3 45
49400O SAR,4 78
50000OFILE1 E
51000O 'MONETARY POSITIVE '
51500O 'SYMBOL:'
51600O SLN,5 3 45
51800O SAR,5 78
52000OFILE1 E
53000O 'MONETARY NEGATIVE '
53500O 'SYMBOL:'
53600O SLN,6 3 45
53800O SAR,6 78
54000OFILE1 E
55000O 'MONETARY LEFT ENCLOSURE '
56000O 'SYMBOL:'
56200O SLN,7 3 45
56400O SAR,7 78
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
57000OFILE1 E
58000O 'MONETARY RIGHT '
9000O 'ENCLOSURE SYMBOL:'
59200O SLN,8 3 45
59400O SAR,8 78
60000OFILE1 E
61000O 'NUMERIC THOUSANDS '
61500O 'SEPARATOR:'
61600O SLN,9 3 45
61800O SAR,9 78
62000OFILE1 E
63000O 'NUMERIC DECIMAL SYMBOL:'
63200O SLN,103 45
63400O SAR,10 78
64000OFILE1 E
65000O 'NUMERIC POSITIVE SYMBOL:'
65200O SLN,113 45
65400O SAR,11 78
66000OFILE1 E
68000O 'NUMERIC NEGATIVE SYMBOL:'
68200O SLN,123 45
68400O SAR,12 78
69000OFILE1 E
70000O 'NUMERIC LEFT ENCLOSURE '
71000O 'SYMBOL:'
71200O SLN,133 45
71400O SAR,13 78
72000OFILE1 E
73000O 'NUMERIC RIGHT ENCLOSURE '
74000O 'SYMBOL:'
74200O SLN,143 45
74400O SAR,14 78
75000OFILE1 E
76000O 'MONETARY GROUPING '
77000O 'SPECIFICATION:'
78000O SLN,153 45
80000O SAR,15 78
80500O SAR,16 90
81000OFILE1 E
82000O 'NUMERIC GROUPING '
83000O 'SPECIFICATION:'
84000O SLN,153 45
85000O SAR,17 78
86000O SAR,18 90
Explanation
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to retrieve the monetary and numeric symbols. Norway is the
convention specified in Example 5–14. If this parameter contains all blanks or zeros, the
procedure will use the hierarchy to determine the convention to be used. Refer to the
MLS Guide for the list of convention names and the explanation of the hierarchy.
TOTAL is a numeric field returned by the procedure. It contains the total number of
symbols returned.
SLN is an alphanumeric array returned by the procedure. It contains the lengths of all
symbols being returned in SAR. It has a maximum of 16 words returned.
SAR is an alphanumeric array returned by the procedure. Each element of the array
contains a symbol defined in the monetary and numeric template for the specified
convention. The corresponding entry in SLN contains the length of each symbol. A
maximum of 216 characters can be returned in SAR.
SLN and SAR are parallel arrays. Each entry in SLN specifies the number of characters
the corresponding entry in SAR has. If an entry in SLN is 0 (zero), it indicates that the
symbol is not defined and the corresponding entry in SAR is filled with blanks. If an entry
in SLN is not zero, but the corresponding SAR is all blanks, then the number of blanks
specified by the SLN entry is the symbol.
The procedure returns the convention-defined monetary and numeric templates in fixed-
length fields. Each field is 12 characters long except where noted.
The following shows the monetary and numeric symbols that are returned in the SAR
array and the offset of the field in which the symbol is returned:
The monetary and numeric groupings each occupy two adjacent fields (24 bytes) in SAR.
The monetary and numeric groupings, when present, are character strings consisting of
unsigned integers separated by commas. The integers specify the number of digits in
each group. They appear exactly as they are declared in the monetary and numeric
templates including embedded commas.
The following table shows the offset in bytes of the fields in the SLN array which contain
the symbol lengths for the monetary and numeric symbols:
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
3002
Output
Sample output from Example 5–14 follows:
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVTIME
This procedure formats the time you supply according to the convention and language
you specify.
Example
Example 5–15 shows the parameter declarations and the specifications required to call
the CNVTIME library procedure. Each of the parameters is explained in the text following
the example.
This example formats the time in numeric form using the Belgium convention. The
formatted time is returned in FTARY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVTIME PROCEDURE. IT FORMATS A TIME IN
00400F* NUMERIC FORM USING BELGIUM CONVENTION. THE SYSTEM DEFAULT
00600F* LANGUAGE IS SPECIFIED.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVTIME'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10000C*
10200C Z-ADD4 TYPE 110 NUMERIC TIME
10500C MOVEL'114958' TIMARY 10
10600C MOVE 'BELGIUM 'CNVSTR
10800C MOVE ' 'CNVMID
11000C MOVE ' ' CNVEND
11200C*
12000C EEXSRCNVTIME RSLT 110
16000C PARAMTYPE
17000C PARAM TIMARY
18000C PARAM CNVNAM
18500C PARAM LNGNAM 17
19000C PARAM FTLEN 110
20000C PARAM FTARY 45
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FTARY = '
37600O FTARY
Explanation
TYPE is a numeric field passed to the procedure. It indicates which of the following two
formats are to be used to edit the time:
Value Meaning
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to edit the time value. If this parameter contains all blanks or
zeros, the procedure will use the hierarchy to determine the convention to be used.
Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy. The name of the convention in Example 5–15 is Belgium.
FTLEN is a numeric field returned by the procedure. It contains the length of the edited
time value.
FTARY is a numeric field returned by the procedure. It contains the edited time value.
The recommended length of formatted time is 45 characters.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
3006 3052
Output
Sample output from Example 5–15 follows:
RESULT = 1
FTARY = 11:49:58
See Also
For more information on the error result values, see Table 5–3 later in this section.
CNVTPLT
This procedure returns the requested type of formatting template retrieved from the
convention definition you specify in CNVNAME.
You might want to use this procedure to improve the performance of your program. For
example, you can use the CNVTPLT procedure with a procedure that accepts a template
as an input parameter. Using both procedures enables the procedure that accepts a
template as input to be called repeatedly without it trying to locate the template at each
call.
Example
Example 5–16 shows the parameter declarations and the specifications required to call
the CNVTPLT library procedure. Each of the parameters is explained in the text following
the example.
This example retrieves a monetary editing template from the Turkey convention. The
template is returned in TMPARY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVTPLT PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVTPLT'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10400C MOVEL'TURKEY' CNVNAM 17
10600C Z-ADD5 TYP 110 MONETARY TPLT
11200C*
12000C EEXSRCNVTPLT RSLT 110
16000C PARAMTYP
18000C PARAM CNVNAM
18500C PARAM TMPLEN 110
19500C PARAM TMPARY 48
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36720OFILE1 E
36740O 'TMPLEN = '
36760O TMPLEN3
36800OFILE1 E
37000O 'TMPARY = '
37600O TMPARY
Explanation
TYP is a numeric field passed to the procedure that specifies the type of template to be
returned (monetary template format in Example 5–16). This parameter can have the
following values:
Value Meaning
Value Meaning
CNVNAM is an alphanumeric array passed to the procedure. It contains the name of the
convention that you specify. In Example 5–16, the convention is Turkey. If this parameter
contains all blanks or zeros, the procedure will use the hierarchy to determine the
convention to be used. Refer to Refer to the MLS Guide for the list of convention names
and the explanation of the hierarchy.
TMPLEN is a numeric field returned by the procedure that contains the length of the
template being returned.
TMPARY is an alphanumeric field returned by the procedure that contains the requested
template. The recommended length of a template is 48 characters.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred in the CNVTPLT procedure. Any value other than 1 indicates an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
Output
Sample output from Example 5–16 follows:
RESULT = 1
TMPLEN = 23
TMPARY =!T[.:0,3]D[,]#N[-]C[T]!
See Also
For more information on the error result values, see Table 5–3 later in this section.
CSMSG
This procedure returns an alphanumeric array of message text associated with the
designated message number. You might want to use this procedure to retrieve the text
of an error message so that it can be displayed by your program. The message number is
obtained as the result value returned from a call to one of the CENTRALSUPPORT
procedures. A message number greater than or equal to 1000 indicates an error
message.
When you call CSMSG, you can designate the language into which the message is to be
translated, and the desired length of the returned message. If the returned text is shorter
than the length specified, the procedure pads the remaining portion of the field with
blanks.
• The header, which comprises the first 80 characters of the message text returned by
CSMSG. The text in the header provides the error number and a concise text
description.
• The short description, which comprises the second 80 characters of the message
text returned by CSMSG. If space is a consideration, you might want to limit the
description of the error to the header and short description.
• The long description, which comprises the remaining characters of the message text
returned by CSMSG. The long description provides a complete explanation of the
error that was returned.
Part or all of the message text can be returned. Note that the header part starts at offset
1, the short description at offset 81, and the long description at offset 161. For example,
if you specify MSGLEN to be equal to 200 characters, then MSG would contain the
header message beginning at offset 1 and padded with blanks to offset 80, if necessary,
followed by the short description beginning at offset 81 padded with blanks to offset
160, if necessary, followed by the first 40 characters of the long description beginning at
offset 161.
The desired message length should be at least 80 characters, equal to one line of text.
Anything less results in an incomplete message. Using a length of either 80, 160, or 999
is recommended. The value of 999 causes the entire message to be returned.
Example
Example 5–17 shows the parameter declarations and the specifications required to call
CSMSG. Each of the parameters is explained in the text following the example.
This example illustrates how to get the message text associated with a
CENTRALSUPPORT error message. Assume that the sample call to CCSVSNNUM
returns the error 3004 (The requested name was not found). When the error is returned,
this example gets the first 160 characters (2 lines) of the message text for the error.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CSMSG PROCEDURE. THIS PROGRAM
00400F* INTENTIONALLY RECEIVES AN ERROR FROM THE CCSVSNNUM PROCEDURE AND
00500F* THEN USES CSMSG TO OBTAIN THE ERROR MESSAGE TEXT.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CSMSG'
02000E NAMARY 1 17
04000E MSG 2 80
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
07000ISYSINF DS
08000I 1 17 VSNNAM
09000I 18 34 LNGNAM
10000I 35 51 CNVNAM
10500C Z-ADD1 CCSVSN 110
11000C MOVEL'BADNAME' NAMARY
11500C*
12000C EEXSRCCSVSNNUM RSLT 110
14000C PARAMCCSVSN
16000C PARAM NAMARY
18000C PARAM NUM 110
22000C*
24000C RSLT IFNE 1
25000C Z-ADD160 MSGLEN 110
25500C*
26000C EEXSRCSMSG RSLT2 110
26500C PARAMRSLT
27000C PARAM LNGNAM
27500C PARAM MSG
28000C PARAM MSGLEN
28200C*
28400C EXCPTHEAD
28500C*
29000C RSLT2 IFEQ 1
29500C EXCPT
30000C END IFEQ
30500C*
32000C END IFNE
34000C*
36000C SETON LR
36020OFILE1 E HEAD
36040O 'RESULT FROM CCSVSNNUM = '
36060O RSLT 3
36065OFILE1 E HEAD
36070O ' '
36080OFILE1 E HEAD
36100O 'RESULT FROM CSMSG = '
36120O RSLT2 3
36125OFILE1 E HEAD
36130O ' '
36140OFILE1 E HEAD
36160O 'MSG = '
36200OFILE1 E
36400O MSG,1
36500OFILE1 E
36600O MSG,2
Explanation
RSLT is a numeric field passed to the procedure. It contains the number of the message
for which you want the text. These values are returned by calls on other
CENTRALSUPPORT procedures. The message numbers and their meanings are listed at
the end of this section. In Example 5–17, the RSLT field is from an executed
CCSVSNNUM procedure that requested a ccsversion number from the name
BADNAME.
LNGNAM is an alphanumeric field passed to the procedure. It specifies the language the
message is to be displayed in. If this parameter contains all blanks or zeros, the
procedure uses the default language hierarchy to determine the language to be used.
Refer to the MLS Guide for details about determining the valid language names on the
system and for the explanation of the default language hierarchy. The recommended
array size for LNGNAM is 17 characters.
MSG is an alphanumeric field returned by the procedure. It contains the message text
associated with the specified message number.
MSGLEN is a numeric field passed to the procedure that specifies the maximum length
of the message to be returned as input. It also contains an update value as an output
parameter. For output, MSGLEN specifies the actual length of the message returned by
the procedure. If MSGLEN is equal to 0 (zero), one line of text (80 characters) is returned.
If MSGLEN is between 1 and 79, then only a partial message is returned. MSGLEN
should not be greater than the size of MSG. Recommended values for MSGLEN are 80,
160, or a large number that returns all of the message. MSGLEN in Example 5–17 is 160.
RSLT2 is a numeric field returned by the procedure that indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the procedure result whenever you use this procedure.
1002 3002
3003
Output
Sample output from Example 5–17 follows:
MSG =
>>> CENTRALSUPPORT INTERFACE ERROR (#3004) <<<
INVALID CHARACTER SET OR CCSVERSION NAME
See Also
For more information on the error result values, see Table 5–3 later in this section.
MCPLANGS
This procedure returns the names of the languages that are currently bound to the
operating system. For information about binding languages to the operating system, see
the MLS Guide. You might use this procedure to see what languages are available on
your system.
Example
Example 5–18 shows the parameter declarations and the specifications required to call
the MCPLANGS library procedure. Each of the parameters is explained in the text
following the example.
This example returns the languages bound by the operating system. Assume for this
example that the bound language is German.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE MCPLANGS PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/MCPLANGS'
02000E LNGS 20 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
11500C*
12000C EEXSRMCPLANGS RSLT 110
14000C PARAM TOTAL 110
16000C PARAM LNGS
18000C*
20000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C 1 DO TOTAL I 110
29500C EXCPT
29600C END DO
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
30000C END IFEQ
30500C*
36000C SETON LR
36050OFILE1 E HEAD
36100O 'RESULT = '
36150O RSLT 3
36152OFILE1 E HEAD
36154O ' '
36160OFILE1 E HEAD
36170O 'LANGUAGES'
36175OFILE1 E HEAD
36180O '---------'
36200OFILE1 E
36400O LNGS,I
TOTAL is a numeric field returned by the procedure. It contains the total number of
languages that are bound to the operating system.
LNGSRY is an alphanumeric field returned by the procedure. It contains the names of the
languages bound to the operating system. The maximum length of each name is 17
characters, and the names are left-justified. For any name that is less than 17 characters,
the field is filled on the right with blanks. It is recommended that the size of the array be
84 characters, or 20 17-character elements. An array of that size holds 5 names.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1 1001 3000
1002 3001
Output
Sample output from Example 5–18 follows:
RESULT = 1
LANGUAGES
---------
ENGLISH
See Also
For more information on the error result values, see Table 5–3 later in this section.
TPLTDATE
This procedure formats a date according to a template. You specify the template and the
date value and the language in which the date is to be displayed. The procedure then
returns the formatted date. The template may be retrieved for any convention from the
CNVTPLT procedure. It may also be created by the user.
Example
Example 5–19 shows the parameter declarations and the specifications required to call
the TPLTDATE library procedure. Each of the parameters is explained in the text
following the example.
This example formats a date using a template provided by the calling program. The
formatted date is translated to English and returned in FDARY. The date consists of an
unabridged day of week name, abbreviated month name, numeric day of month, day of
month suffix rd, and numeric year.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE TPLTDATE PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/TPLTDATE'
02000E TPLARY 1 1 23
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10200C MOVE '19901003'DATARY 8
10400C MOVEL'ENGLISH' LNGNAM 17
11200C*
12000C EEXSRTPLTDATE RSLT 110
16000C PARAM DATARY
18000C PARAM TPLARY
18500C PARAM LNGNAM
19500C PARAM FDLEN 110
20000C PARAM FDARY 40
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FDARY = '
37600O FDARY
38000VVECTOR SEQ
40000!W!, !1N!. !DE!, !YYYY!
Explanation
DATARY is an alphanumeric array passed to the procedure. It contains the date to be
formatted. The date must be in the form YYYYMMDD. The spaces of the field have fixed
positions. You must use blanks or zeros in any fields that you omit. The date requested in
Example 5–19 is October 3, 1990.
TPLARY is an alphanumeric array passed to the procedure. The template must use the
control characters described in the MLS Guide. The recommended length of a template
is 48 characters.
LNGNAM is an alphanumeric field passed to the procedure. It contains the name of the
language to be used to format the date. If this parameter contains all blanks or zeros, the
procedure uses the hierarchy to determine the language to be used. Refer to the MLS
Guide for information about determining the valid language names on your system. The
English language is requested in Example 5–19 and is left-justified by the MOVEL
operation.
FDLEN is a numeric field returned by the procedure that contains the length of the
formatted date.
FDARY is an alphanumeric array returned by the procedure that contains the formatted
date. The recommended length of the formatted date is 45 characters.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
Output
Sample output from Example 5–19 follows:
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
TPLTDATTIM
This procedure formats the system-provided date, the time, or both according to a
template and language that you supply. The system obtains the date and time from a
single function call to avoid the possibility of splitting the date and time across midnight.
The template may be retrieved for any convention from the CNVTPLT procedure. It may
also be created by the user.
Example
Example 5–20 shows the parameter declarations and the specifications required to call
the TPLTDATTIM library procedure. Each of the parameters is explained in the text
following the example.
This example formats system date and time according to a template provided by the
calling program in TMPARY. The formatted date and time are translated to English and
returned in SDTARY. DTPLEN is set to the length of the template in TMPARY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE TPLTDATTIM PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/TPLTDATTIM'
02000E TPLARY 1 1 35
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10400C MOVEL'ENGLISH' LNGNAM 17
11000C Z-ADD21 DTPLEN 110 DATE TEMPLATE
11200C*
12000C EEXSRTPLTDATTIMRSLT 110
16000C PARAM TPLARY
18000C PARAM LNGNAM
18500C PARAMDTPLEN
19000C PARAM DATLEN 110
19500C PARAM SDTLEN 110
20000C PARAM SDTARY 40
20500C*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'SDTARY = '
37600O SDTARY
38000VVECTOR SEQ
40000!W!, !N! !D!, !YYYY! !0T!:!0M!:!0S!
Explanation
TPLARY is an alphanumeric array passed to the procedure. It contains the template you
specify, left-justified in the field. It contains the template used to format the date. If both
date and time templates are present, the date template must appear first. The
recommended length of a template is 48 characters. Refer to the MLS Guide for
information about creating a template.
LNGNAM is an alphanumeric field passed to the procedure. It contains the name of the
language to be used to format the value of the date, the time, or both. If this parameter
contains all blanks or zeros, the procedure uses the hierarchy to determine the language
to be used. Refer to the MLS Guide for information about determining the valid language
names on your system and the explanation of the hierarchy. English is the language
requested in Example 5–20.
DTPLEN is a numeric field passed to the procedure. It specifies the length of the date
template in TPLARY. If DTPLEN is 0 (zero), it indicates there is no date template in
TPLARY. If you specify both a date and time template, then the date template must
appear first in TPLARY. The length of the date template requested in Example 5–20 is 18.
The date and time are formatted if both date and time templates are present, the date is
formatted if only the date template is present, and the time is formatted if only the time
template is present.
DATLEN is a numeric field returned by the procedure. It contains the length of the
formatted date portion of the date and time.
SDTLEN is a numeric field returned by the procedure that contains the length of the
formatted date, the time, or both. Use the expression SDTLEN-DATLEN to determine the
length of the formatted time in the output array.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
TPLTTIME
This procedure formats the time you supply according to the convention and language
you specify. The template may be retrieved for any convention from the CNVTPLT
procedure. It may also be created by the user.
With this procedure, if the time template is !0t!:!0m!:0s!, the language is English, and
the input time is 1255016256, the numeric time is formatted as 12:55:01.
Example
Example 5–21 shows the parameter declarations and the specifications required to call
the TPLTTIME library procedure. Each of the parameters is explained in the text following
the example.
This example formats a caller-supplied time using a template also passed by the calling
program. Alphabetic time components are translated to English and returned in FTARY.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE TPLTTIME PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/TPLTTIME'
02000E TPLARY 1 1 23
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10200C MOVEL'114958' TIMARY 10
10400C MOVEL'ENGLISH' LNGNAM 17
11200C*
12000C EEXSRTPLTTIME RSLT 110
16000C PARAM TIMARY
18000C PARAM TPLARY
18500C PARAM LNGNAM
19500C PARAM FTLEN 110
20000C PARAM FTARY 40
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FTARY = '
37600O FTARY
38000VVECTOR SEQ
40000!T! !I! !M! !K! !S! !R!
Explanation
TIMARY is an alphanumeric array passed to the procedure. It contains the time to be
formatted in the form HHMMSSPPPP, left-justified. The partial seconds field, PPPP, is
optional. The spaces of the field have fixed positions. You must use blanks or zeros in
any fields that you omit. Example 5–21 request that the time 114958 be formatted.
TPLARY is an alphanumeric array passed to the procedure. It contains the template you
specify, left-justified in the field. The recommended length of a template is 48 characters.
Refer to the MLS Guide for information about creating a template.
FTLEN is a numeric field returned by the procedure. It contains the length of the edited
time value.
FTARY is an alphanumeric array returned by the procedure. It contains the edited time
value. The recommended length of formatted time is 45 characters.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
Output
Sample output from Example 5–21 follows:
RESULT = 1
See Also
For more information on the error result values, see Table 5–3 later in this section.
VSNCOMPTXT
This procedure compares two records, using one of three comparison methods along
with the compare relationship to be checked. The comparison is specified as one of the
following types:
• A binary comparison, which is based on the hex code values of the characters
• An equivalent comparison, which is based on the OSVs of the characters
• A logical comparison, which is based on the OSVs plus the PSVs of the characters
The procedure retrieves the OSVs and PSVs from the SYSTEM/CCSFILE based on the
specified ccsversion.
Example
Example 5–22 shows the parameter declarations and the specifications required to call
the VSNCOMPTXT library procedure. Each of the parameters is explained in the text
following the example.
This example compares two strings using the CanadaEBCDIC ccsversion. The first string
is “hotel” and the second string is “htel.” Assume the following ordering values for the
characters:
e 69 2
h 72 2
l 76 2
o 79 2
t 84 2
79 8
The compare relation value 2 is in the RLTN parameter to determine if “hotel” is equal to
“htel” using a logical comparison. You can use the MLS Guide to determine that the
ccsversion number for CanadaEBCDIC is 74. You can also retrieve this number by calling
the procedure CCSVSNNUM with the name CanadaEBCDIC.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNCOMPTXT PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNCOMPTXT'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500C MOVE 'hotel' TEXT1 5
07000C Z-ADD0 TEXT1S 110 TEXT1 START
07500C MOVE 'htel' TEXT2 5
08500C Z-ADD0 TEXT2S 110 TEXT2 START
09000C Z-ADD5 CLEN 110 COMPARE LENGT
09500C Z-ADD74 VSNNUM 110 CANADAEBCDIC
10000C Z-ADD2 RLTN 110 EQUAL COMPARE
10500C Z-ADD2 ORDTYP 110 LOGICAL ORDER
11000C*
12000C EEXSRVSNCOMPTXTRSLT 110
14000C PARAMVSNNUM
16000C PARAM TEXT1
16200C PARAMTEXT1S
16400C PARAM TEXT2 5
16600C PARAMTEXT2S
16800C PARAMCLEN
17000C PARAMRLTN
17200C PARAMORDTYP
18000C*
20000C EXCPT
34000C*
36000C SETON LR
36020OFILE1 E
36040O 'RESULT = '
36060O RSLT 3
Explanation
VSNNUM is a numeric field passed to the procedure. It contains the number of the
ccsversion that is used to compare the text records. The number can be obtained by
referring to the MLS Guide. The following values are allowed:
Value Meaning
Greater than or Specifies a ccsversion. The numbers of the ccsversions are listed in
equal to 0 the MLS Guide.
TEXT1 is an alphanumeric field passed to the procedure. It contains the first text to be
compared. The recommended array size for TEXT1 is determined by the caller.
TEXT1S is a numeric field passed to the procedure. It contains the byte offset in TEXT1,
relative to 0 (zero), at which the comparison begins.
TEXT2 is an alphanumeric field passed to the procedure. It contains the second text to be
compared. The recommended array size for TETXT2 is determined by the caller.
TEXT2S is a numeric field passed to the procedure. It contains the byte offset in TEXT2,
relative to 0 (zero), at which the comparison begins.
CLEN is a numeric field passed to the procedure. It contains the number of characters to
compare. This value cannot be longer than the length of the text records.
The strings to be compared must be of equal length or padded with blanks up to the
CLEN value. If all pairs of characters compare equally, the strings are considered equal.
Otherwise, the first pair of unequal characters encountered is compared to determine
their relative ordering. The string that contains the character with the higher ordering
(higher PSV and higher OSV) is considered to be the string with the greater value. If
substitution forms strings of unequal length, the comparison proceeds as if the shorter
string were padded with blanks on the right. This padding ensures that the strings are of
equal length.
RLTN is a numeric field passed to the procedure. It indicates the relational operator of the
comparison. The valid values are
Value Meaning
ORDTYP is a numeric field passed to the procedure. It indicates the type of comparison
to be performed by the procedure. The following are the valid values:
Valu Meaning
e
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure.
The possible values for RSLT and their meanings are as follows:
Value Meaning
0 1000 3003
1 1001 3006
1002
The meanings of the error result values are explained under “Errors” at the end of this
section.
Output
Sample output from Example 5–22 follows:
RESULT = 0
See Also
For more information on the error result values, see Table 5–3 later in this section.
VSNESCAPE
This procedure takes the input text and rearranges it according to the escapement rules
of the ccsversion. Both the character advance direction and the character escapement
direction are used. If the character advance direction is positive, then the start of the text
is the leftmost position in the destination parameter. If the character advance direction is
negative, then the start of the text is the rightmost position in the destination parameter.
From that point on, the character advance direction value and the character escapement
direction values, in combination, control where each character should be placed in
relation to the previous character.
Example
Example 5–23 shows the parameter declarations and the specifications required to call
the VSNESCAPE library procedure. Each of the parameters is explained in the text
following the example.
This example takes the string ABCDEFG and rearranges it according to the escapement
rules of the ccsversion. Assume for this example a ccsversion number of 999 with a
character advance direction of plus (+, left to right) and with the following character
escapements:
A + Left to right.
B -- Right to left.
C -- Right to left.
D -- Right to left.
E + Left to right.
F + Left to right.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNESCAPE PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNESCAPE'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD999 CCSVSN 110
09000C MOVEL'ABCDEFG' SOURCE 7
09200C Z-ADD0 SRCS 110 START, 0-RELA
09600C Z-ADD7 TRNLEN 110 TRANSLATION L
10000C*
12000C EEXSRVSNESCAPE RSLT 110
14000C PARAMCCSVSN
16000C PARAM SOURCE
17000C PARAMSRCS
18000C PARAM DEST 7
20000C PARAMTRNLEN
20500C*
21000C EXCPT
34000C*
36000C SETON LR
36200OFILE1 E
36400O 'RESULT = '
36600O RSLT 3
36800OFILE1 E
37000O 'DEST = '
37200O DEST 20
Explanation
CCSVSN is a numeric field passed to the procedure. It enables you to specify the number
of the ccsversion that is used. The ccsversion number used in Example 5–23 is 75.
Ccsversion numbers can be obtained by calling the CENTSTATUS procedure or by
referring to the MLS Guide. The following values are allowed:
Value Meaning
Greater than or Specifies a ccsversion. The numbers of the ccsversions are listed in
equal to 0 the MLS Guide.
SOURCE is an alphanumeric field passed to the procedure that contains the text for
which the escapement information is requested. The SOURCE for Example 5–23 is
“ABCDEFG”. The recommended array size for SOURCE is determined by the caller.
SRCS is a numeric field passed to the procedure. It contains the relative offset of the
location in SOURCE where the text rearranging is to begin.
DEST is a numeric field passed to the procedure. It contains the escapement information
for the input text. The recommended array size for DEST is the same as the size for
SOURCE.
TRNLEN is a numeric field passed to the procedure. It contains the length of the text that
is to be rearranged.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1 1000 3000
1001 3002
1002 3003
Output
Sample output from Example 5–23 follows:
RESULT = 1
DEST = ADCBEFG
See Also
For more information on the error result values, see Table 5–3 later in this section.
VSNGETORD1
This procedure returns the ordering information for the input text. The ordering
information determines how the input text is collated. It includes the ordering and priority
sequence values of the characters and any substitution of characters to be made when
the input text is sorted. You can choose one of the following types of ordering
information:
This example obtains the OSVs and PSVs for the input text string “ABC¯®.” The
ccsversion is CanadaEBCDIC. You can use the MLS Guide to determine that the
ccsversion for CanadaEBCDIC is 74. You can also retrieve this number by calling the
procedure CCSVSNNUM with the name CanadaEBCDIC. This example requests logical
ordering information, so both the OSVs and PSVs are returned. This example also allows
for maximum substitution, so the parameter max_osvs is equal to itext_len * 3 and the
parameter total_storage is equal to max_osvs + round(max_osvs/2.0).
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNGETORD1 PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNGETORD1'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD74 CCSVSN 110
08500C MOVE 'ABC¯®' SOURCE 5
09200C Z-ADD0 SRCS 110 START, 0-RELA
09500C Z-ADD5 TLEN 110 TRANSLATION L
09600C Z-ADD0 DESTS 110 DEST OFFSET
09650C TLEN MULT 3 MAXOSV 110
09700C Z-ADD2 ORDTYP 110 LOGICAL COMPA
09750C*
09800C MAXOSV DIV 2 TOTSTG 110 MAX BYTES
09850C MVR DECMAL 112 REMAINDER
09900C DECMAL IFGE.5
09950C TOTSTG ADD 1 TOTSTG
09970C END END IF
09980C MAXOSV ADD TOTSTG TOTSTG
10000C*
12000C EEXSRVSNGETORD1RSLT 110
14000C PARAMCCSVSN
16000C PARAM SOURCE 5
17000C PARAMSRCS
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
17500C PARAMTLEN
18000C PARAM DEST 25
18500C PARAMDESTS
19000C PARAMMAXOSV
20000C PARAMTOTSTG
20200C PARAMORDTYP
20500C*
21000C EXCPT
22000C RSLT IFEQ 1
26000C END
34000C*
36000C SETON LR
36200OFILE1 E
36400O 'RESULT = '
36600O RSLT 3
Explanation
VSNNUM is a numeric field passed to the procedure. It contains the number of the
ccsversion that is used. The number can be obtained by calling the CENTSTATUS
procedure or by referring to the MLS Guide. The following shows the allowed values:
Value Meaning
Greater than or Specifies a ccsversion. The numbers of the ccsversions are listed in
equal to 0 the MLS Guide.
SOURCE is an alphanumeric field passed to the procedure that contains the text for
which the ordering information is requested. The recommended array size for SOURCE is
determined by the caller.
SRCEST is a numeric field passed to the procedure. It contains the offset of the location
in SOURCE where the translation is to begin.
TLEN is a numeric field passed to the procedure. It contains the length of the text that is
to be translated.
DESTST is a numeric field returned by the procedure. It designates the starting offset in
DEST at which the result values are placed.
MAXOSV is a numeric field passed to the procedure. It designates the maximum number
of storage bytes to be used to store the ordering sequence values.
The value of MAXOSV should be at least the length of the input text, but it might need to
be more to allow for substitution. The maximum substitution length is 3; therefore, to
allow for substitution for every character, the value of MAXOSV is as follows:
If the number of ordering sequence values returned is less than MAXOSV, then the
destination is filled with the ordering sequence value for blank.
TOTSTG is a numeric field passed to the procedure. It defines the maximum number of
bytes needed to store the complete ordering information for the text. If you request
equivalent ordering information, TOTSTG is equal to MAXOSV. If you request logical
ordering information, you must provide space for the four-bit priority values in addition to
the space allowed for the OSVs. Each OSV has one PSV, and one byte can hold two
PSVs. Therefore, the space allowed for PSVs values is MAXOSV/2, and the value of
TOTSTG is as follows:
MAXOSV + (MAXOSV)/2
When the ordering information is returned by the procedure, all OSVs are listed first,
followed by all the PSVs.
ORDTYP is a numeric field passed to the procedure. It indicates the type of ordering
information you want, as follows:
Value Meaning
1 OSVs only
2 PSVs only
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
3002 3008
Output
Sample output from Example 5–24 is as follows:
RESULT = 1
In this sample, DEST contains the following hex data: 414243414541 454040404040
404040111221 111111111111.
See Also
For more information on the error result values, see Table 5–3 later in this section.
VSNINSPTXT
This procedure searches specified text for characters that are present or not present in a
requested truthset. The SCAND parameter is an integer that represents the number of
characters that were searched when the criteria specified in the FLAG parameter were
met. If SCAND is equal to INSLEN, then all the characters were searched, but none met
the criteria. Otherwise, adding the TEXTST value to the RSLT value gives the location of
the character, from the start of the array, that met the search criteria.
Example
Example 5–25 shows the parameter declarations and the specifications required to call
the VSNINSPTXT library procedure. Each of the parameters is explained in the text
following the example.
This example examines a record which contains two fields, a name and a phone number.
The name is verified to contain only alphabetic characters as defined by the France
ccsversion. You can use the MLS Guide to determine that the ccsversion number for
France is 35. You can also retrieve this number by calling the procedure CSSVSNNUM
with the name France.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNINSPTXT PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNINSPTXT'
02000E TEXT 1 1 40
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500C Z-ADD35 VSNNUM 110
08000C Z-ADD0 TEXTST 110 START TEXT
10000C Z-ADD40 INSLEN 110 INSPECT LEN
10400C Z-ADD13 TTYPE 110 SCAN NUMERIC
10800C Z-ADD0 FLAG 110 NOT IN TRUTHS
11000C*
12000C EEXSRVSNINSPTXTRSLT 110
14000C PARAMVSNNUM
15000C PARAM TEXT
16000C PARAMTEXTST
16200C PARAMINSLEN
16400C PARAMTTYPE
16600C PARAMFLAG
16800C PARAM SCAND 110
17000C*
17500C EXCPTHEAD
18000C*
20000C RSLT IFEQ 1
22000C EXCPT
24000C END
34000C*
36000C SETON LR
36020OFILE1 E HEAD
36040O 'RESULT = '
36060O RSLT 3
38000OFILE1 E
40000O 'SCANNED CHARACTERS = '
42000O SCAND 3
44000VVECTOR SEQ
460007775961089John Alan Smith
Explanation
VSNNUM is a numeric field passed to the procedure. It specifies the ccsversion to be
used. The ccsversion number used in Example 5–25 is 35. The following are the values
allowed for VSNNUM:
Value Meaning
TEXTST is a numeric field passed to the procedure. It contains the byte offset in TEXT,
relative to 0 (zero), at which the search begins.
INSLEN is a numeric field passed to the procedure. It specifies the number of characters
to be searched beginning at TEXTST. It specifies the maximum length of the search.
TTYPE is a numeric field passed to the procedure. It indicates the type of truthset to be
used for the search. The following are the values allowed for TTYPE and their meanings:
Value Meaning
A ccsversion is not required to have a definition for each of these truthsets. Some of the
truthsets, such as 16 and 17, are optional. A result of 4002 might be returned if the
truthset was not defined for the ccsversion. The input text remains unchanged.
FLAG is a numeric field passed to the procedure. It indicates the type of search to be
performed. The values allowed for FLAG and their meanings are as follows:
Value Meaning
0 Search the text until a character is found that is not in the requested
truthset.
RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1001 3001
1002 3003
3006
3007
Output
Sample output from Example 5–25 follows:
RESULT = 1
SCANNED CHARACTERS = 10
See Also
For more information on the error result values, see Table 5–3 later in this section.
VSNTRANTXT
This procedure applies a specified translate table to the source text and places the result
into the destination parameter. You can use the same alphanumeric field for both the
source and destination text.
You might use this procedure to translate alternate digits received as data into numerics
for arithmetic processing.
Example
Example 5–26 shows the parameter declarations and the specifications required to call
the VSNTRANTXT library procedure. Each of the parameters is explained in the text
following the example.
This example translates a string in lowercase letters to uppercase letters using the
CanadaEBCDIC ccsversion. The input string is “p¯an.” You can use the MLS Guide to
determine that the ccsversion number for CanadaEBCDIC is 74. You can also retrieve
this number by calling the procedure CCSVSNNUM with the name CanadaEBCDIC.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FPRINT O DISK
01500A TITLE 'OUT/RPG/VSNTRANTXT'
05000$$ INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
18000C MOVE 'p¯an' SOURCE 7
24000C Z-ADD74 VSNNUM 110
28000C Z-ADD4 TLEN 110
28500C Z-ADD0 STRTS 110 START SOURCE
29000C Z-ADD0 STRTD 110 START DEST
29500C Z-ADD7 TYP 110 LOW-TO-UPPER
30000C*
32000C EEXSRVSNTRANTXTRSLT 110
34000C PARAMVSNNUM
38000C PARAM SOURCE
40000C PARAMSTRTS
42000C PARAM DEST 10
44000C PARAMSTRTD
46000C PARAMTLEN
47000C PARAMTYP
48000C*
48500C EXCPTHEAD
48600C*
48700C RSLT IFEQ 1
48800C EXCPT
48900C END
49000C*
62000C SETON LR
64000OPRINT E HEAD
66000O 'RESULT = '
68000O RSLT 3
70000OPRINT E
72000O 'DEST = '
74000O DEST
Explanation
VSNNUM is a numeric field passed to the procedure. It contains the number of the
ccsversion to be used. The ccsversion contains the rules for translation of text. Refer to
the MLS Guide for a list of the ccsversion numbers. The values allowed for VSNNUM and
the meanings of the values are as follows:
Value Meaning
STRTS is a numeric field passed to the procedure It designates the byte offset, relative
to 0 (zero) in SOURCE at which translation is to begin.
DEST is an alphanumeric field returned by the procedure. It contains the translated text.
The recommended array size for DEST is the same as the size for SOURCE.
STRTD is a numeric field passed to the procedure. It indicates the starting offset location
in DEST where the translated text is to be placed.
TLEN is a numeric field passed to the procedure. It designates the number of characters
in SOURCE to translate, beginning at STRTS.
TTABLE is a numeric field passed to the procedure. It designates the type of translation
requested. The allowed values for TTABLE and their meanings are as follows:
Value Meaning
A ccsversion is not required to have a definition for each of these tables. Some of the
tables, such as 5, 6, 7, and 8, are optional. A result of 4002 might be returned if the table
was not defined for the ccsversion. The input text remains unchanged.
RSLT is a numeric field returned by the procedure that indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.
1002 3002
Output
Sample output from Example 5–26 follows:
RESULT = 1
DEST = P®AN
See Also
For more information on the error result values, see Table 5–3 later in this section.
Errors
All of the procedures in the CENTRALSUPPORT library return integer results to indicate
the success or failure of the procedure. Table 5–3 displays error codes associated with
internationalization. You can find a complete list of error codes and their explanations in
the CENTRALSUPPORT library file SYMBOL/INTL/RPG/PROPERTIES.
Values from 2000 through 2999 contain error messages in which the caller passed invalid
data to a procedure, but the CENTRALSUPPORT library was able to return some valid
data.
Values from 3000 through 3999 contain error messages in which the caller passed invalid
data to a CENTRALSUPPORT procedure, and the CENTRALSUPPORT library was unable
to return any valid data.
Table 5–3 lists the error values that can be returned for internationalization and the
specific description of each error message that you can have your program display.
Refer to the MLS Guide for a list of the complete error messages and for information
about the corrective actions to be taken if an error occurs.
3001 The output array size is smaller than the length of the data it is supposed to
contain.
3002 At least one array length is invalid or the offset + length is greater than the size
of the array.
3003 The requested number was not found.
3004 The requested name was not found.
3005 The requested number was not found.
3006 The type code specified is out of the acceptable range.
3007 The flag specified is out of the acceptable range.
3008 The space for OSVs or total storage allocated in OUTPUT is not big enough for
OSVs and/or PSVs.
3011 An invalid control character was detected in the template.
3012 The input date contains illegal characters.
3013 The input time contains illegal characters.
3014 An attempt was made to add a new convention with the name of an existing
convention.
3015 The maximum digits value is either missing or out of range.
3016 The fractional digits value is either missing or out of range.
3017 The international fractional digits value is either missing or out of range.
3018 The long date template is either missing or contains invalid information.
3019 The short date template is either missing or it contains invalid information.
3020 The numeric date template is either missing or contains invalid information.
3021 The long time template is either missing or it contains invalid information.
3022 The numeric time template is either missing or contains invalid information.
3023 The monetary template is either missing or it contains invalid information.
3024 The numeric template is either missing or it contains invalid information.
3027 The lines per page value is either missing or it is out of range.
3028 The characters per line value is either missing or it is out of range.
3029 A required symbol in either the monetary or the numeric template is missing.
3030 An invalid template length value was encountered.
3052 The hour value is outside of the valid range for the 12-hour clock. Acceptable
values are in the range 1 through 12.
3053 The minute value is outside of the valid range. Acceptable values are in the
range 0 through 59.
3054 The second value is outside of the valid range. Acceptable values are in the
range 0 through 59.
3055 The partial second value contains invalid characters.
3056 An input time is required, but it is missing.
3057 The month value is required, but it is missing
3058 The day-of-year value is outside of the valid range. Acceptable values are in the
range 1 through 365 (1 through 366 for a leap year).
3059 The day-of-year value cannot be calculated because a date component (year,
month, or day) is missing.
4002 The requested data was not found.
The RPG Indicator Summary form shown in Figure 6–1 is used for documentation
purposes to provide an accurate record of the indicators that are used and the function of
those indicators in the RPG source program.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler control option
is TRUE.
6 Contains any value as long as column 7 contains an asterisk (*).
7 Requires an asterisk (*); causes complete line to be considered a comment.
8–10 Contains record identifying indicators.
11–13 Contains input field indicators.
14–16 Contains resulting indicators from calculations.
17–19 Contains matching indicators.
20–22 Contains control level, overflow, halt, and user indicators.
23–74 Identifies functions of indicators listed in columns 8 through 22.
75–80 Contains the program identification. Any entry is valid.
The Control Specification provides the RPG compiler with information about options such
as debugging, date formatting, and sign positioning. Only one Control Specification line
can appear in an RPG program. The use of the Control Specification is optional.
Table 7–1 summarizes the field definitions for the Control Specification.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler control
option is TRUE.
6 Identifies the type of specification for each line of code. This field must be coded
with the letter H.
7 Contains an asterisk if the line is a comment.
Columns Description
Field Definitions
The fields for the Control Specification coding form are defined in the paragraphs that
follow.
An entry in a column that is not part of any of the defined fields in a specification might
cause warnings to be displayed.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 7–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105H*
00110H* This is an example of how comment lines are coded. All lines
00120H* with an asterisk in column 7 are ignored by the compiler.
00140H*
00150H* Control Specification
00170H*
00200H 1
Valid entries for the Object Output field (column 10) are
Entry Results
D Warnings are treated as syntax errors; no object code file is created by the
compiler if syntax errors are found.
Treating warnings as syntax errors has the same effect as setting the $WARNFATAL
compiler control option. If syntax errors are found or if warnings are found when
$WARNFATAL is TRUE, no object file is created by the compiler. By default, warnings do
not prevent the object code from being created.
Refer to Volume 2 of this manual for information about valid entries used with COMS.
Valid entries for the Sign Position field (column 17) are
Entry Definition
A valid nonblank entry in this column overrides any previous assignment of the sign
position with the default value or the $RSIGN compiler control option. The sign position
specified by this field can be overridden by the $RSIGN compiler control option if
different sign positions are required in the program (refer to Section 21, “Control of the
Compilation Process”).
Valid entries for the Inverted Print field (column 21) are
Entry Definition
I International format.
This column might be partly overridden by entries in the Date Format and Date Edit fields
(columns 23 and 24).
The Inverted Print field values and resulting formats are shown in Table 7–2.
Valid entries for the Date Format field (column 23) are
Entry Definition
Blank Use the format specified by the Inverted Print field (column 21).
Valid entries for the Date Edit field (column 24) are
Entry Definition
Blank Character specified by the Inverted Print field (column 21) is used as the
separator.
Entry Definition
The correspondence between characters of the ASCII character code and characters of
the EBCDIC character code is determined by standard mapping tables for EBCDIC-to-
ASCII and ASCII-to-EBCDIC translation (refer to Appendix B, “Reference Tables”).
Valid entries for the External Sign Handling field (column 40) are
Entry Definition
When positive, unpacked, unedited numeric data are written, the sign byte is
converted to alphanumeric 0 through 9. The positive sign (binary 1100) is
retained for positive, packed, unedited numeric output data. Retention of this
sign permits the writing of positive, unpacked numeric data, which cannot
otherwise be written as alphabetic characters even though no editing is done.
O Input fields are handled as described for the S option. For output fields, the
sign byte in positive, unpacked, unedited numeric output fields contains
positive zero (+0) or A through I. Positive, packed, unedited numeric output
fields retain the positive sign (binary 1100).
Any entry other than blank, S, or O is treated as a blank, and a warning message is
displayed.
Entry Definition
After each time the lines are printed, the program pauses to enable the
operator to reposition the forms. The operator can print the lines as many
times as necessary to align the forms properly.
The 1P indicator can also be used to designate output to devices other than printers.
If this field contains an entry other than blank or 1, the entry is treated as a blank and a
warning message is displayed.
Valid entries for the Zero/Blank Indicator Setting field (column 42) are
Entry Definition
Blank The default value is R for RPG II and S for RPG I dialect. Source input dialect is
determined by the Source Input Dialect field (column 51) in the Control
Specification.
R Zero/blank indicators are turned off at BOJ and are not affected by a Blank
After field specified for the associated field during output.
Halt indicators are always turned off initially, even if the indicators are used to test for
zero or blanks, and are never turned on by a Blank After field entry. Any entry other than
blank, S, or R is treated as a blank, and a warning message is displayed.
Valid entries for the File Translation field (column 43) are
Entry Definition
Valid entries for the Line Printer Skipping field (column 46) are
Entry Definition
Blank The default value is 2 for RPG II and 1 for RPG I dialect. Source input dialect is
determined by the Source Input Dialect field (column 51) in the Control
Specification.
Any entry other than 1, 2, or blank is treated as a blank, and a warning message is
displayed.
Valid entries for the Run-Time Error field (column 49) are
Entry Definition
Any entry other than S, G, or blank is treated as a blank, and a warning message is
displayed.
Valid entries for the Halt Indicator field (column 50) are
Entr Definition
y
Any entry other than S, G, or blank is treated as a blank, and a warning message is
displayed.
Valid entries for the Source Input Dialect field (column 51) are
Entry Definition
• Printer output skipping refers to channel numbers. This option can be overridden.
Refer to “Line Printer Skipping (Column 46)” in this section.
• Zero/blank indicators (except the halt indicators) are turned on at the beginning of
program execution. This option can be overridden. Refer to “Zero/Blank Indicator
Setting (Column 42)” in this section.
If more than one zero/blank indicator is used for a given field, only the first zero/blank
indicator is the related zero/blank indicator of the field.
• When a field with a related zero/blank indicator becomes 0 (zero) or blank, the related
zero/blank indicator is turned on immediately. (Fields can become 0 or blank as a
result of a Blank After entry, move operations, or arithmetic operations.) This option
can be overridden. Refer to “Zero/Blank Indicator Setting (Column 42)” in this
section.
• The last record (LR) indicator test in the PLC is bypassed. Refer to step 4 in
Section 3, “RPG Program Logic Cycle (PLC).”
• An ampersand (&) appearing in the extension portion of an edit word is written as an
ampersand (unlike RPG II, in which the ampersand is written as a blank).
Any entry other than blank or 1 is treated as a blank, and a warning message is displayed.
Valid entries for the Time of File Open field (column 52) are
Entry Definition
N All files are opened at BOJ. The $ACCESSOPEN compiler control option (if
specified) is ignored and a warning message is displayed.
Any entry other than blank or S is treated as a blank, and a warning message is
displayed.
Valid entries for the Time of File Close field (column 53) are
Entry Definition
N All open files are closed at EOF. The $EOFCLOSE compiler control option (if
specified) is ignored and a warning message is displayed.
S Consecutively processed input files, update files, and combined files are
closed at EOF. All other open files are closed at EOJ.
Any entry other than blank or S is treated as a blank, and a warning message is
displayed.
The Program Identification field is used to identify any cross-reference listing that might
need to be created for the program. For more information about cross-reference listings,
see the descriptions of the $XREF and $XREFFILES compiler control options in
Section 21, “Control of the Compilation Process.”
Every file used by an RPG program must be described through File Description
Specifications. These specifications provide information about the way the file is to be
used.
File Specifications are also required for data management files. Refer to Volume 2 of this
manual for more information.
File Specifications are also used to define key descriptions for indexed files.
Additional information about the file can be specified in the Attribute Specifications that
follow directly after the corresponding File Specifications. Refer to Section 9, “Attribute
Specifications,” for more information.
Table 8–1 summarizes the field definitions for the File Specifications form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter F.
7 Contains an asterisk if the line is a comment.
7–14 Contains a unique name for every file used by the program.
15 Specifies the way in which each file is used. Acceptable entries are I, O, U,
C, or D.
16 Describes the use of input, update, and combined files. Acceptable entries
are blank, P, S, C, T, D, F, or R.
17 Specifies the files that are to be checked for EOF during multifile
processing. Acceptable entries are blank or E.
18 Specifies that matching fields are to be checked. Acceptable entries are
blank, A, or D.
19 Specifies whether the file contains fixed–length or variable–length records.
Acceptable entries are blank, F, or V.
20–23 Specifies the block size. Allowable entries are device dependent.
24–27 Specifies the record size. The entries are device dependent.
28 Specifies, for disk files, processing by an addrout file or sequentially within
limits. Acceptable entries are blank, L, or R.
29–30 Specifies the length of a key field. Acceptable entries are 1 through 99,
right-justified.
31 Describes the format of keys within the records. Acceptable entries are
blank, K, A, P, N, I, J, L, or R.
32 Identifies the way in which a file is to be accessed or if multiple buffers are
required. Acceptable entries are I, 1 through 9, T, or blank.
33–34 Specifies the overflow indicator used to condition records of a printer file.
Acceptable entries are blank, OA through OG, or OV.
35–38 Specifies the key field starting position in each record of an indexed file.
Acceptable entries are 1 through 9999, right-justified.
39 Indicates whether an output table, array file, or printer file is further
described in the Extension Specifications or Line Counter Specifications.
Acceptable entries are blank, E, or L.
Columns Description
40–46 Identifies the I/O device to which each file is assigned. Acceptable entries
are DATACOM, DISK, GCRTAPE, ODT, PACK, PETAPE, PORT, PRINTER,
PUNCH, READER, REMOTE, SPO, TAPE, TAPE7, and TAPE9.
47–52 Assigns a name to the key field of an indexed sequential file. Any valid field
name is an acceptable entry.
53 Performs a function that depends on the entry in this field and the Device
field (columns 40–46).Acceptable entries are blank, U (unlabeled file), F
(special forms), L (exclusive use), or K (continuation line).
54–65 Specifies a continuation line option for a DISK file. The valid entry is RECNO.
66 Specifies the addition to, or the deletion from, an existing file or that
unordered records are to be loaded for indexed files. Acceptable entries are
blank, A, U, B, or D.
67 Specifies whether the file is to be translated from ASCII to EBCDIC, from
EBCDIC to ASCII, or from a translation table specified by the user.
Acceptable entries are blank, E, A, or S.
68 Indicates a primary key or whether duplicates are allowed for indexed
sequential files. Acceptable entries are blank, D, or N.
69 Specifies whether a disk file being created is delete-capable.
70 Specifies the action to be taken during the closing of a tape or disk file.
Acceptable entries are blank, C, P, U, N, R, or K.
71–72 Indicates whether or not the file is conditioned by an external indicator.
Acceptable entries are blank or U1 through U8.
75–80 Contains the program identification. Any entry is valid.
An entry in a column that is not part of any of the defined fields might cause a warning
message to be displayed.
Field Definitions
Field definitions for the File Specifications are discussed in the following paragraphs.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 8–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105F*
00110F* This is an example of how comment lines are coded. All lines
00120F* with an asterisk in column 7 are ignored by the compiler.
00140F*
00250F* File Specifications
00270F*
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
Valid entries for the File Type field (column 15) are
Entry Definition
I Input file
O Output file
U Update file
C Combined file
D Display file
Input, output, update, combined, and display files can be specified in any order, provided
that the rules specified in the discussion of primary and secondary files later in this
section are followed.
Input Files
Input files contain records used as the source of data by a program. Records are read
from a file that is described as input. Input files should be further described in the Input
Specifications, with the exception of table files, which must be described in the
Extension Specifications.
Output Files
Output files contain records that are written, printed, displayed, or punched as output
from the program. Output files normally are described in the Output Specifications. If
Output Specifications are not provided for an output file, data records are not written to
the file. The file might still be opened and closed by the PLC. If EOJ vector output is
assigned to the file in the Extension Specifications, output data are written to the file
automatically.
The File Designation field (column 16) must be blank for all output files except when a
direct file is being created. For more information, refer to the discussion of direct files in
Section 4, “Disk Files.”
Update Files
An update disk file enables the program to read a record, make the information available
for processing, and write information back into the file. A primary or secondary update
file must be updated in the same cycle as the selection of the file.
All update files normally are described in the Output Specifications and must be further
described in the Input Specifications. If Output Specifications are not provided for an
update file, data records in the file are not updated.
When a record is read by the program, the record is placed in a buffer. The only fields
that can be altered in the record buffer are the ones specified in the Output
Specifications. All other data in the record buffer remain unchanged.
Combined Files
Combined files are files used for both input and output. These files consist of records
read by the program and written as output. The records that have been read are written.
The output is as specified in the Output Specifications. Output is retained in a holding
area until the next record is read from the file. This action ensures that only one record is
written for each record read and processed by the program. Combined files must be
further described in the Input Specifications and are normally described in the Output
Specifications. If Output Specifications are not provided for a combined file, records are
not written for that file.
Display Files
Display files print a field or record directly on the operator display terminal (ODT). The
DSPLY operation must be used in the Calculation Specifications to perform the print
operation. Display files are described only in the File Specifications; that is, they do not
need Input Specifications or Output Specifications.
Valid entries for the File Designation field (column 16) are as follows:
Entry Definition
P Primary file
S Secondary file
C Chained file
D Demand file
F Full-procedural file
R Record-address file
Primary Files
A primary file is the principal file from which the program reads input records. The
primary file can be specified as input, update, or combined. An RPG program can have no
more than one primary file. If more than one primary file is defined in the File
Specifications, all primary files except the first named primary file are assumed to be
secondary files, and a warning is displayed.
If a P is not entered in any of the File Specifications, the first secondary file defined is the
primary file.
Secondary Files
A secondary file is specified for multifile processing and can be an input, update, or
combined file. Multifile processing occurs when the PLC is used to process more than
one file.
Note: Chained, table, demand, and full-procedural files do not use the PLC to process
records.
Secondary files are processed in the order in which they are entered in the File
Specifications.
Chained Files
A chained file can be an input, update, or output file. When the chained file is an input
file, it is accessed by the CHAIN operation code in the Calculation Specifications. Chained
files do not use the PLC for input.
The RPG compiler does not explicitly limit the number of chained files allowed in an RPG
program.
When the chained file is an output file, a direct file is created. Refer to the discussion of
direct files in Section 4, “Disk Files,” for more information.
Table and array files are not involved in record-selection processing at execution time.
Vector files are read before data files at execution time.
A vector output file that is written or punched at EOJ is a normal output file. This file is
indicated by the letter O in the File Type field and requires no entry in the File
Designation field (column 16).
Demand Files
A demand file can be an input, update, or combined file. Demand files can be processed
consecutively or randomly. Demand files do not use the PLC for input. Records are read
through the use of the READ and CHAIN operation codes in the Calculation
Specifications.
The RPG compiler does not explicitly limit the number of demand files allowed in an RPG
program.
Full-Procedural Files
A full-procedural file can be either an input disk file or an update disk file. The file can be
accessed randomly or consecutively. Full-procedural files do not use the PLC for input.
The READ, CHAIN, READP, and READE operation codes in the Calculation Specifications
are used to read records from full-procedural files. The READP and READE operations
are available only for EFS files.
The RPG compiler does not explicitly limit the number of full-procedural files allowed in
an RPG program.
Record-Address Files
A record-address file must be an input file. The file is not described in the Input
Specifications, but must be described in the Extension Specifications.
For a description of using limits files and addrout files, refer to Section 4, “Disk Files.”
Table 8–2 shows the relationship of the File Type (column 15) and File Designation
(column 16) fields for disk files.
Table 8–2. Summary of File Type and File Designations for Disk Files
This field must be blank for all files except primary, secondary, and record-address files
and any file processed by a record-address file.
Valid entries for the End of File field (column 17) are
Entry Definition
Blank If this entry is blank for all files, all records are read from all primary,
secondary, and cycle-driven record address files before the program ends.
E All records in this file are read and processed before the program ends.
Note: If there is an E in column 17 for a file, the program ends when EOF is reached for
that file even if EOF was not reached for other files controlled by the PLC.
An E in this field signifies that processing ends after the last record is processed in each
file for which the E was specified, except in multifile processing. For multifile processing,
if the primary file is designated with an E in column 17, all associated secondary files
continue processing after the last record has been read in the primary file; processing
stops when an unmatched record appears in each secondary file not specified with an E
in column 17.
When a data file is processed using a record-address file, the data file itself never
reaches EOF. The use of column 17 enables the program to end when the record-
address file reaches EOF.
For EFS files with multiple keys, each key is described as a separate file. For more
information, refer to the discussion of alternate index files in Section 4, “Disk Files.”
For BFS files, if more than one key is needed for an indexed file, the following rules must
be followed to describe the additional keys:
• All key descriptions pertaining to a given indexed file must follow directly after the
initial File Specifications.
• The word KEY must be entered in columns 15 through 17.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01700FFBFS UF F1350 270 8AI 2 DISK PRIK U
01720F KEY 4A 10 ALK1 D
01730F KEY 6A 14 ALK2 D
Example 8–2. BFS File with One Primary Key and Two Alternate Keys
Example
Example 8–3 shows an EFS file with a primary key (PRIK) and two alternate keys (ALK1,
ALK2) with duplicates allowed. Note that the KEYEDIOIISUPPORT library does not
create key files in the order in which you enter them.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01700FFEFS UF F1350 270 8AI 2 DISK PRIK U
01720A TITLE 'FILE/INDEX/EFS'
01730FFEFS UF F1350 270 4AI 10 DISK ALK1 D
01740A TITLE 'FILE/INDEX/EFS/KEY02'
01750FFEFS3 UF F1350 270 6AI 14 DISK ALK2 D
'FILE/INDEX/EFS/KEY01'
Example 8–3. EFS File with One Primary Key and Two Alternate Keys
Entry Definition
Blank or A Records with matching fields are checked for sequence in ascending order.
If a record from a matching file is out of sequence, a MATCH FIELD SEQUENCE ERROR
message is displayed. Refer to Appendix A, “System Messages,” for the list of error
messages.
Valid entries for the File Format field (column 19) are as follows:
Entry Definition
Record-address files and EFS disk files must always have a fixed format.
For files containing variable-length records, the beginning of each record must contain
the total size of the record. If the mnemonic value of the INTMODE attribute is EBCDIC
(the default) the size is stored in the first four characters of the record as a decimal
number. These first four characters indicate the total number of characters in the record.
If the INTMODE attribute is set to SINGLE, the size is stored in the first word of the
record in binary. The user program must maintain the total size field of the record. For
information on setting the length of variable-length records, see the discussions of the
INTMODE, SIZEVISIBLE, and BLOCKSTRUCTURE attributes in the File Attributes
Programming Reference Manual.
Example
Example 8–4 shows the specification of record lengths for variable-length records. The
INTMODE attribute has the default value of EBCDIC and the SIZEVISIBLE attribute has
the default value of TRUE. The program reads three input files, each of which has a
different record length. Each record is written to the output file. Because the output file
has variable-length records, the total size of each record is stored in the first 4 characters
of the record. The length of the first 4 characters is included in the value of the total size
of the record.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F*
00200F* Each input file has a different record length.
00300F*
00400FHEADER IP F 80 80 DISK
00500FRECORDS IS F 368 368 DISK
00600FTRAILER IS F 132 132 DISK
00700F*
00800F* The output file has variable-length records.
00900F*
01000FTAPE O V8000 372 DISK
01100IHEADER AA 01
01200I 1 80 REC1
01300IRECORDS BB 02
01400I 1 368 REC2
01500ITRAILER AA 03
01600I 1 132 REC3
01700O*
01800O* Write each record from the three input files to the output
01900O* file. Store the total size of the record in the first 4
02000O* characters. The size should include the 4 characters used
02100O* to store the size.
02200O*
02300O* REC1 is a 80 character record. The size is stored as 80+4.
02400O*
02500OTAPE D 01
02600O 4 '0084'
02700O REC1 84
02800O*
02900O* REC2 is a 368 character record. The size is stored as 368+4.
03000O*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
03100O D 02
03200O 4 '0372'
03300O REC2 372
03500O* REC3 is a 132 character record. The size is stored as 132+4.
03600O*
03700O D 03
03800O 4 '0136'
03900O REC3 136
Table 8–3 gives the minimum and maximum block and record length in characters for
specific devices.
DISK 1 9999
ODT 1 9999
PORT 1 9999
PRINTER 1 132
PUNCH (80 column) 1 80
READER (80 column) 1 80
REMOTE 1 9999
TAPE 1 9999
Note: For card and printer files, the block length must equal the length or be blank.
Table 8–4 gives the default block and record length values for specific devices.
DISK 180
PRINTER 132
All other devices 80
The block length and record length entries can be blank in certain cases.
Block Record
Length Length Result
Entries in the Block Length (columns 20–23) and Record Length(columns 24–27) fields
must be right-justified. Leading zeros can be omitted.
When a disk or tape file is created, greater efficiency is achieved if the block length of
the file is set to a value between 3000 and 6000 bytes.
Fixed-Length Records
The length of one block and one record can be entered in the Block Length (columns 20–
23) and Record Length (columns 24–27) fields, respectively. The block length must be an
integer multiple of the record length. For unblocked files, the block length must equal the
record length (card and printer files are unblocked).
Variable-Length Records
The largest record length and the largest block length are specified in the Block Length
field (columns 20–23) and the Record Length field (columns 24–27), respectively. Control
characters are included in the record length. The block size must be greater than or equal
to the record length.
Variable-length data are written to the file in fixed-size blocks. Each block contains as
many whole records as can fit into the block.
Valid entries for the Processing Mode field (column 28) are as follows:
Entry Definition
Blank Nondisk file or disk file not to be processed sequentially within limits or by an
addrout file
For an alternate index file with a noncontiguous key, this field specifies the total length in
bytes of all parts of the key field within the records of the file. The key defined by this
entry must be the same length in all records of the file.
The entry must be numeric and right-justified in the field. Leading zeros can be omitted.
The value must be the number of bytes occupied by the key field.
The key length plus the value in the Key Field Starting Location field (columns 35–38)
minus 1 must not exceed the value in the Record Length field (columns 24–27). The
maximum key field length is 99 bytes for limits files, indexed files, and alternate index
files. For more information, refer to the discussion of file processing in Section 4, “Disk
Files.”
The length is 6 bytes for addrout files except when the GSORT compiler control option is
used with the SORT compiler, in which case the length is 3 bytes.
Valid entries for the Record-Address Type field (column 31) are as follows:
Entry Definition
K, A Indexed file, alternate index file, or limits file with alphanumeric or zoned-
decimal keys
P Indexed file, alternate index file, or limits file with signed, packed keys
N Indexed file, alternate index file, or limits file with numeric keys in
alphanumeric format
J Indexed file, alternate index file, or limits file with unsigned, packed keys
L Indexed file, alternate index file, or limits file with numeric keys in separate
leading sign format
R Indexed file, alternate index file, or limits file with numeric keys in separate
trailing sign format
If the file is an alternate index file with a noncontiguous key, the field must contain an A.
If the file is an addrout file, the Record-Address Type field (column 31) contains an I and
the File Designation field (column 16) contains an R. If the file is processed by an addrout
file, the File Designation field does not contain R.
A numeric key specified for a limits file can have a different data format than the numeric
key specified for the associated indexed file. For details of the data formats, refer to the
Packed field (column 43) in Section 14, “Input Specifications.”
Valid entries for the File Organization Type field (column 32) are as follows:
Entry Definition
1-9 Sequential or direct file with the number of I/O buffers as specified
T Addrout file
If column 32 contains a T (for an addrout file), the File Designation field (column 16) must
contain an R, and the file must be assigned to disk or tape.
A limits file is defined by entering an R in the File Designation field (column 16) and 1
through 9 or blank in the File Organization Type field (column 32). If an indexed file is
processed sequentially within limits using a record-address file, the key used for
processing is the key defined in the File Specifications. Any other keys that are defined
are checked for consistency at run time.
• The use of buffers can increase the efficiency of the program when it is executed;
however, multiple I/O buffers also increase the size of the program.
• The program runs more efficiently if the number of I/O buffers is set by the system.
Leaving column 32 blank causes the system to determine the number of I/O buffers.
• Multiple I/O buffers cannot be used with table, combined, display, or indexed disk
files.
Valid entries for the Overflow Indicator field (columns 33–34) are as follows:
Entry Definition
OA–OG, OV Specifies indicator used to condition overflow printing for the file.
For more information, refer to the discussion of overflow and printer file handling in
Section 17, “Output-Format Specifications.”
Valid entries for the Extension Code field (column 39) are as follows:
Entry Definition
Blank Line Counter Specifications or Extension Specifications are not required for
this file; however, these specifications can still appear.
E Extension Specifications further describe the file. This entry is allowed only for
input table and array files, and record-address files.
L Line Counter Specifications further describe the file. This entry is allowed only
for printer output files.
Valid entries for the Device field (columns 40–46) are as follows:
SPO ODT
TAPE7 TAPE
TAPE9 TAPE
PETAPE TAPE
GCRTAPE TAPE
PACK DISK
Only one ODT (SPO) file is allowed; this file must be a display file.
Limits files can be assigned to any input device. Addrout files can be assigned only to an
input medium that is available to the SORT compiler as output. Only disk files can be
processed sequentially within limits or by addrout files.
Valid entries for the File Open or Continuation Line field (column 53) are as follows:
Entry Definition
Blank Indicates that standard labels are expected or provided for the file. If the file is
an input or update file, or any type of disk file, then the file is not available to
other programs while this program has the file open.
Entry Definition
B Applies to printer and card files only. For printer files, this entry indicates that
the file is to be written to a printer backup file. For punch files, it indicates that
the file is to be written to a punch backup file.
F Applies to printer files and indicates that special forms are required.
L Applies to disk files and indicates that the file is not available to other
programs while this program has the file open.
By default, input and update disk files are unavailable to other programs while they are
opened by the program. Input and update files can be made available to other programs
by setting the EXCLUSIVE file attribute to FALSE for the file or by setting the
$KEYEDIOIIOUTPUT compiler control option to TRUE.
If this field contains a K, this line is a continuation line. A continuation line is used to
provide additional information about an EFS disk file. A continuation line must occur
immediately after the file description line and must come before Attribute Specifications
or another file description line. Continuation lines must contain blanks in columns 7
through 52, a K in column 53, RECNO in columns 54–59, and the name of the field the
RECNO option uses for the relative record number in columns 60 through 65.
Continuation lines are valid only on EFS disk files if the $KEYEDIOIIOUTPUT compiler
control option is TRUE.
The RECNO option is used to load or randomly add records to an EFS disk file. This
option contains the relative record number of a 7–digit numeric field with zero decimal
positions. This field must be specified if records are to be added randomly to an EFS
direct or sequential file that is delete-capable. It is also required for loading an EFS direct
file that is delete-capable. columns 60 through 65 must contain the name of the field that
the RECNO option uses for the relative record number. The name must be left-justified in
the columns. The relative record number used must be that of a deleted record, that is,
one that is initialized to FF (hex). The compiler uses the relative record number in the
RECNO field to determine where a record is to be read or added.
Refer to Section 4, “Disk Files,” for examples of how to use the RECNO option.
Valid entries for the File Addition/Unordered field (column 66) are as follows:
Entry Definition
For input and output files, if an A or B is entered in this field, an ADD entry is assumed
for all output records.
For indexed files, indexes must be maintained so that records can be accessed in
ascending sequence. A DUPLICATE KEY error message occurs if an attempt is made to
write a record with a key that already exists in the file.
A KEY NOT FOUND error occurs if an attempt is made to access a record by a key value
that does not exist in the file. Refer to Appendix A, “System Messages,” for information
about DUPLICATE KEY and KEY NOT FOUND errors.
The method of adding and deleting file records depends on the type of file. Refer to the
discussions of adding and deleting records in Section 4, “Disk Files,” for more
information.
Valid entries for the File Translation field (column 67) are as follows:
Entry Definition
A This file is translated from the ASCII character code set to the EBCDIC
character code set on input, and from the EBCDIC character code set to the
ASCII character code set on output.
Valid entries for the Duplicate Keys field (column 68) are as follows:
Entry Definition
A valid entry is required in this column for all files processed using a key. One blank entry
is required for each file. When the file is created, a primary key must be defined. D and N
are not allowable entries for the primary key.
This field specifies that records can be deleted from an EFS disk file. If a file is to be
delete-capable, this field must contain a D when the file is created.
Valid entries for the Delete-Capable File field (column 69) are as follows:
Entry Definition
• The File Type field (column 15) must contain the letter O.
• The File Addition/Unordered field (column 66) must be blank.
For more information, refer to the discussion of creating disk files in Section 4, “Disk
Files.”
Valid entries for the File Close field (column 70) are as follows:
Entry Definition
A syntax error occurs if column 70 contains any other entry. The compiler displays a
warning message and ignores the close option specified in column 70 if it is inappropriate
for the device named in the Device field (columns 40–46).
To show the effects of the various close options, each type of file is discussed separately
in the paragraphs that follow.
Card Files
All close options are ignored for card files. A warning message is displayed for the
following entries: P, U, N, R, C, and K. Regardless of the specified option, the logical
connection between the program and the file is severed when the file is closed.
Tape Files
The results of the various options for tape files are described in Table 8–7.
Option Result
Blank (default close) The tape is rewound, and the logical connection between the
program and the file is severed.
P (close with purge) The tape is rewound and marked as available for output, provided
that a write-enable ring is present. The logical connection
between the program and the file is severed.
U (close with The tape is rewound. The tape unit cannot be accessed again by
unload) this program or any other program, without operator intervention.
The logical connection between the program and the file is
severed.
N (close with no The file is positioned at its end, and the tape is not rewound. The
rewind) tape unit remains assigned to the program, and the logical
connection between the program and the file is not severed until
EOJ.
R (close with The compiler displays a warning message, and the default close
remove) option is used.
C (close with The compiler displays a warning message, and the default close
crunch) option is used.
K (close with crunch The compiler displays a warning message, and the default close
and remove) option is used.
Printer Files
All close options for printer files are ignored. A warning message is displayed for entries
P, U, N, R, C, or K. Regardless of the option specified, the logical connection between
the program and the file is severed.
Disk Files
The action taken on files assigned to disk is discussed in terms of old files and new files.
An old file already exists on disk and appears in the disk directory. A new file is created
by the program, can be referred to by the program, and does not appear in the directory.
The results of the various close options for disk files are described in Table 8–8.
Blank The file remains in the directory. The file is entered into the
(default directory. The logical connection
close) between the program and the file
is severed.
P (close The file is deleted from the The file is removed from disk. The
with directory. logical connection between the
purge) program and the file is severed.
U (close The file remains in the directory. The file is entered into the
with directory. The logical connection
unload) between the program and the file
is severed.
N (close The compiler displays a warning The compiler displays a warning
with no message, and the default close message, and the default close
rewind) option is used. option is used.
R (close The file remains in the directory. The file is entered into the
with directory. If another file of the
remove) same name exists, it is deleted
from the directory. The logical
connection between the program
and the file is severed.
C (close The file remains in the directory. The file is entered into the
with directory. Any unused portions of
crunch) disk storage allocated for the file
are released as available to the
system. A file that is closed with a
crunch cannot subsequently be
extended. The logical connection
between the program and the file
is severed.
K (close The file remains in the directory. The file is entered into the
with directory. If another file of the
crunch same name exists, it is deleted
and from the directory. Any unused
remove) portions of disk storage allocated
for the file are released as
available to the system. A file
closed with a crunch cannot
subsequently be extended. The
logical connection between the
program and the file is severed.
Abnormal End
If the program ends abnormally (that is, if the program is discontinued as a result of a
run-time error, operator intervention, or both), the close options described in the
preceding paragraphs do not apply. Instead, the following actions occur:
• For disk files, new files are purged and old files are closed as described for the U
(close with unload) entry.
• Nondisk files are closed as described for the U (close with unload) entry for the
appropriate device.
Valid entries for the File Condition field (columns 71–72) are as follows:
Entry Definition
External indicators can be used to condition operations to be performed only when the
specified indicator has been set at program execution.
The external indicators U1 through U8 receive the values of the Boolean task attributes
SW1 through SW8 at the start of program execution. For information about assigning
values to task attributes, refer to the description of the EXECUTE command in the
CANDE Operations Reference Manual and the discussion of initiating processes in the
Task Attributes Reference Manual.
If all primary and secondary files are conditioned by external indicators, a warning
message is displayed.
If a file is conditioned by an external indicator, records written to the file should also be
conditioned by that indicator in the Output Specifications. If an output file is conditioned
by an external indicator, every output record described in the Output Specifications for
the file should be conditioned by that external indicator; otherwise, the object program
builds the output record and performs any Blank After operations, but suppresses the
write operation. Any calculation operations that should not be performed (especially
CHAIN and READ operations) also can be conditioned by that indicator; otherwise, the
object program automatically conditions the operation on that external indicator.
If an external indicator is entered in the File Condition field for a record-address file, the
same indicator must be assigned to the associated data file.
Attribute Specifications are available for files, libraries, COMS, and DMSII.
All Attribute Specifications for a file must immediately follow the specification for that
file. All Attribute Specifications for a particular library must immediately follow the
declaration of the library. Only one attribute for each Attribute Specification is allowed.
If an attribute is specified more than once, the last attribute setting overrides any
previous attribute setting. Attribute Specifications override attributes already specified in
the File Specifications. For example, if the Device field (columns 40–46) in the File
Specifications contains PRINTER and Attribute Specifications for that file declare the
attribute KIND to have a value of DISK, the attribute KIND is changed from PRINTER to
DISK. Refer to the File Attributes Reference Manual for more information about
attributes.
Table 9–1 summarizes the field definitions for the Attribute Specifications form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with an A.
7 Contains an asterisk (*) if the line is a comment.
7–8 Specifies whether this Attribute Specification is a continuation of the
Attribute Specifications on the preceding line. This field can contain the
entry AN or blanks.
9–65 Contains a file attribute and, optionally, an associated value.
66–71 Contains a field name for use in Calculation Specifications, or contains
blanks.
72–74 Specifies the length of the field name given in columns 66 through 71 or
contain blanks.
75–80 Contains the program identification. Any entry is valid.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Field Definitions
Field definitions for Attribute Specifications are described in the following paragraphs.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 9–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105A*
00110A* This is an example of how comment lines are coded. All lines
00120A* with an asterisk in column 7 are treated as documentation, &
00130A* are ignored by the compiler.
00140A*
Entry Definition
An attribute must appear in this field, but the attribute value is optional. If no attribute
value is given, no initial declaration of a value is made other than the normal default. Only
one attribute is allowed per line (including continuation lines).
For alphanumeric attributes, the attribute value must be an alphanumeric literal enclosed
in apostrophes.
For numeric attributes, the attribute value must be a numeric literal with no decimal
places.
Example
Example 9–2 shows various ways of coding Attribute Specifications. Included are
Attribute Specifications with numeric and Boolean attribute designations.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00500F* File Attribute Specifications
00510F*
00600F* One attribute for a file
00900F*
02000FFILE1 IP 80 80 DISK
03000A TITLE 'INPUT'
03500F*
04120F* Multiple attributes for a file
04150F*
04200FFILE2 IS 80 80 DISK
04300A BUFFERS 2
04400A NEWFILE 'FALSE'
04450F*
04600F* Attribute continuation line
04650F*
05000FFILEOUT O 132 132 PRINTER
06000A TITLE
06500AAN 'OUTPUT'
10000IFILE1 AA 01
11000I 1 2 FILLER
11100IFILE2 BB 02
11200I 1 2 FILLER
The field name can appear only in the Calculation Specifications for a MOVE, MOVEL,
COMP, or Z-ADD operation. This field name cannot name a vector and cannot appear
with any other operation in a Calculation Specifications or in any other specification
except for Attribute Specifications. In addition, the name in this field cannot appear as
the name of a data structure on Input Specifications.
This field must be blank if columns 7 and 8 contain the entry AN. If this field is blank and
an attribute value has not been specified, the compiler displays a warning message.
If the field length of an alphanumeric or mnemonic attribute identifier is greater than the
length of the attribute value, then the value is filled with blanks on the right. If the field
length of an alphanumeric or mnemonic attribute identifier is less than the length of the
attribute value, then the value is truncated on the right.
If the field length of a numeric attribute identifier is greater than the length of the
numeric attribute value, then the value is filled with zeros on the left. If the field length of
a numeric attribute identifier is less than the length of the attribute value, then the value
is truncated on the left.
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
000H S
000FINPUT IP F 80 80 DISK
100FTEST ID F 80 80 DISK
110A*
120A* Declare the field RESDNT to represent the RESIDENT attribute
140A* of the file TEST and TITLE to represent the TITLE attribute:
145A*
150A RESIDENT RESDNT 5
170A TITLE TITLE 75
200FREM O 80 80 REMOTE U
300FODT D 80 ODT
350E*
400E* Either a vector or a data structure can be used to contain the
500E* file title. This program uses a vector.
600E*
700E VEC 1 2 75
000IINPUT NS 01
000I 1 10 FLD1
100ITEST NS 02
200I 1 10 FLD1
210C*
220C* Test whether the file is resident:
225C*
230C N99 Z-ADD1 I 10
235C 99 ADD 1 I
240C MOVELVEC,I TITLE
250C RESDNT COMP 'TRUE' 50
300C EXCPTREM
320C MOVELTITLE STR 80
340C STR DSPLYODT
345C SETON 99
400OREM E
500O 50 24 'FILE IS RESIDENT'
000O N50 24 'FILE NOT RESIDENT'
000V*....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
000V* Note that this is a sequenced Vector Specification.
000V*
000VVECTOR SEQ
000FILE/THAT/IS/THERE.
000SOME/NONEXISTENT/FILE.
For a complete description of file attributes, refer to the File Attributes Reference
Manual.
Attribute Modification
File attributes can be modified by the Calculation Specifications. However, to be
modified, a field name must be associated with the attribute.
If the Result Field (columns 43–48) in the Calculations Specifications is a field name
defined in the Attribute Specifications, the Factor 2 field is used to assign the associated
attribute. If Factor 2 is a field name defined in the Attribute Specifications, the Result
Field contains the associated value for this attribute at the end of the operation.
If a field name associated with a numeric attribute is specified in the Result Field, then
Factor 2 must be either a numeric literal or a numeric variable name with zero decimal
positions.
Example
Example 9–4 shows a program that assigns and modifies file attributes.
...*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
005F*
010F* This program assigns and modifies file attributes for the
012F* files INFIL and OUTFIL. The printer backup file
014F* is routed to "STATION LP2002A".
015F*
100FINFIL IP 180 180 DISK U
200A TITLE 'FILE1 ON DISK'
300FOUTFIL O 132 132 PRINTER
400A DESTINATION DESNAM 16
500IINFIL NS
520C*
525C* When a value is moved into a pointer-valued attribute such as
530C* DESTINATION, the value must be ended with a period (.).
535C*
550C MOVEL'STATION 'WA16 16
600C MOVE 'LP2002A.'WA16
620C MOVE WA16 DESNAM
700OOUTFIL H 1P
800O 5 'HELLO'
Table 10–1 summarizes the field definitions for the Extension Specifications coding form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter E.
7 Contains an asterisk (*) if the line is a comment.
11–18 Contains the file name of a preexecution-time vector file or a record-
address file.
19–26 Contains the name of the file to which the vector is written or the file name
of the file to be processed by a record-address file.
27–32 Contains the name of the input vector. These columns are also used to
name the first of two alternating vectors.
33–35 Designates the number of entries contained in each vector input record.
36–39 Identifies the maximum number of items contained in the vector named in
columns 27 through 32. The entry must be right-justified. The maximum
entry is 9999.
40–42 Specifies the length (in bytes) of each element in the input vector named in
columns 27 through 32.
43 Designates the external vector format. Acceptable entries are the letters P,
J, L, R, B, or a blank.
44 Determines the number of decimal positions contained in each vector
element. Acceptable entries are 0 through 9 if the vector element is
numeric, or blank if the vector element is alphanumeric. Entries for
designator and COMS–time types are described in Volume 2 of this manual.
45 Specifies the sequence in which elements of the vector named in
columns 27 through 32 are loaded. Acceptable entries are the letters A and
D, or blank.
46–57 Describes the second of two alternating vectors. Entries are of the same
type as that specified for the first vector. The second vector is loaded in
alternating format with the first.
58–74 Contains comments.
75–80 Contains the program identification that appears on the source program
listing.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Field Definitions
The field definitions for the Extension Specifications are described in the following
paragraphs.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 10–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105E*
00110E* This is an example of how comment lines are coded. All lines
00120E* with an asterisk in column 7 are ignored by the compiler.
00140E*
Type of Description
Entry
Preexecution- The From Filename field is required for every preexecution-time vector
time vectors used by the program. A preexecution-time vector must be designated
as an input table file in the File Specifications.
Vector files are processed in the order in which they appear in the
Extension Specifications. Thus, if more than one vector file is specified
for the program, the files are loaded in the order in which they appear.
Record- The From Filename field is required for every record-address file used
address files by the program. The record-address file must also be designated as an
input record-address file in the File Specifications.
The same record-address file must not be named in more than one
Extension Specifications. Fields that apply to vectors (columns 27–57)
must be blank for a record-address file.
Following is a description of the entries required for output vector files and record-
address files:
Type of Description
Entry
Output vector To write any vector file, the name of the appropriate output file must
files be entered in this field. The designated output file must previously
have been described in the File Specifications as a sequential output
file. A vector can be written to only one output file and is automatically
written or punched at EOJ after all the other records have been
processed. More than one vector can be written to the same output
file.
Record-address This field must contain the name of the input or update file to be
files processed with the input record-address file specified in the From
Filename field. The input or update file name specified in this field
cannot appear in any other Extension Specification.
Table names must begin with the letters TAB. (These letters can appear alone.) Any
name that appears in this field and that does not begin with TAB is considered an array
name.
If two related vectors are in alternating format in one vector file, the first vector must be
named in this field and the second vector in the Alternating Vector Format field
(columns 46–57). Any combination of tables and arrays is allowed in alternating format.
Valid entries for the Entries per Record field are as follows:
Entry Definition
Entries in this field must be numeric and right-justified; leading zeros can be omitted.
Corresponding items from alternating vectors must be on the same record and in
alternating format. Each pair of items is considered one entry. The number of entries
specified in this field must not exceed the number specified in the Entries Per Vector
field (columns 36–39).
The following equations can be used to determine the number of entries per record:
Variable Definition
• To load a preexecution-time vector, entries are made in the Entries per Record field
and in the From Filename field (columns 11–18). Refer to the discussion of
preexecution-time vectors in this section for more information.
• To load a compile-time vector, an entry is made in the Entries per Record field and
the From Filename field (columns 11–18) is blank.
• If the From Filename (columns 11–18), To Filename (columns 19–26), and Entries per
Record (columns 33--35) fields are blank, vector loading is not implied. In this case,
vectors can be loaded by using either the Input Specifications or the Calculation
Specifications (an execution-time load). Preexecution-time and compile-time vectors
can be changed using Input Specifications or Calculation Specifications.
Table 10–2 shows the vector type resulting from the entries in the From Filename
(columns 11–18) and Entries per Record (columns 33--35) fields.
If the length of a numeric item in a vector data input record is less than the length
specified in this field, then leading zeros must be added. If the length of an alphanumeric
item in a vector data input record is less than the length specified in this field, then
leading or trailing blanks must be added.
The maximum length of a vector element is specified in the discussion of field lengths in
Section 2, “RPG Language Elements.” An element must be completely contained in one
record; therefore, input record sizes also limit the maximum size of a vector element.
For binary data, the number of decimal digits required for the element is designated in
this field. This number must be less than 9.
Entries in this field must be right-justified, and leading zeros can be omitted.
Entry Definition
Preexecution-time vectors can be packed, unless the To Filename field (columns 19–26)
indicates a printer file. Compile-time vectors must not be in packed or binary format.
When vectors are loaded or modified by the Input Specifications, the sign position and
format (packed or unpacked) described in the Input Specifications dictate the external
data format. The sign of compile-time and preexecution vectors is determined by the
Sign Position field (column 17) of the Control Specification, the $RSIGN compiler control
option, and the $FZONE compiler control option.
For details of the data formats of vectors with an entry in this field, refer to the Packed
field (column 43) in Section 14, “Input Specifications.”
This field cannot be blank for a numeric vector. If the numeric elements have no decimal
positions, a 0 (zero) must be entered.
The valid entries for the Decimal Positions field are as follows:
Entry Definition
Entry Definition
Column 45 should contain an entry if high- or low-resulting indicators are assigned when
a LOKUP operation is performed on the vector in the Calculation Specifications.
Using Vectors
Tables and arrays are logical configurations of data elements that have similar
characteristics. Because there are few differences between tables and arrays, both are
usually referred to as vectors. When differences exist in their characteristics, these
elements are referred to individually as either tables or arrays.
Vectors can be distinguished according to the time at which they are loaded with data.
Table 10–3 shows the three types of vectors and the times at which they are loaded.
Each element of a vector must have the same length and data type (numeric or
alphanumeric). All numeric elements must have the same number of decimal positions.
For information on execution-time vectors of types designator and COMS-time, see the
discussion of COMS Extension Specifications in Volume 2 of this manual.
• Array names are described in the discussion of vector names in Section 2, “RPG
Language Elements.”
• If an array name appears without an index, it refers to the entire array. Such a
reference specifies that the designated operation is to be performed repetitively,
once for each element of the array.
The following differences apply to tables:
• If a table name appears without an index, it refers to the last item designated in the
table as stored in the hold area. When no index is used, the hold area can be affected
by the LOKUP operation or other calculation operations described in Section 16,
“Operation Codes,” or by the Blank After field (column 39) in the Output
Specifications.
• A LOKUP operation can be performed on a table. If the operation is successful, the
contents of the hold area are replaced by the value of the table element that satisfies
the search conditions, and the hold pointer is updated to point to this new element. If
the operation is unsuccessful, the contents of the hold area are not modified and the
hold pointer is set to point to the first element of the table.
• A table can be updated by specifying the table name in the Result Field (columns 43–
48) in the Calculation Specifications for a calculation operation other than the LOKUP
operation. Also, a table can be updated by specifying the Blank After field
(column 39) in the Output Specifications. Both of these methods cause the contents
of the hold area and the table element (the element referred to by the hold pointer) to
be changed.
• If a table element is updated by specifying the table name with an index, only the
indexed element of the table changes. The hold area and the hold pointer are not
modified.
• If a table name is used with no index in the Factor 1 (columns 18–27) or Factor 2
(columns 33--42) fields of the Calculation Specifications, the name refers to the value
currently in the hold area for that table.
• At BOJ, the hold pointer is initialized to 1. If the table is numeric, the hold area is
initialized to zeros. If the table is alphanumeric, the hold area is initialized to blanks.
Declaring Vectors
All vectors in a program must be described in the Extension Specifications.
The following Extension Specifications fields require entries for each type of vector,
regardless of the time at which the vector is loaded:
• The Vector Name field (columns 27–32). This field specifies the vector name.
• The Entries per Record field (columns 33–35). This field identifies the number of
vector elements in each input record.
• The Entries per Vector (columns 36–39) and Length of Entry (columns 40–42) fields.
These fields determine the size of the vector.
• The Packed field (column 43). This field specifies the input data format.
• The Decimal Positions field (column 44). This field specifies the number of decimal
positions in each entry.
• The Sequence field (column 45). This field determines the order of the elements.
If the vector is loaded in alternating format with another vector, the Alternating Vector
Format fields (columns 46–57) are also used.
If the vector is to be loaded at preexecution time from the file name specified in the
From Filename field (columns 11–18), the file description in the File Specifications for
that file must include an I in the File Type field (column 15), a T in the File Designation
field (column 16), and an E in the Extension Code field (column 39).
If the vector is to be written at EOJ to the output file named in the To Filename field
(columns 19–26), the output file must be described in the File Specifications.
All vectors can be altered during program execution, regardless of when they were
initially loaded. For this reason, all vectors can be considered to have dynamic
characteristics.
• The name, including the index, can be up to 6 characters long unless it is specified in
the Factor 1 or Factor 2 field in the Calculation Specifications. In that case, the vector
name and index can be up to 10 characters long.
• The name must be unique in the RPG program.
• The value of the index must not be 0 (zero), a negative value, or more than the
number of elements in the array.
Following are examples of valid vector names:
Vector Description
Name
SALE This vector has no index; therefore, the name refers to the entire vector.
SALE,N The index is a field called N that contains the number of the element to
be used. Notice that the entire name cannot have more than 6
characters, including the comma.
SALE,3 The index is 3. The index specifies the actual number of the element to
be used.
Loading Vectors
Preexecution-time, compile-time, and execution-time vectors are loaded differently. The
following text explains these differences.
Preexecution-Time Vectors
Each preexecution-time vector is loaded with data that was read into the program
storage area at the beginning of program execution, before normal operations in the PLC
begin. The storage area is reserved by entries in the Extension Specifications. The data
for each vector are taken from the files identified in the File Specifications.
More than one vector can be loaded from the same file. Short preexecution-time vector
loads are not allowed.
A preexecution-time vector is loaded from the file described in the From Filename field
(columns 11–18) in the Extension Specifications. The data are read in at the beginning of
program execution and placed in the preexecution-time vector until the vector is full (see
Example 10–2).
Vectors are loaded in the sequence in which they are specified in the Extension
Specifications; consequently, files are opened, read, and closed as each designated
vector is loaded. No separators are allowed between vector groups. If the number of
records in a vector file is not equal to the number expected, the compiler displays a
VECTOR LOAD ERROR message. Refer to Appendix A, “System Messages.”
Example
The program in Example 10–2 on the following page shows how to load preexecution-
time vectors. TABLE1, ARRAY2, ARRAY3, and TABLE2 are loaded from FILE1. TABLE1
contains 100 elements. Each element is 18 characters long, and there are three
elements on each record.
ARRAY2 and ARRAY3 are in alternating format. There are 15 elements in each array, and
5 elements of each array on each record. TABLE2 is also in FILE1. It contains 100
elements with 10 elements of each array per record.
ARRAY1 is loaded from FILE2. It has 80 elements; each element is 4 digits in length and
has two implied decimal positions. There are 20 elements per record.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F* This program shows how to load preexecution-time vectors.
01500F*
02000FFILEIN IP 80 80 DISK
02250FFILE1 IT 80 80 EREADER
02500FFILE2 IT 80 80 EREADER
03000FFILEOUT O 132 132 PRINTER
04000E FILE1 TABLE1 3 100 18
05000E FILE2 ARRAY1 20 80 4 2D
06000E FILE1 FILEOUT ARRAY2 5 15 10 AARRAY3 5 1A
06500E FILE1 TABLE2 10 100 6P1
07000IFILEIN AA 01
08000I 5 80 FILLER
09000OFILEOUT D 01
10000O FILLER 80
Compile-Time Vectors
Compile-time vectors are loaded at compile time at the end of the source program and
after any alternate collating or file translation records. Compile-time vectors are described
further in Section 20, “Vector Data Specifications.”
If a compile-time vector does not have a vector data specification associated with it, the
vector entries are initialized to the default values. The default values are also described in
Section 20.
Execution-Time Vectors
Execution-time vectors are loaded during program execution through entries in either the
Input Specifications or the Calculation Specifications. Either certain fields of input records
or the results of calculation operations can be used to load the elements of an execution-
time vector. This loading, unlike the automatic loading of compile-time and preexecution-
time vectors, is completely under programmatic control.
Fields within input records might contain data for vector loading. In this case, loading is
done by assigning either a vector name with an index or an array name without an index
as a field name in an input record description (see Example 10–3). A table name without
an index is not allowed. If the field name contained in the Variable Name field
(columns 27–32) in the Extension Specifications designates a single element of a vector,
the input field is placed into the vector element when the record is selected. If the field
name designates an entire array (no index assigned), the input field length must be an
integer multiple of the element size contained in the Length of Entry field (columns 40–
42) in the Extension Specifications. It must also be less than or equal to the total size of
the array. If the input field is less than the size of the array, the elements not referred to
are not affected.
Example
Example 10–3 shows a load using Input Specifications. When a record from FILEIN with
a T in position 1 is read, the 01 indicator is turned on. The five characters beginning in
position 2 are loaded into the first element of the array AR1. The 60 characters beginning
in position 8 are loaded into the entire array AR2.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 180 180 DISK
05000FFILEOUT O 132 132 PRINTER
06000E AR1 10 5 A
07000E AR2 20 3 A
10000IFILEIN AA 01 1 CT
11000I 2 6 AR1,1
11500I 8 67 AR2
12000OFILEOUT D 01
13000O AR1,1 6
A calculation operation that specifies a vector in the Result Field (columns 43–48) of the
Calculation Specifications causes the designated vector to be loaded with the result of
the operation. If an index is specified, a vector element is loaded. If no index is
designated, the entire vector is loaded.
Example
Example 10–4 shows the loading of execution-time vectors through the use of
Calculation Specifications.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000E AR1 10 5 0A
05000E AR2 50 6 0A
06000IFILEIN AA 01 1 CT
07000I 5 540AR1
07050C* Add the first element of AR1 to every element of AR2
07100C*
08000C 01 AR1,1 ADD AR2 AR2
08030C*
08050C* If IX > 10 turn indicator 02 ON
08070C*
08100C 01 Z-ADD0 IX 30
08200C LOOP TAG
08300C 01 1 ADD IX IX
08400C 01 10 COMP IX 02
08440C*
08450C* If the 02 indicator is OFF, divide 3.1415 into the element
08460C* of AR2 pointed to by IX
08470C*
08500C 01N02 AR2,IX DIV 3.1415 AR2,IX
08600C 01N02 GOTO LOOP
09000OFILEOUT D 01
10000O AR2,1 8
11000O AR2,2 16
12000O AR2,3 24
Writing Vectors
Compile-time and preexecution-time vectors can be written to an output device at EOJ
by specifying an output file in the To Filename field (columns 19–26) of the Extension
Specifications. This vector output is performed automatically after all processing has
been completed. Vector records are in the format specified by the Extension
Specifications.
An entire array can also be written during output by specifying the array name without an
index in the Field Name field (columns 32–37) in the Output Specifications. If an entire
array is written in this manner, the end position specified must have sufficient space for
all elements of the array plus any editing. For editing whole arrays, refer to Section 17,
“Output-Format Specifications.”
Line Counter Specifications are used only for printer files and indicate the form length,
the position of the last line to be printed on each page (overflow line), and the format of
the carriage control tape. If Line Counter Specifications are absent for a printer file, a
form length of 66 lines and an overflow line of 60 are assumed. For more information,
refer to the discussion of printing reports and overflow in Section 17, “Output-Format
Specifications.”
Table 11–1 summarizes the field definitions for the Line Counter Specifications coding
form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter L.
7 Contains an asterisk (*) if the line is a comment.
7–14 Specifies the name of a printer file.
15–17 Specifies the length of the page or form if columns 18 through 19 contain
the letters FL. If columns 18 through 19 are numeric, this field specifies the
line number (counted from the top of the page) to associate with that
channel number. Acceptable entries are 1 through 112, right-justified.
18–19 Designates the use of the numeric entry in columns 15 through 17.
Acceptable entries are the letters FL and 1 through 12, right-justified.
20–22 Specifies the line number of the overflow line if columns 23 through 24
contain the letters OL. If columns 23 through 24 are numeric, this field
specifies the line number (counted from the top of the page) to associate
with that channel number. Acceptable entries are 1 through 112, right-
justified.
23–24 Designates the use of the numeric entry in columns 20 through 22.
Acceptable entries are the letters OL and 1 through 12, right-justified.
25–74 Specifies the channel number related to the preceding Line Number field
entry. Acceptable entries for the Channel Number fields are 1 through 12,
right-justified. The Line Number fields designate a particular line on each
page. Acceptable entries for the Line Number field are 1 through 112, right-
justified.
75–80 Contains the program identification. Any entry is valid.
Field Definitions
The field definitions for the Line Counter Specifications are defined in the following
paragraphs.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 11–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105L*
00110L* This is an example of how comment lines are coded. All lines
00120L* with an asterisk in column 7 are ignored by the compiler.
00140L*
If columns 18 through 19 contain the entry FL (form length), the entry in columns 15
through 17 specifies the length (in print lines) of each page.
If columns 18 through 19 contain a numeric entry identifying a channel number, the entry
in columns 15 through 17 specifies the number of the line (counted from the top of the
form) to be associated with that particular channel. The Channel Number field entry must
be in the range 1 through 12.
The Line Number field entry in columns 15 through 17 must be in the range 1 through
112. Entries must be right-justified in their fields, and leading zeros are optional.
Example
Example 11–2 shows how the Line Counter Specifications are used to set up the channel
line equations, form lengths, and overflow lines for four printer files. For the file PRINT1,
columns 15 through 19 specify that channel 1 is line 10, columns 20 through 24
designate that channel 12 is line 50, and columns 25 through 29 specify that channel 3 is
line 15.
For the file PRINT2, columns 15 through 19 specify that the form length is 50, and
columns 20 through 24 designate that the overflow line is 10.
PRINT3 sets up the form length, the overflow line, and the channel line equation. The
number must be the same for the overflow line and the channel line equation if both are
specified.
PRINT4 sets up the form length and the overflow line. The overflow line is less than the
form length.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00500FPRINT1 O 132 132 OA LPRINTER
00550FPRINT2 O 132 132 OB LPRINTER
00600FPRINT3 O 132 132 OC LPRINTER
00610FPRINT4 O 80 80 OD LPRINTER
00650LPRINT1 1001 5012 1503
00700LPRINT2 50FL 10OL
00750LPRINT3 80FL 60OL 0601 2003 6012
00800LPRINT4 60FL 55OL
00900IFILEIN AA 01
01000I 2 50FIELD1
01010I 7 10 FIELD2
01020I 12 15 FIELD3
01030I 22 272FIELD4
01100OPRINT1 D 01
01200O FIELD1 10
01300OPRINT2 D 01
01400O FIELD2 10
01500OPRINT3 D 01
01600O FIELD3 10
01700OPRINT4 D 01
01800O FIELD4 10
When the overflow indicator is on, the following actions take place before the form is
advanced to the next page:
1. Detail lines still to be printed as part of the current program cycle are completed.
2. Total lines are printed.
3. Total lines conditioned by the overflow indicator for this file are printed.
4. Heading and detail lines conditioned by the overflow indicator for this file are printed.
Because these actions take place after the overflow line is reached, enough space must
be left between the overflow line and the bottom of the page to print all the lines. See
the discussion of overflow in Section 17, “Output-Format Specifications,” for more
information.
The Line Number field entry in columns 20 through 22 must be in the range from 1 to the
entry in the Line Number field (columns 15–17). The entry must be right-justified, and
leading zeros are optional.
The Line Number field entry in columns 20 through 22 must be in the range 1 through
112. Entries must be right-justified in the field, and leading zeros are optional.
Neither form length (FL) nor overflow line (OL) can be specified separately. If Line
Counter Specifications are not used, or if FL and OL are not specified, then the default
value for form length is 66 lines and the default value for overflow line is 60 lines.
The Channel Number field can contain an entry in the range 1 through 12. This Channel
Number entry is associated with a corresponding Line Number field entry in the range 1
through 112, and relates a channel number to a particular position on each page of the
output forms. The same channel number should not be specified more than once in the
same Line Counter Specifications.
All entries must be right-justified in their respective fields, and leading zeros are optional.
The Line Number entry must be less than or equal to the form length defined in
columns 15 through 17 if FL is entered in columns 18 through 19, or to the default
number of lines (66) if the form length is not specified.
If any channel specifications are made, channels 1 and 12 must be defined. If both the
overflow line and channel 12 are specified, they must be associated with the same line
number.
All channel numbers used in the Output Specifications must be defined in the Line
Counter Specifications. When channel numbers are used, it is the responsibility of the
user to ensure that the proper carriage control tape is in the printer.
COMS is a fully featured MCS designed for high-volume transaction processing. This
MCS can be used with RPG programs. For information about COMS
Telecommunications Specifications, refer to Volume 2 of this manual.
The MCS is the logical interface to the operating system under which the RPG program
operates. The primary functions of the MCS are as follows:
• To act as an interface between the RPG program and the network of communication
devices. This interface mechanism is similar to the way an operating system acts as
an interface between the RPG program and devices such as magnetic tape, mass-
storage devices, and printers.
• To perform line discipline, including such tasks as dial-up, polling, and
synchronization.
• To perform device-dependent tasks, such as character translation and insertion of
control characters, enabling the RPG program to be device-independent.
MCS Functions
The RPG program acts as an interface with the MCS when messages are sent or
received, or when the status of the various data communication files created and
maintained by the MCS are interrogated. The RPG program interface consists of
Data communications files consist of one or more messages from, or to, one or more
data communications devices and, as such, form the data buffers between the RPG
program and the MCS. Input data communications files are logically separate from output
data communications files.
Table 12–1 summarizes the field definitions for the Telecommunications Specifications
coding form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter T.
7 Contains an asterisk (*) if the line is a comment.
7–14 Specifies the name of the data communications file.
16 Specifies whether the file is to transmit or receive messages. Acceptable
entries are the letters T, R, I, and O. Entries for COMS headers (I and O) are
described in Volume 2 of this manual.
17–19 Specifies the communication type for COMS headers, which are discussed
in Volume 2 of this manual.
40 Designates the use of the entry in columns 41 through 47. Acceptable
entries are blank, or the letters S and E.
41–47 Contains a symbolic name referring to the remote station number if column
40 contains the letter S. This field contains the actual remote station number
if column 40 contains an E. This field must be blank if column 40 is blank. All
entries are left-justified.
53–54 Specifies an indicator to be turned on when certain errors occur. Acceptable
entries are blank, 01 through 99, L1 through L9, LR, and H0 through H9.
63 Designates the use of the entry in columns 64 through 70. Acceptable
entries are blank or the letters S and E.
64–70 Contains a symbolic name that refers to the location of the message length
if column 63 contains the letter S. This field contains the actual message
length if column 63 contains the letter E. This field must be blank if column
63 is blank. All entries must be left-justified.
75–80 Contains the program identification. Any entry is valid.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Comment (Column 7)
This field can contain an asterisk (*).
Explanatory statements can appear in the source if column 7 contains an asterisk (*).The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 12–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105T*
00110T* This is an example of how comment lines are coded. All lines
00120T* with an asterisk in column 7 are ignored by the compiler.
00140T*
Entry Definition
T Transmit or transmit with reply. The file must be declared in the File
Specifications as a combined or output file (a C or an O, respectively) in the
File Type field (column 15). The file must be further described in the Output
Specifications. If the file is a combined file, it must also be defined in the Input
Specifications.
Valid entries for the Remote Station Location Identification field are as follows:
Entry Definition
S The Remote Station Identification field (columns 41–47) contains the symbolic
name (field name) referring to the LASTSUBFILE attribute.
E The Remote Station Identification field contains the actual station number.
(This entry is not recommended.)
The Remote Station Location Identification field (columns 41–47) indicates how the
LASTSUBFILE attribute of the data communications file is to be referred to in the
program. The LASTSUBFILE attribute indicates the relative station number (RSN) from
which the most recent READ or RECV operation was done, and is used by the system to
determine whereto send data generated for an EXCPT operation or a SEND operation.
Note: The RSN of the file is a numeric value with no decimal positions, is unique only in
the program, and is meaningful only after a file has been opened.
The RSN differs from the logical station number (LSN) that is assigned to each station in
a network. An RSN cannot be used to indicate stations to be opened by a data
communications file. Instead, the FILENAME attribute can be used on an Attribute
Specification following the File Specification of the data communications file to specify
the name of the station to be opened.
If the user specifies a field name, but does not define the format of the field in the
program, the compiler defines the format of the identifier as an 11-digit numeric field
with no decimal positions.
If the user specifies the length of the station identification to be longer than 11 digits and
then attempts to write to the data communications file, a REMOTE STATION
IDENTIFIER <name> SHOULD BE NUMERIC WITH A MAXIMUM OF 11 DIGITS error
message is displayed.
When the Remote Station Location Identification field (column 40) contains an E, the
entry in the Remote Station Identification field contains the actual RSN of the remote
station (left-justified). (This entry is not recommended.)
This field must be blank when the Remote Station Location Identification field
(column 40) contains a blank. If a blank entry is specified, messages are transmitted to
the station from which the last message was received.
An error indicator should be specified for each data communications file. I/O operations
should be conditioned based on the setting of the indicator.
The error indicator is turned on when a data communications error is detected by the
MCS. For example, an error such as INVALID KEY ON A TRANSMISSION, FILE
UNKNOWN ON A RECEIVE, or MESSAGE LENGTH EXCEEDS RECORD LENGTH ON A
TRANSMISSION would cause the MCS to turn on the error indicator.
If an error occurs, processing continues, ignoring the record that caused the error. An
appropriate program response, such as operator notification or the end of the program in
an orderly manner, can be conditioned based on the error indicator.
If an error occurs and an error indicator is not specified, a DATACOM READ ERROR or a
DATACOM WRITE ERROR message is returned. Refer to Appendix A, “System
Messages,” for the list of error messages.
Other errors, including transmission errors, are normally handled by the MCS and not by
the RPG program. Therefore, the RPG program might not be notified of an error
condition.
Note: H0 through H9 are valid entries; however, they should not be used as error
indicators because the program cycle in which the error occurred might not be
completed before the halt indicator is turned off. Also, a program halt might occur before
the controlled halt occurs.
Valid entries for the Message Length Identification field are as follows:
Entry Definition
Blank The Message Length field (columns 64–70) contains no specification for
message length. The default value is the record size.
S The Message Length field (columns 64–70) designates the symbolic name
(field name) containing the message length.
E The Message Length field (columns 64–70) contains the exact message
length.
If the user specifies a field name, but does not define the format of the identifier in the
program, the compiler defines the format of the field as an 11-digit numeric with no
decimal positions.
This field contains the actual message length (left-justified) when the Message Length
Identification field (column 63) contains an E. When a numeric entry is present in the
Message Length field, all messages have the same length. This entry must not exceed
the record length. If the message length is less than the record size, the rest of the
record is not filled with blanks.
This field must be blank when the Message Length Identification field (column 63)
contains a blank entry.
Valid entries in the File Type field for data communications files are as follows:
Entry Definition
C The specified file is a combined file that can receive or transmit with optional
reply.
Valid entries in the File Designation field for data communications files are as follows:
Entry Definition
D Demand file
If the value contained in the Message Length field (columns 64–70) in the
Telecommunications Specifications of an output message exceeds the value specified in
the Record Length field, the message is not transmitted and the indicator specified in the
Error Indicator field (columns 53–54) in the Telecommunications Specifications is turned
on.
If the actual message length is less than the record length, the contents of the remainder
of the record are undefined.
No other entries in this field are valid for data communications files.
Columns 47 through 70
These columns must be blank for a data communications file.
Example
Example 12–2 shows the use of data communications files.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01100F*
01200F* DESCRIPTION OF PROGRAM:
01300F* -----------------------
01400F*
01500F* This program executes a series of RECV operations from the
01600F* remote file REM1, and reports what happened by executing SEND
01700F* operations back to the station of REM1 from which the RECV
01750F* operation was done.
01800F*
01900F* INDICATORS USED:
02000F* ----------------
02100F*
02200F* 02 record identifying indicator for file REM1.
02300F* 05 Error indicator for REM1 (assigned on Telecommunication
02350F* Specifications).
02400F* 10 Turned on to invoke initial prompt record from SEND
02450F* operation.
02900F* 58 EOF indicator for RECV operation (columns 5859).
03000F*
03100FDUMMY IP F 80 80 DISK
03200FCONSOLE D 80 80 ODT
03300F*
03400F* Declare a remote demand file:
03500F*
03600FREM1 CD F 80 80 DATACOM
03700A TITLE 'MARKS'
03800TREM1 R 05
03900IDUMMY NS 01
04000I 1 20 SNAM
04100I*
A library program provides a set of procedural entry points that can be called by other
programs known as user programs. Refer to the Task Management Programming Guide
for a detailed discussion of libraries. Familiarity with this material is assumed in the
following discussion.
Subroutines written in other languages are often called procedures. RPG programs can
call library procedures written in other languages. These procedures can be written in any
programming language that enables library calls from other languages. Library
procedures are also called entry points. Parameters can be passed to the library either by
reference or by value.
The RPG calling mechanism enables both procedures and functions (typed procedures)
to be called as subroutines by the EEXSR and PARAM operations. Information about
these operations is provided in the discussion of library operations in Section 16,
“Operation Codes.”
Table 13–1 summarizes the field definitions for the Library Specifications coding form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6–18 Specifies the form type of the Library Specifications. Acceptable entries are
LIBRARY NAME, LIBRARY SUBR, or LIBRARY PARAM.
19–28 Specifies the name of a library, library subroutine, or library parameter.
29–31 Designates the result length on a Library Subroutine Specifications or the
parameter length on a Library Parameter Specifications.
32 Specifies the library access attribute on a Library Name Specifications, the
Result Decimal Position on a Library Subroutine Specifications, or the
Parameter Decimal Positions on a Library Parameter Specifications.
Acceptable entries are 0 through 9, the letters D, F, I, or T, and blank.
33 Contains an entry only on the Library Parameter Specifications and specifies
whether the parameter is passed by value or by reference. Acceptable
entries are the letters V and R.
34 Contains an entry only on the Library Parameter Specifications and specifies
information about a vector parameter. Acceptable entries are blank, 0 (zero),
*, and the letters L and P.
35–74 Specifies the title or function name on a Library Name Specifications, or
specifies the actual name of the subroutine on a Library Subroutine
Specifications.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Field definitions for Library Name Specifications are discussed in the following
paragraphs.
Entry Definition
Family substitution can occur when the object code specified is on DISK and the library is
linked by title. In this situation, it is desirable to link BYFUNCTION to an initialized library.
Refer to the System Software Utilities Manual for more information.
If this field is blank, the TITLE or FUNCTIONNAME attribute defaults to the library name
in columns 19 through 28.
All library attributes except LIBPARAMETER can be specified on the Library Name
Specifications.
• FUNCTIONNAME
• INTNAME
• LIBPARAMETER
• TITLE
The allowable mnemonic library attribute is LIBACCESS. Its allowable values are BYTITLE
and BYFUNCTION.
Field definitions for the Library Subroutine Specifications are discussed in the following
paragraphs.
Only the following result types are allowed in the Result Decimal Positions field:
Entry Definition
D Designator
I Indicator
T COMS-time
Designator and COMS-time result types are discussed in Volume 2 of this manual.
The number of parameters described in the Library Parameter Specifications must equal
the number of formal parameters declared in the procedure entry point in the library.
Field definitions for Library Parameter Specifications are discussed in the following
paragraphs.
Entry Definition
Blank Alphanumeric
D Designator
F File
I Indicator
T COMS-time
For additional information about parameter matching, refer to the discussion of the
PARAM operation in Section 16, “Operation Codes.”
Entry Definition
Following are the valid entries for all other parameter types:
Entry Definition
Blank Single field, literal, or vector element. Unindexed vector passed as a zero-
bounded ([0]) array.
Note: Pascal array schemata with multiple discriminants in which the base type is a
structured type have no corresponding parameter types in RPG.
Columns 35–74
These columns must be blank.
Following are the predefined system subroutines and their related utilities:
$SETNAME SETACTUALNAME
$LINKLIB LINKLIBRARY
$DELINKLIB DELINKLIBRARY
$CANCELLI CANCELLIBRARY
B
$SETNAME
The $SETNAME system subroutine changes the actual name of a subroutine to another
name. To use $SETNAME, the program must not be currently linked to the library. For
additional information, refer to the following discussion of $DELINKLIB. See Table 13–2
for the parameter specifications for this subroutine.
$LINKLIB
A program is usually linked to the library on the first call of any of its subroutines. If this
implicit link fails for any reason, the calling program is ended. The $LINKLIB system
subroutine enables the option of explicitly linking to the library and checking whether the
linkage was successful. Refer to Table 13–2 for parameter specifications.
$DELINKLIB
A program usually remains linked to the library until the end of the task. However,
$DELINKLIB can end the linkage before the task is complete. If $SETNAME is needed
after the library is linked, a typical usage of system subroutines might include
$DELINKLIB, followed by $SETNAME and $LINKLIB. Refer to Table 13–2 for the
parameter specifications for this subroutine.
$CANCELLIB
The $CANCELLIB system subroutine does not return a result. $CANCELLIB is a special
version of $DELINKLIB.
Table 13–2 describes the result and parameter types for the library linkage subroutines.
Example 1
Example 13–1 contains a partial program sample that shows Library Specifications
coding. A complete programming example is provided in Figure 13–3.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00215E NAME 3 8
00220E*
00100LIBRARY NAME DATELIB T *SYSTEM/DATE/LIBRARY
00105L*
00110L* Library of date manipulation routines.
00115L*
00120LIBRARY SUBR DATEDIF 50 DATE_DIFFERENCE
00125L*
00130L* Returns the number of days between two Gregorian dates.
00135L*
00140LIBRARY PARAM<begin> 60V
00150LIBRARY PARAM<end> 60V
00160L*
00170L*
00180LIBRARY SUBR DATELIT DATE_LITERAL
00185L*
00190L* Turns Gregorian date into MMMMMMMMM DD, YYYY
00195L*
00200LIBRARY PARAMGREGORIAN 60V
00210LIBRARY PARAMLITDATE 18 *
05000C 27 MOVE 'DATE_LIT'NAME,1
05100C 27 MOVE 'ERAL_EUR'NAME,2
05200C 27 MOVEL'OPEAN ' NAME,3
05300C 27 EEXSR$SETNAME RSLT 110 88
05400C PARAMDATELIT
05500C PARAMNAME
05600C 27 88 GOTO ERROR
Example 2
Example 13–2 shows a complete RPG program that uses Library Specifications
extensively. Comments in the example provide an explanation of the code as it is
presented.
A copy of this program and its data file are on the release media under the node
EXAMPLE/RPG/LIBRARY/ACCESS. The library subroutines used by the program are also
on the release media (EXAMPLE/COBOL74/LIBRARY and EXAMPLE/PASCAL/LIBRARY).
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
200F*
202F* DESCRIPTION OF PROGRAM:
204F* -----------------------
206F*
208F* This program illustrates how to declare and use subroutines
210F* from a library. The libraries are written in different
212F* languages. They export procedures for use by calling programs.
214F* Three libraries are invoked: DATELIB, which is written in
216F* Pascal; PRINTLIB, which is written in COBOL74; and GENSUP, the
218F* GENERALSUPPORT system library, which is written in NEWP.
220F*
222F* This program uses three input records: D-records,
224F* S-records, and T-records. In each D-record there are
226F* two dates. The DateLit subroutine of DATELIB is called
228F* to convert the dates from Gregorian format into display
230F* format, that is, from 122654 to December 26, 1954. DateDif is
232F* called to calculate the number of days between the two dates.
234F* The display format dates are then passed to CharCount, which
236F* tallies all the characters used in an array named CT.
238F* The display dates and the number of days between them are
240F* written to a file named MAINFILE.
242F*
244F* In an S-record there are two variables called ACTNAM
246F* and XFLAG. $SETNAME is called to change the actual name
248F* of DateLit to ACTNAM. The Options subroutine of DATELIB
250F* is called to set the DMY (Day-Month-Year) flag of DATELIB
252F* to TRUE if XFLAG is the letter D. Otherwise, DMY is
254F* set to FALSE (indicating Month-Day-Year).
256F*
258F* In each T-record there is file name that is translated
260F* from display format (the form that the user sees) to standard
262F* display format (the form in which file titles are stored) by
264F* the Disp2Std subroutine of GENSUP. The standard format name
266F* is also passed to CharCount to be tallied in the CT array.
268F*
270F* At LR, the Print-It subroutine is called from PRINTLIB.
272F* The parameters of the subroutine are CT and MAINFILE.
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
274F* Print-It writes the contents of CT to MAINFILE.
276F* DICTIONARY OF PROGRAM IDENTIFIERS
280F* IN - Disk file containing program input. There are two record
282F* formats: D-records and T-records. D-records contain date
284F* pairs in the format D mmddyy mmddyy. T-records are in
286F* the format T <70 bytes of title>.
288F* MAINFILE - The file used to display results of Pascal library
290F* calls. This file is also passed as a parameter to
292F* the Print-It subroutine.
294F* OUTNEWP - The file containing the results of calling Disp2Std.
296F* DATELIB - Pascal Library accessed by this program. (Contains
298F* date manipulation routines.)
300F* DateDif - Library subroutine that returns the number of days
302F* between two Gregorian dates.
304F* DAYS - 5-digit numeric field representing the difference in
306F* days between FMDATE and TODATE.
308F* FMDATE - 6-digit integer (zero scale factor) having the
310F* form MMDDYY. FMDATE is read from the IN primary
312F* file. It is the first half of the date
314F* pair read from that file on each cycle.
316F* FMDLIT - 18-byte alphanumeric field used to hold the display
318F* form of FMDATE.
320F* TODATE - 6-digit integer (zero scale factor) having the
322F* form MMDDYY. TODATE is read from the IN primary
324F* file. It is the second half of the date
326F* pair read from that file on each cycle.
328F* TODLIT - 18-byte alphanumeric field used to hold the display
330F* form of TODATE.
332F* LTITLE - The TITLE attribute of the DATELIB library.
334F* LIBACC - The LIBACCESS attribute of the DATELIB library.
336F* VECTOR - A Preexecution vector containing long literals.
338F* ACTNAM - New actual name for DateLit.
340F* INDICATORS USED:
342F*
344F* 01 - record identifying indicator for D-records of the IN file.
346F* 02 - record identifying indicator for T-records of the IN file.
348F* 03 - record identifying indicator for S-records of the IN file.
350F* 10 - Plus field indicator for field FMDATE. It is turned on
352F* if FMDATE is a positive integer on each cycle. It is used
354F* to condition all operations using FMDATE.
356F* 11 - Plus field indicator for field TODATE. It is used to
358F* condition all operations using TODATE.
360F*20,21,22 - Plus, minus, and zero indicators for the field DAYS
362F* when it is set as the result of calling DateDif.
364F* 30 - Error indicator.
366F* 77 - XFLAG (= D ).
368F* 99 - First-control-cycle switch.
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
370F*
372F*
374F*
376FIN IP F 80 80 DISK
378A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/DATA'
380FODT D F 80 80 ODT
382FINVECT IT F 80 80 DISK
384A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/VECTOR'
386FMAINFILEO F 80 80 REMOTE
388A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/OUTPUT/PASCAL'
390FOUTNEWP O F 80 80 DISK
392A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/OUTPUT/NEWP'
394E ACTNAM 1 70
396E STDNAM 70 1
398E FILNAM 70 1
400E CT 256 5 0
402E INVECT VECTOR 1 2 80
404L*
406L* Declare the DATELIB library. Attribute Specifications give an
408L* initial value for the FUNCTIONNAME attribute, and both initial
410L* values and field names for the TITLE and LIBACCESS attributes.
412L* If no attribute modification is used in the Calculation
414L* Specifications, LIBACCESS is BYFUNCTION with FUNCTIONNAME
416L* equal to GOODFUNCTION, and TITLE is ignored. LTITLE changes to
418L* OBJECT/EXAMPLE/PASCAL/LIBRARY and LIBACC is changed to BYTITLE
420L* at the beginning of the Calculation Specifications.
422L*
424LIBRARY NAME DATELIB T TITLE/OVERRIDDEN/BY/ATTRIBUTE/IMAGES
426A TITLE 'THIS/EXAMPLE/SHOWS/HOW/TO/SPECIFY/A/TITLE/ LTITLE 80
428AAN THATS/OVER/40/BYTES'
430A LIBACCESS BYFUNCTION LIBACC 10
432A
434AAN
436AANFUNCTIONNAME 'GOODFUNCTION'
438L*
440L* Declare the DateDif library subroutine. Two parameters are
442L* specified. They are both by-value integers, having a length of
444L* 6 and a scale factor of 0 (zero). The subroutine returns a
446L* result that is a 5-digit number, having a scale factor of 0
448L* (zero). The actual name of the procedure (the name by which the
450L* library exported it) is DATE_DIFFERENCE. The Pascal description
452L* of the subroutine is
454L*
456L* function date_difference ( from_date, to_date : integer )
458L* : integer;
460L*
462LIBRARY SUBR DATEDIF 50 DATE_DIFFERENCE
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
464LIBRARY PARAM FROM_DATE 60V
466LIBRARY PARAM TO_DATE 60V
468L*
470L* Set the DMY (Day-Month-Year) flag. The Pascal description of
472L* the subroutine is
474L*
476L* procedure option ( new_dmy : Boolean );
480LIBRARY SUBR OPTION
482LIBRARY PARAM new_dmy IV
484L* Declare the DateLit library subroutine. Two parameters are
486L* specified. The first is a by-value 6-digit number with a scale
488L* factor of 0 (zero), which is interpreted as a Gregorian date.
490L* The second is a by-reference alphanumeric area, passed with
492L* asterisk bound in which DateLit writes the date as
494L* MMMMMMMMM DD, YYYY. The Pascal definition of this subroutine is
496L*
498L* ebcrange = 1..9999;
500L* ebcdic_schema (length : ebcrange)
502L* = packed array [1..length] of char;
504L* ebcdic18 = ebcdic_schema (18);
506L* procedure date_literal ( in_day : ext_date;
508L* var lit_date : ebcdic18 );
510L*
512L* Note that though the EBCDIC18 type is built from a schema, it
514L* is not a schema itself, so the parameter is passed asterisk
516L* bound.
518L*
520L* This program uses $SETNAME to change the ACTUALNAME of the
522L* subroutine to date_literal_european. The procedure is
524L*
526L* procedure date_literal_european ( in_day : ext_date;
528L* var lit_date : ebcdic18)
530L*
532LIBRARY SUBR DATELIT DATE_LITERAL
534LIBRARY PARAM_DAY 60V
536LIBRARY PARAMLIT_DATE *
538L*
540L* The following example demonstrates passing to a Pascal schema
542L* parameter. The Pascal declaration of this procedure is
544L*
546L* ebcrange = 1..9999;
548L* ebcdic_schema (length : ebcrange)
550L* = packed array [1..length] of char;
552L* char_of_int = array [char] of integer;
554L* procedure char_count ( var in_str :ebcdic_schema;
556L* var count : char_of_int );
558L*
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
560L* The variable in_str is a schema type. To call this procedure
562L* from RPG, L is put (asterisk bound with length) in the Vector
564L* Parameter field (column 34).
566L*
568LIBRARY SUBR CHARCOUNT CHAR_COUNT
570LIBRARY PARAMINSTR L
572LIBRARY PARAMCOUNT 50 *
574L*
576L*
578L*
580LIBRARY NAME PRINTLIB OBJECT/EXAMPLE/COBOL74/LIBRARY
582LIBRARY SUBR PRINT-IT
584LIBRARY PARAMCOUNTS 50 0
586LIBRARY PARAMFYLE F
588L*
590LIBRARY NAME GENSUP
592A LIBACCESS BYFUNCTION
594A FUN
596AANCTIONNAME 'GENERALSU
598A************* Comment lines can be inserted anywhere.*************
600AANPPORT'
602A LIBPARAMETER PARAM 80
604AAN ' THIS IS MY LIBRARY PARAMETER VALUE '
606LIBRARY SUBR DISP2STD I DISPLAYTOSTANDARD
608LIBRARY PARAM <-from-> VP
610LIBRARY PARAM <-to-> VP
612L*
614I*
616IIN NS 01 1 CD
618I 3 80FMDATE 10
620I 10 150TODATE 11
622I NS 02 1 CT
624I 3 72 FILNAM
626I NS 03 1 CS
628I 3 3 XFLAG
630I 5 74 ACTNAM
632C*
634C* First Cycle Setup:
636C*
638C* Inquiring and modifying library attributes:
640C*
642C N99 MOVELPARAM TEMP 80
644C N99TEMP DSPLYODT
646C N99 MOVE LTITLE TEMP 80
648C N99TEMP DSPLYODT
650C N99 MOVE VECTOR,1 LTITLE
652C N99 MOVE LTITLE TEMP 80
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
654C N99TEMP DSPLYODT
656C N99 MOVE LIBACC TEMP10 10
658C N99TEMP10 DSPLYODT
660C N99 MOVEL'BYTITLE 'LIBACC
662C N99 MOVE LIBACC TEMP10 10
664C N99TEMP10 DSPLYODT
666C N99 SETON 99
668C*
670C* HANDLE S-RECORDS:
672C*
674C* This section of the code changes the actual name of DateLit to
676C* the value of ACTNAM. If the library was linked during a
678C* previous cycle, it is delinked with $DELINKLIB. Then the
680C* actual name is changed with $SETNAME. Failure is indicated by
682C* a negative result, and a halt indicator is used in the
684C* Resulting Indicator field (column 56, the minus indicator).
688C*
690C 03 EEXSR$DELINKLIB H2
692C PARAMDATELIB
694C 03 EEXSR$SETNAME H3
696C PARAMDATELIT
698C PARAMACTNAM
700C*
702C* The DMY flag of DATELIB is set.
704C*
706C 03'D' COMP XFLAG 77
708C 03 EEXSROPTION
710C PARAM*IN77
712C* HANDLE D-RECORDS:
714C*
716C* Call external subroutine DateDif. The date difference is
718C* returned into the field DAYS; indicators 20, 21, and 22 are
720C* set to indicate if DAYS is positive, negative, or zero.
722C* FMDATE and TODATE are passed as by-value parameters.
724C*
726C 10 11 01 EEXSRDATEDIF DAYS 50 202122
728C PARAMFMDATE
730C PARAMTODATE
732C*
734C* External subroutine DateLit is called. FMDATE is passed as a
736C* by-value parameter. The alphanumeric field FMDLIT is passed as
738C* a by-reference parameter. The literal date is returned by
740C* storing it in FMDLIT.
742C*
744C 10 11 01 EEXSRDATELIT
746C PARAMFMDATE
748C PARAM FMDLIT 18
750C*
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
752C 10 11 01 EEXSRDATELIT
754C PARAMTODATE
756C PARAM TODLIT 18
758C*
760C* FMDLIT and TODLIT are passed to CHARCOUNT. The character
762C* field is declared as passed by reference, CHARCOUNT does not
764C* update it, so it can be passed by value. The character counts
766C* are tallied in the array CT, which is passed by reference. If
768C* CT is passed by value, the routine runs correctly, but the
770C* CT vector in the calling program is never updated.
774C 10 11 01 EEXSRCHARCOUNT
776C PARAMFMDLIT
778C PARAM CT
780C 10 11 01 EEXSRCHARCOUNT
782C PARAM TODLIT
784C PARAM CT
786C* If FMDATE or TODATE is 0 (zero) set LR as follows:
788C*
790C N10 01
792CORN11 01 SETON LR
794C*
796C* HANDLE T-RECORDS:
798C*
800C* The Disp2std subroutine is called to translate the display
802C* format file name, FILNAM, to the standard format file name,
804C* STDNAM. If any errors occur, indicator 30 is on; otherwise,
806C* it is off.
808C*
810C 02 MOVE ' ' STDNAM
812C 02 EEXSRDISP2STD *IN30
814C PARAMFILNAM
816C PARAMSTDNAM
818C N30 02 EEXSRCHARCOUNT
820C PARAMSTDNAM
822C PARAM CT
824C*
826C* At LR, the Print-It subroutine writes the contents of CT
828C* to MAINFILE:
830C*
832CLR EEXSRPRINT-IT
834C PARAMCT
836C PARAM MAINFILE
838C*
840OMAINFILED 10 11 01
842O 4 'FROM'
844O FMDLIT 23
846O 26 'TO'
..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
848O TODLIT 45
850O 48 'IS'
852O 20 DAYS Z 54
854O 20 59 'DAYS'
856O 21 58 'BACKWARDS'
858O 22 56 'NOTHING'
862OOUTNEWP D 02
864O 6 'INPUT:'
866O FILNAM 80
868O D 30 02
870O 12 '--- NOT GOOD'
872O D N30 02
874O 9 'STANDARD:'
876O STDNAM 80
Example 3
The CURRENT_DATE procedure in the GENERALSUPPORT library returns a
21-character alphanumeric value that represents the calendar date, time of day, and local
time differential factor provided by the system on which the function is evaluated.
...*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
2000FOUTPUT O REMOTE
2500LIBRARY NAME GENSUPP F GENERALSUPPORT
3000LIBRARY SUBR CURRDATE CURRENT_DATE
3500LIBRARY PARAMDATE *
3900C MOVE 'ABCDE' ALPHA 6
4000C EEXSRCURRDATE
5000C PARAM DATE 21
6000C EXCPTOUTPUT
8000C SETON LR
8111OOUTPUT E
9111O DATE 21
Returned Value
The character positions returned, numbered from left to right, appear as follows:
Character Contents
Positions
1 through 4 Four numeric digits for the year in the Gregorian calendar.
5 through 6 Two numeric digits for the month of the year, in the range 01
through 12.
7 through 8 Two numeric digits for the day of the month, in the range 01 through
31.
9 through 10 Two numeric digits for the hours past midnight, in the range 00
through 23.
11 through 12 Two numeric digits for the minutes past the hour, in the range 00
through 59.
13 through 14 Two numeric digits for the seconds past the minute, in the range 00
through 59.
15 through 16 Two numeric digits for the hundredths of a second past the second,
in the range 00 through 99.
17 See Table 13–4.
Character position 17 can contain one of three characters as shown in Table 13–4.
IF character 17 is a . . . THEN . . .
Minus sign (–) The local time indicated in the previous character
positions is behind Greenwich Mean Time.
Plus sign (+) The local time indicated in the previous character
positions is the same as or ahead of Greenwich Mean
Time.
Zero (0) The system on which this value is evaluated does not
have the facility to provide the local time differential
factor.
Character positions 18 through 21 contain the time in hours and minutes relative to
Greenwich Mean Time. The meaning of the time value contained in these positions
depends upon the character in position 17 as shown in Table 13–5.
IF character 17 is a . . . THEN . . .
Example of Output
The following is an example of a value returned by the CURRENT_DATE procedure.
Because character position 17 is a minus sign, the digits 0700 indicate the reported
time is 7 hours and 0 (zero) minutes behind Greenwich Mean Time.
1995062813195795-0700
The Input Specification describes the records in each file and the fields in each record to
be used as input data for the program.
For information about data management and COMS Input Specifications, refer to Volume
2 of this manual.
There are two types of Input Specifications: record-type descriptions (columns 7–42) and
field descriptions (columns 43–70). Field and record-type descriptions must not be
specified on the same line.
Record-type descriptions define the various input records and their relationship to other
records in the file. For record-type descriptions, the columns for field descriptions must
be blank.
Field descriptions define each field within a record. For field descriptions, the columns for
record-type descriptions must be blank. Field descriptions must start one line below the
associated record-type descriptions.
Data structures are also defined in the Input Specifications. Data structures enable the
user to control how fields are mapped in memory. Data structures are described later in
this section.
Table 14-1 summarizes the field definitions for the Input Specification form.
Columns Description
Columns Description
48–51 Contains the rightmost position of the input field. Acceptable entries
are numeric and must be right-justified.
52 Specifies the number of decimal positions for numeric fields.
Acceptable entries are blank or 0 through 9.
53–58 Contains field names, whole arrays, indexed tables or arrays, or one of
the special names, PAGE through PAGEn (where n = 1 through 9).
Entries in this field are left-justified.
59–60 Designates a control level indicator. Acceptable entries are blank or L1
through L9.
61–62 Specifies sequence checking for a single input file or sequence
checking with matching records for two or more input files. Acceptable
entries are blank or M1 through M9.
63–64 Contains one of the following field record relations indicators: 01
through 99 (record identifying indicator), L1 through L9 (control level
indicator that has been previously defined), MR (matching record
indicator), U1 through U8 (external indicator), or H0 through H9 (halt
indicator), or blank.
65–66 Contains an indicator that designates if the specified field is greater
than blank or positive. Acceptable entries are blank, 01 through 99, or
H0 through H9.
67–68 Contains an indicator that designates if the specified field is less than
blank or negative. Acceptable entries are blank, 01 through 99, or H0
through H9.
69–70 Contains an indicator that designates if the specified field is blank (or
zero). Acceptable entries are blank, 1 through 99, or H0 through H9.
75–80 Contains the program identification. Any entry is valid.
Field Definitions
The fields for the Input Specifications are discussed in the following paragraphs.
An entry in a column that is not part of any of the defined fields in a specification might
cause warning messages to be displayed.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
This field identifies the file to which the record-type and subsequent field descriptions
belong or the data structure to be used. If a data structure is specified, the name can be
only 6 characters in length. For additional information, see the discussion of data
structures in this section.
Every input, update, and combined file (except input table files and record-address files)
described in the File Specifications must be described in the Input Specifications. No
other files can be described in the Input Specifications.
The Filename entry must be the same as the one used in the File Specifications. The
entry must appear on the first line containing information about the records in the file. If
the entry is blank, the last file name entered is associated with the record being
described. The first record-type description must not have a blank Filename entry.
Primary and secondary files are processed in the order in which they are described in the
File Specifications, not in the order in which they are specified in the Input Specifications.
All record-type and field descriptions for a particular file must be grouped together in the
Input Specifications. Descriptions of records from different files must not be
interspersed.
When the same record type is identified in more than one way, OR lines can be specified
by entering OR in columns 14 through 15 and leaving column 16 blank. Any additional
record identification codes must be entered in columns 21 through 41.
Columns 7 through 14 must be blank when the AND and OR Lines field contains an
entry. For further details, see the discussion of the Record Identification Codes field
(columns 21–41) in this section.
Entry Definition
Blank Record types are not sequenced, and a warning message is displayed.
All chained and demand files must have an alphabetic entry in this field. Within each file,
all record types that have alphabetic entries in the Sequence field must be specified
before record types with numeric entries.
Example
Example 14–1 shows how to code the Sequence field when both alphabetic and numeric
entries are desired.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00500FFILEOUT O 132 132 PRINTER
00900IFILEIN AA 05 15 D5
01000I 7 13 FIELD1
01010I 011 05 11 CA
01020I 4 9 FIELD2
01030I 021O05 17NCA
01040I 4 9 FIELD3
01100OFILEOUT D 05
01200O FIELD1 15
01250O FIELD2 25
01300O FIELD3 35
If the Sequence field contains a numeric entry, the compiler assigns sequence numbers
to the different record types in the file. These sequence numbers enable the programmer
to specify that one record type is to appear before another record type within a
sequenced group. The program automatically checks the designated order as the records
are read.
The first sequenced record type specified should have an entry of 01 in this field; the
next record type should be given a higher number, and so forth. Gaps in sequence
numbers are allowed, but the numbers must be in ascending order.
AND and OR records can be specified within a sequence-checked file. However, the
AND and OR line must not have a sequence field; all sequencing specifications are taken
from the preceding line.
Entry Definition
Blank Record types are not to be checked for sequence. The Sequence field
(columns 15–16) contains an alphabetic entry.
N One or more records of the designated type are present in each sequence
group.
Records in an AND and OR Lines field must not have a Number field entry. The
specifications from the preceding line apply to the AND and OR Lines field
(columns 14–16).
Entry Definition
If the letter O is entered in this field, a record of the designated type can be optionally
present in each group of a sequenced file. If this field is blank, the Number field
(column 17) contains an entry that indicates one or more records are specified for this
record type; record types must be present for each group. If the letter U is entered, the
data structure defined in columns 7 through 12 of this specification is used as a local data
area.
If all record types in a file are designated as optional, no sequence errors are detected.
Records in an AND and OR Lines field (columns 14–16) must not have an Option field
entry. The specifications from the preceding line also apply to the AND and OR Lines
field.
Entry Definition
TR Header-trailer specification
DS Data structure
** Look-ahead field
If the entry is blank, a warning message is displayed. The various entries have special
meanings, as defined in the following paragraphs.
For any one primary or secondary file, only one record identifying indicator can be on. For
any one chained or demand file, more than one record identifying indicator can be on.
However, this situation occurs only if two or more records are read from the same file
during one program cycle through the use of CHAIN or READ operations.
Record identifying indicators can be assigned in any order. If the same operations are to
be performed on different groups of records, the same indicator can be assigned to more
than one group of records. Refer to the discussion of the OR line in the Record
Identification Codes field (columns 21–41) in this section.
Different indicators can be specified for each group of records that requires special
processing in an OR relationship; however, record identifying indicators are not allowed
in an AND line. If the record identifying indicator is not specified on an OR line, the
default value is the value of the last previously specified record identifying indicator for
that record. If no value has been specified for that record, no record identifying indicator
is used. Refer to the discussion of the AND line in the Record Identification Codes field
(columns 21–41) and to the discussion of the OR relationship in the Field Name field
(columns 53–58) in this section.
The use of the LR indicator as a record identifying indicator for a file that is read during
detail calculations does not cause the LR indicator to be turned off. This is because all
indicators used as record identifiers are turned off at the indicator initialization step of the
program logic cycle (PLC). During the indicator initialization step, the record is read during
detail calculations and before a test for the LR indicator occurs.
Header-Trailer Specifications
A header-trailer, or spread-record, enables an individual record to be processed as if it
were actually several records. The record is composed of a portion of data that are
common to the entire record (the header) and is followed by one or more occurrences of
the remaining fields of the record (the trailer). The header is used with each occurrence
of the trailer.
Data Structure
A data structure can be used to define an area of memory in several ways and reorganize
fields for easier reference. A data structure is an area in memory composed of one or
more subfields. Columns 19 through 20 contain DS to indicate that a data structure is
used. Refer to the discussion of data structures in this section.
By using look-ahead fields, the program can extend the use of the matching record
function or determine when the last record of a control group is being processed.
Matching records are described later in this section. The rules for processing the last
record of a control group are as follows:
• Look-ahead fields can be specified only for input, update, or combined files that are
either primary files or secondary files.
• One set of look-ahead fields can be specified for each file; the description applies to
all records in that file.
• A look-ahead field is read-only and must not be used as the Result Field for
calculation operations (except for the DEBUG, TESTB, TESTN, and TESTZ
operations).
• The name given to a look-ahead field must not occur in any other Input or Extension
Specifications and must not be a special word (except PAGE through PAGEn).
• If the look-ahead field occurs in Output Specifications, the Blank After field
(column 39) must not be used.
• To access information both before and after the record is selected for processing,
the field must be described twice using different names; it must be described once
as a look-ahead field and once in the normal manner.
• The look-ahead field must not follow a record-type description that has a numeric
Sequence field (columns 15–16) entry.
• Columns 17, 18, and 21 through 74 must be blank.
• Columns 14 through 16 must contain blanks or alphabetic characters, but not AND or
OR on the lines following the line containing the pair of asterisks (**).
• On the look-ahead field description lines, columns 7through 42 and 59 through 74
must be blank.
• When the last record of a file is being processed, any look-ahead fields for that file
contain all nines (signed numeric or alphanumeric according to the field type).
For input files, a look-ahead field enables the program to access information in fields of
the next record that becomes available for processing. Thus, the program can use
information from the look-ahead fields to condition certain operations before the record is
available for processing.
Figure 14–2 shows the processing of two input files. (See Example 14–2 later in this
section for coding examples of look-ahead fields.)
For combined and update files, the look-ahead fields apply to the next record in the file
only if the current record was read from some other file. When the current record is read
from a combined or update file, the look-ahead fields apply to the current record.
Figure 14–3 shows processing records from an update file and a secondary input file.
Figure 14–3. Records Available for Look-Ahead Fields: One Update File and One
Input File
Example
Example 14–2 shows coding for look-ahead fields.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILE1 IP 180 90 DISK
00325FFILE2 IS 180 90 DISK
00350FFILE3 US 180 90 DISK
00400FPRINTER O 132 132 PRINTER
00500IFILE1 AA 01 1 C2
00600I 1 11 CTL L1M1
00700I 12 162AMT
00800I **
00850I 1 11 NXTCTA
00900IFILE2 BB 02 1 C3
01000I 22 32 CTL L1M1
01020I 12 162AMT
01040I **
01050I 22 32 NXTCTB
01060IFILE3 CC 03 1 C2
01070I 02 12 CTL L1M1
01080I 16 202AMT
01090I **
01100I 02 12 NXTCTC
01110C*
01120C* Accumulate totals.
01130C*
01140C AMTL1 ADD AMT AMTL1 82
01150C AMTLR ADD AMT AMTLR 102
01160C*
01170C* FILE1 or FILE2 next?
01180C*
01190C 03 NXTCTA COMP NXTCTB 20
01200C N03N02 SETOF 20
01210O*
01220O* When FILE2 is processed next, flag this FILE3 record.
01230O*
01240OFILE3 D 03 20
01250O 60 '9'
01260OPRINTER D 1 02 20
01270O CTL 32
01280O AMT A 20
01290O T 12 L1
01300O CTL 32
01310O AMTL1 AB 20
01400O LR AMTLR A 50
If record identification codes have been specified, other codes can be designated with
the AND and OR Lines field (AND or OR in columns 14 through 16). As many lines as
necessary can be used to describe these continuation codes. Example 14–3 shows AND
and OR relationships.
At least one Record Identification Codes field entry must be present on each AND line
and on the preceding line. Record identification codes are not required on an OR line.
AND Line
An AND line is used to describe record identification codes that consists of more than 3
characters. Each new line enables three more record identification codes to be specified.
An AND line is identified by coding the word AND in columns 14 through 16. The record
selected must contain all the characters specified in the record identification codes to
turn on the corresponding record identifying indicator (columns 19–20).
OR Line
Sometimes a particular record type can be identified by two or more different record
identification codes. For this condition, an OR line is used to indicate that only one of the
codes specified must be present to identify the record type.
Example
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00405I*
00410I* The lines below describe a record type that can be
00415I* identified by the code DEPT appearing in positions
00420I* 67-70 of the input record. The AND line is used in
00425I* order to specify additional characters as part of the
00430I* record identification code.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
0435I*
00440I* The OR line enables an alternate code to be specified.
00445I* Thus, a 9 in the first position also serves to
00450I* identify the record type even if the code DEPT does
00455I* not appear in positions 67 through 70 of the input record.
00460I*
00465I* For the record type below, either the word DEPT in
00470I* positions 67-70 or a 9 in position 1 (or both)
00475I* causes the L1 indicator to turn on.
00480I*
00500IFILEIN 011 L1 67 CD 68 CE 69 CP
00510I AND 70 CT
00520I OR 1 D9
00600I 7 13 FIELD1
01100OFILEOUT D L1
01200O FIELD1 15
Entry Definition
Blank Character must be present in the location specified by the Position field entry.
N Character must not be present in the location specified by the Position field
entry.
Entry Definition
C Entire character
Z Zone portion
If the zone of the plus sign (+) is specified, the record identification code is treated as the
positive zone (that is, a zone of A through I). If the zone of the minus sign (–) is specified,
the record identification code is treated as the negative zone (that is, a zone of J through
R).
Entry Definition
Data defined with either a blank or a P can be specified as left- or right-signed in either
the Sign Position field (column 17) in the Control Specification or the $RSIGN compiler
control option (refer to Section 21, “Control of the Compilation Process.” )
The various external formats specified in the Packed field are described in the following
paragraphs.
Each digit portion holds one digit of the number; the zone portions (except for the sign
position) are dropped.
An input field defined with unsigned packed decimal format is converted to signed
internal format automatically by the RPG program when the field is moved from the input
buffer to the work area. After conversion, the data field contains a positive sign (binary
1100). The sign can be altered by performing calculation operations on the data field.
Binary Format
In binary format, the field length must be either 2 bytes or 4 bytes. A 2-byte field implies
a 4-digit numeric field, unless the field is otherwise defined. A 4-byte field implies a 9-
digit numeric field, unless the field is otherwise defined. This format is illustrated in
Figures 14–10 and 14–11.
The numeric value of a positive number is obtained by summing the values associated
with the bit positions where the bit value equals 1. The value of a negative number is
obtained by summing the values associated with the bit positions where the bit value
equals 0 and then adding 1. The sign bit is not included in these calculations.
In single-precision numeric format, the field must be 6 bytes long. The value itself is
represented in a sign-magnitude binary format, as shown in the following diagram. In
Figure 14–12, the 6 bytes (which make one word) are shown as a grid of bits, numbered
from top to bottom and from left to right, with the top left bit being number 47, and the
bottom right bit being number 0.
1 = negative
0 = positive
For double-precision numeric format, the field must be 12 bytes (two words) long. The
value itself is represented in a sign-magnitude binary format, as shown in Figures 14–13
and 14--14. For this diagram, each word is shown as a grid of bits, numbered from top to
bottom and from left to right, with the top left bit being number 47, and the bottom right
bit being number 0.
If the Field Name (columns 53–58) entry is a field name or a vector element, the length of
the field is determined by the following rules, where n is the difference between the TO
location and the FROM location plus 1.
Alphanumeric n
Unpacked numeric n
Packed signed numeric 2n –1
Packed unsigned 2n
numeric
Separate leading sign n –1
Separate trailing sign n –1
Binary [(n + 2) * (n + 2)] div 4
Single-precision n
Double-precision n
The value of n must not exceed the field-size limits as described in the discussion of field
lengths in Section 2, “RPG Language Elements.”
If the Field Name entry (columns 53–58) specifies an array without an index, the FROM
and TO entries need not provide sufficient space for the whole array (as long as the Field
Location entry provides for an integer number of array elements). The actual length, in
bytes, needed for each array element can be calculated as follows, where t is the value
specified in the Length of Entry field (columns 40–42) in the Extension Specifications:
Alphanumeric t
Unpacked numeric t
Packed signed numeric (t/2) + 1 (integer portion)
Packed unsigned numeric (t + 1)/2 (integer portion)
Separate leading sign t
Entries in the FROM and TO subfields must be right-justified, and leading zeros can be
omitted.
Entry Definition
Any field to be edited or used for arithmetic operations must be numeric. The number of
decimal positions specified cannot exceed the length of the field, as specified in the Field
Location field (columns 44–51).
All fields within one record type should have unique names. If two or more fields within
the same record have identical names, only the last one defined is used unless field
record relation indicators are used. Refer to the discussion of the Field Record Relations
field (columns 63–64) in this section. Fields within a record are processed in the order in
which they appear in the program (subject to the state of the field record relation
indicator). Fields from different record types can have the same name; however, names
not uniquely defined must have the same length and decimal positions. These fields
need not occur in the same location in each record.
OR Relationship
To eliminate duplicate coding of identical fields in different record types, the OR
relationship can be used. OR lines can be used when either of the following situations
occurs:
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100H* The following program shows identical fields defined
00150H* within two different record types.
00200H*
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00500IFILEIN AA 01 70 CA
00600I 1 5 FIELD1
00700I 10 25 FIELD2
00800I 41 472FIELD3
00810I 60 69 FIELD4
00900I BB 02 70 CB
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000I 1 5 FIELD1
01010I 10 25 FIELD2
01020I 41 472FIELD3
01030I 60 69 FIELD4
01100OFILEOUT D 01
01200O FIELD1 5
01300O FIELD2 25
01400O FIELD3 47
01500O FIELD4 69
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100H* This program shows identical fields defined within two
00150H* different record types using an OR line.
00200H*
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00500IFILEIN AA 01 70 CA
00550I OR 02 70 CB
00600I 1 5 FIELD1
00700I 10 25 FIELD2
00800I 41 472FIELD3
00810I 60 69 FIELD4
01100OFILEOUT D 01
01200O FIELD1 5
01300O FIELD2 25
01400O FIELD3 47
01500O FIELD4 69
Special Words
The special words PAGE and PAGEn (where n is in the range 1 through 9) can be used in
the Field Name field.
Refer to the discussion of special words in Section 2, “RPG Language Elements,” for a
complete description of the use of these words.
Entry Definition
A control break occurs when a record containing a control field is read and the data in
that control field are different from the data in the same control field of the previous
record. When a control break occurs, the designated control level indicator is turned on
(along with all lower control level indicators). For example, if control level indicator L5 is
turned on, then indicators L4, L3, L2, and L1 are also automatically turned on. Control
level indicator L0 cannot be assigned to a control field because it is always on.
A control level indicator either can be turned on or can be turned off by specifying it as a
resulting indicator (in columns 54–59 in the Calculation Specifications). A control level
indicator can also be used as a record identifying indicator; however, in this case, control
level indicators lower than the one specified are not automatically turned on or off.
For a detailed description of the treatment of control breaks, refer to the description of
step 7, Control Fields and Record Identification, in Section 3, “RPG Program Logic Cycle
(PLC).”
• The same control level indicator can be used for different record types or files;
however, the control fields associated with that indicator must have the same length.
(See Example 14–6.)
• Field names have no effect on the control level indicator; thus, control fields in
different record types can have the same name and indicator.
• The maximum cumulative size of control fields within one record type is 255
characters.
• Control fields can overlap within a record type.
• For control break purposes, numeric control fields are treated as though they had no
decimal positions.
• For numeric control fields, only the absolute value of the field is compared. The sign
is ignored.
• All control fields with the same control level indicator are considered numeric, if any
of those fields are described as numeric.
• Control levels can be written in any sequence, and gaps are permitted in the control
levels assigned.
• For each control level used in a program, a control break occurs the first time a
control field is encountered if there is no previous control field to compare with the
current control field.
• During the PLC, total calculations and total output are processed in the cycle after
the control field is selected.
• Different record types in a file do not need to have the same number of control
fields. However, the user must ensure that unwanted control breaks do not occur.
Example
Example 14–6 shows the coding of control fields.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00600IFILEIN AA 01 2 CQ
00700I 1 6 MINOR L1
00800I 10 21 NAME
00900I 25 330MAJOR L2
00910I 35 452TOTAL L3
00920I BB 02 2NCQ
00930I 1 90MAJOR L2
00940I 11 202AMT
00950I 21 26 MINOR L1
00960I 30 402TOTAL L3
01000CL1 AMT ADD TOTAL TOTAL
01100OFILEOUT D L1 L2
01200O MINOR B 10
01300O MAJOR B 30
01400O TOTAL 50
01500O NAME B 65
If the same control level indicator is assigned to more than one field within the same
record type, the control field created is known as a split control field. All designated fields
(those having the same control level within the same record type) are combined by the
program in the order in which they are specified in the Input Specifications and are
treated as one control field.
Example
Split control fields are shown in Example 14–7.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00500IFILEIN AA 01 1 D1
00600I 13 16 TYPE01L3
00700I 19 25 TYPE03L3
00800I 10 12 TYPE02L3
00900I 26 28 TYPE10
00910I 29 29 TYPE11L5
00920I 30 31 TYPE12L5
01000I BB 02 1ND1
01100I 2 4 PART01L5
01200I 5 10 DEPT01L3
01300I 11 18 DEPT02L3
01310I*
01320I* The lines above describe split control fields in two record
01330I* types. The L3 control field is split in both record types;
01340I* however, the total length of all L3 fields in the first
01345I* record is the same as in the second record. The L5 control
01350I* field is split in the first record type. The total length
01360I* of all L5 control fields in that record type is equal to
01370I* the length of the single L5 field in the other record type.
01380I*
01500C TYPE01 COMP 'AAAA' 03
01510C TYPE02 COMP 'BBB' 04
01520C TYPE03 COMP 'CCCCCCC' 05
01530C TYPE11 COMP 'Y' 06
01540C TYPE12 COMP 'XX' 07
01600OFILEOUT D L3
01700O 03 TYPE01 10
01800O 04 TYPE02 13
01900O 05 TYPE03 20
01910O DEPT01 30
01920O DEPT02 40
01930O D L5
01940O 06 TYPE11 10
01950O 07 TYPE12 15
01960O PART01 20
The following special rules must be observed for split control fields:
• The same control level indicator can be used for split control fields in different record
types if the field names used are different. The length of various portions of a split
control field in one record type can differ from the corresponding portions in another
record type. However, the total length of the control fields (whether split or not)
must be the same in both record types. For further information, refer to the
discussion of the Field Record Relations field (columns 63–64) in this section.
• If one portion of a split control field is numeric, the entire field is considered numeric.
• No portion of a numeric split control field can exceed the maximum size for numeric
fields (as given in the discussion of field length in Section 2, “RPG Language
Elements” ). However, the total length of all fields assigned to one control level
indicator (within each record type) can be 255 characters.
• A mixture of packed and unpacked control fields is allowed.
• Split control field lines must be contiguous.
Entry Definition
This field must be blank for chained, demand, display, output, record-address, and vector
files.
For multifile processing, the use of match fields enables the compiler to dynamically
determine the absolute value of the data in the specified match fields and to select which
record to process next. This process is known as matching record input control. For the
matching record (MR) indicator to be turned on, one of the multiple files must be
designated as primary, and all others to be used in matching record input control must be
specified as secondary.
If matching records are specified for two or more secondary files and are not specified
for the primary file, matching record processing is performed, but the MR indicator is
never turned on.
For both multifile and single-file processing, the use of match fields specifies that the
sequence of the absolute value of the data in the match field must be in agreement with
the collating sequence specified in the Collating Sequence field (column 26) in the
Control Specification.
Match Fields
Match fields enable the comparison of records from primary and secondary files to
determine when the records match. A maximum of nine different fields can be
designated as match fields (M1 through M9).
The matching record (MR) indicator is turned on whenever the match fields from a
primary file are exactly the same as the match fields from any secondary file. The MR
indicator is turned on or off after overflow output, but before detail calculations, during
the PLC. Additional information on the matching record (MR) indicator is provided in
Section 3, “RPG Program Logic Cycle (PLC).” The entries M1 through M9 specify the
fields in each record are to be matched and cause the MR indicator to be turned on when
a match condition occurs. M1 through M9 are not indicators; the MR indicator conditions
the operations that should be performed when records match.
The following rules must be observed when match fields are assigned:
• All match fields must be in the same sequence during input. Refer to the discussion
of the Sequence field (column 18) in Section 8, “File Description Specifications,”
because sequence checking is automatically performed on all fields designated as
match fields. A sequence error in any field causes a MATCH FIELD SEQUENCE
ERROR message to be displayed. (Refer to the list of error messages in Appendix A,
“System Messages.”)
• If matching is used, not all the primary and secondary files are required to have
match fields. In addition, not all record types within a file are required to have match
fields. However, to achieve a matched condition, at least one record type from the
primary file and at least one record type from a secondary file must have match
fields.
• All fields given the same match field (M1-M9) must be the same length.
• Overlapping of different match fields within a record type is allowed.
• The cumulative size of all match fields cannot exceed 255 characters.
• All records to be matched must contain the same match fields (M1-M9); otherwise, a
match cannot occur, and a warning message is displayed.
• When more than one match field is designated for a record type, all fields to be
matched are combined in descending match field order and are treated as one
contiguous match field. The highest match field is M9.
• Split match fields are not allowed; thus, the same match field cannot be used more
than once for each record type unless field record relation indicators are used.
• Numeric match fields are treated as though they had no decimal positions.
• For numeric match fields, the absolute value of the data are compared.
• If one field within a particular match field is defined to be numeric, then for purposes
of determining a match condition, the rest of the match fields are treated as numeric
values.
• The MR indicator is turned on in multifile processing if the absolute value of the data
in the match fields of a secondary file and the primary file are equal.
• Field names have no effect on the match fields assigned; therefore, match fields in
different record types can have both the same name and the same match field
assigned.
• Whole arrays must not be designated as match fields.
• Records in primary and secondary files without match fields specified are processed
before records in primary and secondary files with match fields specified.
The following rules apply to file processing when match fields are used:
• If a match field condition occurs, the primary file record is processed first.
• When records do not match, the record with the lowest (for ascending files) or
highest (for descending files) match field value is processed first.
• For purposes of record selection, records without match fields are considered to
match the last preceding record with match fields specified and are selected next.
However, because no match occurs, the MR indicator is turned off. If the next record
matches the preceding record with match fields specified, the MR indicator is again
turned on.
• Since matched primary records are selected and processed before matched
secondary records, it is always possible to change the secondary record based on
the contents of the primary record. To change the primary record based on the data
in the secondary record, look-ahead fields must be specified for the secondary
record.
• The MR indicator is turned off while a record selected by the FORCE operation is
processed. If the next nonforced record matches the last record with match fields
specified, the MR indicator is turned on again.
During each program cycle, the program selects a record for processing by inspecting
the record in the input buffer of each primary and secondary file. The following rules
apply to multifile processing when matching records are used:
• If the next record from any primary or secondary file has no match fields, that record
is selected.
• If records are in ascending sequence, the record with the lowest match field is
selected. If records are in descending sequence, the record with the highest match
field is selected.
• If more than one record satisfies either of the preceding rules, the record from the
highest-priority file is selected. The primary file has the highest priority, followed by
the secondary files in the order in which they are specified in the File Specifications.
• If the primary file has an E in the End of File field (column 17) in the File
Specifications, but the secondary files do not, any secondary file records that match
the previous primary record are processed before the LR indicator is turned on. Any
interspersed secondary file records without match fields also are processed before
the LR indicator is turned on.
• The MR indicator is turned on during the processing of any record that contains a
match field, provided that the current match field value originally occurred in a record
from the primary file. Otherwise, the MR indicator is turned off.
Example
An example of multifile processing with match fields is shown in Example 14–8. If
records from the primary and secondary files (EMPLYCRD and TIMECDS) have matching
values for EMPLNO and DEPTNO, the MR indicator is turned on, and records from the
primary file are processed first. If the primary file no longer matches, records from the
secondary file that match the previous primary file are processed.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FEMPLYCRDIP A 96 96 DISK
00400FTIMECDS ISEA 96 96 DISK
00410FPAYROLL O 96 96 PRINTER
00500IEMPLYCRDAA 10 1 CN 2 CA
00600I 3 15 NAME L1
00700I 16 180DEPTNO M2
00800I 19 220EMPLNO M1
00900I 23 292PAYRAT
01000ITIMECDS BB 20 1 CR 2 CC
01100I 3 15 NAME L1
01200I 16 180DEPTNO M2
01300I 19 220EMPLNO M1
01400I 40 462HRSWRK
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.0201
500C MR520 HRSWRK MULT PAYRAT PAY 164
01600C MR 20 TOTPAY ADD PAY TOTPAY 164
01700C MR 20 TOTHRS ADD HRSWRK TOTHRS 82
100OPAYROLL D L1
02200O NAME 15
02300O EMPLNO 25
02400O DEPTNO 30
02500O TOTHRS B 40
02600O TOTPAY B 60
Sequence Checking
Sequence checking of records within a file is performed whenever match fields (M1-M9)
are assigned. This sequence checking is performed with matching records if the primary
file and any secondary files have match fields specified. A maximum of nine fields (M1-
M9) in a record can be used for sequence checking. When a record is encountered that
has match field values out of sequence, a MATCH FIELD SEQUENCE ERROR error
message is displayed (refer to Appendix A, “System Messages”).
The following rules apply when match fields are assigned for sequence checking:
• The contents of the fields designated for sequence checking must be in the same
order, either ascending or descending.
• When more than one field is designated for sequence checking, all fields specified
are combined in order by descending sequence of matching fields (M9–M1) and are
treated as one contiguous field.
• Split sequence fields are not allowed; therefore, the same match field cannot be
used more than once in the record unless field record relation indicators are used.
• Numeric fields are treated as if they had no decimal positions.
• For numeric fields, only the digit portion of each character is compared.
• All sequence fields are considered numeric if any of the fields are numeric.
Example
Example 14–9 shows sequence checking with matching records.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FVOTERLSTIP 180 180 TAPE
00500FREPUBLSTO 132 132 PRINTER
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00510FDEMOCLSTO 132 132 PRINTER
00520FOTHERLSTO 132 132 PRINTER
00600IVOTERLSTNS 01 80 CX
00700I 4 8 STATE M4
00800I 10 15 COUNTY M3
00900I 20 30 CITY M2
01000I 33 35 PRECNT M1
01010I 40 44 PARTY
01020C 01 PARTY COMP 'REPUB' 10
01030C 01 PARTY COMP 'DEMOC' 20
01040C 01 PARTY COMP 'INDEP' 30
01700OREPUBLSTD 10
01800O STATE 8
01900O COUNTY 15
02000O CITY 30
02010O PRECNT 35
02020ODEMOCLSTD 20
02030O STATE 8
02040O COUNTY 15
02050O CITY 30
02060O PRECNT 35
02070OOTHERLSTD 30
02080O STATE 8
02090O COUNTY 15
02100O CITY 30
02110O PRECNT 35
The following rules apply when field record relation indicators are assigned:
• The field record relation indicator does not need to be the same as any record
identifying indicator specified for the file.
• Fields within a record type that specify the same field record relation indicator can be
entered in any order.
• Split control fields must all have the same entry in the Field Record Relations field.{
Entry Definition
Example
Example 14–10 shows the use of field record relation indicators. Fields FIELD2 and
FIELD3 of the current record are available only if indicator 02 is on, and the FIELD6 field
is available only if indicator 03 is on. Fields FIELD4, FIELD5, FIELD7, FIELD8, and FIELD9
are available only if indicator 04 is on.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 180 180 DISK
00400FFILEOUT O 132 132 PRINTER
00700IFILEIN AA 01 80 CA
00800I 1 51FIELD0L2
00900I 71 752FIELD1L2
01000I 61 64 FIELD2L3 02
01100I 65 70 FIELD3L3 02
01200I 7 12 FIELD4L4 04
01210I 13 22 FIELD5L4 04
01220I 41 514FIELD6 03
01230I 10 13 FIELD7L4 04
01240I 14 20 FIELD8L4 04
01250I 21 25 FIELD9L4 04
01300C 01 FIELD0 COMP FIELD1 020304
01600OFILEOUT D 01
01700O FIELD0 5
01800O FIELD1 75
01900O 02 FIELD2 64
02000O 02 FIELD3 70
02010O 04 FIELD4 12
02020O 04 FIELD5 22
02030O 03 FIELD6 51
02040O 04 FIELD7 13
02050O 04 FIELD8 20
02060O 04 FIELD9 25
The following restrictions apply to control level and matching record indicators:
• A control level indicator cannot be used with a field that is part, or all, of a control
group.
• The matching record indicator should not be used with a field that is part, or all, of a
matching record input control group.
To overcome these restrictions, the fields can be defined twice: once to specify the
control fields, matching fields, or both, and again on another specification line with a
different entry in the Field Name field (columns 53–58) to specify the desired field record
relation.
When two or more control fields, or two or more match fields, have the same control
level indicator or match field indicator, respectively, one of these sets of fields cannot
have a field record relation indicator assigned. If a split control field is specified, this
restriction applies to the group of specifications that forms the split control field. Thus,
specifications with field record relation indicators are used if that indicator is on. When
field record relation indicators are on, the specification without any field record relation
indicator is used.
65–66 Plus Any valid indicator specified in this field is turned on if the
corresponding data field is greater than 0 (for a numeric field)
or greater than blank (for an alphanumeric field).
67–68 Minus Any valid indicator specified in this field is turned on if the
corresponding data field is less than 0 (for a numeric field) or
less than blank (for an alphanumeric field).
69–70 Zero or Any valid indicator specified in this field is turned on if the
blank corresponding data field is 0 (for a numeric field) or blank (for
an alphanumeric field).
The following rules must be observed when field indicators are assigned and used:
• If the Zero/Blank Indicator Setting field (column 42) in the Control Specification is
blank, all field indicators are off at the beginning of the program and remain off until
the condition being tested is satisfied by the input record just read.
If the Zero/Blank Indicator Setting field contains an S, the indicators 01 through 99,
which are used as zero/blank indicators, are turned on at the beginning of the
program execution (unless the indicators are also used as record identifying
indicators). All other field indicators are off at the beginning of the program. Field
indicators are turned on if the condition being tested is satisfied by the input record
just read. In the case of zero/blank indicators that might have been turned on during
the previous output cycle, if the condition being tested is not satisfied, then the
indicator is turned off.
• A field can be assigned more than one field indicator; however, only the indicator
specified for the condition with a TRUE result is turned on. All other indicators
assigned to the field are turned off.
• The state of a field indicator assigned to fields in different record types is determined
by the last record selected.
• The state of a field indicator assigned to more than one field within a record type is
determined by the last field to which the indicator is assigned.
• If a field indicator is not used elsewhere in the program, it remains on (or off) until
another record of the same type is selected.
• Indicators specified in the Field Indicators field can be altered by using them as
resulting indicators in the Resulting Indicators field (columns 54–59) in the Calculation
Specifications.
• If a halt indicator specified in the Field Indicators field is turned on as a result of the
corresponding condition being TRUE, the program halts after the input record that
caused the halt indicator to turn on has been completely processed.
• Field indicators cannot be assigned to whole arrays.
• Define each field in the record with unique field names, such as ITEMA, ITEMB,
ITEMC, and ITEMD. Assuming that each ITEM field is the same length and data
format, the program then handles each individual field in one program cycle.
• Define the control fields, called the header, followed by the entry TR in columns 19
through 20 of the Input Specifications, and the first set of ITEM fields, called the
trailer. This method of specifying data records enables the compiler to assume that
the columns to the right of the record contain more sets of ITEM fields with the
same length and format. One trailer after another is processed, with one program
cycle for each trailer, until the end of the record or a trailer containing all blanks is
reached. Each trailer is processed with the header as one logical record.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F*
00200F* This program demonstrates the header-trailer, or spread
00300F* record, feature.
00400F*
00500F* The program reads a file of customer orders and prints them.
00600F*
00700F* The input file named SPREAD uses header-trailer formatting
00800F* for its input records. Each record has a customer number
00900F* in byte positions 1 through 5, and has between 1 and 4 order
01000F* descriptions following it on the same record. Here the
01100F* CUSTNO field is in the header portion of the input records,
01200F* and ITMNO, SIZE, and QTY are in the trailer portion.
01400F*
01500F* One program cycle is executed for each trailer portion of a
01600F* record, so that between 1 and 4 cycles are executed for each
01700F* input record.
01800F*
01900FSPREAD IP 80 80 DISK
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FPRINT O 120 120 DISK
02100I*
02200ISPREAD AA 01
02300I 1 50CUSTNO
02400I TR
02500I 6 130ITMNO
02600I 14 150SIZE
02700I 16 210QTY
02800O*
02900OPRINT H 1P
03000O 'CUSTOMER NUMBER '
03100O 'ITEM NUMBER '
03200O 'SIZE '
03300O 'QUANTITY '
03400O H 1P
03500O '--------------- '
03600O '----------- '
03700O '---- '
03800O '---------- '
03900O D 01
04000O CUSTNOX 15
04100O ITMNO X 29
04200O SIZE X 40
04300O QTY 1 62
Data Structures
A data structure is an area in memory composed of one or more fields called subfields.
Ordinarily every field and array, whether defined on the Input Specifications or Calculation
Specifications, is assigned its own unique location in memory these fields do not overlap.
The Input Specifications that overlaps redefines locations in the buffer for the input file,
not in the storage location for variables.
A data structure can be used to define an area of memory in several ways and to
reorganize fields for easier reference. One data structure within a program can be
designated as a local data area for the program. Additional information on this type of
data structure is provided within this section. A data structure can also be used to
subdivide an input field into subfields that can be referred to in the program.
A data structure is coded on the Input Specifications. This is done because a data
structure maps an area in memory in a manner very similar to the way the Input
Specifications for a file map the input buffer. However, data structures do not specify
input.
Data structures must be the last entries on the Input Specifications, following all Input
Specifications for files. A data structure entry is specified in two parts: the data structure
name description and the data structure subfield description.
7–12 Data Structure Contains blanks or the name of the data structure.
Name Note that unlike the Input Specifications for files, the
name can be only 6 characters long. The following
conditions apply to the data structure name:
• Must meet the requirements of a field name.
• Can be a name previously referred to in the Field
Name field (columns 53–58) of the Input
Specifications.
• Can be a name previously referred to in the
Variable Name field (columns 66–77) of the
Attribute Specifications.
18 Option Must have a U if the data structure is the local data
area for a terminal; otherwise, it is blank. Refer to the
discussion of the data structure for a local data area
later in this section.
19–20 Record Contains the letters DS.
Identifying
Indicator
21–70 Must be blank.
• Subfield names must be unique within data structures, but the same names can be
repeated in the From, To, Packed, and Decimal Positions fields to enable the user to
repeat fields in varying forms of output.
• The same subfield name cannot be used in more than one data structure.
• A data structure name cannot be used as a subfield name.
• A subfield name can be an array name, but not a table name. The array named is
allocated at the specified location in the data structure. The correct number of bytes
must be designated to accommodate the array as declared in the Extension
Specifications. Note that the Packed field (column 43) can be used to specify the way
in which numeric array elements are to be stored.
Field record relation indicators, control level indicators, match field values, and field
indicators are not allowed in the data structure subfields.
• A data structure is alphanumeric and is initialized to blanks, except for subfields that
are names of compile-time arrays, preexecution-time arrays, or the local data area for
a terminal. The initial value for numeric subfields in display format is 0 (zero); the
value is blank for Packed fields (column 43). For any other numeric format, the initial
value is unpredictable.
• A data structure name can be specified anywhere an alphanumeric field name is
allowed.
• Subfields can be referred to as ordinary variables.
• The maximum length for a data structure is 9999 characters, except for the local data
area, which has a maximum of 512 characters.
• The maximum length for an alphanumeric subfield is 9999 characters. A numeric
subfield has a maximum length of 23 digits.
• An array can be specified as a subfield; however, the length of the subfield must be
the entire length of the array. A table name or an array element cannot be used as a
subfield name.
• When a field appears as a data structure or a subfield, the entire data structure or the
specified location within a data structure is the space reserved for the field.
• A look-ahead field cannot be used as a data structure name or a subfield.
A data structure name must not be the same as any of the following names:
− Another data structure name in the program
− Array name
− Look-ahead field name
− Output group name
− Table name
− Subfield name
• A subfield name must not be the same as any of the following names:
− Array element name
− Data structure name
− Look-ahead field name
− Output group name
− Table name
Example
Example 14–12 shows that subfields can be defined to overlap. In this program example,
the subfield NAME is 60 characters long in positions 1 through 60. The subfield is
redefined in the following two ways:
• The subfield is subdivided into the three subfields FNAME (first name), MNAME
(middle name), and LNAME (last name).
• The entire subfield is redefined by the array N (name). This redefinition is useful
because it enables individual characters of the name to be accessed. For example,
N,5 is the fifth character of NAME. In addition, the array N can be used in the LOKUP
operation code. For example, N can be used to find the first blank character in
NAME, or in any of the subfields NAME, FNAME, MNAME, or LNAME.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000E N 60 1
02000I DS
03000I 1 60 NAME
04000I 1 20 FNAME
05000I 21 40 MNAME
06000I 41 60 LNAME
07000I 1 60 N
Example
Example 14–13 shows the use of repeating subfields for a sporting event and a concert.
The data structure defined is named EVENT. There are two formats for EVENT. The
format used with sporting events has subfields for the event number, date, time, price,
the names of both teams, and the stadium where the game is to be played. The format
used with a concert has subfields for the event number, date, time, price, the name of
the band, and the name of the concert hall at which the performance is to occur.
Note that both formats have subfields for event number, date, time, and price, that the
definition is repeated for each, and the definitions are identical each time they are
repeated.
Note also that the subfield PRICE has a J in column 43. PRICE is to be stored in unsigned
packed format.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000I*
04000I* Definition of a data structure named EVENT:
06000I*
18800IEVENT DS
18900I*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
19000I* The EVENT data structure can have several formats, depending on
19100I* the event type (E-TYPE), which will be S for sporting event and
19200I* C for concert:
19300I*
19800I 1 1 E-TYPE
19850I*
19900I* Layout of EVENT data structure for a sports event:
19950I*
20000I 2 70EVENTNO
20050I 8 130E-DATE
20100I 14 190E-TIME
20150I J 21 232PRICE
20200I 31 50 TEAM1
20400I 51 70 TEAM2
20600I 71 90 STADM
22000I*
24000I* Layout of EVENT data structure for a concert:
26000I*
28000I 2 70EVENTNO
30000I 8 130E-DATE
32000I 14 190E-TIME
34000I J 21 232PRICE
36000I 31 50 BAND
38000I 51 70 HALL
Example
An example of a data structure for a local data area is shown in Example 14–14. LOCAL
is a data structure with one 80-byte alphanumeric field called TEXT. The data structure
LOCAL is the local data area for the program.
When the program is started, the TASKSTRING task attribute is placed into the local data
area. This value can then be referred to with the use of the data structure designated by
the program to be the local data area. In the example of coding for a local data area data
structure, either TEXT or LOCAL can be used.
For instance, the following CANDE command places the alphanumeric value MONDAY at
the beginning of TEXT, with the rest of the local data area, LOCAL, containing blanks:
Because TASKSTRING is a read-only attribute, the value of the local data area is not
written back to TASKSTRING when the program ends.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000I*
02000ILOCAL UDS
03000I 1 80 TEXT
The Calculation Specifications indicate the sequence and timing of the following two
types of data manipulation:
• Detail calculations
• Total calculations
• Subroutines
Note: Subroutines cannot be the only Calculation Specifications entries because
subroutines can be accessed only from detail or total calculations; however, all three
types of Calculation Specifications need not occur.
Each specification line describes one operation and has three functional parts:
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter C.
7 Contains an asterisk (*) if the line is a comment.
7–8 Contains one of the control level indicators, an indication of a subroutine, or
an indication of an AND and OR relationship. Acceptable entries are L0
through L9, LR, SR, AN, OR, or blanks.
9–17 Contains indicators divided as follows:
• Columns 9, 12, and 15 are Not subfields that designate that the
associated indicator is to be off. Acceptable entries are N or blank.
• Columns 10 through 11, 13 through 14, and 16 through 17 can contain
indicators to condition a calculation operation. Acceptable entries are 01
through 99, L0 through L9, LR, MR, H0 through H9, U1 through U8, OA
through OG, OV, or blank.
18–27 Contains a field name, a special word, an alphanumeric or numeric literal, a
subroutine name, a label, a vector name, a vector element, or blank. The
entry must be left-justified.
28–32 Names the type of operation to be performed. Acceptable entries are listed
at the beginning of Section 16, “Operation Codes.” The entry must be left-
justified.
33–42 Contains a field name, a special word, an alphanumeric or numeric literal, a
subroutine name, a vector name, a vector element, a label, a file name, or
blank. The entry must be left-justified.
43–48 Identifies the name of the field, vector, or vector element that is used to
store the results of the operation. The entry must be left-justified.
49–51 Designates the length of the Result Field. Acceptable entries are 1 through
999 or blank. The entry must be right-justified.
52 Designates the number of decimal positions. If this field is blank, the entry is
alphanumeric. Acceptable entries are blank, D, T, or the numbers 0 through
9. COMS entries (D and T) are described in Volume 2 of this manual.
Columns Description
53 Defines whether or not the contents of the Result Field (columns 43–48) are
to be rounded. Acceptable entries are blank or H.
54–55 Specifies an indicator that turns on if one of the following conditions is true:
the Result Field (columns 43–48) is positive, Factor 1 (columns 18--27) is the
highest in a compare or LOKUP operation, or a tested zone (TESTZ
operation) is a plus zone. Acceptable entries are 01 through 99, L1 through
L9, LR, H0 through H9, OA through OG, OV, or blank.
56–57 Specifies an indicator that turns on if one of the following conditions is true:
the Result Field (columns 43–48) is negative, Factor 1 (columns 18--27) is
the lowest in a compare or LOKUP operation, or a tested zone (TESTZ
operation) is a minus zone. Acceptable entries are 01 through 99, L1 through
L9, LR, H0 through H9, OA through OG, OV, or blank.
58–59 Specifies an indicator that turns on if one of the following conditions is true:
the Result Field (columns 43–48) is 0 (zero) or blank, Factor 1 (columns 18--
27) is equal to Factor 2 (columns 33–42) in a compare or LOKUP operation,
or a tested zone (TESTZ operation) is neither a plus nor minus zone.
Acceptable entries are 01 through 99, L1 through L9, LR, H0 through H9,
OA through OG, OV, or blank.
60–74 Contains comments and documentary remarks.
75–80 Contains the program identification. Any entry is valid.
For information about data management and COMS Calculation Specifications, refer to
Volume 2 of this manual.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Field Definitions
The fields for the Calculation Specifications form are defined in the following paragraphs.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 15–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105C*
00110C* This is an example of how comment lines are coded. All
00120C* lines with an asterisk in column 7 are ignored by compiler.
00140C*
Entry Definition
L0–L9 The calculation operation is performed during total calculations only if the
designated control level indicator is on. L0 is always on.
LR The calculation operation is performed if the last record (LR) indicator is on.
L0 through L9
A control level indicator specified on the Input Specifications can be used to condition
operations that are to occur at a control break. The operation described on this
specification line of the Calculation Specifications is performed only when the designated
indicator is on. Information about the time when control level indicators can be turned on
is provided in the discussion of control level indicators in Section 14, “Input
Specifications.” Control level indicators need not be specified in a particular order.
Operations are executed in the order in which the operations are specified.
The L0 indicator is turned on after detail output during every cycle of the program. If no
other control level indicator is assigned, but total calculations are desired, the L0 indicator
can be used to condition those operations.
Example
The L0 indicator is used to condition the total calculation because total calculations are
desired and the program has no control level indicators assigned on the Input
Specifications.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F*
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000I*
05000IFILEIN AA 01
06000I 5 132WAGE1
07000I BB 02
08000I 5 132WAGE2
09000C*
10000C 01 WAGE1 ADD TOTWAG TOTWAG 102
11000C 02 WAGE2 ADD TOTWAG TOTWAG 102
12000CL0 01 02 TOTWAG ADD TOTAL TOTAL 122
13000CLR TOTWAG ADD TOTAL TOTAL
14000O*
15000OFILEOUT T 1 L0
16000O TOTWAGJ 20
LR
The LR indicator is used to condition operations to be performed at EOF. This indicator is
automatically turned on when the last record has been read and processed. Control level
indicators L1 through L9 are also turned on. The LR indicator can also be turned on if it is
specified as a resulting indicator of a Calculation Specification. A calculation operation
that turns on the LR indicator does not cause the other control level indicators to be
turned on.
SR
The subroutine (SR) entry is not an indicator; rather, it is used to indicate that the
specification on a particular line is part of a subroutine. Subroutines must be specified
after all detail and total calculation lines are specified. A subroutine specification line can
contain SR, OR, AN, or blanks in columns 7 through 8. The first BEGSR operation
determines the start of subroutines.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F*
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000I*
05000IFILEIN AA 02 1 CA
06000I 5 132WAGE
07000I 2 42AMT1
08000I BB 03 1 CB
09000I 15 232WAGE
10000I 2 42AMT2
11000I CC 04 1 CC
12000I 25 332WAGE
13000I 2 42AMT3
14000C*
15000C 02 WAGE COMP AMT2 050603
16000C 03 WAGE COMP AMT3 050604
17000C 04 WAGE COMP AMT1 050602
18000C 02 03 04
19000C*
20000C* Example of OR coding
21000C*
22000COR 02 03
23000COR 02 04
24000COR 03 04
25000C*
26000C* Example of AND coding
27000C*
28000CANN05N06 WAGE ADD TOTAL TOTAL 122
29000O*
30000OFILEOUT T 1 LR
31000O TOTAL J 20
The Indicator subfields designate the indicator to be tested. If the immediately preceding
Not subfield is blank, the indicator is tested to determine if it is on. If the subfield
contains an N, the indicator is tested to determine if it is off.
Entry Definition
Blank The operation is not conditioned by any indicators. In this case, the Not
subfield must also be blank.
L0–L9 The operation is conditioned by a control level indicator defined in the Input
or Calculation Specifications.
All the indicators specified on one line are in an AND relationship. These indicator
conditions, plus any others associated in an AND relationship (AN in columns 7–8), must
be satisfied if the operation is to be performed. Each of the indicators is discussed in the
following paragraphs.
• Condition calculation operations to be performed only for specific input record types
if the indicator was designated in the Record Identifying Indicators field
(columns 19–20) in the Input Specifications
• Condition calculation operations to be performed only when an input field meets
certain conditions if the indicator was identified in the Field Indicators field
(columns 65–70) in the Input Specifications
• Condition calculation operations according to the results of previous operations if the
indicator was specified in the Resulting Indicators field (columns 54–59) in the
Calculation Specifications
The following conditions apply when control level indicators are used in the Indicators
field:
• An operation to be performed during detail calculations occurs only while the first
record of the new control group is being processed.
• An operation to be performed during total calculations occurs when both the control
break specified in columns 7 through 8 and the control break specified in the
Indicators field are satisfied. Both control breaks can be satisfied when the last
record of a control group has been processed.
• An operation that is part of a subroutine and that is called from detail calculations
occurs only while the first record of the new control group is being processed.
• An operation that is part of a subroutine and that is called from total calculations
occurs only if the EXSR operation is at an equal or higher control level.
During detail calculations or a subroutine called from detail calculations, the MR indicator
refers to the status of the match fields of the record last selected.
During total calculations or a subroutine called from total calculations, the MR indicator
refers to the status of the match fields for the record before the record last selected.
Because the program does not halt until the record in error has completely processed,
action must be taken to prevent reporting of erroneous results. The halt indicators can be
used with an N in the Not subfields of the Indicators field to inhibit an operation when the
specified halt indicator is on.
The program performs operations in the order in which they appear in the Calculation
Specifications; however, all operations conditioned by control level indicators designated
in the Control Level field (columns 7–8) must appear after operations not conditioned by
control level indicators and before all subroutines.
All entries in the Result Field must be left-justified. Special words, except those in the
following list, can also be entered here.
• Literals
• JDATE
• UDATE
• UMONTH
• UDAY
• UYEAR
• UTIME
• UDAYNM
A new field can be defined by entering the new field name as the Result Field, along with
the Field Length (columns 49–51) and Decimal Positions (column 52) field entries. A
complete description of field names is provided in Section 2, “RPG Language Elements.”
If this field is blank, the field length must be defined elsewhere in the program (in the
Input or Extension Specifications or on a different line in the Calculation Specifications).
This field must be blank if the Result Field (columns 43–48) is blank.
The length of a field, vector, or vector element that has been previously defined can be
entered in this field; however, the length and number of decimal positions specified must
be the same as those previously defined.
Entries in this field must be numeric and right-justified; leading zeros can be omitted.
If the Result Field (columns 43–48) is either alphanumeric or blank, or if the Field Length
field (columns 49–51) is blank, this field must be blank.
If the Result Field is numeric and the Field Length field is specified, the Decimal Positions
field must contain an entry in the range 0 through 9; however, if a numeric vector or
vector element is assigned as the Result Field and the Field Length field is specified, the
Decimal Positions field can contain an entry or can be blank. If an entry is made, it must
agree with any previous entry specified for the field.
Entry Definition
The number of decimal positions specified must not exceed the length of the Result
Field. If the Result Field contains only integer values, the value of the Decimal Positions
field must be 0 to indicate that the Result field is numeric with no implied decimal
positions.
Entry Definition
H Half adjust.
Three fields (columns 54–55, 56–57, and 58–59) can be used to test for different
conditions at the same time.
Entry Definition
The resulting indicator turns on if the Result Field contains the appropriate result. The
Result Field can contain the result of an arithmetic operation or the results of one of the
following operation codes:
• CAS
• CHAIN
• COMP
• LOKUP
• READ
• READE
• READP
• TESTB
• TESTZ
Resulting indicators must not be specified when the Result Field (columns 43–48) is an
unsubscripted array name.
A discussion of operation codes and indicators is provided in Section 16, “Operation
Codes.” When a control level indicator is used as a resulting indicator, lower control level
indicators are not turned on.
Example
Example 15–4 shows the use of resulting indicators.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F*
00200FFILEIN IP 80 80 DISK
00300FFILE1 IT 80 80 DISK
00400FFILE2 ID 80 80 DISK
00500FDISKIN IC 180 180 4AI DISK
00600FFILEOUT O 132 132 PRINTER
00700E*
00800E FILE1 TABLES 3 100 6 0
00900I*
01000IFILEIN AA 01
01200I 5 100FIELD1
01300I 15 200FIELD2
01400I 25 300FIELD3
01500I 32 350KEY
01600I 40 40 ALPHA
01700IFILE2 AA 02
01800I 1 1 DUMMY1
01900IDISKIN AA 03
02000I 1 1 DUMMY2
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02100C*
02200C* Arithmetic operation:
02300C*
02400C 01 FIELD2 SUB FIELD1 FIELD3 22
02500C*
02600C* Compare operation:
02700C*
02800C FIELD2 COMP 124 234567
02900C*
03000C* Lookup operation:
03100C*
03200C FIELD3 LOKUPTABLES 89
03300C*
03400C* Chain operation:
03500C*
03600C KEY CHAINDISKIN 99
03700C*
03800C* Indicator operation:
03900C*
04100C SETON 5152
04200C SETOF 535155
04300C*
04400C* Read operation:
04500C READ FILE2 H8
04600C*
04700C* Test zone operation:
04800C*
04900C TESTZ ALPHA 010203
05000O*
05100OFILEOUT D 1 01
05200O FIELD1 10
05300O FIELD2 20
05400O FIELD3 30
Table 16–1 outlines the organization of operation code definitions in this section.
Arithmetic Operations
In the following paragraphs, a vector element is valid anywhere a field name is valid,
except as noted. Arithmetic operations are allowed only on numerically defined data
items. If the Factor 1 field (columns 18–27) is not specified for an ADD, a SUB, a MULT,
or a DIV operation, the default is the field indicated by the Result Field (columns 43–48).
This feature enables a shorthand specification of the operation. The Factor 1 field
(columns 18–27) and the Factor 2 field (columns 33–42) must either name numeric fields
or contain numeric literals. The Result Field must also be numeric.
All results are signed, and decimal alignment is performed. If the Result Field is not large
enough to hold the result, that result is truncated at one or both ends after decimal
alignment. If the Result Field is too large, leading and trailing zeros are inserted after
decimal alignment. Refer to Table 16–2 for an example of the importance of designating
a correct amount of space for the result.
Factor 1, Factor 2, and the Result Field can have identical or different field names. The
Half Adjust field (column 53) can be specified for all arithmetic operations except SQRT
and MVR. The Resulting Indicators field (columns 54–59) can be specified for all
operations, provided that the Result Field is not a whole array.
A whole array can be entered in the Factor 1 or the Factor 2 field if the Result Field is
also a whole array. In this case, the designated arithmetic operation is performed on each
element of the array or arrays designated as factors. The result is indicated in the
corresponding elements of the array in the Result Field. The operation ends when it
reaches the end of the shortest array. If the Result Field is an array but Factor 1 and
Factor 2 are not, the result of the operation performed on Factor 1 and Factor 2 is placed
in each element of the Result Field array.
• The numeric value of the arithmetic operation is not defined for the attribute field
name.
• The field name is defined as read-only.
The meanings of resulting indicators for arithmetic operations are as follows:
• The plus indicator (columns 54–55) is turned on if the Result Field is greater than 0.
• The minus indicator (columns 56–57) is turned on if the Result Field is less than 0.
• The zero indicator (columns 58–59) is turned on if the Result Field is 0.
The following abbreviations are used in the discussion of the truncation warning
messages:
Abbreviation Definition
• ADD, SUB
A warning is issued if one of the following is true:
(L1 - D1) > (LR - DR)
(L2 - D2) > (LR - DR)
• MULT
A warning is issued if the following is true:
(L1 - D1) + (L2 - D2) > (LR - DR)
• DIV
A warning is issued if the following is true:
(L1 - D1) > (LR - DR)
• ADD, SUB
A warning is issued if either of the following is true:
D1 > DR
D2 > DR
• MULT
A warning is issued if the following is true:
(D1 + D2) > DR
ADD (Add)
This operation adds the contents of the Factor 2 field (columns 33–42) to the contents of
the Factor 1 field (columns 18–27) and stores the sum in the Result Field (columns 43–
48). Additional information on the ADD operation is provided in the discussion of
arithmetic operations in this section.
This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
named in the Result Field. The Factor 1 field can be blank if the field to be used is the
same field as the Result Field. Example 16–1 shows the use of shorthand specifications.
Example
Example 16–1 shows shorthand forms of arithmetic operation coding for the ADD, SUB,
MULT, and DIV operation codes.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...00
100F*
00200FFILEIN IP 80 80 DISK
00300FFILEOUT O 132 132 PRINTER
00400I*
00500IFILEIN AA 01
00600I 5 100AMT1
00700I 15 200AMT2
00800C*
00900C* The following two lines have the same meaning.
01000C*
01100C AMT2 ADD AMT1 AMT2
01200C ADD AMT1 AMT2
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
01300C*
01400C* The following two lines have the same meaning.
01500C*
01600C AMT2 SUB AMT1 AMT2
01700C SUB AMT1 AMT2
01800C*
01900C* The following two lines have the same meaning.
02000C*
02100C AMT2 MULT AMT1 AMT2
02200C MULT AMT1 AMT2
02300C*
02400C* The following two lines have the same meaning.
02500C*
02600C AMT2 DIV AMT1 AMT2
02700C DIV AMT1 AMT2
02800OFILEOUT D 1 01
02900O AMT1 20
03000O AMT2 30
DIV (Divide)
This operation divides the contents of the Factor 1 field (columns 18–27) by the contents
of the Factor 2 field (columns 33–42) and places the quotient in the Result Field
(columns 43–48). Additional information on the DIV operation is provided in the
discussion of arithmetic operations in this section.
This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
designated as the Result Field. Factor 1 can be blank if the Factor 1 field and the Result
Field have the same field name.
Any remainder resulting from the DIV operation is lost unless the next operation
specified is the MVR operation. The Result Field cannot be a whole array if the next
operation is an MVR operation.
MULT (Multiply)
This operation multiplies the contents of the Factor 1 field (columns 18–27) by the
contents of the Factor 2 field (columns 33–42) and stores the product in the Result Field
(columns 43–48). Additional information on the MULT operation is provided in the
discussion of arithmetic operations in this section.
This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
designated as the Result Field. Factor 1 can be blank if the Factor 1 field and the Result
Field have the same name.
Table 16–2 shows the importance of allowing a correct amount of space and number of
decimal places for the result of an operation. Two decimal numbers (89.67 and 2.148) are
multiplied. Allowing too many positions to the left or right of the decimal place causes
many leading or trailing zeros to appear. These zeros are unnecessary and can lead to an
inaccurate interpretation. Inaccuracies can also occur if there are too few leading zeros.
For example, the first result shown in each row of the table is completely inaccurate
because not enough space was provided to contain the result. The result that has 4
decimal positions and a field length of 7 numbers (192.6111) has no leading or trailing
zeros. The result is accurate and easy to read.
Table 16–2 shows the Result Field with varying entries in the Decimal Positions field
(column 52) and the Field Length field (columns 49–51).
Field Length
Decimal Position 1 3 5 7 9
The MVR operation must immediately follow the DIV operation. The MVR and DIV
operations should be conditioned by the same indicators to avoid unpredictable results.
Additional information on the MVR operation is provided in the discussion of arithmetic
operations in this section.
The following items should be considered when the size of the Result Field is specified:
Obtaining reasonable precision from the SQRT operation requires that there be at least
half as many integer positions and implied decimal positions in the Result Field as there
are in the Factor 2 field.
The result of the SQRT operation is automatically adjusted; therefore, a Half Adjust field
(column 53) entry is not allowed.
If Factor 2 is negative, the program displays a SQRT OPERATION ERROR error message.
Table 16–3 shows possible results of the SQRT operation performed on the decimal
number 2994.42. Note the importance of allowing sufficient spaces to the left and right
of the decimal place. In addition, the presence of leading and trailing zeros can lead to an
inaccurate reading of the result. The result that has 3 decimal positions and a field length
of 5 numbers (54.721) has no leading or trailing zeros. The result is accurate and easy to
read.
Field Length
Decimal Position 1 2 3 4 5 6
SUB (Subtract)
This operation subtracts the contents of the Factor 2 field (columns 33–42) from the
contents of the Factor 1 field (columns 18–27) and places the difference in the Result
Field (columns 43–48). Additional information on the SUB operation is provided in the
discussion of arithmetic operations in this section.
This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
designated as the Result Field. The Factor 1 field can be blank if the Factor 1 field and the
Result Field have the same name. See Example 16–1 earlier in this section for examples
of abbreviated specifications.
When two identical fields are subtracted, the result is the same as it is when 0 (zero) is
assigned to the Result Field.
All elements of the array specified by the Factor 2 field (columns 33–42) are added, and
the total is placed in the Result Field (columns 43–48). The Factor 1 field (columns 18–27)
must be blank, and the Result Field cannot be a whole array.
If the Result Field is an element of the array named in the Factor 2 field, the value of that
element before the XFOOT operation is the one used in obtaining the total.
Factor 2 is not affected unless it is named in the Result Field. The Factor 1 field
(columns 18–27) must be blank.
The Factor 1 field (columns 18–27) must be blank. Factor 2 is not affected unless it is
named in the Result Field.
Comparison Operations
The comparison operations test the specified fields for certain conditions. The results are
shown in the specified Resulting Indicators field (columns 54–59), which must be set.
Field values are not affected. At least one resulting indicator must be specified. The
TESTZ operation uses the Result Field (columns 43–48); however, the Result Field and
the Half Adjust field (column 53) must be blank for all other operations. Neither the Factor
1 field (columns 18–27) nor the Factor 2 field (columns 33–42) can name a whole array.
COMP (Compare)
This operation compares the Factor 1 field (columns 18–27) with the Factor 2 field
(columns 33–42) and sets the Resulting Indicators field (columns 54–59).
Setting Comparison
The previously described conditions are also true if Factor 2 specifies a field name
associated with an alphanumeric, mnemonic, or numeric attribute.
If the program reaches the end of the fields, an equal condition exists. The equal
indicator (columns 58–59) turns on if the characters are equal in the collating sequence.
• The high indicator (columns 54–55) turns on if the Factor 1 field contains the
character higher in the collating sequence.
• The low indicator (columns 56–57) turns on if the higher character is in the Factor 2
field.
Each character in the field must be unsigned except for the low-order character, which
must contain one of the following to be considered numeric:
The TESTN operation determines the sign of the low-order (rightmost) character within
an alphanumeric field as follows:
Plus A through I, + 0, +
Negative J through R, – 0, --
Unsigned 0 through 9
Note: Because the tested field is alphanumeric, the contents of this field must be
moved to a numeric field if an arithmetic operation is to be performed.
If the field under test is numeric, no resulting indicator can be specified in columns 58
and 59. With that exception, the Resulting Indicators field is set according to the
character under test.
Move Operations
Move operations transfer the contents of the Factor 2 field (columns 33–42) to the Result
Field (columns 43–48). These operations do not affect the Factor 2 field. The Factor 1
field (columns 18–27) must be blank.
The operation code, the Factor 2 field, and the Result Field must contain entries. The
Control Level field (columns 7–8), the Indicators field (columns 9–17), and the Field
Length field (columns 49–51) can contain valid entries. The remainder of the specification
line must be blank.
The Resulting Indicators field (columns 54–59) can indicate the status (plus, minus, or
zero/blank) of the Result Field in the same manner as for arithmetic operations. If both
the Factor 2 field and the Result Field have the same length, the MOVE and MOVEL
operations give identical results. Factor 2 can be a field, vector, vector element, or literal;
however, the Result Field can only be a field, vector, or vector element.
An array name can be entered in the Factor 2 field if the Result Field also names an array.
In this case, the designated move operation is performed on each element of the array
named in the Factor 2 field. The result is placed in the corresponding elements of the
array specified in the Result Field. The operation ends when it reaches the end of the
shorter array. If the Result Field is an array but Factor 2 is not, the designated move
operation is performed on Factor 2, and the result is placed in all elements of the Result
Field array.
For MOVE and MOVEL operations, the sign of a numeric variable is the algebraic sign;
the sign of an alphanumeric variable is the low-order zone.
Numeric fields that are the result of a MOVE or MOVEL operation contain a negative sign
(binary 1101) if the zone of the low-order byte of the alphanumeric field is negative
(binary 1101); otherwise, the field is positive.
For any move operations that affect the sign position, the following rules apply:
• When a positive numeric field is moved to an alphanumeric field, the sign byte of the
Result Field is alphanumeric 0 through 9.
• When a negative numeric field is moved to an alphanumeric field, the sign of the
Result Field is the negative sign (binary 1101).
Move operations can be specified between fields of different data types. Doing so
converts an alphanumeric field to numeric or a numeric field to alphanumeric. The
position of the decimal point is ignored for numeric fields.
If the Result Field is a field name defined in the Attribute Specifications, the contents of
the Factor 2 field assign a value to the associated attribute. If Factor 2 is a field name
defined in the Attribute Specifications, the Result Field contains the associated value for
this attribute at the end of the operation.
If the Result Field designates a field name associated with an alphanumeric or mnemonic
attribute, Factor 2 must be one of the following:
• An alphanumeric literal
• An alphanumeric variable name
• An alphanumeric attribute identifier
• A mnemonic attribute identifier
If the Result Field specifies a field name associated with a numeric attribute, Factor 2
must be a numeric literal, a numeric variable name with zero decimal positions, or a
numeric attribute identifier.
If the Factor 2 field designates a field name associated with either an alphanumeric or
mnemonic attribute, the Result Field must be an alphanumeric variable name or an
alphanumeric or mnemonic attribute identifier. If the Factor 2 field specifies a field name
associated with a numeric attribute, the Result Field must be a numeric variable name
with zero decimal positions or a numeric attribute identifier.
For an attribute identifier in the Result Field, if the value of Factor 2 is not defined for the
attribute field name or if the attribute field name is defined as read-only, the attribute is
not assigned a value.
Tables 16–4 through 16–6 show the results of the MOVE operation with Result Fields
that are larger, smaller, and equal in length to Factor 2.
Legend
Alpha Alphanumeric
K –2
Legend
Alpha Alphanumeric
K –2
L –3
M –4
Legend
Alpha Alphanumeric
K –2
M –4
The data are moved from the leftmost position of the Factor 2 field (columns 33–42) to
the leftmost position of the Result Field (columns 43–48). If an array is named but not
indexed, the MOVEA operation begins with the first element of the array. If the array is
indexed, the operation begins with the element referred to.
As the transfer of data continues, successive array elements are moved, modified, or
both, until the end of either the Factor 2 field or the Result Field is reached. This action
can cause the MOVEA operation to end in the middle of an array element. If the Result
Field is longer than the Factor 2 field, the remaining data are unchanged. Regardless of
the field lengths, Factor 2 is never changed.
• Either the Factor 2 field or the Result Field must contain an array name.
• Neither the Factor 2 field nor the Result Field can refer to a table name or table
element.
• The Result Field cannot contain a literal.
The following items can be moved by the MOVEA operation:
• For the Factor 2 field, the data transfer begins at the element indicated by the value
of the index.
• For the Result Field, the data reception begins at the element indicated by the value
of the index.
When the same array name is used in both the Factor 2 field and the Result Field, the
data transfer moves the original values of the array named in the Factor 2 field. The index
can be either a literal or a variable.
When a numeric Factor 2 field (source) or Result Field (destination) is used in a MOVEA
operation, the numeric value has a right f-zone format. A numeric value in right f-zone
format has the sign of the numeric value placed in the zone section of the rightmost
character, with 1111 (binary) representing a positive sign and 1101 (binary) a negative
sign. (For example, the numeric value +123 has the EBCDIC representation 123, and the
numeric value –123 has the EBCDIC representation 12L.)
Following is a list of results when a numeric Factor 2 field or Result Field is used for a
MOVEA operation:
The initial data values before the start of the program are the following:
Field Value
Table 16–7 shows the results of an execution of the program in the example.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...02
100F*
00300FFILEIN IP 80 80 DISK
00400FFILE1 IT 80 80 DISK
00500FFILE2 IT 80 80 DISK
00600FFILE3 IT 80 80 DISK
00650FFILE4 IT 80 80 DISK
00700FFILEOUT O 132 132 PRINTER
00800E FILE1 ARY1 1 3 3
00900E FILE2 ARY2 1 2 3 0
01000E FILE3 ARY3 1 4 2
01050E FILE4 ARY4 1 3 3 0
01100IFILEIN AA 01
01200I 5 12 FIELD1
01300C*
01400C* Alphanumeric field to alphanumeric array move no indexing
01500C*
01600C 01 MOVEAFIELD1 ARY1
01700C*
01800C* Alphanumeric array to alphanumeric field move array indexed
01900C*
02000C 01 MOVEAARY1,2 FIELD1
02100C*
02200C* Numeric array to alphanumeric array move no indexing
02300C*
02400C 01 MOVEAARY2 ARY1
02500C*
02600C* Alphanumeric array to alphanumeric array move --
02650C* Factor 2 indexed
02700C*
02800C 01 MOVEAARY3,4 ARY1
02900C*
03000C* Numeric array to alphanumeric array move Result Field indexed
03100C*
03200C 01 MOVEAARY2 ARY1,3
03300C*
03400C* Alphanumeric array to alphanumeric array move --
03450C* both arrays indexed
03500C*
03600C 01 MOVEAARY1,3 ARY3,4
03700C*
03800C* Alphanumeric literal to array move no indexing
03900C*
04000C 01 MOVEA'ABC' ARY2
04010C*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
04020C* Numeric array to numeric array move Factor 2 indexed
04030C*
04040C 01 MOVEAARY4,1 ARY2
04100OFILEOUT D 01
04200O FIELD1 B 10
04300O ARY1,1 B 15
04400O ARY1,2 B 20
04500O ARY1,3 B 25
04600O ARY2,1 B 30
04700O ARY2,2 B 35
04800O ARY3,1 B 40
04900O ARY3,2 B 45
05000O ARY3,3 B 50
05100O ARY3,4 B 55
05200O ARY4,1 B 60
05300O ARY4,2 B 65
05400O ARY4,3 B 70
Table 16–7 shows the contents of data items after the execution of a MOVEA operation.
The values for the field named in the Result Field are shown in the MOVEA result
column.
Legend
P –6
The sign is transferred only if the Result Field is one of the following:
If the Result Field designates a field name associated with an alphanumeric or mnemonic
attribute, Factor 2 must be one of the following:
• An alphanumeric literal
• An alphanumeric variable name
• An alphanumeric attribute identifier
• A mnemonic attribute identifier
If the Result Field specifies a field name associated with a numeric attribute, Factor 2
must be either a numeric literal, a numeric variable name with 0 (zero) decimal positions,
or a numeric attribute identifier.
If the Factor 2 field designates a field name associated with either an alphanumeric or
mnemonic attribute, the Result Field must be an alphanumeric variable name or an
alphanumeric or mnemonic attribute identifier. If the Factor 2 field specifies a field name
associated with a numeric attribute, the Result Field must be a numeric variable name
with 0 (zero) decimal positions, or a numeric attribute identifier.
For an attribute identifier in the Result Field, if the value of Factor 2 is not defined for the
attribute field name or if the attribute field name is defined as read-only, the attribute is
not assigned a value.
Table 16–8 provides examples of the MOVEL operation with the EBCDIC character code.
Legend
N Numeric
A Alphanumeric
An array name can be entered in the Factor 2 field if the Result Field also specifies an
array. In this case, the designated move zone operation is performed on each array
element designated in the Factor 2 field. The result is placed in the corresponding array
element designated in the Result Field. The operation ends when the end of the shorter
array is reached.
If the Result Field is an array but the Factor 2 field is not, the zone from the Factor 2 field
is moved into the appropriate position in all elements of the array.
If the Factor 2 field is alphanumeric and the Result Field is numeric, this operation moves
the high-order (leftmost) position of the Factor 2 field to the sign position of the Result
Field. Factor 2 must be alphanumeric.
If Factor 2 is numeric and the Result Field is alphanumeric, this operation moves the zone
from the sign position of the Factor 2 field to the high-order (leftmost) position of the
Result Field. The Result Field must be alphanumeric.
If Factor 2 is alphanumeric and the Result Field is numeric, this operation moves the zone
from the low-order (rightmost) position of the Factor 2 field to the sign position of the
Result Field.
If Factor 2 is numeric and the Result Field is alphanumeric, this operation moves the zone
from the sign position of the Factor 2 field to the low-order (rightmost) position of the
Result Field.
If both Factor 2 and the Result Field are numeric, this operation moves the zone from the
sign position of the Factor 2 field to the sign position of the Result Field.
If the variable is numeric, the low-order zone of a variable is defined as the algebraic sign.
A high-order zone must refer only to an alphanumeric field. Only the low-order zone can
be referred to when a numeric field is used.
The positive sign (binary 1100) is forced on all positive numeric fields that result from
move zone operations. When the zone of a positive numeric field is moved to that of an
alphanumeric field by a move zone operation, the sign byte of the Result Field
(columns 43–48) contains alphanumeric 0 through 9. When the zone of a negative
numeric field is moved to that of an alphanumeric field by a move zone operation, the
sign of the Result Field contains the negative sign (binary 1101).
The Factor 2 field (columns 33–42) can contain either of the following:
• A 1-byte, alphanumeric field name.
• A series of numeric entries enclosed in apostrophes ('), ranging from 0 through 7.
These numbers indicate which bits to use from the Factor 2 field with the specified
binary field operation. Bits are numbered from left to right in the Factor 2 field. For
example, '017' in the Factor 2 field represents bits 0, 1, and 7.
The Result Field (columns 43–48) can contain only a 1-byte, alphanumeric field.
The Control Level (columns 7–8) and Indicators (columns 9–17) fields can contain entries.
The rest of the Calculation Specifications line must be blank.
Example
Example 16–3 shows binary field operation coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100F*
00200FFILEIN IP 80 80 DISK
00300FFILEOUT O 132 132 PRINTER
00400I*
00500IFILEIN AA 01
00600I 10 10 FIELD2
00700I 15 15 FIELD3
00800I 20 20 FIELD4
00900I 25 25 FIELD5
01000C*
01100C BITON'
01234567'FIELD201200C BITOF'45670123'FIELD3
01300C TESTB'234' FIELD4 101020
01400C TESTB'4567' FIELD5 303040
01500O*
01600OFILEOUT D 01
01700O 10 30 35 'UNEQUAL CONDITION'
If only some of the bits that are on in the Factor 2 field are on in the Result Field, then
the indicator in columns 56 through 57 is turned on. In this case, it is the responsibility of
the programmer to ensure that at least two bits are on in the data supplied from the
Factor 2 field. If only one bit is on, the indicator in columns 56 through 57 is never turned
on.
If the bits that are on in the Factor 2 field are on in the Result Field, the indicator
specified in columns 58 through 59 is turned on.
The same indicator, or two or three different indicators, can be used for one TESTB
operation.
Indicator Operations
When an indicator operation is used, at least one indicator named in the Resulting
Indicators field (columns 54–59) turns on or off.
The Factor 1 field (columns 18–27), the Factor 2 field (columns 33–42), the Result Field
(columns 43–48), and the Half Adjust field (column 53) must be blank.
• The following indicators cannot be turned on or off: first page (1P), matching record
(MR), and overflow indicators not used in the File Specifications.
• A control level indicator (L1–L9) turned on or off does not affect any other control
level indicator.
• All control level and record identifying indicators except L0 are automatically turned
off after the program completes detail output operations regardless of any previous
indicator operation.
• Halt indicators that are on at the conclusion of detail output cause the program to
halt.
• The program goes to EOJ after it completes total output operations if the SETON
operation turned on the LR indicator during either detail or total calculations.
The operations discussed in the following paragraphs explicitly affect the setting of
indicators.
Branching can be either forward or backward and can occur within subroutines.
Branching is allowed between total and detail calculations. Also, a branch can be
performed from a subroutine to a label in detail or total calculations.
The Factor 2 field (columns 33–42) must contain a label that follows the rules for forming
labels described in Section 2, “RPG Language Elements.” This label is entered
elsewhere in the Calculation Specifications with the TAG operation. columns 18 through
27 and 39 through 59 must be blank.
Example
Example 16–4 shows how the subroutine GOEXIT executes a GOTO operation to the tag
EXIT in detail calculations.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C*
00200C EXSR GOEXIT
00300C EXIT TAG
00400CSR GOEXIT BEGSR
00500CSR GOTO EXIT
00600CSR ENDSR
The Factor 1 field (columns 18–27) must contain a unique label (tag) that follows the rules
for forming labels described in Section 2, “RPG Language Elements.”
Conditioning by a control level indicator (columns 7–8) is allowed if the TAG operation is
part of total calculations. columns 9 through 17, 24 through 27, and 33 through 59 must
be blank.
Operations are listed in the Table 16–10. The xx specifies the particular Boolean condition
to be met. A discussion of Boolean operators follows the table.
Boolean Operators
Boolean operators are used with the structured programming operations ANDxx, CASxx,
DOUxx, DOWxx, IFxx, and ORxx to compare a value in the Factor 1 field to a value in the
Factor 2 field.
The ANDxx and ORxx operations do not cause additional levels of nesting. When
determining the nesting level of a structured construct, do not include the ANDxx and
ORxx operations.
Figure 16–1 illustrates the way structured programming operations can be nested.
The condition specified by the structured programming operation preceding the ANDxx
operation determines whether the ANDxx condition is evaluated or another action is
taken. Table 16–12 summarizes the actions taken when the condition of the preceding
operation has been determined.
Field definitions for the ANDxx structured programming operation are as follows:
If the loop is initiated, the operations within the loop are executed. If indicator 11 is on at
the END operation, FAC1A is compared to FAC2A and the following occurs:
If the loop is initiated, FAC1C is compared to FAC2C and the following occurs:
• If FAC1C is less than FAC2C, then FAC1D is compared to FAC2D. If FAC1D is less
than FAC2D, the operations within the loop are executed. If indicator 21 is on, the
comparison with the DOWxx operation is made again; otherwise, the program
continues at the operation following the END operation (at sequence line number
10170).
• If FAC1C is greater than or equal to FAC2C, the comparison between FAC1D and
FAC2D is skipped, the loop ends, and the program continues at the operation
following the END operation.
Indicator 30 is tested to determine if the IFxx structured programming operation should
be started. If indicator 30 is off, the IFxx structured programming operation is not
entered, and the program branches to the operation following the END operation (at
sequence line number 10250).
If the operation is initiated, FAC1E is compared to FAC2E and the following occurs:
If the operation is initiated, FAC1G is compared to FAC2G and the following occurs:
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...10
010C 10 FAC1A DOULEFAC2A
10020C FAC1B ANDLEFAC2B
10030C FAC1A SUB 1 FAC1A
10040C FAC1B SUB 1 FAC1B
10050C* .
10060C* .
10070C 11 END
10080C*
10090C 20 FAC1C DOWLTFAC2C
10100C FAC1D ANDLTFAC2D
10110C FAC1C ADD 1 FAC1C
10120C FAC1D ADD 1 FAC1D
10130C* .
10140C* .
10150C 21 END
10160C*
10170C 30 FAC1E IFEQ FAC2E
10180C FAC1F ANDEQFAC2F
10190C FAC1E SUB 1 FAC1E
10200C FAC1F ADD 1 FAC1F
10210C* .
10220C* .
10230C END
10240C*
10250C 40 FAC1G IFGT FAC2G
10260C FAC1H ANDGTFAC2H
10270C SETON 01
10280C* .
10290C* .
10300C ELSE
10310C SETON 02
10320C END
10330C* .
Several CASxx operations can be grouped together with one END operation, or with one
CAS operation and one END operation. The Indicators field (columns 9–17) can be used
to condition the CASxx operations, but must be blank for the END operation. If a
condition associated with the indicator is not met, control passes to the next operation,
not to the operation following the END operation.
The Resulting Indicators field (columns 54–59) can be specified to indicate the
relationship between Factor 1 and Factor 2. This function is similar to that of the COMP
operation. If resulting indicators are specified, the relationship between Factor 1 and
Factor 2 is tested, and the appropriate indicators are turned on accordingly.
When the CASxx structured programming operation is invoked, the Factor 1 and Factor 2
fields are compared to determine if the condition specified by xx has been met, and
resulting indicators are set to indicate the result of the comparison. If the condition is not
met, the next executable calculation (a CASxx operation, a CAS operation, or the
operation following the END operation) is performed. If the condition has been met, the
subroutine specified in the Result Field is called. When the subroutine is completed, the
CASxx or CAS structured programming operation is ended, and the program passes
control to the operation following the END operation.
All CASxx operations should be placed before the CAS operation so that they can be
evaluated first. This arrangement is necessary because the CAS structured programming
operation executes a subroutine unconditionally; once a subroutine is called, the CASxx
structured programming operation ends.
The CAS and CASxx structured programming operations can be nested within DO,
DOUxx, DOWxx, CASE, and IFxx structured programming operations.
The CAS structured programming operation, which does not use the Factor 1 and Factor
2 fields, has a function that is similar to the EXSR operation. Additional information on the
EXSR operation is provided in this section.
The CASxx and CAS structured programming operations cannot be used within
subroutines or exception routines.
Field definitions for the CASxx and CAS operations are the following:
• The Factor 1 field (columns 18–27) must be blank when the CAS structured
programming operation is used.
When the CASxx structured programming operation is used, columns 18 through 27
must contain one of the following: a numeric or alphanumeric literal; a field name or
vector element of type numeric, alphanumeric, COMS designator, or COMS-time.
COMS designators, however, can be compared using only the EQ and NE Boolean
operators. Factor 1 must be the same type as Factor 2.
• The Operation field (columns 28–32) must contain the CAS or CASxx operation,
where xx represents a condition to be tested. Valid entries are CAS, CASEQ, CASNE,
CASLT, CASLE, CASGT, and CASGE. Boolean operators EQ, NE, LT, LE, GT, and GE
are described in Table 16–11.
• The Factor 2 field (columns 33–42) must be blank when the CAS structured
programming operation is used.
When the CASxx structured programming operation is used, these columns must
contain one of the following: a numeric or alphanumeric literal; a field name or vector
element of type numeric, alphanumeric, COMS designator, or COMS-time. COMS
designators, however, can be compared using only the EQ and NE Boolean
operators. Factor 2 must have the same type as Factor 1 has.
• The Result Field (columns 43–48) must contain the name of the subroutine to be
called.
• Entries in the Resulting Indicators field (columns 54–59) are optional.
Example
Example 16–6 compares two values (FAC1 and FAC2) to determine which subroutine
should be called. Indicator 10 is tested to determine whether if the CASxx structured
programming operation should be started. If indicator 10 is off, the CASxx structured
programming operation on that line is not executed, and the program branches to the
next operation (the CASLT operation on line 10020).
As each CASxx condition is tested, the first one that is met assigns an appropriate value
to a resulting indicator, calls a subroutine, and ends the CASxx structured programming
operation. If no CASxx condition is met, the unconditional CAS operation calls SUBR4.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 CASGT0 SUBR1 223344
10020C FAC1 CASLTFAC2 SUBR2 223344
10030C FAC1 CASEQFAC2 SUBR3 223344
10040C CAS SUBR4
10050C END
10060C
• CASE operation. This operation indicates the start of the CASE structured
programming operation.
• CASE selection variable. Specified in Factor 2 of the CASE operation, this variable is
compared to each CASE label to determine the set of operations to execute.
• CASE labels. These labels are numeric or alphanumeric constants to which the
selection variable is compared. When the selection variable is equal to a certain label
or falls within a specified CASE label range, the set of operations at that label is
executed. Once a match occurs, the rest of the labels are ignored and control passes
to the operation immediately following the END operation.
• END operation. This operation indicates the end of the CASE structured
programming operation.
The CASE structured programming operation might begin by testing a conditioning
indicator to determine if the CASE structured programming operation should be started.
If not, processing continues at the operation following the END operation. The Indicators
field (columns 9–17) on the CASE labels and END operations must be blank. Control level
indicators can be used on the lines containing the CASE and *ELSE labels and the END
operation, but these indicators are not evaluated.
CASE labels can specify complex selection criteria by defining a range of values or a
choice between two or more alternatives. A range can be specified with the use of THRU
in the Operation field of the CASE label operation. CASE labels must be in pairs and in
ascending order when a CASE range is specified; for example, acceptable CASE labels
are AA THRU CC, and 55 THRU 99. A range must not overlap another range nor include a
value that has already been declared by an individual CASE label. Duplicate labels are also
disallowed.
A choice between two or more CASE labels can be made by using OR in the Operation
field of the CASE label operation. The programming example in this section contains the
use of OR in a CASE label. The OR and THRU operations can be combined to create a
more complex CASE label.
If none of the CASE labels match a CASE selection variable. Consequently, an *ELSE
label can be used. *ELSE can be used anyplace in the CASE group; however, logically,
the best position for the *ELSE label and its related set of operations is immediately
before the END operation, after an attempt has been made to match all CASE labels.
Although a program compiles and executes without the *ELSE label, it should always be
specified. If the *ELSE label is not present and none of the CASE labels match, then an
error message is displayed.
After the set of operations at a CASE label has been executed, control is then passed to
the operation immediately following the associated END operation. The CASE structured
programming operation can be exited by using a GOTO operation out of the set of
operations at a CASE label. A GOTO to a tag within another set of operations is not
prohibited, but it is not recommended.
Any RPG operation can be specified in CASE labels, including other CASE structured
programming operations. Nesting cannot exceed 100 levels. As with other nested
operations, CASE structured programming operations must be wholly contained within
detail or total calculations, subroutines, and DMSII exception routines.
• The Factor 1 field (columns 18–27) must contain a numeric or alphanumeric literal, or
a figurative constant. The type and scale factor must be the same as the type and
scale factor of Factor 2 of the CASE operation. The type and scale factor must also
be consistent with all the labels in this CASE structured programming operation.
If *ELSE is used, it appears within this field.
• The Operation field (columns 28–32) contains a colon (:) to designate the end of a
CASE label. The operation THRU specifies a label range. The OR operation permits
alternative CASE labels to be used.
• Columns 33 through 59 must be blank.
Example
Example 16–7 shows the use of the CASE structured programming operation to obtain
marketing and advertising information for a large hotel. The information sought is the
state of origin for previous guests.
The selection variable STATE is alphanumeric. Presumably, before the start of this CASE
structured programming operation, some alphanumeric value was transferred to STATE
either by the MOVE operation or in the Input Specifications.
The THRU operation on line 600 specifies a range. The value of the alphanumeric
constant CA is less than the value of FL, illustrating that label ranges are always specified
in pairs, with the lower value specified first.
The operators THRU and OR can be combined to create more complex CASE label
specifications. An example of the use of OR appears on lines 1200 and 1300.
Line 1700 provides an example when nothing is done at a particular CASE label. If STATE
equals WY, the test for that label is satisfied; however, control immediately passes to the
operation following the END operation.
If the value of STATE does not match any of the CASE labels, the *ELSE label at line
1800 and its related operations are executed. As is the case when any of the CASE
labels are satisfied, the operations specified below the *ELSE label are performed, and
control then passes to the operations following the END operation on line 2200.
The RPG compiler invokes the searching algorithm most efficient for each CASE
structured programming operation. Many factors are considered in determining the
algorithm, including the number of labels and the size and complexity of the operations
between the labels. As a result, the average execution speed for any CASE structured
programming operation is faster than it is if a linear search is used.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C CASE STATE
00200C 'MD' :
00300C*
00400C* Operations for Maryland
00500C*
00600C 'CA' THRU
00700C 'FL' :
00800C*
00900C* Operations for states that are alphabetically
01000C* between California and Florida.
01100C*
01200C 'NJ' OR
01300C 'NY' :
01400C*
01500C* Operations that process New York or New Jersey
01600C*
01700C 'WY' :
01800C *ELSE :
01900C*
02000C* Operations following *ELSE
02100C*
02200C END
Each DO, DOUxx, and DOWxx structured programming operation must have a matching
END operation.
The DOUxx and DOWxx structured programming operations can be used with the
ANDxx and ORxx structured programming operations to form complex conditions.
Discussions of the ANDxx and ORxx structured programming operations are provided in
this section. The DO, DOUxx, and DOWxx structured programming operations are
further described under separate headings.
DO (Do)
Additional information on the DO structured programming operation is provided in the
previous discussion of DO, DOUxx, and DOWxx structured programming operations.
The increment value is a constant added to the index value during each loop cycle. The
index value then becomes the new starting value for the next loop. For the first iteration,
the current index contains the starting value. If the Result Field is blank, the compiler
generates an internal index that is not accessible by the user.
• The Factor 1 field (columns 18–27) can be blank or can contain a starting value. The
starting value must be a numeric literal or a numeric field name or vector element
with no decimal positions. Factor 1 must have the same type as Factor 2 has. The
value used can be positive, zero, or negative. The default value is 1.
• The Operation field (columns 28–32) must contain the operation DO.
• The Factor 2 field (columns 33–42) can be blank or can contain a limit value. The limit
value must be a numeric literal or a numeric field name or vector element with no
decimal positions. Factor 2 must have the same type as Factor 1 has.
The limit value can be positive, zero or negative. The default value is 1.
• The Result Field (columns 43–48) can be blank or can contain a numeric field or
vector element to be used as the current index value. If the columns are blank, the
compiler generates a field that is used as an index value. The compiler-generated
index is not accessible by the user; however, if the current index value is specified by
the user, that value can be altered within the DO loop to affect the control flow.
• Factor 2 of the END operation (columns 33–42) can be blank or can contain an
increment value. The increment value must be a numeric literal or a numeric field
name or vector element with zero decimal positions.
The increment value can be positive, zero, or negative. Extreme care is needed when
using zero or a negative number to avoid an infinite loop. The default value is 1.
Example 1
Example 16–8 shows the use of a DO structured programming operation to perform a
group of operations 10 times. Indicator 98 is tested to determine if the DO structured
programming operation should be started. If the DO structured programming operation is
initiated, the index value, INDX, is tested. If INDX is less than or equal to 10, the group of
operations between the DO and END operations is performed.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10020C 98 DO 10 INDX
10030C* .
10040C* .
10050C END
10060C* .
Example 2
Example 16–9 shows how to use a DO structured programming operation to perform a
group of calculations six times with specified starting and increment values. The DO
structured programming operation is performed in the same way as that shown in the
preceding example. There are, however, two differences. The starting value is 0 and the
increment value is 2. When the DO structured programming operation is initiated, INDX
is given the starting value, which is 0. Thereafter, each time the DO structured
programming operation is performed, the index value increases by 2.
During the DO structured programming operation in this example, INDX receives six
values before the loop ends:0, 2, 4, 6, 8, and 10. Then the loop ends, and control of the
program passes to the operation following the END operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10020C 98 0 DO 10 INDX
10030C* .
10040C* .
10050C END 2
10060C* .
Following are field definitions for the DOUxx structured programming operation:
• The Factor 1 field (columns 18–27) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operators. For more information
about COMS, see Volume 2 of this manual. Factor 1 must be the same type as
Factor 2.
• The Operation field (columns 28–32) must contain the operation DOUxx, where xx
specifies a condition that is tested. Valid entries are DOUEQ, DOUNE, DOULT,
DOULE, DOUGT, and DOUGE. The Boolean operators EQ, NE, LT, LE, GT, and GE
are described in Table 16–11.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Booleans. Factor 2 must be the same type
as Factor 1.
• The Result Field (columns 43–48) must be blank.
Additional information on the DOUxx operation is provided in the discussion of the DO,
DOUxx, and DOWxx structured programming operations earlier in this section.
Example
Example 16–10 performs DOUxx operations until Factor 1 and Factor 2 are equal.
Indicator 10 is tested to determine if the DOUxx structured programming operation
should be started. If indicator 10 is off, the DOUxx structured programming operation is
not executed, and the program branches to the operation immediately following the END
operation.
If the loop is initiated, the operations within the loop are executed. If indicator 20 is on at
the END operation, FAC1 is compared to FAC2. If indicator 20 is not on, the program
branches to the operation after the END operation. If FAC1 is not equal to FAC2, the loop
is repeated until FAC1 equals FAC2 or indicator 20 is turned off. Then the loop ends, and
control of the program passes to the operation following the END operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 DOUEQFAC2
10020C FAC1 SUB 1 FAC1
10030C* .
10040C* .
10050C 20 END
10060C* .
Discussions of the use of the DOWxx structured programming operation with ANDxx
and ORxx operations to form compound conditional expressions are provided earlier in
this section.
Field definitions for the DOWxx structured programming operation are described in the
following list:
• The Factor 1 field (columns 18–27) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operations. Factor 1 must be the
same type as Factor 2.
• The Operation field (columns 28–32) must contain the operation DOWxx, where xx
specifies the condition that is tested. Valid entries are DOWEQ, DOWNE, DOWLT,
DOWLE, DOWGT, and DOWGE. Boolean operations EQ, NE, LT, LE, GT, and GE are
described in Table 16–11.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared, using the EQ and NE Boolean operations only. Factor 2 must be the
same type as Factor 1.
• The Result Field (columns 43–48) must be blank.
Additional information about the DOWxx operation is provided in the discussion of the
DO, DOUxx, and DOWxx structured programming operations.
Example
Example 16–11 performs DOWxx operations until Factor 1 is greater than or equal to
Factor 2. Indicator 10 is tested to determine if the DOWxx structured programming
operation should be initiated. If indicator 10 is off, the DOWxx structured programming
operation is not executed, and the program branches to the operation immediately
following the END operation.
If indicator 10 is on, FAC1 is compared to FAC2. If FAC1 is less than FAC2, the
operations within the loop are executed: 5.25 is added to the value in Factor 1 and the
total is moved into the Result Field, calculations that are unrelated to the ADD operation
are performed, and the DOWLT operation is repeated.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 DOWLTFAC2
10020C FAC1 ADD 5.25 FAC1
10030C* .
10040C* .
10050C 20 END
10060C* .
When the IFxx structured programming operation is invoked, Factor 1 and Factor 2 are
compared to determine if the condition specified by xx has been met. If so, a group of
operations is executed. If not, the next operation after the matching END operation is
performed. If an ANDxx or ORxx operation follows the IFxx operation, the condition for
either of those operations is checked immediately after Factor 1 and Factor 2 of the IFxx
operation are checked. Discussions of the use of the IFxx structured programming
operation with the ANDxx and ORxx operations to form compound conditional
expressions are provided in this section.
The IFxx operation can also be used with the ELSE operation. A discussion of that topic
is provided under the next heading.
Field definitions for the IFxx structured programming operation are described in the
following list:
• The Factor 1 field (columns 18–27)must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operations. Factor 1 must be the
same type as Factor 2.
• The Operation field (columns 28–32) must contain the operation IFxx, where xx
specifies a condition that is tested. Valid entries are IFEQ, IFNE, IFLT, IFLE, IFGT,
and IFGE. Boolean operators EQ, NE, LT, LE, GT, and GE are described in Table 16–
11 earlier in this section.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operations. Factor 1 must be the
same type as Factor 2.
• The Result Field (columns 43–48) must be blank.
Example
Example 16–12 performs the group of operations between the IFEQ and the END
operations if Factor 1 equals Factor 2. Indicator 10 is tested to determine if the IFxx
structured programming operation should be initiated. If indicator 10 is off, the IFxx
structured programming operation is not entered, and the program branches to the
operation immediately following the END operation.
If the IFxx operation is started, FAC1 is compared to FAC2. If FAC1 equals FAC2, a group
of operations is performed. If FAC1 is not equal to FAC2, the program branches to the
operation following the END operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 IFEQ FAC2
10020C* .
10030C* .
10040C END
10050C* .
Additional information about the IFxx structured programming operation is provided in the
discussion of that topic under the preceding heading. Discussions of the use of IFxx
structured programming operation with the ANDxx and ORxx operations to form
compound conditional expressions are provided in this section.
Field definitions for the ELSE operation are described in the following list:
Example
Example 16–13 performs the IFxx structured programming operation with the ELSE
operation. Indicator 10 is tested to determine if the IFxx structured programming
operation should be started. If indicator 10 is off, the IFxx structured programming
operation is not entered, and the program branches to the operation immediately
following the END operation.
If FAC1 does not equal FAC2, control passes to the ELSE operation. The group of
operations between the ELSE and END operations is executed. Control then passes to
the operation after the END operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 IFEQ FAC2
10020C* .
10030C* .
10040C ELSE
10050C* .
10060C* .
10070C END
10080C* .
The condition specified by the structured programming operation preceding the ORxx
operation determines whether the ORxx condition is evaluated or another action is taken.
Table 16–13 summarizes the actions taken when the condition of the preceding
operation has been determined.
Field definitions for the ORxx structured programming operation are as follows:
Example
Example 16–14 shows the ORxx operation used with the DOUxx, DOWxx, IFxx, and
IFxx/ELSE structured programming operations.
If the loop is initiated, the operations within the loop are executed. If indicator 11 is on at
the END operation, FAC1A is compared to FAC2A and the following occurs:
• If FAC1A is less than or equal to FAC2A, then the comparison between FAC1B and
FAC2B is skipped, and control of the program passes to the operation following the
END operation.
• If FAC1A is greater than FAC2A, then FAC1B and FAC2B are compared. If FAC1B is
greater than FAC2B, the loop is repeated until one of the following occurs:
− FAC1A is less than or equal to FAC2A.
− FAC1B is less than or equal to FAC2B.
− Indicator 11 is turned off.
If indicator 11 is off at the END operation, the loop is exited and processing resumes at
the operation following the END operation (at sequence line number 10090).
If the loop is initiated, FAC1C is compared to FAC2C and the following occurs:
• If FAC1C is less than FAC2C, the comparison between FAC1D and FAC2D is
skipped, and the operations within the loop are executed. If indicator 21 is on, the
comparison with the DOWxx operation is made again; otherwise, the program
continues at the operation following the END operation (at sequence line number
10170).
• If FAC1C is greater than or equal to FAC2C, then FAC1D and FAC2D are compared. If
FAC1D is less than FAC2D, the operations within the loop are executed. If indicator
21 is on, the comparison is made again; otherwise, the program continues at the
operation following the END operation.
Indicator 30 is tested to determine if the IFxx structured programming operation should
be started. If indicator 30 is off, the IFxx structured programming operation is not
entered, and the program branches to the operation following the END operation (at
sequence line number 10250).
If the operation is initiated, FAC1E is compared to FAC2E and the following occurs:
If the operation is initiated, FAC1G is compared to FAC2G and the following occurs:
• If FAC1G is greater than FAC2G, the comparison between FAC1H and FAC2H is
skipped, and the group of operations between the ORGT and ELSE operations is
executed. Control then passes to the operation following the END operation (after
sequence line 10330).
• If FAC1G is less than or equal to FAC2G, then FAC1H is compared to FAC2H. If
FAC1H is greater than FAC2H, the group of operations between the ORGT and ELSE
operations is executed, and control passes to the operation following the END
operation (after sequence line 10330). If FAC1H is less than or equal to FAC2H, the
group of operations between the ELSE and END operations is executed, and control
passes to the operation following the END operation (after sequence line 10330).
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1A DOULEFAC2A
10020C FAC1B ORLE FAC2B
10030C FAC1A SUB 1 FAC1A
10040C FAC1B SUB 1 FAC1B
10050C* .
10060C* .
10070C 11 END
10080C*
10090C 20 FAC1C DOWLTFAC2C
10100C FAC1D ORLT FAC2D
10110C FAC1C ADD 1 FAC1C
10120C FAC1D ADD 1 FAC1D
10130C* .
10140C* .
10150C 21 END
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10160C*
10170C 30 FAC1E IFEQ FAC2E
10180C FAC1F OREQ FAC2F
10190C FAC1E SUB 1 FAC1E
10200C FAC1F ADD 1 FAC1F
10210C* .
10220C* .
10230C END
10240C*
10250C 40 FAC1G IFGT FAC2G
10260C FAC1H ORGT FAC2H
10270C SETON 01
10280C* .
10290C* .
10300C ELSE
10310C SETON 02
10320C END
10330C* .
Subroutine Operations
Subroutine operation codes delimit the beginning and end of a subroutine, or call a
subroutine for execution.
Specification lines within a subroutine must contain SR, OR, AN, or blank in the Control
Level field (columns 7–8). Subroutines are specified after all detail and total Calculation
Specifications. Subroutine operations cannot be nested in a subroutine, and a subroutine
cannot call itself. Subroutine operation codes are discussed in the following paragraphs.
Example
Example 16–15 shows subroutine operation coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10160C*
10170C 30 FAC1E IFEQ FAC2E
10180C FAC1F OREQ FAC2F
10190C FAC1E SUB 1 FAC1E
10200C FAC1F ADD 1 FAC1F
10210C* .
10220C* .
10230C END
10240C*
10250C 40 FAC1G IFGT FAC2G
10260C FAC1H ORGT FAC2H
10270C SETON 01
10280C* .
10290C* .
10300C ELSE
10310C SETON 02
10320C END
10330C* .
01000I 65 670EMPLNOL1
01100C*
01200C 01 EMPLNO COMP '000000' 102020
01300C 01 EMPLNO COMP '999999' 201010
01400CL1 10 EXSR SUB1
01500CSR SUB1 BEGSR0
1600CSR HRSWK ADD TOTHRS TOTHRS 102
01700CSR HRSWK MULT RATE PAY 152
01800CSR PAY ADD TOTPAY TOTPAY 122
01900CSR EXSR SUB2
02000CSR MOVE EMPLNO EMPLID 100
02100CSR ENDSR
02200CSR SUB2 BEGSR
02300CSR TOTHRS SUB 40.00 OVTHR 102
02400CSR RATE MULT 1.5 OVTRT 102
02500CSR OVTRT MULT OVTHR OVTPAY 152
02600CSR ENDSR
02700O*
02800OFILEOUT D 01
02900O NAME 15
03000O ADDR 30
03100O EMPLID 45
03200O TOTHRS 55
03300O TOTPAY 70
03400O OVTHR 80
03500O OVTPAY 95
The Factor 1 field (columns 18–27) contains the name of the subroutine, which must
follow the rules for forming labels as described in Section 2, “RPG Language Elements.”
Columns 9 through 17 and 33 through 59 must be blank.
The Factor 1 field (columns 18–27) can contain a label. This label is used, like a tag, as a
point to which a GOTO operation branches within the subroutine, thereby allowing exits
from different points within the subroutine. Columns 9 through 17 and 33 through 59
must be blank.
After the subroutine is executed, the instruction following the EXSR operation is
executed. EXSR can appear anywhere in the Calculation Specifications.
Indicators can condition the EXSR operation, allowing the subroutine to be called only
when certain conditions are satisfied. The Factor 2 field contains the name of the
subroutine being called, which must be the same name as that entered in the Factor 1
field (columns 18–27) of a BEGSR operation. The Factor 1 field and columns 43 through
59 must be blank.
One subroutine cannot contain another subroutine; however, an EXSR operation can be
contained within a subroutine.
Library Operations
The EEXSR and PARAM operations enable a program to call an external subroutine. An
external subroutine can be either a system software procedure known to the compiler or
a library procedure defined on the Library Subroutine Specifications.
Columns 43–59 must be blank if the external subroutine is not a function (that is, if it is
not a typed procedure).
• The type of the field named in the Result Field must match the type of the
procedure, as defined in Table 16–14 later in this section. Information about field
types is provided in the discussion of the PARAM operation in this section. The
Result Field cannot be alphanumeric.
• When a COMS-time or designator type is named as the Result Field, the Resulting
Indicators and Half Adjust fields must be blank. (Refer to Volume 2 for additional
information.)
If the result specified for the EEXSR operation does not have the same length or decimal
positions as specified on the Library Subroutine Specifications, the result is moved
according to the rules for the Z-ADD operation described earlier in this section.
If the subroutine returns a result and columns 43–59 are blank, the result is ignored.
The parameters must be listed in either the order specified in the external system
procedure or the order specified in the Library Subroutine Specifications for the library
subroutine.
The PARAM operation in columns 28–32 requires an entry in either the Factor 2 field
(columns 33–42) or the Result Field (columns 43–48), but not both.
Table 16–14 shows corresponding type matches between RPG and ALGOL. See the
discussion of the Vector Parameters field (column 34) in Section 13, “Library
Specifications,” for additional information on arrays. Designator and COMS-time types
are discussed in Volume 2 of this manual.
File File
Numeric literal Integer
Numeric field (length less than 12)
Numeric vector element (length less than 12)
Numeric field (length more than 11) Double integer
Numeric vector element (length more than 11)
COMS-time field Real
COMS-time vector element
Designator
Designator vector element
Alphanumeric literal EBCDIC array or pointer
Alphanumeric field
Alphanumeric vector element
Unindexed alphanumeric vector
Unindexed numeric vector (item length less than 12) Integer array
Unindexed numeric vector (item length greater than 11) Double integer array
Unindexed COMS-time vector Real array
Unindexed designator vector
Note: If an input file is passed to a library subroutine and the library reads a record or
changes the logical state of the file, unpredictable errors such as duplicated records,
missing records, or misidentified matching records might occur. It is suggested that only
an output file or a demand file be passed.
When a numeric field is passed by reference, the field length and decimal positions must
match those specified on the Library Parameter Specifications. When a numeric field or
literal is passed by value, the value is scaled to match the Library Parameter
Specifications.
When an alphanumeric field is passed by reference and a length is specified, the field
length of the actual parameter must match the length in the Library Parameter
Specifications.
Example
Example 16–16 shows the PARAM operation used in conjunction with the EEXSR
operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100L*
00200LIBRARY NAME DATELIB T *SYSTEM/DATE/LIBRARY
00300L*
00400L* Library of date manipulation routine
00500L*
00600LIBRARY SUBR DATEDIF 50 DATE_DIFFERENCE
00700L*
00800L* Returns the number of days between two Gregorian dates
00900L*
01000LIBRARY PARAM<begin> 60V
01100LIBRARY PARAM<end> 60V
01200L*
01300L*
01400LIBRARY SUBR DATELIT DATE_LITERAL
01500L*
01600L* Turns Gregorian date into "MMMMMMMMM DD, YYYY"
01700L*
01800LIBRARY PARAMGREGORIAN 60V
01900LIBRARY PARAM LITDATE 18 *
02000C*
02100C 10 EEXSRDATEDIF DAYS 50 202122
02200C PARAMFMDATE
02300C PARAMTODATE
02350C*
02400C* Additional Calculation Specifications coding
02450C*
02500C 10 EEXSRDATELIT
02600C PARAMFMDATE
02700C PARAM FMDLIT 1802750C*
02800C* Additional Calculation Specifications coding
02850C*
02900C 10 EEXSRDATELIT
03000C PARAMTODATE
03100C PARAM TODLIT 18
04000O*
04100OPRINTOUTD 1 10
04200O 4 'FROM'
04300O FMDLIT 23
04400O 26 'TO'
04500O TODLIT 45
04600O 48 'IS'
04700O 20 DAYS Z 54
04800O 20 59 'DAYS'
04900O 21 58 'BACKWARDS'
05000O 22 56 'NOTHING'
I/O Operations
Within the normal PLC, a record is read, calculations are performed (using the data from
the input record just read), and an output record is written. The CHAIN, DELET, DSPLY,
EXCPT, READ, RECV, SEND, READE, and READP operation codes enable greater control
over I/O by providing the capability to read and write records at times other than those
normally available as part of the RPG program cycle. The CLOSE operation code ends
processing of a file. The FORCE and SETLL operation codes permit some programmatic
control over the selection of records for processing. These operations are described in
the following paragraphs.
• The Factor 1 field (columns 18–27) must contain a relative record number or a key
field that is used to select the desired record.
• The Factor 2 field (columns 33–42) must contain the name of the disk file.
When the CHAIN operation is used with an indexed file and the length of Factor 1 is less
than the length of the key, the system pads Factor 1 with zeros or blanks. This padding
can cause found conditions to occur unexpectedly.
When the CHAIN operation is used with an alternate index file that has a noncontiguous
key, the entire key must be specified in Factor 1. It is recommended that a data structure
be used to specify the key. Refer to Section 4, “Disk Files,” for more information.
When the CHAIN operation is specified, the following fields must be blank:
When the CHAIN operation is specified, optional entries are allowed in the following
fields:
The CHAIN operation can be performed on an output file when a direct file is created.
Additional information on processing disk files and using the CHAIN operation is provided
in Section 4, “Disk Files.”
Indexed Files
When an indexed file is processed with the CHAIN operation, the value of the data
specified in the Factor 1 field is compared against the index to locate the data record for
which the key field contains the same value as does Factor 1. Record identifying
indicators and field indicators are assigned appropriate values.
If the key field of the data record available for processing does not equal the key value
specified in the Factor 1 field, a RECORD KEY MISMATCH error message is displayed. If
an equal condition is not found, the high indicator (columns 54–55) is turned on. If no high
resulting indicator is specified, a KEY NOT FOUND error message occurs. Refer to the
list of error messages in Appendix A, “System Messages,” for more information.
If the indexed or alternate index file named in the Factor 2 field was defined in the File
Specifications with the letter P, N, or J in the Record-Address Type field (column 31),
then Factor 1 must be numeric. If the file was described by an A or a K in the Record-
Address Type field, then Factor 1 can be either alphanumeric or numeric. Even if Factor 1
is numeric, the comparison is done in alphanumeric mode.
Signs are never ignored. Conversion of a numeric field to an alphanumeric key causes
the sign to be stored by default in the leftmost zone of the key. Refer to Section 21,
“Control of the Compilation Process,” for information about using the $RSIGN compiler
control option to change the default location where the sign is stored. Positive and
negative signs are represented by F (hex) and D (hex), respectively.
Example
Example 16–17 shows coding for chained indexed files.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FINPUT IPE 80 80 DISK
00400FINDEXED IC 80 80 4AI 5 DISK
00700FFILEOUT O 132 132 PRINTER
01100IINPUT AA 01
01200I 1 50INXKEY
01300IINDEXED BB 02
01400I 5 90IKEY
01500I 15 240FIELD1
01600C INXKEY CHAININDEXED 99
01900OFILEOUT D 01 02
02000O FIELD1 20
If the key (numeric integer) is within the bounds of the file, the record is found. If the key
is beyond the bounds of the file, the high resulting indicator specified in columns 54
through 55 is turned on; if no such indicator is specified, a KEY NOT FOUND error
message is displayed and the record area and current record pointer are unchanged.
Refer to Appendix A, “System Messages,” for more information.
Example
Example 16–18 provides an example of using the CHAIN operation with sequential files.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FINPUT IPE 80 80 DISK
00400FSEQ IC 80 80 DISK
00500FFILEOUT O 132 132 PRINTER
00600IINPUT AA 01
00700I 1 50RCDNUM
00800ISEQ BB 02
00900I 5 90DKEY
01000I 15 240FIELD1
01100C RCDNUM CHAINSEQ
01200OFILEOUT D 02
01300O FIELD1 20
The Factor 1 field (columns 18–27) must be blank. The Factor 2 field requires a file name,
and the Result Field (columns 43–48) can be blank or can contain a CLOSE option value.
The Result Field can contain one of the following CLOSE option values:
CLOSE Description
Option
CRUNCH Used for disk files only. The option returns the unused portion of the
last row of disk space (beyond the end of file indicator) to the system.
The file cannot be expanded but can be written inside the end of file
limit.
NOWAIT Used for files in which the Device field (columns 40–46) of the File
Specifications contains the entry PORT. For additional information
about the PORT entry, refer to the File Attributes Reference Manual.
Used on tape files or disk files.
LOCK This option rewinds tape files. The system displays a message as a
reminder that the reel must be saved. The tape unit remains locked
until it is readied manually.
The LOCK option retains a disk file as a permanent file on disk, and the
program returns the buffer storage to the system.
continued
CLOSE Description
Option
PURGE Removes the file name from the directory, and the program returns the
space occupied by the file to the system.
REEL Used for multireel tape files, primarily direct tape files, for which the
system does not automatically perform reel switching. After the current
reel is closed, the next reel is opened.
REWIND Used on tape files or disk files.
When a tape file is used, the file is rewound.
The REWIND option resets the record pointer of a disk file to the first
record of the file. The buffer storage is returned to the system. The I/O
unit remains under program control.
NORWND Used with tape files. It prevents the tape from rewinding during the
CLOSE operation.
When no CLOSE option is specified, the CLOSE operation closes the file according to the
type of file.
Following is a list of file types and the means by which they are closed when no CLOSE
option is specified:
• Card output file. A card containing an ending label is punched. The file must be
labeled.
• Line printer file. The printer is skipped to channel 1, an ending label is printed, and
the printer is again skipped to channel 1. The file must be labeled.
• Unlabeled tape output file. A double tape mark is written after the last block on the
tape, and the tape is rewound.
• Disk file. If the file is a temporary file, the disk space is returned to the system.
An error indicator can be specified in columns 58 through 59. If this indicator is specified
and an error occurs in the operation, the indicator turns on and the program retains
programmatic control. If the indicator is not specified and an error occurs, the operating
system discontinues the program.
Example
Example 16–19 shows the CLOSE operation. It is assumed that the file MYFILE has
been declared in the program as a disk file and is open when the CLOSE operation is
executed.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C*
00200C CLOSEMYFILE CRUNCH
00300C CLOSEMYFILE
00400C CLOSEMYFILE REWIND
The Factor 1 field (columns 18–27) can contain a field name, a vector element, a table
name, or a literal representing the value of the key of the record to be deleted. If the
Factor 1 field is blank, the current record of the file named in the Factor 2 field
(columns 33–42) is deleted from the file. If the Factor 1 field is blank and no current
record is present, or if the key value specified does not exist in the file, a DELETE
ERROR message is displayed. Refer to Appendix A, “System Messages,” for a list of
error messages.
If the length of Factor 1 is less than the length of the key, the system pads Factor 1 with
zeros or blanks. This padding can cause found conditions to occur unexpectedly.
The Operation field (columns 28–32) must contain a DELET operation. The Factor 2 field
(columns 33–42) must contain the name of a file designated as a chained, demand, or
full-procedural disk file. This file must be an indexed file, as indicated by the letter I in the
File Organization Type field (column 32) of the File Specifications. The file must not be an
output file, and it cannot be processed by record address. The file does not need to be
specified as delete-capable in the File Addition/Unordered field (column 66) of the File
Specifications.
The Result Field (columns 43–48) can contain the name of the key as defined in the File
Specifications for the file named in the Factor 2 field. If the Result Field is blank, the
default key is the key specified in the File Specifications. The Result Field must be blank
to delete a record from an alternate index file. Additional information on alternate index
files is provided in Section 4, “Disk Files.” If the key is one for which duplicates are
allowed, the first entry encountered is deleted. The Result Field can contain an entry only
when the Factor 1 field (columns 18–27) contains an entry.
Columns 54 and 55 of the Resulting Indicators field (columns 54–59) can contain an
indicator that is turned on if the record deletion cannot be performed or turned off if the
record deletion was successful. If no indicator is specified and no key match is found, a
DELETE ERROR message is displayed. Additional information is provided in Appendix A,
“System Messages.”
If the key named in the Result Field was defined in the File Specifications with the letters
P, N, or J in column 31, then Factor 1 must be numeric. If the key was defined by an A or
a K in column 31, then Factor 1 can be either alphanumeric or numeric. Even if Factor 1 is
numeric, the comparison is done in alphanumeric mode.
If an external indicator conditions the file from which a record is to be deleted, that
indicator should also condition the DELET operation.
The DELET operation does not affect the current record pointer. Refer to Section 4,
“Disk Files,” for more information on deleting records from a file.
The file name must be entered in the Factor 2 field (columns 33–42). The Half Adjust
(column 53) and Resulting Indicators (columns 54–59) fields must be blank. The Control
Level (columns 7–8) and Indicators (columns 9–17) fields can be assigned.
The Factor 1 field (columns 18–27) is optional and can be used either to name a data item
or to specify a numeric or alphanumeric literal. A data item can be a field name, a vector
element, or an unindexed array. An unindexed table name cannot be used.
The Result Field (columns 43–48) is optional. It is used to specify the name of a data item
(a field name, a vector element, or an unindexed array). If both the Factor 1 field and the
Result Field are blank, a syntax error message is generated. The record length of Factor 1
and the Result Field must not exceed the record length of the file named in Factor 2. The
record length is entered in the Record Length field (columns 24–27) of the File
Specifications.
Example
Example 16–20 shows the coding for the DSPLY operation.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100F*
00200FFILEIN IP 80 80 DISK
00300FSCT D 80 80 ODT
00400FFILEOUT O 132 132 PRINTER
00500I*
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C*
01100C 01 FIELD1 ADD FIELD2 TOTAL 102
01200C 01 TOTAL COMP FIELD3 102030
01300C 10 'HIGH' DSPLYSCT
01400C 20 'LOW' DSPLYSCT
01500C 30 TOTAL DSPLYSCT FIELD3
01600O*
01700OFILEOUT D 01
01800O TOTAL 20
The Operation field (columns 28–32) must contain the entry EXCPT. Factor 1
(columns 18–27), the Result Field (columns 43–48), the Result Length field
(columns 49–51), and the Decimal Positions field (column 52) must be blank.
The Factor 2 field (columns 33–42) can be blank or can contain an entry for the file name
or output group name. If Factor 2 is blank, all lines in the Output Specifications with an E
entry in the Type field (column 15) but no entry in the Field Name field (columns 32–37)
are processed every time the EXCPT operation is executed, depending on output
conditioning indicators.
If Factor 2 contains a file name, only the exception output for that file is processed. The
exception records, however, are not produced for Output Specifications record
description lines that contain an output group name. The file must have output
capabilities.
If Factor 2 contains an output group name, all exception records on the Output
Specifications with this output group name in the Field Name field (columns 32–37) in the
Output Specifications are processed, depending on output conditioning indicators.
Example 16–19 shows a program that contains all three types of exception output.
Resulting indicators can be specified only for data communications and port files. The
indicator meanings are as follows:
• The high resulting indicator (columns 54–55) is turned on when a transmission error
occurs. If no indicator is specified and a transmission error occurs, the program ends
abnormally.
• The low resulting indicator (columns 56–57) is turned on when a file full condition
occurs. If no indicator is specified, the program waits until the message is accepted.
• The equal resulting indicator (columns 58–59) is turned on when an EOF condition
occurs.
Example
Example 16–21 writes to two files, RMT and PRINT. The program writes FIRST LINE OF
REMOTE and SECOND LINE OF REMOTE to RMT. The program writes FIRST LINE OF
PRINT, SECOND LINE OF PRINT, and THIRD LINE OF PRINT to the file named PRINT.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100F*
00200FDUMMY IP DISK
00300FPRINT O PRINTER
00400FRMT O REMOTE0
0050I*
00600I*
00700IDUMMY AA 01
00800I*
00900C*
01000C* Perform exception output to a printer file.
01100C*
01200C EXCPTPRINT
01300C*
01400C* Perform exception output using output group names.
01500C*
01600C EXCPTNAME2
01700C EXCPTWORD
01800C*
01900C* Output using SEND and output group names.
02000C*
02100C SEND REMOTE
02200C*
02300O*
02400O* Exception output to a file.
02500O*
02600OPRINT E
02700O 19 'FIRST LINE OF PRINT'
02800O*
02900O* Exception output with output group names.
03000O*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
03100OPRINT E WORD
03200O 19 'THIRD LINE OF PRINT'
03300ORMT E REMOTE
03400O 21 'SECOND LINE OF REMOTE'
03500OPRINT E NAME2
03600O 20 'SECOND LINE OF PRINT'
03700ORMT E NAME2
03800O 20 'FIRST LINE OF REMOTE'
03900O*
This operation can apply only to input, update, or combined files designated as primary or
secondary. The Factor 2 field (columns 33–42) contains the name of the file to be forced;
all other fields except the Indicators field (columns 9–17) must be blank. This operation
cannot occur during total calculations and should not occur within a subroutine called
from total calculations.
The MR indicator is always off while a forced record is being processed, and the program
treats the record as if it had no match fields specified.
Care should be taken in specifying more than one FORCE operation during the same
program cycle. If more than one FORCE operation occurs, only the last one affects
record selection, and all others are ignored. If the forced file has an EOF condition,
normal record selection determines the next record to be processed.
The Factor 2 field (columns 33–42) contains the name of the file to be read. The READ
operation can be conditioned by the Control Level (columns 7–8) and Indicators
(columns 9–17) fields. Factor 1 (columns 18–27) and columns 43 through 53 must be
blank. An indicator should be specified in columns 58 and 59; if not, an EOF condition on
the READ operation causes a READ AT END OF FILE error message to be displayed.
When the READ operation is used to read an indexed file, the key used to define the
sequence of records to be followed is the key used by the previous successful READ or
CHAIN operation. If no successful READ or CHAIN operation has been performed, the
key used is the one defined in the File Specifications. The READ operation provides the
next record in sequence, using that key.
The following rules must be observed when the READ operation is used:
The READE operation is typically used to read the duplicate records of an indexed file
after the initial record has been accessed. For example, if a CHAIN or READ operation
accesses the first in a series of duplicate records, the READE operation can then be used
to determine if duplicates exist and, if so, retrieve them.
The Factor 1 field (columns 18–27) specifies the key of the record to be retrieved. Factor
1 must be the same type and length as the key specified for the file in the File
Specifications. Factor 1 can be a field name, a vector element, or a literal.
The Factor 2 field (columns 33–42) contains the name of the indexed full-procedural file
that is to be read.
Columns 58 and 59 must contain an indicator. The specified indicator is turned on if the
next record key is not equivalent to the key in Factor 1 or if an EOF condition is reached.
If the file is delete-capable, the READP operation skips all deleted records until a
nondeleted record is found or the beginning of the file is encountered.
The Factor 2 field (columns 33–42) must specify the name of the file to be read. This file
must be a full-procedural file, as indicated by an F in the File Designation field (column 16)
of the File Specifications.
Columns 58 and 59 must contain an indicator. The specified indicator is cleared before
each READP operation and is turned on when the beginning of the file has been reached.
The Factor 2 field (columns 33–42) contains the name of the remote file to be read. The
RECV operation can be conditioned by the Control Level (columns 7–8) and Indicators
(columns 9–17) fields. The Factor 1 (columns 18–27), Result Field (columns 43–48), Field
Length (columns 49–51), and Decimal Positions (column 52) fields must be blank.
An indicator in columns 54–55 overrides the Error Indicator field (columns 53–54) of the
Telecommunications Specifications.
The RECV operation is also used to receive messages through COMS. Refer to the
discussion of COMS in Volume 2 of this manual for more information.
The Operation field (columns 28–32) must contain SEND as an entry. The Factor 1
(columns 18–27), Result Field (columns 43–48), Field Length (columns 49–51), and
Decimal Positions (column 52) fields must be blank.
Factor 2 (columns 33–42) can contain either an output group name or the name of the
remote file to which the message is sent. If Factor 2 contains a remote file name, the
output for that file is processed. Records are not processed for record description lines in
the Output Specifications that contain an output group name. If Factor 2 is an output
group name, all Output Specifications records with the specified output group name are
processed, depending on output conditioning indicators.
The SEND operation is similar to the EXCPT operation. It enables the same indicators in
columns 54 through 59.
• The high resulting indicator (columns 54–55) is turned on when a transmission error
occurs. If no indicator is specified and a transmission error occurs, the program ends
abnormally.
• The low resulting indicator (columns 56–57) is turned on when a file-full condition
occurs. If no indicator is specified, the program waits until the message is accepted.
• The low resulting indicator (columns 58–59) is turned on when an EOF condition
occurs.
The Remote Station Identification field (columns 41–47) of the Telecommunications
Specifications is used to identify the location of the remote file. Additional information on
this specification is provided in Section 12, “Telecommunications Specifications.”
The length of a message sent to a remote file is specified by using the Message Length
field (columns 64–70) of the Telecommunications Specifications. Additional information
on this specification is provided in Section 12, “Telecommunications Specifications.”
The SEND operation is also used to send messages through COMS. Refer to the
discussion of COMS in Volume 2 of this manual.
The Factor 1 field (columns 18–27) must contain a field name, a vector element, a table
name, or a literal representing the value of the lower limit being set. A whole array is not
allowed. The type (alphanumeric or numeric) of Factor 1 must be the same as the type of
the key for the file named as Factor 2.
If the length of Factor 1 is less than the length of the key, the system pads Factor 1 with
zeros or blanks. This padding can cause found conditions to occur unexpectedly.
The Factor 2 field (columns 33–42) contains the name of the file for which the lower limit
is specified. This file must be specified in the File Specifications as an indexed, demand,
or full-procedural file processed within limits either as a chained, indexed input, or update
file. The file must not occur in the Extension Specifications; that is, no record-address file
can be associated with this file. The Result Field (columns 43–48) can contain the name
of the key field to which the SETLL operation pertains. This name must have been
defined in the File Specifications of the file named in the Factor 2 field. If this entry is
blank, the key used is the key defined on the first File Specifications for this file, which is
not necessarily the primary key.
Columns 49 through 59 must be blank. The SETLL operation can be conditioned by the
Control Level (columns 7–8) and Indicators (columns 9–17) fields.
Other Operations
The operations that follow do not share a function similar to that of another operation.
Included are the DEBUG, DEFN, DUMP, LOKUP, SORTA, TIME, and ZIP operations.
The DEBUG operation can be used at any point in the Calculation Specifications to aid the
programmer in finding errors in program logic. Records containing information about the
status of indicators and field contents are written to an assigned output device.
DEBUG operations are compiled into the object program if the Debug field (column 15) in
the Control Specification contains the value 1, or if the $USERDEBUG compiler control
option is TRUE. All DEBUG operations are checked for syntax during compilation.
A file name must be specified in the Factor 2 field (columns 33–42). All DEBUG output
must go to the same file. The file named must be defined as a sequential output file in
the File Specifications.
The Factor 1 field (columns 18–27) is optional and can contain a literal or a field name that
identifies the particular DEBUG operation being executed. Factor 1 must not be an entire
array, and the size of the field must not exceed 8 characters or digits. The literal or the
value of the designated field is written as part of the output records. DEBUG can be
conditioned by indicators in the Control Level field (columns 7–8) and Indicators field
(columns 9–17). Columns 49 through 59 must be blank.
The Result Field (columns 43–48) is optional; however, if specified, it must be a field, a
vector, or a vector element.
One or more records are written as output from every DEBUG operation. The first record
is always written; the second and subsequent records are written only if the Result Field
(columns 43–48) contains an entry.
If a vector element is referred to in the Result Field, the DEBUG output lists the vector
name, its subscript, and its contents. If the Result Field contains an unsubscripted array
name, each element of the array is listed, with each array element and its subscript
beginning a new record. If the Result Field contains an unsubscripted table name, the
contents of the hold area of the table are listed.
Example
Example 16–22 shows DEBUG operation coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100H*
00200H 1
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C 01 FIELD1 ADD FIELD2 TOTAL 102
01100C 01 TOTAL COMP FIELD3 101020
01200C 01 '1' DEBUGPRINT1 FIELD3
01500OPRINT1 D 20
01600O TOTAL 20
Field definitions for the DEFN operation are defined in the following list:
• The Control Level field (columns 7–8) contains L0 through L9, LR, or SR.
• The Indicators field (columns 9–17) must be blank.
• The Factor 1 field (columns 18–27) contains the optional prefix *LIKE.
• The Operation field (columns 28–32) contains the operation code DEFN.
• The Factor 2 field (columns 33–42) contains the name of a field, a vector, or a vector
element. The characteristics of this field determine the characteristics of the field
defined in the Result Field. If the entries of this field and the Result Field have
already been defined, they must match. If the fields are not identical, an error
message is displayed.
• The Result Field (columns 43–48) can contain the name of a field, a data structure, or
a data structure subfield. It cannot contain a vector or vector element. The Result
Field is defined by the field named in Factor 2. If Factor 2 has type alphanumeric or
numeric, the Result Field has the same type. If Factor 2 is a vector or vector
element, the Result Field has the characteristics of the vector or vector element.
• The Field Length field (columns 49–51) can contain a plus sign (+) in column 49 to
indicate that the new entry is longer than the entry in the Factor 2 field. A minus
sign (–) in column 49 indicates that the entry in the new field is shorter than the entry
in the Factor 2 field. Columns 50 and 51 contain a numeric value that indicates the
amount of increase or decrease in the length of the new field. Single-digit numbers
must be right-justified.
If columns 49 through 51 are blank, the entry in the Result Field is defined with the
same length as that of the entry in the Factor 2 field.
• The Decimal Positions field (column 52) must be blank. The number of decimal
positions is taken from the identifier in the Factor 2 field.
• The Half Adjust field (column 53) must be blank.
• The Resulting Indicators field (columns 54–59) must be blank.
Example
Example 16–23 shows the DEFN operation. ALPH1 is a 10-character alphanumeric field,
NUM1 is a 6-digit numeric field with 3 decimal places, and ARY1 is a 10-element
alphanumeric array with elements that are 5 characters in length.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C*
00200C* FD1 is defined as a 12-digit alphanumeric field.
00300C*
00400C *LIKE DEFN ALPH1 FD1 + 2
00500C*
00600C* FD2 is defined as a 16-digit numeric field with
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00700C* 3 decimal positions.
00800C*
00900C *LIKE DEFN NUM1 FD2 +10
01000C*
01100C* FD3 is defined as a 2-character alphanumeric field.
01200C*
01300C *LIKE DEFN ARY1,2 FD3 - 3
01400C*
01500C* FD4 is defined as a 12-digit numeric field with
01600C* 3 decimal positions.
01700C*
01800C DEFN FD2 FD4 - 4
01900C*
02000C* FD5 is defined as a 25-character alphanumeric field.
02100C*
02200C *LIKE DEFN ARY1 FD5 +20
02300C*
02400C* FD6 is defined as a 6-digit numeric field with
02500C* 3 decimal positions.
02600C*
02800C *LIKE DEFN NUM1 FD6
A symbolic dump is produced when the code file accesses the RPGSUPPORT library. A
symbolic dump is not produced if the RPGSUPPORT library has not been initialized at the
point the dump is requested. The two most likely causes for the library not to be ready
are
• The symbolic dump is requested during the typically short interval after a new
RPGSUPPORT library is established with the Support Library (SL) system command.
• The symbolic dump is requested during a time that an RPG program is using a
function from the RPGSUPPORT library.
If the RPGSUPPORT library cannot be used, the following message is displayed and the
program is ended:
DUMP Operation
The DUMP operation produces a symbolic dump at a given point in the execution of the
program.
• The Factor 1 field (columns 18–27), the Result Field (columns 43–48), and
columns 49 through 59 must be blank.
• The Operation field must contain DUMP as an entry.
• The Factor 2 field (columns 33–42) can be blank or can contain the name of an output
file. If an output file name is specified in Factor 2, the file must have a record size of
at least 80 bytes. If Factor 2 is blank, the dump writes to the TASKFILE of the
program. The TASKFILE is a printer file associated with every program. The system
also uses the TASKFILE to write nonsymbolic dump data.
Symbolic dumps produced as a result of program halts are written to the TASKFILE. The
TASKFILE is a printer file associated with every program.
A program dump and an RPG symbolic dump are made available by setting the OPTIONS
attribute. Additional information on program dumps is provided in the Task Attributes
Reference Manual.
A symbolic dump is produced if the OPTIONS task attribute is specified and if either of
the following occurs:
• The DSED option is TRUE and the program ends abnormally because the operator
ends the program.
• The FAULT option is TRUE and the program ends abnormally for any reason other
than operator termination. For example, the program can be ended by the hardware,
system software, or application software. This situation does not include halt
conditions.
Data contained in the symbolic dump appear after program dump information is
presented.
Example 1
The following statement runs a program from CANDE, assigning both the DSED and
FAULT options. A symbolic dump is produced if the program ends abnormally or the
program is ended by the operator.
Example 2
The following statement runs a program from CANDE, assigning only the FAULT option.
A symbolic dump is produced if the program ends abnormally, but is not produced if the
program is ended by the operator.
The search word is the data item for which a match is sought in the vector named in the
Factor 2 field. The search word can be an alphanumeric or numeric literal, a field name, a
vector element, or a table name. If the search word is a table name, it refers to only the
current contents of the hold area for that table. The search word must be the same
length and type as the length and type of the vector being searched. No decimal
alignment is performed.
The Result Field (columns 43–48) is used only if two vectors are specified in the LOKUP.
When used, the Result Field must contain a table name. (Refer to the discussion of a
two-vector LOKUP operation later in this section.)
The Resulting Indicators field (columns 54–59) must be used with the LOKUP operation
to specify the type of search to be performed.
• When a high resulting indicator (columns 54–55) is specified, the vector is searched
for the item immediately higher than the search word.
• When a low resulting indicator (columns 56–57) is specified, the vector is searched
for the item immediately lower than the search word.
• When an equal resulting indicator (columns 58–59) is specified, the vector is
searched, starting from the first entry for an item equal to the search word.
Example
Example 16–24 shows LOKUP operations. ARY1 is searched for an element with a value
equal to the contents of FIELD1. Indicator 10 turns on if the LOKUP operation is
successful.
The second LOKUP operation is a two-vector LOKUP operation. ARY2 is searched for an
element with a value immediately higher than the value of FIELD2. If the LOKUP
operation is successful, indicator 20 is turned on and the hold pointer for the table is set
to be the corresponding element from TABLE.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FFILEIN IP 80 80 DISK
00400FFILE1 IT 80 80 DISK
00500FFILE2 IT 80 80 DISK
00600FFILE3 IT 80 80 DISK
00700FFILEOUT O 132 132 PRINTER
00800E FILE1 ARY1 1 5 5 0
00900E FILE2 ARY2 1 4 5 0A
01000E FILE3 TABLE 1 4 3 00
1100IFILEIN AA 01 1 CA
01200I 6 100FIELD1
01300I 16 200FIELD2
01400C*
01500C* LOOKUP OPERATION:
01600C*
01700C FIELD1 LOKUPARY1 10
01800C FIELD2 LOKUPARY2 TABLE 20
01900OFILEOUT D 01
02000O FIELD1 10
02100O FIELD2 20
One-Vector LOKUP
When the search involves one vector, Factor 1 (the search word), Factor 2 (the vector to
be searched), and one or two resulting indicators must be specified. The Control Level
field (columns 7–8) and the Indicators field (columns 9–17) can also be used. The Result
Field (columns 43–48) and the Half Adjust field (column 53) must be blank.
If the search is successful, the proper resulting indicator is turned on to indicate the
comparison that caused the search to end. The hold pointer for a table is set to point to
the element that satisfied the condition, and the contents of that element are moved into
the hold area. If a data item is assigned to the vector as an index, the data item contains
the index of the element that satisfied the condition. The element for an array is not
saved in a hold area; the index only points to the location of the element.
If the search is not successful, no resulting indicators are turned on. If Factor 2 is a table
name, the hold area is not affected, but the hold pointer is set to point to the first
element of the table. If Factor 2 is a vector with a data item assigned as index, the index
is set to 1.
Two-Vector LOKUP
When the search involves two vectors, Factor 1 (the search word), Factor 2 (the vector
to be searched), the Result Field (a corresponding or related table name that contains
available data), and one or two resulting indicators must be specified. The Control Level
field (columns 7–8) and the Indicators field (columns 9–17) can also be used.
When two vectors are specified with the LOKUP operation, only the vector named in the
Factor 2 field (columns 33–42) is actually searched. If the search is successful, the proper
resulting indicator is turned on to indicate the comparison that caused the search to end.
When tables have no index (in both the Factor 2 field and the Result Field), the hold
pointers for the tables are set to point to the corresponding elements from the tables,
and the contents of those elements are moved to the hold areas. If a data item is used
as a vector index in the Factor 2 field, the data item contains the number of the element
that satisfied the condition. No hold areas or hold pointers exist for arrays; the indexes
point to the locations of the elements in each array.
If the search is unsuccessful, no resulting indicators are turned on, and the hold area for
tables is unchanged. For tables (in both the Factor 2 field and the Result Field) with no
index assigned, the hold pointers are set to point to the first elements of the tables. The
index is set to 1 for vectors with a data item assigned as an index.
The vectors specified for LOKUP need not be the same type; however, the Result Field
(columns 43–48) can contain only a table name.
If the vector being searched is longer than its related vector, the search stops at the end
of the shorter vector. If the vector searched has a literal index, that index must be less
than or equal to the number of elements in either vector. If the vector searched has a
variable index, at run time its value is checked to verify that it is within the range of
elements of the related vector. If not, a SUBSCRIPT ERROR message is displayed at run
time. Refer to the list of error messages in Appendix A, “System Messages.”
The order in which to sort the array is specified by an entry in the Sequence field
(column 45) of the Extension Specifications. If the array is to be sorted in ascending
order, the Sequence field is coded with an A or a blank. If the array is to be sorted in
descending order, a D is entered in the Sequence field.
• The Factor 2 field (columns 33–42) must be coded with the name of the array to be
sorted.
• The Factor 1 (columns 18–27), Result Field (columns 43–48), and Resulting Indicators
(columns 54–59) fields must be blank.
• The Decimal Position field (column 52) indicates the use of a different collating
sequence. Specifying a C in this column indicates that the collating sequence
specified in the Collating Sequence field (column 26) of the Control Specification is
used instead of the collating sequence of the EBCDIC character code.
• The Half Adjust field (column 53) selects the sort method by specifying a value: a
blank or an H specifies heap sort; a B specifies a bubble sort; and a Q specifies a
quick sort.
If performance is critical in an application, the type of sort chosen is important. Quick sort
is generally the fastest method when sorting a completely unsorted array of more than
10 elements. For sorting in descending order, heap sort is often faster than quick sort. If
the array is very small (10 elements or less) or almost entirely sorted, bubble sort is
recommended. Bubble sort is not an efficient sorting method for large arrays.
Example
Example 16–25 shows Extension and Calculation Specifications coding for sorting four
arrays. Default values are used for ARRY1 in both the Extension and Calculation
Specifications. Because the Sequence field of the Extension Specifications is blank,
ARRY1 is sorted in ascending order; because the Half Adjust field of the Calculation
Specifications is blank, a heap sort is used.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100E*
00200E ARRY1 5 100 7 2
00300E ARRY2 20 10
00400E ARRY3 50 12 0A
00500E ARRY4 2 12 6 D
00600C*
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00700C* Sort ARRY1 in ascending order, using heap sort.00800C*
00900C SORTAARRY1
01000C*
01100C* Sort ARRY2 in ascending order, using bubble sort.
71200C*
01300C SORTAARRY2 B
01400C*
01500C* Sort ARRY3 in ascending order, using quick sort.
01600C*
01700C SORTAARRY3 Q
01800C*
01900C* Sort ARRY4 in descending order, using heap sort.
02000C*
02100C SORTAARRY4 H
After this operation is performed, a 6-digit Result Field contains the system time in the
format HHMMSS (where HH represents hours, MM represents minutes, and SS
represents seconds). A 12-digit Result Field contains both the system time and the
system date. The format of the system date depends on the entry in the Inverted Print
field (column 21) in the Control Specification. If the Inverted Print field contains a blank,
the Result Field is provided in the format HHMMSSmmDDYY (where HH represents
hours, MM represents minutes, SS represents seconds, mm represents the month, DD
represents the day, and YY represents the year). If the Inverted Print field contains D, I,
or J, the Result Field is in the format HHMMSSDDmmYY.
The Factor 2 field (columns 33–42) must contain the information required for the WFL
statement and must be an alphanumeric field, table name, vector element, or literal. This
operation can be conditioned by the Indicators field (columns 9–17).
Example
Example 16–26 shows ZIP operation coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FFILEIN IP 80 80 DISK
00600IFILEIN AA 01
00700I 5 10 FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C ZIP FIELD1
01100C ZIP 'START X'
COMS Operations
For information about COMS operations, refer to Volume 2 of this manual.
DMSII Operations
For information about DMSII operations, refer to Volume 2 of this manual.
RPG can be used to write to line and character printers, tapes, disks, and cards. Although
any of these devices can be used to create new files or records, only disks are suitable
for changing a record in place without changing the location of the record in the file. The
Output Specifications can be used to describe only the part of a record to be changed.
For information about output to databases and to the COMS message control system
(MCS), refer to Volume 2 of this manual.
The Device field (columns 40–46) in the File Specifications names the peripheral where a
file is to be written, and the Filename field (columns 7–14) associates a unique name
with the file.
Table 17–1 summarizes the field definitions for the Output Specifications.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter O.
7 Contains an asterisk (*) if the line is a comment.
7–14 Contains a file name specified in the File Specifications.
14–16 Puts the output indicators in an AND or OR relationship. Acceptable entries
are AND, OR, or blank.
15 Contains the type of output record to be written. Acceptable entries are the
letters H, D, T, or E. Additional entries for the DMSII interface are described
in Volume 2 of this manual.
16–18 Determines whether a record is to be added to or deleted from an indexed
sequential file. Acceptable entries are ADD, DEL, or blank.
16 Specifies either the stacker in which the output card is to be placed, or that
the overflow routine is to be invoked. Acceptable entries are the letter F, 1,
2, or blank. Additional entries for carriage control of COMS headers are
described in Volume 2 of this manual.
17–18 Designates the spacing of forms, before or after printing, for printer output
files. Acceptable entries are 0 through 9 or blank.
Columns Description
19–22 Designates the skipping of forms, before or after printing, for printer output
files. Acceptable entries are 1 through 99, A0 through A9, B0 through B2, or
blank.
23-31 Output indicators are divided as follows:
• Columns 23, 26, and 29 indicate whether the output indicators in
columns 24 through 25, 27 through 28, or 30 through 31 must be on or
off. Acceptable entries are blank or N.
• Columns 24 through 25, 27 through 28, and 30 through 31 contain a
previously defined indicator that is used to condition output.
Acceptable entries are 01 through 99, L0 through L9, LR, MR, H0
through H9, U1 through U8, OA through OG, OV, 1P, or blank.
32–37 Contains a previously defined field name, special word, output group name,
vector, or vector element.
38 Specifies one of the following:
• The editing for a numeric output field when an edit word is not being
used. Acceptable entries are 1, 2, 3, 4, the letters A, B, C, D, J, K, L, M,
X, Y, Z, or blank.
• Synchronization for a specific record. Acceptable entries are the letter
S or blank.
39 Determines whether a variable is to be filled with blanks or zeros when the
output operation is finished. Acceptable entries are the letter B or a blank.
40–43 Designates the location of a field within an output record. Acceptable
entries are 1 through n (where n = maximum record length) right-justified,
or blank.
44 Specifies that an output field is to be written in alphanumeric, packed,
binary, single-precision, or double-precision format. Acceptable entries are
the letters P, J, L, R, B, S, D, or blank.
45–70 Contains a constant or edit word used to format and punctuate the output
record. The constant or edit word is enclosed in apostrophes (') and left-
justified. Acceptable entries are any valid RPG character as described in the
character set discussion in Section 2, “RPG Language Elements.”
71–73 Specifies the send type for COMS, which is described in Volume 2 of this
manual.
75–80 Contains the program identification. Any entry is valid.
Field Definitions
The fields in the Output Specifications are defined in the following text.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
Example
Example 17–1 shows comment line coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105O*
00110O* This is an example of how comment lines are coded. All lines
00120O* with an asterisk in column 7 are ignored by the compiler.
00140O*
Every output file described in the File Specifications should also be described in the
Output Specifications, but this description is not required. If Output Specifications are not
provided for an output file, no data records (except possibly EOJ vector output) are sent
to the file; however, the file can still be opened and closed by the PLC. If this entry is
blank on a record description line, the file name of the previously described record is
assumed. The first record type described must have an entry in the Filename field.
For update files, only the fields to be changed need to be specified in an output record.
The remainder of the update record remains unchanged.
Entry Definition
H The record is written during detail output (2), which occurs between detail
calculations (16) and the setting of overflow indicators (3). An H entry has the
same meaning as a D entry and is supplied only to help the programmer
distinguish between page headings from other detail output. Page headings
usually occur once on each page of printed output; detail output occurs once
during each program cycle.
D The record is written during detail output (2), which occurs between detail
calculations (16) and the setting of overflow indicators (3). This output occurs
once for each program cycle.
T The record is written during total output (10), which occurs between total
calculations (9) and testing of the last record (LR) indicator (11). This output
occurs once during each program cycle except the first.
E The record is written during exception output, which occurs during detail (16)
or total (9) calculations as the result of an EXCPT or SEND operation.
Record types can be specified in any order. However, if all output conditioning indicators
are satisfied, the sequence of output is as follows:
1. Detail output, which occurs during each cycle (2), including first page (1P) output only
during the first cycle. (Refer to the discussion of the 1P indicator in this section.)
2. Exception output, which occurs during total calculation (9) if an EXCPT or SEND
operation is executed. The program writes exception output during the first cycle.
3. Total output (10), which occurs during each cycle except the first.
4. Overflow output (13), which occurs during each cycle when a page overflow
condition occurs.
5. Exception output, which occurs during detail calculations (16) if an EXCPT or SEND
operation is executed.
First page output, which occurs when the 1P indicator is on, is heading or detail output
conditioned by the 1P indicator. This type of output occurs only at the beginning of
program execution, because the 1P indicator is off permanently (3) after the first
execution of detail output.
One of the following two methods should be used for determining the output record
sequence, for ease of writing and later program maintenance:
• The records within one file are specified, beginning with heading records and
continuing with detail records, total records, and exception records.
• All the heading records are specified, followed by detail records, total records, and all
exception records.
The two methods of determining the sequence of output specifications can be varied as
required so that the proper physical sequence of records in the files can be ensured.
OR lines (OR in columns 14 through 15) can be used to group indicators so that only one
of the conditions specified must be met for the associated output operation to take
place. The OR line follows the line on which the file is described.
Both AND and OR lines can be used together on a record description line, but not on a
field description line. A maximum of three indicators on a single line in an AND
relationship can be used to condition a field. Refer to Example 17–3 later in this section
for coding of the AND and OR lines.
At least one indicator must be present on an AND and OR line and on the preceding line.
Any number of AND and OR lines can be specified for a record description.
Entry Definition
ADD Add a record to a sequential, direct, indexed, or alternate index file. The file can
be opened for input, update, or output.
DEL Delete the last record read if the file is a sequential, direct, indexed, or alternate
index file.
Record Addition
A record can be added to an existing file only if all the following conditions are true:
• The file is a sequential, direct, indexed, or alternate index file opened for input,
update, or output.
• The File Addition/Unordered field (column 66) in the File Specifications contains A or
B.
• The file is a disk file.
• Columns 16 through 18 contain the entry ADD.
If the Record Addition/Deletion field is blank, the entry ADD is assumed and the compiler
displays a warning message under any of the following conditions:
• The file is an input file and the File Addition/Unordered field (column 66) of the File
Specifications contains an A, which indicates that records can be added to an
existing file.
• The file is an input file and the File Addition/Unordered field contains a B, which
indicates that records can be added or deleted.
• The file in an output file and the File Addition/Unordered field contains an A.
An ADD entry must be specified before any entries in the AND and OR field
(columns 14–16) because the ADD applies to all AND and OR lines in the group.
Refer to Section 4, “Disk Files,” for more information about adding records to a file.
Record Deletion
A record can be deleted from an existing file only if all the following conditions are true:
• The file is either an indexed or alternate index file or an EFS sequential or direct file.
The file must be opened for input or update.
• The File Addition/Unordered field (column 66) in the File Specifications contains D, B,
or blank.
• If the file is an EFS file, it must have been created as a delete-capable file.
• The file is a disk file.
• Columns 16 through 18 contain the entry DEL.
A DEL entry must be specified before any entries in the AND and OR field
(columns 14–16) because the DEL operation applies to all AND and OR lines in the group.
An attempt to delete a record from a BFS sequential or direct file causes the last record
read to be filled with blanks.
Refer to Section 4, “Disk Files,” for more information about deleting records from a file.
• The stacker into which an output or combined file card is placed after it is processed.
• The overflow routine that can be called for possible execution before the record
specified by this line is printed. This process is called fetch overflow.
The valid entries for the Stacker-Select/Fetch Overflow field are as follows:
Entry Definition
Blank This entry forces cards to go automatically to the default stacker, and printer
files do not attempt to fetch overflow.
1-2 This entry represents the stacker into which the card is to be stacked (card
files only).
F This entry causes the system to fetch overflow (printer files only).
Stacker Selection
Only output and combined card files can have stackers selected in the Output
Specifications.
When a combined file has a stacker selected and/or updated during total calculations
(step 9 or 10 of the PLC), the record being updated is the one that caused the control
break. For further discussion, refer to the discussion of the Type field (column 15) in this
section.
If the numeric stacker-selection entry is greater than 2, the record is selected for the
normal (default) stacker.
Record types identified by OR lines can be selected for a special stacker by an entry in
the Stacker-Select/Fetch Overflow field. However, if this field is blank, the record type
selected by the OR line goes to the default stacker; that is, the stacker-selection entry on
the previous line is not assumed. AND lines must not have a stacker-selection entry.
Overflow Fetching
Entering an F in column 16 of the record description of a printer file requests that
overflow output be checked for this file before this line is printed. (For additional
information, refer to the discussion of printing reports in this section.)
Fetched overflow can be specified for any detail, total, or exception output and must not
be conditioned by an overflow indicator; that is, the overflow routine cannot be called
during the printing of overflow.
Fetched overflow can be specified for any OR line. The entry on the previous line is not
assumed. Fetch overflow cannot be specified for AND lines.
Entry Definition
In the following paragraphs, form length refers to the form length specified in the Line
Number, FL, Channel Number field (columns 15–19) in the Line Counter Specifications. If
no form length has been entered, the default form length is used. Overflow line refers to
the overflow line specified in the Line Number, OL, Channel Number field
(columns 29–24) in the Line Counter Specifications. If no overflow line has been entered,
the default overflow line is used. Refer to Section 11, “Line Counter Specifications,” for
more information on form length and overflow lines.
• The number 2 in the Line Printer Skipping field (column 46) in the Control
Specification
• A blank in both the Line Printer Skipping field and the Source Input Dialect field
(column 51) in the Control Specification
The Skip field specifies the particular line number to which the printer is to skip. This field
is divided into two subfields: Skip Before (columns 19–20) and Skip After
(columns 21–22). These subfields indicate whether forms skipping occurs before or after
the record is printed.
Valid entries in the Skip field for skipping to a line number are as follows:
Entry Definition
Blank Do not skip.
If both skipping and spacing are specified on the same line, the operations are performed
in the following order:
1. Skip Before
2. Space Before
3. Skip After
4. Space After
Spacing or skipping to, or beyond, the overflow line causes the overflow indicator
associated with the file to turn on. However, spacing or skipping beyond the overflow
line to a line on the next page does not cause the overflow indicator to turn on. The
overflow area is defined as extending from the first line after the overflow line to one line
before line 1.
For OR lines, different Skip field and Space field (columns 17–18) entries can be
specified. If all such entries are blank for an OR line, spacing and skipping are performed
according to the specifications on the preceding line. If any entries are made for an OR
line, all desired spacing and skipping must be specified. Neither Space nor Skip field
entries are permitted on AND lines.
If a printer record has neither space nor skip specifications, the default value is one line
of spacing after each record printed.
• The number 1 in the Line Printer Skipping field (column 46) in the Control
Specification
• A blank in the Line Printer Skipping field and the number 1 in the Source Input Dialect
field (column 51) in the Control Specification
The Skip field specifies the particular channel to which the printer is to skip. This form of
line printer skipping is directly related to the operation of the printer carriage control tape.
The Skip field is divided into two subfields: Skip Before (columns 19–20) and Skip After
(columns 21–22). These subfields indicate whether forms skipping occurs before or after
the record is printed.
Valid entries in the Skip field for skipping to a channel number are as follows:
Entry Definition
Skipping is performed according to the format punched in the carriage control tape. Line
Counter Specifications are required to associate line numbers with the channel numbers
referenced so that the program can determine when the overflow line has been reached.
The overflow area is defined as the lines from channel 12 to one line before channel 1.
If a printer record has neither space nor skip specifications, the default value is one line
of spacing after each record printed.
The following entries are allowed in the indicator subfield of the Output Indicators field:
Entry Definition
Blank The operation is not conditioned by any indicator. In this case, the Not subfield
must also be blank.
Because all three indicators on one line are in an AND relationship, all indicators on one
line or group of lines must be on or off, as individually specified; otherwise, the
associated operation does not take place.
An indicator specified on the line describing the record type conditions the entire output
record. If an indicator and a field description are specified on the same line, the indicator
conditions that field only, are unchanged. Regardless of the field lengths,
Example
Example 17–2 shows coding for output indicators.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00310FPRINT1 O 132 132 PRINTER
00320FPRINT2 O 132 132 PRINTER
00400IFILEIN AA 01
00500I 5 100FIELD1
00600I 22 292FIELD2
00700I 35 442FIELD3
00800C 01 FIELD1 ADD FIELD2 TOTAL 102
00900C 01 TOTAL COMP FIELD3 101020
01000C 01 FIELD1 COMP FIELD2 304050
01100OPRINT1 D 01
01200O FIELD1 10
01300O FIELD2 20
01400O 10 FIELD3 30
01500O 20 TOTAL 30
01600OPRINT2 D 01
01700O OR 10N50
01800O OR 3001850O OR 40
01900O 35 'UNEQUAL FIELDS'
The types of output conditioning indicators are discussed in the following paragraphs.
• To condition output operations that are to be performed only for specific input record
types, as specified in the Record Identifying Indicators field (columns 19–20) in the
Input Specifications
• To condition output operations that are to be performed when an input field meets
certain conditions, as specified in the Field Indicators field (columns 65–70) in the
Input Specifications
• To condition output operations according to the results of calculations, as specified in
the Resulting Indicators field (columns 54–59) in the Calculation Specifications
Because the program does not halt until after the record in error has been processed
through detail output, some operations might need to be prevented to avoid erroneous
output. Using halt indicators can inhibit or permit an operation, depending on the status
and specification of the indicator.
If no overflow indicator is assigned to the file, forms advancing at end of page (EOP) is
handled automatically. Any output record specification line not conditioned by an
overflow indicator but designating a skip to the next page turns off the overflow indicator
before the skip takes place.
Overflow indicators cannot condition exception records, but can condition fields within
exception records. No more than one overflow indicator can be associated with a group
of output indicators in an AND and OR relationship. Overflow is described in detail in the
discussion of printing reports in this section.
The 1P indicator can be used to condition heading, detail, total, or exception lines.
However, a 1P indicator turned on for a total record, an exception record, or field
descriptions prevents all output for that record or field.
Example
Example 17–3 shows the use of the 1P indicator.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00500FPRINT2 O 132 132 OF PRINTER
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
00910C 01 FIELD1 COMP 0 020303
00920C 01 FIELD2 COMP 0 040505
00930C 01 FIELD3 COMP 0 060707
01000C 01 FIELD1 ADD FIELD2 TOTAL 102
01100C 01 TOTAL COMP FIELD3 101020
01200C 01 FIELD1 COMP FIELD2 304050
01210OPRINT1 H 3 1P
01220O 35 'REPORT HEADING #1'
01300O D 01 02 04
01310O AND 06
01320O FIELD1 10
01500O FIELD2 20
01600O 10 FIELD3 40
01700O 20 TOTAL 40
01710OPRINT2 H 201 1P
01720O OR OF
01730O 35 'REPORT HEADING #2'
01800O D 01
01900O OR 10N50
02000O OR 30
02050O OR 40
02100O 35 'UNEQUAL FIELDS'
This field assigns an identifier to an output data field. The identifier used must have been
defined previously in one of the following fields unless it is a special word:
An output group name can be used to identify a group of records for output. The group is
used only with exception output. Exception records with an output group name are
processed when the output name is specified in the Factor 2 field of an EXCPT or SEND
operation. If the Factor 2 field contains a blank, a file name for the EXCPT operation, or a
file name for the SEND operation, then exception records with an output group name are
not processed.
Using output group names can reduce the need for conditioning indicators on exception
records. However, conditioning indicators can still be used to determine whether or not
the fields are to be written. Overflow indicators cannot be used to condition a record with
an output group name.
Refer to the discussion of the EXCPT operation in Section 16, “Operation Codes,” for an
example of output group names.
The following special words are reserved for use as variable names:
UDATE UMONTH
UDAY UYEAR
UTIME UDAYNM
JDATE *PLACE
A discussion of *PLACE is provided later in this section. For information about the
remaining special words, refer to Section 2, “RPG Language Elements.”
If the record identified in columns 14 through 16 of an OR line is left blank (in the
AND and OR Line field), the entry designated for synchronization of the previous line
is assumed. A record identified in an AND line must not have an entry for
synchronization.
Additional information on synchronization of output is provided in the File Attributes
Reference Manual.
Entry Definition
If the Zero/Blank Indicator Setting field (column 42) in the Control Specification contains
an R, or both column 42 and the Source Input Dialect field (column 51) in the Control
Specification are blank, then the Blank After field entry has no effect on zero/blank
indicators.
The zero/blank indicator is turned on when the following conditions are true:
• If the Zero/Blank Indicator Setting field contains an S or is blank and the Source Input
Dialect field contains the number 1
• If an indicator has been assigned to the field in the Input or Calculation Specifications
to test for zero or blank and the same field is used in the Output Specifications with
Blank After specified
If more than one indicator is assigned to the same field as a zero/blank indicator in
different Input or Calculation Specifications, only the first one is turned on when the field
is reinitialized. Whenvectors or vector elements are written with Blank After, zero/blank
indicators are not changed.
Example
Example 17–4 shows code in which an end position is designated. The specified end
position is 30. Because the end position for the next field is blank, the first position for
that field is 31.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000OPRINT
03000O 30 'THIS MESSAGE APPEARS '
04000O 'ON ONE LINE.'
05000O*
06000O* The output record that appears is:
06000O* THIS MESSAGE APPEARS ON ONE LINE.
For information on how the specified end position relates to the result obtained by using
various edit codes, refer to Table 17–3 later in this section.
Entry Definition
S Field is to be written in single-precision numeric format. The field can have from
1 to 11 digits and occupies 6 bytes.
The internal format of numeric data is not necessarily the same as the external data
format. Any necessary conversion is performed automatically. Packed data fields are
always character aligned (byte aligned). The output of a field specified with signed,
packed data format (P format) creates a field with an odd number of digits and a sign.
The output of a field specified with unsigned, packed decimal format (J format) creates a
field with an even number of digits and no sign.
Constants
A description of the use of constants, *PLACE, edit codes, and edit words follows.
Constants are literals and contain information that is not changed by any operation.
Constants appear in the output exactly as they are written in the Output Specifications,
at the position specified in the Field End Position field (columns 40–43).
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C 01 FIELD1 ADD FIELD2 TOTAL 102
01100C 01 TOTAL COMP FIELD3 101020
01200C 01 FIELD1 COMP FIELD2 304050
01300OPRINT1 H 304 1P
01400O 33 'ONE O''CLOCK REPORT'
01410O H 1 1P
01420O 10 'FIELD1'
01430O 20 'FIELD2'
01440O 30 'FIELD3'
01450O 40 'TOTAL'
01500O D 01
01600O FIELD1 10
01700O FIELD2 20
01800O 10 FIELD3 30
01900O 20 TOTAL 40
• By defining each field and corresponding end position every time it is to appear in the
output record
• By using the special word *PLACE
Both methods produce identical results, but using the *PLACE entry requires less
coding.
• All fields within the record type preceding the *PLACE entry are repeated according
to the *PLACE end position, not only the one preceding line.
• An end position must be given for every *PLACE entry.
• An additional *PLACE entry (on a separate line) must be used every time the fields
are to be repeated.
• Because *PLACE applies only to fields previously described in the record, *PLACE
cannot be the first field description.
• The end position specified for *PLACE should be at least twice that of the highest
end position previously specified. If enough space is not allowed for all fields to be
printed again, overlapping occurs (with the *PLACE output overlapping the previous
characters).
• The end position specified for *PLACE must not be lower than the highest previously
specified field end position.
• *PLACE moves all the fields beginning in position 1 of the record through the highest
non*PLACE end position specified in the preceding field descriptions.
• Only the Output Indicators (columns 23–31), Field Name (columns 32–37), and Field
End Position (columns 40–43) fields can have entries.
Example
Example 17–6 shows the use of the *PLACE special word to write the same output to
files PRINT1 and PRINT2.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00500FPRINT2 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 1 50FIELD1
00800I 11 150FIELD2
00900I 21 250FIELD3
01100OPRINT1 D 01
01200O FIELD1 5
01300O FIELD2 15
01310O FIELD3 25
01320O FIELD1 35
01330O FIELD2 45
01340O FIELD3 55
01342O FIELD1 65
01344O FIELD2 75
01346O FIELD3 85
01350O*
01360O* The above output definition can be defined using the *PLACE
01370O* specification as shown below:
01380O*
01400OPRINT2 D 01
01500O FIELD1 5
01600O FIELD2 15
01700O FIELD3 25
01800O *PLACE 55
01900O *PLACE 85
Edit Codes
Edit codes are single-character codes used to edit numeric fields. Only numeric fields can
be edited by using edit codes. If an edit code is specified, the Constant or Edit Word field
(columns 45–70) must be blank; however, if check-protect asterisks or a floating dollar
sign is desired, an asterisk enclosed in apostrophes ('*') or a dollar sign enclosed in
apostrophes ('$'), respectively, can be entered in columns 45 through 47. Edit codes X, Y,
and Z cannot be used with a check-protect asterisk or a floating dollar sign.
When an entire array is edited using an edit code, the following points must be
considered if an end position large enough for all the output data is specified:
• Conditioning indicators on the record description line and on the field description line
determine when the field is written.
• The variable name specified in the Field Name field (columns 32–37) must have been
previously defined as one of the following:
− An entire numeric array
− A single element of a numeric vector
− A numerically defined field
− A numerically defined special word
• An edit code entry in column 38 causes specific punctuation of the variable. (Refer to
the examples in Table 17–4 later in this section.)
• An entry of B in the Blank After field (column 39) does not affect the editing specified
on this line.
• The Field End Position field (columns 40–43) defines where the last character of the
edited output appears.
Note: A syntax error occurs if the total length in bytes of the variable plus all
inserted editing symbols is greater than the length in bytes, from the specified end
position to position 1, of the output record.
• Edit codes A, B, J, K, 1, and 2 provide the comma option. Commas (,) are inserted in
the edited output only if more than three significant, nonzero digits appear to the left
of the implied decimal point.
• Edit codes A, C, J, L, 1, and 3 provide the zero balance option. This option ensures
that at least one 0 (zero) is written if the value of the field is 0.
The number of zeros written is determined by the number of decimal positions
assigned to the field, as shown in the following example:
0 0
1 .0
2 .00
9 .000000000
minus sign (–) for each array element, or two spaces for each possible CR for
each array element
Legend
? The X edit code removes a plus sign (+).
?? The Y edit code suppresses the leftmost zero only.
Table 17–3 summarizes the results obtained when each of the edit codes is used to edit
a 2-decimal-position field whose length is 5 and whose value is –3.12. The Output
Specifications specify a Field End Position value of 12. A right brace (}) represents a
negative 0.
6 7 8 9 10 11 12 13
None } 0 3 1 2
1 3 . 1 2
2 3 . 1 2
3 3 . 1 2
4 3 . 1 2
A 3 . 1 2 C R
B 3 . 1 2 C R
C 3 . 1 2 C R
D 3 . 1 2 C R
J 3 . 1 2 --
K 3 . 1 2 --
L 3 . 1 2 --
M 3 . 1 2 --
X } 0 3 1 2
Y 0 / 3 1 / 2
Z 3 1 2
Table 17–4 lists examples that show the effects of the Y edit code on given input strings.
Table 17–5 lists examples that show the effects of various edit codes on a positive zero
input string.
Table 17–6 lists examples that show the effects of various edit codes on a negative zero
input string.
Table 17–7 lists examples that show the effects of the edit codes on a positive, 10-digit
field with two implied decimal places.
Table 17–7. Effects of Edit Codes on Positive Data with Two Implied
Decimal Places
Table 17–8 lists examples that show the effects of the edit codes on a negative, 10-digit,
numeric field with two implied decimal places.
Table 17–8. Effects of Edit Codes on Negative Data with Two Implied
Decimal Places
Edit Words
Edit words are alphanumeric literals that can be used instead of an edit code when a
special edit format is desired.
Edit words are functionally subdivided into the following three parts:
Part Description
Extension Holds the constant information to be printed with the body and the
status data used to make the resulting output field more
understandable
The body is defined differently depending on whether the RPG I or RPG II dialect is used.
For more information about which dialect is in effect, refer to the Source Input Dialect
field (column 51) of the Control Specification.
RPG II Every replaceable character in the edit word up to, and including, the
rightmost replaceable character
Examples of valid entries for replaceable characters are shown later in this section.
The body generally contains appropriately spaced decimal points (.), commas (,),and
slashes (/). Other characters can also be specified to appear with the data of the variable
named in the Field Name field (columns 32–37). All leading zeros are suppressed up to
the position following a zero-suppression character.
The body should be at least as long as the variable, plus 1 byte for each punctuation
character specified. If the number of replaceable characters in the body is less than the
length of the variable, a syntax error occurs. If the number of replaceable characters
exceeds the length of the variable, the data is placed in the edit word right-justified in
RPG II and left-justified in RPG I.
The preceding rule regarding the size of the body of an edit word has the following
exceptions:
• Zero suppression of the high-order position of a variable can occur when the number
of replaceable characters in the body of the edit word equals the length specified for
the variable. The zero suppression of the high-order position of a variable does not
occur if the number of replaceable characters in the body of the edit word exceeds
the length of the variable by 1 and if the leftmost position of the edit word contains a
0 (zero).
• An extra space must be allowed in the edit word for a floating dollar sign if output is
to appear correctly when the variable contains its maximum value. If an extra space
is not allowed, a warning message is displayed. If the field contains its maximum
value, the leftmost digit is not printed.
A replaceable character is a part of the edit word that does not require an extra position
in the output field. The replaceable characters are as follows:
Entry Definition
Blank No entry
The status entry of an edit word is either the minus sign (–) or the credit sign (CR). If the
value of the data is positive, the sign is not written, because no sign implies a positive
sign. If either a CR or a minus sign (–) appears after the body, the status portion of an
edit word consists of everything after the body up to and including the first CR or minus
sign (–). If a CR or a minus sign does not occur after the body, the edit word has no
status portion. The entire status section is written only if the value of the numeric
variable is negative.
The extension portion of the edit word contains constant data written with the variable
data to improve readability.
The extension portion of an edit word is optional and, if present, consists of everything
that appears after the body and status sections, if present. The extension section is
always printed exactly as coded except for the ampersand (&), which is printed as a blank
in RPG II and as an ampersand (&) in RPG I. In the following example, O'CLOCK is a
constant within the body of the edit word, and MIN. (minute) is the extension:
The following rules must be observed when edit words are used:
• The Field Name field (columns 32–37) entry must be a numeric variable.
• Edit words must be left-justified, enclosed in apostrophes, and no longer than 24
characters.
• The entire character set is valid in edit words, with the exception of replaceable
characters.
• The number of replaceable characters in the edit word should be greater than or
equal to the length of the field to be edited.
• The field is padded with leading zeros before editing if the number of replaceable
characters in the body exceeds the length of the field to be edited.
• The Edit Code field (column 38) and the Packed field (column 44) must be blank.
• A zero or asterisk (*) in the edit word has the following effects:
− A zero causes insignificant zeros in the variable data to be filled with blanks in the
body.
− An asterisk (*) causes insignificant zeros in the variable data to be filled with
asterisks.
This substitution of characters begins at the position of the zero-suppress character
and extends left to the end of the field.
• All zeros and asterisks except the leftmost are considered constants if more than
one zero or asterisk is used in the edit word.
• Any constant to the left of the zero-suppression character (zero or asterisk), except
for the dollar sign ($), is also suppressed.
• Only the first zero is suppressed when the first character of the edit word is zero and
the field being edited contains leading zeros equal in length to the number of
replaceable characters.
• The leading zeros are not suppressed when the first character of the edit word is
zero and the variable field contains leading zeros of a length less than the number of
replaceable characters. Refer to edit word examples 61 and 62 later in this section.
• The ampersand (&) is replaced by a blank in the body and status portions of all edit
words. In the extension portion, the ampersand is replaced by a blank in RPG II and
is printed as an ampersand in RPG I.
• A floating dollar sign ($) is specified by placing a dollar sign immediately to the left of
the zero-suppression character—either a zero or an asterisk (*). The symbol printed
depends on the entry in the Currency Symbol field (column 22) in the Control
Specification.
Fixed dollar signs ($), decimal points (.), commas (,), ampersands (&), minus signs (–), and
constant information all require extra space in the output field.
Following are 63 examples of how to use edit words. The leftmost entry is the edit word,
which is coded in columns 45 through 70 of the Output Specifications. The input string
shows the input, and the output string shows the result of the editing.
Example 1
*....5....*....6....*....7 Input String Output String
0000123456 0000123456
Example 1 shows that without an edit word, a positive sign is forced to alphanumeric 0
through 9. Refer to the discussion of the External Sign Handling field (Column 40) in
Section 7, “Control Specification,” for information on printing of a positive zone sign.
Example 2
*....5....*....6....*....7 Input String Output String
-0000123456 }000123456
Example 2 shows that without an edit word, the sign position is not converted to a
numeric character. A right brace (}) indicates negative zero (–0).
Example 3
*....5....*....6....*....7 Input String Output String
' ' 0000000000
Example 4
*....5....*....6....*....7 Input String Output String
' ' +0000123456 123456
Example 5
*....5....*....6....*....7 Input String Output String
' ' -0000123456 123456
Example 6
*....5....*....6....*....7 Input String Output String
' , , 0. ' 0000000005 .05
Example 6 shows a standard approach to editing an amount field. The decimal appears
between the dollars and cents. The commas mark each of three positions to the left of
the decimal. The zero-suppression character (0) immediately to the left of the decimal
causes zero suppression to the left.
Example 7
*....5....*....6....*....7 Input String Output String
' , , 0 -' 00000000 0
Example 7 shows that zero suppression begins where the zero-suppression character is
specified and continues to the left. An extra space occurs on the right side for the minus
sign (–).
Example 8
*....5....*....6....*....7 Input String Output String
' , , . -' -00000000123 1.23-
Example 8 shows that the status portion prints when the field is negative. Because no
zero-suppression character is specified, all insignificant zeros are suppressed.
Example 9
*....5....*....6....*....7 Input String Output String
' 0' -0000123456 123456
Example 9 shows that zero suppression performs no function when it is specified in the
rightmost position. The sign is not printed, because no status is specified in the edit
word.
Example 10
*....5....*....6....*....7 Input String Output String
'0 ' +0000123456 000123456
Example 10 shows that zero suppression begins where the zero-suppression character is
specified and continues to the left.
Example 11
*....5....*....6....*....7 Input String Output String
'$ 0 &CR GROSS' 0000000000 $ 00 GROSS
'$ 0 &CR GROSS' 0000000000 $ 00 CR0GROSS
'$ 0 &CR&GROSS' 0000000000 $ 00 &GROSS
'$ 0 &CR&GROSS' 0000000000 $ 00 GROSS
The output for example 11 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Ten characters are present from the right of
the dollar sign ($) to the left of the ampersand (&). Eight zeros are suppressed. All zero
fields are positive.
The second and fourth lines show the output for RPG II. The blank between CR and
GROSS is interpreted as the last replaceable character, so CR is considered a constant
within the body and GROSS is the extension. An ampersand (&) is needed in place of the
blank between CR and GROSS to obtain the same output as in the first example.
Example 12
*....5....*....6....*....7 Input String Output String
' , , , -OLD BAL' 0000000000 OLD BAL
' , , , -OLD BAL' 0000000000 BAL
' , , , -OLD&BAL' 0000000000 OLD&BAL
' , , , -OLD&BAL' 0000000000 OLD BAL
The output for example 12 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. All 10 zeros are suppressed. Only the
extension portion of the edit word is displayed.
The second and fourth lines show the output for RPG II. The blank between OLD and
BAL is interpreted as the last replaceable character. All constants to the left of the zero-
suppression character, or the first printed digit, are suppressed. BAL is the extension. An
ampersand (&) is needed in place of the blank between OLD and BAL to obtain the same
output as RPG I.
Example 13
*....5....*....6....*....7 Input String Output String
' , 0. ' 000000 .00
Example 14
*....5....*....6....*....7 Input String Output String
' , .0 ' 000000 0
Example 15
*....5....*....6....*....7 Input String Output String
' , , 0 * ' 0000000000 0*00
Example 15 shows that the zero-suppression character is the zero. The asterisk (*) is a
constant.
Example 16
*....5....*....6....*....7 Input String Output String
'0, ,0 ' 001234 ,012,034
Example 16 shows that only the first zero of the source data is suppressed. The second
zero of the edit word is considered a constant.
Example 17
*....5....*....6....*....7 Input String Output String
' , , . -' -000000015 15-
Example 18
*....5....*....6....*....7 Input String Output String
' , , 0. -' 000000005 0.05
Example 18 shows the suppression of all insignificant zeros and punctuation to the left of
the zero-suppression character. An extra space occurs on the right side for the minus
sign (–).
Example 19
*....5....*....6....*....7 Input String Output String
' , ,$0. -' 0000000005 $0.05
Example 19 shows zero suppression along with a floating dollar sign ($). Placing the
dollar sign next to the zero-suppression character causes the currency symbol to float to
the last position that is zero-suppressed. An extra space occurs on the right side for the
minus sign (–).
Example 20
*....5....*....6....*....7 Input String Output String
' , , $0. CR**' -0012345678 $123,456.78CR**
Example 20 shows a floating dollar sign ($) with a negative amount. The edit word needs
one more replaceable position than is in the length of the source data to ensure a
position for the currency symbol when the output field is full.
Example 21
*....5....*....6....*....7 Input String Output String
'$ , , 0. ' 0000000000 $ .00
The dollar sign ($) in example 21 is not a floating dollar sign because it does not
immediately precede the zero-suppression character. All punctuation to the left of the
zero-suppression character is suppressed.
Example 22
*....5....*....6....*....7 Input String Output String
'$ &- NET' +0000123456 $ 123456 NET
'$ &- NET' +0000123456 $ 12345 -6NET
'$ &-&NET' +0000123456 $ 123456 &NET
'$ &-&NET' +0000123456 $ 123456 NET
The output for example 22 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The edit word includes zero suppression along
with a constant dollar sign ($) and an extension portion.
The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. An ampersand (&)
is needed in place of the blank between the minus sign (–) and NET to obtain the same
output as for RPG I.
Example 23
*....5....*....6....*....7 Input String Output String
'$ &- NET' -0000123456 $ 123456 NET
'$ &- NET' -0000123456 $ 12345 -6NET
'$ &-&NET' -0000123456 $ 123456 -&NET
'$ &-&NET' -0000123456 $ 123456 - NET
The output for example 23 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include zero suppression with the status
portion reporting negative.
The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. An ampersand (&)
is needed in place of the blank between the minus sign (–) and NET to obtain the same
output as for RPG I.
Example 24
*....5....*....6....*....7 Input String Output String
'$0 - NET' +0000123456 $000123456 NET
'$0 - NET' +0000123456 $000012345-6NET
'$0 -&NET' +0000123456 $000123456 &NET
'$0 -&NET' +0000123456 $000123456 NET
The output for example 24 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include both zero suppression in the high-
order position and a floating dollar sign ($).
The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. To obtain the same
output as for RPG I, an ampersand (&) is needed in place of the blank between the minus
sign (–) and NET.
Example 25
*....5....*....6....*....7 Input String Output String
' $0 &CR' -0000123456 $123456 CR
Example 25 shows a floating dollar sign ($) with the status portion reporting negative.
Example 26
*....5....*....6....*....7 Input String Output String
' $0 &CR' -1234567890 $1234567890 CR
Example 26 shows a floating dollar sign ($) with the status portion reporting negative.
Example 27
*....5....*....6....*....7 Input String Output String
' , ,$0 . NET' 0000000005 0.05 NET
' , ,$0 . NET' 0000000005 0.005NET
' , ,$0 . &NET' 0000000005 0.05&NET
' , ,$0 . &NET' 0000000005 0.05 NET
The output for example 27 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include a floating dollar sign ($) with no
status. An extra blank in the edit word after the body is used to print a space between
the body and the extension.
The second and fourth lines show the output for RPG II. The blank is interpreted as the
last replaceable character and no blank is printed. An ampersand (&) placed between the
body and the extension to obtain the same result as for RPG I.
Example 28
*....5....*....6....*....7 Input String Output String
' , , $0. ' 0000000005 $.05
Example 29
*....5....*....6....*....7 Input String Output String
' , , $0. -' -1234567890 $12,345,678.90-
Example 29 shows an edit word with a number of replaceable characters that exceeds
(by 1) the length of the field being edited so that there is enough space to print all the
digits.
Example 30
*....5....*....6....*....7 Input String Output String
' , , $0. CR' -0001234567 $12,345.67CR
Example 30 shows an edit word with a number of replaceable characters that exceeds
(by 1) the length of the field being edited so that there is enough space to print all the
digits.
Example 31
*....5....*....6....*....7 Input String Output String
' , $0, . -SALES' 0000001234 $,012.34 SALES
Example 31 shows an edit word with a number of replaceable characters that exceeds
(by 1) the length of the field being edited so that there is enough space to print all the
digits. The placement of the zero-suppression character causes undesirable results.
Example 32
*....5....*....6....*....7 Input String Output String
' , $,0 . ' 00123456 1$,234.56
Example 32 shows a dollar sign ($) and zero-suppression character that are separated;
therefore, the dollar sign is a constant in the body, not a floating dollar sign.
Example 33
*....5....*....6....*....7 Input String Output String
' , , * . &-' 0000123456 *****1,234.56
Example 33 shows that the check-protect asterisk (*) suppresses insignificant zeros and
punctuation, filling each position with an asterisk. Two extra spaces occur on the right
side, one for the ampersand (&) and one for the minus sign (–).
Example 34
*....5....*....6....*....7 Input String Output String
'* ' -0000123456 *000123456
Example 34 shows an edit word that is the same length as the field being edited, so the
asterisk (*) occupies one of the positions.
Example 35
*....5....*....6....*....7 Input String Output String
'* ' +1234567890 1234567890
Example 35 shows that the asterisk (*) is a replaceable character; when no insignificant
characters are present, it is replaced.
Example 36
*....5....*....6....*....7 Input String Output String
' *' -0000123456 ****123456
Example 36 shows that the check-protect asterisk (*) suppresses insignificant zeros and
punctuation, filling each position with an asterisk.
Example 37
*....5....*....6....*....7 Input String Output String
' , *, * ' 0000001234 ******,012*34
Example 37 shows that the check-protect asterisk (*) suppresses insignificant zeros and
punctuation, filling each position with an asterisk. The second asterisk is a constant in the
body. Placing the check-protect asterisk before the comma causes undesirable results.
Example 38
*....5....*....6....*....7 Input String Output String
'& ,* 0, ' 012345 **120,345
Example 38 shows that the ampersand (&) is for spacing and is not a replaceable
character. Check-protect asterisks (*) fill all insignificant positions. The zero is a constant
in the body.
Example 39
*....5....*....6....*....7 Input String Output String
' &CR NET' +0000123456 123456 NET
' &CR NET' +0000123456 12345 CR6NET
' &CR&NET' +0000123456 123456 &NET
' &CR&NET' +0000123456 123456 NET
The output for example 39 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The first ampersand (&) is in the status portion
of the edit word and is replaced by a blank.
The second and fourth lines show the output for RPG II. The blank between CR and NET
is interpreted as the last replaceable character. CR is assumed to be a constant within
the body, and NET is the extension. An ampersand (&) is needed in place of the blank
between CR and NET to obtain the same output as for RPG I.
Example 40
*....5....*....6....*....7 Input String Output String
' &CR NET' -0000123456 123456 CR NET
' &CR NET' -0000123456 12345 CR6NET
' &CR&NET' -0000123456 123456 CR&NET
' &CR&NET' -0000123456 123456 CR NET
The output for example 40 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The first ampersand (&) is in the status portion
of the edit word and is replaced by a blank. The status reports negative.
The second and fourth lines show the output for RPG II. The blank between CR and NET
is interpreted as the last replaceable character. CR is assumed to be a constant within
the body, and NET is the extension. The blank between CR and NET should be replaced
by an ampersand (&) to obtain the same output as for RPG I.
Example 41
*....5....*....6....*....7 Input String Output String
' &- NET' -0000123456 123456 NET
' &- NET' -0000123456 12345 -6NET
' &-&NET' -0000123456 123456 -&NET
' &-&NET' -0000123456 123456 - NET
The output for example 41 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I, which is the same as example 40, except that
a minus sign (–) is used for the status instead of CR.
The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. An ampersand (&)
is needed in place of the blank between the minus sign (–) and NET to obtain the same
result as for RPG I.
Example 42
*....5....*....6....*....7 Input String Output String
' &NET&CR' 0000123456 123456
Example 42 shows NET as part of the status, not the extension. NET is not displayed,
because the status is positive. If the order of CR and NET is reversed, then NET would
be printed regardless of the status. Extra spaces occur on the right side for &NET&CR.
Example 43
*....5....*....6....*....7 Input String Output String
' &NET CR' -0000123456 123456 NET CR
' &NET CR' -0000123456 12345 NET6CR
' &NET&CR' -0000123456 123456 NET CR
The output for example 43 depends on whether RPG I or RPG II is specified. The first line
shows the output for RPG I. NET is part of the status, not the extension. NET is
displayed because the extension reports negative. The second example shows the
output for RPG II. The blank between NET and CR is interpreted as the last replaceable
character. The blank between NET and CR should be replaced by an ampersand (&) to
obtain the same output as for RPG I. Because the ampersand (&) is placed in the status,
the last example results in identical output for RPG I and RPG II.
Example 44
*....5....*....6....*....7 Input String Output String
'$& , , . CR' -1234567890 $ 12,345,678.90CR
Example 44 shows a constant dollar sign ($). The ampersand (&) is used for spacing. The
status reports negative.
Example 45
*....5....*....6....*....7 Input String Output String
' , , *. *CR**' +0000123456 *****1,234.56 **
Example 45 shows that the first asterisk (*) indicates check-protect. The second asterisk
is part of the status. The third and fourth asterisks are the extension.
Example 46
*....5....*....6....*....7 Input String Output String
' , , *. *CR**' -0000123456 *****1,234.56*CR**
Example 46 is the same as example 45, but with the status reporting negative.
Example 47
....5....*....6....*....7 Input String Output String
'$& , , 0. &- GROSS' -1234567890 $ 12,345,678.90 GROSS
'$& , , 0. &- GROSS' -1234567890 $ 1,234,567.89 -0GROSS
'$& , , 0. &-&GROSS' -1234567890 $ 12,345,678.90 -&GROSS
'$& , , 0. &-&GROSS' -1234567890 $ 12,345,678.90 - GROSS
The output for example 47 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include a constant dollar sign ($). Leading
zeros are suppressed. The ampersands (&) are used for spacing. The status reports
negative. The extension is GROSS.
The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and GROSS is interpreted as the last replaceable character. The blank between
the minus sign (–) and GROSS should be replaced by an ampersand (&) to obtain the
same result as for RPG I.
Example 48
*....5....*....6....*....7 Input String Output String
'$& , , 0 . &-NET PAY' -1234567890 $ 12,345,678.90 -NET PAY
'$& , , 0 . &-NET PAY' -1234567890 $ 1,234,567.89 -NET0PAY
'$& , , 0 . &-NET&PAY' -1234567890 $ 12,345,678.90 -NET&PAY
'$& , , 0 . &-NET&PAY' -1234567890 $ 12,345,678.90 -NET PAY
The output for example 48 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I, which is the same as that in example 47
except that the extension contains NET PAY instead of GROSS.
The second and fourth lines show the output for RPG II. The blank between NET and
PAY is interpreted as the last replaceable character. The –NET is assumed to be a
constant within the body, and PAY is the extension. An ampersand (&) is needed
between NET and PAY to obtain the same result as for RPG I.
Example 49
*....5....*....6....*....7 Input String Output String
'$& , , *. CR' -0000123456 $ *****1,234.56CR
Example 49 shows a constant dollar sign ($). Check-protect asterisks (*) are substituted
for insignificant zeros and punctuation.
Example 50
*....5....*....6....*....7 Input String Output String
' 0 LBS.& OZ.TARE&-' +000002 0LBS. 02
Example 50 shows that the first three zeros of source data are suppressed. The fourth
zero and the constant LBS are displayed. The ampersand (&) is used for spacing, and 02
is inserted. OZ.TARE&-- is the status. Because the value is positive, the status is not
printed. Extra spaces occur on the right side for OZ.TARE& and the minus sign (–). For
more meaningful output, refer to example 51.
Example 51
*....5....*....6....*....7 Input String Output String
' 0 &LBS.& - OZ. TARE' +000002 0 LBS. 02 OZ. TARE
' 0 &LBS.& - OZ. TARE' +000002 0 LBS. 00-0OZ.2TARE
' 0 &LBS.& -&OZ.&TARE' +000002 0 LBS. 02 &OZ.&TARE
' 0 &LBS.& -&OZ.&TARE' +000002 0 LBS. 02 OZ. TARE
The output for example 51 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The intended extension portion of the previous
example is located after the status portion.
The second and fourth lines show the output for RPG II. The blanks between the minus
sign (–) and OZ and between OZ and TARE, are considered replaceable characters. An
ampersand (&) should replace the blanks in the two previously mentioned places to
obtain the same result as for RPG I.
Example 52
*....5....*....6....*....7 Input String Output String
' 0LBS. OZ.TARE&-' -000002 LBS.02OZ.TARE -
Example 52 shows that the first three zeros of the source data are suppressed. The
fourth zero and the constant LBS are displayed, and 02 is inserted. The status reports
negative. Refer to example 51 for more readable output.
Example 53
*....5....*....6....*....7 Input String Output String
' & & LATER' 031274 3 12 74 LATER
' & & LATER' 031274 31 274LATER
' & & &LATER' 031274 3 12 74&LATER
' & & &LATER' 031274 3 12 74 LATER
The output for example 53 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Leading zeros are automatically suppressed.
Ampersands (&) are used for spacing. No status portion is present.
The second and fourth lines show the output for RPG II. The value is moved into the last
blank position. An ampersand is needed before LATER to obtain the same results as for
RPG I.
Example 54
*....5....*....6....*....7 Input String Output String
' PROFIT' 0000123456 123456 PROFIT
' PROFIT' 0000123456 123456PROFIT
' &&PROFIT' 0000123456 123456&&PROFIT
' &&PROFIT' 0000123456 123456 PROFIT
The output for example 54 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Automatic zero suppression is performed. No
status is present, but there is an extension.
The second and fourth lines show the output for RPG II. The last two blanks are part of
the body, not the extension. The last two blanks should be replaced by ampersands (&)
to obtain the same results as for RPG I.
Example 55
*....5....*....6....*....7 Input String Output String
' , , . &CR NET' -0000123456 1,234.56 CR NET
' , , . &CR NET' -0000123456 123.45 CR6NET
' , , . &CR&NET' -0000123456 1,234.56 CR&NET
' , , . &CR&NET' -0000123456 1,234.56 CR NET
The output for example 55 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Automatic zero suppression is performed. The
status reports negative, and an extension is present.
The second and fourth lines show the output for RPG II. The blank between CR and NET
is interpreted as the last replaceable character. The CR is assumed to be a constant
within the body, and NET is the extension. The blank between CR and NET should be
replaced by an ampersand (&) to obtain the same result as for RPG I.
Example 56
*....5....*....6....*....7 Input String Output String
' , , DOLLARS CENTS' 0000123456 1,234DOLLARS56CENTS
Example 57
*....5....*....6....*....7 Input String Output String
' , DOLLARS CENTS' 000000 CENTS
Example 58
*....5....*....6....*....7 Input String Output String
' , 0 DOLLARS CENTS&CR' 000000 0DOLLARS00
In example 58, the first three zeros of the source data are suppressed. CENTS&CR is the
status and is not printed, because the status reports positive. Extra spaces occur on the
right side for CENTS&CR.
Example 59
*....5....*....6....*....7 Input String Output String
' - - LATER' 093074 9-30-74 LATER
' - - LATER' 093074 93-074LATER
' - - &LATER' 093074 9-30-74&LATER
' - - &LATER' 093074 9-30-74 LATER
The output for example 59 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Automatic zero suppression is performed.
The second and fourth lines show the output for RPG II. The rightmost blank is
interpreted as the last replaceable character. The last blank should be replaced by an
ampersand (&) to obtain the same result as for RPG I.
Example 60
*....5....*....6....*....7 Input String Output String
'0 - - ' 063369690 63-36-9690
Example 60 shows one method of editing a social security number. If the high-order zero
is not to be suppressed, refer to example 61.
Example 61
*....5....*....6....*....7 Input String Output String
'0 - - ' 063369690 633-69-690
'0 - - ' 063369690 063-36-9690
The output for example 61 depends on whether RPG I or RPG II is specified. The first line
shows the output for RPG I. Suppression of the high-order zero cannot be avoided.
Because RPG I considers the body to be the first n replaceable characters (where n
equals the length of the field being edited), the field is not filled on the left with an extra
zero.
The second line shows the output for RPG II. Suppression of the high-order zero can be
avoided by specifying an edit word with one extra position to the left of the body and by
placing the zero-suppression character in this position.
Example 62
*....5....*....6....*....7 Input String Output String
'0 HRS. MINS. 0''CLOCK' 0042 0HRS.42MINS. O'CLOCK
'0 HRS. MINS. 0''CLOCK' 0042 0HRS.04MINS.2O'CLOCK
'0 HRS. MINS.&0''CLOCK' 0042 0HRS.42MINS.&O'CLOCK
'0 HRS. MINS.&0''CLOCK' 0042 0HRS.42MINS. O'CLOCK
The output for example 62 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Only the high-order position is zero-
suppressed. Because the apostrophe (') is used to delimit edit words and constants, it
must be specified twice for each time it appears in the output. Insertion of additional
ampersands (&) in the body of the edit word makes the output more readable.
The second and fourth lines show the output for RPG II. The blank between the period
and the O is interpreted as the last replaceable character. The blank should be replaced
by an ampersand to obtain the same result as for RPG I.
Example 63
*....5....*....6....*....7 Input String Output String
' / / ' 093074 9/30/74
Example 63 shows a method of editing a 6-digit date field. This method is comparable to
using the Y edit code on the same field.
Example
Example 17–7 shows edit words and edit codes that produce the same formatted
output.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00500FPRINT2 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 5 132AMT1
00800I 15 222AMT2
00900I 31 360DATE
00950I 40 470AMT3
01300OPRINT1 D 01
01400O AMT1 15 ' , , 0. -'
01500O AMT2 30 ' , . CR'
01600O DATE 40 ' / / '
01700O AMT3 50 ' '
01800O*
01900O* The following detail output record produces the same results
01910O* as the detail output record above.
01920O*
01930OPRINT2 D 01
01940O AMT1 J 15
01950O AMT2 B 30
01960O DATE Y 40
01970O AMT3 Z 50
Printing Reports
An important objective of most RPG programs is generating a printed report. Producing
readable report with minimum programming is the purpose of special features and
functions that have been incorporated into the language.
One special feature includes line printer skipping. Different methods are used by RPG I
and RPG II. The distinction between RPG I and RPG II is made in either the Line Printer
Skipping field (column 46) in the Control Specification or the Source Input Dialect field
(column 51) in the Control Specification. The skip to channel option is compatible with
RPG I, and the skip to line number option is compatible with RPG II.
Forms Specifications
Both the skip to channel and the skip to line number options can use Line Counter
Specifications, carriage control tapes, or both to control the paper movement on the
printer. No check is made to ensure that the carriage control tape agrees with the
channel-line equations; this check is the user's responsibility. However, the usages and
specifications for the two options differ in several respects, as described in the following
paragraphs.
The default value for the form length is 66 lines, and the default value for the overflow
line is line 60. When these default values are acceptable, as many as 12 channel-line
equations can be specified in the Line Counter Specifications. If the default values are
not desired, the form length and overflow line must be entered in the first two sections
of the Line Counter Specifications, and only 10 channel-line equations can be specified.
In either case, every number specified in the Skip field (columns 19–22) in the Output
Specifications is assumed to be a channel number and must be equated to a line number
in the Line Counter Specifications. A syntax error is displayed if a skip to channel is
specified for a channel that does not have an associated line number.
Entries in the Skip field (columns 19–22) in the Output Specifications are line numbers.
If a channel-line equation is specified for a line number used in the Skip field, a skip to
channel operation, rather than a skip to line number operation, is performed.
Page Formatting
The definition of a page depends on the type of line printer skipping being performed.
• For the skip to channel option, a page is the potential number of lines of print,
starting at channel 1 of the carriage control tape and continuing through the line
before channel 12 of the carriage control tape.
• For the skip to line number option, a page is the potential number of print lines
between line 1 and the overflow line, inclusive.
• For the skip to channel option, the overflow area extends from channel 12 to one line
before channel 1.
• For the skip to line number option, the overflow area extends from the first line after
the overflow line to one line before line 1.
When EOP is reached during a printer operation, one of the following actions occurs:
• Automatic skipping occurs when no overflow indicator is assigned to the file in the
Overflow Indicator field (columns 33–34) in the File Specifications. Because no
overflow indicator is defined for the file, one cannot be used to condition output.
Automatic skipping moves the paper from the overflow area to the top of the next
page before resuming print operations.
The paper is moved in one of the following two ways:
− The skip to channel option moves the paper from the overflow area to channel 1.
− The skip to line number option moves the paper from the overflow area to line 6.
• Continuous printing occurs when an overflow indicator is assigned to the file (in the
Overflow Indicator field) but is not used to condition printer-file record output. The
overflow indicator is defined and can be used in the Calculation Specifications. If
used in the Output Specifications, the overflow indicator is used only to condition
field descriptions of printer files.
• Overflow operations occur when an overflow indicator is assigned to the file (in the
Overflow Indicator field) and that indicator is used to condition printer-file record
output. Using the overflow indicator to condition printer-file record output defines the
lines of print that are to be written during overflow output. Skipping based on
overflow must be requested because this skipping is not done automatically.
When overflow operations are specified, normal overflow output can be printed when
the overflow output routine in the RPG cycle is reached. If fetched overflow is specified
(F in the Fetch Overflow field, column 16 in the Output Specifications), overflow output
can be printed immediately before the record described on the line containing the F in
column 16. This output is called fetched overflow output.
Overflow Indicators
One overflow indicator and one PAGE field are allowed for each printer file. These
indicators, OA–OG and OV, are the only method of determining the status of printer files.
Overflow indicators can be used only with printer files and are not assigned by default.
The assignment of overflow indicators determines the type of paper motion and overflow
handling that occurs according to the discussion of EOP in this section.
Overflow indicators work differently for the skip to channel option and the skip to line
number option, as described next.
• When the overflow indicator is used in the Resulting Indicators field in the Calculation
Specifications, and the operation turns it off.
• When the conditions of the overflow turn-off routine are satisfied. Refer to
Example 17–7 earlier in this section.
• When the destination specified in the Skip field (columns 19–22) in the Output
Specifications is in the overflow area.
• When the destination specified in the Space field (columns 16–18) in the Output
Specifications is in the overflow area.
• When a line is printed in the overflow area.
• When the overflow indicator is used in the Resulting Indicators field (columns 54–59)
in the Calculation Specifications and is turned on by a calculation operation.
An overflow indicator turns off in the following situations:
• When the destination specified in the Skip field in the Output Specifications is a new
page, and the record is not conditioned by the overflow indicator.
• When the overflow indicator is used in the Resulting Indicators field in the Calculation
Specifications, and the operation turns it off.
• When the conditions of the overflow turn-off routine are satisfied. Refer to
Example 17–7 earlier in this section.
The overflow indicator is not turned off if a new page is reached by spacing. Refer to
Table 17–9 and Figure 16–2 for more information on overflow operations.
OVERFLOW
AREA:
Skip No effect Turns on
Space No effect Turns on
Print Turns on Turns on
NEW PAGE:
Skip No effect Turns off on a line not
conditioned by an overflow
indicator
Space No effect No effect
Print No effect No effect
Overflow
Overflow handling is performed only once for any single physical overflow, whether
fetched or performed during the normal part of the PLC when overflow processing is
performed.
The RPG program distinguishes between overflow indicators that are turned on during
detail operations and those that are turned on during total operations. If turned on during
detail operations, overflow indicators are not turned off for one full cycle. If an overflow
indicator has been turned on during detail calculations and overflow is fetched, overflow
is still performed only once.
If the program overflow specifications leave the printer in the overflow area, the cycle
does not perform the overflow processing again. To perform overflow processing again,
the program must cause another physical overflow.
The following is the sequence of printed output operations when all conditioning
indicators are satisfied:
1. The fetch overflow routine is specified for a record if the Fetch Overflow field
(column 16) contains an F. This routine can invoke the overflow routine, which in turn
can invoke the procedures listed in the following steps 2 through 7. These
procedures can be invoked as many times as required to produce all the overflow
output.
2. The skip routine is called if the Skip Before field (columns 19–20) is specified.
3. The space routine is called if the Space Before field (column 17) is designated.
4. The print routine is called.
5. The skip routine is called if the Skip After field (columns 21–22) is specified.
6. The space routine is called if the Space After field (column 18) is designated.
7. The overflow turn-off routine is called after all detail output is complete.
8. If the last record (LR) indicator is off, either of the following is called after all total
output is complete:
• The overflow routine
• The automatic skipping routine, if automatic skipping is also specified
Examples
The programs shown in Examples 17–8 and 17–9 provide two examples of overflow
coding.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 OF PRINTER
00600IFILEIN AA 01
00700I 5 132FIELD1
00800I 15 222FIELD2
01000C FIELD1 ADD FIELD2 TOTAL 102
01005O*
01010O* Skip to line number 1 before first page output.
01020O*
01100OFILEOUT H 301 1P
01102O*
01105O* Skip to line number 2 before overflow.
01106O*
01110O OR 02 OF
01200O 45 'HEADING'
01205O*
01210O* Skip to line number 4 before and to line number 1 after
01220O* total output conditioned on the last record (LR) indicator.
01230O*
Example 17–8. Using the Skip to Line Number Option for Overflow (cont.)
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01300O T 0401 LR
01305O*
01310O* Skip to line number 2 before and to line number 1 after
01320O* total output conditioned on overflow.
01330O*
01400O OR 0201 OF
01500O 45 'TOTAL'
01600O TOTAL 1 62
Example 17–8. Using the Skip to Line Number Option for Overflow
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200H 1
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 OF PRINTER
00410L*
00412L* Define the line numbers associated with each channel number.
00414L*
00450LFILEOUT 1001 4510 1302 5011 5512
00500IFILEIN AA 01
00600I 5 132FIELD1
00700I 15 222FIELD2
00800C FIELD1 ADD FIELD2 TOTAL 102
00810O*
00820O* Skip to channel 1 before first page output.
00830O*
00900OFILEOUT H 01 1P
00910O*
00920O* Skip to channel 2 before overflow.
00930O*
01000O OR 02 OF
01100O 45 'HEADING'
01110O*
01120O* Skip to channel 11 before and to channel 1 after total
01130O* output conditioned on the LR indicator.
01140O*
01200O T 1101 LR
01210O*
01220O* Skip to channel 10 before and to channel 1 after total
01230O* output conditioned on overflow.
01240O*
01300O OR 1001 OF
01400O 45 'TOTAL'
01500O TOTAL 1 62
Figure 17–6. Printer Overflow Operations for Normal and Fetched Output
If the overflow area is reached during detail calculation exception output (refer to column
1 in the preceding figure), the following actions occur:
When the overflow area is reached during total calculation exception output (see column
3 in Figure 17–6), steps 4 through 10 are performed.
When the overflow area is reached during total output (see column 4 in Figure 17–6),
steps 5 through 10 are performed.
7. Overflow output is not performed. For exceptions, refer to the following discussion
of multiple output lines.
8. Detail calculations are performed.
9. Detail output is performed.
10. The overflow indicator is turned off.
If the overflow area is reached during detail output (see column 6 in Figure 17–6)
additional steps 3 through 10 are performed.
If the overflow area is reached during total calculation exception output (see column 7 in
Figure 17–6), additional steps 5 through 10 are performed.
If the overflow area is reached during total output (see column 8 in Figure 17–6),
additional steps 6 through 10 are performed.
The system represents characters by hexadecimal (hex) values. The sequence of values
representing characters is called the normal collating sequence. Alternate Collating
Sequence Specifications explicitly modify the values of those characters and thus their
position in the collating sequence.
Table B–2 in Appendix B, “Reference Tables,” shows the EBCDIC values that can be
used for the normal collating sequence for RPG. The EBCDIC values are also used for the
translation table for RPG. Because the EBCDIC character set begins with 00 (hex) and
the hex value of any character is greater than 0 (zero), the position of a character in the
collating sequence is the decimal value of that character plus 1. For example, the
EBCDIC value of an A is 194, which has a decimal value of 193, or C1 (hex).
Note: In some cases, there are differences between the collating sequence for MCP
based systems and that of other systems. Data transferred from another system use the
hexadecimal value of the EBCDIC representation of the other system. As an example,
the differences between the MCP based systems and the IBM System/36 EBCDIC
tables are noted in Table B–2 later in this manual.
For either method, the alternate collating sequence records must follow any Output
Specifications and precede any compile-time vector records. File translation records can
immediately precede or follow alternate collating sequence records.
File translation is another way to change the EBCDIC values. For more information, refer
to Section 19, “File Translation Specifications.”
• The Collating Sequence field (column 26) in the Control Specification must contain an
S.
• Multiple sequence specifications can be entered if required. If multiple sequence
specifications are used, they must be grouped together. Only one collating sequence
can be specified for a program.
The following features are affected by an alternate collating sequence:
Table 18–1 summarizes the field definitions for the Alternate Collating Sequence
Specifications form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter S.
7 Contains an asterisk (*) if the line is a comment.
7–74 Designates the relative positions that the EBCDIC characters occupy in the
modified collating sequence.
75–80 Contains the program identification. Any entry is valid.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Field Definitions
Field definitions for the Alternate Collating Sequence Specifications are discussed in the
following paragraphs.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
• The characters specified in this field must be in the relative positions that they are to
occupy in the modified collating sequence, beginning with position 1 of that collating
sequence.
• Literals must be used to specify the characters. These literals can be numeric,
alphanumeric, or hexadecimal. The rules for the formation of literals are described in
Section 2, “RPG Language Elements.”
• Character values not specified by a literal have values greater than those specified in
the modified collating sequence. The relative order of these unspecified characters is
unchanged from the normal collating sequence.
• If a numeric literal is used, it specifies the position of a character in the normal
collating sequence. This literal must be an unsigned integer in the range 1 through
256 (the maximum number of characters in the EBCDIC character set).
• If an alphanumeric literal is used, it specifies the collating sequence position of that
character. If the value of the alphanumeric literal contains multiple characters, each
character in the literal, starting with the leftmost character, is assigned a successive
ascending position in the modified collating sequence.
• If a hexadecimal literal is used, it specifies the character with that value.
• A range of characters can be specified by placing a dash (–) between the beginning
and ending literals of the range. If a range is specified, the contiguous characters in
the character set are assigned successive ascending positions in the modified
collating sequence, beginning with the character specified by the leftmost literal and
ending with the character specified as the rightmost literal. This range can be in
either ascending or descending order. If the literal is alphanumeric, the beginning and
ending literals of the range must each contain one character.
• Two or more characters in the normal collating sequence can be assigned the same
position in the modified collating sequence by specifying the literals for each of the
characters with an ampersand (&) between them.
• No character can be assigned more than one position in the collating sequence.
Example 1
In this example, characters G and F, which have values of 200 and 199, are modified to
be the first and second characters of the collating sequence.
Example 2
The following example shows three methods for specifying the same alternate collating
sequence. The first 14 characters in the collating sequence are unchanged; however, 'H'
has a value of 15 and 'G' has a value of 16. The remaining characters then follow 'G' in
the new collating sequence.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00500S* First method
00600S*
00700S @00@ - @0D@ 'H' 'G'
00800S*
00900S* Second method
01000S*
01100S @00@ - @0D@ 'HG'
01200S*
01300S* Third method
01400S
01500S@00@ - @0D@ @C8C7@
Example 3
In the following example, the characters in positions 241 through 250 of the normal
collating sequence (that is, '0' through '9') occupy positions 1 through 10 in the modified
collating sequence.
01000S 241-250
Example 4
In the following example, characters '9' through '0', in descending order, appear in
positions 1 through 10 in the modified collating sequence.
Example 5
In the following example, the characters 'A', 'B', and 'C' occupy positions 1, 2, and 3 of
the modified collating sequence.
Example 6
In the following example, the characters in positions 12, 13, 14, and 15 of the normal
collating sequence occupy position 1 of the modified collating sequence.
Example 7
In the following example, the characters 'A' and 'B' occupy position 1 of the modified
collating sequence. The character 'C', in position 196 of the normal collating sequence,
occupies position 2 of the modified collating sequence. The character 'D' (C4 hex)
occupies position 3 of the modified collating sequence.
Example 8
Example 18–1 shows a program sample that changes the collating sequence by using
the Control Specification and the Alternate Sequence Collating Specifications. The
relative order of characters in the collating sequence is important rather than the position.
The values for '0' through '9' are equal to each other, but are less than any characters.
The new sequence makes 'b' greater than A, H less than 'i', and '9' equal to '4'.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200H S
00400FDUMMY IP F 80 80 DISK
00600FOUTPUT O 80 80 DISK
00700IDUMMY NS 01
00800I*
00900C 'bbb' COMP 'AAA' 1012
00920C EXCPT
00930C 'CHS' COMP 'CiS' 1012
00940C EXCPT
00960C '131' COMP '486' 101214
00970C EXCPT
01600OOUTPUT E
01700O 10 40 'F1 > F2'
01800O 12 40 'F1 < F2'
01889O 14 40 'F1 = F2'
01900S* The next line makes all numbers occupy position 1
01950S '0' & @F1@ & 243 & '3' & '4' & @F5@ & '6' & '7' & '8' & '9'
02000S 'a''A''b''B''c''C''d''D''e''E''f''F''g''G''h''H''i''I'
02100S 'j''J''k''K''l''L''m''M''n''N''o''O''p''P''q''Q''r''R'
02200S 's''S''t''T''u''U''v''V''w''W''x''X''y''Y''z''Z'
Example 18–1. Changing the Collating Sequence Using the Alternate Collating
Sequence Specifications
** Specifications
Following are rules for changing the collating sequence by using the ** Specifications:
• Using the ** Specifications requires using the $UNSEQ compiler control option.
When $UNSEQ is TRUE, an RPG source record is not required to have a sequence
number in columns 1 through 5. The $UNSEQ compiler control option is described
further in Section 21, “Control of the Compilation Process.”
• The Collating Sequence field (column 26) in the Control Specification must contain an
S.
• The first data record must contain two asterisks (**) followed by a blank character in
columns 1 through 3.
• The second and any additional data records must be coded as follows:
Columns Description
9–10 Must contain the hexadecimal value of the character whose normal
collating sequence is being changed.
11–12 Must contain the hexadecimal value of the character that replaces the
character in the normal collating sequence.
13–16, Can be used in the same way as columns 9 through 12 are used to fill up
17–20, the entire record with changes to the collating sequence. Blanks are not
21–24,..., allowed between the 4-position entries because the first blank ends the
93--96 record.
• More than one record can be used if the collating sequence of many characters
needs to be changed.
• A record with double asterisks (**) and then a blank character in columns 1 through 3
must follow the last record that specifies an alternate collating sequence.
• If a character is inserted between two consecutive characters, the collating
sequence must be changed for every character affected. For example, if you insert
an A between the lowercase letters a and b, then the collating sequence from b
through i must be changed.
Example
Example 18–2 shows a program sample that changes the collating sequence of the
lowercase letters a through m to take the positions of A through M; that is, lowercase a
takes the position of A, b takes the position of B, and so on.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00050H* The Control Specification must contain an S in column 26.
00060H*
00100H S
00150F*
00200F* File, Input, Calculation, and Output Specifications
**
ALTSEQ 81C182C283C384C485C586C687C788C889C991D192D2N3D394D4
**
File translation is used to alter the hexadecimal value of one or more characters of the
file. File translating often is used for file security. I/O data can be translated to protect
classified information.
Characters for an input file are translated when the file is read. Characters for an output
file are translated before the file is written. Characters for an update or combined file are
translated when the file is read and when it is written.
Table B–2 in Appendix B, “Reference Tables,” shows the EBCDIC values that can be
used for the system-defined translation table for RPG. The EBCDIC values are also used
for the normal collating sequence for RPG. Because the EBCDIC character set begins
with 00 (hex) and the value of a character must be an integer greater than 0, the value of
a character is the decimal value of that character plus 1. For example, the EBCDIC value
of an A is 194, which has a decimal value of 193, or C1 (hex).
Note: In some cases, there are differences between the MCP based systems
translation table and that of other systems. Data transferred from another system use
the hexadecimal value of the EBCDIC representation of the other system. As an
example, the differences between the MCP based systems and the IBM System/36
EBCDIC tables are noted in Table B–2.
Either of the following methods can be used to specify a user-defined file translation. A
translation table is used to change the collating sequence of a file.
Refer to Section 18, “Alternate Collating Sequence Specifications,” for more information
about changing the EBCDIC values.
• The File Translation field (column 67) in the File Specifications for this file must
contain an S.
• The File Translation field (column 43) in the Control Specification must contain an F.
Figure 19–1 shows the File Translation Specifications form.
Table 19–1 summarizes the field definitions for the File Translation Specifications coding
form.
Columns Description
An entry in a column that is not part of any of the defined fields in a specification might
cause warnings to be displayed.
Field Definitions
Field definitions for the File Translation Specifications are discussed in the following
paragraphs.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
The compiler displays a warning message if the complete table is not specified. All
unspecified characters are allocated to unused positions that are greater than the
specified positions in the table. The unspecified characters remain in the same relative
order as in the EBCDIC character sequence.
The characters are specified in the form of RPG literals. These literals can be numeric,
alphanumeric, or hexadecimal.
Numeric literals specify the ordinal position of a character in the EBCDIC character set.
This literal must be an unsigned integer in the range 1 through 256 (the maximum
number of characters in the EBCDIC character set).
A range of characters can be specified by placing a hyphen (–) between the beginning
and ending literals of the range. This range of contiguous characters in the EBCDIC
character set can be in either ascending or descending order. Specifying a range of
characters causes each character within that range of the EBCDIC character set to be
assigned a successive ascending position in the nonnative character set. If alphanumeric
literals are used, the beginning and ending literals of the range must each contain one
character.
Mapping two or more nonnative characters to one native character is allowed only for
input files. This mapping can occur if a particular native character appears two or more
times in the File Translation Specifications for an input file.
Mapping of one nonnative character to more than one native character is allowed only for
output files. Two or more characters in the EBCDIC character set can be assigned to the
same character in the nonnative character set by specifying the literals for each of the
characters with an ampersand (&) between them. No character can be specified more
than once.
For an update or combined file, the specified mapping must be a one-to-one mapping so
that the characters in the two code sets are uniquely paired.
Example 1
In the following example, the characters occupying positions 1 and 2 in the nonnative
character set from file FILE1 are reversed; that is, the characters are mapped onto
positions 2 and 1 in the native character set.
00100XFILE1 2 1
Example 2
In the following example, characters '9' through '0' in the native character set from FILE1
are associated with positions 1 through 10 in the nonnative character set.
00100XFILE1 '9'-'0'
Example 3
In the following example, characters in positions 1 through 3 of the nonnative character
set from FILEIN are mapped onto character 'A' in the native character set. Many-to-one
mappings, such as this one, are allowed only for input files.
Example 4
In the following example, characters 'A', 'B', and 'C' in the native character set for
FILEOUT are mapped onto the character associated with position 1 in the nonnative
character set. One-to-many mappings, such as this one, are allowed for output files only.
** Specifications
Following are the rules for using the ** Specifications for file translation:
• Using the ** Specifications requires using the $UNSEQ compiler control option.
When $UNSEQ is TRUE, an RPG source record is not required to have a sequence
number in columns 1 through 5. The $UNSEQ compiler control option is described
further in Section 21, “Control of the Compilation Process.”
• The file to be translated must have one of the following:
− The File Translation field (column 67) in the File Specifications for this file must
contain an S.
− The File Translation field (column 43) in the Control Specification must contain an
F.
• The first data record must contain two asterisks (**) followed by a blank character in
columns 1 through 3. The remaining columns can be used for comments. The two
asterisks are used in place of a specific coding form.
• The second and subsequent data records must contain the following:
Columns Description
1–8 To translate all files, columns 1 through 6 must contain *FILES and
columns 7 and 8 must be blank. The compiler translates all input,
output, update, and combined files.
9–10 Must contain the hexadecimal value of the EBCDIC character that is to
be replaced.
11–12 Must contain the hexadecimal value of the EBCDIC character that is
replacing the original character.
13–16, Can be used in the same way as columns 9 through 12 are used to fill
17–20, ..., the entire record with translation entries. The first blank ends the record.
93--96 If needed, more than one record can be used.
Example
In Example 19–1, the name RON is replaced by a code name JIM.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00050H* The Control Specification must contain an F in column 43.
00060H*
00100H F
00100F*
00200F* File, Input, and Calculation Specifications
00500O* Output Specifications
00600O* D9=R, D1=J, D6=O, C9=I, D5=N, D4=M
**
*FILES D9D1D6C9D5D4
A compile-time vector is loaded with data at compilation time. The data to be loaded are
read into the program memory, which is reserved by the entries in the Extension
Specifications.
Compile-time vector data are placed at the end of the source program after any Alternate
Collating Sequence or File Translation Specifications.
A loaded compile-time vector becomes a permanent part of the program so that a vector
file is not needed when the program is executed. Only vectors that do not change often
should be compiled into the program. Refer to the description of source-file maintenance
in Section 21, “Control of the Compilation Process,” for more information.
More than one compile-time vector (or pair of alternating compile-time vectors) can be
loaded.
The following entries are required in the Extension Specifications when a compile-time
vector is used:
• The Entries Per Record field (columns 33–35) must identify the maximum number of
entries that are contained in the vector.
• The From Filename field (columns 11–18) must be blank.
• The Packed field (column 43) must not contain P, J, or B because a compile-time
vector cannot be in packed or binary format.
The following list describes the vector data specification record:
• The vector data specification record can be either a Vector Data Specifications form
or an ** Specifications. The two types of vector data specification records are
described further on the following pages.
• Each set of compile-time vector data must appear in the order in which the
associated vector was specified. The data start on a new record and must be
preceded by a vector data specification record.
• The vector data are separated from the source code by a Vector Data Specifications
record. All records up to (but not including) the next Vector Data Specifications record
or EOF are loaded into the first compile-time vector (or pair of alternating compile-
time vectors) specified in the Extension Specifications.
If more records occur than are needed to load the vector, the excess records are ignored.
If fewer records occur than are needed to load the vector (that is, a short vector), any
remaining vector elements are initialized as follows:
If any set of data contains either more records or fewer records than the number
specified to fill the vector, a warning message is displayed.
The coding form for Vector Data Specifications is shown in Figure 20–1.
Table 20–1 summarizes the field definitions for the Vector Data Specifications form.
Columns Description
1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter V.
7 Contains an asterisk (*) if the line is a comment.
7–12 Contains the word VECTOR.
14–16 Controls the starting column position of the vector data. Acceptable
entries are blank or SEQ.
75–80 Contains the program identification. Any entry is valid.
An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.
Field Definitions
Following are the field definitions for the Vector Data Specifications form.
Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.
No comments can appear after the first VVECTOR record. An asterisk (*) in column 7 is
considered part of a vector data record.
Entry Description
Blank The vector data are encoded starting at the first position in each record. Only
the VVECTOR records have sequence numbers in columns 1 through 5.
SEQ The vector data are encoded in columns 6 through 80. The Sequence
Number field and the mark field are treated the same as other records of the
source program are treated.
Example 1
Example 20–1 shows the loading of three compile-time vectors.
The two lines following 11000 are used to load ARRAY1. The line following line 11500 is
used to load ARRAY2. The five lines following line 12000 load TABLE1 and TABLE2 in
alternating format. The first five characters on each line are placed in TABLE1, and the
remaining seven numbers on each line are loaded into TABLE2. Refer to Section 10,
“Extension Specifications,” for information about vectors in alternating format.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000E FILEOUT ARRAY1 2 3 4 A
05000E ARRAY2 3 3 3 1
06000E TABLE1 1 5 5 ATABLE2 7 2A
07000IFILEIN AA 01
08000I 5 80FILLER
09000OFILEOUT D 01
10000O FILLER 8
11000VVECTOR
AAAABBBB
CCCC
11500VVECTOR
111222333
12000VVECTOR
AAAAA1111111
BBBBB2222222
CCCCC3333333
DDDDD4444444
EEEEE5555555
Example 20–1. Loading Three Compile-Time Vectors Without Using the SEQ Field
Example 2
Example 20–2 shows the loading of a compile-time record when SEQ is entered on a
VVECTOR specification.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
04100E MSG 1 2 60
04200E*
04200E* Vector MSG has two 60-character alphanumeric
04400E* elements with one element per record of the source file.
05000E* :
06000E* :
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
98000VVECTOR SEQ
98100THIS LINE IS THE VALUE OF THE FIRST ELEMENT OF 'MSGS'
98200THIS LINE IS THE VALUE OF THE SECOND ELEMENT OF 'MSGS'
** Specifications
A record with ** followed by a blank character in columns 1 through 3 must precede the
data for each compile-time vector.
Example
Example 20–3 is the same as Example 20--1 except that ** Specifications are used
instead of Vector Data Specifications.
.....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000E FILEOUT ARRAY1 2 3 4 A
05000E ARRAY2 3 3 3 1
06000E TABLE1 1 5 5 ATABLE2 7 2A
07000IFILEIN AA 01
08000I 5 80FILLER
09000OFILEOUT D 01
10000O FILLER 8
**
AAAABBBB
CCCC
**
111222333
**
AAAAA1111111
BBBBB2222222
CCCCC3333333
DDDDD4444444
EEEEE5555555
This section describes the files the compiler uses during compilation, the compilation
process, the methods used to control the compilation, and the report the compiler
provides to estimate the memory it will use.
Compiler Files
The compiler files are the files the compiler uses and creates during the compilation.
The files the compiler uses for input are described in the following list:
• The CARD file is the first file the compiler reads. The function of the CARD file
depends on the setting of the MERGE compiler control option, which if used must
appear in the CARD file.
− If the MERGE option is FALSE, the compiler uses the CARD file as the symbol
file (that is, the primary input file that contains the source language input of the
program to be compiled.)
− If the MERGE option is TRUE, the compiler uses the SOURCE file as the symbol
file and the CARD file as the file that updates the SOURCE file with patches.
• The SOURCE file is the file from which the compiler reads previously stored source
records. The compiler is directed to this file when the MERGE option is TRUE.
Patches to this file appear in the CARD file.
The DEPENDENTSPECS file attribute is set to TRUE for all compiler input files. To set file
attributes that are different from the permanent file (for example, the file attribute
BLOCKSIZE), you must set DEPENDENTSPECS to FALSE.
The files the compiler uses for output are described in the following list:
• The NEWSOURCE file is the output symbol file that is created when the NEW option
is TRUE. A NEWSOURCE file can be used as a symbol file for a subsequent
compilation.
− If the MERGE option is FALSE, this symbol file is a copy of the CARD file.
− If the MERGE option is TRUE, a symbol file is created that merges the CARD file
and SOURCE file.
• The LINE file is the file the compiler generates as its output listing.
• The CODE file contains the compiled object code.
• The ERRORS file contains any source records that have syntax errors and the error
messages for those source records. If no syntax errors occur during the compilation,
no ERRORS file is produced.
− If the compiler is started with WFL and compiler file equation is not applied to
the ERRORS file, errors are written to the LINE file and no ERRORS file is
created.
− If the compiler is started with CANDE, the ERRORS file is written to the remote
station that started the compiler.
• The ERRORSOURCE file contains both the source program and the error messages
intermixed.
Table 21–1 shows the default device and the purpose of each compiler file.
Table 21–2 shows the different default values for compiler control options when a
program is compiled through CANDE or WFL. If an option is not listed, its default value is
the same for both compilation methods and is described in the discussion of the
particular option.
ERRORLIMIT 5 150
LINEINFO TRUE FALSE
LIST FALSE TRUE
Using CANDE
RPG programs can be created with the MAKE command in CANDE. Enter a command in
the following form to create and edit an RPG source program. In this example, MYFILE is
the source program, U is the UTILITY command, and EDITOR is the utility used to edit
the program.
A file can be compiled by using the COMPILE command. If a source file is created as an
RPG file as shown in the preceding example, then it can be compiled by entering the
following CANDE command:
COMPILE
Refer to the CANDE Operations Reference Manual for information about the COMPILE,
MAKE, and UTILITY commands.
Using WFL
WFL can be used to compile a program. WFL is invoked by using the WFL START
command in CANDE.
Example 1
Example 21–1 shows a WFL job that compiles a source program without editing.
Example 2
An existing RPG source file can be edited by using a file called a patch file. The patch file
contains replacement and insertion records and appropriate compiler control options.
Insertion and replacement records from the patch file are merged into the source file by
comparing the sequence entries in columns 1 through 5.
All merging is based on the EBCDIC collating sequence, which determines the results
when blank or nonnumeric sequence entries occur.
Example 21–2 shows a WFL job used to compile a source program that merges a patch
file with an existing source program.
Example 3
Example 21–3 shows a WFL job used to compile a source program that merges a patch
file with an existing source program and creates a new merged file.
Example 21–3. Compiling a Source Program That Creates a New Merged File
When a separate initiating file is used, the name and device type of the patch file must
be identified in one of the following ways:
• A file equation
• A fixed default
• Extra parameters to be included in the initiating file
Refer to the WFL Reference Manual for more information about using WFL to compile
programs.
Example 4
The TASKSTRING task attribute can be used to pass compiler control options to the RPG
compiler from a WFL job. Example 21–4 shows a WFL job using the TASKSTRING
attribute that can be used to reset the LIST compiler control option.
Refer to the Task Attributes Reference Manual for information about using the
TASKSTRING task attribute.
A CCR contains a dollar sign ($) in column 6 of the input record. Records with a dollar
sign only in column 6 are temporary CCRs. They affect only the current compilation, they
are not saved in the NEWSOURCE file, if any, and (unless the $LISTDOLLAR option is
TRUE), they are not printed in the program listing.
Records containing a dollar sign in both columns 6 and 7 are permanent CCRs. They
remain permanently associated with the language portion of the input and output files.
CCRs can appear anywhere in the source input specifications. CCRs are in free format
from column 6 through 74, so they have no standard specification form.
• A Boolean option can be set or reset by using the SET and RESET keywords. If the
option is SET, it is assigned a value of TRUE. If the option is RESET, it is assigned a
value of FALSE.
When an option is SET, the compiler applies an associated function to all subsequent
processing until the option is RESET. Boolean options can also have associated
parameters that are related to the function the Boolean option affects.
Depending on the syntax used, the status of Boolean options is determined in one of
the following three ways:
− If a Boolean option appears on a CCR without the SET or RESET keyword, then it
is implicitly assigned the value TRUE.
− If a Boolean option appears on a CCR with the SET or RESET keyword, then the
specified Boolean option is explicitly assigned the value TRUE or FALSE,
respectively.
− If the CLEAR option appears on a CCR, then all Boolean options are assigned
the value FALSE, except for the MERGE option and the NEW option.
• An immediate option causes the compiler to perform a function that is independent
of subsequent processing. Immediate options can also have associated parameters.
• The special option INCLUDE inserts source program text into the program being
compiled.
• A value option causes the compiler to store a value associated with a given function.
Example
Example 21–5 shows how CCRs are entered on a coding form. Note that Boolean
options use SET and RESET. Value, immediate, and include options do not. Also, note
that more than one option can appear on a CCR. The options specified cause the title,
NOVEMBER REPORT, to be printed at the top of each page, the compiler listing to be
double-spaced, and a page to be ejected before source listing is printed.
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100$$TITLE "NOVEMBER REPORT"
00200$$SET DOUBLE LIST
00300$$PAGE
00350H*
00400H* BEGINNING OF SPECIFICATIONS
CCR Syntax
CCRs are interpreted from left to right, beginning at the first text position following the
dollar sign ($) and continuing until the last text position.
<Boolean option>
ÄÄÂÄ<accessopen option>ÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<code option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<delete option>ÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<DMSname option>ÄÄÄÄÄÄÄÄÄ´
ÃÄ<dollarisdata option>ÄÄÄÄ´
ÃÄ<double option>ÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<eofclose option>ÄÄÄÄÄÄÄÄ´
ÃÄ<fzone option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<KEYEDIOIIOUTPUT option>Ä´
ÃÄ<lineinfo option>ÄÄÄÄÄÄÄÄ´
ÃÄ<list option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<listdeleted option>ÄÄÄÄÄ´
ÃÄ<listdollar option>ÄÄÄÄÄÄ´
ÃÄ<listincl option>ÄÄÄÄÄÄÄÄ´
ÃÄ<listomitted option>ÄÄÄÄÄ´
ÃÄ<listp option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<map option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<merge option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<new option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<omit option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<rsign option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<seq option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<statistics option>ÄÄÄÄÄÄ´
ÃÄ<summary option>ÄÄÄÄÄÄÄÄÄ´
ÃÄ<unseq option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<userdebug option>ÄÄÄÄÄÄÄ´
ÃÄ<warnfatal option>ÄÄÄÄÄÄÄ´
ÃÄ<warnsupr option>ÄÄÄÄÄÄÄÄ´
ÃÄ<xref option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ<xreffiles option>ÄÄÄÄÄÄÄÙ
<immediate option>
ÄÄÂÄ<clear option>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ<page option>ÄÄÙ
<value option>
ÄÄÂÄ<errorlimit option>ÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<errorsource option>ÄÄÄÄÄÄÄÄ´
ÃÄ<pagesize option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<sequence base option>ÄÄÄÄÄÄ´
ÃÄ<sequence increment option>Ä´
ÃÄ<target option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ<title option>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
Explanation
The first dollar sign ($) is required in column 6. If used, the second dollar sign ($) must
appear in column 7. The second dollar sign makes the option a permanent CCR.
<Boolean option>
These options have a value of TRUE or FALSE. If the option is not assigned, the default
value is used. If the option is present, the assigned value is used.
<immediate option>
These options cause the compiler to apply a function that is independent of subsequent
processing.
<value option>
These options cause the compiler to store a value associated with a given function.
SET
RESET
POP
The POP keyword discards the current value of the Boolean option and restores the
setting to its previous value.
ACCESSOPEN (Boolean)
ÄÄ ACCESSOPEN ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The ACCESSOPEN option causes files to open at the time of first access, rather than at
beginning of job (BOJ) (as specified in the PLC). Program processing occurs as if an S
had been placed in the Time of File Open field (column 52) of the Control Specification.
The ACCESSOPEN option overrides the Time of File Open field entry in the Control
Specification unless that entry is an N. If the Time of File Open field contains an N, the
ACCESSOPEN option is ignored and processing continues as if the Time of File Open
field contained a blank.
CLEAR (Immediate)
ÄÄ CLEAR ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The CLEAR option assigns the value FALSE to all Boolean options except the MERGE
option and, conditionally, the NEW option.
If a source-language record has been written to the new symbolic file (NEWSOURCE)
because the NEW option is TRUE, then the NEW option is not assigned the value FALSE.
CODE (Boolean)
ÄÄ CODE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The CODE option produces a listing of the object code. The default value is FALSE.
DELETE (Boolean)
ÄÄ DELETE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The DELETE option discards source language records from the secondary input file
(SOURCE) until the option is assigned a value of FALSE.
This option can appear only on a CCR in the primary source-language input file (CARD).
This option is ignored if the MERGE option is FALSE. The DELETE option does not alter
the normal merging process. Instead, it causes the compiler to discard all source
language records selected from the secondary input file, including CCRs.
The source-language records that are discarded when this option is TRUE are not carried
forward to the output symbolic file (NEWSOURCE) if the NEW option is TRUE. In
addition, these records are not listed unless the LISTDELETED option is TRUE.
DMSNAME (Boolean)
ÄÄ DMSNAME ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The DMSNAME option produces a listing of the data set structures for the database
declared in the Database Specification. Only those structures that are defined in the
program are listed. The LIST option must also have a value of TRUE.
DOLLARISDATA (Boolean)
ÄÄ DOLLARISDATA ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The DOLLARISDATA option causes dollar signs ($) that appear in column 6 after a vector
data specification to be treated as vector data rather than as a compiler control option.
The default value for the DOLLARISDATA option is FALSE.
DOUBLE (Boolean)
ÄÄ DOUBLE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The DOUBLE option double-spaces all printed compiler output. If no listing is produced,
then this option has no effect.
EOFCLOSE (Boolean)
ÄÄ EOFCLOSE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The EOFCLOSE option causes serial input files to close at end of file (EOF), rather than at
end of job (EOJ) (as specified in the PLC). Program processing occurs as if an S had been
placed in the Time of File Close field (column 53) of the Control Specification.
The EOFCLOSE option overrides the Time of File Close field entry in the Control
Specification unless that entry is an N. If the Time of File Close field contains an N, the
EOFCLOSE option is ignored and processing continues as if the Time of File Close field
contained a blank.
ERRORLIMIT (Value)
ÄÄ ERRORLIMIT ÄÂÄÄÄÄÄÂÄ <integer> ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ
The ERRORLIMIT option specifies the maximum number of errors that the compiler can
produce before the compilation ends.
The compiler keeps a count of the syntax errors produced; warnings are counted only
when the WARNFATAL option is TRUE. When this count exceeds the specified or
default error limit, the compilation ends.
If the error limit is exceeded, the compiler produces a listing of the errors up to the
maximum and informs the user that the compilation ended for this reason.
If the error limit is exceeded and the NEW option is TRUE, the new file being created is
purged when the compilation ends, if possible. Refer to the NEW option in this section.
The default value is 5 if the compilation is started through CANDE and 150 if the program
is started through WFL.
ERRORSOURCE (Value)
ÄÄ ERRORSOURCE ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄÄÄÄÄÂÄ <file name> ÄÙ
ÀÄ = ÄÙ
The ERRORSOURCE file contains both the program source and error messages,
intermixed. If a file name is specified, it must be quoted. The default name of the error
source file is ERRORSOURCE. If the LIST option is TRUE, errors are written to both the
error source file and the output listing file (LINE).
Error messages in the error source file have a question mark (?) in column 2 of the
record.
When the ERRORSOURCE option is assigned the value TRUE and an INCLUDE option is
encountered, the INCLUDE option is placed in the ERRORSOURCE file. Included records
are placed in the ERRORSOURCE file only if an error occurs in the INCLUDE file. Then
the record in the ERROR file is written to the ERRORSOURCE file with a question mark
(?) in column 2.
When the ERRORSOURCE option is TRUE and an OMIT option is encountered, omitted
lines are moved into the error source file, but are not compiled for syntax.
The ERRORSOURCE option cannot be specified with the MERGE option or the SEQ
option. The ERRORSOURCE option cannot be changed during compilation. Once
assigned, it stays in effect for the remainder of the compilation. The ERRORSOURCE
option can occur only in the CARD file.
When an ERRORSOURCE file is compiled, the UNSEQ option must be TRUE. The
compiler discards records with a question mark (?) in column 2.If an error occurs on a
VVECTOR line, when the ERRORSOURCE file is compiled, then the error line is
considered to be part of the vector, so it should be deleted from the file before
compilation.
FZONE (Boolean)
ÄÄ FZONE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The FZONE option indicates that external numeric data and numeric values in data
structures use an F positive zone sign.
This option applies to both right and left signed data in display format (blank in the
PACKED field) of Input or Output Specifications. If this option is FALSE, a positive zone
sign is represented with a C for external numeric data and numeric values in data
structures.
INCLUDE (Special)
ÄÄ INCLUDE ÄÂÄ<file title>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄë
ÀÄ<internal file name>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÄ<file title>ÄÙ
ëÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ%
ÀÄ<sequence number>ÄÙ ÃÄ TO ÄÂÄ<sequence number>ÄÙ
ÀÄ - ÄÄÙ
<sequence number>
ÚêÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÄÄÁÄ/5\Ä<digit>ÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The INCLUDE option suspends the merging process and accepts input from the file
specified by the parameters.
If a starting sequence number is specified, inclusion of source records begins with the
first record in the included file that has a sequence number greater than or equal to the
specified sequence number. If a starting sequence number is not specified, inclusion of
the source records begins with the first record.
If an ending sequence number is specified, inclusion of the source records ends when a
record in the included file has a sequence number greater than the specified ending
When the UNSEQ option is TRUE, the starting sequence number and/or the ending
sequence number cannot be specified in an INCLUDE option.
A file that is included can contain CCRs with INCLUDE options. This option can be nested
up to five levels.
The source-language records included when the INCLUDE option is used are listed only if
the LISTINCL option is TRUE.
The INCLUDE option can be preceded by other options, but no other options can follow it
on a line.
If the NEW option has the value TRUE, the source-language records included when the
INCLUDE option is used are not carried forward to the output symbolic file
(NEWSOURCE).
The source records from an included file are independent of the merging process.
The <file title> variable is a quoted string containing a usercode, file name, and family
statement.
KEYEDIOIIOUTPUT (Boolean)
ÄÄ KEYEDIOIIOUTPUT ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The KEYEDIOIIOUTPUT option invokes special file handling for a program that is creating
or using EFS disk files.
Following are two instances when using the KEYEDIOIIOUTPUT option is important:
• When a disk file is created by an RPG program with the KEYEDIOIIOUTPUT option
assigned the value TRUE, the disk file is created as an EFS file.
• When records are added to a disk file by an RPG program, continuation records can
be used only when the KEYEDIOIIOUTPUT option is TRUE.
The default value for the KEYEDIOIIOUTPUT option is FALSE.
LINEINFO (Boolean)
ÄÄ LINEINFO ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The LINEINFO option stores sufficient information with the object program so that the
source-language sequence number associated with a given program address can be
determined. Consequently, if a program ends abnormally, the source-language sequence
number of the ending point can be provided or easily determined.
The default value of this option is FALSE when the program is compiled through WFL
and is TRUE when compiled through CANDE.
LIST (Boolean)
ÄÄ LIST ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
LISTDELETED (Boolean)
ÄÄ LISTDELETED ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The LISTDELETED option produces a listing of any source-language input that is deleted
when the DELETE option is TRUE. The deleted source language input that is read is
identified on the listing with a D.
LISTDOLLAR (Boolean)
ÄÄ LISTDOLLAR ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The LISTDOLLAR option produces a listing of temporary CCRs encountered during the
compilation.
LISTINCL (Boolean)
ÄÄ LISTINCL ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The LISTINCL option causes the records included when the INCLUDE option is used to
be included in the printout when the LIST option is TRUE. The LISTINCL option has no
effect when the LIST option is FALSE.
LISTOMITTED (Boolean)
ÄÄ LISTOMITTED ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The LISTOMITTED option produces a listing of any source-language input that is omitted
when the OMIT option is TRUE. The LISTOMITTED option has no effect when the LIST
option is FALSE.
LISTP (Boolean)
ÄÄ LISTP ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The LISTP option produces a listing of the source-language records that appear in the
primary input file (CARD). Source-language records from the secondary input file
(SOURCE) are not listed. If the LIST option is TRUE, then the LISTP option has no effect.
MAP (Boolean)
ÄÄ MAP ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The MAP option includes in the output listing information about the allocation of variables
in the object code.
MERGE (Boolean)
ÄÄ MERGE ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÃÄÄÄÄÄÂÄ<device>ÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÀÄ , ÄÙ ³
ÀÄ ( ÄÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ ) ÄÙ
ÃÄÄÄÄÄÂÄ<device>ÄÙ
ÀÄ , ÄÙ
<device>
ÄÄÂÄ DISK ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ TAPE Ä´
ÃÄ PACK Ä´
ÀÄ CARD ÄÙ
The MERGE option merges primary source-language records (CARD) with secondary
source-language input records (SOURCE) specified by the MERGE option parameters.
Once assigned the value TRUE, this option remains TRUE throughout the compilation
and cannot be changed. An attempt to change the value of this option during a
compilation causes an error to occur. If no MERGE option parameters appear, the
SOURCE file is used.
The <file title> is a quoted string specifying the name of the file containing secondary
source-language records. If the file title is not specified, then the SOURCE file is used
unless a file equation overrides it.
The <device> is the device on which the file to be merged resides. If the device is not
specified, DISK is used unless a file equation overrides it.
NEW (Boolean)
ÄÄ NEW ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÃÄÄÄÄÄÂÄ<device>ÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÀÄ , ÄÙ ³
ÀÄ ( ÄÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ ) ÄÙ
ÃÄÄÄÄÄÂÄ<device>ÄÙ
ÀÄ , ÄÙ
<device>
ÄÄÂÄ DISK ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ TAPE Ä´
ÃÄ PACK Ä´
ÀÄ CARD ÄÙ
The NEW option begins writing all input source-language records accepted for
compilation to a new symbolic file (NEWSOURCE). These records include input records
omitted by the OMIT option and permanent CCRs, but exclude records discarded by the
DELETE option.
The NEW option remains TRUE throughout the compilation and cannot be changed. Any
attempt to change this value during compilation causes an error to occur.
The <file title> variable is a quoted string specifying the name of the symbolic file to
which accepted records are written. If the file title is not specified, then the
NEWSOURCE file is used unless a file equation overrides it.
The <device> variable is the device on which the new symbolic file is to reside. If the
device is not specified, DISK is used unless a file equation overrides it.
OMIT (Boolean)
ÄÄ OMIT ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The OMIT option causes all source-language records to be ignored, but not discarded,
during compilation. This option can appear on a CCR in either the primary (CARD) or the
secondary (SOURCE) source-language input.
The source-language records omitted when this option is TRUE are carried forward to the
output symbolic file (NEWSOURCE) if the NEW option is also TRUE.
The source-language records omitted when this option is TRUE are not listed unless the
LISTOMITTED option is also TRUE.
Any CCRs encountered in the source-language input while this option is TRUE are
processed in the normal fashion.
PAGE (Immediate)
ÄÄ PAGE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The PAGE option causes the compiler to skip to the top of the next page on the output
listing.
If the OMIT option is TRUE and the LISTOMITTED option is FALSE, then the PAGE
option is ignored.
PAGESIZE (Value)
ÄÄ PAGESIZE ÄÂÄÄÄÄÄÂÄ<integer>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ
The PAGESIZE option indicates the maximum number of lines that can appear on a page
of the output listing.
The specified page size includes the number of lines necessary for a page heading, if
any. The compiler ensures that the specified integer is large enough so that both page
headings and at least one line of text can be printed on a page.
If the compiler is unable to create an output listing with a page heading, then this option
has no effect.
RSIGN (Boolean)
ÄÄ RSIGN ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The RSIGN option causes the compiler to assume that all signs are in the low-order
(rightmost) position of numeric fields. This assumption applies only to the location of the
sign in external numeric data items and numeric fields of data structures. It does not
affect the internal storage of data. If the RSIGN option is assigned a FALSE value, all
signs are assumed to be in the high-order (leftmost) position of the field.
This option can be assigned a value of TRUE or FALSE at different points in the RPG
source program so that different fields are allowed to have different sign positions. If the
RSIGN option appears before the Control Specification, it is overridden by a valid
nonblank entry in the Sign Position field (column 17) in the Control Specification or by any
following RSIGN option. If the RSIGN option appears after the Control Specification, it
overrides any previous assignment of the sign position either by default, by another
RSIGN option, or by a valid nonblank entry in the Sign Position field.
This option remains TRUE and applies to all following source specifications until it is
assigned the value FALSE. Similarly, this option remains FALSE and relates to all
following source specifications until it is assigned the value TRUE.
SEQ (Boolean)
ÄÄ SEQ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The SEQ option assigns new sequence numbers to the source-language records
accepted for compilation.
This option assigns new sequence numbers to the NEWSOURCE file. The sequence
numbers are based on the values of the SEQUENCE BASE option and the SEQUENCE
INCREMENT option.
This option affects only input source-language records encountered by the compiler,
following the merging process. These records include those that are omitted when the
OMIT option has the value TRUE.
Sequencing occurs before the production of a new symbolic and, if the symbolic is listed,
before the source-language records are listed. If the resulting base exceeds the
sequence maximum value (99999) when the compiler increments the SEQUENCE BASE
option by the SEQUENCE INCREMENT option, then the SEQ option is assigned the value
FALSE and a sequencing error occurs.
The SEQUENCE BASE option contains the sequence number that is to be assigned to
the next source-language record when the SEQ option is TRUE. After each record is
sequenced, the value of the SEQUENCE BASE option is increased by the value of the
SEQUENCE INCREMENT option.
The value of the SEQUENCE INCREMENT option increases the value of the SEQUENCE
BASE option when records are being sequenced, because the SEQ option has the value
TRUE.
STATISTICS (Boolean)
ÄÄ STATISTICS ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ ( ÄÂÄ CPU ÄÄÄÄÄÂÄ ) ÄÙ
ÃÄ IO ÄÄÄÄÄÄ´
ÀÄ ELAPSED ÄÙ
The STATISTICS option generates code to gather and report statistics about the
execution of an RPG program.
If the STATISTICS option is TRUE when an RPG program is compiled, the statistics
report is printed automatically every time the program is run.
The following information is reported for each line of the program compiled while the
STATISTICS option is TRUE:
If the STATISTICS option has the value TRUE, then by default the elapsed time is
collected and reported. However, whether elapsed time, Central Processor Unit (CPU)
time, or I/O time should be collected can be specified explicitly the first time the
STATISTICS option is assigned a value.
The STATISTICS option can have the value TRUE around groups of specifications.
However, the statistics gathered for the first and last specifications of such a group are
not reliable. All logically related lines of an operation (for example, all the lines specifying
output fields of an output record) should be included in a group for which statistics are
collected.
SUMMARY (Boolean)
ÄÄ SUMMARY ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The SUMMARY option produces a summary of information about the compilation on the
output listing.
Since the summary produced when this option is TRUE is the same as that produced
when the LIST option is TRUE, the SUMMARY option takes effect only if the LIST option
has the value FALSE.
TARGET (Value)
ÄÄ TARGET ÄÄ = ÄÄ<primary identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄë
ÚêÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ , ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ëÄÁÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ ( ÄÄ<secondary identifier>ÄÄ ) ÄÙ
<primary identifier>
ÄÄ<target identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
<secondary identifier>
ÄÄ<target identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
This option designates a specific computer system or group of systems as the target for
which the generated object code is to be optimized. This option can be used to specify
all machines on which the code file needs to run.
The default TARGET option is installation defined. For information about how an
installation defines the default target, refer to the COMPILERTARGET command
discussion in the System Commands Operations Reference Manual.
TARGET must appear in the source program before the first record that is not a compiler
control record.
If a secondary target is specified, the compiler does not generate any operators that are
valid for the system or systems identified by the primary target but invalid for the system
or systems identified by the secondary target.
Examples
TARGET=THIS
The compiler optimizes the object code file for the system on which it is compiled.
TARGET=THIS (ALL)
The compiler optimizes the object code file for the system on which it is compiled, but it
does not generate any operators that are invalid for other machines.
TITLE (Value)
ÄÄ TITLE ÄÂÄÄÄÄÄÂÄÂÄ ' ÄÂÄÂÄ<alphanumeric literal>ÄÂÄÂÄ ' ÄÂÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ ÀÄ " ÄÙ ÀÄ<alphanumeric literal>ÄÙ ÀÄ " ÄÙ
The TITLE option stores a user-specified title to be used on all subsequent pages of the
output listing. If the compiler is unable to create an output listing with page headings, this
option has no effect.
Use of the TITLE option after the first title causes the new <alphanumeric literal>
variable to be stored and the previous title to be lost.
The alphanumeric literal is an alphanumeric string specifying the title to be used. This
literal must contain at least one character.
TITLESPERFILE (Value)
ÄÄ PAGESIZE ÄÂÄÄÄÄÄÂÄ<integer>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ
The TITLESPERFILE option indicates the maximum number of physical file titles that can
be associated to a single logical file when that logical file has the pseudo-file attribute
TITLESPERFILE = TRUE.
The TITLESPERFILE option can be used only in COMS programs. The option is applied
with the same value to all TITLESPERFILE files in the program.
The associated integer value can be any unsigned integer in the range 1 through 999.
However, a value of 1 has no effect.
The setting of the TITLESPERFILE option cannot be changed after the first source
record. The option must be set before the first control record of the source program that
is not a compiler control record. If the option is set more than once, a warning is issued
and the first option setting is applied to the program; subsequent settings are ignored.
UNSEQ (Boolean)
ÄÄ UNSEQ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The UNSEQ option causes the compiler to ignore the values in the Sequence Number
field (columns 1–5) of all records. This option and the MERGE option cannot both be
assigned the value TRUE.
The UNSEQ option is not allowed in an included file when the starting sequence number,
the ending sequence number, or both of the sequence numbers of the INCLUDE option
are designated.
USERDEBUG (Boolean)
ÄÄ USERDEBUG ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The USERDEBUG option overrides the setting of the Debug field (column 15) of the
Control Specification. The USERDEBUG option has three values: TRUE, FALSE, and
unspecified. When the value assigned is TRUE or FALSE, this option overrides the
setting of the Debug field of the Control Specifications. If the USERDEBUG option is
unspecified, the value of the Debug field of the Control Specification is used to specify
user debugging.
If the USERDEBUG option is specified, it must be specified before the first line of the
RPG program. This option cannot be altered during program compilation.
Note: This option has no effect on the linkage to the COMS library (which is also
specified in the Debug field of the Calculation Specifications).
WARNFATAL (Boolean)
ÄÄ WARNFATAL ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The WARNFATAL option counts warning messages as syntax errors. The default value is
FALSE.
WARNSUPR (Boolean)
ÄÄ WARNSUPR ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
The WARNSUPR option suppresses the printing of warning messages. The default value
is FALSE.
XREF (Boolean)
ÄÄ XREF ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ <line width> ÄÙ
The XREF option produces a cross-reference listing of the source program. If any syntax
errors occur during compilation, no cross-reference listing is created.
The <line width> can be any integer greater than or equal to 72 but less than or equal to
132. If not specified, the default value is 132.
If the LINE file has the USERBACKUPNAME option set and the compiler is calling the
XREFANALYZER utility to generate a cross-reference listing, the FILENAME of the LINE
file used by XREFANALYZER is the FILENAME of the LINE file with the node XREFLIST
appended.
XREFFILES (Boolean)
ÄÄ XREFFILES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
If any syntax errors occur during compilation, no cross-reference files are created.
• Compiler directives are used with the LIST option in the source program.
The LIST option can be specified by using the LIST compiler control option.
• All compiler directives begin with a slash (/) in column 7.
• A compiler directive can appear on any specification except the Vector Data
Specifications.
• The compiler directive itself does not appear on the printer output. It controls how
the output appears.
The three compiler directives and their uses are described in the following paragraphs:
/EJECT
A /EJECT entry causes the specifications following this compiler directive to begin on a
new page of the compiler listing. The PAGE compiler control option can also be used to
perform this function.
/SPACE n
A /SPACE n entry causes spaces to occur in the compiler listing. The number for n can
be 1, 2, or 3. A blank is required between /SPACE and the number. The value entered for
n is the number of lines to be spaced before the next line is printed. If a number for n is
not entered, 1 is assumed. If n is greater than the number of lines remaining on the
current page, the next line is printed on a new page.
If double-spacing is desired for the entire compiler listing, use the DOUBLE compiler
control option.
/TITLE
A /TITLE entry causes heading information to be printed on the compiler listing. The
heading information is specified in columns 14 through 74 of the same specification. The
heading appears at the top of each page in the compiler listing.
A program can contain more than one /TITLE entry. Each /TITLE entry provides heading
information for the compiler listing until the next /TITLE entry is specified.
A /TITLE entry must be the first record in the program for the title to begin on the first
page of the compiler listing.
The compiler prints its own heading in addition to the heading specified by the /TITLE
entry.
The TITLE compiler control option can perform the same functions as the /TITLE entry.
Memory Description
Nonoverlayable data The memory that must always be resident for a program to run,
space including 2400 bytes of working space to run the RPG support
library.
File buffer space The sum of the sizes of the buffers for all files. If all files are
open, this sum is the file buffer space that the program will use.
The file buffers for indexed files are controlled by the KEYEDIOII
library; therefore, this estimate is not valid for indexed files.
Minimum code space The size of the largest code segment in the program.
Program-dependent The sum of the nonoverlayable data space, the file buffer space,
required memory and the minimum code space.
Estimated memory The sum of the program-dependent required memory plus the
required to run overlayable data space. There is no attempt to estimate the
operating system overhead.
Unless otherwise specified, the operator can respond with any of the following when an
error message appears:
• ?<mix no>AX GO
• ?<mix no>AX STOP
• ?<mix no>AX DUMP
GO enables the program to continue. STOP causes the program to end in an orderly
manner by turning on the LR indicator and performing normal EOJ routines. DUMP
causes the program to write a dump. After the dump is done, a message is displayed.
The operator can respond to this message with either GO or STOP.
A program can be either continued or ended automatically, depending on the entry that
appears in the Run-Time Error field (column 49) in the Control Specification. When an
error occurs and the Run-Time Error field is blank, the operator must enter a valid
response for the error after the message is displayed.
Some run-time errors cause records, keys, and other data to be displayed. A maximum of
180 characters can be displayed; the first null, 00 (hex), stops the display of data.
System messages, with their causes and responses, are described in the following
paragraphs.
• This error occurs during exception output, detail output, or total output when the
user attempts to add a record randomly (using the RECNO field) to a record position
in an EFS file that does not contain a deleted record.
For example, this error occurs when
− An EFS file is not created with the DELETE-CAPABLE attribute set to TRUE.
− The record position of a record added between records of an EFS sequential file
contains a nondeleted record.
− The record position of a record added between records of an EFS direct file does
not contain a deleted record.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues, and the record is not added to the file.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.
AGAIN?
• This error message occurs when forms positioning is requested. The program
pauses to enable the operator to reposition the form.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either NO
or YES.
For information on forms positioning, see the discussion of the Forms Position field
(column 41) in Section 7, “Control Specification.”
• This error occurs when an attempt is made to modify the contents of the primary key
field of an indexed file that is being accessed sequentially by key or randomly by a
record-address file.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This error results from an attempt to initialize a COMS designator to a name that is
not recognized by COMS.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This data communication error results when a data communications file for which no
error indicator is specified is read.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues, and the operation that caused the error is
ignored.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This data communication error results when a data communications file for which no
error indicator is specified is written to.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues, and the operation that caused the error is
ignored.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.
DEADLOCK ERROR
• This error is caused by a DMSII DEADLOCK exception. The DEAD LOCK ERROR
occurs in the following conditions:
− A deadlock occurs during an attempt to lock a record or a wait on begin
transaction. The system will have automatically freed all records for the program.
− A time-out occurs during an attempt to lock a record or a wait on begin
transaction.
− A CREATE/STORE statement is attempted on a locked structure.
− The LOCKLIMIT is exceeded. Too many records in this structure are currently
loaded.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either
RETRY or STOP.
• This error occurs when a program attempts to delete a record in an EFS file that was
not the last record read. This error typically results when a program performs a READ
or a CHAIN operation that fails, but the program tries to delete the record on the
subsequent update anyway.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.
• This error results from an attempt to delete a record in one of the following cases:
− No current record is defined.
− The key value specified for the deletion does not exist in the file.
− No record was selected during this program logic cycle.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues, and the current record pointer and record
work area remain unchanged.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This error occurs when an EFS file is not delete-capable, but an attempt is made to
delete a record.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues, and the record is not deleted from the file.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
DUPLICATE KEY
• This error occurs when an attempt is made to write a record to an indexed file in
which a record with the current key already exists.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues. The new record is not written to the file, thus
maintaining the integrity of the file.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• The HALT message is displayed at the end of a program cycle if one or more halt
indicators (H0–H9) are turned on.
An Hn is displayed for each indicator that is on. Each n represents a halt indicator,
where n is a digit from 0 through 9.
GO All halt indicators are turned off, and the program continues.
STOP The LR indicator is turned on, and all final total calculations and output
are performed.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
The program can be either continued or ended automatically, depending on the entry
in the Halt Indicator field (column 50) in the Control Specification. Refer to Section 7,
“Control Specification,” for additional information.
• This error occurs when an input record from the specified file is out of sequence
according to the entries in columns 15 through 18 in the Input Specifications.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
INTEGRITY ERROR
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
• This error occurs during an ordered load of an indexed file when an out-of-sequence
record is placed in the file. A record is out of sequence when the key is less than the
key of the last record.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This error occurs when an input record from the file specified with match field values
is out of sequence. In any one file, all records with match field values must appear in
the correct match field sequence (either ascending or descending). The sequence
checking enables consecutive records to have equal match field values.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.
• This error occurs when the value of the selection variable in a CASE operation does
not match any of the case labels, and *ELSE has not been specified.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This error results if a system error is received when a file is being opened or closed.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
• This error occurs during a READ operation when the file specified reaches end of file
(EOF) and no indicator is specified in the Resulting Indicators field (columns 58–59) in
the Calculation Specifications.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This error occurs when an input record from the file specified cannot be identified;
that is, none of the codes specified in the Record Identification Codes field
(columns 21–41) in the Input Specifications for the file can be found in the input
record.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues by ignoring the record and reading the next
record from the same file. In the case of a chained file, the next
record is the one that originally caused the RECORD IDENTIFICATION
ERROR, as the key is not changed.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• When an indexed file is read using the CHAIN operation, this error occurs if the key
field of the record returned for processing (record key) does not equal the key
requested (search key).
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
SECURITY ERROR
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
• This error occurs if the Factor 2 operand for the SQRT operation is negative.
• The operator can enter one of the following responses:
Entry Definition
GO The program continues, and the Result Field (columns 43–48) in the
Calculations Specifications is set to zero (0).
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.
• This error occurs when a program refers to a vector element with an invalid
subscript. An invalid subscript is either a value less than or equal to zero (0) or greater
than the number of elements in the vector. The number of the source line causing
the error is given to identify the location of the invalid subscript.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
• This error occurs when a program tries to update an unlocked record in a file. Record-
level locking is activated by default for all EFS disk files when they are created.
Record-level locking is allowed for BFS indexed files.
Locking occurs implicitly when a record is read. If a program tries to update a record
that has not been read, then an error occurs. Allowing the update would compromise
the integrity of that record for other users of the file.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.
• This error occurs when a preexecution-time vector is loaded if the number of data
records in the specified vector file is not equal to the expected number of records.
• The operator can enter one of the following responses:
Entry Definition
GO If the vector file contains more records than the expected number, the
remainder of the file is ignored. Otherwise, all unfilled vector elements
of the vector currently being loaded are left as initialized. The program
continues with the selection of the next vector file for loading.
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.
• This error occurs when a preexecution time vector is loaded and the vector element
is out of sequence (either ascending or descending) with the previous element
loaded as specified by the entry in the Sequence field (column 45) in the Extension
Specifications.
• The operator can enter one of the following responses:
Entry Definition
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
VERSION ERROR
DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.
This appendix contains the following reference tables for EBCDIC, ASCII, and
hexadecimal (hex) character types:
• Character representation
• Bit fields
• Character values and graphics
Regarding the signs of numeric fields, the following is true:
• 8-bit characters
The sign is in the zone bits (bits 4 through 7) of the field. A bit configuration of 1101,
D (hex), indicates a negative number. Any other bit configuration indicates a positive
number.
• 4-bit digits
The sign is carried as a separate digit, the location of which depends on the sign
position of the field. A bit configuration of 1101, D (hex), indicates a negative number.
Any other bit configuration indicates a positive number.
Table B-1 shows that characters are represented for storage as values assigned to fields
of 4 or 8 bits. The Character Type column lists the valid character types. The Field Size
and Bits Used columns show the field size in bits and the maximum number of bits,
respectively, used for each type of character. The Valid Data Types column shows the
character-oriented constructs that are used to manipulate each character type.
Figures B–1, B–2, and B–3 show how the various character types are formatted in a word
of storage. Comparing Figures B–1 and B–2 shows that ASCII characters are stored in 8-
bit fields like EBCDIC characters. The zeros shown for ASCII bits 7, 15, 23, 31, 39, and 47
indicate that these bits must be 0 when ASCII characters are stored.
Table B–2 lists the 256 EBCDIC values represented in binary, octal, decimal, and
hexadecimal terms. The table also shows the corresponding ASCII and EBCDIC graphics
as they appear when printed with an EBCDIC96 print train. In the EBCDIC column, the
corresponding word appears for any nonprintable EBCDIC value.
The collating sequence can be different on different systems. As an example, the table
compares the order of characters in the IBM System/36 system collating sequence to
that of the MCP based systems by enclosing the System/36 characters in parentheses to
the right of MCP based characters when there are differences.
01010110 126 86 56 V
01010111 127 87 57 W
01011000 130 88 58 X
01011001 131 89 59 Y
01011010 132 90 5A Z ] (!)
01011011 133 91 5B [ $
01011100 134 92 5C \ *
01011101 135 93 5D ] )
01011110 136 94 5E ^ ;
01011111 137 95 5F _ ^ (or ª)
01100000 140 96 60 ` --
01100001 141 97 61 a /
01100010 142 98 62 b
01100011 143 99 63 c
01100100 144 100 64 d
01100101 145 101 65 e
01100110 146 102 66 f
01100111 147 103 67 g
01101000 150 104 68 h
01101001 151 105 69 i
01101010 152 106 6A j |
(or broken
bar)
01101011 153 107 6B k ,
01101100 154 108 6C l %
01101101 155 109 6D m _
01101110 156 110 6E n >
01101111 157 111 6F o ?
01110000 160 112 70 p
01110001 161 113 71 q
01110010 162 114 72 r
01110011 163 115 73 s
creating a BFS indexed disk file, 4-19 using Calculation Specifications, 10-17
creating a BFS sequential disk file, 4-13 using Input Specifications, 10-16
creating an alternate index file, 4-26 look-ahead field coding, 14-13
creating an EFS delete-capable direct MCPLANGS procedure, 5-76
file, 4-16 MOVEA operation, 16-19
creating an EFS direct disk file (not delete- MULT operation, 16-6
capable), 4-18 multifile processing with matching
creating an EFS direct file, 4-5 records, 14-32
creating an EFS indexed disk file, 4-21 nested structured programming
creating an EFS sequential disk file, 4-14 operations, 16-31
data communication files, 12-12 one-vector LOKUP operation, 16-77
data structure for local data area, 14-46 output indicators coding, 17-13
data structure format with repeating overflow with skip to channel option, 17-60
subfields, 14-44 packed decimal format, 4-19
DEBUG operation, 16-72 page fields, 2-12
defining subfields in data structures to PARAM operation, 16-57
overlap, 14-44 processing a BFS direct or sequential
DEFN operation, 16-73 file, 4-23
deleting a record using the DEL entry, 4-53 processing an indexed file
deleting a record using the DELET consecutively, 4-24
operation code, 4-53 processing random file using relative
deleting records from an EFS sequential or record numbers, 4-35
direct file, 4-52 processing randomly indexed file using
designating end position on Output keys, 4-37
Specifications, 17-20 processing randomly using an addrout
determining if a file is present on disk, 9-7 file, 4-40
DIV operation, 16-6 processing sequentially by key, 4-25
DO operation, 16-42 processing sequentially within limits
DO operation with increment values, 16-43 using a limits file, 4-29
DOUxx operation, 16-44 releasing a locked record with free
DOWxx operation, 16-45 operation, 4-54
DSPLY operation, 16-65 resulting indicator coding in
duplicate coding, 14-24 Calculation Specifications, 15-15
edit word and edit codes sequence checking using matching
comparisons, 17-50 records, 14-33
edit words, 17-35 sequential-within-limits
EEXSR operation, 16-57 using the SETLL operation code, 4-32
EXCPT operation, 16-66 SORTA operation, 16-80
field record relation indicators, 14-35 split control fields, 14-28
file translation coding, 19-5, 19-7 SQRT operation results, 16-9
GOTO operation, 16-29 subroutine operations, 16-53
header-trailer specification coding, 14-39 symbolic dump during program run or
IFxx operation, 16-47 compilation, 16-76
IFxx/ELSE operations, 16-48 TPLTDATTIM procedure, 5-80
Input Specifications sequence two-vector LOKUP operation, 16-77
checking, 14-5 using remote files, 12-12
L0 indicator coding, 15-6 using the ALLOCATION and EXTEND
Library Specifications coding, 13-12 attributes, 4-5
Library Specifications program, 13-13 using the DEL entry with a direct file, 4-51
Line Counter Specifications coding, 11-4 using the RECNO field with a chained
loading a noncontiguous key using a update direct file, 4-47
CHAIN operation, 4-38 using the RECNO field with a chained
loading execution-time vectors update file, 4-46
using variable-length records, 8-13 Entries per Vector (columns 36-39), 10-7
VSNESCAPE procedure, 5-89 Form Type (column 6), 10-3
VSNGETORD1 procedure, 5-92 From Filename (columns 11-18), 10-4
VSNINSPTXT procedure, 5-95 Length of Entry (columns 40-42), 10-7
VSNTRANTXT procedure, 5-98 Packed (column 43), 10-8
zero balance output, 17-26 Program Identification
ZIP operation, 16-82 (columns 75-80), 10-10
example program for accessing a 4-digit Sequence (column 45), 10-9
year, 13-20 Sequence Number (columns 1-5), 10-3
exception output To Filename (columns 19-26), 10-5
EXCPT operation, 16-65 Vector Name (columns 27-32), 10-5
Output Specifications, 17-5 vectors in, 10-11
EXCPT operation external indicators (U1-U8), 17-15
example of, 16-66 for calculation operations, 15-10
resulting indicators in, 16-66 in File Specifications, 8-30
EXSR operation, 16-54 in Output Specifications, 17-15
EXTEND file attribute, 4-5 initializing in program logic cycle (PLC), 3-3
extended file system (EFS) files, 4-1 using to show a field record
adding record to end, sequential, 4-44 relationship, 14-36
adding records between, sequential, 4-45 External Sign Handling field
adding records, direct, 4-47 in the Control Specification, 7-8
adding records, indexed, 4-48
comparison to BFS, 4-1
creating, direct, 4-16 F
creating, direct nondelete capable, 4-18
creating, indexed, 4-20 Factor 1 field in Calculation
creating, indexed delete-capable, 4-16 Specifications, 15-11
creating, sequential, 4-13 Factor 2 field in Calculation
delete-capable entry, 8-27 Specifications, 15-12
deleting from, direct, 4-52 FAULT option, use in symbolic dump, 16-76
deleting from, indexed, 4-53 fetch overflow, 17-9
deleting from, sequential, 4-52 sequence of operations, 17-64
file attributes of, 4-4, 4-12 when printed, 17-53
format of, 8-12 Fetch Overflow field in Output
full-procedural, 8-9 Specifications, 17-8
KEYEDIOIIOUTPUT option, 21-14 Field End Position field (columns 40-43)
extending files, 8-29 in Output Specifications, 17-19
Extension Code field in File use with edit codes, 17-26
Specifications, 8-21 Field Indicators field in Input
Extension Specifications, 1-4, 10-1 Specifications, 14-37
alternating format in, 10-5 field length, 2-4
coding form, 10-1 Field Length field
determining type of vector, 10-7 in Attribute Specifications, 9-6
field definitions, 10-3 in Calculation Specifications, 15-13
Alternating Vector Format allowing correct space for result, 16-8,
(columns 46-57), 10-10 16-10
Comment (column 7), 10-3 Field Location field in Input
Comments (columns 58-74), 10-10 Specifications, 14-22
Decimal Positions (column 44), 10-9 field name, 2-4
Entries per Record Field Name field
(columns 33-35), 10-6 in Input Specifications, 14-23
in Output Specifications, 17-17
Message Length (columns 64-70), 12-8 two-vector LOKUP operation, 16-77, 16-79
Message Length Identification type values
(column 63), 12-7 used in input parameters, 5-21
Program Identification
(columns 75-80), 12-8
Remote Station Identification U
(columns 41-47), 12-6
Remote Station Location Identification U1-U8 indicators, See external indicators
(column 40), 12-5 (U1-U8)
Sequence Number (columns 1-5), 12-4 UDATE, 2-10
Station Type (column 16), 12-5 in Factor 1 field, 15-11
termination routines in program logic cycle in Factor 2 field, 15-11
(PLC), 3-6 in Output Specifications, 17-17
TESTB operation, 16-27 UDAY, 2-10
TESTN operation, 16-13 in Factor 1 field, 15-11
TESTZ operation, 16-14 in Factor 2 field, 15-11
text comparison in Output Specifications, 17-17
in internationalization, 5-7 UDAYNM, 2-11
time formats in Factor 1 field, 15-11
for internationalization, 5-11 in Factor 2 field, 15-11
Time of File Close field in Output Specifications, 17-17
in the Control Specification, 7-13 UMONTH, 2-10
Time of File Open field in the Control in Factor 1 field, 15-11
Specification, 7-13 in Factor 2 field, 15-11
TIME operation, 16-81 unpacked format, 14-17
TITLE UNSEQ compiler control option, 21-23
compiler control option, 21-22 in ** Specifications, 19-6
in Attribute Specifications for libraries, 13-4 unsigned packed decimal format, 14-18
library attribute, 13-4 update file, See file, update
Title or Function Name field UPDATE UNLOCKED RECORD error
in Library Name Specifications, 13-4 message, A-14
titles on compiler listing, 21-25 USERDEBUG compiler control option, 21-23
TITLESPERFILE compiler control utility, SYSTEM/KEYEDIOII/UTILITY, 4-3
option, 21-23 UTIME, 2-11
To Filename field in Factor 1 field, 15-11
in Extension Specifications, 10-5 in Factor 2 field, 15-11
in program logic cycle (PLC), 3-6 in Output Specifications, 17-17
total calculations, 15-1 UYEAR, 2-10
in program logic cycle (PLC), 3-1, 3-6 in Factor 1 field, 15-11
total output in program logic cycle (PLC), 3-6 in Factor 2 field, 15-11
TPLTDATE CENTRALSUPPORT library in Output Specifications, 17-17
procedure, 5-78
TPLTDATTIM CENTRALSUPPORT library
procedure, 5-80 V
example of, 5-80
TPLTTIME CENTRALSUPPORT library
value compiler control options, 21-7
procedure, 5-82
value reference in PARAM operation, 16-55
translate table, See mapping table
Value/Reference field
translating data, 19-1
in Library Parameter Specifications, 13-8
Translation Table field
Variable Name field
in File Translation Specifications, 19-3
in Attribute Specifications, 9-5
truthset, 5-6
in Input Specifications, 14-23
definition of, 5-6
Y Symbols
year value, with 4 digits, accessing, 13-20 $CANCELLIB for library linkage control, 13-10
$DELINKLIB for library linkage control, 13-10
$KEYEDIOIIOUTPUT file attribute in disk
Z files, 4-4
$LINKLIB for library linkage control, 13-10
Z (zone) portion of C/Z/D field in Input $RSIGN option for sign conversion in CHAIN
Specifications, 14-16 operation, 16-60
Z-ADD operation, 16-11 $SETNAME for library linkage control, 13-10
Zero balance option, 17-26 ** Specifications
ZERO figurative constant, 2-6 use for vector loading, 20-7
zero suppression with edit words, 17-35 use in alternate collating, 18-8
Zero/Blank Indicator Setting field use with File Translation, 19-6
in Control Specification, 17-19 use with UNSEQ, 19-6
in program logic cycle (PLC), 3-3 *BLANK figurative constant, 2-6
zero/blank indicator, when on, 17-19 *BLANKS figurative constant, 2-6
ZEROS figurative constant, 2-6 *ELSE label, 16-38
ZIP operation, 16-81 *IN alias, 2-14
Z-SUB operation, 16-11 *INxx alias, 2-13
*LIKE field in DEFN operation, 16-73
*PLACE, 2-15, 17-23
*ZERO figurative constant, 2-6
*ZEROS figurative constant, 2-6
/EJECT, 21-25
/SPACE, 21-25
/TITLE, 21-25
1P indicator, 17-15
in program logic cycle (PLC), 3-3
*86000544-103*
8600 0544–103