SC21 7667 4_System_34_RPG_II_Reference_Manual_Jan82 4 System 34 RPG II Reference Manual Jan82

SC21-7667-4_System_34_RPG_II_Reference_Manual_Jan82 manual pdf -FilePursuit

SC21-7667-4_System_34_RPG_II_Reference_Manual_Jan82 SC21-7667-4_System_34_RPG_II_Reference_Manual_Jan82

User Manual: SC21-7667-4_System_34_RPG_II_Reference_Manual_Jan82

Open the PDF directly: View PDF PDF.
Page Count: 703

DownloadSC21-7667-4_System_34_RPG_II_Reference_Manual_Jan82 SC21-7667-4 System 34 RPG II Reference Manual Jan82
Open PDF In BrowserView PDF
-- - - ------- - ------

--

5C21 -7667-4
File No. 534-28

•

IBM System/34

RPG II
Reference Manual
Program Number 5726-RG 1

--- - - -------- - - ---... -

SC21-7667-4
File No. S34-28

•

IBM System/34
RPG II
Reference Manual
Program Number 5726-RG 1

Fifth Edition (January 1982)
This is a major revision of, and obsoletes, SC21-7667-3 and technical newsletter
SN21-8136. Chapter 10 has been reorganized to place the operation codes in
alphabetical order. New operation code diagrams have also been added. Other
changes or additions to the text and illustrations are indicated by a vertical line to
the left of the change or addition.
This edition applies to release 8, modification 0 of IBM System/34 RPG II
Program Product (Program 5726-RG1), and to all subsequent releases and
modifications until otherwise indicated in new editions or technical newsletters.
Changes are periodically made to the information herein; changes will be reported
in technical newsletters or in new editions of this publication.
It is possible that this material may contain reference to, or information about,
IBM products (machines and programs), programming, or services that are not
announced in your country. Such references or information must not be construed
to mean that IBM intends to announce such IBM products, programming, or
services in your country. (For example, ideographic support is available only in Far
East countries.)
This publication contains examples of data and reports used in daily business
operations. To illustrate them as completely as possible, the examples include the
names of individuals, companies, brands, and products. All of these names are
fictitious and any similarity to the names and addresses used by an actual
business enterprise is entirely coincidental.
.
Use this publication only for the purposes stated in the Preface.
Publications are not stocked at the address below. Requests for copies of IBM
publications and for technical information about the system should be made to
your IBM representative or to the branch office serving your locality.
This publication could contain technical inaccuracies or typographical errors. Use
the Reader's Comment Form at the back of this publication to make comments
about this publication. If the form has been removed, address your comments to
IBM Corporation, Publications, Department 532, Rochester, Minnesota 55901.
Comments become the property of IBM.
IBM may use and distribute any of the information you supply in any way it
believes appropriate without incurring any obligation whatever. You may, of
course, continue to use the information you supply.

© Copyright International Business Machines Corporation 1977, 1978, 1979,
1980, 1982

Preface

PURPOSE OF THE MANUAL
The RPG II reference manual aids the programmer in
writing RPG II programs for the IBM System/34. The
manual describes the program documentation the
programmer needs to write, test, and maintain RPG II
programs. Using this manual, the programmer can:
• Use the detailed reference material to code, compile,
and debug RPG II application programs
• Use the detailed reference material to implement
RPG II functions such as work station support, data
structuring, and display format generation
• Use the information as a guide to the RPG II program
cycle
• Achieve more efficient use of disk and main storage
and more efficient program execution

MAJOR TOPICS
The following chapter descriptions summarize the major
topics discussed in this manual:
• Chapter 1 describes the RPG II program cycle, briefly
describes the indicators that can be used to change
the program cycle, and provides an overview of the
RPG II specifications.
• Chapters 2 through 9 provide a column-by-column
description of the RPG II specifications in the order
they are used:
Control
File description
Extension
Line counter
Telecommunications
Input
Calculation
Output
Each column description includes a list of possible
entries, a general discussion of column use,
considerations for all possible entries, a specific
discussion of each entry, and, where pertinent, charts
and examples.

• Chapter 10 provides a detailed explanation of the
operation codes used on the calculation
specifications.
• Chapter 11 describes how records are selected for
processing in multifile processing and how match
field values are assigned.
• Chapter 12 describes the special considerations for
using the CONSOLE device in an RPGII program.
When the CONSOLE device is specified in an RPG II
program, the operator can enter data from a display
station directly into an executing RPG II program.
• Chapter 13 describes the special considerations for
using a WORKSTN (display station) device in an
RPG II program. When a WORKSTN device is
specified, an RPG II program can receive input data
from, and write output data to, one or more display
stations. Sample programs that use the WORKSTN
device are included in Chapter 13.
• Chapter 14 describes how to create, define, and load
tables and arrays for an RPG II program.
• Chapter 15 describes the RPG II auto report function,
which can reduce the coding required for similar
programs and which can produce formatted reports.
• Chapter 16 presents programming considerations that
can help the programmer save storage and improve
performance.
• Chapter 17 presents a detailed description of the
RPG II program logic cycle.
• Chapter 18 describes the command statements '
required to compile and execute an RPG II program.
• Chapter 19 contains sample RPG II programs. These
include the specifications and the printed output for
the programs. Chapter 13 contains sample programs
for the WORKSTN device.
• Chapter 20 describes the support provided for the
processing of ideographic data.

iii

• Appendix A includes summary charts for the
specification sheets, for the operation codes, for the
indicators, and for the display screen format Sand D
specifications.

• IBM System/34 Displayed Messages Guide,
SC21-5159
• IBM System/34 Screen Design Aid Programmer's
Guide and Reference Manual, SC21-7716

• Appendix B contains the RPG and auto report printed
messages that are generated by the compiler.

• IBM System/34 Master Index, SC21-7739

• The glossary provides a list of RPG II terms and their
definitions.

• IBM System/34 Interactive Communications Feature
Reference Manual, SC21-7751

SYSTEM REQUIREMENTS

The System/34 Introduction includes a Publications
Summary that contains a brief description of the
contents of each of the System/34 system publications.

See the IBM System/34 Planning Guide, GC21-5154, for
the system requirements for the System/34 RPG II
Compiler.

RPG II Coding and Debugging Material

The System/34 RPG II compiler provides ideographic
support when used with the ideographic version of the
SSP and the ideographic hardware devices that version
supports.

• RPG Control and File Description Specifications,
GX21-9092

RELATED PUBLICATIONS

• RPG Telecommunications Specifications, GX21-9116

• IBM System/34 Introduction, GC21-5153

• RPG Input Specifications, GX21-9094

• IBM System/34 Planning Guide, GC21-5154

• RPG Calculation Specifications, GX21-9093

• IBM System/34 System Support Reference Manual,
SC21-5155

• RPG Output Specifications, GX21 -9090

• RPG Extension and Line Counter Specifications,
GX21-9091

• RPG Auto Report Specifications, GX21-9139
• IBM System/34 Concepts and Design Guide,
SC21-7742
• IBM System/34 Source Entry Utility Reference
Manual, SC21-7657
• IBM System/34 Data Communications Reference
Manual, SC21-7703 ~
~<...

IBM Introduction

to RPG 1/, GC21-7514

• IBM System/34 Installation and Modification Reference
Manual: Program Products and Physical Setup,
SC21-7689

• RPG Indicator Summary, GX21-9095
• RPG Debugging Template, GX21-9129
• Translation Table and Alternate Collating Sequence
Coding Sheet, GX21-9096
• System/34 Display Screen Format Specifications,
GX21-9253
• IBM 5251 Display Station Keyboard Template
Assignment Sheet and Display Screen Layout Sheet,
GX21-9271

• IBM System/34 Operator's Guide, SC21-5158

(
iv

Contents

CHAPTER 1. INTRODUCTION
RPG II Functions . . . . . . .
Steps in Using RPG II . . . . .
Overview of Specification Sheets
Control Specifications. . . .
File Description Specifications
Extension Specifications. . .
Line Counter Specifications .
Telecommunications Specifications
Input Specifications
Calculation Specifications
Output Specifications .
How RPG II Works . . .
RPG II Program Cycle.
Indicators . . . . .
Common Entries
Columns 1-2 (Page)
Columns 3-5 (Line) .
Column 6 (Form Type)
Column 7 (Comments)
Columns 7-12 (/EJECT)
Columns 7-12 (/TITLE)
Columns 7-14 (/SPACE)
Columns 75-80 (Program Identification)

1-1
1-1
1-1
1-4
1-4
1-4
1-4
1-4
1-4
1-5
1-5
1-5
1-5
1-5
1-9
1-12
1-12
1-13
1-13
1-13
1-13
1-13
1-14
1-14

CHAPTER 2. CONTROL SPECIFICATIONS.
Columns 1-2 (Page) .
Columns 3-5 (Line) . . . . .
Column 6 (Form Type) . . . .
Columns 7-9 (Size To Compile)
Column 10 (Object Output) . .
Column 11 (Listing Options)
Columns 12-14 (Size to Execute)
Column 12
Columns 13 and 14 .
Column 15 (Debug) . .
Columns 16-17 . . . .
Column 18 (Currency Symbol)
Columns 19-20 (Date Option) .
Column 19 (Date Format)
Column 20 (Date Edit)
Column 21 (Inverted Print) .
Columns 22-25 . . . . . .
Column 26 (Alternate Collating Sequence)
Columns 27-36 . .
Column 37 (Inquiry) . . . . . . . .
File Sharing . . . . . . . . . .
Inline Inquiry Subroutine (SUBR95)
Columns 38-40 . . . . . . .
Column 41 (1 P Forms Position)
Column 42 . . . . . . . - .
Column 43 (File Translation) .
Column 44 . . . . . . . . .
Column 45 (Nonprint Characters)
Columns 46-47 . . . .
Column 48 (Shared I/O) . . . .
Columns 49-51 . . . . . . . .
Columns 52-53 (Number of Formats)

2-1
2-1
2-1
2-1
2-2
2-2
2-2
2-2
2-2
2-2
2-3
2-3
2-3
2-3
2-3
2-3
2-4
2-4
2-4
2-9
2-9
2-10
2-10
2-11
2-11
2-11
2-11
2-14
2-14
2-14
2-14
2-14
2-14

Columns 54-56 . . . . . . .
Column 57 (Transparent Literal)
Columns 58-74 . . . . . . .
Columns 75-80 (Program Identification)

2-15
2-15
2-15
2-15

CHAPTER 3. FILE DESCRIPTION SPECIFICATIONS
Columns 1-2 (Page) .
Columns 3-5 (Line)
Column 6 (Form Type) . .
Columns 7-14 (Filename) .
Column 15 (File Type)
Input Files.
Output Files . .
Update Files . .
Combined Files
Column 16 (File Designation)
Primary Files. .
Secondary Files
Chained Files
Record Address Files
Table or Array Files .
Demand Files .
Column 17 (End of File)
Column 18 (Sequence) .
Column 19 (File Format)
Columns 20-23 (Block Length)
Columns 24-27 (Record Length)
Column 28 (Mode of Processing)
Consecutive . . . . . .
Sequential by Key . . . . .
Sequential Within Limits
Random by Relative Record Number or Key
Random by Addrout File . . . . . . . .
Shared File Considerations . . . . . . .
Columns 29-30 (Length of Key Field or Record
Address Field) . . . . . . . . . . . .
Column 31 (Record Address Type)
Column 32 (File Organization or Additional
Input/Output Area). . . . . .
File Organization . . . . . .
Additional Input/Output Area
Addrout Files . . . . . . .
Columns 33-34 (Overflow Indicator)
Automatic Overflow . . . . .
Overflow Indicator Specified . .
Columns 35-38 (Key Field Starting Location)
Column 39 (Extension Code)
Columns 40-46 (Device)
BSCA . .
CONSOLE
CRT
DISK . .
KEYBORD
PRINTER
WORKSTN
SPECIAL Device Support
Reading and Updating a Work Station
Utility Transaction File (SUBR22) . .

3-1
3-1
3-1
3-1
3-2
3-2
3-2
3-2
3-2
3-4
3-4
3-4
3-4
3-5
3-5
3-5
3-5
3-6
3-6
3-6
3-7
3-7
3-8
3-9
3-9
3-10
3-11
3-17
3-17

Contents

3-17
3-19
3-20
3-20
3-22
3-28
3-28
3-28
3-28
3-29
3-29
3-29
3-30
3-30
3-32
3-33
3-33
3-33
3-33
3-33
3-37

v

System Input Subroutine for SPECIAL Device
(SUBR01) . . . . . . . . . . . . . . .
1255 MICR Subroutine (SUBR08 and SUBR25)
Columns 47-52 . . . . . . . . .
Column 53 (Continuation Lines-K)
Columns 54-59 . . . . . . . . .
Name of Label Exit . . . . . .
Continuation Line Option for SPECIAL Device
Continuation Line Options for WORKSTN File
Continuation Line Keyword Option
Columns 60-65 (Storage Index) . . . . .
. Column 66 (File Addition) . . . . . . .
Adding Records to an Indexed File (A)
Adding Records to Delete-Capable Direct
and Sequential Files . . . . . . . . .
Extending a Sequential File . . . . . .
Loading Records in an Unordered Sequence (U)
File Addition Functions for Indexed Files
File Addition Functions for Sequential
Files (File Extension) . . . . . . . . .
Random File Addition Functions for DeleteCapable Direct and Sequential Files
Column 67 . .
Columns 68-69 . . . . . . .
Column 70 . . . . . . . . .
Columns 71-72 (File Condition)
Columns 73-74 . . . . . . .
Columns 75-80 (Program Identification)
File Description Charts. .
How to Use the Charts . . . . . .
CHAPTER 4. EXTENSION SPECIFICATIONS.
Columns 1-2 (Page) .
Columns 3-5 (Line)
Column 6 (Form Type)
Columns 7-10
Columns 11-18 (From Filename)
Columns 19-26 (To Filename). .
Columns 27-32 (Table or Array Name)
Table Name . . . . . . . . . .
Array Name . . . . . . . . . .
Columns 33-35 (Number of Entries Per Record)
Columns 36-39 (Number of Entries Per Table
or Array) . . . . . . . . . . .
Columns 40-42 (Length of Entry) .
Column 43 (Packed or Binary Field)
Column 44 (Decimal Positions)
Column 45 (Sequence) . . .
Columns 46-57 . . . . . . .
Columns 58-74 (Comments)
Columns 75-80 (Program Identification)
CHAPTER 5. LINE COUNTER SPECIFICATIONS
Columns 1-2 (Page) .
Columns 3-5 (Line)
Column 6 (Form Type) . .
Columns 7-14 (Filename) .
Columns 15-17 (Line Number-Number of Lines
Per Page) . . . . . . . . . . . . . . .
Columns 18-19 (Form Length) . . . . . .
Columns 20-22 (Line Number-Overflow Line)
Columns 23-24 (Overflow Linel . . . .
Columns 25-74 . . . . . . . . . . .
Columns 75-80 (Program Identification)

vi

3-45
3-45
3-45
3-45
3-46
3-46
3-46
3-47
3-49
3-49
3-51
3-51
3-52
3-52
3:"56
3-56
3-56
3-56
3-56
3-56
3-56
3-57
3-57
3-57
3-57
3-57

4-1
4-2
4-2
4-2
4-2
4-2
4-2
4-3
4-3
4-3
4-3
4-5
4-6
4-6
4-6
4-8
4-8
4-10
4-10

5-1
5-1
5-1
5-1
5-2
5-2
5-2
5-2
5-2
5-2
5-2

CHAPTER 6. TELECOMMUNICATIONS
SPECIFICATIONS .
Columns 1-2 (Page) .
Columns 3-5 (Line)
Column 6 (Form Type)
Columns 7-14 (Filename) .
Column 15 (Configuration)
Column 16 (Type of Station)
Column 17 (Type of Control)
Column 18 (Type of Code)
Column 19 (Transparency)
Column 20 (Switched) . .
Columns 21-31 . . . . .
Column ::12 (Location of Identification-This Station)
Columns 33-39 (Identification-This Station)
Column 40 (Location of Identification-Remote Station) .
Columns 41-47 (Identification-Remote Station)
Columns 48-51 . . . . . . . . . . . . .
Column 52 (lTB) . . . . . . . . . . . .
Columns 53-54 (Permanent Error Indicator) .
Columns 55-57 (Wait Time) . . . . . . .
Columns 58-59 (Record Available Indicator)
Column 60 (Last File) . . . . . . . .
Columns 61-62 (Polling Characters) . .
Columns 63-64 (Addressing Characters)
Columns 65-74 . . . . . . . . . . .
Columns 75-80 (Program Identification)
File Description Specifications for BSCA Files .
Columns 7-14 (Filename)
Column 15 (File Type)
Column 16 (File Designation)
Column 17 (End of File) . . .
Column 19 (File Format). . .
Columns 20-23 (Block Length)
Columns 24-27 (Record Length)
Column 32 (File Organization or Addition I/O Area) .
Columns 40-46 (Device) . .. . . . . .
CHAPTER 7. INPUT SPECIFICATIONS
FILE AND RECORD-TYPE IDENTIFICATION ENTRIES
Columns 1-2 (Page) .
Columns 3-5 (Line)
Column 6 (Form Type) .
Columns 7-14 (Filename) .
Columns 14-16 . . . . .
Columns 15-16 (Sequence)
Assigning Sequence Numbers
Column 17 (Number) . . . . .
Column 18 (Option) . . . . . .
Display Station Local Data Area
Columns 19-20 (Record Identifying Indicator, **,DS) .
Record Identifying Indicators
Look-Ahead . . . . . . . . . . . . .
Data Structures . . . . . . . . . . .
Columns 21-41 (Record Identification Codes)
Position (Columns 21-24, 28-31, and 35-38)
Not (N) (Columns 25, 32, and 39)
C/Z/D (Columns 26, 33, and 40) . .
Character (Columns 27, 34, and 41)
AND Relationship
OR Relationship
Column 42 . . . . .

6-1
6-2
6-2
6-2
6-2
6-2
6-2
6-2
6-2
6-3
6-3
6-3

6-1
6-3
6-3
6-4
6-4
6-4
6-4
6-5
6-5
6-6
6-6
6-6
6-6
6-6
6-6
6-6
6-6
6-7
6-7
6-7
6-7
6-7
6-7
6-7

7-1
7-2
7-2
7-2
7-2
7-2
7-2
7-2
7-2
7-6
7-6
7-6
7-7
7-7
7-10
7-17
7-22
7-23
7-23
7-23
7-23
7-24
7-24
7-24

FIELD DESCRIPTION ENTRIES . .
Column 43 (Packed or Binary Field)
Zoned Decimal Format (Blank)
Packed Decimal Format (P)
Binary Format (B)
Columns 44-51 (Field Location)
Column 52 (Decimal Positions)
Columns 53-58 (Field Name) .
Field Names . . . . . . .
Special Words (PAGE, PAGE1-PAGE7)
Columns 59-60 (Control Level) . . .
Assigning Control Level Indicators
Split Control Fields . . . . .
Columns 61-62 (Matching Fields)
Match Fields. . . . . . . .
Sequence Checking . . . . .
Columns 63-64 (Field Record Relation) .
Record Identifying Indicators (01-99)
Control Level (Ll-L9), Matching Record (MR),
and External (U1-U8) Indicators.
Halt Indicators (H1-H9) . . . . . . .
Columns 65-70 (Field Indicators)
Assigning Indicators in Columns 65-70
Numeric Indicators (01-99)
Halt Indicators (H1-H9) . . . . . .
Columns 71-74 . . . . . . . . . . .
Columns 75-80 (Program Identification)

7-26
7-26
7-26
7-27
7-29
7-30
7-31

CHAPTER 8. CALCULATION SPECIFICATIONS
Columns 1-2 (Page) .
Columns 3-5 (Lines) . . . .
Column 6 (Form Type) . . .
Columns 7-8 (Control Level)
Control Level Indicators (LO, Ll-L9) .
Last Record Indicator (LR) .
Subroutine Lines (SR) .
AND/OR Lines (AN, OR) .
Columns 9-17 (I ndicators)
Field Indicators (01-99)
Command Key Indicators (KA-KN, KP-KY) .
Record Identifying Indicators (01-99)
Resulting Indicators (01-99) . .
Control Level Indicators (Ll-L9)
Last Record Indicator (LR). . .
Matching Record Indicator (MR)
Halt Indicators (H1-H9) . . . .
External Indicators (U1-U8) . .
Overflow Indicators (OA-OG, OV)
Relationship Between Columns 7-8 and
Columns 9-17 . . . . . . . . . .
Columns 18-27 (Factor 1) and Columns 33-42
(Factor 2) . . . . . . .
Literals . . . . . . .
Columns 28-32 (Operation)
Columns 31-32 . . . . .
Columns 43-48 (Result Field)
Erase . . . . . . . . ..
Field Name, Table Name, Array Name, Array
Element, or Data Structure . . . . . . . .

8-1
8-2
8-2
8-2
8-2
8-3
8-3
8-6
8-6
8-6
8-6
8-6
8-6
8-11
8-11
8-11
8-11
8-11
8-11
8-11

7-31
7-31

Columns 49-51 (Field Length) .
Column 52 (Decimal Positions)
Column 53 (Half Adjust) . . .
Columns 54-59 (Resulting Indicators)
Test Results . . . . . . . . . .
Allowing Command Keys to be Pressed (SET)
Setting Indicators (SETON, SETOF) .
Columns 60-74 (Comments) . . . . .
Columns 75-80 (Program Identification)

8-21
8-22
8-22
8-23
8-23
8-25
8-25
8-25
8-25

CHAPTER 9. OUTPUT SPECIFICATIONS
Columns 1-2 (Page) .
Columns 3-5 (Line)
Column 6 (Form Type) . .
Columns 7-14 (Filename) .
Columns 14-16 (AND/OR)
Column 15 (Type) . . .
Heading Records (H)
Detail Records (D) .
Total Records (T). .
Exception Records (E) .
Columns 16-18 (ADD/DEL)
ADD . . . . . . . . .
DEL . . . . . . . . .
Column 16 (Fetch Overflow or Release)
Fetch Overflow . . . . . . . . .
Release . . . . . . . . . . . . .
Columns 17-22 (Spacing and Skipping)
Column 17 (Space Before). .
Column 18 (Space After)
Columns 19-20 (Skip Before)
Columns 21-22 (Skip After) .
Columns 23-31 (Output Indicators)
AND and OR Lines . . . . . .
Command Key Indicators (KA-KN, KP-KY) .
Overflow Indicators (OA-OG, OV)
First Page Indicator (1 P)
Halt Indicators (H1-H9) . .
External Indicators (U1-U8)
Columns 32-37 (Field Name)
Field Names . . . .
Special Words . . .
Column 38 (Edit Codes)
Column 39' (Blank After)
Columns 40-43 (End Position in Output Record)
Column 44 (Packed or Binary Field) . .
Columns 45-70 (Constant or Edit Word)
Constants . .
Format Name
Edit Codes
Edit Words .
Columns 71-74 .
Columns 75-80 (Program Identification)

9-1
9-2
9-2
9-2
9-2
9-2
9-2
9-2
9-2
9-2
9-2
9-4
9-4
.9-4
9-5
9-5
9-5
9-6
9-6
9-6
9-6
9-6
9-8
9-8
9-11
9-11
9-13
9-13
9-13
9-13
9-13
9-17
9-21
9-22
9-22
9-26
9-26
9-26
9-28
9-28
9-28
9-37
9-37

7-32

7-34
7-34
7-36
7-36
7-36
7-39
7-39
7-43
7-43
7-43
7-43
7-45
7-45
7-45
7-45
7-45

8-11
8-12
8-12
8-19
8-19
8-20
8-20
8-20

Contents

vii

CHAPTER 10. OPERATION CODES . . . . . . . . . 10-1
Arithmetic Operations
10-4
Move Operations . . . . . . .
10-4
Move Zone Operations. . . . .
10-5
Compare and Testing Operations
10-5
Bit Operations . . . . . . .
10-5
10-5
SETON and SETOF Operations
10-6
Branching Within RPG II . . .
10-6
Subroutine Operations . . . .
10-6
Linking to External Subroutines
WORKSTN Operations . . . .
10-6
Programmed Control of Input and Output.
10-6
ALPHABETIZED OPERATION CODES
10-7
ACO (Acquire) . . . . .
10-7
ADD (Add) . . . . . . .
10-7
BEGSR (Begin Subroutine)
10-7
BITOF (Set Bits Off)
10-8
BITON (Set Bits On)
10-8
CHAIN (Chain)
10-11
COMP (Compare) .
10-13
DEBUG (Debug). .
10-15
Records Written for DEBUG
10-15
DIV (Divide) . . . . . .
10-16
ENDSR (End Subroutine) . . .
10-16
EXCPT (Exception Output)
10-16
EXIT (Exit to an External Subroutine) .
10-18
EXSR (Execute Subroutine)
10-19
Coding Subroutines
10-19
FORCE (Force)
10-19
GOTO (Branch To) .
10-22
KEY (Key)
10-25
LOKUP (Lookup)
10-30
LOKUP With One Table
10-31
LOKUP With Two Tables
10-31
Referencing the Table Element
Found in a LOKUP Operation
10-32
Using the LOKUP Operation with Arrays.
·10-32
MHHZO (Move High to High Zone)
10-38
MHLZO (Move High to Low Zone) .
10-38
MLHZO (Move Low to High Zone) .
10-38
MLLZO (Move Low to Low Zone)
10-38
MOVE (Move)
10-38
MOVEA (Move Array)
10-40
MOVEL (Move Left) .
10-43
MULT (Multiply). . .
10-45
MVR (Move Remainder)
10-45
NEXT (Next)
10-46
POST (Post)
10-46
READ (Read a Record)
10-47
REL (Release) . . . .
10-47
RLABL (RPG II LABEL) .
10-48
Message Retrieve Subroutine (SUBR23)
10-53
SET (Set) . . . . . . . . . . . . . .
10-54
Using SET Operations in Subroutines
10-58
User Message Member . . . . . .
10-58
Special Combinations of the SET and
KEY Operations . .
10-60
SETLL (Set Lower Limit)
10-60
SETOF (Set Off). . .
10-62
SETON (Set On)
10-62
SHTDN (Shut Down)
10-62
SORTA (Sort an Array) .
10-63
SORT (Square Root)
10-64
SUB (Subtract)
10-64
TAG (Tag) . . . .
10-64

viii

TESTB (Test Bit)
TESTZ (Test Zone)
TIME (Time of Day)
XFOOT (Summing the Elements of an Array)
Z-ADD (Zero and Add)
Z-SUB (Zero and Subtract) . . . . . . .

10-67
10-69
10-69
10-69
10-69
10-69

CHAPTER 11. MULTIFILE PROCESSING
No Match Fields
Match Fields . . . . . . . . . . . . .
Assigning Match Field Values (Ml-M9)
Processing Matching Records

11-1
11-1
11-1
11-1
11-3

CHAPTER 12. CONSOLE FILE CONSIDERATIONS
Restrictions For Using a CONSOLE File
When Used With KEYBORD/CRT Device
Automatic Generation of Display Screen Formats
Display Format . . . . . . . . .
Prompt Format . . . . . . . . .
Altering the Display Screen Format
Specifications For a CONSOLE File
File Description Specifications . .
Input Specifications . . . . . . .
Erasing the CONSOLE File Buffer.

12-1
12-1
12-1
12-1
12-2
12-5
12-5
12-5
12-5
12-6
12-7

CHAPTER 13. WORKSTN FILE CONSIDERATIONS
AND SAMPLE PROGRAMS . . . . . . . . . . .
Program Attributes . . . . . . . . . . . .
SRT (Single Requestor Terminal) Program .
MRT (Multiple Requestor Terminal) Program
Attaching a Device to a Program
WORKSTN File Input Processing
End-of- File Considerations
Writing a Program with a WORKSTN File
Creating a Display Screen Format. . .
Restrictions for Using a WORKSTN File
Command Keys . . . . . .
Control Specifications . . . .
File Description Specifications
Input Specifications . . .
Calculation Specifications . .
Output Specifications . . . .
WORKSTN Exception/Error Handling
Specifications for the INFDS Data Structure
Specifications for the INFSR Subroutine. .

13-1
13-1
13-2
13-3
13-4
13-4
13-8
13-9
13-9
13-13
13-14
13-14
13-14
13-17
13-19
13-21
13-21
13-25
13-29

Special Display Format Considerations
Overriding Fields in a Format
Read Under Format. . . . . . .
Processing the Duplicate Character Value
(Hex 1C) . . . . . . . . .
' .... .
Enabling/Disabling Command Keys . . .
Enabling/Disabling Function Control Keys
IBM-Written Subroutines SUBR20 and SUBR21
Setting and Restoring External Indicators
(SUBR20) . . . . . . . . . . . . .
Reading and Writing the Display Station
Local Data Area (SUBR21) -.
WORKSTN Sample Programs.
Sample Program ITMINQ
Sample Program INQPUT .
Sample Program INQRY2 .
Saving Fields (SAVDS) or Indicators (lND) for a
WORKSTN File . . . . . . . .
Using MICs with a WORKSTN File
Debugging WORKSTN Programs . .

13-30
13-30
13-31

CHAPTER 14. TABLES AND ARRAYS
Rules For Creating Table or Array Input Records
Defining Tables and Arrays. . . .
Loading Tables and Arrays . . . . . .
Compile-Time Tables and Arrays . .
Preexecution-Time Tables and Arrays
Execution-Time Arrays
Searching Tables and Arrays
Referencing Arrays . . . .
Array Name and Index .
Referencing an Array in Calculations
Modifying Contents of Tables and Arrays
Adding Entries to Short Tables or Arrays
Table and Array Output .
Editing Entire Arrays . . . .
Example of Using Tables. . . .
File Description Specifications
Extension Specifications .
Input Specifications
Calculation Specifications
Examples of Using Arrays .
Building an Array Using Field Indexes .
Building an Array Using Fixed Indexes
Calculating Totals with Arrays . . .
Using Arrays to Format Field Output
Printing Array Elements . . . . . .

. 14-1
14-3
14-3
14-4
·14-4
14-4
14-4
14-7
14-7
14-7
14-8
14-9
14-9
14-10
14-10
14-12
14-12
'14-12
14-12
14-12
14-14
14-14
14-14
14-14
14-14
14-20

13-31
13-32
13-32
13-32
13-32
13-34
13-34
13-34
13-42
13-46
13-49
13-49
13-50

. 15-1
15-1
15-1
15-5
15-6
15-8
15-8
15-10
15-11
15-12
15-12

CHAPTER 15. AUTO REPORT FUNCTION
Auto Report Generated Specifications . .
Format of the Generated Specifications
Order of Generated Specifications
Option Specifications . . . . . . .
-AUTO Specifications . . . . . . .
-AUTO Page Heading Specifications.
Record Description Specifications
Field Description Specifications
-AUTO Output Specifications . . . .
Record Description Specifications
Field Description (Blank or B in Column 39)
Field Description (A in Column 39) . . .
Field Description (C in Column 39) . . .
Field Description (1-9 or R in Column 39)
Group Printing . . . . . . . .
/COpy Statement Specifications
Modifying Copied Specifications
Report Format . . . . . . . . .
Spacing and Skipping. . . . .
Placement of Headings and Fields
Generated Specifications . . . . .
Generated Calculations . . . .
Generated Output Specifications
Programming Aids . . . . . .
Examples of Using Auto Report. .

15-~3

15-15
15-18
15-20
15-21
15-22
15-26
15-30
15-30
15-30
15-34
15-34
15-34
15-39
15-44

CHAPTER 16. PROGRAMMING CONSIDERATIONS . 16-1
16-1
Storage Saving Techniques. . . . . .
16-1
Overlay Process . . . . . . . . .
General Storage Saving Techniques .
16-4
Performance Improvement Techniques .
16-8
16-8
Coding Techniques for Calculation Operations
CHAPTER 17. DETAILED RPG II PROGRAM LOGIC

. 17-1

CHAPTER 18. COMPILING AND EXECUTING RPG II
PROGRAMS . . . . . . . . . .
. 18-1
Compiling the RPG II Source Program
18-1
RPG Command Statement .
18-1
RPGX Command Statement . . .
18-4
RPGR Command Statement . . .
18-4
Compiling the Auto Report Source Program
18-8
AUTO Command Statement
18-8
18-10
Auto Report Halts .
18-10
Cross-Reference Listing . .
18-10
Listing Format . . . . .
Running the Object Program
18-11
18-11
RPG II Halt Procedures

Contents

ix

CHAPTER 19. SAMPLE PROGRAMS
Sample Program 1 (SAMPL1). .
Control Specifications. . . .
File Description Specifications
Input Specifications
Calculation Specifications .
Output Specifications . . .
Sample Program 2 (SAMPL2) .
Control Specifications. . .
File Description Specifications
Input Specifications
Calculation Specifications .
Output Specifications . . .
Sample Program 3 (SAM PL3) .
Control Specifications. . .
File Description Specifications
Input Specifications
Calculation Specifications .
Output Specifications . . .
Sample Program 4 (SAM PL4) .
Control Specifications. . .
File Description Specifications
Input Specifications
Calculation Specifications .
Output Specifications . . .
Sample Program 5 (SAMPL5) .
Control Specifications. . .
File Description Specifications
Input Specifications
Calculation Specifications . .
Output Specifications . . . .
Sample Auto Report Program (EXAUT2)
Control Specifications. .
ICOPY Statements . . .
Calculation Specifications
*AUTO Specifications. .
Sample WORKSTN File Program (ORO)
Expanding Sample WORKSTN File
Program ORO. . . . . . . . . . .

. 19-1
19-1
19-1
19-1
19-1
19-1
19-1
19-4
19-4
19-4
19-4
19-4
19-4
19-4
19-4
19-4
19-10
19-10
19-10
19-10
19-10
19-10
19-17
19-17
19-17
19-17
19-17
19-17
19-17
19-17
19-17
19-21
19-21
19-21
19-28
19-28
19-33

CHAPTER 20. IDEOGRAPHIC SUPPORT
Specifying Ideographic Data
Ideographic Constants . . . . . . .
Ideographic Literals. . . . . . . . .
Ideographic Fields, Tables, and Arrays
Ideographic Comments . . . . . .
Processing Considerations . . . . . .
Move Ideographic Data with Deletion of
Control Characters (SUBR40)
Move Ideographic Data with Addition of
Control Characters (SUBR41)
Ideographic Device Support
Messages . . . . . . . . .

.20-1
20-1
20-1
20-2
20-2
20-3
20-3

x

19-51

20-4
20-5
20-6
20-6

APPENDIX A. SUMMARY CHARTS .
Control Specifications ... . .
File Description Specifications
Extension Specifications . . .
Line Counter Specifications. .
Telecommunications Specifications
Input Specifications . . .
Calculation Specifications
Output Specifications . .
Option Specifications (Auto Report)
Operation Codes
Valid Indicators . . . . . . . . .
Summary of Indicators. . . . . .
Display Screen Format Specifications
S Specifications
o Specifications . . . . . . . .

A-1
A-1
A-4
A-9
A-11
A-12
A-16
A-19
A-22
A-25
A-26
A-28
A-29
A-33
A-33
A-37

APPENDIX B. PRINTED MESSAGES
RPG II Messages . . . . . . .
RPG II Displayed Messages . . . . .
RPG II Auto Report Messages
RPG II Linkage Editor Messages

B-1
B-1
B-54
8-55
8-66

APPENDIX C. WORKSTN RETURN CODES

C-1

GLOSSARY

G-1

INDEX . . .

X-1

Chapter 1. Introduction

RPG II FUNCTIONS

3

After the RPG II program has been coded on the
specification sheets, the source program must be
placed in a library on disk in the order shown in
Figure 1-2. The source program can be placed on
disk in one of the following ways:
a. Use the source entry utility (SEU) program of
System/34 Utilities program product to enter
the source program from a display station. See
the SEU Reference Manual for information about
the source entry utility.
b. Use the reader-to-library copy function of the
utility program $MAINT and enter the source
program from a display station. See the System
Support Reference Manual for more information.
c. If the source program is on diskette in basic
data exchange format, use the TOLlBR
command to move the source program to a
library on disk. See the System Support
Reference Manual for more information.

4

After the source program is entered into the
system, the operator can run the RPG II compiler
by entering the required procedure or command
statements from the display station or by placing
the job on the input job queue (see the System
Support Reference Manual). The compiler
processes the source program under the control of
the system support program product.

5

If the compiler does not find any terminal errors in
the program, the object program is produced and
stored on disk. The object program contains all
the machine instructions required to prepare the
report.

6

The operator can now execute the object program
by entering the required procedure or command
statements from the display station or by placing
the job on the input job queue (see the System
Support Reference Manual). (See Chapter 18 for
examples of the command statements.) The object
program is read into the system and executed, and
the report is produced.

RPG II consists of a symbolic programming language
and a compiler program. The language is commercially
oriented and specifically designed for writing application
programs to produce reports that meet common
business data processing requirements. The compiler
diagnoses the source program, translates the source
program into an executable object program, and supplies
the logic that is the framework for the RPG II program.

STEPS IN USING RPG II
To use RPG II to prepare a report, you must follow the
general steps shown in Figure 1-1. The numbers in the
following text refer to the numbers on the figure:
1

2

You must analyze the report requirements to
determine the format of the input files and the
layout of the finished report. For example,
determine what fields in the input records are to
be used, what calculations are to take place,
where the data comes from, where the data is to
be located in the output records, and how many
and what kind of totals must be accumulated.
You must then provide the RPG II compiler with
information about these requirements by coding
the RPG II specification sheets. The specification
sheets are designed so that one specification line
represents one statement in the source program.
The following specification sheets are used to
code an RPG II program. For a brief description of
the information contained on each specification
sheet, see Overview of Specification Sheets in this
chapter.
a. Control and file description specifications
b. Extension and line counter specifications
c. Telecommunications specifications
d. Input specifications
e. Calculation specifications
f. Output specifications

8PG II Functions

1-1

Output

CD The RPG II source

CD The report outline is studied by

prog~r-=..a...;.;.;.;;;.;.~;;.;.;.;=~

written on specification sheets.

the programmer.

Line Counter
Control and
File Description

Main Storage

Compiler Program

Source Program

Compiler Pr'ogram on Disk

----

o The compiler program, read from
disk into storage, translate s the
source program into an ob ject
program.

Di sk

CD

The source program is written on
disk.

"

Object Program on Disk

CD

The object program is stored on
disk. When the program is called
for, it is read into main storage.

Main Storage
Input Data

Object Program

BSCA

DISK-----.......~
WORKSTN ~
CONSOLE~
KEYBORD~CD
SPECIAL

Figure 1·1. Preparation of a Report Using RPG II

1·2

Introduction

Output Data
)PRINTER
/ /

DISK

VeRT
~. WORKSTN

SPECIAL
BSCA
The object program performs the
processing of the data specified by
the RPG II program and produces
the desired report.
Processing

Compile-Time Table
or Array Data

Alternate Collating
Sequence Specifications

**16
File Translation
Specifications

Calculation Specifications
Input Specifications
(required)l
Telecommunications
Specifications
Counter Specifications
File Description Specifications (required).

16= blank

Control Specification

1

If the KEY operation is specified as the only
input, input specifications are not required.

Figure '-2. Required Order of Specifications for the RPG II Source Program

Steps In Using R PG II

1-3

OVERVIEW OF SPECIFICATION SHEETS

Extension Specifications

Use the RPG II specification. sheets to write your RPG II
program. The specification sheets are designed in
columns so that the information is presented in the
format required by the RPG II compiler. Each
specification line represents one statement in the source
program. Each specification sheet and the information it
provides to the compiler are briefly described in the
following text.

The extension specifications describe all record address
files, table files, and array files used in the program.
The information includes:
• Name of the file
• Number of entries in a table or array input record
• Number of entries in a table or array
• Length of the table or array entry

Control Specifications
The control specifications provide the compiler with
information about the program and describe the system
you are using. The information includes:
• Storage size needed to execute the program
• Date format for the program
• Whether special RPG II functions such as alternate
collating sequence or file translation are to be used
• Whether disk files will share a single input/output
area
• Number of formats in the display screen format load
member for a WORKSTN file
For a detailed description of the control specifications,
see Chapter 2.

File Description Specifications
The file description specifications describe all files (for
example, input files, output files, and combined files)
that are used by the object program. The information
for each file includes:
• Name of the file
• How the file is used
• Size of records in the file
• Input or output device used for the file
• Whether the file is conditioned by an external
indicator
For a detailed description of the file description
specifications, see Chapter 3.

1-4

Introduction

For a detailed description of the extension
specifications, see Chapter 4.

Line Counter Specifications
Line counter specifications indicate at what line overflow
occurs and the length of the form used for each printer
file in the program. Information for each printer file
includes:
• Number of lines per page (length of form)
• Overflow line
For a detailed description of the line counter
specifications, see Chapter 5.

Telecommunications Specifications
The telecommunications specifications describe each
BSCA file used in the program. The information
includes:
• Name of the file
• Description of the network used
• Type of station
• Type of control
• Type of code used
• Station identification
For a detailed description of the telecommunications
specifications, see Chapter 6.

Input Specifications

Output Specifications

The input specifications describe the records and fields
in the input files used by the program. The information
for each record includes:

The output specifications describe the records and fields
in the output files and the conditions under which
output operations are performed. The information
includes:

• Name of the file
• Sequence of record types
• Indications for record identifying indicators, data
structures, look-ahead fields, record identification
codes, type of numeric fields, mat~h fields, control
level fields, field record relation, field indicators

• Name of the file
• Type of record to be written
• Spacing and skipping instructions for printer and CRT
files

• Location of fields in the record

• Output indicators that specify when the record is to
be written

• Name of field

• Name of the field and location in the output record

For, a detailed description of the input specifications, see
Chapter 7.

• Editing specifications
• Constants
• Format name for the WORKSTN file

Calculation Specifications
Calculation specifications describe the calculations to be
performed on the data and the order in which they are
to be performed. Calculation specifications can also be
used to control certain input and output operations. The
information includes:
• Control level and conditioning indicators for the
operation specified
• The fields or constants to be used in the operation

For a detailed description of the output specifications,
see Chapter 9.

HOW RPG II WORKS
Each object program that the RPG II compiler generates
goes through the same general cycle of operations. The
phrase program cycle refers to the operations that are
performed for each record read.

• The operation to be performed
• Resulting indicators that are set after the operation is
performed
For a detailed description of the calculation
specifications, see Chapter 8.

RPG II Program Cycle
The program cycle involves three basic logic steps:
• Reading information (input)
• Performing calculations (processing)
• Recording results (output)
Within each program cycle, these basic logic steps can
be divided into numerous substeps in which you as'the
programmer can assign indicators to control when
calculation and output operations occur.

How RPG II Works

1-5

According to RPG II program logic, calculation and
output operations are performed at two different times
in a cycle: total time and detail time (see Figure 1-3).
First, the program performs total calculation operations
(those conditioned by a control level indicator in
columns 7 and 8 of the calculation specifications) and
total output operations (those specified by a T in column
15 of the output specifications). Second, the program
performs all detail calculation operations (those not
conditioned by a control level indicator in columns 7 and
8 of the calculation specifications) and all detail output
operations (those specified by a D or H in column 15 of
the output specifications).
Total calculation and total output operations are
generally performed on data accumulated for a group of
related records that form a control group. A control
group is a set of records all having the same information
in a control field. Each time a record is read, the
program checks the information in the control field to
determine whether it differs from the control field
information on the previous record. When the
information differs from the previous record's control
field, a control break occurs, indicating that all records
from a particular group have been read and a new group
is starting. When all records from a control group have
been read, the program performs total calculation and
output operations using the information accumulated
from all records in that group. Information contained in
the record that starts the new control group is not used
in the total operations.
Detail calculation and detail output operations are
generally performed for each record read if all
conditioning indicators are satisfied. If either of the
following conditions is met, detail calculation and output
operations are performed:
• All total calculation and total output operations are
completed, but the last record is not processed.

Step 1.

If the conditioning indicators are satisfied,
RPG performs the heading or detail output
(those lines having an H or D in column 15
of the output specifications).

Step 2.

RPG turns off all control level and record
identifying indicators.

Step 3.

RPG reads a record and turns on the
appropriate record identifying indicator.

Step 4.

RPG determines whether a control break
occurred. (A control break occurs when the
control field of the record just read differs
from the control field of the previous record.)

Step 5.

If a control break has occurred, RPG turns
on the proper control level indicator and all
lower control level indicators except LO,
which is always on.

Step 6.

If this is the first cycle, RPG goes to step 9.

Step 7.

RPG performs total calculation operations
(those conditioned by control level indicators
in columns 7 and 8 of the calculation
specifications) if the appropriate control level
indicators are on.

Step 8.

RPG performs total output operations (those
lines having a T in column 15 of the output
specifications) according to output
specifications.

Step 9.

RPG determines whether the LR indicator is
on. If it is, all records have been processed,
and the program ends. .

Step 10.

RPG makes data from the record read at the
beginning of the cycle (step 3) available for
use in detail calculation and output
operations.

Step 11.

RPG performs all detail calculation operations
(those not conditioned by control level
indicators in columns 7 and 8 of the
calculation specifications) on the data from
the record read at the beginning of the cycle.-

• No total operations are to be done (the information in
the control field has not changed).
Figure 1-4 shows the specific steps in the general flow
of the RPG II program cycle. A program cycle begins
with step 1 and continues through step 11, then begins
again with step 1. Steps 7 and 8 are known as total
time, and steps 1 and 11 are known as detail time. The
following statements describe the steps shown in
Figures 1-3 and 1 -4.

1-6

Introduction

Start

o Perform heading
or detail output

1m Move data from
'\.

record read at
beginning of
cycle into

"

~

~~

,

/
Detail
time

'"

"

,......""'"

",,

Total
time

'\.

~~
/

/

/

/

/

/
/

/

/
/

"

,...... ~/.

/

/

/

/

/ /
Read a record and
turn on appropriate
record identifying
indicator. If last
record was read
on previous cycle,
turn on LR and L1
through L9
indicators and
go to step 7.

/

/

Figure 1-3. Steps in RPG II Logic, Showing Total Time and Detail Time

How RPG II Works

1-7

Step 1

End of job
Step 2
Turn off record
identifying and
control level
indicators

Step 3

Make data from
record just read
available for
processing

Step 11
Do all detail
calculations

Step 5
Turn on proper
control level
indicators

Yes

Yes

Step 7
Do total
calculations

Step 8
Perform total
output

Figure 1-4_ RPG II Program Logic Cycle

1-8

Introduction

The first and last cycles of a program differ somewhat
from the other cycles. Before the first record is read in
the first cycle, the program prints lines conditioned by
the 1 P (first page) indicator and also performs any
heading or detail output operations having no
conditioning indicators or all negative conditioning
indicators. Heading lines printed before the first record
is read might consist of constant or page heading
information or fields for reserved words, such as PAGE
and UDATE. In addition, the program bypasses total
calculations and total output steps.
During the last program cycle, when no more records
are available, the LR (last record) indicator turns on,
automatically causing all control level indicators to turn
on. The program performs the total calculations and
total output, and the program ends.
For a detailed discussion of RPG " program logic,
including the first and last cycles of a program, see
Chapter 17, Detailed RPG /I Program Logic.

Indicators
RPG " logic is built around indicators. Because the logic
is set up to test the status of various indicators at
specific times, the status (on or off) of indicators can be
used to affect the sequence of a program's operations.
Usually indicators are set on or off by conditions in the
program itself. However, you can also set certain
indicators with the SETON, SETOF, and SET operation
codes (see Chapter 10, Operation Codes). At the start of
each program, all indicators are off except the 1 P (first
page) indicator, LO indicator, and any external (U1
through U8) indicators that have been set on. At the
beginning of each program cycle, only record identifying
indicators (01 through 99, L1 through L9, and LR) and
control level indicators (L 1 through L9) are turned off; all
other indicators remain unchanged. For WORKSTN files,
command key indicators are turned off just before data
from the record just read is made available for
processing; all command key indicators are turned off
except the one corresponding to the command key
used.
Figure 1-5 shows the valid RPG " indicators and the
specifications on which they can be used to condition
operations. The following text brie~ly describes each
type of indicator and where it can be specified. For a
complete description of an indicator and how it can be
used, see the· appropriate column description in the
applicable chapter of this manual.

01-99 (Field, Record Identifying, Resulting, and
Conditioning Indicators)

You can assign any numbers from 01 to 99 to indicate:
• The type of record read. See Columns 19-20 (Record
Identifying Indicator,**, DS) in Chapter 7, Input
Specifications.
• The status (plus, minus, zero/blank) of an input field.
See Columns 65-70 (Field Indicators) in Chapter 7,
Input Specifications.
• The results of a calculation operation. See Columns
54-59 (Resulting Indicators) in Chapter 8, Calculation
Specifications.
Any indicators that you assign in these columns or that
you set on or off with a SETON or SETOF operation
code can also:
• Establish field record relations. See Columns 63-64
(Field Record Relation) in Chapter 7, Input
Specifications.
• Condition calculation operations. See Columns 9-17
(Indicators) in Chapter 8, Calculation Specifications.
• Condition output operations. See Columns 23.;.31
(Output Indicators) in Chapter 9, Output Specifications.
Indicators reflect only one condition at a time. When
one indicator is used to reflect two or more conditions,
it is always set to reflect the condition of the last
operation performed.
If any indicator from 01 to 99 is set on or off by the
operation code SETON or SETOF, it remains on or off
until an instruction in a specification line containing that
same indicator is performed. The indicator is then set to
reflect the condition that results from the operation
performed.

H1-H9 (Halt) Indicators

Use any halt indicators, H 1 through H9, to:
• Stop the program when an unacceptable condition
occurs.
• Condition calculation or output operations that are not
to be performed when an unacceptable condition
occurs. This conditioning is necessary; otherwise, all
calculation and detail output operations are still
performed (before processing stops) for the record
that caused the unacceptable condition.
• Establish field record relations. See Columns 63-64
(Field Record Relation) in Chapter 7, Input
Specifications.
How RPG II Works

1-9

Indicators

File
Description
Specifications

Overflow
(33-34)

File
Conditioning (71-72)

Input Specifications
Record
Identifying}
(19-20)

Control
Level
(59-50)

Calculation Specifications

Field
Record
Relation}
(63-64)

Field
(65-70)

Control
Level
(7-8)

Output
Specifications

Conditioning
(9-17)

Resulting
(54-59)

Conditioning
(23-31 )

01-99

X

X

X

X

X

X

H1-H9

X

X

X

X

X

X

1P

X2

MR
OA-OG,OV

X
X

X

X

X

X

LO
L 1-L9

X

LR

X

U1-U8

X

S

X

X2

X

X

X

X

X

X

X

X

X

X

X

X

X6

X

X

KA-KN,
KP-KY

Note: X denotes the indicators that can be used.

} Not valid on look-ahead fields.
field named is not a match field or a control field.
3 0nly for detail or heading lines.
4Cannot condition an exception line, but can condition fields within the exception record.
S Not valid for table input files.
6Valid for SET, KEY, and SETOF operations only.
2 When

Figure 1-5. Valid Indicators

1-10

X

Introduction

IP (First Page) Indicator
Use the 1 P indicator to condition lines that are to be
printed on only the first page. These lines are usually
heading lines. Data printed for the heading lines is
usually specified as constants in columns 45 through 70
.of the output specifications.
All lines conditioned by the 1 P indicator are printed
before the first record from the input file is processed.
Therefore, do not use the 1 P indicator to condition
output fields that require data from input records
because the output will be meaningless. The 1 P
indicator qannot be used with a WORKSTN file or to
condition calculation operations.
The 1 P indicator is on at the beginning of the program
and turns off after all lines conditioned by it are printed.

MR (Matching Record) Indicator
Use the MR indicator to condition calculation and output
operations that are to be performed only when records
match. The MR indicator turns on when a primary file
record matches any secondary file record on the basis
of the match field indicated by M 1 through M9. The
MR indicator is always set to reflect the match or
non match condition before any detail calculation
operations are performed. If all primary file records
match all secondary file records, the MR indicator is
always on. (For a discussion of matching records, see
Chapter 11, Multifile Processing.)

OA-OG, OV (Overflow) Indicators
Use overflow indicators for printer files primarily to
condition the printing of heading lines. To use an
overflow indicator in columns 23 through 31 of the
output specifications, you must assign an overflow
indicator to each printer file on the file description
specifications in columns 33 and 34. This same
indicator must then be used to condition ,all lines that
are to be written to the associated printer only when
overflow occurs.

LO Indicator
You do not need to assign the LO indicator because it is
always on. Therefore, it is normally used only in
columns 7 and 8 of the calculation specifications to
specify that the calculation be done at total time. The
LO indicator cannot be set off with the SETOF operation
code.

LI-L9 (Control Level) Indicators
Control level (L 1 through L9) indicators signal when a
change in a control field has occurred. Therefore, you
can use them to condition operations that are to be
performed only when all records with the same
information in the control field have been read. You can
also use them to condition total printing (last record of a
control group) or to condition detail printing (first record
in a control group). Control level indicators always turn
on after the first record ~f a control group is read.
Control level indicators can be used on input (columns
19 and 20, 59 and 60, and 63 and 64)' calculation
(columns 7 and 8, 9 through 17, and 54 through 59),
and output (columns 23 through 31) specifications.

LR (Last Record) Indicator
Use the LR indicator to condition all operations that are
to be done only at the end of the job. For all primary or
secondary files (except KEYBORD), the LR indicator
normally turns on when the last record is detected. No
record identifying indicators will be on while last record
processing is performed for these files. When LR turns
on, all other control level indicators (L 1 through L9) also
turn on.
For KEYBORD files and demand files, the LR indicator
must be turned on at the appropriate time in calculation
specifications. Record identifying indicators can be on
while last record processing is performed for these files.
When LR is turned on in detail calculations, all other
control level indicators turn on at the beginning of the
next cycle. LR and the record identifying indicators are
both on throughout the remainder of the detail cycle,
but the record identifying indicators are turned off
before LR total time.
Do not specify an LO through L9 indicator in an OR
relationship with an LR indicator because the specified
operations will be" done twice at LR time.
All total lines conditioned by LR are performed last. The
program ends after all total records are written,

How RPG II Works

1-11

U1-U8 (External) Indicators
The external indicators U1 through US are normally set
prior to processing by an operation control language
(OCl) statement (SWITCH). Their setting can be
changed during processing, allowing the program to
alter the status of these indicators.
The external indicators can be used:
• To determine whether a file is to be used for a job
(see Columns 71-72 in Chapter 3, File Description
Specifications)
• To condition calculation operations

When the command key indicators are used as
conditioning indicators in the preceding columns, they
are turned on and off in the following manner:
• They are turned on when the appropriate command
key is pressed for a SET operation.
• They are turned off when the specified command key
is not pressed for the SET operation or when a
SETOF operation is performed.
When RPG makes the data read from a display station
attached to a WORKSTN file available for processing, all
command key indicators are set off. If a command key
was pressed when the data was read into the program,
the corresponding command key indicator is set on.

• To condition output operations
• As field record relation indicators

COMMON ENTRIES

For a discussion of external indicators when used with a
WORKSTN file, see Chapter 13, WORKSTN File
Considerations and Sample Programs.

Columns 1 through 7 and 75 through 80 are common to
all RPG specification sheets. The entries that can be
made in these columns ar~ described in the following
text.

KA-KN, KP-KY (Command Key) Indicators

Columns 1-2 (Page)
Assign command key indicators to specify what
command keys the operator can press for a SET
operation (see SET in Chapter 10, Operation Codes).
All 24 command keys can be used for a WORKSTN file.
You can use the command key indicators to condition
calculation and output operations. To document the use
of the command keys for the operator, you can use the
template assignment form on the IBM 5251 Display
Station Keyboard Template Assignment Sheet and Display
Screen Layout Sheet.
Twenty-four command keys are designated for the top
row of the keyboard. In the lowercase position, key 1
corresponds to command key indicator KA, key 2 to KB,
... - (minus) to KK, and = (equal) to KL. In the
uppercase position, key I corresponds to command key
indicator KM, @ to KN, ... and + to KY. Any of the
command key indicators that can be used in a SET or
SETOF operation or for a WORKSTN file can then be
used to:
• Condition calculation operations in columns 9 through
17 of the calculation specifications
• Condition outP.ut operations in columns 23 through
31 of the outpu~ specifications

1-12

Introduction

Entry

Explanation

Blank

No page number is used

01-99

Page number

Use columns 1 and 2 in the upper right corner of each
sheet to number the specifications sheets, in ascending
order, for your job. You can use more than one of each
type of sheet, but keep all sheets of the same type
together. When a" specifications sheets are filled out,
arrange them in the order shown in Figure 1-2.

Columns 3-5 (Line)

Column 7 (Comments)

Entry

Explanation

Entry

Explanation

Blank

No line number is used.

*

Comment line

Any
numbers

Line numbers.

Use columns 3 through 5 to number the lines on each
page. Columns 3 and 4 are preprinted on each sheet so,
in most cases, line numbering is already done. For
instance, the calculation specifications sheet is
prenumbered for lines 01 through 20. Below the
prenumbered lines you can add or insert up to five more
specifications (see Figure 1-6).
Page and line numbers are optional entries and are not
required to successfully compile an RPG II program.
Columns 1 through 5 are checked for ascending
sequence, and RPG II prints an S in the left margin of
the RPG II listing for any statement that is out of
sequence. If you use SEU to enter the source program,
you can request that SEU serialize the statements.
The control specifications line is always line 01. Any
other lines on the sheets can be skipped. The line
numbers used need not be consecutive, but should be in
ascending order.

Column 6 (Form Type)
Entry

Explanation

H

Control (header) specifications·

F

File description specifications

E

Extension specifications

L

Line counter specifications

T

Telecommunications specifications
Input specifications

C

Calculation specifications

o

Output specifications

Use an asterisk in column 7 to identify the line as a
comment line. Use comments throughout your program
to help document the purpose of a certain section of
coding. Any character can be used in a comment line.
Comments are not instructions to the RPG II program;
they serve only as a means of documenting your
program.

Columns 7-12 (JEJECT)
Entry
/ EJ ECT

Explanation
The specifications following this entry are
to begin on a new page of the compiler
listing.

The /EJECT specification is not printed on the compiler
listing.

Columns 7-12 (JTITLE)
Entry

Explanation

/TITLE

The heading information (such as a title
or security classification) that follows
the /TITLE entry appears at the top of
each page of the compiler listing. The
heading information is entered in
columns 14 through 74.

A program can contain more than one /TITLE
statement. Each /TITLE statement provides heading
information for the compiler listing until the next /TITLE
statement is encountered. To print on the first page of
the compiler listing, a /TITLE statement must be the
first statement encountered. Information specified by
the /TITLE statement is printed in addition to compiler
heading informa~ion.
The /TITLE statement causes an eject to the next page
before the title is printed. The /TITLE statement is not
printed on the compiler listing.

Column 6 contains a preprinted letter on all sheets. The
letter identifies the type of specifications for each line of
coding. The H in column 6 of the control specifications
stands for header or control record. The control
specification must always be the first record in the RPG
II source program (see Figure 1-2).
Common Entries

1-13

Columns 7-14 (fSPACE)

Columns 75-80 (Program Identification)

Entry

Explanation

Entry

Explanation

/SPACEbn

Line spacing occurs at this point in the
compiler listing. Valid entries for n are
1 to 3. If n is not specified, 1 is
assumed.

Blank

RPGOBJ is the program identification
assigned.

Any valid
program
name

Program identification. The first
character must be alphabetic but
,cannot be #, $, or @. The remaining
characters must be alphameric with'
no imbedded blanks. No special
character can be used.

One blank (b) must precede the value you specify for n.
The value you specify for n indicates the number of
blank lines to be spaced before the next specification
line is printed. If n is greater than the number of lines
remaining on the current page, the next specification line
is printed on a new page. If just /SPACE is specified,
one line is spaced.
/SPACE is not printed on the compiler listing; it is
replaced by the appropriate line spacing. The spacing
indicated by /SPACE is in addition to the two blank
lines that occur between specification types.

1-14

Introd uction

Control Specifications
Columns 75 through 80 of the control specifications are
used by the compiler to name the object program and to
identify each record in the object program. See Columns
75-80 (Program Identification) in Chapter 2 for a
complete description of how the compiler uses this entry
on the control specifications.

All Other Source Program Specifications
Columns 75 through 80 of all source program
specifications, except the control specifications, can
contain any characters. These columns can contain the
program name used in the control specifications, or they
can contain any other characters to identify a certain
portion of the program. These entries are ignored by the
compiler but appear in the source program listing.
Note: To be compatible with other RPG systems, the
specifications sheets show only 80 positions for each
statement. However, each statement in an RPG \I
source program can contain up to 96 characters.
Columns 81 through 96 are available for comments.
To code a line that must be inserted between two
completed lines, enter the preceding line number in
columns 3 and 4 of the line following the last line with a
printed line number. Then enter a number from 1 to 9
in column 5. A maximum of nine lines can be inserted
between two specification lines.

Calculation Specifications

C
t--Ii
>

Line

~
~
..J

I- 0

§

g

.f 8
3

4

0

1

C

0

2

C

5

Indicators

~i

6

o

3

C

o

4

C

0

5

C

o

6

C

o
o
o

7

C

8

C

9

C

1 0

C

1 1

C

1 2

C

1 3

C

1 4

C

1 5

C

1 6

C

1 7

C

1 8

C

1 9

C

2 0

c

lfji2'1 c

7

At At

Factor 1

Operation

-

-

o

0

Indicators

.,

.0

Factor 2

.;;;
0

Name

z

Resulting

Result Field

Length

~

E

-

'g

0

z
Z
0
9 10 11 12 13 14 15 161 7 18 19 20 21 22 23 2425 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 434445 4647 48 49 50 51 52

~

It:

~11

iI"

II m

IN ~~

1.1-

~

c
c
c

.I ...

~m
lioii )IIL
I~~ ~~h.. I~ 111~
Illi~jp
~~ ~. ~~

IFIA"" 12
lelF Idr~

I\lD FAIrIT l2

812
812

Arithmetic
Plus

Minus Zero
Compare

Comments

1>211<211=2
LookuplFactor 2)i,
High Low Equal
54 55565 75859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

~~
1~11 ~I' L';1I~

iF

C
lL 'L OL 69 B9 L9 99 S9 09 C9 19 '9 09 6S ag LS 9S

ss

VS CS lS 'S OS 6. 8. L. 9. S.

»

C. l . ,. O. 6C

ac

LC 9C SC

~

CC lC 'C OC 6l Bl Ll 9l Sl . l Cl II ' l Ol 6' 8' LL 9' S, .. C, l ' " 0 '

6

8

L

9

S

•

C

l

,

Figure 1-6. I nsertion of Coding Lines

Common Entries

1-15

1-16

Introduction

Chapter 2. Control Specifications

Control specifications provide special information about
your program and describe the computer system to the
RPG II compiler. One control specifications statement is
required for every program. If the control specifications
statement is omitted from the source program, a blank
control specification is assumed by the compiler. See
the individual column descriptions for the meaning of
blank entries.

COLUMNS 1-2 (PAGE)
See Common Entries in Chapter 1.

COLUMNS 3-5 (LINE)
See Common Entries in Chapter 1.

Write the control specifications on the first line of the
RPG Control and File Description Specifications sheet
(see Figure 2-1). The control specifications should
always be the first statement in the source program.

COLUMN 6 (FORM TYPE)
An H must appear in column 6 to identify this line as
the control specifications (or header) statement.

RPG CONTROL AND FILE DESCRIPTION SPECIFICATIONS

IBM

GX21·9092· UM/050'
Printed in U.S.A.

International BU5inen Mac;:hinesCorporation

75 76 71 78 79 80

Program

~~~~;~f:ation I

Date

Programmer

IIIIII

Control Specifications

H

-

Refer to the specific System Reference
Library manual for actual entries.

.;<

~

Line

~

:Ii
5

6

9 10 11 12 13 14

16 17 18

54 55 56 57 58 59

I

II

I

I

I

I

I

I

I

I

I

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

j

I

I

I

I

I

I

I

IIIII I

I

File Description Specifications
File Type

F

File Addition/Unordered

Mode of Processing

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

End of File

Record Address Type

Filename

Sequence

Type

of File

Organization

File Format

~or Additional Area

Line

Device

oJ

Symbolic
Device

Number of Tracks
for Cylincler Overflow

Nameof
Label Exit

UJ

Number of Extents
Tape
Rewind

Storage Index

~

File
Condition

o Overflow Indicator U

!

!
5

o

2

o

3

o

4

o

5

o

6

Block

Recold

length

length

~

~

t:::

e

~
~ ~

§

Key Field

.~

Starting
Location

UJ

Ul·U8
Continuation Lines

~

Option

Entry
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

6

F

I

F

!
I

0 7

o

8

o

9

1 0

F

lL LL OL 6989 L9 99 S9 >9 C9 19 L9 09 6S 8S LS 9S SS vS CS lS IS OS 61' 81' LO 91' SV VI' CV lv LV 01' 6C 8C LC 9C SC

vt

CC lC LC OC 6l 8l Ll 9l Sl

I I I I I I I I II I I I I

vl Cl II Ll Ol 6L 8L LL 9L SL VL C1 lL II OL

6

8

L

9

S

V

C

l

L

~-----------------------------------------------------------------------------------

Figure 2·1. RPG Control and File Description Specifications
Columns '·2 (Page)

2-1

COLUMNS 7-9 (SIZE TO COMPILE)
Columns 7 through 9 are not used. leave them blank.
Any entry in these columns is ignored by the compiler.
The program is compiled in the available storage
specified by the REGION OCl statement. If no region
size is specified, the size to compile defaults to 14K.
COLUMN 10 (OBJECT OUTPUT)
Entry

Explanation

Blank

The system halts only when severe
(terminal) errors are found.

D

The system halts for both warning
errors and severe errors. The
operator can continue the job
after a halt occurs for a
warning error.

The RPG II listing consists of the source program listing,
table and array information, indicator usage information,
the relative location of fields and their attributes,
unreferenced field names, diagnostics, and a main
storage usage map. The main storage usage map lists
the identification, the start address, and the size of each
uniquely identifiable segment of code in the object
program, defines the amount of main storage required
for execution, and lists the number of library sectors
required for the object program.
The partial listing includes the source program, indicator
usage information, and diagnostics. Excluded from this
listing are table and array information, field information,
and main storage usage map.

COLUMNS 12-14 (SIZE TO EXECUTE)

Use column 10 to indicate whether the system is to halt
for warning errors.

Column 12

The compiler produces the object program if no severe
(terminal) errors are detected in the source statements.
This object program is written in the library specified by
the OUTLIB parameter on the COMPilE Oel statement.
If the OUTLIB parameter is not specified, the object
program is written to the system library. The object
program remains in the specified library until it is
deleted by the programmer. Each object pmgram in a
library must be assigned a unique program name. See
Columns 75-80 in this chapter for a detailed di'scussion
of naming the program.

Entry

Explanation

Blank or 0

The entry in columns 13 and 14
determines the size to execute.

0, H, or T

The entry in columns 13 and 14 is
rounded up to the next even number.

Columns 13 and 14
Entry

Explanation

Blank

The main storage available for object
program execution defaults to the
region size specified. If no region
size is specified, the size to
execute defaults to 14K.

02-64

Enter the main storage available for
object program execution in a multiple
of 2K bytes (K = 1,024 bytes).

COLUMN 11 (LISTING OPTIONS)
Entry

Explanation

Blank

The object program is produced if
no severe errors are found, and an
RPG II listing is printed.

B

P

The object program is produced if
no severe errors are found, but
no program listing is printed. Use
this entry to produce an object
program for which you already have
a listing.
The object program is produced if
no severe errors are found, and a
partial program listing is printed.

Use column 11 to specify the program listing option to
be used when your program is compiied. if any severe
errors are found during compilation and if column 11
contains a blank or P, the listing is completed and the
system halts.
2-2

Control Specifications

Use columns 12 through 14 to specify the amount of
main storage to be available for object program
execution. The maximum amount of storage you can
specify depends on the system size. If column 12
contains a 0, H, or T or if columns 13 and 14 contain
an odd number, RPG II rounds the entry in columns 13
and 14 up to the next even number. For example, an
entry of 004 or 005 is rounded up to 006.
Thp rnmnilpn nhiprt nrnnr::lm nrrllnip.~ lin to thp. ::Imount
•• - -

-

-

• • • . - •• -

-

-

-

,

-

-

-

.- -

-

~.

-

- - -

-

-

-

-- , - - -

-

-- 1-

- -

-

-

-

of main storage specified in columns 13 and 14. The
actual amount of storage the program occupies after it
is compiled appears on the RPG listing.

COLUMN 15 '(DEBUG)
Entry

Explanation

Blank

DEBUG operation is not performed.
DEBUG operation ,is performed.

COLUMNS 19-20 (DATE OPTION)
Column 19 (Date Format)
Entry

Explanation

Blank

Defaults to month/day/year if
column 21 is blank. Defaults to
day /month/year if column 21
contains a D, I, or J.

M

Month/day/year.

D

Day / month /year.

Y

Year/month/day.

Use column 15 to indicate whether the DEBUG
operation is to be performed. To perform a DEBUG
operation:
• A 1 must appear in column 15 when the source
program is compiled.
• The DEBUG operation code must be used in the
calculation specifications.
See DEBUG Operation in Chapter 10 for more
information.

COLUMNS 16-17
Columns 16 and 17 are not used. Leave them blank.

COLUMN 18 (CURRENCY SYMBOL)
Entry

Explanation'

Blank

Defaults to $ as the currency symbol

Any other
character

This character is used as the currency
symbol. If a fixed or floating currency
symbol is desired, this symbol must
be appropriately coded in edit words
or in conjunction with the appropriate
edit codes. Any character may be
specified as the currency symbol
except the following characters
which have a special meaning in edit
codes or words:
o (zero)
* (asterisk)
, (comma)
& (ampersand)
. (decimal point)
- (minus sign)
C (letter C)
R (letter R)

Use column 19 to specify the date format for UDATE.
The date format specified in column 19 should be the
same format as the program date. For example, if
column 19 is blank, the input (the program date) must
be mm/dd/yy if column 21 is blank or dd/mm/yy if
column 21 contains a D. If you specify the date in
mm/dd/yy format and the program date in the system
is in dd/mm/yy format, RPG will work with an invalid
date.
If data containing the UDATE field is transmitted to, or
used by, another system, the UDATE format must be
yy/mm/dd.
For a description of the program date, see the System
Support Reference Manual.

Column 20 (Date Edit)
Entry

Explanation

Blank

(1) A slash (/) is assumed when
column 21 contains a blank or D
and column 19 is blank, or when
column 19 contains M; (2) a period
(.) is assumed when column 21
contains I or J and column 19
is blank, or when column 19
contains D or Y.

&

A blank separates the date field.

Any other
characters

The character entered- separates
the edited date field.

Use column 20 to specify the type of edited output that
appears for the Y edit code, which is specified on the
output specifications. For an example of how the entries
in columns 19 through 21 affect the editing of date
fields, see Column 38 (Edit Codes) in Chapter 9, Output
Specifications.
Column 15 (Debug)

2-3

COLUMN 21 (INVERTED PRINT)
Entry

Explanation

Blank

Decimal periods are used for
numeric literals and editing.
UDATE format is mmddyy if column
19 is blank. If columns 19 and
20 are blank, a slash (/) is used
for the Y edit code.
Decimal commas are used for numeric
literals and editing. UDATE format
is ddmmyy if column 19 is blank.
If columns 19 and 20 are blank, a
period (.) is used for the Y edit code.
J is the same as I except zero
is written to the left of the decimal
comma when the field contains a
fraction. Nondecimal edited fields
print with a zero in the low-order
(units) position.

J

D is the same as blank except the
UDATE format is ddmmyy if column
19 is blank.

D

Use column 21 to specify the constants to be used with
RPG II edit codes that are entered on the output
specifications. Decimal period means that numbers are
edited with a period before the fraction (183.55) and
with a comma denoting thousands (1,435). Decimal
comma means that numbers are edited with a comma
before the fraction (183,55) and with a period denoting
thousands (1.435).
For information on how the entries in column 21 are
used to format numeric data, see Column 38 (Edit
Codes) in Chapter 9, Output Specifications.

COLUMNS 22-25
Columns 22 through 25 are not used. Leave them blank.

COLUMN 26 (ALTERNATE COLLATING SEQUENCE)
Entry

Explanation

Blank

Normal collating sequence is used.

S

Alternate collating sequence is used.

Use column 26 only to alter the-normal collating
sequence for alphameric compare operations, sequence
checking, or match fields.

2-4

Control Specifications

Normal Collating Sequence
Each of the alphabetic, numeric, and special characters
used by System/34 is represented in the computer by a
hexadecimal value (see Figure 2-2), The order in which
these characters appear in the computer is based on
this hexadecimal value and is known as the normal
collating sequence. For an RPG II program, the system
uses this collating sequence only in alphameric compare
operations, in sequence checking, and for match fields.
You can alter this c~lIating sequence for use in these
three types of operations. For example, you can insert a
character between 2 consecutive characters, take a
character out of sequence, or make 2 characters equal.

Specifying an Alternate Collating Sequence
To specify that an alternate collating sequence is to be
used, enter an S in column 26. Describe each character
whose collating sequence is to be changed on the
Translation Table and Alternate Collating Sequence
Coding Sheet (see Figure 2-3). Then transcribe the
sequence changes into the correct record format for
entry into the system. These records, called the
alternate collating sequence table records, must be
entered after the RPG II specifications and, if used, the
file transl~tion table records. The alternate collating
sequence table is a special table that requires no file
description or extension specifications and is printed
with the compiled program.

Filling Out the A/ternate Collating Sequence Coding Sheet

Specify each change in the collating sequence in the
Rep/aced By column on the alternate collating sequence
coding sheet. In the Graphic column find the character
whose normal sequence is to be changed, and enter the
hexadecimal value of the replacing character in the
Rep/aced By column.
For example, if a blank is to be replaced by (or
considered the same as) a zero, enter FO (the
hexadecimal value of zero) in the Rep/aced By column
next to the hexadecimal value of a blank (40) (see Figure
2-4). Thus, whenever the system reads a blank and
uses it in an alphameric compare, match field, or
sequence checking operation, the blank is considered
the same as a zero.
If a character is to be inserted between 2 consecutive
characters, you must specify every character that is
altered by this insertion. For example, if the dollar sign
($) is to be inserted between A and B, specify the
changes for characters B through I on the coding sheet
(see Figure 2-4).
The translation table and alternate collating sequence
coding sheet show many hexadecimal values between
the characters I and}, Rand S, and Z and 0 that have
no printable graphic associated with them. Because of
this arrangement of nongraphics in the collating
sequence, a character such as $, when inserted between
A and B, changes only the position of characters B
through I. Because the I replaces the nongraphic
represented by hexadecimal CA, the remaining
characters in the collating sequences are not affected.

Column 26 (Alternate Collating Sequence)

2-5

Collating
Sequence
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

Character
Blank
¢

<
(

+
I
&
!

$
*
)

,

--,
- (minus)
/
J
I

,
%

_(underscore)

>
?

,

#
@

,

=

"

a
b

c
d
e
f
g
h
i
j

k
I

m
n
0

p
q

r

,...,

Hexadecimal
Value

Collating
Sequence

40
4A
4B
4C
4D
4E
4F
50
5A
5B
5C
5D
5E
5F
60
61
6A
6B
,6C
6D
6E
6F
79
7A
7B
7C
7D
7E
7F
81
82
83
84
85
86
87
88
89
91
92
93
94
95
96
97
98
99
A1

49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

Character
s
t
u
v
w
x
y

z
{

A
B
C
D
E
F
G
H
I

}
J
K

L
M
N

0
P
Q

R

\
S
T
U

V
W

84

X
y

85
86
87
88
89
90
91
92
93
94
95

0
1
2
3
4
5
6
7
8
9

Z

Hexadeci mal
Value
A2
A3
A4
A5
A6
A7
A8
A9
CO
C1
C2
C3
C4
C5
C6
C7
C8
C9
DO
D1
D2
D3
D4
D5
D6
D7
D8
D9
EO
E2
E3
E4
E5
E6
E7
E8
E9
FO
F1
F2
F3
F4
F5
F6
F7
F8
F9

Note: When zones are specified for record identification codes, the & is considered to have a hex C zone, the - (minus sign)
is cOiisidered to have a hex D zone, (jnd the biank is considered to have a hex F zone, to be consistent with card punches.
Figure 2-2. Normal Collating Sequence and Hexadecimal Value of Characters
2-6

Control Specifications

"T1

cC'

c

;

N

Internatiollal Business

MJ~hincs

GX21·9096· U/M 050'
Printed in U.S.A.

Corporation

---"®

·No. of sheets per pad may vary slightly

TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE CODING SHEET

~

:;t
£II

:l

III

...iii0'

:l

-i

£II

eCD
£II

:l
C.

~

CD

3£II

...
CD

(')

9..

...
:;

iii

IQ

C/)

!c

CD

:l

n

CD

(')

o
c.

=:;'

Ie

(I)

::r
CD
CD

...

(")

£
c:
3

:l

f\J

en
);
;:::;
~
:l

~
co

(")

£

§"

Graphic

Code

Entry

Replaced
By/Takes
Place 01

Code

00001101
00001110

00
01
02
03
04
05
06
07
08
09
OA
OB
OC
OD
OE

00110011
00110100
00110101
00110110
00110111
00111000
00111001
00111010
00111011
00111100
00111101
00111110
00111111
01000000
01000001

00001111
00010000
00010001

OF
10
11

01000010
01000011
01000100

00010010

12

00010011
00010100
00010101
00010110
00010111

00000000
00000001
00000010
00000011
00000100
00000101
00000110
00000111
00001000
00001001
00001010
00001011
00001100

co

.0

c:
co

:l
C')

~
f\J

.!..J

33
34

Replaced
By/Takes
Place 01

Code

Graphic

01100110
01100111
01101000
01101001
01101010
01101011

Entry
66
67
68

Replaced
By/Takes
Place 01

Code

Graphic

Entry

10011001
10011010
10011011
10011100
10011101
10011110
10011111
10100000
10100001
10100010
10100011

r

99
9A
98
9C
9D
9E
9F
AO
Al
A2

01101100
01101101
01101110
01101111
01110000
01110001
01110010

40
41

01110011
01110100

73
74

10100100
10100101
10100110
10100111

42
43
44

01110101
01110110
01110111

75
76
77

10101000
10101001
10101010

01000101

45

7B

10101011

13
14

01000110

46
47

01111000
01111001

10101100
10101101

15
16

01001000
01001001
01001010
01001011
01001100
01001101
01001110
01001111
01010000
01010001
01010010
01010011
01010100
01010101
01010110

10101110
10101111
10110000

17
18
19
lA
lB
lC
10
IE
1F
20
21
22

00100011
00100100

23
24

00100101
00100110

25
26

00100111

27

01011010

00101000
00101001

28
29

00101010

2A

01011011
01011100
01011101

00101011
00101100
00101101

2B
2C
2D

01011110
01011111
01100000

00101110
00101111

2E
2F

01100001
01100010

00110000
00110001
00110010

30
31

01100011
01100100
01100101

32

?

s
t

88

59

10001100

8C

10111111

!
$

5A
5B

10001101

8D

11000000

{

11000001
11000010

A

5C
5D

BE
8F

I

10001110
10001111
10010000

90

11000011

C

5E
5F

10010001
10010010

j

91

k

60
61

10010011
10010100
10010101

I
m
n

92
93
94

11000100
11000101
11000110

D
E
F

C5
C6

11000111
11001000

10010110
10010111
10011000

G
H
I

p
q

t

<
(

+
I
&

48
49
4A
4B
4C
4D
4E
4F
50
51
52
53
54
55
56
57
58

01011001

Note: Not all graphic symbols shown here are available on all systems.

>

10111100
10111101
10111110

Blank

01010111
01011000

-

:
%

69
6A
6B
6C
6D
6E
6F
70
71

A3
A4
A5
A6
A7
AB
A9
AA
AB
AC
AD
AE
AF
BO
81
82
B3
84
B5
B6
B7
88
B9
8A
BB
BC
BD
BE
BF
CO
Cl
C2
C3

01000111

3'

to
C/)

Entry

35
36
37
38
39
3A
38
3C
3D
3E
3F

00011000
00011001
00011010
00011011
00011100
00011101
00011110
00011111
00100000
00100001
00100010

'--_._----

Graphic

;
~

I

62
63
64
65

72

01111010

:

79
7A

01111011
01111100

I;

7B

@

7C
7D
7E
7F
80
81
82
83
84
85
86
87
88
89
8A

01111101
01111110
01111111
10000000
10000001
10000010
10000011
10000100
10000101
10000110
10000111
10001000
10001001
10001010

=

.

a
b
c
d
e
I
g
h
i

10001011

0

95
96
97
98

u

v
w
x
y

z

10110001
10110010
10110011
10110100
10110101
10110110
10110111
10111000
10111001
10111010
10111011

11001001
11001010
11001011

B

C4

C7

C8
C9
CA
CB

Replaced
By/Takes
Place 01

Code

Graphic

11001100
11001101
11001110
11001111
11010000
11010001

)
J

11010010
11010011
11010100

L
M

CC
CD .

K

11010101
11010110
11010111
11011000

N
0
P

11011001
11011010

R

a

11011011
11011100
11011101

11100011
11100100
11100101
11100110
11100111
11101000
11101001
11101010
11101011
11101100
11101101
11101110
11101111
11110000
11110001
11110010
11110011
11110100
11110101
11110110
11110111
11111000
11111001
11111010
11111011
11111100
11111101
11111110
11111111

CE
CF
DO
Dl
D2
D3
D4
D5

06
D7
D8
D9
DA
DB
DC
DD

11011110
11011111
11100000
11100001
11100010

Entry

DE
DF

\

EO
El

S
T

E2
E3
E4
E5
E6
E7
E8
E9
EA
EB
EC
ED
EE

U

V
W

X
y

Z

0
1
2

EF
FO
Fl
F2

3
4

F3

5
6

F5
F6

7

F7
F8

8
9

F4

F9
FA
FB
FC
FD
FE
FF

Replaced
By/Takes
Place 01

N

00

()

o

"11

ca'
e
~

CJ)

i:f

2CD

n

~

0'
~

0'
~

GX21·9096· U/M 050'
Printed in U.S.A.

®

N

~

"0

International Business Machines Corporation

C;

·No. of sheets per pad may vary slightly

TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE CODING SHEET

»

..
..

CQ

:zCD

o

~

iii

:;.

cc

f
.tl
e

CD

:::l

S

Code
00000000
00000001
00000010
00000011
00000100
00000101
00000110
00000111
00001000
00001001
00001010
00001011
00001100
00001101
00001110
00001111
00010000
00010001
00010010
00010011
00010100
00010101
00010110
00010111
00011000
00011001
00011010
00011011
00011100
00011101
00011110
00011111
00100000
00100001
00100010
00100011
00100100
00100101
00100110
00100111
00101000
00101001
00101010
00101011
00101100
00101101
00101110
00101111
00110000
00110001
00110010

Graphic

Entry
00
01
02
03
04
05
06
07
08
09
OA
OB
OC
00
OE
OF
10
11
12
13
14
15
16
17
lB
19
lA
lB
lC
10
lE
1F
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
20
2E
2F
30
31
32

Replaced
By/Takes
Place 01

Code

I

Replaced
By/Takes
PlaceOI

Entry

I Graphic

33
34
35
36
37
38
39
3A
3B

00110011
00110100
00110101
00110110
00110111
00111000
00111001
00111010
00111011
00111100
00111101

01100110
01100111
01101000
01101001
01101010
01101 011
01101100
01101101
01101110

::::::~~ :;.

I

01 00001 O:?F::::::::::::::::::;:;:;:;:;;;:T';';';'j(2;:;:::;:;;;:;:;'1";:;:;:;:;:;:;::;;:;:;';';:;:;';';'

I

I

I

I t
I

<

I (
I &
I
I
I
I
I

01011000 I
01011001 ..
01011~i*i:(
01011'i1.i"i

~~ ~~ ~:~: ::1 ::;::
01011110
01011111
01100000
01100001
01100010
01100011
01100100
01100101

Note: Not all graphic symbols shown here are available on all systems.

Graphic

I

%

>

Blank and zero consi :lered equal.

I

01000011
01000100
01000101
01000110
01000111
01001000
01001001
01001010
01001011
01001100
01001101
01001110
01001111
01010000
01010001
01010010
01010011
01010100
01010101
01010110
01010111

Code

I
I
I
I
I

I

43
44
45
46
47
48
49
4A
4B
4C
40
4E
4F
50
51
52
53

54
55
56
57

I

58

11

:
#
@

.=
a
b

c
d
e
I
9

h

10001011
10001100
::. 10001101
:::: 1000111 0
:::. 10001111
10010000
10010001
10010010
10010011
10010100
10010101
10010110
10010111
10011000

66
67
68
69
6A
6B
6C
60
6E
6F
70
71
72
73
74
75
76

77

$ takes B's position.

: : !: : : : ;~: : : : : : : I: : : : : : : : : : : : : : : :~: : ,: :
5E
SF
60
61
62
63
64
65

01110001
01110010
01110011
01110100
01110101
01110110
01110111
01111000
01111001 .
01111010
01111011
01111100
01111101
01111110
01111111
10000000
10000001
10000010
10000011
10000100
10000101
10000110
10000111
10001000

Entry

j

k
I
m

n
0

p
Q

78
79
7A
7B
7C
70
7E
7F
80
81
82
83
84
85
86
87
88
89
8A
8B
8C
80
8E
8F
90
91
92
93
94
95
96
97
98

Replaced
By/Takes
Place 01

Code

Graphic

Entry

10011001
10011010
10011011
10011100
10011101
10011110
10011111
10100000
10100001
10100010
10100011
10100100
10100101
10100110
10100111
10101000
10101001
10101010
10101011
10101100
10101101
10101110
10101111
10110000
10110001
10110010
10110011
10110100
10110101
10110110
10110111
10111000
10111001
10111010
10111011

99
9A
9B
9C
90
9E
9F
AO
Al
A2
A3
A4
AS
A6
A7
A8
A9
AA
AB
AC
AD
AE
AF
BO
Bl
B2
B3
B4
B5
B6
B7
B8
B9
BA
BB

~~~~~~~~

:~

Replaced
ByiTakes
Place 01

Code
11001100
11001101
11001110
11001111
11010000
11010001
11010010
11010011
11010100
11010101
11010110
11010111
11011000
11011001
11011010
11011011
11011100
11011101
11011110
11011111
11100000
11100001
11100010
11100011
11100100
11100101
11100110
11100111
11101000
11101001
11101010
11101011
11101100
11101101
11101110

~ ~ ~~~~:::: "·:·A::::::::::::::::·:·:·:·: .:.:.:.:.~~;::::::::::::: ::~:;:::::::::::~~:j::: :\::\
C

C3

C"

C6::
C7
.~

C8

~~~~~~~~

~

11001011

CB

I P

a

DC
DO
DE
OF
EO
El
E2
E3
E4
E5
E6
E7
E8
E9
EA
EB
EC

I U
I V
I W

I X
I Y

I Z

ED
EE

:..C

11110001
11110010
11110011
~ ~ ~ ~ ~~ 00

Fl
F2
F3
,F4. •

4

11110111
11111000

F7
F8

:~;J
11111001
,11111010
J
11111011

F9
FA
FB

II:

F
G

I 0

.r~~i C takes D s posltlon.--j

I

110001tlU:::: :::::4~:.:·:·.......·.·...............1;;4.................~ ":'...;:::, ':. ::' : :::::::
1100010'-' ":':' 1:;::::::::::: :::::::::;: ::::::::W,:i:::::::;::::::-;::'i'!.:" .......
11000110
11000111
11001000

CC
CO
CE
CF
DO
01
02
03
04
05
06
07
08
09
OA
DB

I M
I N

I

Replaced
By/Takes
Place 01

Entry

B takes C's position. -+-~~':-~-+---~

10111110
BE'
10111111
BF
I
11000000 .'..;::d·:.~:,:::::::::::::::::: ::::;::::@.;:;:;:;:;:;:;: .:;:J::::::::::;:.:.:.:.......

11000@:]

Graphic

-

:~: (no printable character)
11111110
11111111

I

I

FE
FF

I

Formatting the Alternate Collating Sequence Records

Example of Alternate Collating Sequence Record

The changes to the collating sequence that are
described on the coding sheet must be transcribed into
the correct record format so that the operator can enter
them into the system. The alternate collating sequence
must be formatted as follows:

The record for the preceding example of inserting the
dollar sign ($) between A and B is formatted as follows.
The changes specified on the alternate collating
sequence coding sheet are shown in Figure 2-4.

Record
Position
1-6

Entry
ALTSEQ (This indicates to the system
that the normal sequence is being
altered.)

Record
Position

Entry

1-6

ALTSEQ

7-8

Blanks

9-12

5BC2 ($ takes B's position)

7-8

Leave these positions blank.

13-16

C2C3 (B takes C's position)

9-10

Enter the hexadecimal value for the
character whose normal sequence is
being changed. Figure 2-2 shows each
printable character and its
hexadecimal value.

17-20

C3C4 (C takes D's position)

21-24

C4C5 (D takes E's position)

25-28

C5C6 (E takes Fs position)

29-32

C6C7 (F takes G's position)

33-36

C7C8 (G takes H's position)

37-40

C8C9 (H takes I's position)

41-44

C9CA (I takes the position
of an unprintable character)

11-12

13-16,
17-20,
21,-24 ...

Enter the hexadecimal value of the
character replacing the character
whose normal sequence is being
changed.
Use these positions in the same way
as positions 9 through 12. The
first two positions specify the
character to be replaced by the
character specified in the next two
positions. There can be as many
four-position entries as can be
contained in the record. The first
blank position terminates the record.

The records that describe the alternate collating
sequence must be preceded by a record with **0 (0 =
blank) in positions 1 through 3. The remaining positions
in this record can be used for comments.

COLUMNS 27-36
Columns 27 through 36 are not used. Leave them blank.

COLUMN 37 (INQUIRY)
Entry

Explanation

Blank or I

Program when interrupted will not
allow the operator to enter new
procedures or commands (does
not recognize an inquiry request).

B

Program when interrupted will
allow the operator to enter new
procedures or commands (does
recognize an inquiry request).

Use column 37 to specify whether an executing program
can be interrupted to allow another program to execute.
The operator requests an interruption (called an inquiry
request) by pressing the ATTN key on the display
station. The procedure or command statements for the
interrupting program must be entered from the display
station.

Columns 27-36

2-9

The program to be loaded following an inquiry request
(the interrupting program) can have an I" B, or blank in
column 37 of its control specifications. However, even if
it has a B in column 37, the interrupting program cannot
be interrupted by another inquiry request.
If column 37 contains a B, the inquiry function of
System/34 allows the operator to interrupt a program
that is currently using the display station and to enter
new procedures or commands. If column 37 contains
any of the valid entries, the operator can set the inquiry
latch for SUBR95, cancel a single requestor terminal
(SRT) program that the operator initiated, or release the
display station from a multiple requestor terminal (MRT)
program.

Multiple Program Mode
When System/34 is operating in multiple program
rode, an inquiry program can access active input,
update, and add files. However, an inquiry program
cannot access indexed sequential add file types or
output files. Each file to be shared in both the
interrupted and the inquiry programs must be designated
by the DISP-SHR parameter on the FilE OCl
statement.
, For a description of the valid file sharing combinations,
see the System Support Reference Manual.

Inline Inquiry Subroutine (SUBR95)
For more information on inquiry, including restrictions on
the use of system utilities in inquiry mode, see
Interrupting a Program (Inquiry) in Chapter 2 of the
System/34 Concepts and Design Guide.
File Sharing

Single Program Mode
When System/34 is ope'rating in single program mode,
an inquiry program can access the files being used by
the interrupted program (that is, the active files) for
input and update processing only. Update processing of
an active file is allowed only if the interrupted program
is not updating or adding to the file. Active output files'
cannot be accessed by the inquiry program.

The IBM-written subroutine SUBR95 can be used to
perform an inquiry type function if the RPG II program
does not have an M RT attribute (that is, the M RTMAX
parameter on the COMPilE OCl statement has a value
of 0 or is not specified). Column 37 can be blank or
contain an I or B. (See Interrupting a Program (Inquiry)
in Chapter 2 of the System/34 Concepts and Design
Guide for restrictions on the inquiry function.)
The linkage to SUBR95 must be specified on the
calculation specifications at every point in the program
where a check is to be made for an inquiry request (see
Figure 2-5). The indicator specified in columns 45 and
46 must be an RPG II indicator. For a detailed
discussion of this linkage, see Linking to External
Subroutines in Chapter 10.
When SUBR95 is called, it checks to determine whether
an inquiry request was made. If one was, made (that is,
the operator selected option 4 in response to the inquiry
display), the indicator specified in the RLABl operation
is turned on and the inquiry request is reset. This
indicator can then be used to condition subsequent
calculation and output operations.

Calculation Specifications
Indicators

C

~

At

Result Field

I

And

Factor 1

Operation

Name

;g
4

0

1

0

Z

Length

0

Z

c
c

0 3

C

0 4

C

I';I~IIIT

RL IAIB,l

Figure 2-5. Linkage for SUBR95

Control Specifications

Compare

1-

11 iN I~~

Comments

1>211<211=2
Lookup(Factor 21 is
High

9 10 11 12 1314 15 16 17 18 19 20 21 22 23 2425 26 27 2829 3031 32 33 34 35 36 37 38 39 40 41 42 4344 45 46 47 48 49 50 51

5

0 2

2-10

Plus IMinu;1 Zero

Factor 2

Line

3

Resulting
Indicators
Arithmetic

Low Equal

5455 5657 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

COLUMNS 38-40
Columns 38 through 40 are not used. leave them blank.

COLUMN 43 (FILE TRANSLATION)

Entry

Explanation

Blank

No file translation is needed.

F

Input, output, update, or combined
files are to be translated.

COLUMN 41 (1 P FORMS POSITION)

Entry

Explanation

Blank

First line is printed only once.
First line can be printed repeatedly.

Use column 41 only when the first output line is written
to a printer file. If the program contains more than one
printer file, the 1 P entry in column 41 applies to each
printer file that has 1 P (first page) output.
When forms are 'first inserted in the printer, they may
not be in perfect alignment. Sometimes several lines
must be printed to determine the correct positioning of
the form. If 1 P forms position is specified, the system
prints the first line of output and issues a message. The
operator can then align the forms and select the
appropriate option to retry pri~ting the line or to
continue printing. The 1 P forms specification is also
valid if the output is spooled. The page counter is not
incremented until the forms have been positioned
correctly.
The 1 P forms position specification can be overridden
on the PRINTER OCl statement, or forms alignment can
be specified on the PRINTER DCl statement.

COLUMN 42
Column 42 is not used. leave it blank.

Use column 43 only when information contained in an
input, output, update, or combined file is in a character
code different from the character code used by
System/34;
The file translation function of RPG II translates 1
character into another. The characters can be translated
when they are read into the system from an input file or
before they are written to an output file. An F in column
43 indicates one or both of the following: (1) a
character code used in the input data must be translated
into System/34 code; (2) the output data must be
translated from System/34 code into a different code.
If file translation is specified for update or combined
files, the input data is translated into System/34 code
and then translated back into the different code for
output.
File translation is generally used as a security measure
when input or output data is coded to prevent access to
classified information. The system cannot process this
classified information until it is translated into
System/34 code. Figure 2-2 shows the hexadecimal
code used by the System/34 to internally represent
alphabetic, numeric, and special characters.
To specify file translation, enter an F in column 43.
Then describe the character that is to be translated on
the Translation Table and Alternate Collating Sequence
Coding Sheet (see Figure 2-3). The translations
described must also be transcribed into the correct
record format ,for entry into the system. These records,
called the file translation table records, must be entered
following the RPG II specifications. This special table
requires no file description or extension specifications,
and is printed with the compiled program.

Columns 38-40

2-11

Filling Out the Translation Table Coding Sheet
Identify each character that is to be translated on the
translation table coding sheet. In the Replaced By
column, enter the hexadecimal val':le of the character
that is to replace the character presently associated with
the hexadecimal value shown in the Entry column. For
example, if the input data is in a code in which the
character B is used to represent the number 1, enter the
hexadecimal value of 1 (which is Fl) in the Replaced· By
column next to the character B (see Figure 2-6).

TRANSLATION TABLE AND ALTERNATE COLLATING

Replaced

Replaced

GraphiC

Entry

By/Takes
PlaceDf

00110Ql1

01
02

00110100

04

00,,0111
00111000

GraphiC

Entry

33
34
35

00000011

00000100

3A
38

OF

00111110

00111111
01000000

"001110

01101101

01110000

60
6E
6F
70

01110001

71

01110010

72

01101"0

42

0"'0101

14

01000111

00010111

17

00011000

18

0"'0111

15
16

0',11000
01111010

48
49

01111011
01111100

48
4C

01111110

01001010

01001101

10000000

01001110

10000001

4F

10000010

SO

10000011
10000100

00011111

51
52

00100001

IF
20
21

00100010

22

00100011
00100100

01010011
01010101

10001000
10001001

10001010
01011000

58

01011001

27

01011010

08

y

1101'011

08

78

11011110

DE
OF

01011101

0010101'

2A
28

00101100

2C

01011111

7A
78

E4
E5

10001011

SA

1000110~

5C

11101011
11101100

2E
2F

5F

8A
88

Fl
F2

80

90
91
92

60
61

10010011

01100010

62

10010101

00110000

10010100

~!L
F~

...:::......:,.......

94
95

:.:.:
.:::

10010110

31
32

01100101

64
65

10011000

97

10

98

"/

/

This is the hexadecimal value of the
character to be translated.

Figure 2-6. Specifications for File Translation Input Records

Control Specifications

.Ii
1"""1

8F

10010000
10010010

E8
EC

87
88

10001111

01100000

~""

81
82

10001110

00101001

C~

EO

10001100

00101000

2-12

"011000

'-CD

oA
75
76
77

10000101
10000110
10000111

01010100
01010110

25

00110010

07

7F

00011101

00110001

11010111

F40

01111101

01001100

00011010
18
lC

CC
CO

05

01111001

00011001

00101111

-

Place Of

w

01000010

00010100
00010101

-'QlOO

Entry

CF
DO
01
02
03
04

01101011

01110100

01000101

00100111

GraphiC

11001100
11001101

41

11
12

00100000

Replaced

By Takes

Entry

GraphiC

01101000

01000001

00010011

00011100

Code

01100111

01110110

00010001

PlaceQf

0,,00110

01'01111
OA
08
OC
00

00001110

00001111

Entry

01101100
00111010
00111011

00001100

GraphiC

01101010

38

00000110

00000111

00001011

Replaced

By/Takes

By/Takes

Cod.

01101001

05

00001001
00001010

Place Of

CODING SHEET

Replaced

By/Takes
Code

SE~UENCE

I::::

/

~:::.

:;,."

F5
11110111
11111000
11111001

F6
F7
F8
F9

FC
FD
11111110

This is the hexadecimal value of the character
that will be substituted for the character that
is to be translated.

Formatting File Translation Table Records

Example of File Translation

File translation table records must be formatted as
follows:

A department store processes sales slips that contain
the wholesale price and the retail price of each item.
Because the wholesale price must remain confidential,
the store substitutes the individual letters of a code
name for the numbers comprising the wholesale costs.
The store uses the code name BUCKINGHAM to
represent the numbers 1 through 9 and 0, respectively.

Record
Position

Entry

1-6
Enter *FI LES to indicate that all
(To translate) input, output, update, and combined
all files)
files are to be translated (both
the input and output data of the update
and combined files are translated).
Complete the file translation table
record beginning with positions 9
and 10.
1-8
(To translate
a specific
file)

9-10

11-12

13-16,
17-20,
21-24, ... ,
93-96

Enter the filename of the input,
output, update, or combined file to be
translated (both the input and output
data of update and combined files
are translated). Complete the file
translation table record beginning with
positions 9 and 10. The *FILES entry
is not made in positions 1 through 6
when only a specific file is to be
translated.
Enter the hexadecimal equivalent
of the external character to be
translated-from on input, or to be
translated-to on output.
Enter the hexadecimal equivalent
of the internal character that RPG
works with. It will replace the
character in positions 9 and 10
on input and be replaced by the
character in positions 9 and 10
on output.
Use these positions in the same way
as positions 9 through 12. The first
two positions contain the hexadecimal
value of the character to be replaced
by the character whose hexadecimal
value is specified in the next two
positions.

If the number of translations exceeds 96 positions,
duplicate positions 1 through 8 on the next record and
continue with the translation pairs as before in positions
9 through 96.

In order for the system to perform any calculations with
the wholesale prices, file translation must be specified
for this file by an F entry in column 43 of the control
specifications for this program. Figure 2-6 shows the
entries made on the translation table coding sheet that
translate the code name into System/34 characters.
The file translation table record for translating this code
word is as follows:
Record
Position

Entry

1-6

*FILES (All files in the program
are to be translated.)

7-8

Blank

9-12

C2F1 (Each B read from the file
is translated into a 1.)

13-16

E4F2 (Each U read from the file
is translated into a 2.)

17-20

C3F3 (Each C read from the file
is translated into a 3.)

21-24

D2F4 (Each K read from the file
is translated into a 4.)

25-28

C9F5 (Each I read from the file
is translated into a 5.)

29-32

D5F6 (Each N read from the file
is translated into a 6.)

33-36

C7F7 (Each G read from the file
is translated into a 7.)

37-40

C8F8 (Each H from the file is
translated into an 8.)

41-44

C1 F9 (Each A read from the file
is translated into a 9.)

45-48

D4FO (Each M read from the file
is translated into a 0.)

All table records for one file must be kept together. The
file translation table records must be preceded by one
record with **0 (0 = blank) in positions 1 through 3.
The remaining positions of this record can be used for
comments.
Column 43 (File Translation)

2·13

Note: On input, the alphabetic characters are translated
to their corresponding numbers. On output, the
numbers are translated back to their corresponding
alphabetic characters.
When the program with this file translation is executed,
each character given in the file translation table record is
translated for every field in each file in the program
(unless a specific file was given in positions 1 through 8
of the file translation table record). All characters that
are not in the file translation table record are handled in
the normal manner.

COLUMN 44
Column 44 is not used. Leave it blank.

COLUMN 45 (NONPRINT CHARACTERS)

Entry

Explanation

Blank

Program halts if the last line
printed contained an unprintable
character.
Program does not halt for
unprintable characters.

Use column 45 to bypass machine halts for unprintable
characters. This column applies only to printer files.
All characters are represented in the system by a
hexadecimal value, which is a numeric code. If a
hexadecimal value is formed during a calculation that is
not in the System/34 character set and that character is
to be printed, the system halts after printing the line. In
the printed line, the unprintable characters are replaced
with blanks.
To bypass this halt, enter a 1 in column 45. An
unprintable character is then replaced with a blank, and
no halt occurs. Note, however, that your output is not
correct, and, by bypassing the halt, the incorrect output
may not become known (for example, when a packed
key field is printed or when a nonprintable field is built
by calculation specifications).

COLUMNS 46-47
Columns 46 and 47 are not used. Leave them blank.

COLUMN 48 (SHARED I/O)

Entry

Explanation

Blank

All disk files use a separate
input/ output area.
All disk files share a single
input/ output area.

Use column 48 to allow all disk files to use one
input/ output area.
Normally an RPG II program uses one input/output area
for each file. Specifying a shared input/output area can
reduce the amount of main storage needed to process a
program. This is particularly important if a program is so
large that it cannot run in the main storage available.
However, the use of a shared input/output area can
increase the time required to process the program.
Therefore, before indicating that all disk files are to
share one input/output area, be sure that the program
would otherwise exceed the capacity of the system.
Additional input/output areas, which can be specified in
column 32 of the file description specifications, cannot
be specified for disk files using a shared input/output
area. Also when an update file using a shared
input/ output area is processed, you must ensure that
retrieval of another record did not occur between
retrieval and update of the specified record; otherwise
an invalid record update operation message is issued.

COLUMNS 49-51
Columns 49 through 51 are not ·used. Leave them blank.

COLUMNS 52-53 (NUMBER OF FORMATS)

Entry

Explanation

Blank

Program assumes an entry of 32.

0-32

Enter the number of formats in the
display screen format member for
the WORKSTN file.

Use columns 52 and 53 to indicate the number of
individual formats in the display screen format member.
This number must include all the formats in the display
screen format load member, not just the number of
formats used by the program.

(
2-14

Control Specifications

COLUMNS 54-56
Columns 54 through 56 are not used. Leave them blank.

COLUMNS 75-80 (PROGRAM IDENTIFICATION)

Entry

Explanation

Blank

RPGOBJ is the program identification
assumed by the compiler.

Any valid
program
name

The first character of the program
identification must be alphabetic,
but cannot be #, $, or @. The
remaining characters must be
alphameric; however, no special
character can be used and blanks
must not appear between characters.

COLUMN 57 (TRANSPARENT LITERAL)

Entry

Explanation

Blank

No transparent literals or constants
are present in the program.

1

Transparent literals or constants can
be present in the program.

The transparent literal option must be specified if there
are transparent literals or constants present in your
program. Transparent literals or constants must begin
with an apostrophe followed immediately by the
shift-out (S/O) control character (hex DE), and must end
with the shift-in (S/I) control character (hex OF)
followed immediately by the terminating apostrophe.
Transparent literals and constants are not checked for
embedded apostrophes.
If the transparent literal option is specified and a literal
or constant is found that begins with an apostrophe
immediately followed by the S / 0 control character, the
RPG II compiler checks for a valid transparent literal or
constant. The following conditions cause a literal or
constant to be diagnosed as an invalid transparent literal
or constant:
• A second S/O control character is found before the
S / I control character.
• An odd number of l-byte characters are found
between the S/O and S/I control characters.
• The S/I control character is not immediately followed
by the terminating apostrophe.
If a literal or constant is found to be an invalid
transparent literal or constant, it is rechecked as an
alphameric literal or constant.

Use columns 75 through 80 to assign a unique name to
your object program. The compiler uses the program
name in a program directory that contains the location
of your program on disk.
If the program contains a CONSOLE or WORKSTN
device, the compiler also uses this program identification
to name the display screen format load member for the
program. The display screen format load member is
generated by RPG II only for CONSOLE files; however,
the name is created for both CONSOLE and WORKSTN
files. This name is used by RPG II; therefore the user
must generate his own load member with this name for
WORKSTN files. For the display screen format load
member name, the compiler uses the name specified as
the value of the FMTS continuation line option. If the
FMTS continuation line option is not specified, the
compiler uses the characters specified in columns 75
through 80 of the control specifications (the program
name) and adds the characters FM to the end of the
program name. FM is added to the end of the program
name regardless of its length, and the resulting name
contains no embedded blanks .
If a cross-reference listing is to be generated for the
program, this program identification is also used to
identify the listing.

COLUMNS 58-74
Columns 58 through 74 are not used. Leave them blank.

Columns 54-56

2-15

2-16

Control Specifications

Chapter 3. File Description Specifications

File description specifications describe each file used by
a program. One file description specifications statement
is required for each file, and a maximum of 20 files can
be described per program.

COLUMNS 1-2 (PAGE)
See Common Entries in Chapter 1.

Write the file description specifications on the Control
and· File Description Specifications sheet (see Figure
3-1 ).

COLUMNS 3-5 (LINE)
See Common Entries in Chapter 1.

Charts at the end of this chapter show all possible files
that can be defined on the file description specifications
sheet (see Figure 3-20 through Figure 3-30). The charts
are arranged by device and show the basic entries for all
possible DISK, PRINTER, CRT, KEYBORD, CONSOLE,
WORKSTN, BSCA, and SPECIAL files.

COLUMN 6 (FORM TYPE)
An F must appear in column 6 to identify this line as a
file description specifications statement.

RPG CONTROL AND FILE DESCRIPTION SPECIFICATIONS

IBM

GX21-9092- UM/050·
Printed in U.S.A.

International Business Machines Corporation

1

Program

75 76 77 78 79 80

2

~~~~;~f:ation I

page[DOf_

Programmer

Date

IIIII I

Control Specifications

i

H

!

Line

4

OllJ

5

c:

g3

6

H

~ Number ;::
~ ;; Of Print ~

Size to
~.8 Size to
Compde ~ ~ Execute

j
3

Model

Model 20

~r-----'-rT-r.-"

'----

9

10 11

12 13 14

II

II

16 17 18

~ Positions U

1;
21 22

I

n

I

Address

to Start

o

~ ~

r;-2.£..

~

~~

Refer to the specific System Reference

Cl

'"

Library manual for actual entries.

u..

a:

~I~ll

HHlhflilUH

I- (/)

LL.

24 25 26 27 28 29 30 31 3233 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5

I

I

I

I

I

54 55 56 57 58 59

I

I

I

I

I

I

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

File Description Specifications
File Type

F

File Addition/Unordered

Mode of Processi ng

Extent Exit
for DAM

Length of Key Field or

File Designation

of Record Address Field

End of File

Record Address Type

Filename

Type of File
Organization
Nor Additional Area

File Format
Line

Symbolic
Device

Device

Number of Tracks
for Cylif'lcier Overflow

Name of
Label Exit

Number of Extents

Tape
Rewind

Storage Index

{l

File
Condition
Ul-U8

8
Key ~ield .~
StartLng
x

(3 Overflow Indicator

!

BloCk
Length

~

j

4

a

2

o

3

a

4

o

5

o

6

0

7

o
a

8

1

a

Recold
Length

a:

C

5~

ii:" . . . .
~ ~

Location

Continuation Lines

Z
::J

Option

LI.J

a:

Entry

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

56

9

lL tL OL 69 89 L9 99 99 .9 £9

~9

t9 0969 B9 L9 99 99 .9 £9

~9

t9 as 6. 81> L. 9. SI> tv £1>

~.

tl> 0.6£ 8£ L£ 9£ 9£ \>£ ££

~£

t£ O£

6~ 8~

Ll 9l

S~

I>~ £~ ~~

t~

O~

6t 8t u

9t St .t £t

~t

tt at

6

8

L

9

9

•

£

~

t

~--------------------------------------------------------------.----------------------

Figure 3-1. RPG Control and File Description Specifications

Columns 1-2 (Page)

3-1

\..;

COLUMNS 7-14 (FILENAME)
Entry

Explanation

A valid
filename

Every file used in a program must
have a unique name. The first
character must be alphabetic. The
remaining characters can be any
combination of alphabetic and numeric
characters; however, speCial characters
are not allowed. Blanks cannot appear
between characters in the filename.
The filename can be from 1 to 8
characters long, and must begin
in column 7.

Use columns 7 through 14 to assign a unique name to
every file used in your program, with the following
exceptions:

Input Files
Input files contain records that a program uses as a
source of data. All input files must be further described
on input specifications, with the following exceptions:
•

Preexecution-time tables and arrays and record
address files are described on the extension
specifications. There is, however, a method of
loading arrays using extension and input
specifications. See Chapter 14, Tables and Arrays, for
complete information.

•

Input files using the device name KEYBORD are
further described on the calculation specifications
when the KEY operation code is used.

All input files must be described within the first 24
noncommented file description specifications, including
continuation statements.

• Compile-time tables and arrays do not require a
filename.
Output Files
• If multiple tables or arrays are read in at preexecution
tirrye from the same device, mUltiple filenames are
required.
For naming tables and arrays, see Columns 27-32 in
Chapter 4, Extension Specifications.

Output files contain records written or printed by a
program. All output files, except table output files, must
be further described on the output specifications. Table
output files are further described on extension
specifications.

COLUMN 15 (FILE TYPE)

Update Files

Entry

Explanation
Input file

o

Output file

U

Update file

C

Combined file

Update files are disk files from which a program reads a
record, updates fields in the record, and writes the
record back in the location from which it was read. The
fields to be updated in this file must be described on
the input and output specifications.
Records can be deleted from update files. The file must
be defined as delete-capable when it is built (for further
information on defining delete-capable files, see FILE
Statement in the System Support Reference Manual).
Records are deleted from files by specifying DEL in
columns 16 through 18 of the output specifications (for
further information on deleting records, see Columns
16-18 (ADD/DEL) in Chapter 9). Deleted records are
filled with hex FFs. The record is not physically removed
from the file. When a direct file load of a
delete-capable file is executed, the entire file is
initialized to deleted records (hex FFs). (For further
information on direct file loading of delete-capable files,
see Direct Files in this chapter.)

3-2

File Description Specifications

A chained file or a demand file can be updated at detail
time, total time, or at exception output time. However,
all other disk files can be updated only at detail time or
exception output time during the same program cycle in
which the record is read.
An invalid record update operation message is issued if
the record to be updated has not previously been read
by the program, or if another record in the same file is
retrieved between the retrieval and update of the
specified record. After a record is retrieved, only one
update is allowed if the files are shared (DISP-SHR). A
second update attempt results in an error message,
without retrieving the record again.
You should use care when updating disk files in any
program that supports multiple display stations
(including MRT programs). If a file ;s shared by two or
more display stations in a program and if the present
record is not updated before the next read from the file,
the following error conditions can occur:
• An update can be lost. For example, if a record is
read from file X and displayed at display station 1,
then the same record is read from file X and
displayed at display station 2. The update performed
from one display station might then be destroyed by
an update performed by the other display station.
If this condition occurs and DISP-SHR was specified
for file X, a diagnostic message is issued and the
second update is not performed.
• The wrong record can be updated. For example, if a
record is read from file X and displayed at display
station 1, then a different record is read from file X
and displayed at display station 2. If display station 1
then tries to update the first record, but the program
does not reread that record, the program attempts to
update the last record read from file X. If this
condition occurs during an attempt to update an
indexed file, a diagnostic message is issued and the
requested update is not performed. Otherwise, the
wrong record is updated.
• An update performed by another program sharing the
file can be lost. For example, if a record is read from
file X and is displayed at display station 1, then a
record in a different sector is read from file X and
displayed at display station 2. The second read from
file X causes the system support program product to
free the sector containing the first record. Another
program sharing file X can then update the first
record. If display station 1 also tries to update that
record using the original field values, the updates
made by the other program may be lost.

You can avoid the preceding error conditions by using
one of the following techniques:
• Before performing an update, reread the record and
check that none of the fields being updated have
been changed since the record was displayed for
updating. (If any of the fields were changed, you
might want to redisplay the field for updating again
or, if possible, perform the update using the field
values currently in the record.)
• Within the program, define an array for each disk file.
The array should contain one element for each
display station. When a display station operator
enters a relative record number, or index key of a
record to be updated, the program should check the
array to ensure that no other display station is
updating that record. If no other display station is
updating the requested record, the program should
place the specified relative record number, or index
key, into the array element corresponding to the
display station. The program can then read the
record and display it at the display station. After the
operator enters the updates, the program must reread
the record being updated and update it using the
information entered from the display station. The
progra~ should then blank out the array element
corresponding to the display station.
If the possibility exists that another program may
update the same file concurrently, the file should be
defined as a different logical file for each display
station using the program. Shared input/output must
be used. If you use logical files and specify
DISP-SHR for each logical file, the system support
program product protects the sector containing the
record from updates by other programs. Using
shared input/output reduces the amount of space
required for input/output buffers. In addition, shared
input/ output automatically performs the reread
operation before updating the record.
Note: Additional input/output areas (numeric entry in
column 32 of the file description specifications)
cannot be specified for disk files using a shared
input/outp'ut area.

CAUTION
If shared input/output is not used and the reread of
the record is performed by the program, the record is
momentarily not protected for update by the system
support program product. Another program can then
update that same record before the reread is
completed.

Column 15 (File Type)

3-3

Combined Files

Primary Files

A combined file is both an input file and an output file.
A combined file can be specified only if the device name
in columns 40 through 46 of the file description
specifications is SPECIAL or WORKSTN. A program
reads records from a combined file and includes output
data on the records in the file. The result is one file that
contains both input and output data. Combined files
must be further described on both the input and output
specifications.

An input, combined, or update file can be specified as a
primary file. A primary file is not required in a program.
However, if specified, the primary file is the main file
from which a program reads records. In multifile
processing, the primary file is used to control the order
in which records are selected for processing. (See
Chapter 11, Multifile Processing, for more information on
record selection in primary files.)

COLUMN 16 (FILE DESIGNATION)
Entry

Explanation

P

Primary file

S

Secondary file

C

Chained file

R

Record address file

T

Table file (preexecution-time
tables or arrays)

D

Demand file

Blank

Output file (except chained
output files)

Use column 16 to further identify the use of input,
combined, and update files. Leave the column blank for
all output files except chained output files.

If a primary file is not specified and one or more
secondary files are specified, the first secondary file is
assigned as the primary file. If no primary or secondary
files are specified, you must provide an exit for your
program by setting on the LR indicator.
If KEYBORD is specified as the device for a primary
input file, no other files in the program can be specified
as primary or secondary files. In this case, you must
provide an exit for your program by setting on the LR
indicator.
If WORKSTN is specified as the device for a primary
file, no other files in the program can be specified as
secondary files.

Secondary Files
Secondary files are used only in programs that do
multifile processing. All files used in multifile
processing, except the primary file, are secondary files.
A secondary file can be an input, update, or combined
file. Secondary files are processed in the order in which
they are written in the file description specifications.
See Chapter 11, Multifile Processing, for more
information on record selection for primary and
secondary files.

3-4

File Description Specifications

Chained Files

Table or Array Files

A chained file is a disk file for which the CHAIN
operation code is used to do one of the following:

A table or array file is an input file that contains table or
array entries. Only preexecution-time table or array files
are described on the file description specifications.
However, all tables and arrays (compile time,
preexecution time, and execution time) must be
described by extension specifications. (For a complete
description of tables and arrays, see Chapter 14, Tables
and Arrays.)

• Read records randomly
• Load a nondelete-capable direct file
A chained file can be an input, output, or update file.
See Column 28 (Mode of Processing), Random by
Relative Record Number or Key in this chapter for a
discussion of random processing. See Chapter 10,
Operation Codes, CHAIN, for information about the
CHAIN operation code.
No more than 15 chained and demand files can be
specified for one prOgram.

Table files are not used in record selection and
processing. Table files are only a means of supplying
entries for tables used by the program. When
preexecution-time table or array files are read during the
execution of the program, the program reads all the
entries from the table or array file before it begins
record processing.
Table or array files must be sequential files.

Record Address Files
Demand Files
A record address file is an input file that indicates which
records are to be read from a disk file, and the order in
which these records are to be read. You can use only
one record address file in a program. All record address
files must be further defined on the extension
specifications. Record address files contain either
record-key limits or relative record numbers.
Record address files that contain record-key limits can
be disk files or CONSOLE files. These record address
files are used with indexed files only. See Column 28
(Mode of Processing), Sequential Within Limits in this
chapter for a complete discussion of this topic.

Demand files can be input, update, or combined files.
The READ operation code must be used in the
calculation specifications to read any demand files
except those entered from files assigned to the
KEYBORD. (The KEY operation code must be used in
calculation specifications to read from KEYBORD
demand files.) See Chapter 10, Operation Codes, READ,
for a complete discussion of processing demand files.
No more than 15 demand and chained files can be
specified for one program.

Record address files that contain relative record
numbers in binary format can only be disk files. These
files are called addrout (address output) files, and they
are produced by the sort program. An addrout file can
be used with a sequential, indexed, or direct file. See
Column 28 (Mode of Processing), Random by Addrout
File in this chapter for a complete discussion of this
topic.

Column 16 (File Designation)

3-5

COLUMN 17 (END OF FILE)

COLUMN 18 (SEQUENCE)

Entry

Explanation

Entry

Explanation

Blank

The program can end whether or
not all records from the file
are processed. However, if column
17 is blank for all files, all
records from every file must be
processed before the program
can end. This column must be blank
for WORKSTN or KEYBORD files.

Blank

No sequence checking is to
be done. This column must be
blank for a WORKSTN file.

A

Sequence checking is to be done.
Records in the file are in
ascending order.

D

Sequence checking is to be done.
Records in the file are in
descending order.

E

All records from the file must be
processed before the program can end.
This entry is not valid for files
processed by record address files.

Use column '17 to indicate whether the program can end
before all records from the file are processed. Column
17 applies only to files used in a program that does
multifile processing.
Column 17 can be used only for input, update, or
combined files used as primary, secondary, or record
address files. The devices associated with column 17
are DISK and CONSOLE. End of file for CONSOLE files
is identified when the operator presses command key
12, that is, the Cmd key and the = (equal) key.

Use column 18 to indicate whether the program is to
check the sequence of records. Column 18 applies to
input, update, or combined files used as primary or
secondary files. Sequence checking can be done for
disk files (except those processed randomly) and
CONSOLE files. Use columns 61 and 62 of the input
specifications to, identify the record fi~lds containing the
sequence information.
Sequence checking is required when match fields are
used in the records from the file. When a record from a
matching input file is found to be out of sequence, the
program halts and the operator has three options:

A program that performs multifile processing could
reach the end of one file before reaching the end of the
others. It needs, therefore, some indication of whether
it is to continue reading records from the other files or
end the program. An entry in column 17 provides that
indication.

• Bypass the record out of sequence and read the next
record from the same file.

If the records from all files 'must be processed, column
17 must be blank for all files or contain Es for all files.

• Cancel the entire program.

Note: An entry cannot be made in column 17 for files
assigned to the KEYBORD and WORKSTN devices. To
terminate the program with a primary file assigned to
the KEYBORD, the LR indicator must be set on by
calculation specifications.

• Bypass the record out of sequence, turn on the LR
indicator, and perform all end-of-job and final total
procedures.

If column 18 contains an entry and matching records are
specified, the entry in column 18 must be the same for
all files. If column 18 is left blank and matching records
are specified, then ascending order is assumed for a
primary file and the sequence of the primary file is
assumed for all secondary files.
COLUMN 19 (FILE FORMAT)
Entry

Explanation

F or blank

Fixed-length records

An F in cOlufnn i 9 indicates thai aii rel:un.i:; in the fiie
are of the same length. If this column is blank, F is
assumed.
3-6

File Description Specifications

COLUMNS 20-23 (BLOCK LENGTH)

COLUMNS 24-27 (RECORD LENGTH)

Entry

Explanation

Entry

Explanation

Blank

The block length for this file
equals the record length. These
columns must be blank for a
WORKSTN file and can be blank
for any other file.

1-4096

Record length for disk
or SPECIAL files.

1-4075

Record length for BSCA files.

2-1518

Record length for CONSOLE files.

1-79

Length of largest field keyed
for KEYBORD files.

1-79

Length of .largest output record
for CRT files.

1-198

Length of largest output record
for printer files. (Entries from
133 through 198 should only be used
for printers with 198 print positions.)

2-58

Twice the record address field
length for a record address file
assigned to the CONSOLE device.

1-9999

Length of largest input or output
record for a WORKSTN file.

1-9999

1-9999

Block length for disk equals the
record length or is a multiple
of the record length.
Block length for a SPECIAL file
equals the record length or
is greater than the record
length.

1-4075

Block length for a BSCA file
equals the record length or is
a multiple of the record length.

2-1518

Block length for a CONSOLE file,
if entered, must equal the record
length.

1-79

Length of largest field keyed for
a KEYBORD file.

1-79

Length of largest output record
for a CRT file.

1-198

Length of largest output record
for a printer file. (Entries from
133 through 198 should only be
used for printers with 198
print positions.)

Use columns 20 through 23 to specify the block length
for the file. The entry made in columns 20 through 23
depends on the device named for the file. The block
length entry must end in column 23, and leading zeros
can be omitted (see Figure 3-2).

Use columns 24 through 27 to indicate the length of the
records in a file. An entry must be made for each file,
and the entry depends on the device named for the file.
Entries in these columns must end in column 27, and
leading zeros can be omitted (Figure 3-2).
All records in one file must be the same length. (For
update files, the length of the record after the record is
updated must be the same as it was before the record
was updated.) The maximum length allowed depends
upon the device assigned to the file (see Figure 3-2).
The record length specified can be shorter than the
maximum length allowed for the device but not longer.

The function of the block length entry is to specify the
amount of main storage to use for the input/ output
area. The maximum block length is 9999. The block
length entered for disk files must equal the record
length or be a multiple of the record length. If the
record length is entered but the block length is not
specified, RPG assumes the block length equals the
record length.

Columns 20-23 (Block Length)

3-7

Cols 40-46
Device

Cols 20-23
Block Length l

Cols 24-27
Record Length

Maximum
Record Length

DISK

Record length or a multiple
of record length

Record length

4096

CONSOLE

Record length

Record length

1518

Record length

58

Record address
record length

file

KEYBORD

Length of largest field
to be keyed

Length of largest field
to be keyed

79 - alphameric
15 - numeric

PRINTER

Record length

Record length

198

CRT

Length of longest output
record

Length of longest
output record

79

SPECIAL

Record length or greater
than the record length

Record length

4096

BSCA

Record length or a multiple
of record length

Record length

4075

WORKSTN

Must be blank

Length of longest
input or output
record

9999

, Block length must be blank for a WORKSTN file and can be blank for any other file.
Figure 3-2. Block Length and Record Length Entries

The record length for KEYBORD files should be the
length of the largest field to be keyed (that is, the
record length equals the largest field length specified in
columns 49 through 51 of the calculation specifications
when the KEY operation code is used). If the KEY
operation is used to display a message, you must also
consider the length of the message when you specify
the record length for the KEYBORD file. The maximum
alphameric field length is 79 characters. and the
maximum numeric field length is 15 characters. If the
record length specified for a KEYBORD file is 40 or less,
a display of six lines with 40 characters per line is
centered both vertically and horizontally on the display
screen. If the record length is greater than 40, the
display consi~ts of 24 lines with 79 characters per line.

COLUMN 28 (MODE OF PROCESSING)
Entry

Explanation

Blank

Consecutive'
Sequential by key'

L

Sequential within limits'

R

Random by relative record number
Random by key
Random by add rout file
Direct file load (random load)

'See Shared File Considerations in this chapter.

3-8

File Description Specifications

Use column 28 to indicate the method by which records
are to be read from the file, or to indicate that a direct
file load (random load) is to take place.
For disk files specified as primary, secondary, demand,
or chained, the possible processing methods depend
upon the organizations of the files (see Figure 3-3). For
the other types of files, consecutive processing is the
only possible method.
Column 31 further identifies the access method for the
program. See Column 31 (Record Address Type) in this
chapter.
Primary, Secondary, or Demand Files
File
Organization

Consecutive
The consecutive processing method applies to
sequential, indexed, and direct input disk files (blank in
column 31). During consecutive processing, records are
read in the order they appear in the file. The contents of
spaces left for missing records in direct files are read as
though the records were there, unless the file is defined
as delete-capable. If the file is delete-capable, deleted
or missing records are bypassed. (When a
non-delete-capable direct file is loaded, such spaces are
filled with blanks. If the file is delete-capable, the
spaces are filled with hex FFs to designate deleted
records.) If an indexed file is processed consecutively,
the index is not used. Records in the file can only be
read; they cannot be updated or added to the file.

Possible Processing Methods

Sequential

Consecutively
Randomly by add rout file

Direct

Consecutively
Randomly by add rout file
(except demand files)

The program reads records from the file until either the
end of that file is reached or the program ends because
of an end-of-file condition of another file. See Column
17 (End of File) in this chapter for more information
about the second condition.

Sequential by Key
Indexed

Sequentially by key
Sequentially within limits
Randomly by addrout file
Consecutively (not using the index)

Chained Files
File
Organization

Possible Processing Methods

Sequential

Randomly by relative record number

Direct

Randomly by relative record number

Indexed

Randomly by key or relative
record number

Figure 3-3. Possible Processing Methods for Disk Files

The sequential-by-key method of processing applies
only to indexed disk files that are used as primary files,
secondary files, or demand files.
Records are read in ascending key sequence. However,
records added to the file since the last sort of the index
cannot be accessed unless the I FI lE attribute is
specified. If the file is to be processed sequentially as
an input file or if the file is to be updated or added to,
the keys must be sorted to allow access to all the added
records in the file. To ensure that the keys are sorted,
make sure that the FilE OCl statement does not have
DISP-SH R specified, or use the KEYSORT procedure
(see Shared File Considerations in this chapter). The
program reads records until all records in the file are
processed or the program ends because of the
end-of-file condition of another file. See Column 17
(End of File) in this chapter for more information about
the second condition.

Column 28 (Mode of Processing)

3-9

Sequential Within Limits

The sequential-within-limits method of processing
applies only to indexed disk files used as primary files,
secondary files, or demand files. A limits record
consists of the lowest record key and the highest record
key of the records in the indexed disk file that are to be
read. Limits records are contained in a record address
file. The record address file can be a disk file or a
CONSOLE file.
The sequential-within-limits method can be executed
when you use either (1) a record address file containing
limits records or (2) the SETLL operation code in
calculation specifications. However, records added to
the file since the last sort of the index cannot be
accessed unless the IFILE attribute is specified (see
Shared File Considerations in this chapter).

. The record address file containing the limits and the
files being processed by limits can have record keys in
different formats. For example, one file can have
packed keys and the other zoned decimal keys. During
execution time, the format of the key from the record
address file is changed to the format of the record key
in the file being processed by limits. If the formats
differ, the format of the keys for each file must be
indicated by an A or a P in column 31. Also, the zoned
decimal key length must be twice the packed length,
minus one or two. See Packed Decimal Format (P) in
Chapter 7 for more information concerning this
calculation.
Note: A key cannot contain any hex FF characters.

The same set of limits can appear in more than one
record in the record address file. Data records,
therefore, can be processed as many times as you want.

To process sequentially within limits, the program reads:
• A limits record from the record address file

If the two record keys in a limits record are equal, only
one data record is read.

• Records with keys greater than or equal to the low
record key and less than or equal to the high record
key

Note: Double buffering (column 32) should not be
specified for the record address file.

The program repeats this procedure until either the end
of the record address file is reached or the program
ends because of the end-of-file condition of another
file. See Column 17 (End of File) in this chapter for
more information about the second condition.

The SETLL operation code method of limits processing
applies to any indexed disk file used as a demand file (D
in column 16 and L in column 28 of the file description
specifications). You cannot, however, process an
indexed demand file with SETLL if you are using a
record address file to set the limits of the file.

The format of records in a record address file containing
limits must conform to these rules:
• Only one set of limits is allowed per record in the
record address file. The length of a record in a
record address file, therefore, must be twice the
length of the record key.
• The low record key must begin in position 1 of the
record. The high record key must immediately follow
the low record key. A record key can be from 1 to
29 characters in length.
• The low record key and the high record key must
have the same length, and each key must have the
same length as the key field length specified in
columns 29 and 30. Therefore, leading zeros may be
necessary when numeric record keys are specified.
• An alphameric record key can contain blanks.

3-10

File Description Specifications

The maximum number of files that can be processed
with the SETLL operation is limited by the number of
demand files permitted in an RPG II program. A
maximum of 15 demand and / or chained files is allowed
per program. See Figure 3-4 for an example of SETLL.
For more information on how to use the SETLL
operation code to set limits, see Chapter 10, Operation
Codes. I
When the end-of-file indicator is turned on, another
SETLL can be specified and processing of the file can
continue. However, it is not necessary to wait for end
of file before you specify another SETLL operation.

Random by Relative Record Number or Key
Random processing by relative record number or by key
applies to chained files only. Either method requires use
of t"e CHAI N operation code. The records of a file to
be read or written must be processed by the CHAIN
operation code. The records are read only when the
CHAI N statements that identify them are executed.
For sequential and direct files, relative record numbers
must be used to identify the records (see Figure 3-5).
Relative record numbers identify the positions of the
records relative to the beginning of the file. For
example, the relative record numbers of the first, fifth,
and seventh records in a file are 1, 5, and 7
respectively.
For indexed files, record keys must be used to identify
the records (see Figure 3-6). A record key is the
information from the key field of a record. The
information is used in the index portion of the file to
identify the record.
When random processing is used, records are read from
the chained update file during the calculation phase of
the program. Records can be read during total
calculations and updated during total output, or be read
during detail calculations and updated during detail
output (see Figure 3-7).

Column 28 (Mode of Processing)

3-11

File Description Specifications
File Type

F

Mode of Processing

End

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

r---

of File

Record Address Type
Sequence

Filename
Line

:u~ I
~
4

:3

5 6

7

8

9

w

~
22

is

Record
Length

Block

Length

~
~

5

Device

Number of Extents

Tape

L.U

Rewind

Storage Index

~

~

8

Overflow Indicator

Condition

-5
Key Field .~
Starting)(

0: --

~ ~

Symbolic

Device

Type of File
Organization
("\lor Additional Area

File Format

Number of Tracks
for Cylil"lcler Overflow

Nameof
Label Exit

~ ~

Location

Option

W

~

Entry

10'1 12 13 14 15 16 17 18 '9 2021 222324252627 28 2930 31 32333435363738394041 4243444546 4748495051 52 53 54 5556575859

Ul.~

Z

Continuation Lines

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I

I

I
o

I Iii I I

F

7

I

I

I

The input disk file, MASTE R, described as an indexed
file to be processed by record keys is to be processed
within the limits contained on the record address file,
LIM ITS. The LIM ITS file, which is further described on
the extension specifications sheet, is entered from the
CaNSO LE device.

Each set of limits read from LIM ITS consists of the low
and high account numbers to be processed. Because the
account number key field (ACCT) is eight positions long,
each set of limits includes two 8-position keys.

Extension Specifications

E

Record Sequence of the Chaining File
Number

I--

Number of the Chaining Field

To Filename

Line

~

From Filename

~
3

4

o

1

o

2

Table or
Array Name

5

6

7

8

9

of

Number

Entries

of

Per
Record

Entries

of

Table or
Array Name

of

Entry

(Alternating

Entry

Length

Per Table
or Array

Length

Comments

Format)

10 11 12 13 14 15 16 17 18 19 20 21 22 23 2425 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 4748 49 50 51 52 53 54 55 56 57 58 596061 62 63 64 6566 67 68 69 70 71 72 73 74

I II
!

I

!

1

i

!

i

I

I

o

3
1

!

I

I

I
I

i

i

I

I

As MASTER is processed within each set of limits, the
corresponding records are written out on the printer
output file, PRINT. Processing is complete when all
sets of limits have been processed.

Input Specifications

I

z=>

Filename

Line

&

"-

>--

~

;---

o

4

0

1

I,... IH';l

0

2

I

0

3

I

0

4

IS

0

5

I

0

6

I

5

6

R

7

8

9

n

I

A

I

Field Name

s
Position

° uO

~

Cl

N

~

Position

u

~
rn

z

Cl

u:R

HS

MA 5 It' EIR N5

~

Position

~§j
z u u

0

~

o

1"1
~2

I

From

Iii

I

I

I
I 1
I I I I I I I I I I I I I I I I I I I

I

I

!

I

I

I

!

I I

I

I

i

i
!

~

z u

I

I I II I I

I
!

!

I I

I

I

I

JI

I I

i

!
I

I

I

I I

I

Figure 3-4 (Part 1 of 2). Processing Indexed Files Sequentially Within Limits

3-12

0;

u::

-.;

To

Zero
Plus Minus or
Blank

~
£l

10111213 1415 1G 17 18 19 20 21222324 2526 27 28 29 3031 3233 34 35 36 37 38 39 40 4142 43 44 45 46 47 48495051 52535455565758 59 60 6162 63 64 65 66 67 68 6970 71 72 73 74

I. _

7

z

°

~~

t
it j

~6

Field
Indicators

Field Location
3

2

1

f-;ND

3

0

Record Identification Codes

0

~

I---

File Description Specifications

I
I

I

I
I

"
l1

I

I

Is AC'c It:

;1

I
!

IlD~ a..-AN IA:nID
:

I

i

I

1

i~~ NA:ri~
!
I

!
I

!
1

I

I

I

I

I

I
i

I

I I

i
I

!8 Ac,.!T'

~

I

I
I

I

I

I

I
I

I

I

I

I

I

i

I

I

I

i

I

I

I
I

I

!

I

!

!

!

!

I
I

i

I

I
I

I

I

I

Calculation Specifications

C

Indicators

I---

1

At

Operation

Factor 1

Plus Minus! Zero
Compare
1>21<211-2
Lookup( Factor 21 is
High Low Equal

Factor 2
Length

Name
0

Indicators
Arithmetic

Line

0

0

z

z

Z

Resulting

Result Field

910 1112 1314 1516 17 IS 19 20 21 22 23 24 25 26 27 2S 29 30 31 32 33 34 35 35 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

3

4

5

0

1

C

o

2

o

3

c
c

o
o

4

C

5

C

o

6

C

5455 56 57 58 59 60 61 62 63 64 65 66 67 6S 69 70 71 72 73 74

\ la IAIA IAI. I.IA IA I ~IE IT:l ~ l'!i 'M:~ :Sll el~

INlq~

IN:q:q

Comments

qq

SE loiN
IRIt;IAn ~:l"I :AS IT fJ~

I

File SMASTER is processed by the SETLL operation code.
It is characterized by having no extension specifications,
and its filename appears in factor 2 of the SETLL operation
code. In this example the first record read from fi Ie
SMASTE R would be the one whose key is equal to or the
next higher than the literal' AAAAAAAA'. Records are
read sequentially to end of file unless the cycle is interrupted
by additional SETLL operations.

Output Specifications

o

-5
-

Space

iUc

Filename

Line

~ R
A
5

6

4

o

1T 0IPiKJlINT,

0121

0

o 13'

0

o

0

~

ND

10 11 12 13J 14 15 16 17 1f

3

4'

Output Indicators

Skip

~~

I---

9

I

0
<

I·: i . :

il I 1U-~-L,

n

f--

.

i

11.1: ,I

o 9T

'Tn :

L.....--"I,--,--O-'-L

:

i

I

Ii

- f--

L-J

I

c H
-

-~

+:
I

•.

i~~!;2

I

Z

• AUTO

I

Ui

~::

~ ~ ~: :.' I~I

.g

~

W

OJ

Record

•

:~OO"""."'

::
1

2

3

4

No Sign

CR

~ ~

to:::nt

.e:
a.

++~;J,_j,_-~1-i I_,~' ! 1
i
I~~~_ . Li8
!

I

.!
'1

i

:

Ii, I
i

--.:
__1- , _ U

N'A.HAOR
:
!

i

1

i-I':-.L
I

I

I

1

~2L~ -jutU 1o

I

I" I. ~ , -Ij 1 I 1~,l,
~-H-l_~)-- __ 1___ I I!

I

:,~ I

Z

I

Field Name

Zero Balances

Commas

5

6

7

8

9

Ed;. :,,;

x

=

y

=

Remove

~1~tSeSign

~;~,:.

,-

1011121314151617 IS 19 202122 23 24 •

19 20 21 22 23 24 I 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

~'-;f °
--U-,c'-'---H--r-~
o 61 0 ] ~tl
OISI

'.I I"~:

Z

:>

( ( '

!

:

I:

l4~C.IT;l

:'0
!

i

iii
Ii

:

1

I

!

!

!

,Ni"'E

I I

W-J-J

,I

1

1

1I !
I I!

a"

-c-+~..
_L

I'

I

•

,I

U-W-!
!;

Iii

iii TT !

: :ilc _~~treR !~:::
: ,~!s :!: II
W

-~-i~_J_': i'tr---r--:----;-i
,,~_L '--~_

!!

I

;

i i
: i i
Iii!;

I

i

;

II

!

i

i
i

i I
II

Ii
II

:!
I I

I

"I

I

I

I

!

t

:

1

I

i

:

'.

I!

11!!:

-r-r-r-r--:-

[

I

I!

.
il I TI ~
I
_____L-lI,-"-I...J._~, _ _:""",,:,_ _ _ _~~---'-_ _L...J.-'---1-.--J._--':"--..C--.L..J

Figure 3·4 (Part 2 of 2). Processing Indexed Files Sequentially Within Limits

Column 28 (Mode of Processing)

3·13

File Description Specifications
File Type

File Addition/Unordered

Mode of Processi ng

Extent Exit
for DAM

Length of Key Field or

File Designation

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Symbolic

Device

Type of File

Device

Number of Extents

Tape

Organization

File Format
"

o

2

3

o

4

~

0

~Overfl~~

BlOCk

Record

Length

Length

~

t:::

e

~
~ ~

Key Field

~

Starting

~

Location

Condition

z

Continuation Lines

r.----------r-------~~
Option
Entry
~

UJ

The direct update file, MASTE R, is to be processed
randomly by relative record numbers. The account
number (ACCT) from the primary DISK file, CHANG E,
is used as the relative record number. As each record is
read from CHANGE, the MASTER record corresponding

U1-~

~

60 61 62636465 6667 68 69 70 11 72 7374

10 11 12 13 14 15 16 1"1 18 19 2021 22 23 24252627 28 2930 31 323334 3536373839 4041 4243444546 47484950 51 52 53 54 55 56 575859

o

Rewind

Storage Index

~

or Additional Area

N

line

Number of Tracks
for Cylil"lcier Overflow

Name of
Label Exit

to the account number is read during calculation time by
the CHAIN operation code. At detail output time, the
data in the NEW field replaces the original data in the
NAMADR field and the updated MASTER record is output to its original relative record location on the disk file.

Input Specifications
Record Identification Codes

I

0

Filename

Line

~
z

3

4

5

6

o

2

I

o

3

I

o

4

I

05

I

1

8

9

-;:;

~

Position

a;

~

U

'U

Position

~

~
0

z

Position

~
u6

Field
Indicators

Field Location

I--

Jj

~
0

z

e

~

~ 6

Field Name

-~

a:
.J

From

0':
~

To

0

:2~
.~

]

:§

u.u.

g

.~ g'

~~
8 :;,u

~

OJ

Q;

~

0

~
"0

j

Zero
Plus Minus or

Blank

"0
0;

u:

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 41 48 49 50 51 52 53 54 55 56 51 58 59 6061 62 63 64 65 66 61 68 69 10 11 12 13 14

INS
~ ~1\1t\l6!£

Iii

t1

INS

~

8~ACdT

rO+6~-Ir+~r+~-r~-r-r+-rr+1-r+~rr~-r++1-r+1-r+~rr.~-r~~ql~~~~~~N~~~~~Ir++4-r~-rr+1-r+-~jrr+4l~
LO~7~LI~~~~-L.-LJ-~~-L-L-LJ-~_~-L-L~~~~-L-L~~LJ-L-LJ-~LJ-L_L_LJ_L-LJ-~L~-L-LJ-~~~-L-L-L_~~J-L-L~-L~~~
Calculation Specifications

-

C

Indicators

~

Arithmetic

AL

g~~

Line

.g I

Factor 2

Operation

Factor 1

At

5

01 I
1

01 1
2

~~

Length

Name

I- 0 a;"

E "' '"

4

Indicators

0_

.Ja:
=0

3

Resulting

Result Field

~ ~

Plus IMinusl Zero
Compare

Comments

1>211<211=2

Lookup( Factor 2)is

& 85"

z

6

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 2829 3031 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 5051 5253 54 55 5651 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

7

8

0

0

(3

z

z

o

High

I I I I I ~IHIAIT~ 14IA~IT~IRI I I I I I I I I I I
I I I I I I I I I I I I I 1IIIIJJ~l I I I I I iJ

~~trrl

I QJI2
I

c
c

-

I

Low Equal

~

I I II II IIIII I III1
I I I IIIIIIIIIIIIII

Output Specifications

o

Space

~ 4~-+--~--~---r----~--~

e
J:

Filename

Line

I-

>

5

6

0

0

o

R

'AND
1

8

I I

w

And

And

'"

rY
. . '~.

--'"---'---'---'---"""1>

ur

End

I=c=o=~=:=as=l=z=ert=oo=::=r:~=~c=es=l=N=O=S=ign=l==C:=}=~=l

'AUTO

in
Output
Record

Yes
No

No
Yes

B
C

K
L

No

No

D

M

a:
.J

: :

~I:~~~:n

Field Edit
Z = Zero
Suppress

Constant or Edit Word

OJ

Q;
1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 20 21 2223 24 '

i-------- -- --i--f-

9 1011 12 13 14 15 16 17 18 1920 21 22 23 24 25 26 21 28 29 30 31 32333435 36313839 4041 4243444546 47 48 49 5051 52 53545556 51 58596061 626364 65666168 69 10 71 72 13 14

~r--O -f---j----f- -

-

. -

-

---c-

f--N~~+--- - --- --if--+!,+~-+-++-+-+--f--rl+'-

I - - f - - T--

Figure 3-5. Random Processing of a Direct File by Relative Record Number

3-14

II

Position

0

1--:+2_1+-+:--1-~--Ij-ILIJ""'A~'-t-'LjlI:
..--t'--'IK"I-t_f""'~1 - -1- - --- - - «1~~3_

o

Field Name

E L

fJi"DD

~
4

(I)

i~~.!

I-

3

Output Indicators

Skip

w u.

I--

File Description Specifications

-r-- .-----t----l-+-+-+-t--I

File Description Specifications
File Type

F

-

Mode of Processi ng

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

End of File

Record Address Type
Sequence

Filename

Type of File
Organization
Nor Aelditional Area

File Format
line

~uOI
~
~ €

4

'j

7

8

9

Record

Block
Length

~

~

t:

~

Length

~ ~

~ ~

I

•

I

I

Option

Ul'~

~

Entry

60 61 62 53 64 65 66 67 68 69 70 71

n 73 74

~ m~~ll~~i +-+i-+-+-+-i"---r-I,t+-+-+--+-+-H--+--J-+-+-+-1H-+-+--+- f-++--

--+-t-+-t-t-+--+-+--+-+---+-+4-f-t-t-+-I-'-I--

--'-i

I

I

z

Continuatton Lines

1011 12 13 14 15 1611 18 19 2021 222324252627 28 2930 31 3233343536373839404142414445464748495051 52 5354 5556575859

'I

~
Condition

Key Field ~
Starting;
Location
UJ

e

~

0: :~~~~f- ~~E._~ +5% ~~ R B~I
F

Tape

Storage Index

~

r--- §

1

a 4/

Number of Extents

o O\lerflow Indicator 8

i
UJ

Symbolic
Device

Device

Number of Tracks
for Cylincier O\lerflow

Nameo!
Lauel Exit

ill

I

data in the NEW field of CHANGE replaces the original
data in the NAMADR field. The updated MASTER
record is then written on its original disk location. See
Column 32 (File Organization or Additional I/O Area)
in this chapter for a description of indexed file organization.

MASTER, a chained update file, is described on the file
description specifications sheet as an indexed file to be
processed by keys. As each record is read from the input
disk file, CHANGE, the account number (ACCT) is used
as the key to chain to the corresponding record in
MASTER at calculation time. At detail output time, the

Input Specifications
a

I
r--

Record Identification Codes

Field
Indicators

Field Location

~
Filename

Line

Field Name

.~

Position

~
0

Position

~

0
N

z u

3

0

0;
Vl

Position

~

~

0

z U 6

Cl
N

z u 6

From

c:
...J
co

0-

To

~.~

Q:

Vl

Cl

~
]

0
0

:9-0

~

.~ Qj

'0

u..u::

~

~

g

.S

8

~6

-5

:~

Zero
Plus Minus or

Blank

'0
0;

u::

3 4 5 6 7 8 9 10 11 12 t3 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4647 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

a 12 i

I

I

!

~SI

IIII

!

i:

I

:1

I

14tr. T

~

Ij
IS lAC. ":1"
IA
i
i ~L-I~~-L~~~I~_!_~I~-L-L_~~~~-L~~L-Li-L-L~~Li-L-L~L-~~~.-L~~~-L-L~~~-+-L~~~~_~-L~~
i:

rIO~166,:-rI~·,-~~i-+l-ri~I-,-+-r~.r+~
01

7

I

1

Calculation Specifications

C
-

Indicators

~.

Resulting
Inuicators

Result Field

0_
...Jc:

Arithmetic

=0

AL

AL

~~~
'00:,"

Line

E :::

~
3 4 5 6

I

Vl

8 5'

~

7 8

9 10 11 12

'0

Length

Plus Minusl Zero

Comments

Compare
~ ~ 1>21<211-2

~~ Lookup(Factor 2)1,
il High Low Equal
o I
17
18
19
20
2t
22
23
24
25
26
27
2829
303t
32
15 16
33 34 35 36 37 38 39 40 41 42 4344 45 4647 48 49 50 51 5253 54 55 56 57 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
0

Z

Z

1314

IAJClcJTI I I I I I IcJHAI1~ INI~smEJ~ I I I I I I I I II
IIIIIIIII IIII IIIIIIIII IIIII [I

I ItJ2

C
011
01 2 1 c

.g :2'

Factor 2

Operation

Factor 1

Name

I-

I

~~

I I IIII IIIIII IIII
I I I II I I I I I I I I I I I I

Output Specifications

o

W

Line

~

Space

Filename

~ ~~~
~ R
A
3

4

0111

5

6

0

o 12; 0
01310

7

8

~~

1.1
And
0

_

'0

OJ

«

Z

I

~

(fr...

Output Indicators

And

'0

I

'0

Z

I

Z

c:

End

«

Record

Commas

V

II

Field Name

• AUTO

'.::

~

I
1

r

OJ

No Sign

CR

:

X = Remove

1
2
3

A
B
C

J
K
L
M

Y

to Print

Plus Sign

Yes
N

No

NOconstant :r Edit :ord

N~s. Y~s

~ ~ :~St'~:tn 2

I

Zero Balances

Yes
Y

D.te
Field Edit
Z = Zero
=

Suppress

co

Ci:

1

I

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 '

•
9 1011 12131415
161712192021222324 252627282930:31 32333435363738394041424344454647484950 51525;) 54 55 5657585960616263646566676869707172 73 74

MAr:l U::IKJ i

II
i I

Skip

~ ~_~
~~ ~ ~

iD

1: ru-I t- .
i

I-I--LI-

ml-t ~td~

i l l
I

1.litl.J -I-r---~ l-L

~E.~, -r-r
:1;:!

1--

!

I

~~

'1

II
I

I

iii

I.

I -+-+--+-+-+-+-+-+-+-+-I--+-I--+-t
.t--+-I-t-t-+-+-+-t-tl-r+--c-

i

I

I

Figure 3-6. Random Processing of an Indexed File by Key
Column 28 (Mode of Processing)

3-15

File Description Specifications
File Type

F

-

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or

File Designation

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Type of File

Line

23

u

,:3

34

789

5

1011'2'3

Vi
0:

'41~

a Overflow Indicator

D

~I

D

~

D
L.U

~
>

Record

~

cr

~ ~

::J

Number of Extents

Tape

IF ~5~

U

Condition

0

~

Continuation Lines

IS: Trq(p

Riu

~~

L __

I

K

a z)IslKll I

,

__ ,-LL

I

Z

I)lS IK!

~ j

Indexed file, MASTE R, is described as a chained update
file to be processed by keys. The key field in MASTER
is ITEM NO, in positions 1 through 10. As each record
is read from TRANS, the input transaction file, the
ITEM NO field is used as the key to chain to MASTER
during calculations. If the character 2 is in position 64
of the transaction record, the quantity in ADJUST is

I

I I

!

60 61 62 63 64 65 66 67 68 69 707172 7374

III
-1lJJJ

I II I I
I

I
!

!

I

~

Entry

Option

U'~

~

::J

Location

lD~ R11i ~tI

~
File

Storage Index

-0
0

18 19 2021 22 23 24252627 28 29 30 31 32 33 34 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

F

3

e
:
t:
Key Field
e
Starting

~

Length

~u:

1617

°121 MAS rr~E~IU~Ll C
°T 1 FfrR:AN~~Jl~

Block
Length

Symbolic
Device

Device

...J

Organization
Nor Additional Area

File Format

Number of Tracks
for Cylir"lcler Overflow

Name of
Label Exit

i

!

:

I
I

:

!

I

I

I

I

I
:

I

I

added to the ONHAND field of MASTER. If the
character 3 is in position 64, ADJUST is subtracted
from ON HAND. If the character 1 appears in location
64 of the MASTER record, the updated ONHAND
field is written out on its original location in the
MASTER record at detail output time.

Input Specifications
Record Identification Codes

I

,

I---

3

~

3

4

5

°,
°
°

7

8

9

From

Position

~
-

0;

-,;

~

'c

~
-0

u: u:

5
~

"-

To

I ~~ Ci

~.1

NS

j

6

~

8

Ii!

Zero

PillS Minus or

Blank

0;

u:

I

I

li~ Ir:riEMN~

rJ.

I

I

I

!

I

I

I

1

!

I

i

I
I

!

3

!

I

I

i

4

!

I

I

I

i

i

i

I I ,

I

5

1-0+-6+-+-Il-it'+-IR+-A+-N+-~+-I+-1+-+--N+C~+·-+--,~~~,l-~2.-l--+!-

°
°

Position

0

-,;

1011 12 13 14 1!3 16 17 18 19 20 21 222324 25 2627 28293031 32 33 34 35 36 37 38 39 40 41 42 43 44454647 48 49 50 51 5:' :;;,3 5.J 55 513 57 55 596061 626364 65 66 67 68 69 7071 727374

I

2

°
°

6

Field Name

~

Position

0

...J

0

Filename

Line

Field
Indicators

Field Location

2

7

I

8

I

1 ~~

~

bR

illl C2

!

:

1

~~asbW~ANO:

15h

I
~

!

'

K:3
j'

L'..L°--L..L1..L..L...LJ-L-L-ILL1-L_.L...L...L.L-'_J.1

i

I

lITrE MN'O I

111.:d!IAn,

ur

1

!

!

'

I~

l-o+,9-+I--l-I~1+--+---+-1+-1+--+'---+-+-+-+-~++lJ!---+-+-+-f-l-i+--+--l---+--I-+~IH-+.+_r-_+-__ I-_+-_+M--t!-l_:111t1

I

I

li

I

!

Iii

!

IIi!

I

I

!

I

I

i

I

\15lt I

I

i

I
I

I

I

!

!

i

'

:

i

I

Calculation Specifications

c
-

Indicators

Arithmetic

Operation

Factor 1

,g :t Plu. IM,nusl Zero

Factor 2

.~ ;-

~
~

line

3

Resulting
Indicators

Result Field

4

5

0'

Name

Length ]

Comments

Compare

i ' > 21, < 2 , 2
=

j

o

0

0

z

z

z

6

9 10 11 12 13 14 15 1617181920 21 22 23242526 27 2829 3031 32 33343536 37383940 41 42 4344454647 48 49 5051 52 53 54 55565758596061 62 6364 6566 676869 70 71 727374

'u 0

C

Lookup! Factor
High

I

tlHIAllNN A~~~I~

.1 \ It=!rllN

2hs

Low Equal

~I'::

I

!

Output Specifications
i£

0

'§
W-Lf

I--Filename

Line

~

~~
-~

f-

~
4

5

°I, I
°121

6

~

D

Jd

E L

'A fofo

0

~
~fA N D
7

8

9

:;: ~-

I III I I

II

f

___ .

-

-~

H

Figure 3-7. Updating an Indexed File
3-16

I

-

~

File Description Specifications

Field Name

1
!II ~-

10" 12 13 14 1516 1718 19 20 2122 232412526 2J28 29

oIMAISI'tlsRI
0

.E

~~ ~~

f-

3

Output Indicators

Skip

Space

f::;;

I~ N~

I 'I

a

:>

Commas

Zero Balances
to Print

Yes
Yes
No
No

Yes
No
Yes
No

II

End
Position

31~ g
30~31
~N~~j~~
H' H- +~..
in

"AUTO

~ ~

,

2
3
4

CR

-

X =

A
B

J

Y =

K
L
M

Z =

C
D

Remove
Plus Sign
Date

Field Edit
Zero
Suppress

a:

Output

I

No Sign

Record

Constant or Edit Word

Q::

'

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 1617 1819 2021 222324 '

32 33 34 35 36 37 3R 39 40 41 42 43 44 4S 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 6R 69 7Q 71727374

I

I

I

,

~

I I

! I

I I :1

!II I!1

II I! 111 :11

;

!

-1

ilL] Ill!
!

i

;

:

I

!

!

i

I
I

!

I

:

!

!

;

Random by Addrout File
An add rout (address output) file is a record address file
produced by the sort program. It contains the relative
record numbers of the records in a disk file. (Each
relative record number is a 3-byte binary field.) You can
use add rout files to process input or update files that
are designated as primary or secondary files.

COLUMNS 29-30 (LENGTH OF KEY FIELD OR
RECORD ADDRESS· FIELD)
Entry

Explanation

1-29

Length of record key or
relative record number

Use columns 29 and 30 to indicate:
When an RPG II program uses an add rout file, it reads a
binary relative record number from that file. The binary
relative record number is then converted to a disk
address, and the record at that address in the original
file is located and read. Records are read in this manner
until either the end of the add rout file is reached or the
program ends because of the end-of-file condition of
another file (see Figure 3-8). See Column 17 (End of
File) in this chapter for more information about the
second condition.
Because addrout files are record address files, they
must be further described on the extension
specifications. Both the addrout file and the file to be
processed by the add rout file must be described on the
file description specifications.

• The length in bytes of the record keys in indexed files
and record address files
• The length of the relative record numbers in addrout
files, which is always 3
Columns 29 and 30 apply only to indexed files and
record address files.
All of the key fields in the records in an indexed file
must be the same length. The maximum length is 29
bytes (8 bytes for record keys in packed format). All of
the relative record numbers contained in an add rout file
are 3 characters long.

Shared File Considerations
After an indexed file has records added to it, the keys
might be out of sequence. If the file is to be processed
sequentially as an input file (blank or L in column 28) or
if the file is to be updated or added to, the keys must
be sorted to allow access to all the records in the file,
unless the IFILE attribute is specified. To ensure that
the keys are sorted, make sure the FILE DCL statement
does not have DISP-SHR specified, or use the
KEYSDRT command. An indexed file that is created
(output file) has its keys sorted at job termination if an
unordered load was specified (U in column 66 of the file
description specifications). For further information on
key sorting, see Key Sorting for Indexed Files in Chapter
2 of the Concepts and Design Guide.
IFILE support allows shared, indexed sequential
processing of all added records in an indexed file.
Without IFILE support, indexed sequential processing is
limited to only those records having index entries in the
primary portion of the index. Indexed files can be given
the IFILE attribute by specifying it on the FILE OCL
statement or in the SETFILE or BLDFILE procedure. For
more information about I FI LE support, see Indexed Files
with the IFILE Attribute in Chapter 2 of the System/34
Concepts and Design Guide.

Columns 29-30 (Length of Key Field or Record Address Field)

3-17

File Description Specifications
File Type

F
-

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or

File Designaflon

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Type of File

0

0

~
~
3

5

4

o

2

o

3

8

BlocK

Record

length

Length

iQ

o >

e:

a

Rewind

~

a:

:::;

w :;;: t;:

Condition

x

Starting
Location

~ ~

InRIT:F II Lt;1 IR~ IF
3 I r.
irE!R riP F 250 I b~
FP ipJl INrr iER 1""
IF 132 l1 ~~

I

2

~

::l

Option

K

W

:;;:

Entry

60 61 62 63 64 65 66 67 68 69 707172 73 74

EnIISI\(

31tit'
11

~

Ul-~

Continuation Lines

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

9

F

Tape

Storage Index

-3

~.§
Key ~ield ~

5
a: ---

FA

5

Number of Extents

o Overflow Indicator 8

F~ IAiS

0 4

o

7

6

~

Device

w

Nor Additional Area

Line

Name of
Label Exit

Symbolic

Device

O~ganization

File Format

Number of Tracks
for Cylir"lcier Overflow

_D!1~11<
PIR [IN iTlER

I

t-t- t-f-- t-r--- 1 - -

~

-,~

The record address file, ADRTFILE, defined as an
addrout disk file, consists of 3-byte binary relative
record numbers that correspond to locations of records
on the input disk file, MASTER. As each record is read
from ADRTFILE, tbe indicated record from MASTER
is located and read. For each record read from MASTER
(indicator 01 is on), a detail line is printed on the printer
output file, PRINTER.

--

Because end of file (E in column 17 of the file description specifications sheet) is specified for the addrout
file, processing continues until all records in ADRTF I LE
have been read.

Extension Specifications

E

Record Sequence of the Chaining File

Number

I--Line

Number of the Chaining Field

Table or
Array Name

To Filename

0-

>

f--

From Filename

~
3

4

6

5

7

8

of

Number

Entries

of

Per

Entries

Length
of

Record

Per Table

Entry

o

Table or
Length
Array Name of
(Alternating
Entry

Cl

]~

i1}

or Array

Ci

~

Comments

~

Format)

&

10 1112131415161718 19 20 21 22 23 24 25 26 27 28 29 3031 32 33 34 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 50 51 525354 5556 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

9

1~ ~l-r t

011 I J 1 A1U~ llrLlJ'!1;. ~!A~~jRlI 11111
01 1 E I I I I I I I I I I I I I I I I I I I I I
E

2

ttl I I J I
IIIII II

I1
II

I I I I II II I I I I I I I I
I III jill JI 1111 I I

Input Specifications
Record Identification Codes

I

0

';:;

Filename

Line

Position

~
2

3

4

o

1

o

2

7

8

9

1) 6~

Position

0

~
0

2

<:Iosition

~

U

Field
Indicators

Field Location

r-

~

~

0

6

2

§~

6

Field Name

'"
0

i'" .~

From

To

~

.~

~ ~

Cl

~

0
0

~.;

.~

~

iii

] U-i.L
g .~ ~ ~
~] u:
.3 :iiu
'"

Zero
Plus Minus or

Blank

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

Im!M~\I~IN

~~

NS

~

I

I

~ctT

8

I

~0-f-3+-~I-f-+-+-f-4-+-f-4-+-~-+~-f-4-+-f-4-+-f--f-+-~-+-+~-+-~f-4-+-f-4-+-~-+-r-f-+~J~-f-~lb~~~~N~~~~~A~b~R~+-~-+-+-f-4--r-~-+-r~-+-~0J-4~~I~-L~I-L~~-L~~~~~1_~~LL~~LL~LJ-LJ-~-LJ-~-L~~-L~~-LJ-~-L~~-L~~~~~~~~~~~~

Output Specifications

0

"§

Output Indicators

Skip

Space

w"-

~

t;;
o
~

~ ~

Filename

Line

5

6

Jd

f--

j

4

~

&J ~
i"R
>D EL

!
3

.e

a

ADD ~
R

;;:

1

Field Name

a:

;3

0

2

2

2

'AUTO

fJ\ND
7

8

9

I

8>
End
in

u

Output
Record

~~

to Print

Yes
No
Yes
No

Yes
Yes
No
No

II

Position

en

Zero Balances

Commas

No Sign

CR

~

X = Remove

A
B

J

V

C

L

D

M

Plus Sign

1
2
3
4

K

Date
Field Edit

Z = Zero
Suppress

a:

Constant or Edit Word

..J

a:'"

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 '

10 11 12 13 1415 16 17 18 19 20 21 22 2324 25 26 2728 29 30 31 32 33 34 35 36 37 3839 4041 4243 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I I I I I II-_i-r -ttH i i
- -4- .~,.1~, lft- - - J~ ! ! ! !
: - -(- --- - tj'---r~H-Tttir
m~11111 unttt tjii±ttjn~umJjjjjj~rtLtttllij-ttttjji
~~ () IlfllWlIl:II211<211=2

IFllll.EI I
II
I I I '!MIAIIN
" " III I I
I
I
I
I
I
I
I
II
I
II
I
III
""I""

~Ubr'INO

~11

c
c

2

b

o

.g I

~ ~
~ ~
.(3 -

Comments

Compare

lookup(Factor 2lis

Z
Cl J: High low Equal
Z
~
9 10 11 12 13 14 15 16 11 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 SO 51 52 53 54 55 5651 58 59 60 61 62 63 64 65 66 61 68 69 10 11 12 13 14

01I' 1I II
o

Length

Name

to- '0 rr.-

E

3

AL

~.5~

Line

~

I I
I I I I I I I I JJI I I I It I

1111""1,

""1""""1

Output Specifications

0

"§

Filename

line

i~~~

f-

~
3

4

0

1

0

0 2

0

6

0 3

0

o

0

0

And

Field Name

And

0
OJ

i>

Conimas

Zero Balances
to Print

Yes
Yes
No
No

Yes
No
Yes
No

Position
in
Output

No Sign

CR
A
B
C
0

X = Remove
Plus Sign
= Date
Field Edit
Z = Zero
Suppress

Y
K
l
M

Constant or Edit Word

Record

'AUTO

,

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 '

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

u ~, 1.. lt Il ~~
-r-

-_i1iY~'~ ~ - --+-- -- -1- -- -- -

.

--f- - - f - ~-

____ -'-_-'--'----"-->- ..J- _ _ _ _ _ , _ _ _ _ _ _ _

'- _

_

---

~-I-a 1-~ T'~ - - -'-1- J -f-+-+--+--ji---+-+-t-I--+--+--+--+--+---t-I--t---t-+--i
~Ie

_'--_-'-_-'-_'-_<--'--.--l_-I._ -'--'----'---'--<--l----"--'--_-I--_J--'--'c-'-_-!-_

A record is written for each successful CHAIN operation ..
Figure 3-10. Using CHAIN to Load a Direct File
3-24

~-y-----y--"lEndI I

E l

'Afofo

o R
A~ro

1--+--t--f--jH-+
4

Output Indicators

Skip

t: :t.tol--r-+--.--+----r-,--.-r-1--i
~ ~ ~ ~

f-

5

Space

@~

f--

File Description Specifications

- ---

1-1-1-

I

I

(3)

Records are stored on disk in the order
indicated by the relative record numbers.
Spaces are left in the file for missing
records (in this case, records 5 and 7).

Relative record number l

(3)

lThe programmer usually derives relative record numbers from information in the records.
Figure 3·11. Direct File Organization

Column 32 (File Organization or Additionallnput/Output Area)

3·25

File Description Specifications
File Type

F

Mode of Processing

End of File

File Format

~

~

Record

Block

~

Length

Length

a:

e:.
?!I:::
~~

Organization or

~

Additional Area

c

0

fl

I d'

.2

I ~~~£7;:d

:fi

Symbolic
Device

Device

8

7

Number of Tracks
for Cvlinder Overflow

Name of
Label Exit

Number of Extents

Tape

~
Condition

Storage Index

ver~~

Continuation Lines

g ~ w ~ ru..:..L..---..I.-=Ex-te-rn-a~1R::!-e-~.1.rd~N::-a...Jm'-e<..J,.;;::::.L-----'-'L""o",ca""tio","n'--'--i

5 6

4

~~

~ ~

j

3

("II

w ,-----,----;

oj:::

!

Extent Exit
for DAM

Record Address Type ...J
'--""""'T=-y-pe-o""'f-=FiC""le--i UJ

Sequence

Line

File Addition/Unordered

Lenglh of Key Field or
of Record Address Field

File Designation

r---

Z

r.-----r-----,~
Option
Entry
~

9· 1011 12 13 14 15 16 17 1819 2021 222324252627 2829 30 31 323334 3536373839 4041 4243444546 4748495051 52 53 54 55 56 57 58 59

UI·U8.
UC ~

~

6061 62636465 66 67 68 69 70 71 72 73 74

I~'rlsll(
FC()~I'i ... ll

03

o

4

F

o

5

F

o

6

F

I~~

ID l:5'f<,
11<1~1j::v-INII"l

The direct file being created, CUSTF I LE, is defined as an
output file that is processed randomly. A file description
specifications continuation line containing the keyword

Ir U~ITIN~

R ECNO specifies that RPG uses the contents of the field
CUSTNO as the relative record number of the record to
be loaded.

Input Specifications

I

File~:me

t--

Record Identification Codes

'g

~

~

li:

g ~:

.f 1---;D:::a:-:ta---r"""T:O±Rrl~ .§ ~
S~~~~re
~ ~ ~ ~ c3- ~
5

Position

Q1

6

Field Location

! i; ~ ~

Record Name

0.

~

g

~

Line

External Field Name

g~ e
N

~U

~ U t5

Position

~,,_.c
eN ~
z

~

Position

u u

From

To.g

~o_ ~N_ ;::..
~ ~!ol ~"'~

Occurs

z u u Vi

n Times

c:

~

3

4

o

I

o

1[8 €C.lI.~

2

I

l

o

3

I

q
2."1

1

8

Field Name

~

.g

.5

E~ ]

~ ~~ ~

RPG

~

Data Structur.

u;

Field
Indicators

~

Length

~o

U

..c·c
:; ~
~

Plus Minus !;ro.

~

BI an k

U

9 1011 12 13 14 15 16 17 18 19 20 21 222324 25 26 27 28 29 30 31 32333435363738394041 42434445464148 49 5v 51 52535455565758596061 626364 65666768 69 7071 727374

IQjll

II rl

o

4

I

o

5

I

o

6

I

o

I~I~
S~

7

I

o

1'2

8

I

o

9

I

These input specifications define the fields that make up the
record to be loaded. The CUSTNO field from the input

~b\'

N

23 I"ll' $iT NM
3q AD "'R
lc;l5 '"IT l'tisl1
e;lal Zllif

-

"Illl

record is used as the relative record number to indicate
the record to be loaded.

Output Specifications
~

0

Space
~!
e~

r-~
Line

=.~

Filename
or
Record Name

8.

E

!.~

A~d

~~

~~ ~..;:

~
A ~~

of

Output Indicators

Skip

j

~
0

z0

z

AND

4

5

6

7

8

Z

'AUTO

OC UStIlF III ED

0 2

0

0 3

0

0 4

0
0

:5~

kll

RE CO IRID

Figure 3·12. Using RECNO to Load a Direct File

File Description

Sp7cifica~ions

Commas

Zero Bal ances
to Print

Ves
Ves
No
No

Ves
No
Ves
No

a:

No Sign
I

CR

A

2

B

3
4

C
0

J
K
L
M

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero

5·9 =
User

Defined

Suppress

:::;
iil
Ii:

LIJ '"

A record is loaded in the CUSTF I LE for each record read
from the RECIN file.

3·26

~~

Position
in
Output
Record

9 10 11 12 13 14 15 16 17 18 1920 21 22 23 24 25 26 2728 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

0 I

0 5

0

~
cc

<

~~I3

A~d

Field Name
or
EXCPT Name

Constant or Edit Word
I

2

1 '~'

&fJ

3

4

5

6

7

8

9 10 II 12 13 14 15 16 17 18 19 2021 22 23 24

«~48048~~~~~~~~n~~~~~~~~~nMooro

71 72 73 74

Records are stored on disk in the same order in
which they are read. No index is kept, and no
spaces are left between disk records.

1st
record

2nd

3rd

4th

5th

6th

Figure 3-13. Sequential File Organization

Column 32 (File Organization or Additional Input/Output Area)

3-27

Addrout Files

When overflow is handled automatically and the
overflow line is sensed, the following steps occur:

When describing an add rout file, you must place a T in
column 32. The add rout file must be a disk file. See
Column 28 (Mode of Processing) in this chapter for a
description and example of addrout processing.

1.

All remaining detail lines in that program cycle are
printed if a printer operation spaced or skipped to
the overflow area.

2.

All remaining total lines in that program cycle are
printed.

3.

A skip to line 06 occurs.

COLUMNS 33-34 (OVERFLOW INDICATOR)
Entry

Explanation

Blank

No overflow indicator is used.

OA-OG,

Specified overflow indicator
conditions what records will .
be printed when overflow occurs.

Overflow Indicator Specified

OV

Use columns 33 and 34 to specify an overflow indicator
to condition which lines in each printer file will be
printed when overflow occurs.
Only one overflow indicator can be assigned to a file. If
more than one printer file in a program is assigned an
overflow indicator, the indicator must be unique for each
file.
Overflow occurs when a record is printed on the
overflow line or when a space or skip instruction causes
forms movement past the overflow line. When overflow
occurs, the specified overflow indicator turns on and
remains on for the rest of the program cycle. The
indicator turns off after all lines conditioned by that
indicator are printed. If no overflow indicator is
specified and the fetch overflow routine is not used, the
compiler automatically handles overflow. See Column 16
(Fetch Overflow) in Chapter 9, Output Specifications, for
a description of the fetch overflow routine.

Automatic Overflow
If an overflow indicator is not specified, the compiler
automatically advances the forms to the next page and
continues printing once overflow is sensed. Printing
begins on line 06 after the operator has positioned the
first page, and overflow occurs at six lines less than the
system page size unless the overflow line has been
changed by line counter specifications. Detail lines,
therefore, begin on line 06 for all pages except the first.

3-28

File Description Specifications

RPG II logic allows the overflow indicator to turn on at
three different times in the program cycle: (1) at total
time, (2) at detail time, and (3) at calculation time if
exception output is used. There is only one time in the
program cycle, however, when the program checks to
determine whether the overflow indicator is on: right
after all total records are printed.
When the overflow line is sensed, the overflow indicator
turns on and the following steps occur:

1.

Detail lines are printed if that part of the program
cycle is not already completed.

2.

Total lines are printed.

3.

Total overflow lines are printed if conditioned by
the overflow indicator.

4.

Forms advance to the next page if indicated by the
skip specifications on a heading line or total line.

5.

Heading and detail lines are printed if conditioned
by overflow indicators.

For more information on how to condition output
operations with the overflow indicator, see Columns
23-31 (Output Indicators) in Chapter 9, Output
Specifications.

COLUMNS 35-38 (KEY FIELD STARTING
LOCATION)

Entry

Explanation

1-4096

Record position in which the key
field begins

Use columns 35 through 38 to identify the record
position in which the key field for an indexed file begins.
Columns 35 through 38 apply only to indexed disk files,
and an entry must be made in these columns for an
indexed disk file. The key field of a record contains the
information that identifies the record. This information is
used in the index portion of the file. The key field must
be in the same location in all of the records in the file.
The entry in these columns must end in column 38.
Leading zeros can be omitted.
Key fields cannot contain any hex FF characters.
Therefore, if the key field is a binary field, you must be
sure that no hex FF characters appear in the key field.

COLUMN 39 (EXTENSION CODE)

Entry

Explanation

Blank

No extension or line counter
specifications are used.

E

Extension specifications further
describe the file.

L

Line counter specifications further
describe the file.

Use column 39 to indicate whether the file is further
described on the extension specifications or on the line
counter specifications. Column 39 applies only to (1)
preexecution-time table and array files, (2) record
address files, and (3) output files assigned to the printer.
Describe printer output files on the line counter
specifications, and describe table, array, and record
address files on the extension specifications.

COLUMNS 40-46 (DEVICE)

Entry .

Explanation·

BSCA

Binary synchronous communications
adapter

CONSOLE

Console data file or console record
address file

CRT

Display screen

DISK

Disk

KEYBORD

Keyboard

PRINTER

132-position printer

SPECIAL

Used for a device not supported
directly by RPG II

WORKSTN

Display station

Use columns 40 through 46 to identify the input/output
device used for the file. All entries must begin in
column 40. The devices and the associated file types
that can be used with each device are shown in Figure
3-14. Figure 3-15 shows the columns that can be used
for the devices named.
WORKSTN, CONSOLE, CRT, and KEYBORD all refer to
the same physical device-a display station that consists
of a display screen and a keyboard. CONSOLE, CRT,
and KEYBORD devices can be used only with one
display station. A CONSOLE file can be used only as an
input file and cannot be used to display existing records
in a file. A KEYBORD file can be used as an
input/ output file with the SET and KEY operation codes,
which allow the output of prompts and the input of one
field at a time. A CRT file can be used only as an
output file to display information on the screen; this
information cannot be changed by the operator. The
WORKSTN file is an input/output (combined) file, which
allows the programmer to specify multiple fields that
can be output fields, input fields, or output/input fields.
The WORKSTN file can be used with multiple display
stations or SSP-ICF sessions.

Columns 35-38 (Key Field Starting LocatIon)

3-29

BSCA
A BSCA device allows an RPG " program to transmit
and receive binary synchronous data via a data
communications network. For more information on the
BSCA device, see Chapter 6, Telecommunications
Specifications.

CONSOLE
Use CONSOLE as the device name in one of two ways:
(1) for a record address file, or (2) for an input data file.
If CONSOLE is used for a record address file, the file
must be further defined by extension specifications. Use
CONSOLE when you want data records entered directly
from a display station to an executing program.
CONSOLE is an input file only and cannot be used to
display existing records.

3-30

File Description Specifications

Column 15

Column 16

Device

Form of Data

File Type

DISK

Disk

Primary input

I

P

Disk

Secondary input

I

S

Disk

Record address file containing record key
limits

I

R

Disk

Record address file containing relative record
numbers (add rout file)

I

R

Disk

Chain input

I

C

Disk

Demand

I

D

Disk

Table or array (preexecution time only)

I

T

Disk

Update (primary, secondary, chained, or
demand)

U

P, S, C, or D

Disk

Output

0

Disk

Direct file load (nondelete-capable file)'

0

C

Keyed in by operator

Demand

C

D

Keyed in by operator

Combined primary

C

P

Keyed in by operator

Primary input

I

P

Keyed in by operator

Secondary input

I

S

Keyed in by operator

Demand

I

D

Keyed in by operator

Record address files containing record key
limits

I

R

Keyed in by operator

Primary input

I

P

Keyed in by operator

Demand

I

D

CRT

Displayed lines

Output

0

PRINTER

Printed lines

Output

0

BSCA

Data communications line

Primary input

I

P

Data communications line

Secondary input

I

S

Data communications line

Demand

I

D

Data communications line

Output

Special device

Primary input

I

P

Special device

Secondary input

I

S

Special device

Demand

I

D

Special device

Update (primary, secondary, or demand)

U

P, S, or D

Special device

Combined (primary, secondary, or demand)

C

P, S, or D

Special device

Output

0

WORKSTN

CONSOLE

KEYBORD

SPECIAL

0

, For information on the specifications for the direct file load of a delete-capable file, see Direct File Load (Delete-Capable File) in
this chapter.

Figure 3-14. Devices and Associated File Types
Columns 40-46 (Device)

3-31

File Description Specifications
File Type

-

F

Mode of Processing

File Addition/Unordered

Extent Exit

Length of Key Field or
of Record Address Field

File Designation
End of File

Record Address Type
Sequence

Filename

Type of File

File Format

Line

~
~

~

~

8

9

10 11 12 13 14

Device
..J

W
~

~:;:~ ~~it

Number of Extents
Tape
Rew~.nd_

~

Storage Index

Block
Length

Record
Length

~

~

Condition

e
: ; Key
- -Field- .~5
t:::

~~

Continuation lines

~:~:~:n.E

Option

Entry

~

~

Ul.~

~

1617 1819 20 21 22 23 24 25 26 27 282930 31 323334 35 36 37 38 39 40 414243 •• 454647.48.950 515253 :;4 55 56 5758 59 60 61626364 6566 67 6B 6970 71 7273 7.

~O-+-~---I--+-I-I-l--+-+--+-+---l~-+--+--l--+-+-+-+--i--:+-jf-+-+-+-+-_-I-+4'I,+-+-++-+-Fn=-F11=J=j-Sl:g.
!i

a

Symbolic
Dev ice

0 Overflow Indicator (3

c

:E

~w~~
1

Organization
Nor Additional Area

Number of Tracks
for Cylinder Overflow

for DAM

J

3

I

I

i(

H'

~O:4~:~:::~~j::~~:-:~4+_~.-_pl-:C~;f~C=::~I~tlj:t]ULkQ'<$'/~umHill~~~~~~!~lIDijO~R~~mn~~~~IB~~~~~~~~~iGl]llnu~.
a

5

a

6

-l-+-+-l--l---l--t· 1--1--

:

1 4
1 5

1 6

Shaded columns must be blank.
Figure

3·~5.

Columns That Apply to Device Named

CRT
The CRT (display screen) can be used as an output
device for normal and exception output. (See Column 15
in Chapter 9, Output Specifications, for more information
on exception output.) Any alphameric character can be
written on the display screen. If the record length is
less than or equal to 40, up to 40 characters can be
written across the width of the screen, and a maximum
of six such lines can appear on the screen at one time.
The display is centered both vertically and horizontally
on the screen. If the record length is greater than 40,
up to 79 characters can be written across the width of
the screen, and a maximum of 24 lines can appear on
the screen at one time.
Data moves onto the screen from bottom to top: after
the bottom line is written on the screen, if space-1-after
is coded for the bottom line, the top line of a full screen
moves off. Data is written on the display screen at the
normal output times (total and detail) or at calculation
time for exception output.

3·32

File Description Specifications

The display screen is designed to display messages and
instructions to the operator and to display operator
responses. It should not be used interchangeably with
the printer as a major output device because of the .
speed with which data moves on and off the screen.
Output operations such as spacing and skipping can be
specified with some restrictions. Spacing before and
after (a 0 to 3 entry in columns 17 and 18 of the output
specifications) and a skip-before to line 01 only (01
entry in columns 19 and 20 of the output specifications)
can be specified. Specify a skip-before to 01 to erase
data from the display screen. If a skip-before to any line
other than 01 is specified, the system assumes the entry
to be 01 and the screen is erased. A skip-after
(columns 21 and 22 of the output specifications) cannot
be specified for CRT files. When a line is written on the
display screen over a previous line, the previous line is
erased. Edit codes, edit words, and output indicators
can be specified for CRT files.

DISK

WORKSTN

DISK is an input/output device that allows the RPG II
program to process data stored on disk. Disk files can
be sequential, direct, or indexed files. See. Column 28
(Mode of Processing) in this chapter for a description of
the processing methods that can be used for disk files.

The WORKSTN device allows an RPG II program to
communicate with one or more display stations. A
device can be specified as WORKSTN if you use the
System/34 Display Screen Format Specifications to
define its output and input and if it is allocated to the
program. Only one WORKSTN file can be specified in a
program. A program containing a WORKSTN file cannot
contain KEYBORD, CONSOLE, or CRT files.

KEYBORD
The entries CONSOLE and KEYBORD refer to the same
physical unit that includes both the keyboard and the
display screen. Use KEYBORD when you use the KEY
or SET operation codes. If KEYBORD is specified for
the primary input file, you must provide a means of exit
from the program by setting on the lR indicator.
Input specifications are not used for KEYBORD files.
The input data is defined in the KEY or SET/KEY
operation itself.

PRINTER
The print unit allows a separate output file to be printed
on a 132-position printer. A maximum of eight printer
files is allowed per program. PRINTER must be
assigned as the device for each file, and each file must
have a unique filename. Use the PRINTER OCl
statement to assign a filename to a particular printer.

For a complete description of the file description
specifications for a WORKSTN file, see Chapter 13,
WORKSTN File Considerations and Sample Programs.

SPECIAL Device Support
Files using devices not directly supported by RPG II can
be processed on System/34. To do this, enter
SPECIAL in columns 40 through 46 of the file
description specifications to indicate that the file is
handled by a SPECIAL device.
You must also supply a subroutine to perform the
input/ output operations required to transfer data
between the SPECIAL device and main storage. Enter
the subroutine name in columns 54 through 59 of the
file description specifications. Control cannot be
transferred from one user assembler subroutine to
another user assembler subroutine.
The SPECIAL device is also used with the IBM-written
subroutine SUBR22 to read a transaction file created by
the work station utility of the Utilities Program Product
(see Reading a Work Station Utility Transaction File in
this chapter).

Columns 40·46 (Device)

3·33

Linkage for User-Written Irtput/Output"Subroutines
The RPG II compiler generates the following DTF (define
the file) for linking to an assembler input/output
subroutine:
Bytes
(hex)

Description

o

Device code (X'OO')

1-2

Address of data management

3

Mask for external indicators

4-5

Backward chain pointer

6-7

Forward chain pointer

8-9

Logical record address

A

Completion code:
X' 42' = End of file
X' 41' = Controlled cancel
X' 40' = Normal completion

B

Operation code:
X'80' = Get
X'40' = Put
X'20' = Update
X'10' = Close

C-F

Attributes
Byte 1:
X'20' = Update file
X' 40' = Output file
X'80' = Input file
X'CO' = Combined file
Byte 2:
X'08' = Dual input/ output
X'01' = DTF open

10-11

Record length

12-19

Filename

1A-1B

Physical input address

1C-1D

Physical output address

1 E-1 F

Block length

20-21

Address of array DTT if array
linkage is used

3-34

File Description Specifications

The address of byte 0 of the DTF is passed to the
input/ output subroutine in index register 2. Bytes 0
through 7 and C through 21 are filled in by RPG II at
compile time;" The contents :of these fields depend on
the entries specified in the file description specifications
for the SPECIAL device. The input address (bytes 1A
and 1 B) and the output address (bytes 1C and 1 D),
when present, point to the physical buffer that has been
allocated within the load module by RPG II for use by
the SPECIAL device. The completion code (byte A) is
inserted by the input/output subroutine when control is
returned to RPG II. The operation code (byte B) and the
logical record address (bytes 8 and 9) are inserted at
object time.
Figure 3-16 shows an example of the DTF generated by
RPG II for an input/output subroutine.
If array linkage is used, the RPG II compiler generates
the following DTT (define the table):
Bytes

Description

0-1

Address of rightmost byte of
the first element of the array

2-3

Address of rightmost byte of
the last element of the array

4-5

RPG II last LOKUP element

6-7

Length of array element

8-13

Array name

(
\

********************************************************************

*
*

*
*
*
*
********************************************************************
RPG II SPECIAL DTF OFFSETS AND EQUATES

*

**** SPECIAL DTF LAYOUT ****

*

**** SPCMP EQUATES ****

*

**** SPATl EQUATES ****

*

**** .SPAT2 EQUATES ****

DEVICE CODE (XIOO')
ADDRESS OF D.M.
UPSI INDICATORS
BACKWARD CHAIN. POINTER
FORWARD CHAIN POINTER
LOGICAL RECORD ADDRESS
COMPLETION CODE
OPERATION CODE
ATTRIBUTE BYTE ONE
ATTRIBUTE BYTE TWO
ATTRIBUTE BYTE THREE
ATTRIBUTE BYTE FOUR
RECORD LENGTH
FILE NAME
PHYSICAL INPUT I/O ADDRESS
PHYSICAL OUTPUT I/O ADDRESS
BLOCK LENGTH
ADDR OF ARRAY DTT IF SPECIFIED
LENGTH OF SPECIAL DTF

0000
0002
0003
0005
0007
0009
OOOA
OOOB
OOOC
OOOD
OOOE
OOOF
0011
0019
001B
001D
001F
0021
0022

SPDEV
SPDMA
SPUPS
SPCHA
SPCHB
SPLRA
SPCMP
SPOPC
SPAT1
SPAT2
SPAT3
SPAT4
SPRCL
SPNAM
SPPBI
SPPBO
SPBKL
SPDTT
SPLEN

0040
0042
0041

SPNORM
SPEOF
SPCCNL

0020
0040
0080
OOCO

SPUPDT
SPOUT
SPINP
SPCMB

0008
0001

SPDIO
SPOPEN

0040
0080
0020
0010

**** SPOPC EQUATES ****
*
SPPUT
EQU
x ' 40'
PUT
SPGET
EQU
X' 80'
GET
EQU
XI 20 I
SPUPD
UPDATE
SPCLS
EQU
X' 10'
CLOSE
*** END OF EXPANSION **

EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU

EQU
EQU
EQU

EQU
EQU
EQU
EQU

EQU
EQU

0
SPDEV+2
SPDMA+1
SPUPS+2
SPCHA+2
SPCHB+2
SPLRA+l
SPCMP+l
SPOPC+l
SPATl+l
SPAT2+l
SPAT3+l
SPAT4+2
SPRCL+8
SPNAM+2
SPPBI+2
SPPBO+2
SPBKL+2
SPDTT+1

x'40'
x'421
X'4l'

X'20'
X'40'
X ' 80 '
XICO I

X ' 08'
X'Ol '

NORMAL
END OF FILE
CONTROLLED CANCEL

UPDATE FILE
OUTPUT FILE
INPUT FILE
COMBINED

DUAL I/O.
DTF OPEN

Figure 3-16. Example of RPG II Generated DTF

ColUmns 40A.6 (Oev.ice)

3-35

Considerations for the Assembler Programmer

File Description Specifications for SPECIAL Device

The input/ output subroutine must save and restore the
registers altered· in the subroutine. Control should be
returned to the address in the address recall register
(ARR).

The following file description specifications apply to files
assigned to the SPECIAL device:·

Column

Entry

7-14

Valid RPG II filename.

15

1,0, U, or C.

16

P, S, D, or blank.

17

E or blank.

18

A, D, or blank.

19

F.

20-23

Block length.

24-27

Record length.

28-31

Must be blank.

• The input/output subroutine must do its own open
when the first call to it is issued. It must also do its
own close to the file on a close call.

32

1 through 9 or blank.

33-39

Must be blank.

• If a dual input/output area is requested, the second
area will be immediately behind the first.

40-46

SPECIAL.

47-53

Must be blank.

54-59

Name of the user-written or
IBM-written subroutine that
performs the input/output
operations. The subroutine name
must be in the form SUBRxx, where
x is any alphabetic character or
in the form SRyzzz, where y is any
of the following 15 characters: B,
C, D, F, G, H, I, L, M, 0, P, R,
S, T, or U; and z is any of the
following 16 characters: A, B, C,
D, F, G, H, I, L, M, 0, P, R, S,
T, or U.

60-70

Must be blank.

71-72

U1 through US or blank.

73-74

Must be blank.

When an input operation is done, the input/output
subroutine must move the address of the physical buffer
currently being used to the logical record address
location in the DTF(bytes 8 and 9). This logical record
address points to the record within the physical buffer
that is to be processed by the RPG II program.
When an output operation is requested, the
input/ output subroutine must move the data from the
logical buffer (address in bytes 8 and 9 of the DTF) to
the physical buffer (address in bytes 1C and 1 D of the
DTF). The logical record address (bytes 8 and· 9) points
to the RPG II common output buffer that contains the
record to be output by the SPECIAL device.
The assembler programmer must also consider the
following:

• Subroutines of the type SUBRxx cannot be overlaid;
however, subroutines of the tYpe SRyzzz can be
overlaid.
• Only consecutive processing is supported for
SPECIAL files.

3.36

File Description Specifications

The following can be used with SPECIAL files:

File Description Entries

•

FORCE operation code

To use SUBR22, the following entries must be made on
the file description specifications:

•

READ operation code

•

Column

Entry

6

F.

7-14

Name of the transaction file
created by the work station
utility.

15

I, U.

16

P, S, or D.

17

Blank or E.

18

Blank (assumed blank if an
entry is present).

19

F.

20-23

Enter the block length, which is
calculated by the following formula:
• Block length = 256 if the record
length is a submultiple of 256
• Block length = the .record length
if the record length is a
multiple of 256
• Otherwise, the block length must
equal the record length plus 255
rounded up to the next .multiple
of 256

24-27

Valid entries for record length
.
are 14 through 4096.

File translation

The following cannot be used with SPECIAL files:
• CHAIN operation code
• Spacing and skipping
• *PRINT
SPECIAL files can only be processed consecutively.
(See Figure 3-31 for possible file description entries for
SPECIAL files.)

Reading and Updating a Work Station Utility
Transaction File (SUBR22)
The IBM-written subroutine SUBR22 allows an RPG II
program to read and update records from a transaction
file created by the work station utility of the System /34
Utilities Program Product. To link to this subroutine', use
the SPECIAL device and an array with one 13-character
element.
For an example of an RPG II program that reads records
from a work station utility transaction file, see Figure
3-17.
Notes:
1. The user program must initialize positions 1 through
11 of the array before the first data record is read by
SUBR22 or before SUBR22 begins to read a new
logical chain.
2. The last 13 bytes of the work station utility
transaction file record (the trailer information) are not
returned to the RPG program and cannot be updated.
3. The user program should check position 13 of the
array (the error indicator) after each data record is
read to determine if any errors were encountered.

Note: The record length
specified must include 13 bytes
for the work station utility file
trailer information, of which
bytes 11 and 12 contain
the work station 10.
28-39

Must be blank.

40-46

SPECIAL.

47-53

Must be blank.

54-59

SU~R22.

60':'70

Must be blank.

71-72

Blank or U1 through U8.

73-74

Must be blank.

75-80

Program identification.
Columns 40-46 (Device)

3-37

Control Specifications

H

I---

~

line

Co

~ Number .~
:; Of Print ~
~ Positions

Size to
~.~ Size to
Compile :; !i. Execute

~c;

c:

~

j ...J:~

o

5

Refer to the specific System Reference
Library manual for actual entries.

o

Address
to Start

~


in
0:: w ~LL
7

Extent Exit
for DAM

:§

~

Condition

~.~

e

;Z ~

Starting

~

Location

W

Ul.~

Continuation Lines
:J

Option

K

Entry

~

Fi) liS IpW ~y ~~
Fh '~III &~Ir Irln

2

o

3

o

4

F

o

5

Fil I~!A INI~

o

6

F

'"

I~

lc ~1112
~

~IQ

Mr{ tJ04~ rlllll'
ISIP IEIr II~lt

IJlj

1[":,

~I~

r~r,

IKlt

~II<

I';;'

lo!e l"lll
IN :illC!l

This program uses SUBR22 to selectively read chains of
records from the work station transaction file
(WSUXAC) and to write them to a permanent disk file
(TRANS). The operator enters the 10 of the work station
whose transactions· he wishes to copy. The program
displays error messages when a file or chain containing
an error is encountered, or when the work station I D
entered cannot be found. The program also displays a
message after all the records in a chain have been
copied. The program ends when a file containing an
error is found, or when Cmd key 7 is pressed.
Extension Specifications
Record Sequence of the Chaininq rile
Number

Numher of the Chaininu Field:

of

To Filename

line

?

~

From Filename

Table or
Array Name

Entries

Number
of

Per

Entri~s

Lenu th
of

Per Table

Entry

Record

or Array

SUBR22 requires an array (in this program, an
execution-time array is used) to contain control
information to be passed to and from SUBR22 and the
program with each data record. This array (CONTRL)
contains the work station 10, the error indications, and
the last record flag.
Figure 3-17 (Part 1 of 4). Reading;) Work Station Utility Transaction File

3-38

~

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3334 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 51 58 59 60 61 62 63 64 65 66 67 6B 69 70 11 72 73 74

o

E

~

Fiie uescription Specifications

0

;;;

c<-

0:
OJ

0
~

~

~

c .%

Table or
Array Name
IAlternatinq
Format)

0
~

Lenu th
of
Entry

0:
...J
OJ

.%

Comments

RPG Input Specifications

I

Record Identification Codes

,

~

~

Filename

Line

j

Ii;

Position

~e~
~ ~ tl

..-I-r-

o R
'A~ro

5

7

8

Ii;

~~ ~

Position

~~
~

~u6

u

ti~

4

o
o

2

I

3

IW ~III ~14C

4

I

5

I

6

I

o

7

I

a

8

I

o

9

I

1 0

I

11

I

1 2

I

NS

~R

llt

1

11

ali

2

r.
.f' "\"

11

Indicators

0

0

1

o
o
o

,2

C*

3

c

4

C

o

5

o

6

Factor 1

7

C

B

C*'

o

9

2

1 3
1 4
1 5
1 6
1 7
B

1 9
0

PR OM PT

Dr SP LAlv

11

I{

1

•

1111

~"'!I I"

111::1

Il:lf I,.

1I~rT

T

I,..

Resulting
Indicators
Arithmetic
;: Plus IMinusl Zero
Compare

Length

Comments

~ 1>211 <211-2
:: Lookup(Factor 21is
~ High

Low Equal

5J 54 55 5657 58 59 60 61 62 63 64 65 66 67 6B 69 70 71 72' 73 74

RIF AD 01 Is PLAY
AT ION OP ER- AT OR FOR WS 10 OF RE CO RDS TO 'B E. CO PI EO
10 8'
SE. TON
(h8

SE llOF
RS TA RT

TAG
(lSi\- 0~

TOF
ET OF

~E

Kkl

~O

T'" Et-lD

EX C.PT

(2516
0b

~O TO RS TIA RT

LO OP

C

056 01

RE AD 01 SP LA '{

C

c
c
c
c
c
c
c
c
c
c

~T

1t211 <211 =2
Lookup(Factor 21i.
High Low Equal

\ R'

R~ ST RT

Ris TA RT

TAQ.

SE. TON

EX CPT

The first READ operation reads the first record, which is
blank, from the display. Indicator 08 is set on to display
the initial ENTER WS ID prompt (displayed by the
EXCPT operation) and is then set off. The program also
sets off indicators 04, 05, 06, and 07.
The second READ operation is executed when:
• The Enter/Rec Adv key is pressed (WSID is blank).
Indicator 06 is turned on because the input field is
blank. The EXCPT operation is executed, displaying
the ENTER WS ID prompt and the error message
WSID BLANK. The program then goes to RSTART,
sets off indicators 04, 05, 06, and 07, and waits for
the READ operation to be executed.

LR

Depending on which indicators have been turned on
by the previous comparisions, the EXCPT operation
causes one of the following output combinations to
be performed:
The ENTER WS ID prompt and the error message
WS ID xx BAD 'CHAIN are displayed if indicator
04 is on.
The ENTER WS ID prompt and the error message
WS ID xx NOT FOUND are displayed if indicator
05 is on.
The record is written to the permanent disk file
(TRANS), and the ENTER WS ID prompt and the
message WS ID XX CHAIN COPIED are displayed
if indicator 07 is on.
The record is written to the permanent disk file
(TRANS) if indicator 01 is on.

• Two characters are entered in the WSID field.
The program attempts to read a record from the
transaction file (WSUXAC). The SUBR22 error flag
(ERROR) is checked for the following:
If the WSU transaction file contains an error,
indicator 03 is turned on.
If the record returned to the program is from a
display station session that ended abnormally,
indicator 04 is turned on.
If no records exist for the work station I D that was
entered, indicator 05 is turned on.
After these comparisons are executed, the last record
flag (LAST) is checked to determine whether this
record is the last record in the logical chain. If it is
the last record, indicator 07 is turned on.
Figure 3-17 (Part 3 of 4). Reading a Work Station Utility Transaction File

3-40

File Description Specifications

If indicator 04, 05 or 07 is on, the program goes to
NEW I D after performing the output. Otherwise, the
program goes to LOOP and continues reading records
from the WSU transaction file until an error is
encountered or the last record in the chain is
reached.
The program ends in one of two ways. Either Cmd key
7 is pressed, turning on indicator KG, or a bad file is
found, turning on indicator 03. Either condition causes
the program to branch to END, turn on the LR indicator,
and display the EN D OF JOB screen. If indicator 03 is
on, the error message BAD FILE is also displayed.

RPG Output Specifications
S

0

~ Space

~ ~

Filename

Line

>-~

>-

3

4

5

6

a

7

8

~

i'it
>f-'- cl;~

~

~

1

l!! "

.E

'A ~~

~~

co

~

Z

o

I

o II) II~ PL IAI~

2

0

3

0

4

0

o

5

0
0

7

0

o
o

8

0

9

0

I 0

0

I

I

0

2

0

I 3

0

I 4

0

I

0

I 6

011

I

0

7

I 8

0

I 9

0

2 0

0

'AUTO

~~

~~

i

End

Position
in
Output
Record

Yes
No
Yes
No

No Sign

CR

I

A
B
C
0

2

3
4

:

X -

J

Y -

K
L

Z

M

&

Remove
Plus Sign
Date
Field Edit
Zero
Suppress

a:

Constant or Edit Word

..J

'"

Q:
•

1

234567

8

9

1011 12 13 14 15 16 17 18 19 20 21 22 23 24 •

NL

rNL

N

11tJIl

J<~

~

IN I,,"

~~ IIrl
12

11
liB

~
IJ:I

IA Ie

11

,

'11= ~Ir t
Ie 'ip 'AI,., II: IL J(; ,

1~l3

I~

I~IA Ihll~

,

't-'I~ ~I~ III

, wlc:; lrln

III' ~~ II tJ l"le pll ~ht
I ~ IriT IF~ II !N Ir I
l4rn V'~ ~L ~
' I-ol
11rLl ' Itr<;I,ln ~!, tAlA If'

J~ WI~
I~

1-

5

a:

z

Z

rrl

Zero Balances
to Print

Yes
Yes
No
No

III

,..
,..

f-I- 1-1I

AL

Commas

~

,..
f--

6

Field Name

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 3031 32 33 34 35 36 37 38 19 4041 4243 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 7J 74

o
o
o
o
o

:>

Output Indicators

Skip

~~

~

1'-'

1'6

.'1.

IN IR

I~~ rr~

'I-:

Figure 3·17 (Part 4 of 4), Reading a Work Station Utility Transaction File

Columns 40-46 (Device)

3-41

The following entries must also be made on the file
description continuation line:
Column

Entry

7

F.

5-52

Must be blank.

Contents of the Array

The array named in columns 54 through 59 of the
continuation line is used to pass parameters from the
RPG II program to SUBR22 and from SUBR22 to the
RPG II program. The entries that can be made in the
array are described in the following text.
Positions 1-7 (Starting Record Number)

K.

53
54-59

Name of an array with one
13-character element. This array
must also be described on the
extension specifications.

60-74

Must be blank.

75-80

Program identification.

Entry: Any valid zoned decimal relative record
number or- blank
To read part of a logical chain in the transaction file,
specify the relative record number of the first record
to be read. Records are read from the file until the
end of the logical chain is reached or until a restart
parameter is specified. The starting record number is
blanked by SUBR22 after it is used to process
records.
Positions 8-9 (Work Station 10)
Entry: 2-character work station 10 or blank
To read one logical chain from the transaction file,
specify the work station 10 of the display station
whose logical chain is to be read. Records are read
from the file until the end of the logical chain is
reached or until a restart parameter is specified. The
work station 10 is blanked by SUBR22 after it is used
to process records.
Note: When the file is read, this same value is in
positions 11 and 12 of the trailer portion of the
transaction file record.

3-42

File Description Specifications

Position 10 (Type)

Position 12 (Last Record Flag)

Entry: A or blank

Entry: E, L, or blank

To read all the logical chains in the transaction file,
enter an A in position 10. All logical chains in the file
are read in the sequence in which they are chained
(that is, all data records are read for the first display
station in the chain, then for the second display
station in the chain, and so on). The type entry is
blanked by SUBR22 after it is used to process
records.

An E is returned to the RPG II program in position 12
of the array when an A was specified in position 11
of the array and one of the following conditions
occurs:

Position 11 (Restart/Active)

• The end of the logical chain is reached when a
starting record number was specified in positions
1 through 7.
• The end of the logical chain is reached when a
work station 10 was specified in positions 8 and 9.

Entry: A, R, or blank
The restart parameter allows the RPG II program to
read/update more than one logical chain and to
read / update active logical chains or chains from
sessions that ended abnormally. When an R is
specified in position 11, the program starts
processing records from the file as specified by the
parameter list. However, an R should not be moved
into position 11 before the first read is executed for
the program. When an A is specified in position 11,
the program also starts processing records from the
file as specified by the parameter list. An entry of A
allows the program to process records from active
work sessions and work sessions that terminated
abnormally. If position 11 is blank, the next record in
the logical chain is read.

• The last record of the transaction is reached when
an A was specified in position 10.
Note: A blank record is returned to the program
whenever an E is returned to the array.

Columns 40-46 (Deyice)

3-43

An L is returned to the RPG II program in position 12
of the array when one of the following conditions
occurs:
• The current record is the last record entered for a
work session that ended normally when a starting
record number is specified in positions 1 through

7.
• The current record is the last record entered for a
work session that ended normally when a work
station I D is specified in positions 8 and 9.
• The current record is the last record entered for a
work session that ended normally, the work
session is the last work session in the transaction
file, and an A is specified in position 10.
When an E or L is returned to the RPG program, the
programmer can specify the restart option (R in
position 11). If the E or L parameter is ignored by
the program, the next read request to the subroutine
causes a normal end-of-file indication to be returned
to the RPG II program. After the end-of-file
indication is returned to the RPG II program,
additional attempts to access the file also result in
end-of-file.
SUBR22 blanks out the last record flag if a restart is
specified.
Position 13 (Error Flag)

J
This file has not closed normally and contains
display station sessions that may be incomplete.
However, the data being processed by the
program comes from a completed display station
session. A data record is returned to the program
with this error flag.

N
No-record-found error occurred for one of the
following reasons:
• The work station ID specified in the parameter
list is invalid.
• The parameter list does not contain a starting
record number, type, or work station I D
parameter for a first-time or restart option.
• The relative record number specified, is invalid.
A blank record is returned with this error flag. If a
no-record-found error occurs, the restart option
must be specified the next time the subroutine is
called, and the programmer must reset the
no-record-found indicator.

P
An attempt was made to update a record, but no
record was retrieved for the update.

Entry:
D
Blank
No errors found. The subroutine has returned a
good data record to the program.

An attempt was made to process a delete-capable
file. The work station utility does not allow
delete-capable files. Processing of this file is
canceled and the file is closed.

W
This display station session ended abnormally. The
last sequence set may be incomplete, or some
inserted records may have been lost. A data
rec?rd is returned to the program with this error
flag. SUBR22 does not read any records that have
been added during the work session that ended
abnormally.

3-44

File Description Specifications

Note: When the subroutine is accessed the first time or
with a restart parameter specified, one of the three
first-time options (starting record number, work station
ID, or type) must be specified in the parameter list. If a
valid option is not specified, the subroutine returns to
the program without reading a record. If the subroutine
is accessed twice consecutively with a valid option
specified, a normal end-of-file indication is returned to
the RPG II program. If more than one valid option is
specified, the subroutine only processes the first valid
option found. The subroutine checks for the first valid
option in the following order: starting record number,
type, and work station I D.

System Input Subroutine for SPECIAL Device
(SUBR01)
The IBM-written subroutine SUBR01 (system input
subroutine) can be used to input a record for use by
system functions, such as system utility programs or
program products. To use this subroutine, specify
SUBR01 in columns 54 through 59 for a SPECIAL
device. This subroutine makes 120-character records
available to the SPECIAL file. RPG treats the records
read by SUBR01 as data records.
The record length and block length entries for the
SPECIAL file should be 120 to avoid execution errors. If
the block length is not specified, it defaults to the
record length. If the operation control language (OCl)
statements to execute the program are entered from the
keyboard, the records to be made available to the file
must also be entered from the keyboard. If a procedure
was called to execute the program, the records to be
available to the file must follow the RUN OCl statement
in the procedure. The last input record in the procedure
should be followed by a END control statement. If the
program is an SRT program and if there is no END
statement in the procedure, successive OCl statements
(entered from the keyboard) are read as input to the
SPECIAL file in the program. If the program is an MRT
program, a procedure must be used for the data records
and the EN D control statement must follow the last data
record.
If a program is to be run from the input job queue, a
procedure must be used to execute the program. If
CONSOLE is specified in the same program as SUBR01,
the OCl and the data records for SUBR01 must be
contained in a procedure or undesirable results can
occur.
See the System Support Reference Manual for
information on how to create a procedure.

1255 MICR Subroutine (SUBR08 and SUBR25)
The 1255 MICR subroutines (SUBR08 and SUBR25)
allow you to use the 1255 as a SPECIAL device in an
RPG II program. To use SUBR08 or SUBR25, you must
place certain entries on the file description and
extension specifications in order to define the SPECIAL
device file and to name the subroutine. SUBR08 uses
system and stacker specifications to describe each job
to be performed by the 1255. SUBR25 uses a SUBR25
parameter list and a Device Control language program
to describe each job to be performed by the 1255. The
system and stacker entries or the SUBR25 parameter
list is placed in an array. See the IBM System/34 1255
Magnetic Character Reader Reference Manual,
SC21-7740, for more information and examples of how
to code the file description and extension specifications.

COLUMNS 47-52
Columns 47 through 52 are not used. leave them blank.

COLUMN 53 (CONTINUATION LlNES-K)
Entry

Explanation

K

Continuation record

Use column 53 to indicate that a continuation record
provides additional information about the SPECIAL file,
disk file, or WORKSTN file being defined. Only one
continuation record can be specified for each SPECIAL
file or each disk file; however, several continuation
records can be specified for a WORKSTN file. When
you specify a continuation record for a SPECIAL device,
columns 54 through 59 (continuation line option) must
be coded. When you specify a continuation record for a
disk or WORKSTN device, columns 54 through 65 must
be coded. Figure 3-18 shows an example of the coding
necessary on the file description specifications sheet for
a continuation line for a SPECIAL file.

Column 53 (Continuation Lines-Kl

3-45

File Description Specifications

Record Address Type

Sequence

Fiiename

Type of File
Organization
C'\j or Additional Area

File Format

Line

u..

o

t

~

~
~

..J

Device

LU

Symbolic
Device

Name of
Label Exit
Storage Index

~

o Overflow Indicator 8

BloCK
Length

Record
Length

~w~~

~

S~
~~

-5
Key

~ield

~

Continuation Lines

~~a::~~~n ~

Option

Entry

-1-+--1--+-

Figure 3·18 Specifications for a SPECIAL Device

COLUMNS 54-59

Name of Label Exit
Entry

Explanation

Blank

No SPECIAL device is used.

SUBRxx

Name of the user-written or
IBM-written subroutine that cannot
be overlaid and that performs the
input/ output operation for a SPECIAL
device. (For a user-written subroutine,
x = any alphabetic character. Numeric
characters are reserved for
IBM-supplied subroutines.)

SRyzzz

Name of the IBM-written subroutine
(5-character name in library is @yzzz)
that performs the input/output
operation for a SPECIAL device
(y = any of the following 15
characters: B, C, D, F, G, H,
I, L, M, 0, P, R, S, T, or U;
z = any of the following 16
characters: A, B, C, D, F, G, H,
I, L, M, 0, P, R, S, T, or U).

Note: Subroutines of the type SRyzzz can be overlaid.
Modifications within the subroutine code mayor may
not be present the next time the subroutine is used.

3-46

File Description Specifications

Use columns 54 through 59 to specify the subroutine
that performs the input/output operations for a file
assigned to a SPECIAL device. Columns 54 through 59
must contain an entry for each file assigned to a
SPECIAL device. The subroutine name entered in
columns 54 through 59 can be from 4 to 6 characters
long. For a user-written subroutine the first 4 characters
must be SUBR; the remaining characters can be any
alphabetic character.
Note: User-written subroutines should be placed in
#LlBRARY, not in the same library as the RPG II source
program.

Continuation Line Option for SPECIAL Device
Entry

Explanation

Table/ array
name

Name of table/ array used by the
user-written subroutine. The
array name cannot be ASCII
or BUFOFF.

Continuation Line Options for WORKSTN File

Keyword

Value

The following options can be specified for a WORKSTN
file if more than one device is attached to a program or
if you want to specify the WORKSTN file information
data structure (INFDS) or the WORKSTN
exception/error processing subroutine (INFSR). The
NUM keyword is required if the program attaches more
than one device to a file at the same time. Enter the
keyword in columns 54 through 59 and the value in
columns 60 through 65 (columns 60 through 67 can be
used if the FMTS option is specified).

IND

Number of indicators, beginning with 01,
that are to be saved and restored by
display station. Indicators 01 through the
number specified here are saved and
restored for each display station. If IN D is
not specified, or if NUM equals 1, no
indicator swapping is done. The entry
must be right-justified in columns 60
through 65.
Note: For SAVDS and IND, only one copy
of the data structure and indicators is
available at a time. The indicators and
data structure that are available are those
associated with the device from which the
last input was read.

Note: For WORKSTN files, a device can be either a
display station or an SSP-ICF session.

Keyword

Value

NUM

Maximum number of devices that can be
attached to this file at one time. The
number specified must be right-justified
in columns 60 through 65. If not
specified, 1 is assumed. If specified,
NUM must be greater than or equal to the
number of requestors specified by the
MRTMAX parameter on the COMPilE
statement plus the number of acquired
devices (those specified on the
WORKSTN OCl statement or in the ACO
operation). The number specified on the
MRTMAX parameter is reserved'for
requestors. The difference between the
MRTMAX value and the NUM value is the
maximum number of devices
(nonrequestors) that can be attached to
the program at one time via Oel
statements or the ACO operation code.
For example, if the M RTMAX value is 5
and the NUM value is 6, only one
nonrequestor device can be attached to
the program, even if only one requestor is
presently signed on.

SAVDS

The data structure and indicators that are
available change each time an input
operation (either a primary file input or a
demand file read) is executed. On an
input operation, the present copy of the
data structure and indicators in the
program is written to a save area for the
device from which the previous input was
read. The data structure and indicators for
the device now being read from are then
written from the save area associated with
the device to the program SAVDS and
IND areas (for further information~ see
Figure 13-2 in Chapter 13).
SlN

Name of a two-digit numeric field whose
value determines the first line on the
display screen where the display format is
to begin if a variable starting line number
(V In column 17 of the display screen
format S specification) was specified in
the format. If SlN is not specified, all
formats having a variable starting line
number begin on line 1.

Name of a data structure that is to be
saved and restored for each device
attached to this file. This data structure
cannot be a display station local data
area, and it cannot contain a compile-time
array or a preexecution-time array. If
SAVDS is not specified or N U M equals 1,
no data area swapping is done.

Columns 54·59

3-47

Keyword

Value

Keyword

Value

FMTS

*NONE. Indicates that there are only
SSP-ICF formats present in this program.

INFSR

Name of the user-written calculation
subroutine designated as the WORKSTN
exception / error processing subroutine to
which control may be passed if an
exception / error occurs during the
following operations: ACO, REL, NEXT,
POST, input (READ or primary input), or
output (EXCPT operation or normal cvcle
output). If INFSR is not specified, the
program halts if an exception / error
occurs. See WORKSTN Exception/Error
Handling in Chapter 13 for more
information on INFSR.

INFDS

Name of the data structure that contains
the identification of the type of
exception / error condition and an
indication of the WORKSTN operation
that was executing when the
exception/ error condition occurred. It also
specifies the area that is posted with the
display station screen size (960 or 1920
characters) and information about
ideographic support. If IN FDS is not
specified, this information is not available
to the RPG II program. See WORKSTN
Exception/ Error Handling in Chapter 13 for
more information on IN FDS.

Display screen format load member name.
The compiler uses the name specified
here as the display screen format load
member name. The format load member
name entered here can be from 1 to 8
characters in length, left-justified in
columns 60 through 67. If a name is not
entered, the compiler assumes the display
screen format load member name is the
program name (from columns 75 through
80 of the control specifications) with FM
added to the end of the name.
ID

Name of a 2-character self-defining
alphameric field that contains the ID of
the device that supplied the record being
processed in this file. The ID field is
updated whenever a record is read from
the WORKSTN file. Therefore, it always
contains the identification of the device
from which the last record was read
(unless your program moves a different
identification into the ID field). This field
is considered self-defining because it
need not be specified a's an input or result
field. For a multiple device file, you can
direct an operation to a device other than
the one currently being processed by
changing the value in the ID field to the
symbolic ID of another device in the file
before performing the output operation.
The device I Ds are assigned at system
configuration time. Display station IDs are
in the form AX, where A !s an alphabetic
character (A-Z, #, @, or $) and X is any
character. If a WORKSTN OCl statement
exists for the display station, the I D is the
same as the value of the SYMID
parameter.
SSP-ICF session IDs can be in two
formats.- They are either N N where N is
numeric (0-9), or INA where N is numeric
and A is alphabetic (A-Z, #, @, or $). If
the format is NA, a SESSION OCl
statement must be specified with a
SYMID parameter whose value is also in
an NA format.

3-48

File Description Specifications

For more information on the keywords and their
associated values, see Chapter 13, WORKSTN File
Considerations and Sample Programs.

Continuation Line Keyword Option
The RECNO keyword is used to randomly add records
to, or to load, a delete-capable disk file.

Keyword

Value

RECNO

Name of a numeric field that is seven
digits long with zero decimal positions.
This field name must be specified if
records are to be added randomly to a
delete-capable direct or sequential file.
This field name is also required for a
direct file load of a delete-capable file.
The programmer places the relative
record number of the record to be added
to the file in the RECNO field. It must
be the relative record number of a
deleted record, a record that has been
initialized to hex FFs. RPG uses the
relative record number in the RECNO
field to determine where a record is to
be loaded (direct file load) or added
(ADD on output specifications).
Note: If a CHAIN operation successfully
reads a record from a sequential or
direct file, RPG places the relative record
number of this record in the RECNO
field.

COLUMNS 60-65 (STORAGE INDEX)
Entry

Explanation

Blank

No storage index is kept in storage.

6-9999

Number of bytes reserved for the
storage index.

The storage index is a table containing entries for tracks
in the index portion of a file. Each entry contains a
sector address and the lowest key field from the next
track in the file index. The index portion of a file
contains the position of the records in the file. Each
index entry consists of a key and a 3-byte disk address
for each record in the file. The last entry of the file
index contains all FFs to indicate the end of the index.
Figure 3-19 shows the layout of the index for the
indexed file, INDEXT, and the most efficient storage
index for the file, INDEXT. Notice that the storage
index contains one entry for each track in the file index
if the space reserved is large enough.
Use of the storage index significantly reduces the
amount of time needed to process an indexed file. It
enables the system to go more directly to the specific
record you want by searching only a small portion of the
file index. Without the storage index, all file index
entries that precede the record you want must be
searched. When the storage index is used, as shown in
Figure 3-19, the record 767 can be found in the
following manner:

1.

Search the storage index until the first key field
higher than key 767 is located. In this instance the
key is 769 on track C; therefore, key 767 must
reside on track B.

2.

Search track B in the file index until key 767 is
located.

3.

Chain directly to the associated data record.

In columns 60 through 65, specify the number of
storage positions (bytes) you want reserved for the
storage index. Using the amount of main storage you
specify, the system builds the most efficient storage
index it can. The storage index is built immediateiy
before your RPG II program is executed.

Use columns 60 through 65 to specify the number of
bytes to be reserved for the storage index. Columns 60
through 65 apply to indexed files processed randomly
via the CHAIN operation code and indexed files
processed sequentially within limits. Specifying a
storage index provides faster retrieval of records.
Storage index cannot be specified with a shared
input/ output area. Entries must end in column 65.
Leading zeros are not required.

Columns 60-65 (Storage Index)

3-49

Record # 1
key

Track A

J.--a
d
d
r
e

a
d
d
Record #385
key

Track B

e
s

Record #386
key

,

a
d
d
r
e

Record # 383
key

a
d
d
r
e

Record #767
key

a
d
d
r
e

a
d
d
Record #384
key

\

e
s

)

16 bytes----.f

Record #387
key

a
d
d
r
e

I

Record # 768
key

a
d
d
r
e

\

Record # 769
key

Track C

a
d
d
r
e

a
d
d
r
e
s

Record # 770
- key

Record # 771
key

a
d
d
r
e

I

I

Record #999
key

a
d
d
r
e

Record # 1000
key

a
d
d
r
e

------~----~~----~~~\\~----~~----~~
I

I

I ndex layout for
file INDEXT
48 bytes

SSS

Key of
Record #
385

I~SS

~13 bytes.....)
Sector address I
(3 bytes)

Key of
Record #
769

SSS

1.- 13 bytes .....)

Track B
address
(3 bytes)

FFFFFF

I

....--Storage index for
file INDEXT

1.-13 bytes .....)

Track C
address
(3 bytes)

Ilf the index begins on a track boundary, this address will also be a track address.
Figure 3·19. Example of Storage Index

3·50

File Description Specifications

For efficient processing, the storage index you specify
should be large enough to contain one entry for each
track in the. index, plus one entry that is the delimiter for
the storage index. The minimum number of bytes
required for a storage index entry for one track equals
(the key length + 3) multiplied by 2. For example, if file
INDEXT has one track that contains index entries and a
key length of 4, the most efficient storage index is 14
bytes, that is, (4 + 3) times 2. If the file index occupies
more than one track, the number of bytes required for
the storage index equals (the key length + 3) multiplied
by (the number of tracks containing index entries + 1).
For example, if the key length equals 4 and the number
of tracks containing index entries equals 5, the number
of bytes required for the storage index is 42; that is, (4
+ 3) multiplied by (5 + 1) equals 42.
To determine the number of bytes in the storage index,
use the following calculation:

If the storage space specified in columns 60 through 65
is not large enough to contain an entry for every track of
file index, the system divides the given area into as
many entries as there is room for with each entry
pointing to a larger track of the file index. As the
number of entries in the storage index decreases, the
amount of processing time increases.

COLUMN 66 (FILE ADDITION)
Entry

Explanation

A

New records are added to the file.

U

Records are to be loaded for an
indexed file in unordered sequence
(random sequence).

Use column 66 to indicate:

1.

Use the CATALOG procedure to find the total
number of records that the file can contain.

2.

Determine the length of an entry in the file index
by adding 3 to the key length.

3.

Determine the number of keys in each sector by
dividing 256 by the entry length. Drop the
remainder.

4.

5.

6.

Determine the number of sectors in the index by
dividing the number of records in the file (the
. result of step 1) by the number of keys in each
sector (the result of step 3). Round up the result.
Determine the number of tracks in the index by
dividing the number of sectors (the result of step
4) by 60 if your disk has 27.1 megabytes or less.
Divide by 64 if your disk has more than 27.1
megabytes. If the quotient is not a whole number,
round it up to the next whole number. (To
determine the number of megabytes on your disk,
use the STATUS command to display the status of
your work session. The AVAILABLE DISK SIZE
field on the third display of work station status
shows the number of megabytes on the disk.)
Determine the optimal size for the storage index
by multiplying the length of an entry in the file
index (the result of step 2) times the number of
tracks in the file index (the result of step 5).

• The program is to add new records to the file (Figure
3-20). Records can be added at detail, total, or
exception time during the program cycle.
• The program is to load records in an unordered
sequence (Figure 3-21).
Column 66 applies to direct, sequential, and indexed
disk files.
Note: Adding records to a file also requires a
corresponding ADD entry in columns 16 through 18 of
the output specifications.

Adding Records to an Indexed File (A)
Records added to an indexed file are added at the end
of the file and entries for the new records are made in
the index. (See Key Sorting for Indexed Files in the
Concepts and Design Guide for an explanation of when
the system sorts the keys into ascending sequence.) File
addition (column 66) cannot be specified for indexed
files from which records are read by the
sequential-within-limits method. Records added to an
indexed file should be in ascending sequence to achieve
better performance.

Column 66 (File Addition)

3-51

When indexed chained files are specified with add, the
records to be added may contain either of the following:

If records are to be added to an indexed file processed
sequentially:

You must place in the RECNO field the relative record
number of the record to be added to the file. It must be
the relative record number of a deleted record (one that
is filled with hex FFs). You code output specifications
that contain ADD in columns 16 through 18 to add
records to a file. RPG uses the relative record number
from the RECNO field to locate where the record is to
be added to the file. If the relative record number is not
the number of a deleted record, a halt occurs and a
message is issued stating that a duplicate record exists
in the file. An option to continue can be taken, but the
record is not added to the file.

• The key of the record to be added must be lower
than the key currently in process and higher than the
preceding key, or

If a CHAIN operation accesses a nondeleted record in
the file, that record is returned to the program and RPG
places the relative record number in the RECNO field.

• The file must be at end of file.

Records cannot be added to sequential files past end of
file by using the RECNO keyword. For example, if a
sequential file has relative record numbers 1 through 5
and 7 through 10, a record can be added at relative
record number 6 but not at relative record number 11.
Attempting to add a record past end of file results in
error RPG-9038, THIS FILE IS FULL.

• Keys that are above the highest presently in the file.
In this case, the records constitute an extension of
the file.
• Keys that are either lower than the lowest presently
in the file, or fall between those already in the file.

If these requirements are not met, a halt occurs;
otherwise, the record is added.
To add a record to any indexed file processed randomly,
the program searches the index to the file to determine
whether the record is on the file; if it is, a halt occurs.
Otherwise, the record is added.

Extending a Sequential File
Adding Records to Delete-Capable Direct and
Sequential Files

Records can be added to direct and sequential files that
are processed randomly by relative record number. The
file must be defined as delete-capable when it is built.
When a delete-capable direct file is built, it is initialized
to all deleted records (hex FFs). For further information
on defining delete-capable files, see FILE Statement in
the System Support Reference Manual.
If records are added to direct or sequential files, the file
must be defined as an input or update chained file on
the file description specifications. The file description
specifications must also contain an A in column 66 to
specify file addition. The keyword RECNO and its
associated field must be specified on a file description
specification continuation line for each file that records
are added to (for further information on the RECNO
keyword, see Continuation Line Keyword Option in this
chapter).

3-52

File Description Specifications

Records can be added to a sequential file without
specifying the RECNO keyword. The file must be
defined as an output file and column 66 of the file
description specifications must contain an A to specify
file addition.
Records added to a sequential file are added to the end
of the file. They cannot be added between other
records.

File Description Specifications
File Type

F

File Addition/Unordered

Mode of Processi n9

Extent Exit
for DAM

Length of Key Field or

File Designation

f----

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Type of File

Fde Format

Line

Ci

~a:

!
~

4

J

5 6

789

2

F

o

3

F

0 4

F

o

F

!

F

:1I

5

Record
Length

Length

~-.

P:R:IN'f

JJJ

I

~: H.- -~
I

1'1:
!
I

I

Tape

~

Storage Index

~

u:

~~

;: e

cc

Location

:1l2I,

F ~!5c

iE~~2

~I- f-.

113~
i !I

K

L.U

!rIA

'

I

:

"

:

I

i

!

!

i

:

~

The new records are contained in disk file DISKIN. The
file INDEXED is the existing disk file to which new records
are added. A printer file, PR INT, provides a report showing
all the records in DISK IN with an indication of which
records are not added.

606162636465 66 67 6869 707172 7374

Ir

I

!

!

I
I

i

lA

!

,
I

r

1

I

I

II I

1

il UJ

~

Entry

Option

1

: ~+ LP'Ril'NT,ER
-H' I I I
'

i I

I :

I

I

AAtI.

Z

::J

1
~ ~~Sll<
[l)lSIK I
I

b~

U1.~

Continuation lines

Starting;

~ ~

...J

Condition

~~

10"121314 1516 17 11:1 19 ;'0 11 22 23 24252627 28 29 30 3132 3334 35363738 3940414243444546 47 48 49 50 51 52 53545656675859

12~- lE J12~~
m.;slKintJ
11Nl\I~"i 1;;]) ~

o

o 6:
L

~

BloCK

~
o >
c.1"

Number of Extents

o Overflow Indicator c3

0

UJ

Symbolic
Device

Device

...J

Organizdtion
C"o or Additional Area

Number of Tracks
for Cyliflrler Overflow

Name of
Label Exit

On the file description specifications sheet, an A must appear
in column 66 for the file INDEXED. On the output specifi·
cations sheet, ADD must appear in columns 16 through 18
for the new record to be added.

Line Counter Specifications

L

10

I---

:"

Line

0

5 6

1

1

1

2

::i

7

8

9

<5

6 .3
0

~

§
i.

...J

12

~

~

Filename

11

§

~

::i

Z

~

~

0
...J

0

::i

16 ~~ I

~

Z

::i

I

~

~

~

::i

i3

s

"'

z

u

~

c
::i

i §I I
U

::i

l~

"'

E
::i ~

~
I jZ
~

§

Z

U

::i

::i

~

1
6 iz

::i

]j

~

u

~

::i

~

1
U

§
Z

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3S 36 37 38 39 4D 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

d)Q.IIWT

",Ibll=l

~~f'\IL

I

!

I
I

I

I
I

As defined on the input specifications sheet, all the
records in DISKIN should have an A in position 120.
The code identifies a record to be added to the disk file,
and this record type is assigned indicator 01. On the

output specifications sheet, notice that when 01 is on,
the data from DISKIN is written on the disk file
IN D EX ED and is also printed on the file P R INT to keep
a visual report of new records.

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

I--Filename

Line

~_:J

,~ ~ ~_·_i-.~
"'~

:= (/)

-

~
Position

ES="E"

~~~~~§

OR
ZOo:
f-~f-

9

10 11 12 13 14 15 16 17 18 19 20 21

'AlA

o 2

I

o

4

I

o

5

I

o

6

I

o

7

I

o

8

I

I

E

~.e~
;~2

ZUU

AND

345678

_

n

Position

~e~
E~2

Position

Field Name

To

Frorn

Zero
Plus

Minus or

Blank

ZUU

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4647 48 49 5051 52 53 54 55 56 57 58 59 6061 62 63 64 65 66 67 68 69 70 71 72 73 74

,

~2 If 1?~IP1IlrIA

I

112
!

'i.1

I

i

!

i

!

I
i

!

i

Figure 3·20 (Part 1 of 2). Adding New Records to a File

Column 66 (File Addition)

3·53

Output Specifications

o

~ Space
u.-

I---

~~ ~
o R
~fN

3

4

5

0'

o
o

2
3

I

~ ~ !!

Filename

Line

6

7

8

-;;:

0

Z

Field Name

II

....

.1

I

20

2°

Zero Balances
to Print

No Sign

~~s

!

p~~tion

~~

-

X = Remove

g

~

Z

Field Edit

~~~~ress

=

--

Constant or Edit Word

Record

- -

CR

=I==";;;;"YN~eOs~4===2'==*==AB*JK==i Y = ~~:eSign

~ ~ ~utPut ~~

,~§

'AUTO

I

.

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 '

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30131 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 12 73 74

ollJNll1 Elxit; lr In ~ II I~_ --1-4 _
0
_
1_ r- _1
rJ{ii;[V I
0
I
IFit :.;.:, M
I

-W-+-J-Lr- ~ - -t1-+-

0

Commas
F=Yy=ee=ss

E

a:

And

I

r
1-----I----l--l---°---l--l~-L-~L - '-I__ ~ -Ho 6 0 'P,< I NT
lu
.~ ~a'
::

'I

.t>.

I

And

~'i5 ~ ~
ro

L?r'

Output Indicators

Skip

~ ~ ~

IFII EL~

'i'" 0Rtf:llt--~
~t I

II

I

i

i 11Jcl
: 12.Q

11

r--r:J'Cl

-+t

-r

'

'

1- _J ~-L
I.

Iii

I

,I

-b.~ __ i I

:

L1!

Iii i

I

I

I

I:

I
I

J
I

I

I I ! ! 'I

I

I

I

I _,

1

I i
I,

i

I

I

I

I
I

I

:

!

_b~::~ ~_: t- -~bl~r- T~-+--~ 1~1_' ~__ ~: Ie '_: tr4--+ Jwt: I i ,
~~_ 0
_~
tr-_,-~f~
r-r+- +j_~___+-It
_ t-L~~I~lU!N'NA?I~QhO~EL:Re~CC_~'A~~~+'
iit
I r- '1
-r-r
:'"
I~q- '~I E;":r!Ito\! :J:tlEfm' -r-H-I':0
t~l- -I;t 1- -T I--:dlt r-11-,-r- j--+--I 'I 1+ - -~I~
~-t~ I I r~-rj, I
: - ,-~i-h--"--+
" 0
bl~r- - ~t- r -T -~'! -- -r - if--c ,-t-- -,--~ t-- r,-rtf-- - tTL rr--~ r- :-rrt-t--I I +I I
I: ~-T~
---:~~W---+I'i
'--5~~~
-, It' I:';:: --H-+--t-+-t-El~I ~-:-f-t-rl- -I-- -~L-f--tt-I---r+-I----Lf--t-+--,H
f-r --'~~f-- -+
~_--l_~L ----r-i-'--f---L+-~,
I
: '::
rT, I
: ! ~,- H-Ti
~~;~~~t- --;--~~~ -f-t---C:- I--t-+ l--- ~ -r=~-LL i i i
!

o

7

0

!i Itl

I

-

0

_1_

019

I

I

I

I

'iJ(ln

0

,

2

0

-

I

,

5

-f---- -

,

-r -,

t--t--I-

0

1 6

0

'7

o

1 8

o

I

I

I

11\

-w:
l-

~--'-,- -r-t-t~~:~!ItJ~- -~-.t"
II"I,Vlnlt:.

__ '--- L_

Ililt '"
112 ~
I

I

I,

I;

f

r!

'

,

I : :

I

--t--~:--' '-I-L.:.-J-+'~
I
l'
tl~I~~t'lIIRrn I~r /1' JAit e •

---1---

I

I

I

I

'

I

I

I

;;

!

I

I

I -{-

I

I

;

':

"

I

I:

'

I

I

:

1
I

.-t--+-+-!-t--+-+--+---i

-r

There may be records in DISKIN that do not belong in that
file, or some records may have an error. Those records are
identified on the input specifications sheet as not having the
character A in position 120. These records turn on indicator
02 and are not to be added to the disk file INDEXED.
However, these records are printed on the file PR I NT for a
visual report, but they must be identified in the printed
report as records that were not added to the disk file
INDEXED. On the output specifications sheet, the constant
RECORDS NOT ADDED is printed only on indicator 02,
indicating a record that was not added to the disk file. In
this manner, a report of all records in DISKIN is printed, and
the records not added to INDEXED are identified by the
constant RECORD NOT ADDED.
Figure 3-20 (Part 2 of 2). Adding New Records to a File

(
3-54

File Description Specifications

File Description Specifications
File Type

F
I--

File Addition/Unordered

Mode of Processi ng

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation
End of File

Record Address Type

Sequence

Filename

Type of File

0

~

Cl

~ ~
7

5 €

4

J

o

2

o
o

3

FMAS~ER

41

F

1

o

5!

F

I

t-~

Record

Block
Length

'"

Key Field
Starting

'" >-

~~

Length
0::

:;

u::

::J

·__ 1PE _I~ -~
0

~

Location

Condition

,
~

,t-

qb

I f--f---18 IAr:
I
I T

16'1

25b

I
I

I

_.

:

l

I,

Z

~

::>

I I!
I I!

j D1..51<1 I !
I

I

1

1

I

TI

;

1

I

1

I

!

I

i

1

I I

I
I

I

I
III

I

i

!

60 61 62 63 64 65 66 67 68 69 70 71 72 7374

II
I

I

I

I

I

~

Entry

Option

K

~,~~jlf-

f-

0

4

Output Indicators

Skip

&~ !~

!
3

Space

tt-

~ ~

Filename

Line

~

0::

i~ I

~
Z

~

Oi

:3 5

~ ~

'AUTO

i

i

a

:>
End
Position

0

o : 3,

1

0\4
~.'

0

0

I!

I,

'

I

i

:

I

I

Ii

Zero Balances
to Print

Yes
Yes
No
No

Yes
No
Yes
No

II

In

Output

Record

~
g

0:

No Sign

CR

~

X = Remove

I

A
B

J

Y

C

K
L

Z =

D

M

Plus Sign

2
3
4

= Date
Field Edit
Zero

Suppress

Constant or Edit Word
\

1

2

3

4

5

6

7

B

9

10 "

12 13 14 15 16 17 1819 2021 222324 '

1516 1712 19 20 2122 J24 25 2627128 29 30 31 323334353637 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

..

ffi- -rt-l---~-Ltlli~-H

01_1 o~~StT\,RH-~
L~l1-'LH~iqlkTT1
12\
I
lie·
i h~
+lr-~-l+;-'
;-; . . " " " -- -+-r--n--::TT~IIqRt~
1 I .
: I :
,I I i++++
;,
.
.
.
+---.
f--f--+-I II i ' : : _lLL:
:, Ti TT
.1 '
_.!..._ :
:
o

Commas

i

--i-·

' I
I1__

!

.

i

' I

:.

I

.

:
~

-+-

I:
rr--r---H I \ : I I
I,

II

I

1

I

I

I

!

I

II
II
I !
i

;

Figure 3-21. Unordered Load of An Indexed File

Column 66 (File Addition)

3-55

Loading Records in an Unordered Sequence (U)

File Addition Functions for Sequential Files (File
Extension)

Unordered load (U in column 66) is specified when an
indexed file is to be built from records in an unordered
sequence. After records are loaded and an index is built
in the unordered sequence, the system sorts the index
into ascending sequence.

Col
15

Col
66

Function

o

A

Extend an existing sequential
file by adding records to the
end of the file.

o

Blank

Load records in a sequential
file.

File Addition Functions for Indexed Files

In the following chart, combinations of entries in column
15 and column 66 show the functions that can be
performed for indexed files (I in column 32).
Col
15

Col
66

Function

o

Blank

Load records in ascending key
sequence to an indexed file.

o

U

Load records in unordered key
sequence to an indexed file.

o

A

Add records to an existing
indexed file.

U

Read records of an indexed file
without adding new records or
updating records.

0

Blank

A

U

U

Blank

A

Read records of an indexed file
and add new records to the file
that are not presently there. No
updating is performed.
Update records of an indexed
file without adding new records.
Update records of an indexed
file and add new records to the
file.

Random File Addition Functions for Delete-Capable
Direct and Sequential Files
Col
15

I

Col
16

Col
66

Function

C

A1

Add records to an
existing direct or
sequential file.

C

A1

Add records to an
existing direct or
sequential file.

Blank 1

Load a direct file.

Adding records to delete-capable files requires that the
keyword RECNO and its associated field be specified on a
file description specifications continuation line.

COLUMN 67

Column 67 is not used. Leave it blank.

COLUMNS 68-69

Columns 68 and 69 are not used. Leave them blank.

COLUMN 70

Column 70 is not used. Leave it blank.

(
3-56

File Description Specifications

COLUMNS 71-72 (FILE CONDITION)

COLUMNS 73-74

Entry

Explanation

Columns 73 and 74 are not used. leave them blank.

Blank

The file is not conditioned by an
external indicator.

COLUMNS 75-80 (PROGRAM IDENTIFICATION)

U1-U8

The file is conditioned by the
specified external indicator.

Use columns 71 and 72 to indicate whether the file is
conditioned by an external indicator. Columns 71 and
72 apply to input (excluding table input files, and
KEYBORD files), update, and output files. A file
conditioned by an external indicator is used only when
the indicator is on. When the indicator is off, the file is
treated as though the end of the file is reached; that is,
no records can b.e read ·from or written to the file.
The external indicators are normally set prior to
processing by the SWITCH OCl statement or by a
previous RPG II program. Their setting can be changed
during processing, allowing the program to alter the
status of these indicators. However, if an external
indicator conditions a file, that indicator must be set on
when the program is loaded in order to use the file in
the program. For information on how to save and
restore the external indicators for each display station
attached to a WORKSTN file, see Chapter 13,
WORKSTN File Considerations and Sample Programs.

See Common Entries in Chapter 1.

FILE DESCRIPTION CHARTS
Figures 3-22 through 3-33 show the file description
specification entries for disk files (which are presented
by disk file organization and processing method),
KEYBORD files, CONSOLE files, PRINTER files, CRT
files, WORKSTN files, SPECIAL files, and BSCA files.
When you use the charts, keep the following in mind:
• The entries in the chart must be made for the
processing method and type of file described on that
line.
• The shaded columns must be blank for the file
described on that line.
• The other columns may be required or optional, but
cannot be indicated on the chart because the entries
represent information that changes from program to
program.

How to Use the Charts
If a file is conditioned by an external indicator, any
calculations that are not done when the file is not used
should also be conditioned by the same indicator.

If you are updating an indexed disk file using the CHAIN
operation code, see Figure 3- 22 and refer to indexed
disk files, random processing by CHAIN operation code.
Then choose the chained update file with or without
record addition.
In this example, the following columns are required but
may change from one program to another: filename,
record length, length of key field, and key field starting
location. Optional entries are line, block length, storage
index, and file condition.

Columns 75-80 (Program Identification)

3-57

w

en

oo

-n

-n

~
(1)

CD

~

"0

....

00

0'

ta

§'
::J

en

'tJ
(1)

0

=;;

0'
Q)
r+

0'

a

; U"

of Record Address Field

End of File

•

Sequence

Filename

Record Address Type
Type of File

File Format

Organization

or Additional Area

Line

'"
'":;'

o

s:

Type of

:r

Processing

~

c.

;

by Key, no ADD
by Key, no ADD

~

;-

by
by
by
by

c.
(1)
)(
(1)

c.

0

~
CD

;

5 F

1

Key,
Key,
Key,
Key,

with ADD
with ADp
with ADD
no ADD

by Key, no ADD
Sequential

l

'"
C
'":;'

by Key, no ADD
by Key, with AD D

F

'IllS

F

II

a

5 -

F

a

6

F

a

7

F

08

F

a

9

F

J

a

F

c.
(1)

by
by
by
by

~

Record

length

length

~

11 18

4

:::;

~

I

I

Device

Symbolic
Device

W
~

I~I
-'!!

~

NumDer aT I raCkS

:or Cylinder Overflow

Name of,
Label EXIt

Tape

I

...J

Rewind

Storage Index

~

1~
[S

r

uP IF
b S IF"
Unii'IF
.P F

location
3334 35 36 3138

1- I

li

,
I

[4llli

-

I I I I I I ItI I lA
I ! I I I I ral I 'Aim
I 1 I I I I [:m~

K

W

~IISI~'44

~l

D1

45 46

t(.

~

Iii

Entry

~

59 60616263

56

Option

~
I
}
1

~.

I

-

r-

~
H-

E

Lfl

tt ~~ ~- . "

.

,

zl

e o n t i nlines
Uiiation
::>

~111<

11

r:
F

J..i;:

Ul-U8

~t::t~~:ld ~

~ ~

11

Condition

~2

~~

I I : t l l :I I I
~III.r!1
lJ 1 S
II
DIS K
Ii
r"IlI t<.
11
~1
I
I
~1I 1<

Ii Ii

Dflli!iI~1

Limits
Limits
Limits
Limits

e:

a:

20 2122 23 24 25 26 21 28;>9 3031
1

SI I IFI I
I
PII?l 11=1 I
I IFI I

by Limits
by Limits

;-

1011 121314

03

r+

:r
(1)

9

a

by Key, with ADD
by Key, with ADD

ta

8

11

by Key, no ADD

Block

Ii F
w

'"....

:!!

...J

Extent Exit
for DAM

o Overflow Indicator U

(1)

0

File

IUI.. .. :»;)I"~

length of Key Field

File Designation

J.-

N

.n,

File Type

F

w

0

3l0

File Description Specifications

:c'

151

IDllis;~
II\~I~
i\ll~l.

I I I I I I ILl I IA~:

[)~~j¥~-+-

liij:ttrltrtt[tlJAir~riri1210 1 IF

i-i-

im.J~

~-4-

Random
by Addroul
by Addrout
by Addrout
bv Addrout
Unordered
load { Ordered
Add recordS {ADD only
only
Shaded columns
must be blank,

I~

1217 i IF
12181 IF
1219 I IF
1310 1 IF
13121 IF
13131 IF
l!,141 JF

13ti ~

~r-t~~-

I llliin

I~ Iliml

I---rrj'
l_l-_...L L

~~V,

~----l._.l--1-l-

1

1·. ,·,1

111&1710'T'

.1_1-.1- L-L-L.L..L_L_L_L_L

1 Sequential processing by key or limits must use the file index, which is always arranged in ascending sequence, When an indexed file

is processed record by record from beginning to end, the sequential-by-key method is used to process the file through the index,
21f chained files are pr~cessed by key, column 31 should contain an A; however, if chained files are processed by relative record number,
columns 31 and 32 must be blank,

File Description SpecitlcatlOns

"Tl

cEo
~
CII

F"e Type

F
f--

w

N
~

of Record Address Field

Record Address Type I...J

Device

Symbolic
Device

Number of Tracks

for Cylinder Overflow
i

Name of
Label Exit

File Format

0

Number of Extents

Tape
Rewind

Storage Index

~

Line

CII

~

Record
Length

cc

Type of

3:
l!

Processing

C.

III

.....
~

Consecutive

CII

::J

~
C
iii"

~

f
;Random

i

o

2

F

IIlp

t:"

o

:I

F

1:S

1=

I[)I lSI I<.
ni Sli<.
J;ln Tlc;lKJ

4

F

I:rT

rF

F

Ito

IF

o

6

F

1L) P

~

o

7

F

J~

F

IDI lslK!

o

8

F

IU ~

~

loll: lslKl

o

9

F

6y CHAIN

1 0

F

I1:Ir I··

1=

by CHAIN (deletecapable)

11

F

1 2

Fl.··•.·

by CHAIN

1 3

F

by CHAIN (deletecapable)

1

.,..

Cil
III

:J

Opt LOn

5

to end

r+

<

External Record Name

o

file is read
f rom b"
egm n"ng
I

4

F
Ff

1 5

Ii I ,........

ulc
LJlc
1

F

I='

•.••

1r::11 ~IK

Q

R·····

..

IRI
IR

.

111111lDlmK

1··· ___

llW~K

1 6

F
F

by Addrout

1 B

F

trl5 I.·

1 9

F

lulp

F

US

0

F

~lI 15IK

F

!D~ s~

{ The file is written
Load
on disk as entered
Add records {ADD only
only

20
12 1
12 2
12 3

II
11'

Ir

IQ
IQ

F

R

T

IT

~

011 IS~

InllISIKI
DtI I~:~

DtI s~

F
F
F

t-;14

F

I;t-

-~

;rs

RI

I~

It\I~tll.lNI ....

b'\\!.I'IIIt(II=:IyIBO RD

If KEYBORD is specified as a primary input file, no
other input files in the program can be specified as
primary or secondary files.

o

Input data entered from the KEYBORD device must be
defined in calculation specifications for a KEY operation .

•

No input specifications can be used for KEYBORD files.

~

c3

r - - - - 1;
Key ~ield ~

o

Tape

Storage Index

Option

Entry

10 11 12 13 14 15 16 17 18 19 70 21 22 23 24 25 16 27 28 29 30 31 32 33 34 35 36 37 3839 4041 42 4.1 44 45 46 47 4849 50 51 52 53 54 55 56 57 58 59

-l-----!-1

Number of Extents

f

~

Ul-~

~

60 61 62 63 64 65 66 67 ~ 69 70

2! 72l!.~

74

:
I IlR ,?If i
i It n I.·· . . /js: i
I
...
l
I
I
I

liP

!

1

I

It!

I

Ul·U8

'~

Continuation Lines

~

I

1

!

I

..... .....

1

I

1 •... 1 •.•.•.

1

1

~."

10 51

47 4 849

Cb'NI~b!u~

.'

C.ON~O'1

I·

2

6516,

606162

:....

II.·' CO~SIOI~

I •••

n

68697071

>

I. ........

.. .,.

7374

I·····

I

I····· )\

t

I ...... .

EcbwSidLI:

:

~.'7·

I

i

~

~

Entry

Option

K

LU

~

Z

:::>

1011121314 1516 17 18 19 20 21 22 23 24252627 28 29 30 3132 3334 35363738 39 4041 42 4344 45 46

i

I

Condition

-5

£>:

~ ~
2

w

o Overflow Indicator 8

Block
Length

o

Name of
Label Exit

Symbolic
Device

Device

...J

Organizat1on
Nor Additional Area

Number of Tracks
for Cylil1cier Overflow

.

<

....

It

>

1

'

1

: i

:

I

i

.

:

Shaded columns must be blank.

Input file records are displayed on the display screen when
keyed into the program.
Figure 3-27. CONSOLE Files

File Description Specifications
~----'-------------'---------------------'------------------''-----------'----------r'----------r---------r-------------.-,

File Type

F

----

Mode of Processi ng

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation
End of File

Record Address Type
Sequence

Filename

Type of File
Organization
Nor Additional Area

File Format

i

line

I

w

OJ

I ~~~.~

Symbolic
Device

Device

...J
LLJ

Number of Tracks
for CyliNter Overflow

Name of
Label Exit

Number of Extents
Tape
R . d

Storage

"0

~

Index

~::;: ~ ~ t'. "'~ i
, ,,:,::'"""'" ' ' ,"," ~
········1/ . P4¥ PR:l;N[lE!RJT 'I!'h! TIl lIlt!
i
:
I
Ii
I
1 I I!

~ ;~"~

1-"-r-"-r--'+"+'---"--"o..:..:'O:.,.':...:.',...:'~2
J 4 5 6 7 8 9
..:..:13:.,.':..::.4+,15 16 17 18 19 2021 22 2324252627 28 2930 31 3233 34!35 36 37 38 39 4041 4243444546 4748495051 52 53 54 55565758 59 6061 62636465 6667 6869 7071 72 73 74

2

F

!

1
1

0 3

F

i

1

0

l ! I ! O· r' ~. 'LL
II

j

iii

I

,I

I'

1-+-+-+-+--I--1---+-+-+-++ -+-t---t-t--t-+-+-!+-+II t-+---+-H'-H-+--1H-t-t-+i-+i~:-t-i-- i
0 4
i i
F
j j i i

,I
i

1

I

11!

I

i

J : l. ·re-IT I I

i

i

I ;

;

I

!

J L

I · ' I-C-'-

I

I

Shaded columns must be blank.
Figure 3-28. PRINTER Files

File Description Specifications
File Type

F

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

.-

End of File

Record Address Type

Filename

Sequence

Type of File
Organization
Nor Additional Area

File Format
line

Device
~

Symbolic
Device

Name of
Label Exit

Number of Tracks
for Cylil1cier Overflow
Number of Extents
Tape

~

Storage Index

o Overflow Indicator 8

BlOCk

Length

Record
Length

~

a:

:J

~~

~ ~

Condition

-5

~tea~t~~:'d .~
Location

UJ

Continuation lines

Z

Ul.~

~

Shaded columns must be blank.
Figure 3-29. CRT Files

3-62

File Description Specifications

/

'\

File Description Specifications·
File Type

F

-

Mode of Processi ng

File Addition/Unordered

Extent Exit
for DAM

Length of KeV Field or
of Record Address Field

File Designation
End of File

Record Address Type
Sequence

Filename

File Format
Line

Number of Extents
Tape

~

Storage Index

-tl

o Overflow Indicator 8

Block
Length

Condition

-5

f:

Record
Length

~ ~

~tea~t~~;'d .~

~ ~

o

Symbolic
Device

Device

Type of File
Organization
Nor Additional Area

Number of Tracks
for Cylinder Overflow

Name uf
Label Exit

Location:.u

Option

Ul~

Z

Continuation Lines

~

Entry

6

Shaded columns must be blank.
Figure 3-30. WORKSTN Files

Fi Ie Description Specifications
File Type

F
r---

File Addition/Unordered

Mode of Processi ng
Length of Key Field or
of Record Address Field

File Designation

Record Address Type
Sequence

Type of File
Organization
or Additional Area

w

(5 Overflow Indicator

8

File Format
N

Line

25

~

:3 u

~

5 6

0

§ ~

!
34

~
Vi

End of File

Filename

g~
7

8

9

Block
Length

0;;

w ~

IP

U:

o

2

o

3

F

l:S

F

o

4

F

I D

o

5

F

\A

F
F

o

6

F

Co
0
•.•.•. \ I··

o

7

F

o

8

F·••••• · ······1

o

9

F

1 0

F

i\ I·• •.·. Ii

S
a:-

a:

n

~

~

t::

e

!

...•............ t..
•i •••••

I(

I i i •••.••

. •. Ii

...

(I

x

1
... .. }I/
I

................

I

I .• . .....:...... .....:.: : ....
:

t l Al. ii./. 1\ •.• •. <)

SP lee ll~ L <
> •...•...• •·1> ····1> s,p EG tlA LI) 1\ 1
.•. . .... ... il<··/
? . .•. ........ 1<· .•. Iii

1

I

i

n

7374

I
;.

.

...•

•••••••••••
..

(

••

•

.....

i i ····1/
i·1 i i
••.•.

60 61 62 63 fl4 65 66 67 68697 071
....

s,e Cot AL Iii> 1\ •.• . (i
~ PiE Cot AI.. .·1···.· •.. 1·····1
SP 6(' lIlA \.. I> I . . . i:i iY I·• ·
···1

~

•. . <. \ i/ 1\ ii
i····. ( ........ ..........
...

.>
I)

..

I

I···· .•••.•.•. \

/> . . .
....... I

r-.......

?(

•

~

:J

i

.. ( I·

UH~

z

Entry

Option

K

(/ $pe
•••••••••

I

......

~

Continuation Lines

W

···.·.1·.·.

Tape

Condition

~

Key Field
Starting
Location

Number of Extents

Storage Index

23 24252627 2R 29 30 313233 34 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

F

F
F

Symbolic
Device

Device

Number of Tracks
for Cylinder Overflow

Name of
Label Exit

-.9

f:

~ ~

::;

1011121314 1516 1718 192021

F

Record
Length

..J

Extent Exit
for DAM

I

•.•..

.....

....

....
.

...

..

? 1\

....

....

••••••

.

...

.. •< < •.. •. •.
.•. > ........ )
....
.

•••••

Ii •..

}

....

<

I·.···}

I·.·.···

....

.
••••

I

Shaded columns must be blank.
Figure 3-31. SPECIAL Files

File Description Specifications
File Type

F
-

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation
End of File

Record Address Type
Sequence

Filename

Type of File
Organization
~or Additional Area

File Format
Line

"

!

Block
Length

j

5

~

Record
Length

Name of
Label Exit

Symbolic
Device

Device

W

Tape
Rewind

Storage Index

"0

~

a

a Overflow Indicator U
r--- §
~ t:
Key Field '§
~
Starting
~
~ ~
Location
W

Condition

a:

z

Continuation Lines

e

Option

0 2

~p

F

as CA

i

0 3

IS

F

6S (.A

• .• • i<

0 4

l:D

F

0 5

0

F

as GA
Os C.A

l

•••••••

I·····.
I··

I·•....

J

i.i . . . .

........

.......

.. :

.....

.....

r

..\ .>:.
.. .............

.......

....

i . ••.••. i

Ul·~

~

Entry

10 11 12 13 14 IS 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3132 3334 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 50 51 52 5 3 54 55 56 57 58 59

! !

Number of Extents

f:

..J

7

..J

Number of Tracks
for Cylinder Overflow

60 61 62 6364 65 66 67 6869 70 71 72 73 74

i
:
t •·• •·•
i 1< k<
·····.·Ii V.···· .
·····.·1;.

/1 Ii . • •.

0 6
0 7

Shaded columns must be blank.
Figure 3-32. BSCA Files

File Description Charts

3-63

File Description Specifications
File Type

F
-

File Addition/Unordered

Mode of Processing

Extent Exit
for DAM

length of Key Field or
of Record Address Field

File Designation
End of File

Record Address Type
Sequence

Filename

File Format

Line

o

iU5

~

-..

Block
Length

~w~~
3

4

5

6

a 2

F

a
a

3

F

4

F

7

8

9

6

F

a

8

Fl •. ·

a

9

F

1

a

F

(3 Overflow Indicator

8

s !::::
0:

e

~ ~

Number of Extents
Tape

~

Storage Index

Condition

-5
Key Field .~
Starting)(

Location

Option

W

Ul-'FL-

~

Continuation Lines

~

Entry

10 l' 12 13 14 15 16 11 18 19 2021 222324252627 28 2930 31 323334 35 36 37 38 3940414243444546 4748495051 52 53 54 55 56 57 58 59 6061 626364 65 66 67 68 697011 72 73 74

i12rl

.....

F

a

~

~

Record
length

Symbolic
Device

Device

Type of File
Organization
Nor Additional Area

Number of Tracks
for Cylinder Overflow

Name of
Label Exit

F

....

II

~
>

I

F

:

.

...

i····

SP':CII ~L

.:.

,~PE~I ~L

I

.•.

ISUI8~(Jll

..

I,.
1

I

•...••

.

I.·•.

F
F
ZL Lt O£ 69 89 £999 !i9 t9 £9 Z9 L9 0965 8S

is

gg 5S &>9 CS ZS LS

as

60' 8t Lt 9t

~t

»

£t I t Lt 0" 6£ 8£ l£ 9C ~£ i"£ ££ l£ t£

Figure 3·33. File Description Specifications for IBM·Supplied Subroutines

3-64

File Description Specifications

m:

6Z 8l II 9l Sl t l £l II Ll Ol 6L 8L iL 9L SL ,,' £L lL Lt Ot

6

8

i

9

S

t

£

l

L

Chapter 4. Extension Specifications

Record address files require entries in columns 11
through 26. Preexecution-time tables and arrays require
entries in columns 11 through 45. Compile-time tables
and arrays require entries in columns 19 through 45. If
an alternating table or array is specified with the table or
array described in columns 11 through 45 or 19 through
45, it must be described in columns 46 through 57 of
the same line. A maximum of 75 tables or arrays or
data structures can be used in a program; however, only
70 of these can be compile-time tables or arrays.

Extension specifications describe all-record address files,
compile-time or preexecution-time tables, and
compile-time, preexecution-time, or execution-time
arrays used in a program. Write these specifications on
the RPG Extension and Line Counter Specifications
sheet (Figure 4-1).

RPG

IBM

EXTENSION AND LINE COUNTER SPECIFICATIONS

GX21-9091 . UM/050'
Printed in U.S.A.

Internallonal Business Machmes Corporation

I--p_ro_g_ram_ _ _ _ _ _ _ _ _-.-_ _ _ _ _ _~I

IDat~

Programmer

f-;-~:-::-ic-+--t~t-+-+-+I-I--+~I

Punching

f

Instruction

Card Electro Number

1

I

Page

2

OJ

75 76 77 78 79 80

~~~;~I:ation I

01_

IIIIII

Extension Specifications

E

Record Sequence of the Chaining File
Number

.-,

Number of the Chaining Field

>-

5

6

7

8

9

t- - t- t- - -t-

.-+---+-+-+-1--+-+-+---+-4-1-~-

E
--1-

6

o

7

E

f- -f- f- - -

o

8

Entry

Per Table
or Array

-

-- -- --

r-f_ ~ -

f- - 1-1- --

.0

Table or
Array Name

0
~

Length

g~

0
~

01
Entry

(Alternating
Format)

a:

-

-1-1---1---

Comments

a:

~

~ ~

-f-I--f- f-

- -

-+-+-+--1--1-- - 1--- --1- -

-- -

&

---.

- f- -

-- -

--1-- r---r---- -

f-c------

- -- - -+-+--t-+--t-

-

----f- - 1--

-.-f_f_

-- 1- --1---1- -- -- - --- -I---I-I----r--- -

--1-1---1---1-----1-1-

-- - - - - - f - I -

1--1-1-1- -

-1- -

~I---

-

--- -

--- -. --.

f_ --

--l-l--+-+-I---+-4-l-f-+-+--+---i-I-·--f-f-I---l-f- ,- - -- - --- I- --

f_ -. -

-t---t-t-J-t-+---+-+-+---1--' ---

f_f-

_.+- --

-1-- - 1-- -

- I- -- - -

E
- -- -1--- -

-1-1-

-- - -

-- - I -

--1- - - 1-- - ---1'- - c-f_---

f-f-I--- - -

f-

-t-+-J-f---1--1-1-t- -- - --

--- - . -

t--J-t-t--t---I-+-+--l'--f- t-I--- 1--- -. '- -+-4-+-1-+--1- I o 4
E
f - f _ I - -- -+-t---+-+-+--1-1-+-+-1
.- I -

o

.,

Length
of

Entries

Record

1

5

of

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 11 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 41 48 49 ~o 51 52 53 54 55 56 57 ~ 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

o 2
E
1--+- - -I-J-+-t--t-+-·t-f--- f o 3
E
o

Number

Entries

Q:

~P-t--+-t-+--lf-t-t--

I--

of
Per

From Filename

~
o

Table or
Array Name

To Filename

Line

-.-

-

- -

-I--- - - .- ---I·-f-- .-- -

1- -

-t-

-

-,-I--

- -. --'-1- .--

"-I-~f_f_

---I-+-+--II--+-+--+-+-II-+-+-+---+-~

-- ---

-

--~

-- - - f _ --

---~f_

E
1---

1

-

-

-

-

--

--

-

.

-

-

~-

-

1- -

- -

1----'--

-I'

-

i---HI--+-++ 1-- - ---

-- - - -- -. --.- -- --1-------

Line Counter Specifications
10

L

~

1

]

Filename

u

1 1 1 1
(;

:::i

3

-

4

1 2
-

7

IlL
-I- - -

8

9

--'

:::i

--'

0

~
:::i

§

z

1
§
<5 z :::; 1 I ~

:::i

~

I1

.,
E
.3'2
~

J1

.c

:::i

~

.,

I~

~~

I1

Qi

:::i

1

<5

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

--1--+--+---+-+-1---1--+-+--1-+-

-f-----.-

- -

-

-

-

-_. --- -- -

- -

.,

-

12

1 ~6 1 1 ~ §
.c

~

5~

11

.J

:::;

J!

u z

:::i

~

I1

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

-

--

--

L

--I- ---

.----- -

1- -

f_f_

---

-

- -- - - - - I - . -

--

-+--+-+-+---1--+-+-1----1-+-1---1---1--+--1-4-+---1-··- - - -

- I--- - -- --

-f_

--'1-1-+-+--t-+-J

L

Figure 4-1. RPG Extension and Line Counter Specifications

Extension Specifications

4-1

Figure 4-6 at the end of this chapter shows possible
extension specifications. See Chapter 14, Tables and
Arrays for a complete discussion of tables and arrays.

COLUMNS 1-2 (PAGE)
See Common Entries in Chapter 1.

COLUMNS 3-5 (LINE)
See Common Entries in Chapter 1.

COLUMN 6 (FORM TYPE)
An E must appear in column 6 to identify this line as an
extension specifications statement.

When a table or array is loaded at compilation time, it is
compiled along with the source program and included in
the object program. Such a table file does not need to
be loaded separately every time the program is run.
Only those tables and arrays that contain constant data
should be compiled with the program.
When tables or arrays are compiled with the program,
table records must always follow the RPG II source
program. A record with **is (is = blank) in position~ 1
through 3 must separate the RPG II source program
from the table or array records. Tables or arrays must
be separated from each other by records with **is in
positions 1 through 3. Because **is in positions 1
through 3 indicates the start of a table or array, **lS
must not be specified in positions 1 through 3 of the
table input records.
Short tables (tables that contain blank entries) can be
compiled with the program, but a warning is issued.
See Columns 36-39 in this chapter for a discussion of
short tables.

COLUMNS 7-10
Columns 7 through 10 are not used. Leave them blank.

COLUMNS 11-18 (FROM FILENAME)
Entry

Blank

Explanation

Table or array is loaded at
compilation time if there is an
entry in columns 33 through 35.
Array is loaded at execution time
(via input and/or calculation
specifications) if there is no
entry in columns 33 through 35.

Record
address
filename

Name of the record address file.

Table or
array
filename

Name of the table or array file loaded
at preexecution time.

Use columns 11 through 18 to name a table file, array
file, or record address file. Filenames must begin in
column 11. The record address filename must always
be entered in these columns and also on the file
description specifications. The filename of every
preexecution-time table or array used in the program
must be entered in these columns. Leave columns 11
through 18 blank for compile-time tables or arrays and
for arrays loaded via input and / or calculation
specifications (execution-time arrays).

4-2

Extension Specifications

COLUMNS 19-26 (TO FILENAME)
Entry

Explanation

Name of
an input
or update
file

File processed via the record
address file named in
columns 11 through 18.

Name·of
an output
file

Output file to which a table or
array is to be written at end of job.

Use columns 19 through 26 to define the relationship
between a file named in these columns .and a file named
in columns 11 through 18. Filenames must begin in
column 19.
If a record address file is named in columns 11 through
18, the name of the input or update file that contains
the data records to be processed must be entered in
columns 19 through 26. Do not enter the record
address filename in these columns.
If a table or array is to be written at end of job (that is,
after LR processing), enter the filename of the output
file in columns 19 through 26. This output file must be
named previously in the file description specifications. A
table or array can be written to only one output device.
Leave columns 19 through 26 blank if the table or array
is not to be written.

If a table or array is assigned to an output file, it is
automatically written at the end of the execution-after
all other records are written. The table or array is
written in the same format in which it was entered.
Because there is no program control over the output
format when an entry is made in columns 19 through
26, those cases where formatting is required should be
provided for in the program through the output
specifications or by the EXCPT operation that writes one
item at a time (see Chapter 10, Operation Codes,
EXCPT). Tables or arrays should be written only after all
records are processed (last record indicator is on).

COLUMNS 27-32 (TABLE OR ARRAY NAME)
Entry

Explanation

Table or
array name

Name of table or array used
in the program

Use columns 27 through 32 to name the table or array.
No tv/O tables or arrays can have the same name. The
rules for forming table and array names are discussed in
the following text.

Table files are processed in the order they are specified
on the extension specifications. Therefore, if you have
more than one table file, the files are to be loaded in the
same order as they appear on the extension
specifications.
If two tables are in alternating format in one file, the
table whose entry appears first must be named in
columns 27 through 32. The second table is named in
columns 46 through 51 (Figure 4-2).

Array Name
Each array used in a program must be given a unique
name that does not begin with the letters TAB. The
name can be from 1 to 6 characters long and must
begin with an alphabetic character. This array name is
used throughout the program. The array name should
be used by itself only to reference the entire array. See
Array Name and Index in Chapter 14 for more
information on array names and on referencing array
entries.

COLUMNS 33-35 (NUMBER OF ENTRIES PER
RECORD)
Table Name
Every table used in your program must have a name
that begins with the letters TAB. The entire table name
can be from 3 to 6 characters long.
After the letters TAB, 1 to 3 alphabetic or numeric
characters can be used (no special characters are
allowed). Blanks cannot appear between characters in
the table name. Any name in columns 27 through 32
that does not begin with TAB is considered an array
name.
The table name entered in columns 27 through 32 is
used throughout the program. However, different
results can be obtained depending upon how the table
name is used. When the table name is used in factor 2
or the result field of the calculation specifications with a
LOKUP operation, the name refers to the entire table.
When the table name is used with any other operation
code, the name refers to the table entry last selected
from the table by a LOKUP operation (see Operation
Codes, LOKUP in Chapter 10 and Tables and Arrays in
Chapter 14).

Entry

Explanation

1-999

Number of table or array
entries in each table or
array input record

Use columns 33 through 35 to indicate the exact
number of table or array entries in each table or array
input record. The number must end in column 35. Every
table or. array input record except the last must contain
the same number of entries as indicated in columns 33
through 35. The last record can contain fewer entries
than indicated, but not more. Comments can be entered
on table input records in the positions following the
table entries.
.If two tables or arrays are in alternating format in one
file, each table or array input record must contain the
corresponding entries from each table or array. The
corresponding entries from the two tables or arrays are
considered one entry and must be on the same record ..

Columns 27-32 (Table or Arrayl\,larne)

4-3

Two tables (TABA and TABB) are described in alternating
format. An item for TABA appears first. Thus, TABA is
named in columns 27 through 32 of the extension specifications sheet (see Part 2 of this figure); TABB is named in
columns 46 through 51.
Table B
(amount due)

Table A
(account number)
1:.::

00126

56.751·1

03240

39.00

03648

156.72

15632

17.98

28887

2.97

29821

290.98

30001

579.95

- - - -Corresponding
table items

Note: The decimal points shown

~

in Table B are only for illustration
purposes. Decimal points are not
a part of table or array input data.

~

5

7

positions

positions

TABA

TABB

TABA

TABB

TABA

TABB

TABA

TABB

item

item

item

item

item

item

item

item

I

I

I

I

I

~~~~

Entry 1

Entry 2

Entry 3

Entry 4

TABA

TABB

TABA

TABB

TABA

TABB

item

item

item

item

item

item

I

,

I

•

.~~~
Entry 5
Entry 6
Entry 7

The corresponding items from the
tables are entered in the system
in alternating format. Corresponding
items from the two tables are con·
sidered as one entry.
Figure 4·2 (Part 1 of 2). Related Tables

(
\

4-4

Extension Specifications

Table entries for the two tables, A and B, are entered in
alternating format. A 1 and B 1, the corresponding items in
tables A and B, are considered one entry. Even though
14 table items are listed, there-are only seven table entries.
Extension Specifications

E

Rccord Sequence of the Chaining File

-

Number
of

Number of the Chaining Field

Line

!

Table or
Array Name

To Filename
From Filename

~
9

Entries
Per
Record

Number
of

Entries
Per Table
or Array

Length
of
Entry

Table or
Array Name

.9 CI

]~

~ ~ ~
~~ ~

(Alternating

Length
of
Entry

Comments
a:

~

Format)

1011121314 151617 18 19202122232425 26 ~1·28 ~.;.30·3' 32 33 34"3!) 36 31 38 39 40414243444& 46 4148 49"50 51525354 55 565758 59 60 6162636465666768 fig 70 71721374

~~r- E

ii:L

I

T~ A~ . . .

[,;rT -,

~ ~ -: TI~~B • .•

17

/,~~'vl>1 .~qI ~-:~-~~~1C~--

Table whose items are loaded first is named in
columns 27 through 32.

2 -t-+--+-+-+--+-+-'-+--+--t-t-+-+--t-+-+-+--l

-,_L : i

I

Table whose items are loaded second is named in
columns 46 through 51.
This entry indicates the number of table entries in
each input record. Remember, corresponding items
from the two tables are considered as one entry.

Figure 4-2 (Part 2 ot 2). Related Tables

When columns 27 through 32 contain an array name,
the following rules apply to the use of columns 11
through 18 and 33 through 35:
•

For a preexecution-time array, columns 11 through
18 must contain a filename and columns 33 through
35 must have· an entry.

•

For a compile-time array, columns 11 through 18
must be blank and columns 33 through 35 must have
an entry.

•

For an execution-time array, columns 11 through 18
and columns 33 through 35 must be blank.

COLUMNS 36-39 (NUMBER OF ENTRIES PER TABLE
OR ARRAY)
Entry

Explanation

1-9999

Maximum number of table or
array entries

Use columns 36 through 39 to indicate the maximum
number of entries that can be contained in the table or
array named in columns 27 through 32. This number
applies to one table or array or to two tables or arrays in
alternating format. The number entered must end in
column 39.
Because the number of entries for two tables or arrays
written in alternating format must be the same, the
number in these columns also gives the number of
entries in the second table or array specified in columns
46 through 51.

Columns 36-39 (Number of Entries Per Table or Array)

4-5

If the table or array is full, these columns give the exact
number of entries in it. However, if the table or array is
not full, these columns give the number of entries that
can be put into it (Figure 4-3). A table or array that is
not full is one that contains unused entries and is known
as a short table or array.
A compile-time table or array should be full. However,
if it is not full (a short table or array), the table or array
is compiled with the program and a warning is issued.
In storage, the unused entries in a short table or array
are filled with blanks or zeros (for alphameric or numeric
tables or arrays, respectively). Apreexecution-time table
or array need not be f u l l . '
.

COLUMNS 40-42 (LENGTH OF ENTRY)
Entry

Explanation

1-15

Length of a numeric entry

1-256

Length of an alphameric entry

Use columns 40 through 42 to specify the length of
each entry in the table or array named in columns 27
through 32. The number entered must end in column
42. For numeric tables or arrays in packed decimal
format, enter the zoned decimal length in columns 40
through 42. For numeric tables or arrays in binary
format, enter the number of digits required in storage
for the binary field. F.or a two-position binary field, the
entry in columns 40 through 42 is 4; for a four-position
binary field, the entry is 9.
All table or array entries must have the same number of
characters. It is almost impossible, however, for every
item to be the same length. Therefore, add leading
zeros for numeric entries and add blanks after
alphameric entries to make them the same length (see
. . . .'
Figure 4-4).
For compile-time arrays, the maximum length of an
alphameric entry is 96 because. the maximum length of a
record in the source program is 96 characters.
If two tables' or arrays are entered in. alternating format,
the specification in columns 40. through -;1-2 applies to
the table or array whose entry appears first in the record
(see Figure 4-5).
See Chapter 14, Tables and Arrays, for more
information.

4-6

Extension Specifications .

COLUMN 43 (PACKED OR BINARY FIELD)
Entry

Explanation

Blank

Data for table or array is in
zoned decimal format or is
alphameric.

p

Data for table or array is in
packed decimal format on disk.

B

Data for table or array is
in binary format on disk.

i

Use column 43 to indicate that a numeric field in a
preexecution-time table or array file is in packed or
binary format. Leave column 43 blank if the field is in
zoned decimal format. See Column 43 under Field
Description Entries in Chapter 7 for more information on
packed or binary format.

COLUMN 44 (DECIMAL POSITIONS)
Entry

Explanation

Blank

Alphameric table or array

0-9

Number of positions to the right
of the decimal in numeric table
or array items

Use column 44 to indicate the number of decimal
positions in a numeric table or array entry. Column 44
must always have an entry for a numeric table or array.
If the entries in:a table or array have no decimal
positions, enter a O.

\,

Note: The decimal points shown in these
tables are only for illustration purposes.
Decimal points are not part of table input
data.

TABPRT

TABAMT

TABPRT

TABAMT

(part number)

(price)

(part number)

(price)

001 ",
002
003
004
005
009
010
014
026
045
096
097
098
099

127.62
198.32
.27
.01
1.98
3.79
5.67
2.33
14.67
29.33
29.34
.05
.09
1.19

100
101
110

2.22
126.73
596.74
393.75
697.75
1.92

115
126
,137

127.62
198.32
.27
' .01
1.98

001
002
003
004
005

~ • I

If this qata is entered into
the system, TABPRT and
TABAMTwil1 be full (20
entries fill the tableL

If this data is entered into
the system, TABPRT and
TABAMT will not be full.

Extension Specifications

E

Record Sequence of the Chaining File
Number
of

Number of the Chaining Field

:~~~~ ~ame ~:tries

To Filename

Line

Record

From Filename

3

4

5

6

a

7

9

o 3,

E

~E

1'1

Entry

or Array

1

I
I

!

I

'":~11f'

li:;;i:'~

40

'EI

-H--~+--

, i

~~
a: -

g ,§

u

~

~

cS

~

Table' or
Array Name
(Alternating
Formatl

Length

Comments :

of

a:

Entry

~
..:

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

112 f'i211l1 L3
1<'

§ 0

Length
of

Per Table

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

0'1 E l l

~~- _E I

Number

~~tries

1 \

~

TIAIR'AI'I'l

~

2

7,0

71 72 73 7.

1
f

j~-r---+--,I-,r-,t-t--+-cl--'t--t-t---+-+-+-t
_

'-_

--.L.L_L-L-L-'--L-L-'--L-Lc...l-J

This entry indicates that TABPRT and TABAMT can
both have a maximum of 20 entries.
Figure 4·3. Table Entries (Number per Table)

Column 44 (Decimal Positions)

4·7

JANUARY
FEBRUARY
MARCH
APRIL
MAY
JUNE
JULY
AUGUST
SEPTEMBER
OCTOBER
NOVEMBER
DECEMBER

JANUARYbb
FEBRUARYb
MARCHbbbb
APRILbbbb
MAYbbbbbb
JUNEbbbbb
JULYbbbbb
AUGUSTbbb
SEPTEMBER
OCTOBERbb
NOVEMBERb
DECEMBERb

List of Months

All entries must
have the same
length. Those
items that are
not as long as
the longest
item must be
padded with
blanks (b).

TABMO

Figure 4·4. Length of Table Entries

COLUMN 45 (SEQUENCE)
Entry

Explanation

Blank

No particular order

A

Ascending order

D

Descending order

Use column 45 to describe the sequence (either
ascending or descending) of the data in a table or array
file.
When an entry is made in column 45, the table or array
is checked for the specified sequence. If a compile-time
table or array is out of sequence, a severe error occurs
and the program halts after compilation. If a
preexecution~time table or array is out of sequence, an
error occurs and the program halts immediately. The
program can be restarted from the point where it halted
if you do not want to correct the out-of-sequence
condition; however, if you do correct the
out-of-sequence condition, program execution must be
restarted from the beginning.
Ascending order means that the table or array entries
start with the lowest data entry (according to the
collating sequence) and proceed to the highest:
Descending order means that the table or array entries
start with the highest data entry and proceed to the
lowest.

4-8

Extension Specifications

If two tables or arrays are entered in alternating format,
the entry in column 45 applies to the table or array
containing the entry that appears first on the record.
When the LOKUP operation is used to search a table or
array for an entry to determine whether the entry is high
or low compared with the search word, the table or
array must be in either ascending or descending order.
See LOKUP in Chapter 10 for more information.
An execution-time array (built by input and/ or
calculation specifications) is not sequence checked.
However, an A or D entry must be specified if a high or
low LOKUP operation is performed.

COLUMNS 46-57
Entry

Explanation

Table or
array name

Name of the alternating
table or array

Use columns 46 through 57 only to describe a second
table or array that is entered in an alternating format
with the table or array specified in columns 27 through
32. All fields in this section have the same significance
and require the same entries as the fields with
corresponding titles in columns 27 through 45. See the
previous discussion on those columns for information
about correct specifications. Leave these columns blank
for a single table or array.

TABCOD
(code)

Two tables are entered in alternating format, TABCOD and
TABAMT. Each item in TABCOD is 3 characters long;
each item in TABAMT is 6 characters long. Since TABCOD
is entered in the system first, its length, 3, is specified in
columns 40 through 42. The length of items in TABAMT
is in columns 52 through 54.

TABAMT
(amount)
217.43
93.06
8.14
2166.58
39.23
1741.78
83.33
5.12
72.03
253.96

021
022
023
040
041
060
117
118
143
352

Note: The decimal points shown in these tables are only
for illustration purposes. Decimal points are not a part of
table input data.

~~

3

6

positions

positions

Extension Specifications

E

--

Record Sequence of the Chaining File
Number
Number of the Chaining Field

of

To Filename

Line

Table or
Array Name

From Filename

3

4

5

0 11

6

E

8

7

9

1

O~E
f-- ,

I

:

3i

E

I

i

E

0.4

Number
of

Length

Entries
Per Table

of
Entry

:5 0

~ ~

cf ";'

~ .1

or Array

l

Table or
Array Name

of

(Alternating

Entry

Length

Comments
a;

Format)

...J

~ ~ ~

al

"-

10 1112131415161718 19 20 21 22 23 24 25 26 27 28 29 30 31 32 333435 36 37 38 39 404t""2 4344 45 46 47 48 49 50 51 525354 555G 57 585960 61 62 6364 6566 67 68 69 70 71

1

0

Entries
Per
Record

I
,

I

I

1

1

II

I

!

i

I
I I

!!I

I
I

I

1

!
!

ill

mfJRJr ~

II! 1
L
11:
I

I

11~

I liJd

J~I

lR+1=ffirl
11
!-li-L
,-_u
I

,1 ...L.:-----:..'; 1 _\
, -"-__ _..1---1_
:

"

ITI~RA 'MIT I~
!

I

I I

2

I

!

! i
i

I

II

: ,I

1

!

I

!
i

r

; i

I

n
I

i

i

I

I

1

1

!

i

!

!

:

-~~;

73 74

I

The length of the table item that is first entered in the
system must appear in columns 40 through 42.
Figure 4-5. Length of Corresponding Table Items

Columns 46-57

4-9

COLUMNS 58-74 (COMMENTS)

COLUMNS 75-80 (PROGRAM IDENTIFICATION)

Columns 58 through 74 can be us~d for comments 'to
document the purpose of each' specification line.

See Common Entries in. Chapt~r 1.

/

Extension Specifications

E

Record Sequence of the Chaining File

-

Number
of

Number of the Chaining Field

Line

!
~

To Filename
From Filename

Table or
Array Name

Entries
Per

Record

Number
of
Entries
Per Table
or Array

• The shaded columns must be blank for the file
named.
• For tables and all arrays except execution-time arrays,
columns 19 through 26 are optional. For all tables
and arrays, columns 46 through 57 are optional.
• Execution-time arrays are loaded via input and/or
calculation specifications.
• For record address files, columns 11 through 26 must
have entries.
Figure 4-6. Possible File Entries for Extension Specifications

4-10

Extension Specifications

Length
of
Entry

.~

a:
-'

~

~
'E

"- 0

a

Table or
Array Name

g

(Alternating

~

i

Format)

Length
of
Entry

a
~

0

a:

~

~

~~~

Comments

Chapter 5. Line Counter Specifications

COLUMNS 1-2 (PAGE)

Line counter specifications indicate at what line overflow
occurs and the length of the form used in the printer.
Both of these entries must be specified on the RPG
Extension and Line Counter Specifications sheet (Figure
5-1). Line counter specifications should be used for
each printer file in your program. If no line counter
specifications exist, the form length used is the form
length specified on the PRINTER DCl statement. (See
the LINES parameter of the PRINTER DCl statement in
the System Support Reference Manual for a description
of the defaults for the form length.)

See Common Entries in Chapter 1.

COLUMNS 3-5 (LINE)
See Common Entries in Chapter 1.

COLUMN 6 (FORM TYPE)

In these instances, the overflow line is assumed to be six
lines less than the specified form length.

RPG

IBM

An l must appear in column 6 to identify this line as a
line counter specifications statement.

EXTENSION AND LINE COUNTER SPECIFICATIONS

GX21-9091 . UM/OSO·
Printed in U.S.A.

Inl!'rnatlOnal BuslIll:s) Machines Corporallon

----l1
I

rP_ro_gra_m_ _ _ _ _ _ _--,-_ _ _ _ _

f Date

Programmer

Punching

Instruction

+---+-III-----4--+II-+---I---1l1

f-G_ra_Ph;_C

Card Electro Number

I

1

Page

Punch

2

OJ

75 76 77 78 79 80

~~;~;~f:at;on I

of _

IIIIII

Extension Specifications

E

RI~l.:urd

S'·qUeIH.f' of

II.(~

Cil,IIIIIrHI

Fdr'

Number

r-

NlHlllJl'r

of

(ht.' CIl ..Jlnlll~J

rlf;id

Table or
Array Name

To Filenall~'-'
From Filename

o.5

o

Number

f..~lrles

of

Lenu th

Per

Entne ..

of

Record

Per Table

Entry

ur ArI:

j

...J

;£ c5

Reserved

~

10 11 12 1314 15 16 17 18 19 20 21 22 23 24 25 26 27 282930 31 32 3334 3536 3738 39 40 41 4243 44 45 4647 4849 50 51 52 53 54 5556 57 58 59 60 61 6263 64 65666768 69 7071 72 73 74

I-+-t-...Jf--.........,.-+--t-t-+--t---\-.. - r-- 0

0

" ~~

w

Vi
8

2

0

]

Remote
Dial Number

f-

~
3

2

[I] 0'_ ~~~~;~f~cation I I I I I I I

Remote Station

Filename

0-

75 76 77 78 79 80

Identification

I-

Line

U.S.A..

InternatIonal Business Machine Corporation

-++-H-+--+-+-+-+-+-I--+-+--+-II--+-l-+-H-+--+-H-++-+--+-++-H-+--+-+--t-i

-- -- ---f---- -- -- -- - -

-- --

---roo

--\--+-t---l--+-+-+-l--+-+-+---If--t--t--+-I-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-Ic-t---t-+--1t--t--t-+--+c-t--+--t--t--t----i

-- f -

r--- -

f-I-- -

- r- -- ------r-

T

1-- - t O 6

T
T

I-+-+-+-~--+--t-l-+---I-

o
0

8
9

- r-I-I- -

T

I-+-t-...Jf--.........,.-+--t-t-+-t--t--l----I-I- I-- 1

0

-- ---

T
-

r-- - - ;-- -1-- - ---\-+-+-+--t--'I---- r - - - -\---+--1I----1--+-+--+-+-t--I----I--\- -- - - r- -"---\-+-+-+-+-+--+--+-+-+-I-+-+-+-+-+-+-+-t---I

T

I-+-+-...Jf--I-+-+--t--t-+-t---t-t---t---i---t-+-- - r - - - 1- --1-- -1-- --T
1

2

T

t

3

T

1

5

T

1

6

T

1

8

T

r-r-- -r-- -

-

- -I-- --

-

-I-r- --

-t--t---i-t---t-I-t--+-t--t--t--t--I----I--t--t--t--t-+--t--t--t--t--t--t--f--...Jf--t---t-t---\--t--t-t--t--t--t-t--+-+--+

- r-

--1--

-- - I--

--t---t--I-+--t-- 1---

-

r--- -- - +-t--+--+--+--t-+-+-t----\--

T

T

1

9

T

2

0

T
T
T
T
T
T

Figure 6-1. RPG Telecommunications Specifications
Telecommunications Specifications

6-1

BSC is a flexible form of line control that provides a set·
of rules for communications between devices. For a
description of the basic characteristics and operational
concepts of BSC, a description of the RPG II interface
to BSC, and a complete description of RPG II data
communications programming, see the Data
Communications Reference Manual.
Note: Telecommunications specifications are used only
for RPG II data communications programming.
Telecommunications specifications are not used for the
Interactive Communications Feature (SSP-ICF).

COLUMN 16 (TYPE OF STATION)

Entry

Explanation'

T

This station transmits messages from
the file named in columns 7 through 14.
The file must be designated as an
output file on the file description
specifications and must be defined
on the output specifications.

R

This station receives messages in
the file named in columns 7 through
14. The file must be designated as
an input file on the file description
specifications and must be defined on
the input specifications.

COLUMNS 1-2 (PAGE)
See Common Entries in ·Chapter 1.

Note: This entry is independent of the entry in column

20.
COLUMNS 3-5 (LINE)
COLUMN 17 (TYPE OF CONTROL)

See Common Entries in Chapter 1.

COLUMN 6 (FORM TYPE)
A T must appear in column 6 to identify this line as a
telecommunications specifications statement.

COLUMNS 7-14 (FILENAME)

Entry

Explanation

Blank

Polling is not used.

T

This is a tributary station on
a multipoint network. Column 17
must contain a T if column 15
contains an M.

System/34 cannot be the control station.

Entry

Explanation

A valid
filename

Filename previously defined on the
file description specifications for
the BSCA device

COLUMN 18 (TYPE OF CODE)

Entry

Explanation

A or U

ASCII (formerly referred to as
USASCII) transmission control
characters are used. An A or U entry
causes the necessary file translation
to be done for System/34.

E or blank

EBCDIC transmission control characters
are used.

COLUMN 15 (CONFIGURATION)

Entry

Explanation

P or blank

This is a point-to-point
nonswitched network.

M

This is a multipoint network
where the control station selects
the tributary station through
polling or addressing. System/34 .
cannot be the control station.

S

This is a point-ta-point
switched network.

If this column contains an M, column
contain a T.

6-2

Telecommunications Specifications

17

must

ASCII and EBCDIC characters are listed in the Data
Communications Reference Manual.
If your BSC program halts because of an invalid ASCII
character in your data, check your data. and the ASCII
translation table.

(
'.

COLUMN 19

(T~ANSPARENCY)

Entry

Explanation

y

EBCDIC transparency is used. The
data being transferred can contain
transmission control characters
and/or pa~ked numeric or alphameric
characters~ Column 18 must be E or
blank.

N or blank

EBCDIC transparency is not used.
Zoned decimal numeric or alphameric
data is transmitted and received.
The data being transferred cannot
contain transmission characters.

COLUMN 20 (SWITCHED)

Entry

Explanation

Blank

This is not a switched network.

M

The operator using this program
makes the connection by dialing
the number (manual dial).

A

This program uses autoanswer.

B

This program uses manual answer.

Notes:
1. This entry is independent of the entry in column 16.
2. For a detailed explanation of how the initial line
connection is made, see Network Control in the Data
Communications Reference Manual.

COLUMNS 33-39 (IDENTIFICATION-THIS STATION)

Entry
. Alphameric
characters

The station identification referred to by the symbolic
name can be from 2 to 15 characters long, but it must
not contain a transmission control character.
The station identification is translated if the BSCA files
are translated.

COLUMN 40 (LOCATION OF
IDENTIFICATION-REMOTE STATION)

Entry

Explanation

Blank

This is a nonswitched or switched
network, and no identification is
used for the remote station.

S

This is a switched network. The
remote station's identification is
at the position specified by the
symbolic name in columns 41
through 47.

E

This is a switched network. The
entry in columns 41 through 47
is the remote station's
identification.

Columns 21 through 31 are not used. Leave them blank.

Entry

Explanation

Blank

This is a nonswitched or switched
network, and no identification is
used for this station.

S

This is a switched network. This
station's identification is at the
position specified by the symbolic
name in columns 33 through 39.

E

This is a switched network. The
entry in columns 33 through 39 is
this station's identification.

When column 32 contains an E, this
entry is the actual identification
sequence of this station (minimum of
2 characters). When column 32
contains an S, this entry is the
symbolic name of the location of this
station's identification.

If columns 33 through 39 contain a symbolic name, it
must not be an array name. If the BSCA file is a
primary or secondary file, the symbolic name must refer
to the first entry of a table (the table might have only
one entry) to ensure that the station identification is in .
storage before the communications line is open.

COLUMNS 21-31

COLUMN 32 (LOCATION OF IDENTIFICATION-THIS
STATION)

Explanation

Column 19 (Transparency)

6-3

COLUMNS 41-47 ""{IDENTIFICATION-REMOTE
STATION)

COLUMNS 53-54 (PERMANENT ERROR
INDICATOR)

Entry

Explanation

Entry

Explanation

Alphameric
characters

When column 40 contains an E, this
entry is the actual identification
sequence of the remote station
(minimum of 2 characters). When
column 40 contains an S, this entry
is the symbolic name of the
location of the remote station's
identification.

Blank

No permanent error indicator is
specified." If a permanent error
occurs, a system halt occurs and
the program cannot be restarted.

01-99,
L1-L9,
LR,
H1-H9

A permanent error indicator can be
specified for every BSCA file. If
there is more than one BSCA file,
each file can have a permanent error
indicator. The indicator does not have
to be unique for each file. Specifying
a permanent error indicator is
recommended when the system is
running in an unattended mode.

If columns 41 through 47 contain a symbolic name, it
must not be an array name. If the BSCA file is a
primary or secondary file, this symbolic name must refer
to the first entry in a table (the table might have only
one entry) to ensure that the station identification is in
storage before the communications line is open.
The station identification referred to by the symbolic
name can be from 2 to 15 characters long, but must not
contain a transmission control sequence character. The
station identification is translated if the BSCA files are
translated.
The identification received from the remote station is
compared with this entry. The session continues only if
the identification matches.

COLUMNS 48-51
Columns 48 through 51 are not used. Leave them blank.

COLUMN 52 (ITB)

Entry

Explanation

Blank

Intermediate block checking
is not used.
Intermediate block checking is used.

Use columns 53 and 54 to specify a permanent error
indicator for every BSCA file. When a permanent error
occurs, the specified error indicator and the
identification indicator of the record causing the error
turn on (however, no hardware diagnostics are
performed). The permanent error indicator can then be
used to condition the appropriate programming
response, such as printing a message or performing a
controlled cancel.
Do not attempt further transmission while the
permanent error indicator is on. This includes attempts
to transmit more than one record during detail, total, or
exception output. Further transmission can be prevented
if each record to be transmitted is conditioned with the
not-permanent-error indicator in columns 9 through 11
of the calculation specifications or columns 23 through
31 of the output specifications.
To retry an operation after a permanent error occurs,
turn off the permanent error indicator. The RPG II
program can then access the BSCA file on which the
error occurred. If an error occurs on the retried
operation, the permanent error indicator is turned on
again; otherwise, processing continues.

Intermediate block checking (lTB) can be used only if
the records are blocked. ITB and EBCDIC transparency
cannot both be specified for the same BSCA output file.

I

\
6-4

Telecommunications Specifications

Keep the following points in mind when retrying an
operation:
• The permanent error indicator is the only indication to
the RPG II program that an error occurred. A BSCA
information message describing the type pf error is
displayed. If a halt (H 1 through H9) is not issued as
part of the permanent error routine, the BSC,A
information message may not be presp.rved on the
display screen.
• Any data in the BSCA buffers at the time of an error
is lost. The record in your buffers is not the same as
the record in the BSCA buffers. Therefore, retrying
the last operation will still result in lost data.
• Switched lines are not disabled when an error occurs
unless a disconnect sequence is received or the
hardware detects disconnect.
• Any data transmitted while the permanent error
indicator is on is invalid. Unless your program is
designed to recognize all data, the error condition can
cause an unidentified record halt.
• A limit should be imposed by the RPG II program on
the number of times an error can occur before the
program is stopped.

Note: Avoid using H 1 through H9 as permanent error
indicators if you are going to condition operations on the
permanent error indicator being off. Because Hl
through H9 are reset at the end of the detail· logic cycle,
they can be set off before the program cycle in which
the error occurred is completed. If Hl through H9 is
used as a permanent error indicator, the H 1 through H9
display can preempt the system halt display. If the Hl
through H9 display appears before the system display,
the operator should take the 0 option to prompt the
system halt display.

COLUMNS 55-57 (WAIT TIME)

Entry

Explanation

Blank

The system convention for time-out,
180 seconds, is used.

Numeric

The length in time in seconds,
to 999, that BSC waits with no
messages being sent or received
before a permanent error occurs.

A permanent error indication is recognized by the
system whenever the wait time on an idle line elapses.
Therefore, when determining the wait time, consider the
time the operator might require to respond to halts and
other processing interruptions, and also time the
program might require for special operations such as
table searches and computing square roots.
The wait time limit specified applies only to delays
caused by the System/34 program and does not apply
to the remote device. In addition, the time limit applies
only during the transmission or reception of a file, not
between file transmissions. The occurrence of a
permanent error indicates the end of processing of a
file, but not the end of file.

COLUMNS 58-59 (RECORD AVAILABLE
INDICATOR)

Entry

Explanation

01-99,
L1-L9,
LR,
Hl-H9

A record available indicator should
be specified if a reverse interrupt
(RVI is to be received. See Device
Dependent Considerations in the
Data Communications Reference
Manual for examples of using a'
record available indicator. This
indicator turns on whenever a
reverse interrupt (RVI) is received.

Columns 55-57 (Wait Time)

6-5

COLUMN 60 (LAST FILE)
Entry

Explanation

Blank

This BSCA file may not be
the last input file processed.

L

This BSCA fiie is processed
only after all other input
files are processed.

The entry in column 60 does not affect demand files.

COLUMNS 61-62 (POLLING CHARACTERS)
Entry

Explanation

Blank

This station is not transmitting on
a multipoint network.

Alphameric
characters

The polling identification of this
station is required if this station
is part of a multipoint network and
the BSCA file is a transmit (output)
file. Polling and addressing characters
must be used in pairs as listed in the
Data Communications Reference Manual.

COLUMNS 63-64 (ADDRESSING CHARACTERS)
Entry

Explanation

Blank

This station is not receiving on a
multipoint network.

Alphameric
character

The addressing identification of this
station is required if this station is
part of a multipoint network and the
BSCA file is a receive (input) file.
Polling and addressing characters must
be used in pairs as listed in the Data
Communications Reference Manual.

Enter polling and addressing characters in EBCDIC; the
compiler converts the characters to the form required by
the code specified in column 18. (If ASCII was
specified, enter uppercase addressing characters; they
are converted to lowercase ASCII characters.) See
Polling and Addressing Characters in the Data
Communications Reference Manual.

6-6

Telecommunications Specifications

COLUMNS 65-74
Columns 65 through 74 are not used. Leave them blank.

COLUMNS 75-80 (PROGRAM IDENTIFICATION)
See Common Entries in Chapter 1.

FILE DESCRIPTION SPECIFICATIONS FOR BSCA
FILES
The following entries are used on the file description
specifications to define a BSCA file. Entries for the
columns not listed are described in Chapter 3, File
Description Specifications.
The only other specification sheet affected by a BSCA
file is the control specifications. Because a BSC
program must not be interrupted, a B must not be
entered in column 37 of the control specifications.

Columns 7-14 (Filename)

Enter the name of the BSCA file. The same filename
must be used on the telecommunications specifications.
Note: Look-ahead fields must not be specified for a
BSCA file.

Column .15 (File Type)
Entry

Explanation

This is an input (receive) file.

o

This is an output (transmit) file.

/
I

\

Column 16 (File Designation)

Columns 20-23 (Block Length)

The entries for this column are the same as those
described in Chapter 3 except that:

Enter the size of the blocks of data processed by BSC.
The block length must be a multiple of the record
length. The maximum block length is 4,075 bytes.

• D (demand file) is the required entry for transmit
interspersed with receive. BSCA files should also be
designated as demand files for any receiving program
that does not address the BSCA files immediately.
For example, if the BSCA file is defined as a
secondary file, the communications line opens as
soon as the program begins. This means that your
wait time might elapse before you are ready to
process the BSCA file. If the BSCA file is defined as
a demand file, however, the line opens once the
program is ready to receive the first record from the
BSCA file.
• R (record address file) is an invalid entry. A BSCA
file cannot be a record address file.

Column 17 (End of File)

Enter an E if end of file on the input (receive) file is to
determine end of job. The BSCA input file might be the
only file with an E in column 17. However, if any other
input file has an E in column 17, all BSCA input files
should also have an E in column 17. This E is not
necessary for the BSCA files; but when it is not
specified and end of file is reached on another input file,
the BSCA files close and the system on the other end
of the communications line has no indication of what
has happened. When an E is specified for the BSCA
files, all systems can come to a successful end of job.

Columns 24-27 (Record Length)

Enter the length of the BSCA records, right-justified. If
the record length is not specified, it defaults to the
maximum record length, which is 4,075 bytes.
If a record that has data of 0 length is received, it is
ignored unless 3740 mode is used, in which case it is
considered a file separat·)r. If your program receives a
record that has a length greater than 0 but shorter than
the record size specified, the remainder of the record
contains unpredictable characters.

Column 32 (File Organization or Addition I/O Area)

Assign dual input/output areas in this column. Any
number, 1 through 9, assigns two input/output areas. If
this column is blank, only one input/output area is
assigned and throughput is decreased accordingly.

Columns 40-46 (Device)
Entry

Explanation

BSCA

This is the device entry for BSCA files.

For data communications programming considerations,
see the Data Communications Reference Manual.

Column 19 (File Format)

Enter an F (fixed length) for BSCA files.

File Description Specifications for BSCA Files

6-7

6-8

Telecommunications. Specifications

Chapter 7. Input Specifications

Input specifications describe the data files, records, and
fields of the records used in the program. All input files
are described on the input specifications except files
assigned to the device KEYBORD, record address files,
addrout files, and table files. KEYBORD files are
described on the calculation specifications when the
KEY operation code is used. Record address files,
add rout files, and table files are described on the
extension specifications.

The input specifications are divided into two categories:
• File and record-type identification entries (columns 7
through 42) describe the input record and its
relationship to other records in the file.
Field description entries (columns 43 through 74)
describe the fields in the records. These
specifications must start on the line below the file
and record-type identification specifications.
Write these specifications on the RPG Input
Specifications sheet (see Figure 7-1).

----------------------------------------------.----------------------------------------RPG INPUT SPECIFICATIONS
IBM

Inlernatlonal BUSiness Machines

1
Program

Page

Date

Programmer

Record Identification Codes

I
Vl

0

;:
;;;
0

;E

Position

From

Position

~
3

4

5

6

0 2

I

0 3

I
I

o
o

5

I

6

I

o

7

I

o

B

I

o

91

1 0

I

75 76 77 7B 79 SO

Field
Indicators

~
.~

Field Name

~

°

.;:
0

:9.t;

~

]
°
g .£ gt ~
Oi
~~
::;;u
u::
8
.!?"ii

'0

u..~

Zero
Plus Minus or

Blank

'0

7

I 1."';-;"";""';-;"";"-+ File

4

To

0

0 1

o

2

[I] 0'_ ~~~;~':ation I I I I I I I

Field Location

o

Filename

Line

GX21·9094· U/M050'
Printed in U.S.A.

Cor~ofatlon

and Record Identification..;.....;--r-';-;'-;-;--;'+-I

I
I

11

I

1 2

I

1 3
1 4
1 5

I

1 6

I

7

I

1 B

I

,

9

I

2 0

I

,

-4-

!

I
I

I

I
I
I
Zl LL Ot 69 89 £9 99 59 t9 £9 Z9 L9 09 65

as

£5 9S SCi K

eli

Z5 15 OC;; 6.,. 8" L'" 9" 5t " ..

tt Zt u, 0 .. 6£ 8C It

9[

5£ lrt ££ lC U: OC 6Z 8l iZ 9Z 5Z tZ CZ ZZ LZ OZ 6' 8' II 9' 5' .. L t l lL U 0'

6

8

L

9

S

t

t

z ,

Figure 7-1. RPG Input Specifications

Input Specifications

7-1

File and Record..:Type Identification
Entries
COLUMNS 1-2 (PAGE)

COLUMNS 15-16 (SEQUENCE)
Entry

Explanation

Any two
alphabetic
characters

Program does not check for special
sequence. Alphabetic characters must
be used for chain~d files, demand
files (except, CONSOLE demand files),
WORKSTN files, and look-ahead
records.

01-99

Program checks for special sequence.

See Common Entries in Chapter 1.

COLUMNS 3-5 (LINE)
See Common Entries in Chapter 1.

COLUMN 6 (FORM TYPE)
An I must appear in column 6 to identify'this line as an '
input specifications statement.

COLUMNS 7-14 (FILENAME)
Entry

Explanation

A valid
filename
or data
structure
name

Same filename that appears on the
file description specifications
for the input file or the name
of a data structure;

If a data structure is specified (DS in columns 19 and
20), columns 7 through 14 can contain:
• Blanks
• A name up to 6 characters long
• A name previously referenced in columns 53 through
58 of the input specifications
Data structure entries must be the last entries on the
input specifications.

COLUMNS 14-16
Entry

Explanation

AND or OR

AND/OR indicates a relationship
between record identifying indicators
or record types. The entry must
begin in column 14.

See Columns 21-41 (Record Identification Codes) and
Columns 53-58 (Field Name) in this chapter for more
information on AND/OR relationship.

7-2

Input Specifications

Use a numeric entry (01 through 99) in columns 15 and
16 to assign a special sequence to different record types
in a file. The first sequence number ,must be .01. Gaps
in sequence numbers are allowed, but the numbers must
be in ascending order.
If the types of records do not need to be in any special
order, use two alphabetic characters (see Figure 7-2).
Within one file, all record types having alphabetic entries
in columns 15 and 16 must be described before those
types with numeric entries.

Assigning Sequence Numbers
Enter a numeric character in columns 15 and 16 if one
record type (identified by a record identification code)
must be read before another record type in a sequenced
group. To specify sequence checking, 'each record type
must have a record identification code, and the record
types must be numbered in the order they should
appear. The program checks this order as the records
are read (see Figure 7-3). If a record type is out of
sequence, the program stops. The operator can restart
the program by selecting the appropriate option and
pressing an entry function key. The program bypasses
the record that caused the halt and reads the next
record from the same file.
Sequence numbers ensure only that all records of the
lowest record type precede the records of the next
highest record type; The sequence numbers do not
ensure that records within a record type are in any
certain order. Sequence riumbers are unrelated to
control levels and do not provide for checking data in
.fields of a record for a special sequence (see Figure
7-4). Use columns 61 and 62 to indicate that data in
fields of a record be checked for a special sequence.
Records in an OR or AND line' cannot have a sequence
entry in these columns. The entry in columns 15 and 16
on the previous line also applies to the OR or AND line.
See Columns 53-58 (Field Name) in this chapter for
information on OR relationships.

Record Identification Codes

I

t---Filcnamc

line

Position

o R
I- - I AND

I Item Number (BC)
0

1

5

6

I

0 3

I

0 4

I

o
o

I

G

I

0 7

I

o

I

8

8

IIW~

0 2

5

7

0 9

I

1 0

I

1 1

I

2"

0

~

~ B~
z u u

.-I--r4

3

fr
cJ!l

3

2

1

Position

~§J
zuu

Position

9 10 11 12 13 1415 16 17 18 19 20 21 22 23 24 2526 27 28 29 3031 3233 34 35 36 37 38

10..

hi'

~

AA

~11

l1

~IP

~t r--~12

11

~l

t-r-r-r-

File RECORDA has two types of records (part number and
item number) that can appear in any order. Because they
are not to be checked for sequencing, they are assigned 2
alphabetic characters in columns 15 and 16 (AA and BC,
respectively) instead of numbers.
Figure 7-2. Unsequenced Record Types in a File

C:olumns 15-16 (Sequence)

7-3

Item Number (07)
City/State

(03)
(02)

(01 )

-
~

Entry

Option

K

18 19 20 21 22 23 24252677 28 29 30 3137 3334 35363138 39 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

FS'EC b Nl)1rill ~-J: F I qib

01 1
0131
2

Number of Extents

o Overflow Indicator 8

e

Vi

Symbolic
Device

Device

...J

Number of Tracks
for Cylinder Overflow

Name of
Label Exit

primary file record. The 6 indicates an unmatched
record in the primary file.
Because the primary file record is processed first when it
matches a secondary file record, the information from
the secondary file can be made available only by a lookahead field.

Input Specifications
Record Identification Codes

I

~

~

Filename

Line
~

0-

cJl

~

~

.--1--.--

~~fA N a

3

4

a

1

IP

a

2

I

0

3

I

5

6

7

8

9

4

I~,",

a

5

I

a

6

I

I

!

I

9

Z

0

-0

Position

-c.

~
]

.!!:!w

~

]

0

8

-5

0

Field Name

'0;

0:;

0

a::

Position

~ o u
'0 B j

Z

~~ ~

Position

~u6

u u

Z

From

1ji

~Cl
o~
u

To

.~

0
0

:9-0 ~-c
u.u: 0
.S ~ ~
:~

-c

:Ou

u:

~~

Zero
Plus Minus or
Blank

0:;

10 11 12 13 1415 1617 18 19 20 21 22 23 24 2526 27 28 29 3031 32 33 34 35 36 37 38 39 40 4142 43 44 45 4641 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 6768 69 70 71 72 73 74

_I- 1"

~~

I;

tf.tZ rJ~ MiEl1
[tq M~ TCH

li
1ll

~l2

I. 4"1

1.~

If.

"'(:::" ..",

Ii

~~LI
8 i

II

Rl MA Rrf AlA

a

a
a

g ::>. ~~
~ 0

:::6

Field
Indicators

Field Location
3

2

1

IAI'

.:•..•.. ~~
~"

1\ I i i
Ii Ii Iii Li<

y./

lAllA UI:I"f

[til ~A TI'IH

1~

':,:'.':"".,.,

1ai[1
~11

11 ltd IAl XT~ ~IM \,1
Iii IJli 1.\
I::'::,.

Look-ahead field (field from secondary file records
needed in primary file records).

Output Specifications

o

Space

I--Filename

Line

~~

f-

">

4

a

1

5

6

a

And

E L

"Afol-o

j
3

I

.E !!:!

i'R
>~ ~~

f-

Cl

~~fA N a

~

L

°pIRlf.1ARIY

Z

3

0

0
I--I-+---l---f-l---+-+--· f-+-

Z

in

~~~~~

'AUTO

29:

~
~liINN!D

to Print

Ves
Ves
No
No

Ves
No
Ves
No

No Sign

CR
A
B
C

a

J
K
L
M

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

a:

g

Constant or Edit Word

Q:
1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 '

'3Q ;11 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 51 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

r""" 1':":',1.';'::

f-~

Zero Balances

Commas

Position

,

a

a
a

Field Name

0

Z

9 10 11 12 13 14 15 16 17 12 19 20 21 27

2
0
f------- +-I---f-+---+.--f-+-+

>

Output Indicators

Skip

w"-

,NIX

TrJA.,

1!fiG I

. f- ~f--f----I----I--l---+--l---I-j--l---~-+-+--I-.-+-+---+-+--l---+----l

.c-c

4

f- f- f- f-.

f-.

/
Place the look-ahead field from secondary records into
positions 31 through 40 of the primary record if the two
records match.

Place a 6 in position 1 of the primary, record if the
record matches no secondary record.

Figure 7-7. Look-ahead Fields
Columns 19-20 (Record Identifying Indicator, **, OS)

7-11

SECONDARY FI LE

PRIMARY FI LE

2

CD Read first reco'rd
from primary file.

(P2)

(P3)

(P4)

3

2
(S2)

(P5)

(S3)

(S4)

(S5)

r;.t~field nf-' ------Matc~e~
J--'
-l
""n

I ' Area into which records

I

I

I

I

I
I

""

~

~

CD

I

Read first record
from secondary file.

are read (read area).

r-----------------,

I

I
I

L_. ________________

2

CD

Read second record

(P3)

2
(P4)

I
I

(S2)

(P5)

't

1----CD Select first record
from primary file
for processing.

I

(S3)

I

(S1)

Ld
(P1)

7-12

Input Specifications

I
I

---1
I

L _________________

Figure 7-8 (Part 1 of 2). Available Records: Two Input Files

(S4)

(S5)

--I

LJ

~
(P2)

~

3

from~mary:._I--- _______
I

I

Area into which selected
records are placed for
processing (process area).

II
~

Read Area

Process Area

CD

Read third record
from primary file.

2
(P4)

(52)

(P5)

2
(53)

(54)

(55)

Read Area

CD

Select second record
Process Area

Processed Records

~
2

3

(P4)

2

2

(P5)

(53)

Inn

3

(54)

CD

, -- - - - - - - - - - - - - - - -/- - - I

:

~

(55)

I

~:

Read second record
from secondary file.

Read Area

~-------------- ~~ - - - -- - ~ CD Select first record from

I
II
I

L __ - - - - -

~

~-

I

II

(51 )

----l------ _____

I
.J

secondary file for processing.

Process Area

r;--,

I1

I

, Records Being
Processed

I (P2) I

~-~

r.;---,
I1

I

I (P1) I
L.,;_~

Processed Records

P1
P2

S1

Records Available For
Look-Ahead
P2 and S1
P3 and S1
P3 and S2

Figure 7·8 (Part 2 of 2). Available Records: Two Input Files
Columns 19-20 (Record Identifying Indicator, **, DS)

7-13

UPDATE FI LE (Primary File)

CD

1

Read first
record from
update file.

-

3

223
(S3)

(S4)

(S5)

CD Read first record

-

-

-

-

-

-

-

Match

~n

Ud

1

(S2)

(U5)

(U4)

(U3)

(U2)

t

~atc~ield 1

2

2

SECONDARY FI LE

J
'" n

f~

-

from secondary file.

-

1

-

1 Area into which records

W

I
I
I
I
r---------------------~

are read (read area).

I

I
I
I

L_____________________

1

2
(U2)

(U3)

2

3

(U4) (U5)

(S2)

I
~

2

2

1

Area into which records
are selected for processing
(process area).

(S3)

3
(S4)

(S5)

,-----------'--------1

I

I~

I
I

(uff

Cd·
(Sl)

~

1--- - - -I
I

I
I

CD

Select first record
from update file
for processing.

CJ

I

Read Area

I Record Ul has r:'0ved into the pr~ces.s
I area, but a data Image of Ul remains In

- - - - - - ---- -----1
1

(Ul)

I

the read area until U2 is read in. U2 is
not read in until Ul is,compl~t~ly processed. Therefore, while Ul IS

I

L ______________________ J Process Area

Figure 7-9 (Part 1 of 3). Available Records: One Input File, One Update File

7-14

I nput Specifications

In

the

I process area, records available for lookI ahead are Sl and Ul (the data image).

CD Read second record

2

2

3

,

2

(U3)

(U4)

(U5)

(S2)

(S3)

from update file., _ '--- _ _~ _ _ _ _ _ _ _ _ _ _ _ _ _ _

1

I

I:u~)1

2

3

(S4)

(S5)

I

GJ

Read Area
I

I

r----------------------j

I

I

I
I
I

I
I
I

Process Area

L __________ ~---------~
r,-l
II

I

Processed Records

(U1)1

~-~

2

2

3

1

2

2

3

(U3)

(U4)

(U5)

(S2)

(S3)

(S4)

(S5)

·----------------------1
I

I

I
CD Select second
record from
update file
for processing.

III

~

~

I

I

~:

Read Area

!------~------------1
r-l

I

Process Area

~

:

IL _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J

r,-"

I
I
I (Ul)1

Processed Records

L_.J
Figure 7·9 (Part 2 of 3). Available Records: One Input File, One Update File

Columns 19-20 (Record Identifying Indicator, **, DS)

7-15

CD

Read third record
from update file.

(U4)

(U5)

(S3)

(S4)

-I----,
Inn
:
1 __ - - / - - - - - - - - -

I
I

~

CD

(S5)

~:~::~~~~arr:C~;~~.

Read Area

~

I
I

W

r----------------------~

II

I

II CD

(S 1)

:

L _____________________ J

Select first record from
secondary fi Ie for

process; ng.
Process Area

r,-,
I

I

~~2~

Processed Records

rT-l

I

I

I

(U1)1

Records Being
Processed

Records Available For
Look-Ahead

~_:..:.J

U1
U2
S1
Figure 7·9 (Part 3 of 3). Available Records: One Input File, One Update File

7-16

Input Specifications

U1 and S1
U2 and S1
U3 and S2

Data Structures

A data structure can be used to:
• Define the same internal area multiple times using
different data formats (see Figure 7 -10).
• Subdivide a field so that either the entire field or its
subfields can be referenced (see Figure 7-11).
• Group fields for easier reference (see Figure 7 -12).
To specify a data structure, make the following entries
(the columns not mentioned must be blank):
• Column 6: I.
• Columns 7-14: The name (maximum of 6 characters)
of the data structure, which is optional. If specified,
the name must meet the requirements of a !ield
name. The data structure name can be referenced (1)
as a field only on the input or output specifications,
(2) as an RLABL, or (3) as a SAVDS or INFDS name
in columns 60 through 65 of the file description
specifications continuation lines for a WORKSTN file
(see Chapter 13, WORKS TN File Considerations and
Sample Programs, for more information on SAVDS or
INFDS).
• Column 18: U, if this data structure is to be used as
a display station local data area.
• Columns 19-20: DS, which identifies this as a data
structure.
• . Columns 75-80: Program identification.

Remember that data structure entries must be the last
entries on the input specifications.
Figure 7-13 shows some common uses of a data
structure.

Columns 19-20 (Record Identifying Indicator, **, DS)

7.-17

Input Specifications

I

Record Identification Codes
3

Filename

Line

Position

'o~r4

o

1

5

I~ ~LlE

6

1

8

9

o

2

I

o

3

I'll

o
o

4

I

5

Irt'
I

~ ~

K

REe.

(6

IJotA ~I='

~

6
7

11*

o
o

8

I

9

I~ ~~ 111J:1~

1 1

I

1 2

I

1 3

I

I

I

,

IRA ~~ FER

o

I

~
b

e

~

Position

~ ~

z u u

~o
o~
z u

til

41 CS
'11 CP

[q~

C!R

Iq~

CC

1 6

qJ, C[

~12.

CF

I~IE clo RID, 1r:IT 11=11

I

1 8

I

-

_

-

1 9

I
I

2

1

I

+

I
I

2 4

I~ rt'R ~N gf,

2 5

I

2

6

I

2 7

I

2 8

I
I

3 0

I

3

I

1

--1-- f--f-- t-- f - f - f-t--

- r- t-t-t- -

1--1--

ER

H's-

,R.

4

rrlR EC

1312 lslRI... II; Co

1£'1 IIHIl IYo.

12

~IL ILl

ll'i~1l

Elc
-t t- a- ~15IE: IPI~
ITNw-.
P
lAIR
~r- lJ2 ~~ TI'( olH
g 117IIIG trrt' OIR~
12r3 I~ eolstr
11

!2R OR ])~ Ire
I~~ "IA NT ~ur:

l3lCl

~T Ie, 'h'~

irA .Elr.

(U~

11

11

i"'l

~~

I

-

lUI I

-

tt

f-

f--~-

-~-I

PR EC

12'b ~U Nil ~Ic

~

2 2
2 3

9

r,,~

-

3

q
16 t'A Rtf I~~

i_il1

--f-- - f-f--

~,-

--

~_t tif~
t_llL!

-t-

-

~11

-

'f

-f--

2 0

Plus Minus or

Blank

--

Il'l~

I~ PU ~c. AS ~Ef- ,RE ~O 1~ID Ic:ll Ita

17

To

312 SR IEIc.

L

-I

1 5

From

!! i

--4

Zero

0;

Position

10 11 12 13 14 15 16 17 18 19 20 21222324 2526 21 28 29 30 31 3233 34 35 36 31 38 39 40 41 42 43 44 45 4647 48 49 50 51 52 53 54 55 56 51 58
59 60 61 62 63 64 65 66 6168 69 70 11 72 13 14

o

1 0

~o e ~

z u u

r;'No
3

Field Name

Ii:

~

2

Field
Indicators

Field Location
2

1

I---

- f- -

.

--- -- -

-

~
.L

4

12~
l~~

Irp ,Kiln
... 1I...
lUi Illl~

--

,-

'n OJ

I-Ir

KlQ "
it'11 ~~~

--

Data Structure

~
/

/
/ /

I I
III
/~~--------~------~--------3~0~2~~--\'

10

\"

\

/

20

... /3

/'

""

\ ", , / /

./'

I<-/_ _ _ _ _ _~\r-----'~----'I/
-

SREC

\

",
\J"
PREC

35

40,,-

\

\

"

\\
\

\J

",

, "'I~____________________________________________
" "~,I

Figure 7·10. Using a Data Structure to Redefine the Same Internal Area Multiple Times

Input Specifications

"'"

TREC

7·18

'" "

Input Specifications
Record Identification Codes

I

-

,

Field
Indicators

Field Location

2

3

Ul

o

Filename

Line

Field Name

~

Zero
Plus Minus or
Blank

0;

:

Position

Position

Position

j§Jji

'Or;rr;rr;fo
3

4

5

6

7

B 9

I l1 C.A

rnI I I
:

!

, ;

1

I

I

I

•

,!~~--+-+,P!..,!-Af~R¥rr~N1=OI--+-+_f-+++-+--+-I-+-+-++-+-t-l
''<;!'''J
NAM'E
I
!
~ Q: pAJ I N0

~ 11

~j

toR

II~~~

!

r-+-+I-t--+-+-++-,-t--,:-,+-+-+--1-+-1---+-++-+-~-+-I-+-++I+-+--H-I-t--+-...;!!!!~ '(Jl

1

-;151 I

I

2. ~~

l I
, I

I 1

I
013' I
o 14 ' I

To

10 11 12 13 14 15 16 17 18 1920 21 22 23 24 25 2627 2829 3031 32 33 34 35 363738 3940414243 44454647 48 495051 52 53 54 555657 58 59 6061 62 636465666768 6970 71 72 73 74

01' I II!~~iIN

~!

From

1

~ 1I 1 :

i

6

1 IIPAM}tCLLt--+--+_r---t-D_?I-'-l!'1-l..-+-+-+-++++--I-+-1-I-f-H-H-4-1-++-++-H-H--+I-:--H_;"!++++++-++-t--H-t-t-r--t-t--t-I--t-t-i
01 7 I I ~ , : , I i i
I l1
A IMF!G
I
I

o1

1

I

_r-~~~~I-~-I-4-+-+4~~~,+,4--~-I--~+-:~I-~~~-+~~~-r+l~r+~I~~I~~ft'LI,~'ilftlq~~-r~-r+i-r+~-~
o :8 I
I : I ,
1_ +--+_~-:....I+-'-"':-+-+-I--t-+-+-"--+-1-+---+--1H--i-I-+--+-+-t--+-+-+-f---l-.- ~
!.J.fO
KUg
i
o 9
I
I • : :,
----:I
I
i
I
_r--~~lll-t-t1r3h5m,nJiTIU
+-+-+--+-+-+-+-+--i
I

:

•

£:}~,_~____., ~._-,_._-_-_:-_=_-,-_ -~~,
-

,-.
,

~

!

3'

I

4

I

r--- -,

:'

I ' ,

I

1

I:

i:

L_L I .1

I

-+-I--+-+--!_+-+-+--i!l~HJ~~+--I~-+~,,-,>~~~~+,W,-+,.i~~~-""'+-+-+_:I-+-_+-I-+-_l-+-+-+-t-+-+-t-I

I_I-+-+-+-+-!,+-+-1--+-+-1--1-:+,

---+~--- -~~~I--t--l--!---;-

I

I

I

-+-I--t--I-t--H-~-+-

ii'

I

;-;,- -- --·-----+---;---'---;--H

Ji. I

::

!

,I;

'ji

-_'-~' ___-I-L

u:

I

j

I'

'c-_'

-:-

I

Data structure can be referenced by PARTNO name or
by subfields MFG, DRUG, STRNTH, COUNT or PART DS.
However, the data structure name (PART NO) cannot be
referenced In factor 1, factor 2 , or t he resu It f Ie Id (un Iess
the operation is R LAB L), but any of the subfield names can.

Figure 7·11. Using a Data Structure to Define Subfields within a Field

Input Specifications

I

0

Filename

Line

:r

Jl

>0

~~
:::6

4

5

6

7

8

910 11

tr

'I!.L

~

0
Position

I

: III r

3

J
~ e

~

Position

~ ~

0

111

~l1

~§
Z

U

Position

6

-!O

o ~u

Z

"5 a:
~~ 0:
~

0

~

t;

Ul

0

From

To

Field Name

-;;;
E

...J

~
0;

j

g

~

CD

~.1

.3

.,

Field
Indicators

.0
0

~~

.!!:!~

U-u-

~~
~

"fi

~~
:;Ou

~

"
0

~

"

Zero
Plus Minus or
Blank

0;

u::

2 c.~

I

tns

I

!

;I
IJ
I

i

I

l--~-

r--

I

I

I

i

1

i

i

i

:

I

!

,
1

121c Il '- C~ rrlN

11

!

i

12

1

I
1

n

1~ IP~ iJ~Y
l6 ~y CL.E
sf HE AID

"6

1'''

KIEY

2.1_ l'l
3d! EG .ON
R~ N~H

50

EM PI.
28 RR FLD

[f»

12-

1§ tD
11 PL ~N"
I.. I.: Ilf 't,jI!J. NNO

I

~,

I

12~

12.6 1- HO URS

I

127

I

lL tL OL 69 89 L9 99 99 ;.g C9 Z9 t9 09 69

as

The data structure defined on line 07 (LOA) is used as
the display station local data area (U in column 18).
Information from the requesting command display
station's local data area is read into this data structure
at the beginning of the program and is written out at the
end of the program. The program can change this data
and update the display station local data ~rea at end of
job. This use of the data structure is usually related to a
single requestor terminal (SRT) program.
The third data structure (defined on line 13) contains
three subfields (KEY on line 14, ARRFLO on line 19, and
10 on line 20) for which additional subfields are defined.
The name ARRFLO (line 19) indicates a subfield into
which an array is moved.
Figure 7-13. Typical Uses of Data Structures
Input Specifications

~~ ~

RA ~E

1218 GO ~£

L9 99 99 ts C9 Z9 t9 09 6> 8t> L> 90 90 . . C. Z' tv 006C 8C LC 9C 9C 1>£ CC ZC tC OC 6Z 8Z LZ 9Z 9Z OZ CZ U

The data structure defined on line 01 (SAVOS) is used
as the SAVOS data structure (specified on a file
description continuation line for the WORKSTN file).
This data structure contains fields that are to be saved
and restored for each display station attached to the
WORKSTN file.

7-20

Zero
Plus Minus or
Blank

To

o

123
1214

Field
Indicators

Field Location
3

2

1

tZ OZ 6t 8t i t 9t St Vt Ct Zt tt Ot

6

8

L

9

S

•

C

Z

t

To specify the subfields of a data structure, make the
following entries. These entries must be made on the
line below the DS specification. The columns not
mentioned must be blank.
• Column 6: I.
• Columns 44-47: The number of the record position in
which the subfield begins relative to the beginning of
the data structure.
• Columns 44-50: To define the reserved, self-defining
subfields for the file information data structure
(lNFDS)' enter keywords (*OPCODE, *RECORD,
*SIZE, *STATUS, *MODE, *INP, *OUT) on subfield
specification lines for the data structure.

When using a data structure, consider the following:
• A data structure is considered an alphameric byte
string. The data structure is initialized to blanks
except for that part of the data structure that is
initialized with an array or a display station local data
area. You must ensure that numeric subfields are
initialized with numeric data prior to their use in
CHAIN, LOKUP, COMP, or editing operations. If the
element is a compile-time array, the array data is
placed in the data structure after the data structure
has been initialized to blanks.
• You can redefine a subfield in the data structure by
specifying the same or part of the same from/to
positions for another subfield.

In addition to these keyword-defined subfields, there
is an alphameric subfield in the INFDS that contains
WORKSTN data management or SSP-ICF return
codes. This subfield is filled in for all WORKSTN
files. The subfield is located in positions 23 through
26 and must be defined on the input specifications.
(For information on return codes resulting from the
use of the Interactive Communications Feature, see
the Interactive Communications Feature Reference
Manual.)

• The name of an input field or a result field that is
being redefined in a data struct'ure must be specified
in the data structure or be the data structure name;
however, it does not have to immediately precede the
subfields redefining it.

Each subfield must be given a name in columns 53
through 58. This allows the program to reference the
subfields. For more information concerning the
INFDS data structure, see WORKS TN Exception/Error
Handling in Chapter 13.

• The from and to positions specified in a data
structure for an input field that is being redefined are
relative to the beginning of the data structure, not to
the positions that the field occupies in the input
record.

• Columns 48-51: The number of the record position in
which the subfield ends relative to the beginning of
the data structure.
• Column 52: The number of digits (0 through 9) to the
right of the decimal position if the subfield is
numeric. Leave the column blank if the subfield is
alphameric . • Columns 53-58: The subfield name.
The subfield name can be the same as an input field
name or a result field name, and it can appear as an
RLABL. Subfields can be used in factor 1, factor 2,
or as an output field. However, the same subfield
name cannot be specified in different data structures,
and a data structure name cannot be specified as
part of another data structure. RPG II field name
rules apply to subfield names.

• If a field appears as a data structure name or as a
data structure subfield name, the physical space
reserved for that field is in the data structure,
regardless of where the field was defined.

• A subfield can have the same length attributes as
other fields or subfields.
• The maximum length of an alphameric subfield is 256
characters; the maximum length of a numeric subfield
is 15 characters.
• If arrays are specified as subfields, the length
specified must equal the amount of storage required
to store the entire array.

• Columns 75-80: Program identification (optional).

Columns 19-20 (Record Identifying Indicator, **, OS)

7-21

The following restrictions apply to the use· of a data
structure:
• The maximum length of a data structure is 9,999
characters. However, if the data structure is defined
as a display station local data area (U in column 18),
the maximum length is 256.
• The length of a data structure is defined in one of
two ways: (1)1f the data structure name is specified
as a field in an input record, the length of the data
structure is the same as the length of the input field.
If the to-position specified for a subfield exceeds the
length defined for the input field, the input field
specification is invalid. (2) If the data structure name
is not specified as a field in an input record, the
length is defined by the highest to-position specified
for a subfield.
• Look-ahead fields cannot appear as a data structure
or a subfield.
• Packed or binary numeric fields cannot be specified
as a subfield within the data structure. The field can
be defined as packed or binary in ,a file. RPG
converts the field to zoned decimal format when it is
placed in the data structure. The field is carried in
zoned decimal format within the data structure.
• RPG II reserved words, array elements, and table
names cannot be specified as a subfield.
• A maximum of 75 data structures or tables or arrays
can be used in a program.

. COLUMNS 21-41 (RECORD IDENTIFICATION
CODES)
Use columns 21 through 41 to describe the information
that identifies a record type. If all records are to be
processed alike regardless of their type or if there is
only one record type, leave columns 21 through 41
blank.
Note: Only columns 21 through 34 are valid for
CONSOLE files (see Chapter 12, CONSOLE File
Considerations, for more information).

When one file contains more than one record type, each
record type is identified by a code consisting of a
character or a combination of characters in certain
positions in the record. If different operations are to be
performed for each record type, this code must be
described in columns 21 through 41 so that the program
can determine the type o~ record selected for
processing. Only one type of record is selected for
processing during a program cycle, and the record
identifying indicator for that record turns on at the time
of selection.
Seven columns are used for the description of on~
character in the record identification code. Each
specification line contains three sets of seven columns:
columns 21 through 27, 28 through 34, and 35 through
41. Each set consists of four fields: Position, Not,
C/Z/D, and Character. Coding is the same for all three
sets.
Note: Any record that is read by the system and is not
described by a record identification code in columns 21
through 41 causes the program to halt. The operator
can· continue, however, by selecting the appropriate
option and pressing an entry function key. The record
that causes the halt is not processed and the next
record in that file is read.

(
7-22

Input Specifications

Position (Columns 21-24, 28-31, and 35-38)
Entry

E:tplanation

Blank

No record identification code is
needed.

1-4096

Record position of one character
in the record identification code.

Use these columns to give the location in the record of
every character in the identification code. These entries
must end in columns 24, 31, and 38 respectively.

Not (N) (Columns 25, 32, and 39)
Entry

Explanation

Blank

Character is present in the specified
record position.

N

Character should not be present in the
specified record position (not valid for
CONSOLE files; see Chapter 12).

Use these columns to indicate that a certain character
should not be present in the specified position.·

Character (Columns 27, 34, and 41)

In these columns, enter the alphabetic character, special
character, or numeric character that is used in the record
as the identification code or part of the code.

Character Grouping by Zone or Digit

When characters are used for record identification
purposes on a digit or zone o,nly basis, all characters
having the same zone or digit are selected by the
system as meeting record identification requirements.
When a character is read into the system, it is converted
into an 8-bit code. The program tests this 8-bit code to
see whether the character meets the requirements of
the record identifying character in the input
specifications.
Figure 7 -15 lists the characters that have identical zones
or digits. For example, if column 26 contains D, which
specifies digit only, and column 27 contains A, all
records having a slash (/), A, J, or 1 in the specified
column are selected as having the correct record
identification code. If column 26 contains Z and column
27 contains A, all records containing & or A through I
are selected as having the correct code.

C/Z/D (Columns 26, 33, and 40)

The following three special cases are exceptions:
Entry

Explanation

C

Entire character. C must be used
for CONSOLE files (see Chapter 12).

Z

Zone portion of character.

D

Digit portion of character.

Use these columns to indicate what portion of a
character is used as part of the record identifying code.
Only the zone portion, only the digit portion, or both
portions (the whole character) can be used (see Figure
7 -14). When establishing record identifying codes,
remember that many characters have either the same
zone or the same digit portion. For a list of characters
that have identical zone or digit portions, see Figure
7-15.

• The hex representation of an & (ampersand) is 50.
However, when the ampersand is coded in the
character entry, it is treated as though its hex
representation were CO, that is, as if it had the same
zone as the characters A through I. An ampersand in
the input data satisfies two zone checks, for either a
hex 5 zone or a hex C zone.
• The hex representation of a - (minus sign) is 60.
However, when the minus sign is coded in the
character entry, it is treated as though its hex
representation were DO, that is, as if it had the same
zone as the ,characters J through R. A minus sign in
the input data satisfies two zone checks, for either a
hex 6 zone or a hex D zone.
• The hex representation of a blank is 40. However,
when the blank is coded in the character entry, it is
treated as though its hex representation were FO, that
is, as if it had the same zone as the numeric
characters 0 through 9. A blank in the input data
satisfies two zone checks, for either a hex 4 zone or
a hex F zone.

Columns 21-41 (Record Identification Codes)

7-23

AN D Relationship

OR Relationship

A maximum of three identifying characters can be
described in one specification line. If the identification
code consists of more than 3 characters, an AND line
must be used to describe the additional characters.
Write the word AN D in columns 14 through 16 to
indicate an AND line (see Figure 7-14).

If a particular record type can be identified by two
different codes, OR lines must be used to indicate that
either of the codes can be present to identify the
record. A maximum of 20 OR lines can appear for each
record sequence if no AND lines are used. Write the
word OR in columns 14 and 15 to indicate an OR line
(see Figure 7-14).

A maximum of 20 AN D lines can be used to describe
the record identifying code for a record sequence if no
OR lines are used. The record must contain all the
characters indicated as its record identification code
before the record identifying indicator turns on. AND
lines are not allowed on CONSOLE files used for
interactive data entry.

Note: If AND lines and OR lines are combined, the totAl
number of AND and OR lines for one record sequence
cannot exceed 20.

COLUMN 42
Column 42 is not used. Leave it blank.
Character 5 must be present in position 1, zone of
character T in position 94, character 9 in position 95,
and digit E in position 96. However, digit 9 must not
be present in column 93. Only the digit portions of 9
and E are checked, and only the zone portion of
character T is checked.

Input Specifications
Record Identification Codes

I

1

f----

i
Jl

Filename

Line

rei
3

4

0

1

o

2

0

3

o

4

5

6

7

'A ~'o

Ro Lit ·}I~c.

nAINni([?

l1l2

6

I~

o

7

I

o

8

I

o

9

I
I

I

POSItion

~5
..... r--.

CA

~e

b~

0

11 Cis

.... r--.,

I~
I~

5

0

~ ~
z
U

R

Iflf

o

Z

zU

9 10 11 12 13 14 15 16 1718 19 20 21 22 23 24 25 26 27 28 29 30 31

IP All
I

o

1 0

8

POSition

f-,-

fA"

ql

0

.21~~ I~

II

[AlA

811\,;1.-

IJ

0
.~

~o

Field
Indicators

Field Location

/
~~

j~
~§ UUl

a:

From

To

...J

Field Name

~
-a;

0..

j

~

g

III

.~

Q:

0

8

0
0

12-0 ~

.!!!Gi

LLU:

.~ ~

j

"5 :E

"0

:
?

S
T
U
V

w

1
2
3
4
5
6
7
8
9

Zone C

&
{
A
B
C
D
E
F
G
H

I
Zone 7

Zone D
- (minus)

:

#
@

,

(apostrophe)
=

"

}
J
K
L
M
N

0
P
Q

R
Zone 8
a
b
c
d
e
f
9
h

}
{

\
0
Digit 1

I
a
j
"""

Digit 6
f

Digit 2
b
k
s
B
K

S
2
Digit 3
c
I
t
C
L

T
3
Digit 4

d
m
u
D
M
U

<

0

*

w

%

F

@

0

w
6
Digit 7
g
P
x
G

p
X

A

J
I

Digit C

Digit D
(
)

(underscore)

,

(apostrophe)

7
Digit 8
h
q
Y
H
Q

Digit E

+
,

>
=

y
8
Digit 9
i
r
z

I
R
Z
9
Digit A

Digit F

I

--,
?
"

cf.

!
I

I

4
Digit 5

Digit B

e
n
v
E
N
V
5

$
J

#

i
Figure 7-15. Characters Interpreted as Having the Same Zone or Digit

Column 42

7-25

Field Description Entries
Note: The field description entries (columns 43 through
74) must begin one line below the file and record
identification entries (columns 7 through 42) for each
file.

COLUMN 43 (PACKED OR BINARY FIELD)
Entry

Explanation

Blank

Field is in zoned decimal format
or is alphameric. (This column must
be blank for CONSOLE files.)

p

Field named in columns 53 through 58
is in packed decimal format on
the disk.

B

Field named in columns 53 through 58
is in binary format on the disk.

Use column 43 to indicate that a numeric field is in
packed decimal or binary format. Only disk files support
packed decimal or binary fields for read or write
operations. Numeric data fields in packed decimal or
binary format are converted by the system to the zoned
decimal format before they are processed. This
conversion ignores decimal points.
Any array that is in packed or binary format should have
a P or B in this column. The from and to columns
should then define the positions the array occupies in
the record in the packed or binary format. The zoned
decimal length of each array element is defined on the
extension specifications.

Zoned Decimal Format (Blank)

Zoned decimal format means that each byte of storage,
whether on disk or in the computer, can contain 1
character. That character can be a decimal number or
an alphabetic or special character. In the zoned decimal
format, each byte of storage is divided into a 4-bit zone
portion and a 4-bit digit portion. The zoned decimal
format looks like this:
o----~.

7

O----~r

7

O - - - -.....~ 7

O----~I

7

O----~I

7

1101 = Minus sign (hex D)
1111
7-26

Input Specifications

= Plus sign

(hex F)

(

Note: RPG II does not perform data verification on
numeric data. The value of the digit portion of a
character is assumed to be the numeric value of that
character.

The zone portion of the low-order byte indicates
the decimal number is positive or negative. In
zoned decimal format, each digit in a decimal number
includes a zone portion; however, only the low-order
zone portion serves as the sign. The decimal number
8,191 looks like this in zoned decimal format:

~hether

Positive
Zone

l

l

l

Zone

8
: 1000

Zone

9

sign

1

I : I :
000 1

100 1 11111 : 000 1

I

~-------------------4bytes------------------~

Once data is read into the computer, it must be
represented in the zoned decimal format before it can
be processed. Thus, data can be stored on disk and
read into the computer in the zoned decimal format,
thereby eliminating the need to convert the field.
However, storing numeric data (decimal numbers) on
disk in either the packed decimal or the binary format
provides more efficient use of disk storage space.

In the packed decimal format, each byte of disk storage,
except the low-order byte, is divided into two 4-bit digit
portions. The rightmost portion of the low-order byte
contains the sign (plus or minus) for that field. The
packed decimal format looks like this:

0--------' 7
Digit

Packed Decimal Format (P)

Digit

, 7

0

I

Sign

Digit

~

byte
Packed decimal format means that a byte of disk
storage (except for the low-order byte) can contain two
decimal numbers. Because many of the fields in a disk
file contain decimal numbers, you can conserve disk
space by storing these fields in the packed decimal
format.

The sign portion of the low-order byte indicates
whether the numeric value represented in the digit
portions is positive or negative. In the packed decimal
format, the sign is included for each decimal number;
however, the zone portion is not given for each digit in
the number. Compare how the decimal number 8,191 is
represented in packed decimal format with its zoned
decimal representation shown before (see Figure 7-16).

Column 43 (Packed or Binary Field)

7-27

Binary Format:

Positive
sign

~

0

I

I

I

I

I
0

0

I

I

I

I

I
1.

:

I

I

I

I

+ 4

+ 2

+

I

I

I

I

I

4096+2048+1024+ 512 + 256 + 128 + 64 + 32 '+ 16 + 8

I

I

I

1

:

2 bytes

Packed Decimal Format:

a

8

Positive
sign

l

9

I

I

0000 I 1000

0001 I 1001

I

0001 I

-------3 bytes ------~
Zoned Decimal Format: 2

1

Positive
Zone

t

Zone

l

Zone
8

l

Zone

J

9

sign

---------------5 bytes------------~
ITo obtain the numeric value of a positive binary number, add the values of the bits that are on (1); the sign
bit is not included. To obtain the numeric value of a negative binary number, add the values of the bits
that are off (0) plus one; the sign bit is not included.
21f 8.191 is read into storage as a zoned decimal field, it occupies 4 bytes. However, if it is converted to
packed decimal format, it occupies 3 bytes; then when it is converted back to zoned decimal format, it
occupies 5 bytes.

Figure 7-16. Binary, Packed Decimal, and Zoned Decimal Representation of 8,191

7 -28

I nput Specifications

Because data must be represented in zoned decimal
format once it is inside the computer, you must give the
RPG II program an indication when input fields are in
another format. Entering a P in column 43 indicates that
the input field is in the packed decimal format and that
the system must convert this field to the required zoned
decimal format.
When a packed decimal field is converted to a zoned
decimal field, the zoned decimal field always contains an
odd number of bytes. If a zoned decimal field with an
even number of bytes is converted to a packed decimal
field and then converted back to a zoned decimal field,
the resulting zoned decimal field also contains an odd
number of bytes.
Packed fields can be up to 8 bytes long. The following
chart shows the packed equivalents for zoned decimal
fields up to 15 bytes long:
Zoned Decimal
Length in Bytes

Packed Length
in Bytes

Binary format means that 2 bytes of disk storage can
contain a four-digit number, and that 4 bytes of disk
storage can contain a nine-digit number. The binary
format allows you to save even more disk storage space
than you can save using the packed decimal format. In
the binary format, each field on disk must be either 2 or
4 bytes long.
Each 2-byte binary field consists of a 1-bit sign
followed by a 15-bit numeric value. In binary format, a
decimal number as high as 9,999 requires only 2 bytes
of disk storage. For each 2-byte binary field stored on
disk, the RPG II compiler automatically sets aside 4
bytes of storage to accommodate the field when it is
unpacked. A 2-byte field in binary format looks like
this:

o

15
Number

15
14

8

13
12

7

11
10

6

9
8

5

7
6

4

5
4

3

3
2
1

Binary Format (B)

-------2 bytes - - - - - - -

2

Column 43 (Packed or Binary Field)

7-29

Each 4-byte binary field consists of a 1-bit sign
followed by a 31-bit numeric value. In binary format, a
decimal number as high as 999,999,999 requires only 4
bytes of disk storage. For each 4-byte binary field
stored on disk, the RPG II compiler automatically sets
aside 9 bytes of storage to accommodate the field when
it is converted. A 4-byte field in binary format looks like
this:

o

31
Number

~-------------------------4bytes------------------------~

In each case, the sign portion of the high-order byte
indicates whether the numeric value is positive (sign bit
off) or negative (sign bit on). Positive numbers are
represented in true binary notation with a 0 bit in the
sign position. Negative numbers are represented in
twos-complement notation with a 1 bit in the sign
position. The bits between the sign position and the
leftmost significant bit of the integer are always the
same as the sign bit. When the number is positive, all
bits to the left of the most significant bit, including the
sign bit, are Os. When the number !s negative, all bits to
the left of the most significant bit, including the sign bit,
are 1s. Notice that, in the binary format, the zone
position of the decimal number is not given. Compare
how the decimal number 8,191 is represented in binary
format with packed and zoned decimal representation
(see Figure 7-16).
Because data must be represented in zoned decimal
format once it is inside the computer, you must give the
RPG II program an indication when input fields are in
another format. Entering a B in column 43 indicates that
the input field is in the binary format and that the
system must convert this field to the required zoned
decimal format.

Note: Although packed and binary fields require less
disk storage space, the conversion routines needed to
handle such data increase the object program size.

COLUMNS 44-51 (FIELD LOCATION)
Entry

Explanation

1-9999

Beginning of a field (from)
or end of a field "(to). See
Chapter 12 for CONSOLE file
considerations. For a WORKSTN
file, the from and to positions
refer to the location of the
fields in the input record
and not to their location in the
displayed format.

Use columns 44 through 51 to describe the location on
the record of the field named in columns 53 through 58.
Enter the number of the record position in which the
field begins in columns 44 through 47. Enter the
number of the record position in which the field ends in
columns 48 through 51. The entries must end in
columns 47 and 51. Leading zeros can be omitted.
Define a single-position field by entering the same
number in both the from (columns 44 through 47) and
to (columns 48 through 51) positions. If a field of more
than one position is defined, the number entered in
columns 44 through 47 must be smaller than the
number entered in columns 48 through 51.
The maximum field length for a zoned decimal numeric
field is 15 positions (8 if the field is packed and 4 if it is
binary). The maximum field length for an alphameric
field is 256 characters, and the maximum length for a
data structure is 9,999 characters.

7-30

Input Specifications

COLUMN 52 (DECIMAL POSITIONS)
Entry

Explanation

Blank

Alphameric field

0-9

Number of decimal positions
in numeric field

Use column 52 to indicate the number of positions to
the right of the decimal in any numeric field named in
columns 53 through 58. Column 52 must contain an
entry when the field named in columns 53 through 58 is
numeric. To define a field as numeric with no decimal
position, enter a O. If a field is to be used in arithmetic
operations or is to be edited, it must be numeric. If the
number of decimal positions specified for a field
exceeds the length of that field, the number of decimal
positions is assumed equal to the length of the field.

COLUMNS 53-58 (FIELD NAME)
Entry

Explanation

1-6 alphameric
characters

Field name, array name,
or array element

PAGE,
PAGE1PAGE7

Special words

Use columns 53 through 58 to name a field, array, or
array element found on your input records. When
referencing an array, additional entries may be needed in
these columns (see Array Name and Index in Chapter 14,
Tables and Arrays). Use this name throughout the
program whenever you refer to this field. Indicate the
names of the fields for all types of records using a
separate line for each field. However, name only the
fields that you use. For example, if you use only the
first 10 positions of a record that is 96 positions long,
define positions 1 through 10 on the input
specifications.

Field Names
A field name can be from 1 to 6 characters long and
must begin in column 53. The first character must be
an alphabetic character. The remaining characters can
be any combination of alphabetic and numeric
characters (special characters are not allowed). Blanks
cannot appear between characters in the name.
All fields in one type of record should have different
names. If two or more fields on the same record type
have the same name, only the field described last is
used. However, fields from different record types can
have the same name if the fields are the same length
and contain the same type of data. This applies even if
the fields are in different locations in each record type.
Numeric fields can have a maximum length of 15 digits.
Alphameric fields can have a maximum length of 256
characters (66 for CONSOLE files). A data structure can
have a maximum length of 9,999 characters. Subfields
can have a maximum length of 256 characters for
alphameric subfields and 15 digits for numeric subfields.
If a data structure is specified, only field record relation
indicators (columns 63 and 64) can be specified. Entries
for control level indicators (columns 59 and 60)' match
field values (columns 61 and 62), and field indicators
(columns 65 through 70) are not allowed. A data
structure name cannot be specified as a subfield in a
data structure.
Fields that are used in arithmetic operations (see
Chapter 10, Operation Codes) or fields that are edited or
zero suppressed (see Column 38 and Columns 45-70 in
Chapter 9, Output Specifications) must be defined as
numeric. Therefore, column 52 must have a decimal
position entry (0 through 9).

For CONSOLE files, whole array names must be entered
in one of the following ways:
• Define the whole array as a subfield within a field.
• Define each element of the array with an index and
place this entry in columns 53 through 58 of the
input specifications. The index must be an integer
value.

Columns 53-58 (Field Name)

7-31

Field Names in OR Relationship

Special Words (PAGE, PAGE1-PAGE7)

If two or more record types contain identical fields, you
must describe each field. To eliminate duplicate coding
of identical fields from different record types, use the
OR relationship (see Figure 7 -17). A maximum of 20
OR lines can be used for each record sequence group if
no AND lines are specified.

If a printed report has several pages that are to be
numbered, use the special word PAG E to indicate that
page numbering is to be done. When you use a PAGE
entry on the output specifications, page numbering
automatically starts with 1 (see Columns 32-37 in
Chapter 9, Output Specifications).

An OR relationship means that the fields named can be
found in either of the record types. You can use OR
lines when:

To start at a page number other than 1, enter that page
number in a field of an input record and name that field
PAGE in columns 53 through 58. The number entered in
the PAGE field should be one less than the starting
page number. If numbering starts with 24, enter a 23 in
the PAGE field. The PAGE field can be 1 to 15 digits
long, but must have zero decimal positions (see Figure
~ -18). If a PAGE field is used but it is not defined, the
PAGE field is assumed to be 4 digits long with zero
decimal positions. Any entry in the PAGE field should
be right-justified, such as 0023.

• Two or more record types have the same fields in the
same positions (Figure 7-17).
• Two or more record types have some fields that are
identical and some fields that differ in location,
length, or type of data. See Columns 63-64 in this
chapter for sample coding of such record types.

Nrite OR in columns 14 and 15 to indicate an OR line.
f there are several AND or OR lines, field description
nes start after the last record identification line.

Page numbering can be restarted during a program run
when a number is specified in a PAGE field of any input
record. The PAGE field can be defined as a numeric
field, 1 to 15 digits in length, with zero decimal
positions, and used in calculations like any other field.
The eight possible PAGE entries (PAGE, PAGE1, PAGE2,
PAGE3, PAGE4, PAGE5, PAGE6, and PAGE7) are
provided for numbering different page types in the
output file or for numbering the pages for different
printer files.

(
7-32

Input Specifications

Input Specifications

I

Record Identification Codes

0

~

f---

~~

i
&

Filename

Line

~ 0
"0.

0

Position

~rr;ro
4

56

7

8

9

Field Name

~

j.

'O~;3

Field
Indicators

Field Location

-

3

2

1

~
0
z

~

e ~

-.;
Position

~

e ~

Position

~f.36

~2
Uu

go
~ §

lji

.~ ~

To

;;:u

10 11 12 13 1415 16 17 18 19 20 21222324 2526 27 28 29 3031 3233 34 35 36 37 38 3940 4142 434445464 7 48 49 50 51 52 53 54 55 56 57 58 59 60 6162 6364 65 66 6768 69 70 71 72 73 74

IA'~

Ia:s

1

I~ All
I

~

o

3

I

I~ ~

o

4

I

o
o

5

I

6

I

o

7

I

o

8

I
I

I

Ji
t-t--

1 G

I
I

1 ,8

I

9

I

2 0

I

I

I

I

,

I

t

1~

-- ~A

!

I

I

1 7

r--- -

11;

0R

-L

:1 Ie ~
l1 C

-~lc!ll

-..

I ...

.:lIU III 'II=.~
IA
Uj Clli'- 1051

---

18 In'e1FT

,,~

~

!

i 1

I
I

I-

I

1

i

~I'" P'NO
... ":T

Q ml ,~'"
~

I

--

i

I~E P,T

8 tn'E PT ...

I~

~ e:ili ~1 I~IA T,E 1)UP L.I CA TE 1'0 1)~!N6 USE
:1 I~I;J i~t- r-R EL. ~ 10 NS It-\Il F

1 4I

i

1~ 1:.1'1It'NU

-110 Ql!C OST
:lJl.: {D.L 'It. PI

I

I

I

t

~

I~

11 CE,

I

:~
:l
~~A:l !~'C\!

1

I

'1~

I~,

t--~

11 ICS

15

IBe

:trrriJ[
1 5

114

~

11

Plus Minus or
Blank

~2

2

I

:~

"5

o

I

Zero

"-,,-

From

o

o 91

:E-o

.~ ~

I
I

I

I

I

1

I
ZL II Dt 69 89 £99959 V9 £9 Z9 19 0965

as

lS 95 55 tog CS Z5 lS

as 6v 8v Lv 9v

St' ;OF

tv

Zv

Lv

OF 6(:

at

I t 9£ sc V£ CC lC lC DC 6Z Bl tl 9Z SZ vl CZ ZZ lZ OZ 6L P.L LL 9L SL vL CL ZL LL OL

6

8

l

9

5

v

C

Z

L

Figure 7·17. Record Types with Identical Fields

Input Specifications
Record Identification Codes

o

I

Field
Indicators

Field Location

]

f---

Field Name

Filename

line

Position

Position

Position

From

To

Zero
Plus Minus or
Blank

;--;-

o R
~Nro

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3031 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 6061 62 63 64 6566 67 68 69 70 71 72 73 74

o

1

IINPUiT

o

2

I

Oil

o

4

I

11 lep

I

2

!5 dlnl A '--~,
I
I

Figure 7·18. Page Record Description

Columns 53·58 {Field Name}

7·33

COLUMNS 59-60 (CONTROL LEVEL)
Entry

Explanation

L1-L9

Any control level indicator.
Control level indicators cannot
be used with chained, demand, or
WORKSTN files or with a data
structure.

Use columns 59 and 60 to assign control level indicators
to input fields. Use control level indicators to specify
when calculation or output operations are to be
performed. You can assign a control level indicator to
any field; this field is then known as a control field. The
program checks the field for a change in information.
When the information changes, a control break occurs.
All records having the same information in the control
field are known as a control group.
Whenever a record containing a control field is read, the
data in the control field is compared with data in the
same control field from the previous record. When a
control break occurs, the control level indicator turns on.
Operations conditioned by the control level indicator are
then performed (see Columns 7-8 in Chapter 8,
Calculation Specifications or Columns 23-31 in Chapter 9,
Output Specifications).
There are nine different control levels (L 1 through L9).
When a control level indicator turns on, all control level
indicators lower than it also turn on. For example, if
control level indicator 3 turns on, control level indicators
1 and 2 also turn on.
The indicators are ranked in order of importance. The
larger numbers rank higher than smaller numbers. L4
has a higher rank than L 1. The importance of a control
field in relation to other fields determines how you
assign indicators. For example, the type of data that
demands a subtotal should have a lower control level
indicator than data that needs a final total. A field
containing department numbers should have a higher
control level indicator than a field containing employee
numbers (see Figure 7-19).
Because control level indicator LO is always on, it cannot
be assigned to a control field. Nevertheless, you can
use it to condition operations (see C.olumns 7-8 in
Chapter 8, Calculation Specifications).

Normally, control level indicators are used to:
• Condition certain total calculations to be performed
when the information in the control field changes.
• Condition certain total output operations to be done
after totals are accumulated for one control group.
• Condition certain detail calculation or output
operations to be done on the record that causes a
change in a control field (first record of a new control
group).

Assigning Control Level Indicators
The following considerations apply to assigning control
level indicators:
• If the same control level indicator is used in different
record types or in different files, the control fields
associated with that control level indicator must be
the same length and same type (alphabetic or
numeric). See Figure 7-19.
• In the same record type, record positions in control
fields assigned different control level indicators can
overlap (Figure 7-20). However, the total number of
positions assigned as control fields must not be
greater than 144. In Figure 7-20, for example, 15
positions have been assigned to control levels.
• Field names are ignored in control level operations.
Therefore, fields from different record types that have
been assigned the same control level indicator can
have the same name.
• Control levels need not be written in any sequence.
An L2 entry can appear before L1. Also, there can be
gaps in the control levels assigned.
• When numeric control fields with decimal positions
are compared to determine whether a control break
has occurred, they are always treated as if they have
no decimal positions. For instance, 3.46 is considered
equal to 346.
• If a field is specified as numeric, only the digit
portion determines whether a control break has
occurred. This means that a field is always
considered to be positive. For example, -5 is
considered equal to +5.
• All control fields given the same control level
indicator are considered numeric if anyone of those
control fields is described as numeric (column 52 has
an entry). Therefore, when numeric control fields are
compared to determine whether the information has
changed, only the digit portion of each character is
compared.

7·34

Input Specifications

(

Input Specifications

I

-

7

8

9

;

A~8

lila

i

i

I
I

;

i

I

i

I

!

2

I

i

I

i

'

i

:

!

:

;

:I~
I I' :

I

5 i

I

i

!61

I

:

o 17 i

I

o

B:

I

o

9·

I

,' 0,

I

,

I

i

: :I

o ! 4!

0:

,

I

I

II

I
I
!

I

I

2'

I

, 3'

I

~ e~
~

~

e

~

o~

2

Position

~

~

2

zuu

0

§

From

1ji

To

Plus

Minus or

Blank

10 11 12 13 1415 1617 18 19 20 21222324 2526 27 28 29 30 31 3233 3435363738 39 40 4142 4344454647 48 49 50 51 52535455565758 59 60 61 62 6 3 64 65 66 67 68 69 70 71727374

01,1 I E1MPiLiRe"p
01 ! I III [[
o 13:

Position

z u u

R

f.;N+o
6

Zero

0;

Position

r--,.-

345

Field Name

g

&
a

Field
Indicators

Field Location

3

2

~

Filename

Line

o

Record Identification Codes

,

I
1

1

I
;

;
:

: II
! i

I

1

I

i

!

!

I

vV

I

i !

I

iI

I

1.......

I

I
I

i

!

i

!

i

I.... ~

yo:"'"

I

I

Iv

! V(

,.
.1J
Bll

1J I

l1

~Q

~Q

~l':l

l':!:o

~

'10

.....

LN eLl!
lAMe
IIV rc:~ 'AJ[~

IHI FIT

SPIT

~~
1

~

~

V

"
J

V

I

;

I

i

~
~

12~ I! i Nlcl~
I

!

r

I(

I

I

I"_rn

li CA

-I-

lilt
b~

11,

11~

ha

)E ell

iNO Lll

:12 " ~I&i~
ie: ",

:aa !8l

it

II

i

,I

I

Ll2

' I.. 'I~

"" V
I~
IJI

j

Three control level indicators are assigned. The names
of the control fields (DIVSON, DEPT, EMPLNO) give an
indication of their relative importance. The division
(DIVSON) is the most important group. It is given the
highest control level indicator used (L3). The department
(DEPT) ranks below the division. L2 is assigned to it.
The employee field has the lowest control level indicator
(L 1) assigned.

The same control level indicators can be used for different record types. Notice, however, that the control
fields having the same indicators are the same length.
EMPLNO, in both cases, is 6 characters in length, DEPT
is 4, and D IVSON is 1.

Figure 7-19. Control Level Indicators (Two Record Types)

Control Field 1
~
,

2 3 " S 1 7 8 g , Q 11 12' 13'. '5 II 17 ,.,920 2122 23 24 2S 28 27 21 21 30
~

Control Field 2
Figure 7-20. Overlapping Control Fields in a Disk Record

Columns 59-60 (Control Level)

7-35

• Control fields are initialized to hexadecimal zeros.
• A control break can occur after the first record
containing a control field is read. The control fields in
this record are compared to an area in storage that
contains hexadecimal zeros. Because fields from two
different records are not being compared, total
calculations and total output operation are bypassed
for this cycle. A control break occurs then, but it is
not considered to be a true control break.
• If different record types in a file do not have the
same number of control fields, unwanted control
breaks can occur. See Figure 7-21 for an example of
how to avoid unwanted control breaks.
• A control field cannot be specified as binary (8 in
column 43). However, it can be specified as packed
decimal (P in column 43).

Split Control Fields
If a control field is made up of more than one field of a
record, it is then known as a split control field. A split
control field is created when the same indicator is
assigned to two or more connected or unconnected
fields on the same record type.
All fields in one record that have the same control level
indicators are combined by the program in the order
specified by the input specifications and treated as one
control field (see Figure 7-22). Some special rules for
split control fields are:
• For one control level indicator, a field can be split in
some record types and not in others if the field
names are different. However, the length of the field,
whether split or not, must be the same in all record
types.
• The length of the portions of a split control field can
vary for different record types if the field names are
different. However, the total length of the portions
must always be the same.
• No other specification lines can come between lines
that describe split control fields.
• If one section of a split control field is numeric, the
whole field is considered numeric.
• A numeric split control field can have more than 15
characters if anyone portion of the split field does
not exceed 15 characters and the sum of all control
fields is nq~ greater than 144 characters.

7·36

Input Specifications

• A split control field cannot be made up of a packe-d
decimal field and a zoned decimal field. Both
portions of the control field must be packed or both
must be zoned decimal.
Note: Additional rules applying to control level indicators
when used with indicators in the field record relation
columns are discussed in Columns 63-64 (Field Record
Relation).

COLUMNS 61-62 (MATCHING FIELDS)
Entry

Explanation

M1-M9

Any matching level

Use columns 61 and 62 to specify match fields and
sequence checking. Match fields and sequence checking
cannot be specified for chained files, demand files,
WORKSTN files, or a data structure.
An entry in columns 61 and 62 indicates:
• Match fields and sequence checking when you have
two or more input or update files with match fields
• Sequence checking only when you have just one
input or update file
The match levels are ranked in order of importance, with
M 1 being the least significant.

Match Fields
In multifile processing, specify match fields to compare
records from two or more input or update files to
determine which record is to be selected for processing.
You can use one field, many fields, or an entire record
to match records. Whenever the contents of the match
field from the primary file record are the same as the
contents of the match field from a secondary file record,
the matching record (MR) indicator turns on. The MR
indicator can then be used to condition those operations
that are to be done only when records match (see
Columns 9-17 in Chapter 8, Calculation Specifications
and Columns 23-31 in Chapter 9, Output Specifications).
As many as nine match fields can be indicated when
you use the values M 1 through M9. M 1 through M9
only identify the fields by which the records are
matched; they are not indicators, but they cause the MR
indicator to turn on.
For a complete description of how to assign match
fields and how records are selected for processing, see
Chapter 11, Multifile Processing.

Salesman
Number
2
3

Salesman
Name
4
16

1

Item Number

Salesman
Number
3
2

4

Different record types normally contain the same number
of control fields. However, some applications require a
different number of control fields in some records.

JOHN SMITH
100
100

6

9

7

{

3

Unwanted
control
break

The salesman records contain only the L2 control field.
The item records contain both L 1 and L2 control fields.
With normal RPG II coding, an unwanted control break
is created by the first item record following the salesman
record. This is recognized by an L 1 control break
immediately following the salesman record and results
in an asterisk being printed on the line below the salesman record.

01

JOHN SMITH
100
100

2

5 *
101

Amount

Item Record

Salesman Record

02

\

B

A

01

J

(L 1)

(L2)

(L2)

101

4
4 *
9 **

JANE DOE
100
100

6
2

101

8 *
3
3 *

Unwanted
control
break

02

3
2

5 *
4
4 *
9 **

JANEDOE
100
100

6
2

11

8 *
3
3 *
11 **

20

20

Output Showing Unwanted Control Level Break

101

Corrected Output

Figure 7-21 (Part 1 of 2). Unwanted Control Breaks

Columns 61-62 (Matching Fields)

7-37

Input Specifications
Record Identification Codes

I

1

f--Filename

Line

3

4

5

6

I

I

7

8

9

Cl

!:

012;

I

ell

:

0

~

Position

o ! 3:

Iii

I

I

o 15 I

I

I

1

I

!

i

I

~ 12 R

Position

Field Name

~

~ e R~ ~

Position

~ £3 6

Zero
Plus Minus or

To

From

Blank

~ £3 6 ~ ~

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 4445 46 47 48 49 SO 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 09 70 71 72 73 74

I I Ij

~1

i

1B:8

I I i I
I i

~

12

~ £3 6

I I AlA

I

(

til

131,~ 1,~ 1,~

10 11 12

~LiES

3

\

~-~

;;;

~~
o 11

Field
Indicators

Field Location

2

:

Ii!

:

I

'-rr:
!

!

I

r-

iI
II

~ 18

i i I

I

I

I

i

i

I

I

I

I I_!:
I I II!
12 1 i 3 LZ:FiLD ~2.

I : ~

1

: 11

~2

I!I
J, JIJ
Ii
I Ii!

tlA

i

!

:

I

:

I

I

:!:
iii

! ~'f:l INAM~

!

I

I Ii!

I

12

l

I

~I-~
'~~Lt-,-=+:;;2F;;+:!l-±_'D='-t;-ll~.2;t------t----t--+-t-----t----'---'·'-----i

rO+:6_:4-I~_i__
' ~'~_'~~~~_~~~__~4-~I~:~i++4-~141-'-+~~~__~'-~-~rl-~~-h+~L~~ll~~l_~~~-4__ ~_-r___ ~

'

~01~7i~I~~~!I_ _
i~~~~_,----:_~~~I_I~i~_i_!~~L~,~~",_~:__q~~HI

--'----

-----

Calculation Specifications

C
r--

Indicators

~

~

Line

4

.g

Factor 2

56

Length

Name

E~
J: 8
3

Operation

Factor 1

"0

f--

Indicators

c

At

At

~ ...J]

>

Resulting

Result Field

0

0

0

Z

Z

Z

Arithmetic
~

Plus IMinusl Zero

~ ~

Comments

Compare

1>21<2 1=2
~ ~
·u - Lookup(Factor 21is
Cl :I: High Low Equal

9 10 11 12 13 14 1516 17 18 19 20 21 22 23 24 25 26 27 2 829 3031 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 495051 5253 54 55 5657 58 59 60 61 '62 63 64 65 66 67 68 69 70 71 72 73 74

7

o 1

c

o 2

C

o

3

C

o

4

CILll

o

5

.,16 11O!~
lETlOlf

IG j
IQ 12

It 2

DID

AMir
Illlir!OIT

cl12

l.

SC
sa

I'Irr

It

'l TICit'

tnlrl

~lntn

12.ir ~iT

1',

ll.,

I'otr

11~

I
I

5G

IL I~ lit

Tlolt

1111

specifications sheet). Detail calculations are then processed for the item record, and line 02 of the calculation
specifications sheet sets indicator 11 off. This allows the
normal L 1 control break to occur.

This coding prevents the unwanted control break. Line
01 of the calculation specifications sheet sets on indicator
11 when the salesman record is read. When the next item
record causes an L 1 control break, no total output is
printed because indicator 11 is on (line 07 of output

Output Specifications

o

-5 Space

Filename

Line

Skip

~~
i ~ ~ ;;

~ ~!~
f-- ~ ~~

~ R

ADD

I
'i:

2

_

:;

OJ

<

Z

AND

5

01

11

0

01 2 \

0

0!3:

0

i !I:r~-:--r'-~--

0

j

0

i !

'-.

9

ARll,ttri~i~

ill I \ , '

5

o l5i

8

il

1

IL j1f--L

I ! i ___
:,- 7'
+--t-101 ,-

1 i ; i__ ~

-

Field Name

,I

,I

And

And

I I

i

Z

I

ar------->

!

:;

.g ~

I I!

8 i2
.: ~

• AUTO

w

I

29ho

I Commas I Zero Bal,ances

~~~tion
In

c:l

Yes

a:

'

1

•

I~

~~s

2

~

3

4

5

6

7

8

o

91

0

'

I

:

~

K

g ~

Field Edit

9

10 11 12 13 14 15 16 17 18 19 2021 22 23 24 '

l-r~1 '

, 1-_~1.-kL-

ill!'

_

I

I

I j

!

C2:FllDS:
N'A'ME

iii'

:!

,: 11il-~~,

:: I

: : -+-:-:

215

!!

:

iii I

!!
i

i,

'

!

I :

--

i , "

_

L-'_L-

_~

____

~

_

iii

Figure 7-21 (Part 2 of 2). Unwanted Control Breaks

7-38

Input Specifications

I

I

i

I

~ ___

:!

I
! I I:
I! ! i

i
i:

I

,I

i

lCl \ ~

I

~:~ ~T1~~~~_~~~~:~ ~~:~~:[~o}~ 0

1 11 I

1r~.,' : Ili"
,
'i -----:---:----.
I
f/J'L ',--- ~---i----l-~-;-----f-+----+----::t-~,-~ -+-~--+----;-'--i--~-----+-+----+-+-+~-f-+--'---/
I ~ __ .~-"- -:i- 'L~,fLD
J3
:LW
:
'~,I ~;-r--:--t--"-~

-,-,--'~-,

I

1:

I!

:'

I J~~_l_:O'T1

lIS

Li_l'::':

i

+-:

!,

I

~~+---__'__l

--;---- --~--r__r_J...-+-~-+----'---:----+--;
j

I: :I

'

I : _:'__+--<--'--->---1

-,--,,-

:'

:

. . :~~~~~~~_,_,__:J
,~

ji

--,------,----,--'--i

r'i,\- ~H-rr::=: ~> ~~ .~~= 1.2 J=~:=[lt~!~l e-~" =;::n+-:'::IC8
141

~~~~ress

Z =

31 32333435 3G 37 38 39 40 41 4243 444546 47 48 49 5051 52 5:3 545556 57 58 59 60 61 626364 65666768 697071 72 73 74

l--rl+r~,-~--I-· - -11- -:- 'IT,- ~,Lli Nk,11 i A:,~!L~~ -_.JZ5 -- ~_'=~-~b-~~,~.
~ 0 -tTl:~~ r
--- ~ --r--,-- r ; -t--+ 1It1-r,,~, "1.10 2'~ - - , I ' i '
:--1
:
,L---: __ ~l.- r- -- -- ---- --"-- ~ ----- ---+ IL.'.L IP' , ; .r:;1.I] ,
"-t! '-- _. ,
,,'

:i:: :

X = Remove

Constant or Edit Word

~
0-

~

No

~~

2

I CR

F===ye=s

II

Output
Record

No Sign

4=to=:~=:n=t~===='i==*J==1 y = ~'~t~Sign

-r---,.-,

a:

Z

'I

10 '1 12 13l 1415 16 17 12 1920 21 22 2324 25 26 i27 28

4

o1

7

I

I'I:; I
I

3

±'

6

Output Indicators

Ii:
,

I

.;
:.

I

: I

'

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

I-Filename

Lin..?

;,.;

Pos"tion

_

.E

Position

_

~

Field Name
Pos"tion

':0:

J:,....

From

,,,IMASTER
,,,,"" ""flffiIAA ""rb1""""",1 :eM::'" ""::~ """"::~ ~ :'''''''' '" '"

;0 "

"

"

;; ;; "

"

IT·'

o 1

"

"

'00' "

5

sa

52 REGNO l~

I
- J_ _ _ _

~~

____

:~':

" " " "
!

i

I

.

i

:

'\J
\

LO_6~~__________ L_~_U_ _L -_ _-L~-L____LL~_ _ _ _~-L~~_ _

~'inus ~~ro

.. " '" " ..

I

-~-+--+-----

1--0

o;~

Plus

'I!'

---R-----+-+-~_f_-+-+-+-+--f_+__H-_HH_+++_--'2'T'!~~~3"!_'13t_f.tu~5~oiNQ .. 4
~4+~---~~~--++rr--+rrH~~lS 2a ~CCTNO .. ~~

0

1-_2
o 3
I
o

§

To

I

~~c_~~~_·~ ~~~_ _:_.~

All portions of a split control field must be assigned the
same control level indicator.
Figure 7·22. Split Control Fields

Sequence Checking
To check the data in the fields of a record in one input
or update file for a special sequence, assign a value of
M 1 through M9 to the field to be checked. As many as
nine fields can be checked. The sequence (ascending or
descending) of the record file must be specified in
column 18 of the file description specifications (see
Chapter 3). See Figure 7 -23 for an example of
sequence checking.
To check the sequence of record types in a file, see
Columns 15-16 (Sequence) in this chapter.

COLUMNS 63-64 (FIELD RECORD RELATION)

Entry

Explanation

Blank

Columns must be blank for CONSOLE
files.

01-99

Record identifying indicator assigned
to a record type, or an indicator set
on elsewhere in the program.

L1-L9

Control level indicator previously used.

MR

Matching record indicator.

U1-U8

External indicator previously set.

H1-H9

Halt indicator previously used.

The following general rules apply to the use of columns
63 and 64:
• All fields, including match or control fields, that have
no field record relation indicator should be described
before those that do.
• All fields having the same field record relation
indicator should be defined on consecutive
specification lines for more efficient use of storage.
These fields can, however, be entered in any order.
• All portions of a split control field must be assigned
the same field record relation indicator and must be
defined on consecutive specification lines (see Figure
7-24). For more information on split control fields,
see Columns 59-60 (Control Level).
• When used with control or match fields, the field
record relation indicator must match a record
identifying indicator for this file, and the match or
control fields must be grouped according to the field
record relation indicator. The field record relation
indicator for control or match fields can only be 01
through 99 or H 1 through H9.
• When any match value (M1 through M9) is specified
for a field without a field record relation indicator, all
match values used must be specified once without a
field record relation indicator. If all match fields are
not common to all records, a dummy match field
should be used (se,e Figure 7-25).

Columns 63·64 (Field Record Relation)

7·39

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

'-Line

Filename

Field Name

An input file called MASTER is to be sequence-checked
through three fields. Data from two records is shown
below:
Data from First Record

Data from Second Record

DEPT
REGION
DIVSON

DEPT
REGION
DIVSON

008
051
003

003
025
005

Figure 7-23. Match Fields (Sequence Checking Within a File)

7-40

Input Specifications

In sequence checking, all fields are treated as one continuous field. Thus, the match fields look Iike:

Record 1
Record 2

.M3

M2

M1

003
005

051
025

008
003

The match field from record 1 is compared with the
match field from record 2. If the file is specified to be in
ascending sequence, the records are in order because
005025003 is higher than 003051008. However, if the
file is specified as having a descending sequence, record 2
is out of order.

FLD1A

FLDA

FLD1B

FLD2B

FLD2A

~
I

I

I

12345678

9

I

I

I

II

I

101"21314'51617'819~02'222324252G27282930313233J-lJ53G3i333940414243444546414849505152S354555657S8S9606162636 46566676869707172737475767778

Record identification code = 1

FLD1A

FLDA

I

FLD2B

FLDC FLD3B
~-

-"--"
I

I

123456789

I

I

II

I

FLD3C

~
I

FLD1B

II

II

II

~ -"--"-"3

4

5

"

6

7

8

9

~

"II

~

II

II

I

I

I

FLD2A

~ ~
I

I

"

1011 12131415161718192021222324252627282930313233343536 37 38 39 40 ~1 .124344454647.18 49 ~O 51525354555657585960616263646566676869707172 73 74 75 76 77 78

Record identification code
The record identified by a 1 in position 95 has two split
control fields:
FLD1Aand FLD1B
FLD2A and FLD2B

=3

The third record type, identified by the 3 in position 95,
also has three split control fields:
FLD1Aand FLD1B
FLD2A and FLD2B
FLD3D and FLD3E

The record with a 2 in position 95 has three split control
fields:
FLD1Aand FLD1B
FLD2A and FLD2B
FLD3A, FLD3B, and FLD3C

I

FLD3A

=2

FLD1B

FLD2B

FLD1A FLD3D FLDA FLD3E
:

FLDB

101112131415161718192021222324252627282930313233343536373339404142434445464748495051525354555657585960616263646566676869707172737475767778

Record identification code

1

FLD2A

-"'--'~ ~ ~ ~

All portions of the split control field must be assigned the
same control level indicator and all must have the same
field record relation entry.

Record Identification Codes
Field Location

Field

Figure 7·24. Field Record Relation (Split Control Fields)
Columns 63·64 (Field Record Relation)

7·41

M1
EMPNO
I

Three different record types are found in the input file.
All three contain a match field in positions 1 through 10.
Two of them have a second match field. Because M1 is
found on all record types, it can be specified without an
entry in columns 63 and 64. If one match value (M 1
through M9) is specified without field record relation
entries, all match values must be specified once without
field record relation entries. Because the value M1 is
specified without field record relationship, an M2 value
must also be specified once without field record relationship. The M2 field is not on all record types; thus a
dummy M2 field must be specified next. The dummy
field can be given any unique name, but its specified'
length must be equal to the length of the true M2 field.
The M2 field is then related to the record types on which
it is found by field record relation entries (lines 06 and
07).

I

123456789101112131415161718192021222324252627282930

Record identifying indicator 01

M2
DEPT

M1
EMPNO
I

~----

" I

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Record identifying indicator 02

M1
EMPNO
I

M2
DEPT

----

~•

•

.•

123456789101112131415161718192021222324252627282930

Record identifying indicator 03

Record Identification Codes

I

Field Location

f--0

Filename

Line

Position

~
0

Z

3

4

8

9

"

irl

e
13

Position

J

~
0

Z

0

N
U

I

Position

~
0

z

I
13

3i

0

B

"in

a:

From

To

--'

~

ii::

~
-.;

Field
Indicators

0

is
!J~
.~

:§

~

U-u-

8

~~

g

~

II>

(f)

Field Name

c

.~ r
-5 :~

:2u

""
~

'0
0

~

'0

Zero

Plus Minus or
Blank

0;

iZ

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

Ie
o 4
I
'-'-'- o 5
I
o

6

I

0 7

I

o

8

I

o

9

I

11

11

u
i

1111.."

IMlt.

M!2

Figure 7-25. Dummy Match Fields

(
7-42

Input Specifications

Record Identifying Indicators (01-99)
Use a record identifying indicator (01 through 99) in
columns 63 and 64 to relate a field to a particular record
type.
When several record types are specified in an OR
relationship, all fields that do not have a field record
relation indicator in columns 63 and 64 are associated
with all record types in the OR relationship. To relate a
field to just one record type, enter the record identifying
indicator assigned to that record type in columns 63 and
64 (see Figure 7-26).
An indicator (01 through 99) that was previously defined
in the program can also be used in columns 63 and 64
to condition movement from the input area to the
storage area. Control fields, which are specified by a
control level indicator (L 1 through L9) in columns 59 and
60, and match fields, which are specified by a match
value (M 1 through M9) in columns 61 and 62, can also
be related to a particular record type in an OR
relationship by a field record relation indicator. Control
fields or match fields in the OR relationship that do not
have a field record relation indicator are used with all
record types in the OR relationship.
When two control fields have the same control level
indicator or two match fields have the same matching
level value, a field record relation indicator can be
assigned to just one of the match fields. In this case,
only the field with the field record relation indicator is
used when that indicator is on. If none of the field
record relation indicators are on for that control field or
match field, the field without a field record relation
indicator is used. Control fields and match fields can
only have 01 through 99 or H 1 through H9 as the entry
in columns 63 and 64.

Control Level (L 1-L9), Matching Record (MR), and
External (U1-U8) Indicators
Columns 63 and 64 can also be used to specify that the
program accept and use data from a particular field only
when a certain condition occurs (such as matching
records, a control break, or an external indicator is on).
Indicate the conditions under which the program accepts
data from a field by specifying indicator L1 through L9,
MR, or U1 through U8 in columns 63 and 64. Data
from the field named in columns 53 through 58 is
accepted only when the field record relation indicator is
on.

External indicators are primarily used when file
conditioning is specified in columns 71 and 72 of the
file description specifications. However, they can be
used even though file conditioning is not specified.

Halt Indicators (H1-H9)
A halt indicator (H1 through H9) in columns 63 and 64
relates a field to a record that is in an OR relationship
and also has a halt indicator specified in columns 19
and 20.

COLUMNS 65-70 (FIELD INDICATORS)
Entry

Explanation

01-99

Numeric indicator

H1-H9

Halt indicator (when checking for an
error condition in the data)

Use columns 65 through 70 to check the condition of
the numeric fields. Use columns 69 and 70 to check the
condition of an alphameric field. These columns cannot
be used for a data structure. The three conditions are:
• Plus (columns 65 and 66). Any valid indicator entered
in columns 65 and 66 turns on if the numeric field
named in columns 53 through 58 is greater than zero.
• Minus (columns 67 and 68). Any valid indicator
entered in columns 67 and 68 turns on if the numeric
field in columns 53 through 58 is less than zero.
• Zero or blank (columns 69 and 70). Any valid
indicator entered in columns 69 and 70 turns on if a
numeric field named in columns 53 through 58 is all
zeros or if an alphameric field is all blanks. A
numeric field that is all blanks turns on an indicator
specified for zeros. However, if an alphameric field is
all zeros, the field does not turn on the indicator
specified for all blanks.

Columns 65-70 (Field Indicators)

7-43

FLOA

FLOB

~I

~
I
I

I

FLOC

~I

I

1 2 3 4 5 6 7 8 9 101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475

=5

Record identification c'ode

FLOA

FLOB

FLOO

~

~
I

I

~
I

I

I

I

I

I

I

I

I

I

123456789

101112131415161718192021222324252627282030313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475

Record identification code
The file contains two different types of records, one
identified by G 5 in position 1 and the other by a 6 in
position 1. FLDC is related by record identifying
indicator 14 to the record type identified by a 5 in
position 1. F LDD is related to the record type having a 6
in position 1 by record identifying indicator 16. This
means that F LDC is found on only one type of record

Filename

r--:~ i~ 1~ 1.~i'
OR

4

°

1

°

2

5

6

7

8

9

~~J

Position

zuu

ZOo:

r;N+oIti~::~"
..

10 11 12 13 14 15 16 11 la.

IREipolRil

Position

~~

1

Position

ZUU

I

AiA"I!"t-(

~ R(i 11 ~!>

07

°

9

r-c---

i C5

-+1- +t---+

Tl~f---f-----

l-Lr---Lt--+-+--t--+---+-+-I--+I
i I
-f--+-- -TLIt-ti

From

j j~ ~

Field Name

To

0

!

I

II

I

I

iii

J l2~

~

II ;

8

~u

a~

Iii I!

I

:!

!

1

i

FLlQL

Zero

Plus

Minus

~~ank

u..

-L~Q -t~ IF:Un'c.' I
'~~ -t-~Q -El.;~
. . . :::~r----r'r-LLt- j j I ~~ I
r-f--r--r-

'-_'--'-o----'---'--I---'----'--'---'-----'--'---'-----'-I_'----'- L--,---,--I..L...J
I---'-----'------'------'----'---..L...J'--'-----'----L-L----'---'-----'----'--I-'_'----'i.---L

· ~L----+

nIc
I :: i
~-t- ,~

I
: I
iii

I

c-

I

I
i

Iii), ~f--~---W-+--

__ ±'-17
'l'
!

I

'-_c-c-

i

Qk1~'- I i !
111~\
i ~ iii
11!~·i I VI i!

~
!

I

Iii

!

I I I~ I l1iQ -=!lDAi i

ri.+-r-r-i .:
J
'
---1- ---- -1- --1 :
I

1- _ _

I

i~;
~
1

J

ZUUU?Q..

-r-l

6

f---t-1-+I-t_f-+--+ __t--t-+-+-+.
0 B
f--+-t-t-I-+-+--+-+-+-t-t--t--t-

~~

0

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4(1 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 GO 61 62 63 64 65 66 67 68 69 70 71 72 73 74

.1. C~ !
l-o-t-3+-+-I-t-t-+-+-+-+--+--t-l-t--t-t-·>--+:I.-'~;r-t-f'-""-t-"'+""'-t-""'~--t-+--+--+l'_'-1-0+-4-t-+I++-+---+---t--1i------t-t---I-+-+-t---+_+-I_---+-t--t-_+--f-r---+
.......+r--.~
,
0 5
I
1-+ _Hf- +--t--I--+-+_+-ii-----+---+_-r-___ 1_ _ -- ----- -1-r--,.....r-I
1-_+-+-t-t--I--t-+-+-+-+-+ ___ ---r---r----- _
r-- . . . . r---....I
0

Field
Indicators

Field Location

5

Line

3

(that identified by 5 in position 1) and F LDD is found
only on the other type. F LDA is conditioned by
indicator 07, which was previously defined elsewhere in
the program. F LDB is found on both types because they
are not related to anyone type by a record identifying
indicator.

Record Identification Codes

I

=6

-!

il :

/I:
~.- r-r-

I_~

' :

i :
!

This indicator was specified elsewhere
in the program, and F LDA is made
available for processing only when
indicator 07 is set on elsewhere in the
program.
Figure 7·26. Field Record Relation

744

I nput Specifications

Assigning Indicators in Columns 65-70

Halt Indicators (H1-H9)

The following considerations apply to numeric indicators
and halt indicators:

Specify any halt indicator (H 1 through H9) in columns
65 through 70 to check for an error condition in your
data. For example, if a field should not be zero, specify
a halt indicator to check for that zero condition. If a
zero field is found, the halt indicator turns on and the
program stops after the record with the zero field has
been processed.

• Indicators for plus, minus, zero, or blank are off at
the beginning of the program. They are not turned on
until the condition (plus, minus, zero, or blank) is
satisfied by the field being tested on the record just
read.
• Columns 65 through 70 must be blank when table or
array names are specified in input specifications.
However, an entry can be made for an array element.
• A numeric input field can be assigned two or three
field indicators. However, only the indicator that
signals the result of the test on that field turns on;
the others remain off.
If the same field indicator is assigned to fields in
different record types, its status is always based on
the last record type selected.
• When different field indicators are assigned to fields
in different record types, a field indicator turned on
remains on until another record of that type is read.
Similarly, a field indicator assigned to more than one
field within a single record type always reflects the
status of the last field defined.

Indicators H1 through H9 cause the program to halt
after the cycle that caused the indicator to turn on is
complete (all calculations and output for that cycle are
complete). The operator can restart the system by
responding to the system halt.

COLUMNS 71-74
Columns 71 through 74 are not used. Leave them blank.

COLUMNS 75-80 (PROGRAM IDENTIFICATION)
See Common Entries in Chapter 1.

Field indicators assigned in these columns can also be
set on or set off by SETON or SETOF operations in the
calculation specifications.

Numeric Indicators (01-99)
Use numeric indicators 01 through 99 to test a field for
a condition of either plus, minus, zero, or blank. The
indicator specified turns on if the condition is true; it
remains off or turns off if the condition is not true.
Usually these same indicators are used to control certain
calculation or output operations. See Columns 9-17
(Indicators) in Chapter 8, Calculation Specifications or
Columns 23-31 (Output Indicators) in Chapter 9, Output
Specifications.

Columns 75-80 (Program Identification)

7-45

7-46

Input Specifications

Chapter 8. Calculation Specifications

Calculation specifications describe the calculations you
want performed on your data and the order in which
you want the..m performed. Each calculation
specifications statement can be divided into three parts:
• When the operation is to be performed (columns 7
through 17). The indicators entered in these columns
determine under what conditions the specified
operation is' to be done.
• What kind of operation is to be performed (columns
18 through 53). Entries in these fields describe the
kind of operation to be done and specify the data
upon which the operation is to be performed.

RPG

IBM

• What tests are to be made on the results of the
operation (columns 54 through 59). The indicators
entered in these columns signal the result of the
operation and can be used to condition other
operations.
Calculation specifications must be specified in the
following order: detail, total, subroutine.
Write these specifications on the RPG Calculation
Specifications sheet (see Figure 8-,1).

Form GX21-9093

CALCULATION SPECIFICATIONS

International BUSiness Machine Corporation

1

Program

Page
Programmer

c

Date

~

r----

g

Indicators

Result Field

Line

~

~e

Factor 1

5

Operation

Factor 2
Name

8 5'

~

6

7

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

4

a

1

a
a

2

C

3

C

a

4

C

a 5

C

g ffi~I-r-'-+-'---r-+-T"""'T--l

Length

~
~

3

8

75 76 77 78 79 80

Resulting
Indicators

Arithmetic

8..3 ~

.

2

[]JOf_ ~~~~;:f:ation I I I I I I ]

a
Z

a
Z

Plus IMinusl Zero
Compare
1 >211 <211 :2
LookuplFactor 2)is
High Low Equal

Comments

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

C

a

6

C

a

7

C

a

8

C

a 9

C

I ....

~

Conditions r--.
1""';'-+-;-;"-+-;-;"-+-';-;''';-;''''';''''';'

0 pe rat ion s
·-Tests-~

1 laC
1 1

C

1 2

C

1 3

C

1 4

C

1 5

C

1 6

C

1 7

C

1 8

C

1 9

C

2 a

C

C
C
C
C
C

Figure 8·1. RPG Calculation Specifications
Calculation Specifications

8·1

COLUMNS 1-2 (PAGE)
See Common Entries in Chapter 1.

COLUMNS 7-8 (CONTROL LEVEL)
Entry

Explanation

Blank

Calculation operation is done at
detail calculation time for each
program cycle if the indicators
in columns 9 through 17 allow it;
or calculation is part of a
subroutine.

LO

Calculation operation is done at
total.calculation time for each
program cycle after total
calculation processing has
started.

COLUMNS 3-5 (LINES)
See Common Entries in Chapter 1.

COLUMN 6 (FORM TYPE)
A C must appear in column 6 to identify this line as a
calculation specifications statement.

Note: If no control levels
are specified on the input
specifications, total calculation
time processing starts during the
second program cycle. If control
levels are specified on the input
specifications, total calculation
time processing starts during the
program cycle after the first
record containing control fields
is processed or at LR time.
Totals are always processed
at LR time.

8-2

Calculation Specifications

L1-L9

Calculation operation is done when
the appropriate control break occurs
at total calculation time.

LR

Calculation operation is done after
the last record has been processed.

SR

Calculation operation is part of
a subroutine. A blank entry is
also valid for calculations that
are part of a subroutine.

AN, OR

Establishes AND and OR relationships
between lines of indicators.

Use columns 7 and 8:
• To perform total calculation operations when the
appropriate control break occurs.
• To perform calculation operations that are done only
after the last record has been read.
• To indicate that an operation is part of a subroutine.
However, columns 7 and 8 can also be blank for
calculations that are part of a subroutine.
• To specify that certain lines of indicators are in an
AND/OR relationship.

Control Level Indicators (LO, L1-L9)
The LO indicator is on during the entire program. You
need never assign this indicator, but you can use it to
condition operations, especially when no control fields
have been assigned. When a control break occurs, all
operations conditioned by control level indicators are
done before those that are not conditioned. If no
control field is assigned, but total calculations are to be
done and total output records are to be written, use the
LO indicator to condition those operations (see Figure
8-2).
Use a control level indicator (L1 through L9) to specify
that the operation described on the same specification
line is done only when that indicator is on. A control
level indicator turns on when information in a control
field changes. See Columns 59-60 (Control Level) in
Chapter 7, Input Specifications.

Last Record Indicator (LR)
For a primary file, RPG II sets on the last record (LR)
indicator after the last record is read and processed (end
of file has occurred). For a WORKSTN file specified as
a primary file, end of file, which causes RPG II to set on
the LR indicator, occurs:
• When all display stations have been released (by an
R in column 16 of the output specifications or by the
REL operation code) if the program does not have an
N EP attribute.
• When all display stations have been released and the
operator has entered the STOP SYSTEM command if
the program has an NEP attribute.
However, under the following conditions, the
programmer must set on the LR indicator:
• If the program contains no primary file
•

If KEYBORD is specified as the device for a primary
input file

If certain operations are to be done only after the last
record is read, condition these operations with the LR
indicator. Specify the operations conditioned by LR after
all calculations conditioned by LO through L9 (columns 7
and 8) or after detail calculations if there are no total
calculations. The last record turns on the LR indicator
and all other control level indicators specified (L 1
through L9).

A control break for a certain level turns on all lower
control level indicators. Thus, if indicators L3, L2, and
L1 are used in a program and L3 turns on, L1 and L2
also turn on. All operations conditioned by L3, L2, and
L1 are done.
However, when a control level indicator used as a
record identifying indicator turns on to indicate the type
of record read or when the SETON operation turns on a
control level indicator, only that one control level
indicator turns on. All lower level indicators remain
unchanged.
Note: In one program cycle, all operations conditioned
by control level indicators in columns 7 and 8 are done
at total calc~lation time. Operations that are conditioned
by control level indicators in columns 9 through 17 are
done at detail calculation time immediately following the
control break (see Relationship Between Columns 7-8 and
Columns 9-17 in this chapter).

Columns 7-8 (Control Level)

8·3

The input records have ITEM and COST fielas and a oneposition record identification field. The records are grouped
in ascending sequence by district; that is, the district 1
records as a group are followed by a blank record, and the
district 2 records as a group are followed by a blank record.

No field can serve as a control field because the district
number is not on the records. Instead of a control field,
the blank record is used to signal a new district. When the
blank record is read, indicator 02 turns on. The blank
record tells the program that total calculations and total
output operations must be done. However, no total operations can be performed unless they are conditioned by
some kind of control level indicator.
Even though LO is on all the time, it must be used in
columns 7 and 8 because some type of control level indicator must be assigned to all total operations.

I

- /District 4 records

...........---~

District 3 records

~
I,I---~'" - - - - . /oistrict
~
/

Figure 8-2 (Part 1 of 2). Use of the LO Indicator

8-4

Calculation Specifications

"District 1 records

2 records

Input Specifications
Record Identification Codes

I

-g

Filename

Line

&
3

4

1

0

2

0

3

o

4

o

5

5

6

7

8

9

-

Position

~

e

E

Position

go

~

~

~~6

u u

§

Zero

From

To

Plus Minus or
Blank

Jji

10 11 12 13 1415 1617 18 19 20 21 22 23 24 2526 27 28 29 3031 3233 3435363738 3940 4142 4344454647 48495051 52 53 54 55 56 57 58 59 60 61 62 6364 6566 67 68 69 70 71 72 73 74

IltNlp IUh'
I
I I
I II
I Ii i
;

z

Field Name

-;;

-~ e ~~
; t:: .2

Position

....--....o R
f-;"Nfo
0

Field
Indicators

Field Location
3

2

1

I--

I I Ij lei

~1

AlA

I

!

I

gB

I

!

i

I

i

i

~ I
:I

f42
I

I

I

\

1

fa

!

l15 2CO1ST

2~

11 Ie

l1G1 liT E~
I

I

The program shows how total operations can be per·
formed even though there is no control field (no L 1
through L9 indicators).

The program requires:
o A list of items sold in each district
•

A total of all sales for each district

•

A grand total of all sales in all districts

Calculation Specifications

C

Indicators

~.

0_

I---Line

Indicators

Arithmetic

AL At

.Jcr:

=0

~.5~
I- "0 a:

Resulting

Result Field

Operation

Factor 1

0
;:;

Factor 2

0;

Length

Name

E

~ ~; ~
3

4

0

1

c

o

2

C

o

3

C

o

4

c

5

6

7

8

o

5

cL~

o

6

CL~

o

7

i

~

z
z
0
9 10 1112 1314 1516 1718 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

C

~l1

tosri"

t112

D~

sir OIT

lAJDt)

Dl SllloT

IDI SITId1 ' '12

~IDI])

GID TOT

~n

~DID

Dlt 511 oh'

~ID \ 0

torr

r' ""
~~ ~
~

Filename

line

Output Indicators

~~,.!:.

~

ADD
~
OR'"

~'N'D
7

8

9

L

Jd

~I- f--

6

Comments

Compare

5455 56 57 5859 60 61 62 63 64 65 66 61 68 69 70 71 72 73 74

IGllJ TOT

1

i

o

5

Plus IMinusl Zero
1 >211 <211 ~2
Lookup(Factor 2)is
High Low Equal

~[2

Format of the
Printed Report

Output Specifications

-

0

~

~~
211<211=2
Lookup(Factor 2lis

HIgh low Equal
'8 '9 20 2' 22 23 24 25 26 27 2829 30 3' 32 33 34 35 36 37 38 39 40 4, 42 4344 45 46 47 48 49 5051 5253 5455 56 57 5859 hO 61 6'2 63 64 &5 66 67 68 69 70 71 7'2 73 74

~2 ~-"1
~~ ~3

5

f~ !E!L D,A

S:UB

Fl EL 1)6

c

'~

GlrrV

23

Gl

I

I

C

0 6

.g

Factor 2
Name

c
cAN
COR
cAN

0 3
0

Arithmetic

AL AL

~

Line

Resulting
Indicators

Result Field

AN and OR entries group lines of indicators. When
indicators 01, 02, 03, and 04 are on, or when indicators
01,02, 03, and 05 are on, the calculation is performed.

Calculation Specifications

C

0_

E

4

0

1

.g I

Factor 2
Name

5

8

6

7

c

LfLt

~

C'"'R

o

cr\ all

0 4

C

0 5

C

~~
~ ~
~ ~

a

0

z

Length

z

o

I

Plus IMinusl Zero
Compare

Comments

1>211<211-2
LookuplFactor 21i,
High

Low Equal

910" '213 1415 1617 18 19 20 21 22 23 24 25 26 '27 2829 30 3' 32 33 34 35 36 37 38 39 40 41 42 4344 45 4647 48 49 5051 5253 5455 5657 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

0 2
3

Operation

Factor 1

!:; Ul

8 5-

Indicators
Arithmetic

I-

~

Resulting

Resull Field

AL At

...Ja:

=0

~~~
"'0 a:

Line

3

Indicators

~

!----

~

'le ~~ 3

~

Il~ IQ

~~ I~M!'

~~

3 SllM

l4"D
i

I
I
SIU M!rOT
I
I

I

Su 'I'll 0[1

~2H

Three conditions cause the L4 total calculations to be
performed: 01 and 02 are on, but not 03; or 01 and 03
are on, but not 02; or 02 and 03 are on, but not 01.
Figure 8-3. Use of AND/OR Lines for Indicators

Columns 9-17 (Indicators)

8-7

Calculation Specifications

C

Indicators

~

Result Field

At At

Factor 1

Operation

Name
0

Z

4

b

Z

Length

C

0 2

Cl

0 3

c

0 4

C

~

Compare

Comments

1>211<211~2

Lookup(Factor 2)is

b

z

High

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

5

0 1

Low Equal

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

25 L!

ld tJL3

Assume that indicator 25 represents a record type and
that a control level 2 break occurred when record type
25 was read. L1 and L2 are both on. All operations
conditioned by the control level indicators in columns 7
and 8 are performed before operations conditioned by
control level indicators in columns 9 through 17. Thus,
the operation in line 02 occurs before the operation in
line 01. The operation in line 01 is done on the first
record of the new control group indicated by 25, whereas
the operation in line 02 is a total operation done for all
records of the previous control group.
Figure 8-4. Conditioning Operations (Control Level Indicators)

8-8

Plus1Minusl Zero

Factor 2

Line

3

Resulting
Indicators
Arithmetic

Calculation Specifications

The operation in line 02 can be done when the L2
indicator is on provided the other conditions are met.
Indicator 10 must be on. The L3 indicator must not
be on.
The operation conditioned by both L2 and N L3 is done
only when a control level 2 break occurs. These two
indicators are used together because this operation is not
to be done when a control level 3 break occurs, even
though L2 is also on.

Input Specifications
Record Identification Codes

I
"--

0

'"0

Filename

line

~

(;

:

Position

~ §u uj

Position

~~ ~

Z

AND

0

Iii

From

a
a

1

I [ IIM~

2

I

3

I

~

4

I

ij~

5

I

1211

6

I

7

I

a

Zero
Plus Minus or
Blank

~
~

4

a
a
a
a

-.;

u:

To

3

6

7

~

o ~u

~u6

z

f--f-

Position

"0

Field Name

-.;

...--...o R
5

Field
IndicJtors

Field Location
3

2

1

B 910111213 1415 1617 18 19 20 21 22 23 24 2526 27 28 29 30 31 3233 34 35 36 37 38 39 40 4142 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6364 6566 67 68 69 70 71 72 73 74

~Ie

~11

~

11
1~ ~

2

EM plL ~t.lb

l'··' ....>

~e RT~

1~IIIl::

I..

lit:

11:1
·"l/,t

O~

J
L/

!/

~!I'

V

Field indicators can be used to condition operations.
Assume the program is to find weekly earnings including
overtime. The overtime field is checked to determine
whether any overtime was put in. If the employee has
worked overtime, the field is positive and indicator 10
turns on. In all cases the weekly regular wage is calculated. However, overtime pay is calculated only if indicator 10 is on (calculation lines 02 and 03).

Cal culation Specifications

C

Indicators

"--

Arithmetic

At At

Factor 1

Operation

Factor 2
Name

line

5

a
a
a

2

c
c

·'.i

3

C

.i

a
a

4

C

5

C

a

6

C

>i\

RIA s:

.\,

fa ITil',.
1 i1l l)

.A.

1\1

.:.

-

....
Klll1

\alIA E

i

·:'1:"

:s

Plus Minusl Zero

~

1>211<211=2

~

0

4

1

Length

Z
Z
9 10 1112 13 14 15 16 17 18 19 20 21 22 2J 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

Z

3

Resulting
Indicators

Result Field

'"

UT

I~u
4~
~u ILIT
irE_Ilor
....
I~~~
I
VII::I'll

RA

!

~IA 6E
lol\J S;R P'I
ITIO T~L

r.

Compare

Comments

Lookup(Factor 2)is
High

Low Equal

53 54 55 5657 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

iJ

I"

~

'-

Field indicator 10 was assigned on the input specifications. It is being used here to condition calculation
operations.
Figure 8-5. Conditioning Operations (Field Indicators)

Columns 9-17 (I ndicators)

8-9

Input: Specifications
Record Identification Codes

I

Field
Indicators

Field Location

'-Filename

Line

Field Name

....>

Position

Position

Position

From

Zero
Plus Minus or
Blank

To

j
5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

01

IFIL~

o

2

I

o

3

I

o

4

I

o

5

I

!all

OR

l1 crt

!NCIT
11

A record identifying indicator is used to condition an
operation. When a record is read that has a T in position
1, the 01 indicator turns on. If this indicator is on, the
field named SAVE is added to SUM. When a record
having no T in position 1 is read, the 02 indicator is on.
The subtract operation, conditioned by 02, is then done
instead of the add operation.

Calculation Specifications

C

Indicators

~.

~

~I

~ j

Line

4

0

5

1

C

0 2

C

0 3

c

0 4

C

0 5

C

Operation

0;
Z

SuM
5UI~

Ann

sue

SA VE
S~ VIE

II/IX

"-

"

--

Record identifying indicators 01 and 02 are assigned on
the input specifications. They are used here to condition
calculation operations.
Figure 8-6. Conditioning Operations (Resulting Indicators)

8-10

.g

Factor 2
Length

I

~~

~ ~
~ -;
Q
J:

Plus IMinusl Zero
Compare

Comments

1>211<211=2
LookuplFactor 2)is
High

Low Equal

13 14 15 16 17 18 19 20 21 22 13 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 4344 4S 46 47 48 49 50 51 52 53 5455 5657 58 59 GO 01 62 63 64 65 66 67 68 69 70 71 72 73 74

7·j

6

Factor 1

Name

.L§Q
3

Indicators

Arithmetic

At At

.... "0
E ;.

Resulting

Result Field

Calculation Specifications

SUM
su~

a~

gl2

Resulting Indicators (01-99)

External Indicators (U1-U8)

Use any resulting indicators specified in columns 54
through 59 on the calculation specifications to condition
operations according to the results of calculation
operations. See Columns 54-59 (Resulting Indicators) in
this chapter.

Use any external indicator previously specified to
condition which operations should be done and which
files should be used for a specific job. If a file is
conditioned by an external indicator, any calculations
that are to be performed only on that file should be
conditioned by the same external indicator.

Control Level Indicators (L1-L9)
Overflow Indicators (OA-OG, OV)
Use any control level indicators that are specified in
columns 59 and 60 of the input specifications or in
columns 54 through 59 of the calculation specifications.
If control level indicators are used in these columns but
not in columns 7 and 8, the operation is performed at
detail calculation time on the first record of a new
control group or whenever the indicators are on.

Last Record Indicator (LR)
To condition operations to be performed at end of job,
use the last record (LR) indicator in columns 9 through
17 only if LR is turned on during calculations. All
operations to be performed at end of job should be
conditioned by LR in columns 7 and 8.

Matching Record Indicator (MR)
Use the matching record (MR) indicator to condition an
operation that is to be done only when matching records
are found. See Columns 61-62 (Matching Fields) in
Chapter 7, Input Specifications for more information on
matching fields.

Halt Indicators (H1-H9)
Use any halt indicators that are specified in columns 65
through 70 on the input specifications or in columns 54
through 59 on the calculation specifications to prevent
the operation from being done when a specified error
condition is found in the input data or during
calculations. See Columns 19-20 (Record Identifying
Indicator) in Chapter 7, Input Specifications. Using a halt
indicator is necessary because the record that causes
the halt condition is completely processed before the
program stops. Thus, if the operation is performed on
an error condition, the results are in error. A halt
indicator can also be used to condition an operation that
:~ to be done onl',' when an error occurs.

Use any overflow indicators that are specified in
columns 33 and 34 of the file description specifications
to condition operations that are to be done when the
last line to be printed on a page is reached. See
Overflow Indicators in Chapter 9, Output Specifications,
for more information.

Relationship Between Columns 7-8 and Columns
9-17
In one program cycle, all operations conditioned by
control level indicators in columns 7 and 8 (total time)
are done before operations conditioned by control level
indicators in columns 9 through 17 (see Figure 8-4).
When a control level indicator is used in columns 9
through 17 and columns 7 and 8 are not used (detail
time), the operation conditioned by the indicator is done
only on the record that causes a control break or any
higher-level control break.
When a control level indicator (L 1 through L9) is
specified in columns 7 and 8 (total time) and MR is
specified in columns 9 through 17, M R indicates the
matching condition of the previous record and not the
one just read that caused the control break. After all
operations conditioned by control level indicators
(specified in columns 7 and 8 of the calculation
specifications) are done, MR then indicates the matching
condition of the record just read.

Note: The system message displayed on a halt can be
overridden by a user message member. (See User
Message Member in Chapter 10, Operation Codes.)
Columns 9-17 (Indicators)

8-11

COLUMNS 18-27 (FACTOR 1) AND COLUMNS 33-42
(FACTOR 2)

The following entries can be made for factor 2 only:
• A label for a GOTO or EXSR operation

Use columns 18 through 27 and 33 through 42 to name
the fields or to give the actual data (literals) on which an
operation is to be performed. See Figure 8- 7 for a
summary of the operation codes.

• A filename for a SET, CHAIN, DEBUG, READ,
FORCE, ACO, REL, or NEXT operation
• A subroutine name for an EXIT operation

The entries you can use for factor 1 and factor 2 are:
• An array name for an SORTA operation.
• The name of any field that has been defined
• Any alphameric or numeric literal
• Any subroutine, table, array name, or array element
• Any date field name (UDATE, UMONTH, UDAY,
UYEAR)
• The special names PAGE, PAGEl, PAGE2, PAGE3,
PAGE4, PAGE5, PAGE6, orPAGE7
• . Any figurative constant (*BLANK, *BLANKS, *ZERO,
*ZEROS)
The following restrictions apply to entries in factor 1 and
factor 2:
• A data structure name cannot be specified in factor 1
or factor 2.
• A data structure subfield name can be used in factor
1 or factor 2; however, overlapping subfields in a
data ·structure cannot be used in the same
calculation. A subfield is considered to be an
overlapping subfield if its from or t~ position occurs
within the from and to positions of another subfield
within the same data structure. If factor 1, factor 2,
or the result field references a subfieldin a data
. structure that is an array or array element with a
variable index, the entire array is used to determine
whether overlap exists. The same array name can be
referenced in the appropriate factors of a calculation
specification without violating the overlap rule. See
Figure 8-8 for examples of the overlap rule.
• Figurative constants cannot be used with move zone
operations, bit operations, or the SET, KEY, SORT, or
DEBUG operation codes.
The following entry can be made for factor 1 only:
• A label for a TAG, BEGSR, or ENDSR operation

8-12

Calculation Specifications

An entry in factor 1 must begin in column 18; an entry
in factor 2 must begin in column 33.
Entries for factor 1 and factor 2 depend upon the
operation code used in columns 28 through 32. Some
operations require entries in both factors, some require
entries in only one, and some require no entries at all.
See Columns 28-32 (Operation) for more information on
operation codes. For information on how to name a
subroutine, see Subroutine Operations in Chapter 10,
Operation Codes.
Literals
A literal is the actual data used in an operation rather
than the field name representing that data. A literal can
be either alphameric or numeric.

Alphameric Literals

Consider the following rules when using an alphameric
literal (see Figure 8-9):
• Any combination of characters can be used in an
alphameric literal. Blanks are also valid.
• The maximum length of an alphameric literal is 8
characters.
• Alphameric literals must be enclosed in apostrophes

n.
• An apostrophe required as part of a literal is
represented by two apostrophes. For example, the
literal O'CLOCK is coded as 'O"CLOCK'.
• Alphameric literals cannot be used for arithmetic
operations.

Numeric Literals

Figurative Constants

Consider the following rules when using a numeric literal
(see Figure 8-9):

The figurative constants *BLANK, *BLANKS, *ZERO,
and *ZEROS can be specified as literals. The following
rules apply for figurative constants:

• A numeric literal consists of any combination of the
digits a through 9. A decimal point or sign can also
be included.
• The sign (+ or -), if present, must be the leftmost
character. An unsigned literal is treated as a positive
number.
• The maximum total length of a numeric literal is 10
characters including the sign and decimal point.
• Blanks cannot appear in a numeric literal.
•

Numeric literals must not be enclosed in apostrophes

n.
• Numeric literals are used in the same way as a
numeric field.

• The figurative constants *BLANK and *BLANKS can
only be used with alphameric fields.
• The figurative constants *ZERO and *ZEROS can be
used with either alphameric or numeric fields.
• The length of the figurative constant is assumed to
be equal to the length of the other factor field, if
present. Otherwise, the length of the figurative
constant is assumed to be equal to the length of the
result field.
• Figurative constants are considered to be elementary
items, and, if used in conjunction with an array, act
like a field. For example:
MOVE *ZEROS ARR
If ARR has 4-character elements, each element of
ARR contains '0000' after the move is executed.
• After a figurative constant has its length set, the
figurative constant's logical placement in the collating
sequence can be altered by specifying an alternate
cQUating sequence.

Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2)

8-13

Control Level
Indicators
Operation
Code
7-8

Conditioning
Indicators

Resulting Indicators

Columns
9-17

Factor 1

Factor 2

Columns

Result
Field

54-55

56-57

a

a

a

58-59

ACQ

a

a

R

R

ADD

a

a

a

R

R

BEGSR

SR or blank

BITaF

a

a

R

R

BITaN

a

a

R

R

CHAIN

a

a

R

R

a

caMP

a

a

R

R

03

03

03

DEBUG

a

a

a

R

0

DIV

a

a

a

R

R

a

a

a

ENDSR

SR or blank

a

a

R

EXCPT

a

a

EXIT

a

a

R

EXSR

a

a

R

a

R
R

FORCE

GaTa

a

a

a

1

a

a

a

LaKUP
(Array)

a

a

R

R

LaKUP
(Table)

a

a

R

R

a

MHHza

a

a

R

R

MHLza

a

a

R

R

MLHza

a

a

R

R

MLLza

a

a

R

R

KEYnn

Figure 8-7 (Part 1 of 2). Operation Codes

8-14

Calculation Specifications

a
R

a

a

0

04

04

04

04

04

04

Control Level
Indicators
Operation
Code
7-8

Conditioning
Indicators

Resulting Indicators

Columns
9-17

Factor 1

Factor 2

Result
Field

Columns
54-55

56-57

58-59

MOVE

0

0

R

R

MOVEA

0

0

R

R

MOVEL

0

0

R

R

R

R

0

0

0

R

0

0

0

MULT

0

0

MVR

0

0

NEXT

0

0

R

POST

0

0

R

READ

0

0

REL

0

0

0

R
R

0
02

R
R

R

RLABL
SETnnl

0

0

0
R

0

0

0

0

0

0

0

03

03

03

03

SETOF

0

0

03

SETON

0

0

03

SETLL

0

0

SHTDN

0

0

SORTA

0

0

R

SQRT

0

0

R

R

SUB

0

0

R

R

0

0

0

R

R

03

03

03

03

03

03

TAG

0

TESTB

0

R

R
R

0
R

0

0

0

R

10

0

R

XFOOT

0

0

R

R

0

0

0

Z-ADD

0

0

R

R

0

0

0

10

0

R

R

0

0

0

TESTZ
TIME

Z-SUB

lThe nn entries in columns 31 and 32 are for message indicator numbers. If the result field of a SET
operation contains the keyword ERASE, factor 2 must contain the name of the CONSOLE file.
Otherwise, factor 2 and the result field must be blank.
2Columns 56 and 57 can contain an indicator when the READ operation is used with a WORKSTN
device.
3At least one resulting indicator must be specified in columns 54 through 59.
4At least one resulting indicator must be specified in columns 54 through 59, but no more than two can
be used.

Fields without entries must be blank.

o
R
SR

Optional
Required
The only allowable non blank characters in columns 7 and 8 for the BEGSR and ENDSR operation
codes.

Figure 8-7 (Part 2 of 2). Operation Codes

Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2)

8-15

Input Specifications
Record Identification Codes

I

r-'"
D

Filename

Line

~

(;

:

~ §I

Position

-f-,.-

o

3

4

o

1

5

It) ~T ~DS

6

o

2

I

o

3

I

o

4

I

o

5

I

o

6

I

o

7

I

o

B

I

o

9

I

1 0

I

11

I

7

8

Position

-~ e

E

o~

Position

~

~~

~ U

zuu

z u u

R

"A'Nto

Field Name

Q;

~

Iii

To

From

D~

~

16

11

,

11

~
'1

1
1

2~

Is

I

7

1 4

I

*11

1 5

I
I

1 B

I

1 9

I

2 0

I

5 IAILP ~
IAILP IA2
IAL PW ~
~IL

PH IA

~ltP ~

INU Ml
NUM

I

I

·c
.;;;
<5

HOM

1 2

1 7

Q;

u:

I

I

I

I

AA ~Il
ARR

The data structure DATADS contains subfields
and arrays that are defined as overlapping (that
is, occupying part of the same area). ARR1 (on
line 12) has six elements, and each element is
five positions long for a total length of 30. ARR2
(on line 13) has five elements, and each element
is six positions long for a total length of 30.

I

I

tN VM;;

i

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

1

I

I

1

I

I

I

I

I

I

1 1 I I

Figure 8-8 (Part 1 of 3). Examples of Valid and Invalid Calculations with Overlapping Subfields in a Data Structure

8-16

Zero
Plus Minus or
Blank

9 10 11 12 13 14 15 16 17 18 19 20 2122 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 5 1 52 53 54 55 56 57 5 8 59 60 61 62 6364 65 66 67 68 69 70 71 72 73 74

1 3

1 6

Field
Indicators

Field Location
3

2

1

Calculation Specifications

Calculation Specifications

C

-

Indicators

Resulting

Result Field

Indicators

ArithmetiC

At AL

Operation

Factor 1

Factor 2
Name

Line

Length

Plus IMlnus Zero
Compare
1>2/1<21·2

Comments

Lookup(Factor 2hs
4

5

o 1i

c

I

I

C

C

'

04

1 C

,

I

I

do not overlap.
I I I I I
t":

,

I '

~~-

c r

5 i

~7,! ~ -~

--+-

i

:

J~--r-+-

+-H

ii'

1

'

i

I

I

I:

I

-;-rtTt -t-H-

~T~--t----~r:--rrN!U_MjJ
I

~i:I~'
~G

-1-1-- --

1 2

C

1!3!

c

II

-it
-ll

114

C

1

I

5

C

t

1f6

I

!

t-t-

-1t+
!

54

Low Equal

~,5 ~16

~,9

57 58

GO 61

r,~

63 £)4

f,r)

I'

1

1

,

r,q

(16 67 GR

I I I I I

~

1

,i
!
~~~E ~!A',ftM

o~'/ic -ADplH~,' ,2

T

1

i

1

w

71

n

73 74

!
!

-+-I--+-+-1H--+-+~

! '

I

I

G-+

-

f--:-- -i--I--t-1f-+-'1--t--/--t-1--t-r-f-1f-+-..;..1-+-t--+-+'--,-i-+-_~!
:' ::
! I
Ii!

1

1

'~LlPH1~ -~i 1- -t-+--t-t--t---1f-t-t--+-+-+-f--~--+-+-i-+-:-+-+--l

A:L:PWAJl :

i!-

-r;---i-.II-+-"+---+--l-+--:-I-+

!

NoIM+ !
I
I
~~~=I~D~nl~l~+-I[+-I~~FN~V~~¥i~~!~:~~~~~~~~~~~~I~
N'

[",

,,"0,,/16 \T

II

I

--tJj +~ __ ,- M1oiv: ~_ AL~ti~J.

'I

A'f..P'HAB I
•
A'RR.lJ . DC.I-+-+-I--t--+-H-+-+--++-++-+-+-++-+-+-+-+-+-+-~

-rr

1 I Ii'
!
'
I
i I Ii!
!
i
i-- ---r----:,-+-+-+-+--H-+-1--+-H--H-+-++-+--II--i-++-+-H---H-+--H--+-H---H-l---+-+-+-+-+-H-H
The following individual calculations are valid because the subfields .1-+-+-+-+-+-+[-+-1-+-~f-+-1--t---l
are determined to be the same area, and execution will not cause
invalid results.

tt'

I

i'

C

I

'-t-t--/-I~+-'i'----f--

~

Iii

1

, ' - --

-1-----I
117
C l
1 s - C

1 T T TTl

1~~~~M~~~,~~~i~;+I~~N~[~~~~:F~~!~I~~~~~:~I-+-~--+-+'~_~!I~--+-+~

Ii:

+_~ I

I!

~T

-

i~!

+-

[I 1 1 T 1 T T T

-1-AiDrot~-NiUMi4r!

II~'~:

ois'c:

33 34 3S 3G 37 J8 39 40 41 47 4344 45 40 41 4F1 49 5051

T't- The following individual calculations are valid because the subfields
1

,

o

n n 14 25 ']6 'l7 2829 3031 32
I I I I I I I I II I I [

15 ,G 17 18 19 10 11

I

- ' - -;-~

2 I

3

High

Z

Z

9 10 11 12 13 14

r--t-r-- o
o

0

0

0

Z
3

--

iT ~4-'-I-+-II+I~~++I~~~~~~-l---++I~~I+4~~

*

I

2~~~_~_l~i~r-+-+~!+i'+-+~++~~+4~-~+~-l---++4-~+-+-+-H-+4-l---++~H-+-+-+-H--~-l---~-+-+-+~~+-+~

r

iii
I
-~l-~--,t
210

1

C

c

I

--"

- -- - f -

,:

,I

1

-+--

I

I

I:

I

.u'

I'i,U ('Ill~

tt10vE AL.P"'~
~LP"V~~
ElAll~~P+'I-I~~~S++-+--f-!A'f-!=I..+-,-Pf!-!-HpA~2.~-H-H-+-++-++-+-+-++++-I-+-I-++++++-H

Mt'\V
IAD-"

.. ,I.~I.,,'::l

NV"'-=-

f-++-+--l"'ut-~:tJoIJG-+--IHI1-~IU~IIT~'~-'"'''+-l---H-+-+-i!Jj=f!--I'I~-H-+-++-+--1f--++-+-+-H--+--1r-++-+-+-+-+-+-r----+-+-L-+--I
r- +-t--+-t-H-t-t-t-+-f2=-t---fA~~1>f":tipNcpUrlM-¥a'G-+-HH--HUN~u~IN~1:24-t-f-+-+-+++-+-Hf-+-+-++++-l-+--+-++'+-+-+-1--+-+--I
U!"'l

I

i

1

-,

1 __

-=- _r- --I

it~ ~ -11f-f--W-- ~ ~ -i+
f-

-H--

f+ ~ T --~---H-1<'
1

I

-t-

1

:

-I--f- - f - 7

~

The following individual calculations are invalid b:Cause the subfields
occupy part of the same area, and execution could cause invalid

res~lts.

I

t-+-+--!-+--I++-+-1-+--++-+--,H

1

I

:

_+1-----+-+--~+-+-+--I-+-+-+-+++-+-+-++-+-+-+-+-++-+++-+-+-+-+-+--+-+--~+-+-+-+--+-+-+-l---l--l-[++-+--l---l---l--l---t-~
1

I--f--

-

--

- -

Mb "IE lAL !PI-I ~

!At. PH ~I~

~IDD

NU ~2
lNo rv4

MIO VE L~ ,L.P !I-llc\;~

NtJ N2.

A:n tiN UMS
t':NI~
ADn tN
Ii!
all'
ct
~.

lL It Ot 69 89 £9 99 ~9 V9 £9 Z9 19 0965

as

lS 9S SS tS £5 lS LS OS 6.

it 9" Iii"

ZOO Lt 00' 6C

at

IAL PH AI...

H\I Nit
ac

Lt 9C SC l't CC lC Lt

-

---

6l Sl lZ 9Z SZ 17l tZ ZZ LZ OZ 61 aL iL 9L 5L tL tL ZL LL OL

6

8

l

9

Iii

"

elL

Figure 8-8 (Part 2 of 3). Examples of Valid and Invalid Calculations with Overlapping Subfields in a Data Structure

Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2)

8-17

Calculation Specifications
Indicators

Resulting

Result Field

Indicators

Arithmetic

At AL

Operation

Factor 1

Plus IMinusl Zero

Factor 2

Comments

Compare

Length

Name

Line

1>211<211-2
Lookup(Factor 2)is

')

2:

01

o

I

c

o

C

4'

a 5

C

06

C

a

7

C

o

8 C

aI

g

1

a

C

1 1

C

C

1 2

C

1 3

C

1 4

C

Z

Z

HIgh

10 11 12 13 14 15 1617 18 19 70 21 22 23 24 25 26 27 2829 30 31

32 33 34 35 3G 37 38 39 40 41 42 43 44 45 46 47 48 49 SO 51

' ,The following individual calculations involve the same array and are

I-+--+-f-I----i---+---,
03

0

0

z

valid calculations.
II

'1'1

I

I+tt,

'

i

I,

II
\

I

11'1

'I

1 ,

!

til!

II II

'

C

1 6
1 7

C
C

i

I Iml!!!
~I--rrh

,!! I I I

Iii I ! I i I I
The following individual calculations are valid because the array
elements associated with the constant indexes do not overlap. - I
I I
I I I I I
+--~ I I I I I ,
: I
'~
J Mo:vl_EI_ ~&~~I Ii!
A'RIR:~l ' !
t

I I !

I

I,

I

I

tit

1

!

,

I,

'

:

1

.:'

.;

I 1, i i '

I

1

i: 'lU!

: i!

I:

'tt--r-,

1

;:':

i

::

1

!

I

I I

~!

I

i-T
I

'
-·r-----+----+--I--I--r-+-+-------+--+----''-I

: : : I~_

I

~_++l#l
i

1--

':--:-:-rt

I, I

-\-+---t

:'

--<---+---'

,!
-H+
r-

_~_---! _1--1 -L+---LLitf--

'II ' ,

I

f-f-- -

1-+---t-t-+-+--+---+--+---t--1c-l--+-t---+-+-+-+--+--+-+-+--t--+--+-+-+- r--r -- -~r-t---+--t---+----t-+-+-r-f-I-f--+--t--I--t-----1H---+--I----+--+--+--+-+--+--I--f--+-2 0

I

~ ~---!-

!

!

!

"lJ 74

Ii

II --f--+~-;::;tr-'++--I~-~:"'.------;-

I I
-I MWEliy·
R ':1" 12; I I AIRlp2'!
++-, : -+-r-+---f "I Pt'--~-- ,~I+~ II f--n~-:/---;,r---r - - -H---+-- -+ - ,
___ .11 i I I
i _~ ~ ___ ~-+_ J-i-LUl--l--LU-L~-.LL _-<--+- f-I
_~
1

n T:!

44-'-~-~-~----LLl--+: !

i

I,

10

"

-+-~- ~

---t-,

':!

I

The following individual calculations are invalid because the array
elements associated with the constant indexes overlap, or variable
indexes are specified and the entire array is required to determine
1 8
C
1----1+9---t-f--C-t-----1--+----+- ove r Iap.
1 5

i

!

,

t~- -+t-~l JJ-~' lJJ-Hii-~~~I~~1!,ALM::'~~r\si;'6
~
ii I I
~ $ 1[ ~tt+-~t!10T:~~~~1.~l it-, ARLR1I ,J2,
I 1
i I I MO'J'CI
'IX
ARlRai,l1Y : :
t

i

f--

t:

II111111111

-+-+! :

1

Low Equal

54 55 56 1,:,7 58 59 GO 61 G2 63 G4 65 66 67 G8 69

C

~-c-

I

,

I

i

I

J

:

-

!

t~T

I

M~;t~ Alp. RI2 !1
IA RIAll, 5 -+--+---+---t--+---t--t--t--t-t----+-t----t--1f--+--+-'-----t-t---,----t--+-+----t----i
I
,
C
1
_+-+--+-J'--"Mpo."lrv-"-tE. AI121l11 IX~-t--r~_,.,-,RIRI21.~
C
I -r----e-f---~OIY E AIR Rl1 !')(
~ RRI2 1
i
f-+-+--+c-++-+-+++-+-H-f---+-+---,-:-+-+-+-tr+--+
MdV ~ f- A~ B 1 lJ-L-t't--+--+---+--f-IA-'I-'-R-¥-"B+""~'II---,t"""'l)(H__ --+_-++-+-+-+-+-H--+--++---+----l-+-t--r---+-:;-+
-----.;.;-.:..,-H
I
I--t--t--+C-t-----t-+----f-++--+-t--I------t----t-t--rt-t-r---t-t-r-r--t-1-t-.tl_+

-----+_

1

C
Zt LL Ot 6989 19 99 59 t>9 £9 19 L9 09 6S ij(,i lS 9S 55 175 ES lS L5

as

6",

at>

Ltr 917

str

I

tot>' ('to Ztr Ltr Ot> 6t 8£ Lt 9C S( M: CC lC lC

I

i

DC 6Z BZ II 9l SZ tol Cl II LZ DC: 6L BL it 9l 5L tot £L ZL

Figure 8·8 (Part 3 of 3). Examples of Valid and Invalid Calculations with Overlapping Subfields in a Data Structure

8·18

Calculation Specifications

i i

LL Ot

6

8

L

9

i

5

to

(:

Z

L

Calculation Specifications

C
I---

~

4

c~
c~

o

3

C

o

4

C

o

5

C

o

6

C

o

7

o

8

o

9

1 3

c~
c'1
c*
c
c
c
c

1 4

C

1 5

C

Comments

1>211<211=2
Lookup(Factor 2)is

910 1112 1314 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 31 38 39 40 41 42 4344 45 46 47 48 49 50 51

1

2

~

Compare

Length

Z

2

1

Plus IMinusl Zero

Factor 2

7

o

1 1

Operation

8
o

1 0

Factor 1

Name
0

Indicators
Arithmetic

g

5

Resulting

Result Field

At AL

]

Line

3

Indicators

~

0

z

,EIX ~H,Pl ES

\S 112% Dir. ,
, I'L be te'
,~

,,,

Cj: IAL n

I(

\ FEI... '....

High

,.

Low Equal

54 55 5657 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

Ll TE RA LS

,

I .....
I

\

b8'

EX ~~ PL IE~ OF NU 1lt1IE RIC Ll TE IRA LS
11 7 ~11)j~

11 7 ~ltJ Qj. ~¢

.rh ~1

i,,,I"" SA

1-. ~l1 125 bl B~

Figure 8-9. Alphameric and Numeric Literals

COLUMNS 28-32 (OPERATION)
Use columns 28 through 32 to specify the kind of
operation· to be performed using factor 1, factor 2,
and / or the result field. The operation code must begin
in column 28. A special set of operation codes must be
used to indicate the type of operation to be performed.
Every operation code used requires certain entries on
the same specification line. See Figure 8-7 for a
summary of all the operation codes and the entries
required for each code. For further information on the
operation codes, see Chapter 10, Operation Codes.
The program performs the operations in the order
specified on the calculation specifications sheet.

COLUMNS 31-32
Entry

Explanation

Blank or
01-99

Message identification code
(MIC) of user message member
to be displayed for SET or KEY
operations unless overridden
by a factor 1 entry

Use columns 31 and 32 for all KEY operations and for
SET operations in which command key indicators are
specified in columns 54 through 59, unless an entry is
made in factor 1. Entries in columns 31 and 32 are
ignored when factor 1 is specified on the same line as
the SET or KEY operation.
The same combination of MICs should not be assigned
to more than one KEY or SET operation except when
the SET operation immediately precedes a KEY
operation conditioned by the same indicators (columns 9
through 17) and the special SET-KEY combination is
used. See SET and KEY in Chapter 10, Operation Codes,
for complete information.

Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2)

8-19

COLUMNS 43-48 (RESULT FIELD)
Entry

Explanation

ERASE

Erase the CONSOLE file buffer
by using the SET operation code.

Field name,
table name,
array name,
array
element,
data
structure
subfield
name, or
data structure name

The field specified contains the
result of, or is the object of,
the operation specified in columns
28 through 32. A data structure name
can be specified as a result field
only if the operation code in columns
28 through 32 is RLABL or POST.

INxx (xx =
any RPG II
indicator)

The indicator to be transferred to
an external subroutine in an RLABL \
operation.

ERASE
Enter ERASE in columns 43 through 48 to blank or
erase the entire buffer for the CONSOLE file. The
filename of the CONSOLE file must be entered in
columns 33 through 42. ERASE indicates to the system
that the buffer should be set to blanks just before
getting a record at the beginning of the next RPG II
cycle.
Because the buffer is not erased until the beginning of
the next RPG II cycle, processing of the current record
continues after the ERASE operation is encountered. If
the ERASE operation is executed because of invalid
input data, you should insert code in your program to
avoid further calculations and to return to the start of
the RPG II cycle. A 'correct form of the record
containing the invalid input data and any records that
were entered after that record can then be reentered.

8-20

Calculation Specifications

Field Name, Table Name, Array Name, Array
Element, or Data Structure
Use columns 43 through 48 to name the field, data
structure subfield, table, array, array element, or data
structure that holds the result of the operation specified
in columns 28 through 32, or that is the field upon
which an operation is performed. Use the name of a
field, table, array, array element, data structure, or data
structure subfield that has already been defined either
by the input, extension, or calculation specifications; or
define a new field by entering a field name that is not
already used. Any field defined in the result field is
created when the program is compiled. The result field
can be either numeric or alphameric. A field used in
arithmetic operations (see Columns 28-32 (Operation»)
or numeric compare operations or a field edited or zero
suppressed by output specifications must be numeric.
A data structure name can be used as the result field
only if the operation specified in columns 28 through 32
is RLABL or POST. Overlapping subfields in a data
structure cannot be used in the same calculation. If
factor 1, factor 2, or the result field references a
subfield in a data structure that is an array or array
element with a variable index, the entire array is used to
determine whether overlap exists. The same array name
can be referenced in the appropriate factors of a
calculation specification without violating the overlap
rule.
The result field name must begin with an alphabetic
character in column 43 and contain no blanks or special
characters.
If columns 43 through 48 contain the name of a field
that is not defined elsewhere, columns 49 through 52
should also cO'1tain, entries.
If the field is defined elsewhere, entries in columns 49
through 52 are not necessary but, if specified, must
agree with the previous definition of that field.

COLUMNS 49-51 (FIELD LENGTH)
Entry

Explanation

1-256

Result field length

In this example, field C must be defined as 11
characters long with six decimal positions. Some of the
numbers to the right of the decimal could be lost
without changing the meaning of the result greatly.
However, if field C was defined as 10 characters long
with six decimal positions, a significant digit to the left
of the decimal would be lost. Field C in this case would
be 0000.111111; the meaning of the result has greatly
changed.

Use columns 49 through 51 to specify the length of the
result field. If the result field is defined elsewhere, no
entry is required for the length. However, if the length
is specified, it must be the same as the previously
defined length, with the same number of decimal
positions. If the result field is a new field, consider the
form your data is in because the result field must be
large enough to hold the largest possible result. If the
result field is too small, significant digits can be lost.
For example, to add field A (8 characters long, four
decimal positions) to field B (10 characters long, six
decimal positions), the result field, field C, must be large
enough to contain 11 characters:
9999.0000

Field A

000 1. 111111

Field B

10000.111111

Figure 8-10 shows how the contents of a result field
can change after a multiplication operation, depending
on the decimal position (column 52) and field length
(columns 49 through 51) specifications. The result field
for a multiply operation should be as long as the sum of
the lengths of the two factor fields.
Numeric fields have a maximum length of 15 digits.
Alphameric fields can be up to 256 characters long.
If the result field contains the name of a table or array,
an entry in these columns is optional. If used, the entry
must agree with the length described by the extension
specifications.

Field C (result field)

Multiplication: 98.76 x 1.234 = 121.86984
Decimal Positions for
Result Field (column

Result Field Length (columns 49-51)
I------~----r__----r----~--__,---r__-_.,.--~-~~

52)

10
.........•.................

9

' . , \\1
..................

;;::~

......,.,,,,.

.. '

\":

9

8

7

6

5

4

3

2

1

·······>·

I.······••.

........

8
7
6

5

00121 .86984

0121.86984

121 .86984

4

000121.8698

00121.8698

0121.8698

121.8698

3

0000121.869

000121.869

00121.869

0121.869

121.869

2

00000121.86

0000121.86

000121.86

00121.86

0121.86

121.86

1

000000121.8

00000121.8

0000121.8

000121.8

00121.8

0121.8

121.8:~

o

0000000121

000000121

00000121

0000121

000121

00121

0121

0~

~

_

~~--+---~--+----I-~t}~
121

Not permitted
Permitted but inaccurate
Recommended
Figure 8-10. Result Field Contents Based on Various Field Length and Decimal Position Specification

Columns 49-51 (Field Length)

8-21

COLUMN 52 (DECIMAL POSITIONS)

COLUMN 53 (HALF ADJUST)

Entry

Explanation

Entry

Explanation

Blank

Alphameric or numeric result field is
described elsewhere, or the newly
defined result field is alphameric.

Blank

Do not half adjust

H

Half adjust

0-9

Number of decimal positions in a
newly defined numeric result field.

Use column 52 to indicate the number of positions to
the right of the decimal in a numeric result field. If the
numeric result field contains no decimal positions, enter
a 0 (zero). This column ""':lust be blank if the result field
is alphameric. This column can be left blank if the result
field is numeric but was described by input or
calculations specifications. In this case, field length
(columns 49 through 51) must also be left blank.

Use column 53 to indicate that the contents of the
result field are to be half adjusted (rounded). Half
adjusting is done by adding the single digit to the right
of the last decimal pOSition specified to the same
position in the result field. All decimal positions to the
right of the position specified for that field are then
dropped (see Figure 8-11).
The half-adjust entry is allowed only with arithmetic
operations. See Columns 28-32 (Operation). However,
half adjusting cannot be specified for an MVR operation
or for a DIV operation followed by an MVR operation.

The number of decimal positions must never be greater
than the length of the field. The number can, however,
be larger or smaller than the number of decimal
positions that actually result from an operation. If the
number of decimal positions specified is greater than
the number of decimal places that actually result from
an operation, zeros are filled in to the right. If the
number specified is smaller than the number that results
from the operation, the rightmost digits are dropped.
Calculation Specifications

c

Indicators

:3 ~

r-----

4

a 1

=0

Factor 1

Operation

~~~~
5

6

7

8

~

Name

Length

Compare

Comments

1>211 <211 =2
Lookup( Factor 2);,

z

High

9 10 11 12 13 14 15 16 1718 19 20 21 22 23 24 25 26 27 2829 3031 32 33 34 3536 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

Low Equal

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

C

a

2

C

a

3

C

a

4

C

o

5

C

RI;5ULlT
1

This calculation line shows a result field being half
adjusted to two decimal positions (2 in column 52 and H
in column 53).
Second Position

t
35.7968

6

Result of an add operation.
Add the digit to the right of the
last decimal position specified to
the same position in the result field.

35.80xx

Drop all decimal positions to the
right at the position specified.

35.80

Result after half adjusting.

Figure 8·11. Half Adjust

8-22

PluslMinusl Zero

Factor 2

~ 0 c£ i--r--r-t---T--r-t---T-rl

Line

Resulting
Indicators
Arithmetic

~~~

.

3

Result Field

Calculation Specifications

COLUMNS 54-59 (RESULTING INDICATORS)
Entry

Explanation

01-99

Any two-digit number

KA-KN,
KP-KY

Any command key indicator
(allowed only with SET or
SETOF operation)

H1-H9

Any halt indicator

L1-L9

Any control level indicator

LR

Last record indicator

OA-OG,
OV

Any overflow indicator

U1-U8

Any external indicator

Test Results
An indicator can be used in columns 54 through 59 to
test the value of the result field, or to indicate an
end-of-file condition, a no-record-found condition or
an exception/error condition. Normally, only indicators
01 through 99 and H 1 through H9 are used for testing.
The indicator specified turns on only if the result field
satisfies the condition being tested for. If the condition
tested for is not met, the indicator is turned off. This
indicator can then be used to condition following
calculations or output operations (see Figure 8-12). If
the same indicator is used to test the result of more
than one operation, the last operation performed
determines the setting of the indicator.
Three fields (columns 54 and 55, 56 and 57, and 58 and
59) can be used for testing the results. Each field is
used to test for different conditions. You can specify
testing for any or all conditions at the same time.

Columns 54 through 59 have three purposes:
• To test the value of the result field after an arithmetic
operation or to test the result of a CHAIN, KEY,
LOKUP, CaMP, READ, TESTB, TESTZ, ACO, REL,
NEXT, POST, or SHTDN operation. See Chapter 10,
Operation Codes, for more information on each
specific operation.
• To specify which command keys can be pressed for
a SET operation.
• To specify which indicators are to be turned on or off
by the SETON and SETOF operations.

Columns 54-55 (Plus or High): Use an indicator in
these columns when testing:

• Whether the result field in an arithmetic operation is
positive
• Whether factor 1 is higher than factor 2 in a compare
operation
• Whether factor 2 is higher than factor 1 in a table or
array LOKUP operation
• Whether a CHAIN operation is not successful
• Whether each bit named in factor 2 is off for a
TESTS operation
• Whether the character tested in a TESTZ operation is
one of the characters &, A through I
• Whether the numeric field entered in a KEY operation
is positive
• Whether the system operator has requested
shutdown

Columns 54-59 (Resulting Indicators)

8-23

Calculation Specifications

C

Indicators

'---

AL

1

Arithmetic

Factor 1

Operation

Plu'jMinu,1 Zero

Factor 2

b

b

Z

4

5

o
o

1
2

C

o

3

o
o

4

o

6

c
c
c
c
c
c

5

o

7

o

8

1>211<211=2
LookuplFactor 2)i,

b

z

High

9 to t112 1314 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 50 51

3

C

It

tJ2a

1a
1G

ze

Comments

Compare

Length

Name

Line
Z

Resulting
Indicators

Result Field

lArA

"",I ..

..

t"'1'" 111 ~ I

"\I ~toC 11'11

ON RP 'A "I
PA vR Air

~U18

~IQ

ML LIT tad
MU LIT OV RR AT

AtD PAY
.., .. n.D
MU LIT

1\

K 11M

P,~

"

PA~

PAIV

'I

111~ 2'rJ.
\,

.~

~

b

Low Equal

54 55 5651 58 59 60 61 62 63 64 65 66 67 68 69 10 11 12 13 14

H
~

~

\

1\
\

Two indicators are used to test for the different condi·
tions in a subtract operation. These indicators are used
to condition the calculations that must be performed
for a payroll job. Indicator 10 turns on if the hours
worked (H RSWKD) are greater than 40 and is then used
to condition all operations necessary to find overtime
pay. Indicator 20 turns on if HRSWKD is less than 40.
It is also used to condition other operations. In line 03
if indicator 20 is not on (the employee worked 40 or
more hours), regular pay based on a 40·hour week is
calculated. In line 06 if indicator 20 is on (employee
worked less than 40 hours), pay based on less than a
40·hour week is calculated.
Figure 8·12. Conditioning Operation (Resulting Indicators)

Columns 56-57 (Minus or Low): Use an indicator in
these columns when testing:

Columns 58-59 (Zero or Equal): Use an indicator in
these columns when testing:

• Whether the result field in an arithmetic operation is
negative

• Whether the result field in an arithmetic operation is
zero

• Whether factor 1 is lower than factor 2 in a compare
operation

• Whether factor 1 is equal to factor 2 in a compare
operation

• Whether factor 2 is lower than factor 1 in a table or
array LOKUP operation

• Whether factor 2 is equal to factor 1 in a table or
array LOKUP operation

• Whether the bits named in factor 2 are of mixed
status (some bits of!, some bits off) for a TESTS
operation

• Whether an end-of-file condition is reached for the
demand file that is read by the READ operation

• Whether the character tested in a TESTZ operation is
one of the characters - J through R

• Whether each bit named in factor 2 is on for a
TESTS operation

• Whether the numeric field entered in a KEY operation
is negative

• Whether the character tested in a TESTZ operation is
any character other than &, A through I, or -, J
through R

• Whether the ACO, REL, NEXT, READ, or POST
operation to a WORKSTN file is not successful

• Whether the numeric field entered in a KEY operation
is zero or whether an alphameric field is blank

8-24

Calculation Specifications

Allowing Command Keys To Be Pressed (SET)

COLUMNS 60-74 (COMMENTS)

Columns 54 through 59 can contain command key
indicators (KA through KN, KP through KY) for a SET
operation.

Use columns 60 through 74 to enter any meaningful
comments that will help you understand the purpose of
each specification line. Comments are not instructions
to the RPG II program; they serve only as a means of
documenting your program.

When a SET operation occurs, only the command keys
in columns 54 through 59 for that SET operation can be
pressed at that time. From one to three command keys
can be entered for each SET operation. If one or two
command keys are specified, they can appear in any of
the three sets of columns. See SET in Chapter 10,
Operation Codes, for complete information on this
operation.

COLUMNS 75-80 (PROGRAM IDENTIFICATION)
See Common Entries in Chapter 1.

Setting Indicators (SETON, SETOF)
The operation codes SETON or SETOF can be used to
turn indicators on or off. See SETON and SETOF
Operations in Chapter 10, Operation Codes, for more
information on these operations. Any indicators to be
turned on or off by the SETON or SETOF operation
codes can be specified in any of the three resulting
indicator fields (see Figure 8-13). The headings for
columns 54 through 59 have no meaning for SETON or
SETOF operations.
Calculation Specifications
Indicators

C
-

Result Field

At AL

Ii

Arithmetic

Factor 1

Operation

~
3

4

0

1

C

0

2

C

0 3

C

0 4

C

0

5

C

0

6

C

0

7

C

0 8

C

0 9

C

5

6

Factor 2
Name

~

Line

Resulting
Indicators

Length

Plus IMinusl Zero
Compare

Comments

1 >211 <211 =2
Lookup(Factor 2)is

0

0

0

z
Z
Z
9 10 11 12 1314 1516 17 18 19 20 21 22 23 24 25 26 27 2829 3031 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

High

Low Equal

5455 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

bt: TON

;~ ~5

AE rr~tl

22

'--

'45

1-1 ... -

~t: IUJI-

Figure 8·13. Setting Indicators

Columns 60·74 (Comments)

8·25

8-26

Calculation Specifications

Chapter 9. Output Specifications

Write these specifications on the RPG Output
Specifications sheet (see Figure 9-1).

Output specifications describe the records and fields in
the output file and the conditions under which output
operations are performed. These specifications can be
divided into two general categories:
File and record identification entries (columns 7
through 31) that describe the output file, the records,
and the indicators that condition the output.
Field description entries (columns 23 through 74) that
describe the position and format of data on the
output record. These entries must begin one line
below the file and record identification entries.

RPG

IBM

I Program
I Programmer
-

SPECIFICATIONS

OUTPUT

I
I

Date

o

w~

Space

Punching
Instruction

~ ~

Jd

D E L

"ADm

I I

Field Name

ur

:;;:

0

z

z

z

End
Position

in
Output
Record

·AUTO

5

6

o 1

0

o

o

2
3

0
0

o

4

7

8

1

I
Page

Zero Balances

Commas

to Print

Ves
Ves
No
No

II

In

UM/050·

I

U.S.A.

No Sign

Ves
No
Ves
No

75 76

2

[I]

of_

CR
A
B
C
D

J
K
L
M

78 79 80

77

~~~;~f:ation I I I I I I I
X

=

V

=

Z

=

Remove
Plus Sign
Date
Field Edit
Zero
Suppress

a::

Constant or Edit Word

-'
to

Ii:

AND
4

Printed

Card Electro Number

U-,-__-., ::>

0

D~f-

I I
I

I I
I I

I I

Punch

L

~ ~

f-

Graphic

Output Indicators

Skip

~~
irw
'" 1- - l -

Filename

Line

3

GX21-9090-

International BUSiness Machines Corporation

,

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 1819 2021 222324 '

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3031 32 33 34 35 36 37 38 39 4041 4243 44 45 46 47 48 49 5051 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

IIII
f1-:-!-

I I

__ '- __

-f-+--lH-+

File and record identification -,-I

-t-+-+-t-++-t-+--l-+-+-++-++-+-+-t-H--+--+--+-+-++-+-+-+-+-+-+-t--H

I .------11

o

5

o
o

o

6

o

F iel d desc ri pti 0 n +-+--+-+-+--+-+-+--:-+-+--+-+-+-+-+-+-+-+1

'- --- - - - - 1--

~-;-I--"O

~ -;-HO - -

~-:;-fI

5

of---C-

-1-}"_- ~~ -++~] -i- l,----r--- _---- ~
,
r! it
=-tt==-~--~-~:~~=- --t-!

f-- f-- -f---

1

-

r- -

-- -

-- -

0

-

c-- -

-- -

',

_

-1

-+-t-1--+-+-+

tl-- ----

"I

r

--

I--- -

+--t-+--+--f-t-- f---- f---f-

-

-- -f- -- --

r-1-1-- -

I-f---ff---- -

--, -

-

--l---+-+--+-+-+--t-+-+--+-+--1---+--l

- -- - - + - - f - -

I
I
I

~1~6~-°t-l-+-+-~r+~-~r+-r-rf~r+-r~~--r-+-~r+-r-t-~-+-+-~r+-+-~r+-t-~~-+~~-+-+-~~-+~~r+-+-~-r-~~r+-r+-~~~I

~1~7~-o+-I-+-+-~r+-r~~-r~~r+-+-~~-+-+-~r+-+~~-+-+-~r+-+-~r+-+~~-+~~-+-+-~~-+~~r+-r~~-+-+-+-r+-r~~1

I

1 8
0
~1+9'+4-0~-~~~~~++4-~+-t-1~+4~-~+-+~-++4-~+4~t-+-4-1-r++~-~+4~r+4-~+4~r+~~+4~++4-~1

r+~r+~~--+-~-r~~-+-~1-r+--+-+1-r~-r+-~4-r+--+-+1-r~-r+-~+-~4-r+4-r+--+-~-r+-~4-r+~+1-r~-r~ril
2 0

U

It OL

0

~9

•

89 L9 99 59 V9 £9 19 19 096585 L5 95 55

~5

£5 l5 IS 05

6~ B~ 9~ 5~ ~~ £~ l~ I~ O~
a

6£ B£ L£ 9£ 5£ O£ ££ l£ 1£ O£ 6l Ill: Ll 9l 5l

~l

£l II Il Ol 61 BI LI 91 51

~I

CI II "01

6

B

L

9

5

~

£

l

I

I

-------I

Figure 9·1 RPG Output Specifications

Output Specifications

9-1

COLUMNS 1-2 (PAGE)
See Common Entries in Chapter 1.

COLUMNS '3-5 (LINE)
See Common Entries in Chapter 1.

COLUMN 6 (FORM TYPE)
An 0 must appear in column 6 to identify this line as an
output specifications statement.

COLUMNS 7-14 (FILENAME)
Entry

Explanation

A valid
filename

Same filename that appears on
the file description specifications
for the output, combined, update,
or add file

Use columns 7 through 14 to identify the output file
being described. The filename must begin in column 7.

COLUMN 15 (TYPE)
Entry

Explanation

H
D

Heading records
Detail records
Total records
Exception records (lines to be
written during calculation time)

T
E

Use column' 15 to indicate the type of record to be
written. Column 15 must have an entry for every output
record.
Describe output files by entering the records for each
file in this order: heading, detail, total, and exception
(see Figure 9-2). Or enter all record types for all output
files in this order: heading, detail, total, and exception
(see Figure 9-2).

Heading Records (H)

Heading records usually contain constant identifying
information such as column headings, page number, and
date.

The filename need be specified only on the first line.
However, if another output file is specified and further
specifications are then required for the first file, the first
filename must be repeated in columns 7 through 14 (see
Figure 9-2).

Detail Records (D)

COLUMNS 14-16 (AND/OR)

Total Records (T)

Entry

Explanation

AND or OR

AND/OR indicates a relationship
between lines of output indicators.

Use columns 14 through 16 to specify AND/OR lines
for output operations. For further information, see AND
and OR Lines under Columns 23-31 (Output Indicators),
in this chapter.

Detail records usually contain data that comes directly
from the input record or is the result of calculations
performed on data from the input record.

Total records usually contain data that is the end result
of specific calculations on several detail records. Total
output cannot be specified for primary or secondary
update. files. Records can be added to indexed primary
and secondary files at total time if add is specified (A in
column 66) on the file description specifications.

Exception Records (E)

Exception records are written during calculation time.
Exception records can be specified only when the
operation code EXCPT is used. See Chapter 10,
Operation Codes, for further information on the EXCPT
operation code.

9·2

Output Specifications

Output Specifications

-

o

~ Space

~
;;5

Filename

line

5

6

7

8

9 ,0 "

a

I

a
a

of:" IL lElA

2

0

3

0

a

4

0

a

5

0

--

~ ~

R~ ~

a

6

--f-" -

a 7

H_ -

- -

---

--

~

0--

-i--

- "- - f - I -

-f-

-t---t-t-t-+-t-t--t-t-t----t-t-t--t--t-I-

'to i-- - -" --l---f--1rt-+-- - -- -

C.

" - - - - ' - - -t--!--!-+-+-+- -

-

.-

-+-t-+-+-i-t--t

--

~

-t- ---- -

r- -- -

-----1--1- --

~-

--

,L

--1-1-+-+-+-H----f--l---+--H--+++-+-H-t--t
I 4
0
I-H-t--t---t---HH-+-+-++---H-+-I--+- '-:-1- - --- ,---- - t--+-+-+-t---i-t-+--i
I 5

0

~

I--

~
3

4

5

6

7

8

9

1L
1E

0

~

(j
~

;3

0

z

z

Field Name

z

'AUTO

~

,2 ,3 1415 ,617 '8,920 2,22 2324 2526 2728 29 30 3, 32 33 34 35 36 37 38

,0 "

a

I

01=

a
a
a

2

0

3

0

4

0

a

5

of l~ Ere

o

6

0

o

7

0

o

8

0

"

o

9

01= [L E~

,0

I

0

0

I

I

0

I

2

0

I

3

0

I

4

0

I

5

0

LEA

tI---H

i--r-"

f- -

I-f- ---

f--H

i---

r-I-- -I-- -

---

-f-- f - - -

-"~

---

10

,-I--

-- ,- - - f - -

T
-"-

1

1 6

0

I

6

0

0

I

7

of[L EB

1 8

0

I

8

0

1 9

0

I

9

0,",

2 a

0

2

a

0

ZL I, OL 69 89 L9 99 59 '9 C9 Z9 19 09 65

8:'R
>1D ~~
'Aliro
o R
'A'No

I--

1 7

o
o
o
o
o

Output Indicators

Skip

I ~ .2 ~

Filename

Line

- - - , - - - - ' - - """'---- --t--1t-t-t--t--j--1-

-

~ ~- - ~t--l--+-+++-II-" --1- -

- I- - -

--+-II-t-++-I-+---I-I

Space

~

;ii

i--- - , -r- -

"§
UJ If

t:Cl "4

~

'AUTO

1--+-+--+-+--+--1-'-1- - I- -- f-- - - - I - -t----t--t-t-t-t-t----t--t--t---I---t-t---i

--f-I-- - -

o

(j

0

-

;3

0

z

-f-

~~f-~~ItEB---D-r--r---

3

z

-l-

0
-i-- - ---t---t-i:-+-t-" I-- a 8
0
- - - - r----I--r-"
a 9
0
-

I

0

z

L

1-1- - - -.-

r-L-jf_r--,----,--

0

At

Field Name

,2 ,3 ,4 '5 ,6 17 ,2 '9 20 2, 22 23 24 25 26 27 28 29 303, 32 33 34 35 36 37 38

._- -

-

Output Indicators

Skip

oter"L
'A"D'o ~
o R
"A'N'o

Output Specifications

IL EA

if
IE

0
0
0
0

0

as

L5 95 gg

os

C5 Z5 IS OS 6. 8. L. 9.

so ••

C. Z. I. O. 6C 8C LC

ZL IL OL 69

as

L9 99 59 >9 C9 Z9 19 0965

as

L5 95 gg

os

C5 Z5 IS OS 6. 8. L. 9.

so

.',C. Z. I. O. BC 8C LC

Figure 9-2, Order of Output Record Types

Column 15 (Type)

9-3

COLUMNS 16-18 (ADD/DEL)

Entry

Explanation

ADD

Add ;:! record to an indexed,
direct, or sequential file
defined as an input, output,
or update file.

DEL

Delete the last record read
on the identified update file.

ADD

When ADD is specified in columns 16 through 18 to
add a record to an indexed, direct, or sequential file,
column 66 of the file description specifications must
contain an A for the file to which records are being
added. The output device for this file must be DISK.
The ADD entry must not be used in an OR line. An
ADD entry in columns 16 through 18 of the previous
line also applies to the record in the OR relationship.
(For a detailed description of adding records to file, see
Column 66 (File Addition) in Chapter 3.)

DEL

If a record is to be deleted from a file, the file must be
defined as delete-capable when it is built (for further
information on defining a delete-capable file, see FILE
Statement in the System Support Reference Manual). If
you attempt to delete a record from a file that is not
delete-capable, an execution-time error message is
displayed.
DEL must be specified in columns 16 through 18 of the
main output record line. DEL applies to all the OR
extensions to the main line. When records are deleted
from a file, the file must be defined as an update file
(column 15 of the file description specifications contains
U).

Note: Record deletion is not dependent on the file
organization and mode of processing entries.

Records are not physically removed from a file when
they are deleted. Deleted records are filled with hex
FFs. If a direct file load of a delete-capable file is
executed, the entire file is initialized to hex FFs (for
furthm information on direct file loading of
deletr3-capable files, see Direct Files in Chapter 3).
When a file containing deleted records is processed
sequentially or consecutively (primary, secondary, or
demand files) a deleted record is not returned to the
program when it is accessed. It is bypassed, and the
next record is read. This process is repeated until a
nondeleted record is found or the end of the file is
reached. When a file containing deleted records is
processed randomly using CHAIN, the no-record-found
indicator is turned on when a deleted record is
accessed. If this indicator is not specified in columns 54
and 55 of the calculation specification specifying the
CHAI N operation, an error message is displayed.

9-4

Output Specifications

COLUMN 16 (FETCH OVERFLOW OR RELEASE)
Entry

Explanation

F

Fetch overflow routine

R

Release the device (display station
or SSP-ICF session) after output

Fetch. Overflow
Use column 16 to specify fetch overflow for a printer
file only. Column 16 of each OR line must contain an F
if the overflow routine is to be used for each record in
the OR relationship. Fetch overflow cannot be used
when an overflow indicator is specified in columns 23
through 31 on the same specification line. If this
occurs, the overflow routine is not fetched. Specifying
fetch overflow allows you to alter the basic RPG "
overflow logic (see Columns 33-34 in Chapter 3, File
Description Specifications). You can advance forms when
total, detail, or exception records are printed instead of
waiting for the usual time. The fetched overflow routine
does not automatically cause forms to advance; that is,
the entry in columns 21 and 22 of the output
specifications must contain a two-digit entry that is less
than the number of the line the printer is currently on.
Fetching the overflow routine can prevent printing over
the page perforation and can ensure use of as much of
the page as possible.
The fetch overflow specification causes the system to
check whether the overflow indicator assigned to the
printer file is on before printing total, detail, or exception
records. The system tests the indicator each time an F
is encountered in column 16 of the output
specifications. If the overflow indicator is on, the
overflow routine is fetched and the following operations
are done:
1.

All total lines conditioned by the overflow indicator
are printed.

2.

Forms advance to a new page when a skip to a
line number less than the line number the printer is
currently on is specified in a line conditioned by an
overflow indicator.

3.

Heading lines and detail lines conditioned by the
overflow indicator are printed.

4.

The line that fetched the overflow routine is
printed.

5.

Any detail, exception, and total lines left to be
printed for that output cycle are printed.

Use fetch overflow when printing a particular line causes
overflow, and not enough space is left on the page to
print the remaining detail, exception, or total output
lines. To determine when to fetch the overflow routine,
study all possible overflow situations. By counting lines
and spaces, you can calculate what happens if overflow
occurs on each detail and total line.
Figure 9-3 shows an example of specifying fetch
overflow.

Release
A device can be released from the program after output
to that device has occurred. To release the device, enter
an R in column 16. OR lines can be specified; however,
column 16 must contain an R for each OR line. The
device is released when that output specification is
encountered during the output operations. If a format
name is specified on a field description for the record
that contains an R in column 16, the format is written
and then the device is released.
RPG II sets on the LR indicator when all devices have
been released if the WORKSTN file is a primary file and
the program does not have an N EP attribute. If the
program is an NEP, all devices must have been released
and the system operator must enter the STOP SYSTEM
command before RPG II sets on the LR indicator.
Note: For WORKSTN files, a device can be either a
display station or an SSP-ICF session.

Column 16 (Fetch Overflow or Release)

9-5

Output Specifications

G: , ;,

o
Filename

Line

Ifl

~



Commas

Zero Balances
to Print

Ves
Ves
No
No

Ves
No
Ves
No

-En-d- , . - ,

I I
a:

And

~

fr-'-'

~

a:

No Sign

CR
A
8
C
D

J
K
L
M

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

Constant or Edit Word

.

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 4243 44 4546 47 4849 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

~O~'HHoP4IR~I~N~rr~IE~_R~IH1-r~~~I~MHI~_~O~I~~++~_c __ ~+~_r+1-r+~~HH~~-~~~~~-~++++++++++~
o

2

0

o

3

0

o

4

0

0

5

0

o

6

0

o

7

0

o

8

0

If I
m~ 1"11
Ii Ii

Lll

T 11

Ll

T 11

Ul

~--+-f--+- +-+-.J.-!--f--+-~,.....t--+--+--+-++~~I--+-t-+-+-j-f--+--I- +--+-t-t--t-

'- -

--

-t--t-+--t--~-t--+--+-t-+--+-t-t-t-t-t--t--t-t--t--

- -+-+-+--+-t--1--1-

k?l,

~~~-+-~~-t-+-t--~ld~~~~~-+-+-+~+-+~+-+~-~~~~~~rr-t~-+-+-+4-+-+-4-~-4-+-+~-+-+4-r+-+--r+~~- -r-T~-~-~~~
o 9
0

,
,,
,
0

Ll
It
-[ t-t-11_t- -+-+--+''''''I-''''l--+-+--lf--4--i---l-+--- -rt'IE Wll

0
0

,

2

0

3

0

,

4

0

5

0

6

0

\Lil/

rr

'~--+-~-+--l-+-t-+-+-+---t-+-t-~-

-t--h-l--t-+-+-+--t-+--+-+-+-_ --c- --

1

Lll

11

Lt--

- 1 - -f--f--+-1-t--+---l-ll-++-i-++-l--+-+-+--+-f--+--t---I--+--+-+--t--f--t-~-I

-

-f--~-+--t--lt-t---+--+--

t-+-+-l-+-+-+--+--t-+-+-+-+-'-+--t-.=t--+-t-+--t-F'T''''I-H---t--t--t--t-t-t +~--t-1f---I-I--1-

.,

,
,
,

,

8

a
a

9

0

7

rr

1---1- 1-- -

-f-- -- -

I- -+-+-t-+-+-t--f--t--t--l--t---f--t--t-+-t--I

I-I- -I- - --- '-:-I--t--+-+-+-+-+-t--+-+-+-+-+-+-+~-+--+-+-f-t--+-l--+--t-t-+--t-t--+--t-t--I

-

I-I- 1--1- - - -I- - --

-j -~-+--+-!--+---+--!--+--+-+---+---+--!--+--+--I-1f--+-~

Figure 9-3. Uses of Fetch

COLUMNS 17-22 (SPACING AND SKIPPING)

Column 17 (Space Before)
Entry

Explanation

0-3

Number of lines to be spaced
before a line is printed for
a CRT file or a
printer file.

Columns 19-20 (Skip Before)
Entry

Explanation

01

Display screen is blanked immediately
for a CRT file.

01-99

Skip to lines 01 to 99 before printing
for printer files.

AO-A9

Skip to lines 100 to 109 before printing
for printer files.

80-82

Skip to lines 110 to 112 before printing
for printer files.

Column 18 (Space After)

9-6

Entry

Explanation

0-3

Number of lines to be spaced
after a line is printed for
a CRT file or printer file.

Output Specifications

Columns 21-22 (Skip After)
Entry

Explanation

01-99

Skip to lines 01 to 99 after printing
for printer files.

AO-A9

Skip to lines 100 to 109 after printing
for printer files.

80-82

Skip to lines 110 to 112 after printing
for printer files.

Use columns 17 through 22 to specify line spacing and
skipping for printer and CRT files. Spacing refers to
advancing one line at a time, and skipping refers to
jumping from one print line to another.
Figure 9-4 shows the possible spacing and skipping
entries for these files. If an incorrect entry is made in
these columns, the compiler drops the entry and
assumes a blank specification. If columns 17 through 22
are blank, single spacing occurs after each line is
printed. Different spacing and skipping can be specified
for OR lines. If there are no spacing or skipping entries
for the OR line, spacing and skipping are done
according to the specifications for the line preceding the
OR line. No spacing or skipping can be specified on
AND lines.
To prevent OCl statements from printing on the same
page as output data, specify a skip to a new page at the
beginning of each job. For example, if the last output
line for the job is printed on line 01 of a page and no
spacing or skipping is specified, the system begins
printing OCl statements for the next job on the next
line. To avoid this, specify a space-1-after.

Specifying spacing (column 18) and skipping (columns
21 and 22) after printing a line saves time because the
system does not have to wait for the forms to advance
before printing can be done.
With spacing, the maximum number of blank lines that
can occur between two lines of print is five. If six
spaces are specified (three after the preceding print line
and three before the current print line), the printer
spaces six lines and begins printing on the sixth line.
Spacing or skipping to the overflow line or past the
overflow line turns the overflow indicator on. Skipping
past the overflow line to a line of the next page,
however, does not turn the overflow indicator on. Under
this condition, use a SETON operation to turn on the
overflow indicator to condition overflow operations.
Skipping is usually done when a new page is needed. A
skip to a lower line number means advance to a new
page. Skipping can also be specified when more than
five blank lines are required between two lines of print.
The entry for skipping must be a two-digit number that
indicates the number of the next line to be printed. If a
skip is, specified to the same line number that the forms
are positioned on, the forms do not move.

Spacing and Skipping for Printer Files

Line spacing and skipping can be specified both before
and after printing of a line. If both spacing and skipping
are specified on the same line, they occur in this order:
1.

Skip before

2.'

Space before

3.

Skip after

4.

Space after

Files

Space Before
Column 17

Space After
Column 18

Skip Before l
Columns 19-20

Skip After l
Columns 21-22

Printer
CRT

0-3
0-3

0-3
0-3

01-99, AO-A9, BO-B2
01 2

01-99, AO-A9, 80-B2
No entry

lThe skip entries you specify in columns 19 through 22 must not exceed the form length specified in line counter
specifications, or must not exceed 66 if no line counter specifications are supplied.
2 0nly allowable entry is 01, which causes the screen to be erased.
Figure 9-4. Possible Spacing and Skipping Entries

Columns 17-22 (Spacing and Skipping)

9-7

Spacing and Skipping for CRT Files

The following rules apply to spacing and skipping for
CRT files:
• A space-before entry (0-3) can be specified in
column 17.
• A space-after entry (0-3) can be specified in
column 18.
• If a CRT file has a record length of 40 or less, the
space-before and space-after entries cannot both
be 3.
• A skip-before entry, to line 01 only, can be in
columns 19 and 20. This entry immediately clears the
display screen.
• A skip-after entry (columns 21 and 22) must not be
specified for CRT files.

COLUMNS 23-31 (OUTPUT INDICATORS)
Entry

Explanation

01-99

Any resulting indicator, field
indicator, or record identifying
indicator previously specified.

KA-KN,
KP-KY

Any command key indicator
previously specified in a SET
operation or used with a
WORKSTN file.

LO-L9

Any control level indicators previously
specified.

H1-H9

Any halt indicators previously specified.

U1-U8

Any external indicator set prior
to program execution.

OA-OG,
OV

Any overflow indicator previously
assigned to this file.

MR

Matching record indicator.

LR

Last record indicator.

1P

First page indicator. The 1 P indicator
cannot be specified for a WORKSTN
file.

Use output indicators to specify the conditions under
which a line or field is written as output.

9-8

Output Specifications

When an indicator is to condition an entire output line,
enter it on the line that specified the type of record (see
Figure 9-5). When an indicator is to condition when a
field is to be written, enter it on the same line as the
field name (see Figure 9-5).
One indicator can be specified in each of the three
separate output indicator fields (columns 23 through 25,
26 through 28, and 29 through 31). If these indicators
are on, the output operation is done. An N in the
column preceding each indicator (column 23, 26, or 29)
means that the output operation is done only if the
indicator is not on (a negative indicator). No output line
should be conditioned by all negative indicators; at least
one of the indicators should be positive. If all negative
indicators condition a heading or detail operation, the
operation is performed at the beginning of the program
cycle when the first page (1 P) lines are written.
If no output indicators are specified, the line is output
every time that record is checked for output. If no
output indicators are specified on a heading or detail
line, that record is also produced as output at the
beginning of the program cycle.

AND and OR Lines
Use an AND line if more than three indicators are
needed to condition an output operation. Enter the word
AND in columns 14 through 16 of each additional line.
The condition for all indicators in an AN D relationship
must be satisfied before the output operation is done. A
maximum of 20 AN D lines can be used for an output
operation if no OR lines are used.
Output indicators can also be in an OR relationship. If
one or the other condition is met, the output operation
is done. A maximum of 20 OR lines can be used for an
output operation if no AND lines are used.
If AND and OR lines are combined, the total number of
AND and OR lines for an output operation cannot
exceed 20.
AND and OR lines can be used to condition entire
output lines, but they must not be used to condition
. fields (see Figure 9-6). However, you can condition an
output field with more than three indicators by using the
SETON operation in calculations. For example, if
indicators 10, 12,14, 16,. and 18 are used to condition
an output field named PAY, in the calculations you can
set on indicator 20 if indicators 10, 12, and 14 are on.
Then condition the output field PAY on indicators 20,
16, and 18 in the output specifications.

Output Specifications

o

-

~ Space

~
~

0 E L

r,;;OD

!
4

5

6

And

1-'--

!

3

I

....

ri ~ ~

Filename

Line

~

Output Indicators

Skip

7

8

9

**

0"

L

Field Name

:t

0

z

0

Z

;3

0

2

'"
0>

0

'"

a

'AUTO

..

~

i

End

II

>

'"

Record

'"0:

to Print

Yes
Yes
No
No

PosItion

in
Output

Zero Balances

Commas

Yes
No
Yes
No

No Sign

CR

~

X = Remove

1

A

2
3

B

J
K

C
D

Plus Sign
Y = Date
Field Edit
Z = Zero

M

4

L

Suppress

Constant or Edit Word

..J

1 2

3

4

5

6

7 8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

10 11 12 1.3 14 1~ Hi 17 1~ t9 ~O 21 22 23 24 25 26 '27 2B 29 30 31 32 33 34 3S 36 37 3R :19 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

One indicator is used to condition an entire I ine of printing.
When 44 is on, the fields named INVOIC, AMOUNT,
CUSTR, and SALSMN are all printed.

Output Specifications

0

~ Space

Output Indicators

SkiD

~

Filename

Line

~

4

5

6

I

R;:; ~

~~ ~

!
3

~~~

~A ~N -=-D

And

0

_

'"



1;7

Z

• AUTD

~ ~

Record

II

8

Yes
No
Yes
No

No Sign

CR

x

= Remove

Y

= Date

Plus Sign
A
B
C
D

J
K
L
M

Field Edit

Z = Zero
Suppress

Constant or Edit Word

~
1

7

to Print

Yes
Yes
No
No

I-o-r--r-It-o-r-.,.--,c-o-r-T-f------i~ ~ ~Sti:i:tn ~
z

Zero Balances

Commas

2 3

4

5

6

7

8

9

10 It t2 13 14 15 16 17 1819 2021 22 23 24 •

9 10 11 1213 1415 16 11 18 192021 22232425262728293031 32333435 3G 373839404147414445464748495051525354555657585960 6162636465666768 G9 70 71 727374

A control level indicator is used to condition when one field
should be printed. When indicator 44 is on, fields INVOIC,
AMOUNT, and CUSTR are always printed. However,
SALSMN is printed for the first record of a new control
group only if 44 and L 1 are on.
Figure 9-5. Output Indicators

Columns 23-31 (Output Indicators)

9-9

Output Specifications

-

0

~ Space

Output Indicators

Skip

~ ~

roEL

~

t-;:;"OO

f-

~
3

a
a
a
a

4

5

1

6

4

a

5

0

a
a

6

0

B

0

9

1

a

0
0
0
0
0

3

7

a

R

E
::t

0

~

~

a:
III 0;

"0

0

z

z

7

9

8

.:.

8 U

z

~~

"AUTO

A"tr:iro

Z>
End
Position
in
Output
Record

Zero Balances

Commas

to Print

Ves
Ves
No
No

I I

No Sign

CR

:

1

A
B
C
0

J

Ves
No
Ves
No

2
3
4

K
L
M

X = Remove
Plus Sign
V: Date
Field Edit
Z = Zero

Suppress

a:

g

Constant or Edit Word

0:
1

2

4

3

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

10 11 12 ,3 ,415 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3' 32333435363 738 39 40 4' 42 43 44 45 46 47 48 49 50 5' 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

ofT IRS iAl\.#[iN 0

0
0
0

2

11

~~~

Filename

Line

Field Name

211

14~

2.1

Utll N'0I1

1b

r-a ~ID

11

- -

h

r-:1

-- --I"'15

IIA'L~1t

C-IN

r-r-r-f--' --

-- f-f--L-...

~

i

Nl~

ANIO

f--

~i
1m

r-_

1"'-,

.-t-

1\

f--

\

I

\

-I-

~~_~

_~_

~-'---.

.--.l_._~_

e-

_\

. - -- .-

--r- f-f--

_ _ L __

The detail line is printed if either of two sets of conditions
is met. If 21,40,01, and 16 are all on, the line is printed;
if 21 and 40 are on and 01 and 16 are off, the line is also
printed.

Output Specifications

0

4

5 16

all
10 12
I a [3
a [4

10
10
[0
10
10

[01 5
10 16
a 17

I a [s
01 9
1 la
,11

I

.1
I~

~

~

IO~

IA~D
7

8

9

10 "

1Kti Ilh.. ,IN

D

:J
A ()

10
[0
10
[0
[0
[0

N

III

/

"'
1
~

~~~

iR

-

(II?

i'"

to Print

Ves
No
Ves
No

e;

~.

No Sign

CR

1
2

A
B
C
0

3
4

X
J
K
L
M

=

V :
Z :

Remove

Plus Sign
Date
Field Edit
Zero
Suppress

Constant or Edit Word
1

2

3

4

5

H _7

8

9

10 11 12 ,3 '4 15 16 17 '819 2021 22 23 24 •

"

Li C
~:I:

NIU
/i

ii·i'i.it'

i i

1< ::

-"'0-1-

/

Figure 9-6. Output Indicators in AND and OR Lines

Output Specifications

Zero Balances

Ves
Ves
No
No

~IIJ I.VJ,I

L __ ' __ .1 __ ' -

A maximum of three indicators can be used to condition
a field.

9-10

Commas

011

~

.i· 1

End
Position
in
Output
Record

.::>
v

32 33 34 35 36 37 138139 140 4' 42 43 44i454647484950515253545556575859606'626364656667686~~ 17'--22 73 7-'

;>

~

Ifi
IW

1;11

"AUTO

119 20121

'2 13

:.:.:... : ... : ..... "".::.:..: ......... :..

Field Name

~[Q:o-

if

Output Indicators

Skip

~~O~L
~~

Filename

line

3

Is pace

g

I--

31~

11'
j

._.-

Assigning Overflow Indicators

The use of any of the. LO through L9 indicators in an OR
relationship with an LR indicator can result in the
specified operation being done twice when LR is on.
One operation is performed durin\,;) LR processing and
the other at detail or total time. Figure 9-7 shows how
to correctly use the LO through L9 indicators in an OR
relationship.

When assigning overflow indicators in the output
specifications, consider the following:
• Spacing past the overflow line turns the overflow
indicator on.
• Skipping past the overflow line to any line on the
same page turns the overflow indicator on.

Command Key Indicators (KA-KN, KP-KY)

• Skipping past the overflow line to any line on the
new page does not turn the overflow indicator on.

Use command key indicators in columns 23 through 31
to condition output operations; however, any command
keys entered in these columns must also be specified in
columns 54 through 59 of the calculation specifications
for a SET or SETOF operation, or used for a WORKSTN
file. All command keys (KA through KN, KP through KY)
can be used for a WORKSTN file. When the operator
presses a command key, the data keyed at the display
station is returned to the program, the corresponding
('ommand key indicator turns on, and all other command
key indicators turn off. You can then use the command
key indicators to condition calculation and output
operations.

• A skip to a new page specified on a line not
conditioned by an overflow indicator turns the
overflow indicator off before the forms advance to a
new page.
• Control level indicators can be used with an overflow
indicator so that each page will contain information
from only one control group (see Figure 9-8).
• An overflow indicator can appear on either AND or
OR lines. However, only one overflow indicator can
be associated with one group of output indicators.
• When the overflow indicator is used in an AND
relationship with a record identifying indicator,
unusual results are often obtained because the record
type might not be the one read when overflow
occurred. Thus, the record identifying indicator is not
on, and all lines conditioned by both overflow and
record identifying indicators do not print.

See Chapter 10, Operation Codes, for complete
information on the SET or SETOF operation.

Overflow Indicators (OA-OG, OV)
Overflow indicators condition output operations for a
printer file. These operations are done only after the
overflow line (end of page) is sensed. To use an
overflow indicator in the output specifications, the same
overflow indicator must be assigned to the printer file
on the file description specifications. If no overflow
indicator is assigned on the file description
specifications, the compiler automatically handles
overflow (see Columns 33-34 in Chapter 3, File
Description Specifications).

• An overflow indicator cannot condition an exception
line (E in column 15) but can condition fields within
the exception record.
• Overflow indicators can be turned on and off by the
operation codes SETON and SETOF.

Output Specifications

-

~

0

Space

~ ~

Filename

line

>- 0

°

1

5

6

0
8

L

Fi",d N,m,

;;:

z

z

a-,'

-En-d---.,-"

z

'AUTO

in
Output
Record

Zero Balances
to Print

Commas

Position

0

'"

R

A~'o
7

Jd

~~

'A'D'D

~

4

~

~=t
i'R
>f-

!
3

o

:>

Output Indicators

Skip

@~
t: tl

Yes
Yes

Yes

No
No

Yes

No
No

No S.ign

X

=

Remove

J

Y

=

K
L
M

Plus Sign
Date
field Edit

Z

=

CR

A
B
C
D

Zero

Suppress

a:
~

Constant or Edit Word

~

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3233 34 35 36 37 38 39 4041 42 43 44 45 46 47 4849 5051 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

OOvJ

rO+-t-r
+_+-+-+-+-+_ r--2
O

0 __

L1NLR
LR

~

O

r--

°3 0
°4 0
t---T-t--ic--+--+---1-+ -+--+--f-f-t----t--l---+---+-t --+-If--+---+-+-+--t--+-+--I-°5 0
--- r---r---C-['
°6 0
-- -- --_.
,-'----'----

-

.

-1- --r

r- --\- t -t--t-I-+--t- t--t--+-+--t--+----1--+--t--+--+--t-- -

-f-C--f-

f - --I-' - - r - r - - _. -- f - r - r - - , - .-+--!f-\--t-+--t-i

-+--+-+--+-+-+--+-j·--t----+-If-+---t--I---+-+---I-+--+--t--t--·+---I-+---+--+-+---t--+-t--+--+-t-- -

. -r--f-

Figure 9-7. Correct Use of Indicators LO through L9 in OR Relationship
Columns 23-31 (Output Indicators)

9-11

Output Specifications

o

-

Output Indicators

Skip

1L

Filename

Line

~

:::(

C)

3

4

a

1

a

2

5

6

7

8

[>

a

Z

Zero Balances
to Print

No Sign

CR

:

X

=

Yes
Yes
No
No

Yes
No
Yes
No

1
2
3
4

A
B

J

Y

=

K
L
M

Z

I I

End
Position

in
Output
Record

a

Z

Z

Commas

'AUTO

C
0

Remove
Plus Sign

Date
Field Edit

Zero
Suppress

CI:

~

Constant or Edit Word

0:

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 '

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

~ PR I Nrr _O,~ ~~ ~~ =,= :~~~ =~ __: _t---1_--t-f--_t--+-~' ~ =t---+-~-:--::-iB':::'+'1--~t-,A~+--IT+E-+-'-+i-+f--4--+-+-+-+-i+-+-~+ i-l--+!-+--+-+--+ --+-+-+-+-+--+--1

a 3

.~~~~~-+-r~-+~~-r~~-r4-~-r~~

~~- ~-r--- r-r- --r--~- - --~~-

--!

-r--------f--:-r--I----

7';-0-- -'-r--i- --- -f__-- f---~---f__-;;-';-0 ~ f__-i-i-- - -- ~-. -- - - - --

---

-

~~- --

~~-~----r--r-----------ir--ll
~ ___ ~ _~_ ~
_ _~u_ _ -L

-r 1-[---1-

-r--

---1---r--

_ _ __ _

- - ~

I

I

--:-f__-~-f__--------l---f--

-'---

ill

-~
1~ : ~CI~O~ l~':

- -

,

0

06

,_

'DALANCiE '

i

I-I---b---l-i=;'

i-

-I--

I

-- - - -

-'-~'----+i-----

t,--r--~-t-_L _____ ~L

L-L_

-r----1- _

~
:-ftf1ITT
+i
i

I

-1-

I

I

I

~-H-I-r--i--+-

-tr-tt-r--r--f--r-l+--I---t-+
L ~~_'--L-

L ____ l_

'- ___

-I---f__

!

I

_

'-lir--

1-+-1-!__ •I;

~L~

This is the coding necessary for printing headings on every
page: first page, every overflow page, and each new page to
be started because of a change in control fields (L2 is on).
Line 01 allows the headings to be printed at the top of a
new page (skip to 06) only when an overflow occurs (OA is
on and L2 is not on).
Line 02 allows printing of headings on the new page only
at the beginning of a new control group (L2 is on). This
way, duplicate headings caused by both L2 and OA being
on at the same time do not occur. Line 02 allows headings
to be printed on the first page after the first record is read
because the first record always causes a control break (L2
turns on) if control fields are specified on the record.

Output Specifications

0

~

I---

~
~

...

~

*~~
-~I-

Filename

Line

Output Indicators

Skip

Space

Jd

0 E L

"Aro'D
o

R

L

4

5

6

7

8

9

~

~

z

z

z

~f-: ~I-'---f-- - - - ~_
__ , _

_

'AUTO

~

~

~

No Sign

CR

Yes
No
Yes
No

1
2
3
4

A
B

II

C
0

X = Remove
J
K
L
M

Plus Sign
Y = Date
Field Edit
Z = Zero
Suppress

CI:

Constant or Edit Word

-'
III

0:

1

2

3

4

5

tt- -

-t-- --

f-

8

End
Position
in
Output
Record

Zero Balances
to Print

Yes
Yes
No
No

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

-,ot=,~~~=,~'tHf~il--J~tTU-tl= tl~JtJJ_U~

0

3

CI:

Commas

10 11 12 13 1415 16 17 18 1920 21 2223 24 25 26 27 28 29 30 31 32333435 3G 37 38 :19 4041 4243444546 47 4849 5051 52 53545556 57 58 59 60 61 626364 6566676869 70 71 72 73 74

:: :"RtNT
a

IT
"0

f-;;"ND
3

[>
Field Name

-I-- -

'--_ __

- -- _

___

Cid! _ I I i~
_+ l- --~-11-r-r-r--WJ-j- H-r-- -~ 1-[ ~-t --1-++
~l_
._L,,-_U
_LLL.-LJ U_L ~__
_

_

.1 __

_ __

1--0-4-+

~

--

r--\ H++-+~-+---t-t-,-+i~-+--+--+--+i-rl

J++-+---+---+--4---+-++I-+---I,--+-+-++-+-+--+-I
+-+--+J--t--l

_.1_..1__ --'----'-4-L-L---'--'-_'---.L--'--'-'--'-----'--'-_

i

This is the necessary coding for the printing of certain fields·
on every page; a skip to 06 is done either on an ove~flow
condition or on a change in control level (L2). The N L2
indicator in line 01 prevents the line from printing and
skipping twice in the same cycle.
Figure 9-8, Using Control Level Indicators with an Overflow Indicator

9-12

Output Specifications

Figure 9-9 shows the setting of overflow indicators
during the normal overflow routine and during a fetched
overflow routine for both normal output and exception
output. The left portion of the graph shows the general
program cycle. The solid black lines indicate that the
indicator is on, and the dashes show a connection
between the end of one cycle and the start of the next.

External Indicators (U1-U8)
You may want to condition certain output records on
external conditions. If so, use the external indicator to
condition those records.

COLUMNS 32-37 (FIELD NAME)
First Page Indicator (1 P)
The first page (1 P) indicator allows printing either on the
first page only or on every page if used with an
overflow indicator (see Figure 9-10). The line
conditioned by the 1 P indicator must contain constant
information used as headings or fields for reserved
words such as PAGE and UDATE. The constant
information is specified on the output specifications in
columns 45 through 70.
Use the 1 P indicator only with heading or detail output
lines. It cannot be used to condition total or exception
output lines, in an AN D relationship with control level
indicators, or to condition output for a WORKSTN file.
See Column 41 (1 P Forms Position) in Chapter 2,
Control Specifications, for information on forms
alignment of the first page.

Halt Indicators (H1-H9)
If certain error conditions occur, you might not want
output operations performed. Use halt indicators to
prevent the data that caused the error from being used
(see Figure 9-11).

In columns 32 through 37, use one of the following
methods to specify each field that is to be written out:
• Any field name or data structure name previously
used in this program
• The special words PAGE, PAGE1 through PAGE7,
*PLACE, UDATE, UDAY, UMONTH, or UYEAR
• A table name, array name, or array element

Field Names
The field names used must be the same as the field
names on the input specifications (columns 53 through
58) or the calculation specifications (columns 43 through
48). Do not enter a field name if a constant is used in
columns 45 through 70. If a field name is entered in
columns 32 through 37, columns 7 through 22 must be
blank.
Fields can be listed on the specifications sheet in any
order because the sequence in which they appear on the
output record is determined by the entry in columns 40
through 43. However, the fields are usually listed
sequentially. If fields overlap, the last field specified is
the only field completely written.
The sign (+ or -). of a numeric field is in the units
position (rightmost digit). The units position prints as a
letter unless the field is edited. See Column 38 (Edit
Codes).

Columns 32-37 (Field Name)

9-13

NORMAL OVERFLOW ROUTINE
NORMAL OUTPUT
Overflow
During
Detail Output
Read a
record

Overflow
During
Total Output

Overflow
During
Detail Calc_

r

0

I
I

I

Overflow
During
Total Calc_

Overflow
During
Detail Output

I

I

I

I

I

I

r
I
I
I

I
I
I

I

OF

I

+

OF

OF
lines

•
OF

Total
output

IfOFl

OF

Overflow output
T = Total
H = Heading
D = Detail

OF
lines

I~

oFl reF

OF
lines

Perform all
calculations
not conditioned
by control level
indicators
(columns 7-8)

lin~ lllnes

Heading and
detail output·

~

Set off
control level
indicators

OF
OF
lines

OF

•

+
OF

I

I
I

OF
OF
lines

I

U
Off

U

Output Specifications

I

I

I

I

I

I

I
I
I
I

I

I
Off

Figure 9·9. Overflow Printing: Setting of the Overflow Indicator

9·14

I

I

I
I

I
I
Off

•

•
I

I

I

Off

V

Overflow
During
Total Calc_

I

I

•

•

EXCEPTION OUTPUT
Overflow
During
Detail Calc_

I
I

I
I

I

Overflow
During
Total Output

I

I
I

I

Perform all
calculations
conditioned by
control level
indicators
(columns 7-8 of
calculation
specifications)

FETCHED OVERFLOW ROUTINE
NORMAL OUTPUT

EXCEPTION OUTPUT

I
I
Off

Off

U

I
Off

Output Specifications

s

0

~ Space

r---

~ a~

Filename

Line

5

And

0 E L

o

1

:;;:

Q)

R

0

0

Z

7

8

9

a
cc

en

8

0

z

Z

~'ND

6

Field Name

'AUTO

~

:>
End
Position

~

Record

ZPro Bal;mcf's

Commas

to Print

No SIgn

Yes
No
Yes
No

Yes
Yes
No
No

II

in
Output

"0

"Aroco

j

4

I

R~
_ ' - I~-

!
J

Output Indicators

Skip

X

CR

J
K
L
M

A

B
C

=

Y •

Remove
Plus Sign

Date
Field Edit

Z • Zero
Suppress

cc

Constant or Edit Word

..J
Q)

Q:
1

2

3

4

5

6

8

7

9

1011 12 13 14 15 16 17 18 19 20 21 22 23 24

~

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 19 4041 42 43 44 45 46 47 48 49 sO 51 52 53 54 55 56 57 58 59 GO 61 62 63 64 65 fiG 67 68 69 70 71 72 73 74

~.~~~t'Hl'NTH .. J~l±r- -.ll~r------r-c----.-.
_7~r~3r[! 0

~ ="--~,-. -. -.-r-f-.

:

,

1

1

~~.

~---- -~---

.. .

___ '-__1_"--_ ~._ .~. _ _

. -

-

~r-t-+-r·t-+-t_!-+-r~+-r~-r-~-I-

..

.t---t-t--+-+-t-t-+-+-f--+-+-+-+-+-+-+--+-+--+---+--H

-f--·-r-r---t~-t-~~·+-~~-+-r1-+-~-+_r~+-~~-+-r4_+-~-+-+4

-c----~r------t·-r4_+-~_+_r_+_

.. - - - - · - 1 - - -

_

'IACCooINT,r-r-

18

·1--

... f-- -

_.~_ ..J--'-'--'- . ..J._-'--''--'--'--..J._.L-J'-L_L.-L.....L-.L..-.Jl..-I._-'--'--L. • .L-L-l--L--'--'--'--L'-_...L--'--'_ L

,_

L-

_

-'--'--'---'--'

The 1 P indicator is used when headings are to be printed on
the first page only,

Output Specifications

o

_

r--

~ Space

i ~~~
i~~~

Filename

Line

f-

o

0

4

5

Output Indicators

R

6

7

8

.1

I

And

AL

Field Name

aI
~

E L

fA CO CO

"A'N"CO
3

Skip

~ ~
It~-+--,---r----r----.---~

t

0
Q)

o

z

;3

0

z

'AUTO

~

c.:
en

~

:>

Commas

Zero Balances

Yes
Yes
No
No

Yes
No
Yes
No

End

Position
in

Output
Record

to Print

No Sign

X

=

Remove
Plus Sign

J
K

Y

=

Date

L
M

Z

=

Zero
Suppress

CR
A

B
C
0

Field Edit

cc

Constant or Edit Word

..J
Q)

Q:
,

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 20 21 22 23 24 '

9 1011 1213 14 15 16 17 18 1920 21 2:? 23 24 2526 27 28293031 32333435 36 37 3B 39 4041 4243444546 47 48 49 5051 5253545556 5758596061 626364 65666768 697071 72 73 74

The 1 P indicator and an overflow indicator can be used to
print headings on every page,
Figure 9-10, 1P Indicators

Columns 32-37 (Field Name)

9-15

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

r-Field Name

Filename

Line

Position

Position

'ORrf-;N"Co
3

4

5

6

7

B

£)

Zero

To

From

Position

10 11 12 13 14 15 16 17 18 13 20 21 22 23 24 25 2G 21 2829303132333435 363738 39 40 414243 44454647 48 49

sa

Plus Minus or
Blank

51 52 53 54 555657 58 59 6061 62 636465666768 69 70 71 72 73 74

When an error condition (zero in FIE LOB) is found, the
halt indicator turns on.

Calculation Specifications

C
f---

~

I

6 -

~
Line

Indicators

~ i5

And

.5 ~

I- "0

4

5 6

o

1

C

o

2

C

o

3

C

o

4

C

o

5

C

o

7

C

.

J

Arithmetic

Factor 1

And

Operation

2 5:

Factor 2

i

Comments

Length ~
<
.~ -; Lookup(Factor 2)is

Name

85 z

Plus IMinusl Zero
Compare
1 > 2 1 211 = 2

~ ~

r£

E ::. en

~
3

Resulting
Indicators

Result Field

b

Z
Z
Q :I: High
Low Equal
9 10 11 12 13 14 15 1617 18 19 20 21 22 23 2425 26 27 2829 3031 32 3334 35 36 37 3B 39 40 41 42 43 44 45 46 47 48 49 5051 52 53 54 55 56 57 58 59 6061 62 63 64 6566 67 68 69 7071 72 73 74

GO 0 ENiD

1

1
1

When H 1 is on, all calculations are bypassed.

Output Specifications
-

o

~~

Filename

Line

Output Indi.lcators

Skip

I-

~

~~f-

0

E L

~roro

And

;

Field Name

I

~ ~~,3.

>

I-

Space

e~
~~~23

~

Z

~

AND

~•. .•. ::===~~-=-::....-> I=Co=:=:=as={=z=er,;;~o~:~~:~,;;~c=e=s

l=N=O=:=ig=nt=CA=R+J=I:

And

~

0:

~ ~

I
I

8
·AUTO

~

~ ~

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

~:~lion

II

Ves

No

2

B

K

~~

~~s

~

g

~

~ ~I~~~~:n
Field Edit

Z =

~~~~ress

a:

in
°RuecloPurdt

g

Constant or Edit Word

Q:

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 •

9 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

FIELDA and FIELDB are printed only if H1 is not on.
Therefore, if H 1 is on, FIE LOA and FIE LOB are not
printed. Use this general format when you do not want
information that is in error to be printed.
Figure 9-11. Preventing Fields From Printing

9-16

Output Specifications

Special Words
Page Numbering (PAGE, PAGE1-PAGE7)

PAGE is a special word that, when used, causes
automatic numbering of the pages. Enter the word
PAGE or PAGE1 through PAGE7 in these columns if the
pages are to be numbered. When a PAGE field is
named in these columns without being defined
elsewhere, it is assumed to be a four-digit, numeric
field with zero decimal positions. Leading zeros are
suppressed automatically. A PAGE field can also be
defined on input or calculations specifications as a
numeric field from 1 to 15 digits long, with zero decimal
positions.

Page numbering can be restarted at any point in a job.
To do this, set the PAGE field to zero before it is
printed by specifying either blank after in column 39 or
an output indicator. If the status of the indicator is as
specified, the PAGE field is reset to zero and 1 is added
to the PAGE field before it is printed (see Figure 9-12).
The eight possible PAGE entries (PAGE, PAGE1 through
PAGE7) may be needed for numbering different types of
output pages or for numbering pages for different
printer files.

The page number starts with 0001 unless otherwise
specified, and 1 is automatically added for each new
page. See Columns 53-58 (Field Name) in Chapter 7,
Input Specifications, for information concerning page
numbering that starts at a number other than 1.

Columns 32-37 (Field Name)

9-17

Repeating Output Fields (*PLACE)
I
I,

*PLACE is a special RPG II word that allows you to
write the same fields in several locations on one record
without naming the fields and giving their end position
each time the fields are to be written. The fields
repeated by means of *PLACE are written ending in the
position specified in columns 40 through 43 of the same
specifications line. For example, if FIELDS A, B, and C
appear twice on one record, the fields can be specified
in two ways:
• Define each field and its corresponding end position
each time the field is to be printed or written on disk
(see Figure 9-13) .
• Use the special word *PLACE (see Figures 9-13 and
9-14).
Both coding methods shown in Figure 9-13 produce a
record that looks like this:

10

20

30

40

50

60

75

FIELDA

FIELDB

FIELDC

FIELDA

FIELDB

FIELDC

FIELDD

Ending Record
Positions
Fields

Output Specifications
~
~ Space

0

I---

~

~~ ~

roEL

0-

r;oo

>

I-

E

o

~
5

o

1

o 2

R

3

0

3l

~

0

0

z

z

z

6

7

8

9

Fl,1d N.m,

Ves
Ves
No
No

&-'---End---r-o

II

Position

in
Output
Record

'AUTO

to Print

No Sign

CR
A
8

Ves
No
Ves
No

cr.
-'

C
0

J
K
L
M

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

Constant or Edit Word

aJ

Ii:

1

2

3

4

S

6

7

8

9

1011 12 13 14 lS 16 17 18 19 20 21 22 23 24 '

10 11 12 13 14 15 16 11 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 6B 69 70 71 72 73 74

~ "KJ.N ,

- H____ 1I1f- -- ~1

a

-c-

15

-

PA~E -c-l--r-t1S -- ---r-

--

-- -

-f-- -- -- -

--- -

f-+--t-t-+-+-+--+-+--t--i-+-t-I--f----t-l--I--t-+-+-l---+--t--l--I-II--I---f-- c- -c-- --+--+-I--+--+-+-+-+-t-l--+-+-+- - -- -

o 4
a
- - --- - r-~r- -:::

Zero Balances

Commas

r;;~D

r-t-t-t-t-t-+-+-+-+-- - -f-

o

11

t3 ~ ~

Filename

Line

>- ,-

Output Indicators

Skip

~-~-

-r--- -

'--~.

c_ •

___

-f----- ---

--r---

._~_I_L_L_JLL_'___J-----L_L_J_L_---L..J'-----L_.J._

- - f--+--- - H -

--1--11--+---+--1---++-11--+--1--1-- - -c-- -t-l--+-+-t-t-+---t-i

t

- r-- ---+--I--+-+--I-f----+-I-f-_i_ +-I-i-'l--t-t--t-l-t--t--r--- - --+---+-1--+--1--- -/-----1-+-+--1-- -'--r- ----c- -

-------f--- -,c-r-------f-f---f--I---J-----

___ L_'--. _ '---L _ _ '---__ L-_'---~ __

--- ---f--r- -

f---

L. __ '---'---_'- __ '--- _ _ 1-_ _ '--- __ "----.L-L--L---L-l_L

e-

-

--f-r-r- --r-r-- -f- -

_"------'------'---'--'----'---'--'----'-_--'----'----'-_1

When indicator 15 is on, the PAGE field is reset to zero and
a 1 is added before the field is printed. When 15 is off, a 1 is
added to the contents of the PAGE field before it is printed.
Figure 9·12. Resetting the PAGE Fields to Zero

9·18

Output Specifications

,

Output Specifications

o

f---

:>

Field Name
Filename

Line

End
Position

!

~

4

3

5

6

in
Output
Record

'AUTO
1

8

Comm3s

Zero Balances
to Print

Ves
Ves
No
No

Ves
No
Ves
No

I I

No S.ign

CR

:

I

A
B
C

J

2
3
4

D

K
L
M

X • Remove
Plus Sign
V ' Date
Field Edit
Z " Zero
Suppress

a:

Constant or Edit Word

..J

co

0:

1

2

3

4

5

6

1

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

9 10 11 12 13 14 15 16 11 18 19 20 21 22 23 24 25 26 21 2329 30 31 32333435 36313839 40 41 4243 44 45 46 41 4849 50 51 52 53 545556 51585960 61.62 63 64 65666768 69 10 71 72 73 74

To repeat an output field, each field can be defined each
time it is to be printed or written to disk,

Output Specifications

o

Skip

:>

Output Indicators

f---

Field Name
Filename

line

End
Position
in
Output
Record

!
~

3

5

4

6

1

8

Zero Balances
to Print

Ves
Ves
No
No

Ves
No
Ves
No

I I

No Sign

CR

:

X = Remove

I
2
3

A
B
C

J

Plus Sign
V = Date
Field Edit

4

D

K
L
M

Z • Zero
Suppress

a:

Constant or Edit Word
-

0

Zero Balances
to Print

Yes
Yes
No
No

c::

in
0

:::t

Commas

Ur-.---End--r'-'I
Position

~ "IKLLIN 1_,_: ~ ,=~ _,=~ ~: ,+~=

~~ ~
o

8

2>

1

I

2:!

'"Aroro

~~'o
7

Output Indicators

Skip

i~D ~~
E L

f-

~

Space

--

~tt\C

I-

~

J'

' '

I

m'

I

,I

I

I

~~~r:-= --:~ -,--,~~-,~
~~tltl~C E = ~ ·I~:'--~--il)-~~_-l~jl '-lili~ l=I~~,·Fltlill
:;:~=oc_ .... ~I' ·rILI'_jj ____ I~-~-'··L\t)C:- _-j=~s
11-1 !+tt f-1f1t J=tt~
.;+~ _. -.. -l·
11- .··r · - - -~- ----~~-t- ·TItl-iJ----,1·-,I+H hi·· -1+:-ril+ f -t+
--1-' .-. --. ..--- -- j
- . - -," - -1-- --f 1-1J
-+-

j

.•

[--I- - 14
0

---f-

-I
______ l__ J__

Figure 9-14. *PLACE

9-20

Output Specifications

t--

-.

-

.. - -

----

. _.

--e--

_I -

-j --

i i
1"I-t, -:1- __+
___________ ~ __ LJ_ . . __ LL_,._LL
J_..L·
--1- -,-- -- --

11

I

I;

_..1

-

1.--

l
'-O-!--t1-+I
_....l_ LL'--l-i,
1

1

When you specify *PLACE, all fields named for each
record type (H/D/T /E) are written as usual in the
location specified. The entry *PLACE then causes all of
these fields to be written ending at the position
specified in columns 40 through 43 of the *PLACE
specification. When you specify *PLACE, remember:
• *PLACE must be specified after the field names that
are to be written in different positions in one record
(see Figure 9-14).
• *PLACE causes all fields within a record type to be
written, not just the field name on the line
immediately above the *PLACE entry.
• *PLACE must appear on a separate specification line
each time a field or a group of fields is to be written.
• An end position no greater than 256 must be
specified for every *PLACE line. Allow enough space
for all fields to be written (see Figure 9-14);
otherwise, overlapping occurs.
• Multiple or successive *PLACE entries can be
specified if the fields preceding the first *PLACE
specification are to be repeated more than once.
• The leftmost position of the fields to be written by
the *PLACE specification is always assumed to be
position 1.
• The high end position to be used by *PLACE cannot
be defined by a whole array. If a whole array does
have the highest end position of all fields preceding
th.e *PLACE, a field must be defined that has an end
position greater than the end position of the whole
array. This field can be a one-position blank
constant.
• Additional fields or constants can be specified after
the *PLACE specification and are not affected by any
preceding *PLACE specification.
Note: Attempts to use the *PLACE function for other
than its defined purpose may produce unpredictable
results.

Date Fields (UDATE, UMONTH, UDAY, UYEAR)
To have the date printed on a report or program listing,
use special words UDATE, UMONTH, UDAY, or
UYEAR. The date fields are established at job setup
time. UDATE contains the program date that may not
be the same as the date in the result field of the TIME
operation. The result field of the TIME operation
contains the system date. See the System Support
Reference Manual for a complete discussion of the
system date, program date, and the DATE OCl
statement. The following rules apply to date fields:
• UDATE prints a 6-character numeric date field in one
of three formats:
Month/ day /year
Year /month/ day
Day/month/year
Use columns 19 and 20 of the control specifications
to specify the date format and the editing to be done.
If columns 19 and 20 are blank, the date format is
determined by the contents of column 21.
• Use UDAY for the day only, UMONTH for the month
only, and UYEAR for the year only.
• These fields cannot be changed by any operations
specified in the program. Thus, these fields are
generally used only in compare and test operations.

COLUMN 38 (EDIT CODES)
Use column 38 to:
• Suppress leading zeros in a numeric field
• Omit a sign from the low-order position of a numeric
field
• Punctuate a numeric field without establishing an edit
word
A table summarizing the edit codes that can be used in
column 38 is printed above columns 45 through 70 on
the output specifications sheet. If column 38 contains
an edit code, columns 45 through 70 must be blank
except for the following condition: if asterisk fill (that is,
the leading zeros of the field are to be replaced with
asterisks) or a floating currency symbol is required, enter
,*, or the currency symbol (enclosed in apostrophes) in
columns 45 through 47. When an edit code is used to
punctuate an array, two spaces are automatically
inserted between fields of the array to the left of each
element. Only zoned decimal numeric fields can be
edited.
Column 38 (Edit Codes)

9-21

Note: Editing fields of a non printer file must be done
with caution. If you do edit fields of a nonprinter file,
you must be aware of the contents of the edited fields
and the effects of any operations you want to do on
them. For example, if you add an unedited field to an
edited field, the results will be erroneoLls.

Figure 9-15 shows the edit codes and the options they
provide. Figure 9-16 illustrates how data looks when it
is edited by edit codes. Each code punctuates the field
a little differently. All codes suppress leading zeros,
except when J is entered in column 21 of the control
specifications. In this instance, all zero balances and
balances with zero values to the left of the decimal
comma are always written with one leading zero (such
as 0,00 or 0,04). If an edit code is specified on the
output specifications and the edit code is to write zero
balances, a zero balance field always has a zero to the
left of the decimal comma. The edit code cannot
suppress this zero.

COLUMN 39 (BLANK AFTER)
Entry

Explanation

Blank

Field is not reset.

B

Field specified in columns 32
through 37 is reset to blank or
zero after the output operation
is complete.

Use column 39 to reset a numeric field to zeros or an
alphameric field to blanks. If the field is conditioned by
indicators in columns 23 through 31, the blank after is
also conditioned. This column must be blank for
look-ahead and UDATE fields.

Figure 9-17 shows editing for date fields.

Resetting fields to zeros is 'useful when totals are
accumulated and written for each control group in a
program. After the total is accumulated and written for
one control group, the total field can be reset to zeros
before accumulation begins on the total for the next
control group.

Normally, when an edit code is used in column 38, an
edit word cannot be defined in columns 45 through 70;
however, there are two exceptions:

If blank after (column 39) is specified for a field to be
written more than once, the B should be entered on the
last line specifying output for that field.

• If asterisks are to replace leading zeros, enter ,*, in
columns 45 through 47 of the line containing the edit
code.

When blank after is specified with a table name, the
field that is blanked contains the last element found by
a successful LOKUP, or the first element of the table if
no LOKUP or no successful LOKUP occurred. Blank
after can be specified with an array element or a whole
array.

• If the currency symbol is to appear before the first
digit in the field (floating currency symbol), enter the
currency symbol (enclosed in apostrophes) in columns
45 through 47 of the line containing the edit code.
Asterisk fill and the floating currency symbol are not
allowed with X, Y, and Z edit codes.
The currency symbol can appear before the asterisk fill
(fixed currency symbol). This is done in the following
manner:

1.

2.

,Place the currency symbol constant one space
before the beginning of the edited field by entering
the currency symbol constant on a separate
specification line.
Place ,*, in columns 45 through 47 of the line
containing the edit code.

Note: If the currency symbol is not the dollar sign ($),
the currency symbol must be entered in column 18 of
the control specifications.

Figure 9-18 shows the effect the different edit codes
have on the same field with a specified end position for
output.
9·22

Output Specifications

COLUMNS 40-43 (END POSITION IN'OUTPUT
RECORD)
Entry

Explanation

1-4096

End position for disk or
SPECIAL file

1-4075

End position for BSCA file

1-1919

End position for WORKSTN file

1-132

End position for 132- position printer

1-79

End position for CRT file

K1-K8

Length of format name
for a WORKSTN file

Use columns 40 through 43 to define the end position
of a field or constant on the output record. All entries in
these columns must end in column 43. Enter only the
position of the rightmost character in the field or
constant.

Note: If columns 40 through 43 are left blank, the field
or constant is placed in the output record immediately
following the field specified in the previous output
specification for that record. If no previous field
specification exists for the record, the high-order
position of the field is placed in position 1. A blank end
position with *PLACE causes the *PLACE to be ignored.

Entry in Column 21 of Control Specifications

Commas

Decimal
Point

Sign for
Negative
Balance

D or Blank

I

J

Zero
Suppress

1

Yes

Yes

No sign

.00 or 0

,00 or 0

0,00 or 0

Yes

2

Yes

Yes

No sign

Blanks

Blanks

Blanks

Yes

Edit
Code

3

Yes

No sign

.00 or 0

,00 or 0

0,00 or 0

Yes

4

Yes

No sign

Blanks

Blanks

Blanks

Yes

Yes

CR

.00 or 0

,00 or 0

0,00 or 0

Yes

A

Yes

B

Yes

C
D

J

Yes

K

Yes

Yes

CR

Blanks

Blanks

Blanks

Yes

Yes

CR

.00 or 0

,00 or 0

0,00 or 0

Yes

Yes

CR

Blanks

Blanks

Blanks

Yes

Yes

- (minus)

.00 or 0

,00 or 0

0,00 or 0

Yes

Yes

- (minus)

Blanks

Blanks

Blanks

Yes

L

Yes

- (minus)

.00 or 0

,00 or 0

0,00 or 0

Yes

M

Yes

- (minus)

Blanks

Blanks

Blanks

Yes

X'
y2

Yes

Z

Yes

'The X code performs no editing.
2The Y code suppresses the leftmost zero only. The Y code edits a three-to six-digit field according to the following
pattern :
nn/n
nn/nn
nn/nn/n
nn/nn/nn

Figure 9·15. Edit Codes

Columns 40-43 (End Position In Output Record)

9·23

Edit
Code
Unedited

1
2
3
4
A
B

C
D

J
K

L
M
X

Positive
Number2 Decimal
Positions

Positive
Numbero Decimal
Positions

Negative
Number3 Decimal
Positions

Negative
Numbero Decimal
Positions

1234567
12,345.67
12,345.67
12345.67
12345.67
12,345.67
12,345.67
12345.67
12345.67
12,345.67
12,345.67
12345.67
12345.67
1234567

1234567
1,234,567
1,234,567
1234567
1234567
1,234,567
1,234,567
1234567
1234567
1,234,567
1,234,567
1234567
1234567
1234567

00012 1
.120
.120
.120
.120
.120CR
.120CR
.120CR
.120CR
.120.120.120.12000012 1

00012 1
120
120
120
120
120CR
120CR
120CR
120CR
12012012012000012 1

1234567

1234567

120

120

y
Z

Zero BalanceTwo Decimal Positions
Entry in Column 21 of
Control Specifications

Zero Balance-

o Decimal

I

J

Positions

000000
.00

000000
,00

000000
0,00

000000

.00

,00

0,00

a

.00

,00

0,00

a

.00

,00

0,00

a

.00

,00

0,00

a

.00

,00

0,00

a

000000

000000

000000

000000
0/00/00

D or Blank

a

1The EBCDIC values of negative decimal numbers do not print as numerics. The alpha equivalent is printed if column 45 of the
control specifications contains a blank (that is, the program halts for unprintable characters), or if the operator takes a continue
option to the halt. A minus zero (hex DO) prints as a blank, a minus 1 (hex D1) as J, a minus 2 (hex D2) as K, and so on.

Figure 9-16. Examples of Edit Code Usage

9-24

Output Specifications

Control Specification

UDATE

Edit
Code

Contents of
Column 19

Jan 30,1978

Y

Blank

Contents of
Column 20
Blank

M

Blank

Blank

D

y

Blank
-

Blank

Contents of Column 21
D
I

1/30/78
1-30-78

30/01/78
30-01-78

30.01.78
30-01-78

30.01.78
30-01-78

1/30/78
1-30-78

1/30/78
1-30-78

1/30/78
1-30-78

1/30/78
1-30-78

30.01.78
30-01-78

30.01.78
30-01-78

30.01.78
30-01-78

30.01.78
30-01-78

78.01.30
78-01-30

78.01.30
78-01-30

78.01.30
78-01-30

78.01.30
78-01-30

J

Figure 9-17. Date Fields

Negative Number - 2 Decimal Positions
End Position Specified as 10
Edit
Code

Output Print Positions
3 4 5 6 7 8 9 10 11

Unedited
1
2

3

4
A
B

C
D
J

K
L

M
X
y
Z

4
4
4
4

Kl

0 0 4 1
4
1
4
1
1
4
4
1

2
2
2
2

1 2 C

R

1 2 C R
1 2 C R
1 2 C R
4
1 2 -

4
4
4

1 2

-

1 2 1 2 0 0 4 1 Kl
0 / 4 1 / 2
4 1 2

1 K represents a negative 2.

Figure 9-18. Effect of Edit Codes on End Position

80lumns 40-43 (End Position in Output Record)

9-25

COLUMN 44 (PACKED OR BINARY FIELD)
Entry

Explanation

Blank

Field is zoned decimal numeric
data or alphameric data. Leave
this column blank for nondisk files.

P

Field is to be written on disk in
packed decimal format.
Field is to be written on disk in
binary format.

B

Use column 44 to specify whether a num~ric field
(decimal number) is to be written on disk in packed
decimal or binary format. Packed decimal and binary
fields cannot be displayed or printed; these fields can be
written only on disk. Column 44 must be blank for
*PLACE.
After decimal numbers are processed, they can be left in
the zoned decimal format. However, for more efficient
use of disk space, convert decimal numbers into packed
decimal or binary format. When binary output is
specified, a numeric field one to four digits long (zoned
decimal in storage) is converted into a 2-byte binary
field when it is written on disk; a numeric field five to
nine digits long is converted into a 4-byte binary field.
When packed decimal output is specified, a byte of disk
storage (except for the low-order byte) can contain two
decimal numbers. See Column 43 (Packed or Binary
Field) in Chapter 7, Input Specifications, for a description
of how data fields are represented in zoned decimal,
packed decimal, and binary formats.
Notes:
1. Although packed and binary fields require less disk
storage space, the conversion routines needed to
handle such data increase the object program size
(and execution time).
2. Key fields cannot contain any hex FF characters.
Therefore, if the key field is a binary field, you must
be sure that no hex FF characters appear in the key

field.

9·26

Output Specifications

COLUMNS 45-70 (CONSTANT OR EDIT WORD)
Use columns 45 through 70 to specify a constant, the
format name for a WORKSTN file, or an edit word. If
you are using. edit codes, you can also use columns 45
through 47 to specify a floating currency symbol or
. asterisk fill.

Constants
A constant is any unchanging information that is to
appear on a report. Constants are usually words used
for report headings or column headings.
The following rules apply to constants (see Figure 9-19
for examples):
• Field name (columns 32 through 37) must be blank.
• A constant must be enclosed in apostrophes. Enter
the leading apostrophe in column 45.
• An apostrophe in a constant must be represented by
two apostrophes. For example, if the word you're
appears in a constant it must be coded as 'YOU" RE'.
• Numeric data can be used as a constant.
• Up to 24 characters of constant information can be
placed in one line. Additional lines can be used, but
each line must be treated as a separate line of
constants. The end position is specified in columns
40 through 43. If no end position is specified, the
constant is placed in the output record immediately
following the field or constant specified in the
previous output specification line for that record (see
Columns 40-43, End Position in Output Record, in this
chapter).

Output Specifications

-

o

r: Space

o

R

~ 'N
4

5

6

7

8

:: ~

ro

And

I
!

0
C!J

~

Z

2

0

051

0

'0
Z

~ ~
8 U

I
•

I

AUTO

.;

~::
~~

0..

CR

:.

X '"

A

J
K

Plus Sign
Y' Date
Field Edit
Z = Zero

No

a

Yes

C

L

No

D

M

::J
~

W Ol

No Si~"

Yes

a:

In
Output
Record

~

Zero Balances
to Print

Commas

And

Remove

Suppress

Constant or Edit Word
•

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

+ -I~;'~~
WA1fff'r
J!j~il'~~'r.LI"r"C)-I'l--l1

9 10 11 1113 14 15 16 17 18 1920 21 21 23 24 2526 21 28 79 30 31 32333435 36373839 4041 4243444546414849 5051 52 53545556 57 58596061 626364 65666768 6970 71 72 73 74

i

+t;- ~- --f-

=:
~~r- ~=m_LW_~ ___ --tl
D 3

Lf--~--v/
-,-_--,--,

,I , I I
I
~ ~ ~:~tion

~~ j.
~~~
ADD

,

Field Name

~ 5~

Filename

Line

3

Output Indicators

Skip

~:e

+- -

~ w=~ =~

-l-~ --!

--Hi

'I,

5 Ill\" lS'

--I--I-t--:I-H--I--IH-H-H-l-+-l-+-H-+-I--I

+-+-I I III i I
-I~~~~,
~' !II~','
~~Ir'
I
IrSA'LES
'AlllAL'l~'.L~
ICU~IIIIIM
Bit~ - _tlt-i---1tl=~~ -~ - =~~ -:r:-iT i+H+, =~ ]l)l =~,l~--~N,Q _ ~~~~f Allie- BOt ~M+Q~~~rr +---+-+--11
~ ~ ---I-~t' 'il-t-1
H-t,+8i'
_Lt!IT:
- - _(111' - 'J'\k, O~_~\~C[[]
'I,
i
I
,111,1e ,~O~ ~
1i~ !
L1J
I I
~'-~ 0 T, -j -;-. - --- -- -~ -r I I: : t-- :-+-tri- - i - -fl ~,- 1#11 f-I-+_L_ i i i H'- f-- -L+I-f--tHf--f--+
~+--o-I :TtH-~------ -1-1~-1 [ -n- -r f--rli7-r-- -:-tr-- -rrh-r- i - -;- 1-1-li-,
ir
I
~",lit- o-f, -lrr-:,--1,~,--H- ;-l.-:-rr:-- -;--~- -+~"-T-~,-r - !-t-t, t- -rr-rr'- i ,--j-~rrt- I i iI ~L
~~-- ~ -t-:tt~~--·----~htTTT -TT -'i::-:--r - - -~itt- : i I
i i ' ir~
JJI
j'

LI

I

H-

-.I.-

0' 8,

0

-I- -

-

-r!

::

I

I

I·

:

+---.

i

-

I

I'

I

I

V

I

I!

!

I·

--fiji

I

1

I

-1--;-

-I- -- -:-

'
I

i--f-f-

I

I

I,

I

I,

Figure 9·19. Examples of Output Constants

Columns 45-70 (Constant or Edit Word)

9-27

Format Name

Edit Words

The name of the display screen format that is used by
the WORKSTN file must be specified in columns 45
through 54. One format name is required for each
output record for the WORKSTN file; the specification
of more than one format name per record is not
allowed. The format name must be enclosed in
apostrophes. This is the same name that is specified in
columns 7 through 14 of the S specification line on the
display screen format specifications. You must also
enter Kn in columns 42 and 43, where n is the length of
the format name. For example, if the format name is
FORM1, enter K5 in columns 42 and 43.

An edit word allows more flexibility in punctuating a
numeric field than an edit code. You specify directly:

For more information on the display screen format, see
Chapter 13, WORKSTN File Considerations and Sample
Programs.

• Column 38 (edit codes) must be blank.

Note: The output specifications line containing the
format name cannot be conditioned by any indicators.

Edit Codes
If column 38 contains an edit code, columns 45 through
70 must be blank except for the following condition: if
asterisk fill or a floating currency symbol is required,
enter '*' or the currency symbol (enclosed in
apostrophes) in columns 45 through 47. When '*' is
entered in columns 45 through 47, asterisks '"replace all
leading zeros (**NN). When the currency symbol is
entered in columns 45 through 47, the currency symbol
appears before the first digit in the field ($N.NN). For
more information on edit codes, see Column 38 (Edit
Codes) in this chapter.
Note: Asterisk fill and the floating currency symbol
cannot be used with the X, Y, and Z edit codes.

• If commas, decimal points, and zero suppression are
needed
• If the negative sign should print
• If the output is dollars and cents, whether a currency
symbol and leading asterisks should be used
The following rules apply to edit words:

• Columns 32 through 37 (field name) must contain the
name of a numeric field.
• Columns 40 through 43 must contain the end
position of the field in the output record.
• An edit word must be enclosed in apostrophes. Enter
the leading apostrophe in column 45. The edit word
itself must begin in column 46.
• Any printable character is valid, but certain characters
in certain positions have special uses. See Editing
Considerations in the following text.
• An edit word cannot be longer than 24 characters.
• The number of replaceable characters in the edit
word must equal the length of the field to be edited.
See Editing Considerations in the following text.
• All leading zeros are suppressed unless a zero or
asterisk is specified in the edit word. The leftmost
zero or asterisk indicates the last leading zero in the
field to be replaced by a blank or asterisk.
• Any zeros or asterisks following the leftmost zero or
asterisk are treated as constants; they are not
replaceable characters.

9·28

Output Specifications

Editing Considerations

When using an edit word, leave exactly enough room on
the printed form for the edited word. If the field to be
edited is 7 characters long on the input record, consider
whether seven positions allow enough space for it to
print on the report. If the field is edited, it might contain
more than 7 characters.
When computing the length of an edited output field,
determifle how many of the editing characters are
replaceable. The number of replaceable characters in
the edit word must equal the length of the field to be
edited. A replaceable character is a character in the edit
word that does not require a position in the output file.
The replaceable characters are:

o (if used for zero suppression)
* (if used for asterisk fill)
D (blank)

the currency symbol (if it appears immediately to the
left of zero suppress; that is, a floating currency
symbol)
A fixed currency symbol, decimal points, floating
currency symbol, commas, ampersands (representing
blanks), negative signs (- or CR), and constant
information all require space in the output file.
Note: There are two exceptions to the rule that the
number of replaceable characters in the edit word must
equal the length of the field to be edited. The
exceptions are:

• An extra space must be left in the edit word for the
floating currency symbol to ensure a print position for
the currency symbol if the output field is full:

Unedited
Field

Edit
Word

Edited
Field

72432N

'LHS,~$O.~~&-'

$7,243.25~-

Unedited
Field
Length

6

Replaceable
Characters in
Edit Word

7

Columns 45-70 (Constant or Edit Word)

9-29

• An extra space can be left in the edit word if the first
character in the edit word is a zero. In this case, the
field to be edited is not zero suppressed by the
leading zero, but all other specified editing is
performed:

Unedited
Field

Edit
Word

Edited
Field

Unedited
Field
Length

00746J

'OLHH~ ,L?,L? L?'

007,461

6

Formatting Edit Words

The printer spacing chart can help you format edit
words. Figure 9-20 shows how an output line can be
formatted on this chart. The Xs and zeros show field
positions. A zero indicates where zero suppression
stops. An X indicates that any number can appear in
the position. Use blanks in place of the Xs when writing
the edit words.
If it is necessary to show a negative number, a sign
must be included in the edit word. Use either the minus
sign H or the letters CR. These print only for a negative
number; however, the character positions they require
must be included when you enter the end position of
the field on the output specifications. Figure 9-20
shows that for the field PERCPL, CR is to be printed for
. a negative balance. Assume the field PERCPL contains
the negative data 2N (which is -25). The printed output
is: 25CR. If PERCPL is positive, CR does not print and
the same field appears as 25.

9-30

Output Specifications

Replaceable
Characters in
Edit Word

7

Unedited Data

-Item number
Item cost
Selling price
%profit or loss

000241
02000
02200
25
Printer Spacing Chart

0
j

2

1
o1

1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9

4

3

2 3 4 5 6 7

a9 o

1 2 3 4 5 6 7 8 9

o1

2 3 4 5 6 789

1

PI!? / C£

2

ST

LI

3

4

IT EM
,.;U MB EI?

5
6

IT EM
CO ST

SE LL liNG

IPE RiC EINT
PR OF IT OR LO SiS

plR ICE

7

XX XX X(/J

8

$'i X¢ .Xx

$X X'¢ .xx

:r:X CR

9
10
11
12

Output Specifications

-

0

~ Space

~ 5~

Filename

Line

'R ~ :7i
'-+-1D E L

Jd

'A'Do
o

Field Name

L

0

:t

z

z

OJ

;3

z

'AUTO

'Ar"Nro
5

o 1
o 2

6

1

8

9

3

~

~

Record

to Print

Ves
Ves
No
No

End
Position
in
Output

Zero Balances

Commas

No Sign

Ves
No
Ves
No

CR

X •

A
B
C
D

J

V :

K
L
M

Z '

Remove
Plus Sign
Date
Field Edit

Zero
Suppress

a:

Constant or Edit Word

..J

co
0:

•

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 20 21 22 23 24 •

1011 12 13 1415 16 17 18 1920 21 22 2324 25 26 27 28 29 30 31 32333435 36373839 4041 4243 44 4546474849 5051 52 5J 54 55 56 57 58 59 60 61 626364 65666768 697011 727374

0
0

- - - - - - - - ~ - -f-H- - r-rl--+-+--t--t-f-+-+-+-if- -- - f- - f-f- -- - -- -1- -+-

o

UI
a:

0

co

R

:>

Output Indicators

Skip

:IHOMS- - -

rJ

-t--t-t--t-J-L!t-t--+-+-+-+-+--Ft--t-t- H-+-+-~H-t--t-H-t--+-+-t--t-+--t-H-j

O

'-o-r4~orH~~~~~~~~~TTTT~l~I~~!U~~~I~IITT4~B~~~I$~~~~.~~++++++++++++++++~~
r - - -- -

o

5

-I-r-r--

0

7~- ~

- - =~~ ~ =~~-

~~=~ _-~~~

~: ~
f-I__,-- - -

---_. -c· -

- - --r-- - - -- - - --r- r-

_ . _ . ._. _ _ _

1- -- -- -I- - - r

~~- ~ -I--r- r- -+
_~_._L-

_ L-L_

-

-j-H-+--+-+-+-+-+-+-+-+-+--+-+-+H---+--+-H

-c:l~ITCL~-21.,~~ .,. 8,"-_-'

~~'=r~:~:: -__ ~_ ~~- -~~~eIE'R1CI~i1L:~ ~-_~'31 ~~~-~HCR,'-+-+-I-t--t-+--t-_+_-+____ I _ _ r--r-

----------r--r----I-- - -

-+-t--+-~-+-+- ~F""'+=+='+"""-l-"-+--+-+-It-+--t·.."t""'l-t-+"'+-t-f=r'+-+-IH-

-

-1-

-r- --I

--

--- --t- -+

-----------r--~--I-I__--I------

-- --

-,-1-

-f-I-- -- - - -

1-

-T-

-

-1---

-r -

~4--r-

---- --1-------1--

--- ----

-~-I-- I__f-

-t- ---

---~-

e-- -

+- -- -------

- -r-r-- ---r---I__

--t--

-r--+-~-+-+-+-I--t---t--+-I

-H-+--+--t--I-t-+--+-H-+-+--t-f-+-+--t-H-t---t--HH-i--t-H-I

____ '-, ___--L_L-'---'--'--'--'---'---'--'--"--'---'--'-J__
Edited Output

241

$ 20.00

$ 22.00

25

Figure 9·20. Using the Printer Spacing Chart to Format Data

Columns 45-70 (Constant or Edit Word)

9·31

A minus sign can also indicate a negative number. To
leave a space between the number and the negative
sign, place an ampersand (&) in the edit word before the
minus sign. PERCPL then prints as 250-.
To print a currency symbol to the left of a field, enter
the currency symbol next to the first apostrophe and
then include the necessary blanks and punctuation in the
bdit word. A currency symbol in this position is called a
fixed currency symbol. The SPRICE field shown in
Figure 9-21, line 01, can look like any of the following
(N stands for any number):

If you do not want blank spaces between the currency
symbol and the first digit when zero suppression occurs,
you can indicate asterisks (*) fill. Instead of using 0 to
indicate zero suppression, use the asterisk (*) to indicate
that all extra spaces should be filled with asterisks. The
SPRICE field in Figure 9-21, line 03, can look like any
of the following (N stands for any number):

$NNN.NN
$*NN.NN
$**N.NN
$***.NN

$NNN.NN

To have the currency symbol always print next to the
leftmost digit, place the currency symbol next to the
zero suppress 0 in the edit word. A currency symbol
that changes positions depending upon the number of
positions that are zero suppressed is known as a
floating currency symbol. When printed, the SPRICE
field in Figure 9-21, line 05, can look like any of the
following:

$ NN.NN
$

N.NN

$

.NN

$NNN.NN
$NN.NN
$N.NN
$.NN
An extra space must be left in the edit word for the
floating currency symbol to ensure a print position for
the currency symbol if the output field is full.

Note: If the currency symbol is not the dollar sign ($),
the currency symbol must be entered in column 18 of
the control specification.

Output Specifications
~
~

0

I------

Space

~

I

~~~

Filename

Line

~~~

And

DEL

'Afolo ~

~~f-

-a>

Output Indicators

Skip

~

0

z

0

z

Field Name

1

4

5

6

01

0

o
o
o

2

0

3

0

4

0

o

5

0

o

6

0

o

7

0

o

B

0

7

8

Ves
Ves
No
No

Ves
No
Ves
No

No Sign

CR
A
B
C
D

J
K
L
M

X = Remove
Plus Sign
V = Date
Field Edil
Z = Zero
Suppress

·AUTO
,

1

23

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 20 21 2223 24 •

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3031 323334 35 3637 38139 4041 4243 44 45 46 47 48 49 5051 52 53 54 55 56 57 5859 60 61 62 63 64 656667 68 69 70 71 72 73 74

~~IKI!~lt

~~

'I

:e.

ISPR[ ~E

~17

I~

~.

iKll ~It::

211

~ltJ
1--I-1-1-

- - +--~- t-- ---

-l- I- -

Figure 9-21. Different Edit Words Used on the Same Field
9-32

Zero Balances
to Print

Constant or Edit Word

z

A N D

3

Commas

Output Specifications

l-

t-

S~

•

'

Examples of Edit Words

3.

Figure 9-22 shows examples of edit words. For all
examples, column 38 (edit codes) of the output
specification is blank. The symbol 0 indicates where
blank spaces appear in the edited data field. Zeros are
not slashed because there should be no confusion with
the letter O.
Examples 1 through 9 are sample edit words for some
of the most frequently used output formats. Examples
10 through 71 show several possible edit words and the
resulting edited data field.
The following paragraphs provide an additional
explanation of each example shown in Figure 9-22:
1.

2.

A decimal point appears between dollars and
cents; commas appear every three positions in the
dollar portion of the field. The symbol CR appears
in the edited data field when the data is negative;
otherwise, it is replaced by blanks. Because zero
suppression occurs through the units position (zero
in the edit word just left of the decimal point),
blanks replace leading zeros and constants until a
significant digit or until the specified zero is
encountered. If there are no significant digits, the
zero is replaced with a blank; however, the
decimal point and the digits to its right always
appear in the edited data.
Leading zeros and commas are replaced by blanks
through the position of the zero suppression 0
(column 54). Thus, if the entire data field is zero, a
zero appears only in the low-order position of the
edited data. A minus sign appears in the edited
data if the field is negative; if not, the minus sign
is replaced by a blank. The constant ON HAND
always appears in the edited data as it is specified
in the edit word, regardless of whether the minus
sign appears as specified or as a blank.

4.

Because the zero suppression 0 appears in the
tens position of the edit word, leading zeros and
constants are re~ained starting with the units
position. Because the dollar sign is placed just left
of the zero suppression 0, it is a floating dollar
sign. In an edited data field, the floating dollar
sign always appears to the immediate left of the
first digit or retained constant. An extra position is
allowed in the high-order portion of the edit word
to accommodate the floating dollar sign. The
minus sign appears if the field is negative; the
asterisk always appears as a constant because a
zero is specified to the left of it.
This example is similar to example 3 except that
(1) zero suppression occurs up to the decimal
point, (2) CR indicates a negative value, and (3)
two asterisks print at the end of the edited data.
In the edited data shown, the dollar sign has
floated to the left to precede the first significant
digit. If the unedited data were all zeros, the
. output record would appear as $.0000**. An
extra position is allowed in the leftmost portion of
the edit word for the dollar sign.

5.

This example is similar to example 4 except that
(1) no symbol indicates a negative value, and (2)
the edit word includes a fixed dollar sign. Because
the dollar sign is placed in the leftmost position of
the word and is not followed immediately by a
zero suppression 0, it is a fixed dollar sign. The
fixed dollar sign always appears in the leftmost
position of the edited data field.

6.

A space can be left in the edited data field
between a fixed dollar sign and the first digit, even
when the entire field contains significant digits. An
ampersand (&) in an edit word appears as a blank
in the edited field. The minus sign appears in the
edited data if the field is negative; the constant
GROSS always appears in the edited data.

7.

If a zero or asterisk is not specified, zero
suppression can occur throughout the field; thus,
edited data begins with the first significant digit. If
th~ unedited data field contained only zeros, the
entire edit word except the minus sign is replaced
by blanks when the field is edited.

8.

Zero suppression can occur throughout the field.
The symbol CR appears in the edited data field
when the field contains a minus zero.

Columns 45-70 (Constant or Edit Word)

9-33

9.

When asterisk fill is indicated, asterisks replace all
positions in the edit word to the left of the first
significant digit. If the asterisk is in the rightmost
position of the edit word, the entire edited field
contains asterisks when the data is all zeros.

29 and 30. Even if there is no zero in the edit word, the
minus sign appears in the edited field when the
contents of the data field are minus zero. The
constant TOTAL always appears in the edited field.
31.

Some zeros can appear in the edited field when
the entire field is zero. In this example zero
suppression occurs through the position of the
zero in the edit word (column 54), thus leaving two
positions in which zeros can appear in the edited
field.

32.

This example is similar to example 31, except that
a floating dollar sign replaces the last suppressed
zero.

33.

Because the dollar sign is adjacent to the zero in
the low-order position, it is a floating dollar sign.
The floating dollar sign appears in the low-order
position of an all-zero data field. This gives full
protection with a floating dollar sign, even when
all leading zeros are suppressed.

34.

Because the asterisk appears in the low-order
position of the edit word, asterisks appear
·throughout the edited field when the contents of
that field are zero. This gives full protection with
an asterisk, even when all leading zeros are
suppressed.

35.

Asterisk protection occurs only to a certain
position; thereafter, any additional leading zeros
appear in the edited field.

10, 11, and 12. When no edit word is used, the data in
the output record has the same format as the
unedited data. The low-order position of the
output field is printed as an alphabetic character (J
through R) if the source data field is negative.
13, 14, and 15. When a blank edit word is used, all
leading zeros are replaced with blanks, and any
sign in the low-order position of the unedited field
is removed when the data is edited. Negative
values are not identified.
16.

Using a zero suppression 0 in the rightmost
position of the edit word is the same as using a
blank edit word (examples 13, 14, and 15).

17.

Although the zero suppression 0 appears in the
high-order position of the edit word, suppression
of the first leading zero cannot be avoided. See
the note under Editing Considerations for a
discussion of this exception.

18 and 19. An ampersand appears as a blank in the
edited data. The symbol CR appears in the edited
data if the field is negative; CR is replaced by
blanks if the field is positive. The constant NET
always appears in the edited data field.
20.

An ampersand appears as a blank in the edited
data. A minus sign, instead of CR, indicates
negative values.

21 and 22. NET CR indicates when the edited data field
is negative. Therefore, when the edited field is
positive, CR is replaced with blanks.
23.

When the dollar sign appears to the immediate left
of the zero suppression 0, it becomes a floating
dollar sign, even when the dollar sign is entered in
the leftmost position of the edit word.

27 and 28. The floating dollar sign is shown for different
numbers of leading zeros. An extra position must
be allowed in the high-order portion of the edit
word for the dollar sign.

9-34

38.

The constant PROFIT appears in the edited data
field. Negative values are not identified.

24 and 25. This example is similar to example 20,
except that a fixed dollar sign is shown. An extra
position is added to the edit word to allow for the
dollar sign.
26.

36 and 37. Asterisk protection and zero suppression are
indicated for the leftmost position only. The
asterisk is replaced by a significant digit if one
occurs in that position. Negative values are not
identified.

Output Specifications

Asterisk protection and zero suppression are
indicated for the entire field. Asterisks are
replaced by significant digits. Negative values are
'not identified.

39 and 40. Blanks replace punctuation and zeros to the
left of the first significant digit. The decimal point
is lost when there are fewer than three significant
digits. The CR symbol is printed for an all-zero
negative field; the constants NET and -NET
always appear in the edited field.
41.

The ampersand, which appears in the edited field
as a blank, makes it possible to keep the dollar
sign fixed while limiting zero suppression to the
minimum one position. All punctuation is retained
regardless of the number of leading zeros because
the zero in the edit word is placed to the left of
the first comma.

Example
Number

Edit Word

.,

Source Data

Appears in Output Record as:

0000000005 00000000
0000000005 +
0034567890 0000000000
1234567890 00000000123 0000000000 0000135792 0000135678
0000135678 +
0000135678 0000000000
0000135678 +
0000135678 0000135678 0000135678 +
0000135678 +
0000135678 0000135678 0000135678
0000135678 0000135678
0000135678 +
0000135678 0000135678
0000135678 1234567809 0000000000 0000000000 0000000000 +
0000000000 0000000000 -

161616 16 t6t6t6t6l6l6.05t6C R
l6l6l6l6l6l6l6l6l60l6l60 N l6HAN D
161616161616161616$0.0516 *
t6l6t6$345,678.90CR * *
$16 16 t6l6l6 161616 t6l6. 00
$1612,345,6 78.90t6-t6G ROSS
t6l6t6t6t6t6t6t6l6t61.231616 t6l6t6 1616 1616 1616 16 t6C R
* * * * * 1,357.92160000135678
0000135678
000013567Q
t6t6t6l6t6t6t6l6l6t6
l6l6t6t6135678
l6l6t6t6135678
l6l6t6l6135678
l6000135678
l6l6t6t6135678t6l6t6t6NET
t6l6l6l6135678t6CR t6N ET

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

:.•

~

~

~

~

I'

~.

J
~

.1

J

I'
I

II

,&

-

I)
J

J

..

I

~

)

•
.
1.!8
.
. CIR:'
!Q •

J

I
)

I'

I

I

I

I

~ ~E T'
'CR
fQ

I

.sc T'

I

I

- A ET I
NET 'e R'
r;.T CR'
""t- Il T I

I
I
I

I

!

I'

I

I~

I'

'

T'

- IRI'INIEIr

I

IlIleI,

I-

I$I~
~~

I'

i

N~

-I

. i

:'

I

I

as'

I

I'

~~,

I

,

I'

"'I_I .....

&-'

•

•

,

I'

&CR'

~ -If'r, Na I ..
~~.
,~QJ •
$QJ • ICR ~*I'
J

1

I~

!

I

~C
~ IR'
1-

l.t-

I~IJ-

I~I~

I ('II_ At

1-

1

Ir lo
1'10

1\

...

I

~:L •

~I ...

,"",,~I'

:S" ,

ISd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

t6~t6l6135678t6-l6t6NET

l6l6l6l6135678l6NETl6l6l6
l6t6l6l6135678l6N ETt6C R
l6l6l6l6135678l6l6PROF IT
$t6l6l6t6135678l6l6tDNET
$l6l6l6l6135678tD-tDN ET
l6$000135678l6l6NET
l6l6l6l6$1356 78l6C R
$1234567809l6CR
l6l6tDl6l6l6l6l6tDl6l6-l6TOTAL
l6t6l6l6l6l6l6l6l6l6tD-l6TOTAL
$t6l6l6l6tDtDl6l600tDl6l6l6G ROSS
l6l6t6l6l6t6l6tD$OOl6CR t6G ROSS
l6l6tDl6l6l6l6t6tDtD$

Figure 9·22 (Part 1 of 2). Example of Edit Words

Columns 45-70 (Constant or Edit Word)

9-35

Example
Number

Edit Word

Source Data

Appears in Output Record as:

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

I

I

I~

'~

C'RI'

11*

I'

I

~II

I

I

•

11

11$ ,g~ iJ
I
I

•

J

J
1.1

J
J

J

I
I

~

J

.J

:J

•

I

I

I

0-

I

$'1.1

I

,II$IA
I

J

*.

J

J

J

J

I
.J
I

I

~.I

ItJ II!
J

J

)Qj
~J

J

IIR

~

I

rJ.J

-l -J

I

I
I

I

I

I

J

J

.J

J

I

I

• fl

'OS.,
I

leiE NT ClI
i

It:" '::J I

DOILL A RS rl~ 1"1 S~ r. Rl'
~ IlaS ·IA.
Oil -IT ~R ,E! _I
_II
,,~
~L e,l) •
• TlAIR ~1
I

.J

lot

II 'I AIRS

I~

I

I

-IS All E5 1

11 RIC:

- - ~l IN~

IJ

IR*l-Ye '

[eR II
-0 LD ge ~iL NC Ell
1
~ -0 L" Jl'R!Al N.r' ,::1
I

1'1~

J

nl'lII II

liS
101 HIRIs'
I

CIR '
~C

(}..

J

)

.

*. .

I

J

I

Be R~I
_I

)

I

I

~

Er

_I

4! •

.J

I

IJU~

giN Elf I

•

G•

)

iJ

tic R& IN Elf!'
It ft' l IT'
a.l.-

I)

,,:$

I

I

clR l1

~

- Jl ~I'

Ie

L~ ,Ct<.1

I

·

I

a! I 1-iC

I

~

I

-,
I

'I

I

l.l AT Il;;iR I

At
AT ER'
I

·

rz •

_I

_I

Figure 9-22 (Part 2 of 2). Ex~mple of Edit Words

9-36

Output Specifications

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

0000000000 0000000000 0000135678 1234567890 +
0000135678 0000135678 0000135678
0000135678 +
0000000005
0000000005
1234567890 0001356789 0000135678 +
00000000 0000000000 0000001234
1234567890 1234567890 0000000000 +
0000135678
000000 +
000000
000002 +
000002 095140036
0042
000000
000000
00123456
0000000000
001234
0000001234
013579
093066
093066
100166
000000015 000000005

** ** *** ***~CR
********OO~CR

*000135678
1234567890
****135678
~~~~~1 ,356. 78~CR~~NET
~~~~t? 1,356. 7 8~t?t?t?-N ET
$~~0,001 ,356. 78~NET
~t?~~~~t?~~$0.05~N ET
~~~~~~~~~~$.05

$12,345,678.90~~~~$13,567.89CR

* * * * * 1,356,,78t6~~ * *
t6t6t6~~~~.OOt6CR *

* * * * * * * * * * .00~~~~~~$,012.34~SALES
$~12,345,678.90CR

1,234,567,890-0 LO~BALNCE
~t6~~~~~~t6~~~O~OLO~ BALNCE
~~~~~1 ,35600 LLARS78CENTS
~~~~~~t?~~~~~~~CENTS

~~~~OOO L LA RSOO~~~~~~~~
~t6~0 L BS. ~02~t6t6~t6~~~t6
~t6~~LBS.020Z.TAR E~~95-14-0036
~OH RS.42M INS.~O'CLOCK

t6~~~t6.00
~t6~~~~t60
~~t61

$,234.56

~~~~~~~~t60*00
~,012,034

******,012*34
***130,579
~9-30-66~LATER
t69~30~66~LATE R

10/01/66
~t6~t6~~~~~t615~~~~t6~~~0.05~

42 through 45. The floating dollar sign is placed so that
at least the decimal point is retained regardless of
the number of leading zeros. The extra position
appears in the leftmost position of the edit word
to allow for the floating dollar sign.
46.

47.

Asterisk protection and zero suppression occur up
to the decimal point. The decimal point is retained
regardless of the number of leading zeros.
Asterisks replace punctuation when leading zeros
are suppressed. The second asterisk appears only
when the edited data field is negative; the third
and fourth asterisks always appear in the edited
field.
This example shows a standard programming
technique for retaining the decimal point while
suppressing all leading zeros. The edited data
shown is a minus zero value.

48.

Asterisk protection and zero suppression occur up
to the decimal point. The decimal point is retained
regardless of the number of leading zeros. A
minus sign appears in the edited data if the field is
negative.

49.

A constant (in this case, a comma) follows the
dollar sign in the edited data if the floating dollar
sign and the zero suppression 0 immediately
precede a constant. This occurs if there is a
number of leading zeros. The comma following a
dollar sign looks awkward; however, a decimal
point following the dollar sign does not (see
example 43).

50.

A space can be inserted between a fixed dollar
sign and the first data digit when all digits in the
field are significant. An ampersand in an edit
word appears as a space in the edited data field.

51.

In this quantity field, all leading zeros, including
the units position, are suppressed (compare with
example 52).

52.

A single zero is shown in the edited data field
when the data field contains only zeros.

53

th~ough

57. Constants in the edit word are handled
the same as punctuation marks. That is, only
constants to the right of the first significant digit
or the zero suppression 0 appear in the edited
data. Examples 55 and 56 show how more edit
word constants, other than the CR or minus, can
appear as blanks in a positive field. Examples 55
through 57 also show the effect that the position
of the zero suppression 0 has on constants. In
example 56, an ampersand placed after the first
constant provides a space following that constant
in the edited data.

58.

A hyphen (-) is used within the edit word to edit a
social security number. In this example, the initial
zero is suppressed. However, to include the initial
zero in the edited data, leave an extra position in
the edit word. See the note under Editing
Considerations for a discussion of this exception.

59.

Several constants can be used in an edit word.

60 and 61. This example shows the effect that the
position of the zero suppression 0 has on the
decimal point (or any other constants) and
following zeros.
62.

This example shows that a dollar sign separated
from the zero suppression 0, even if only by a
comma, is not a floating dollar sign, but a
constant.

63 through 66. Any zero or asterisk to the right of the
high-order zero or asterisk is a constant, not a
zero suppression 0 or asterisk-protection symbol.
Examples 65 and 66 also show that asterisk
protection replaces not only blanks but also other
constants to the left of the first significant digit.
67 through 69. These are three examples of editing a
date field. Since month numbers have at most one
leading zero, it is not necessary to specify a zero
suppression O. Example 68 shows the use of an
ampersand to retain a blank space in the edited
data.
70.

This example shows what happens to the decimal·
point when no zero suppression 0 is specified for
a field that has fewer than three significant digits.
This applies if the field is more than three digits
long.

71.

This example shows how to retain the decimal
point in a data field that has fewer than three
significant digits. This applies if the field is more
than three digits long.

COLUMNS 71-74
Columns 71 through 74 are not used. Leave them blank.

COLUMNS 75-80 (PROGRAM IDENTIFICATION)
See Common Entries in Chapter 1.

Columns 45-70 (Constant or Edit Word)

9-37

9·38

Output Specifications

Chapter 10. Operation Codes

The RPG II language allows you to perform many
different types of operations on your data. Operation
codes, which are entered on the calculation
specifications, indicate the operation to be performed.
Usually these codes are abbreviations of the name of
the operation.
Many operation codes can be placed into categories.
The first part of this chapter includes general
information about these categories. The latter part of
the chapter describes each operation code in
alphabetical order and shows one or more examples for
most of the operations. Figure 10-1 is a summary of
the specifications for each operation code.

Operation Codes

10-1

Control Level
Indicators
Operation r---7-8
Code

Conditioning
Indicators

Resulting Indicators

Columns
9-17

Factor 1

Factor 2

Columns

Result
Field

54-55

ACQ

0

0

R

R

ADD

0

0

0

R

R

BEGSR

SR or blank

BITOF

0

0

R

R

BITON

0

0

R

R

CHAIN

0

0

R

R

0

COMP

0

0

R

R

03

03

0

0
0

0

0

R

0

0

0

R

0

DIV

0

0

0

R

R

0

ENDSR

SR or blank

0

0

EXCPT

0

0

EXIT

0

0

R

EXSR

0

0

R

0

R

0

0

R

0

0

R

0

DEBUG

58-59

56-57

I

03

~

FORCE
GOTO
KEYnn

1

LOKUP
(Array)

0

LOKUP
(Table)

0

0

MHHZO

0

0

MHLZO

0-

0

0

-+0
0

0

0

R

0

R

0

0
4

0

0
04

4
I

R

0

R

R

I

R

R

i

R

R

R

R

R

04

04

04

I

MLHZO
MLLZO

1

0

1

I

Figure 10-1 (Part 1 of 2). Summary of Operation Code Specifications

10-2

Operation Codes

i

I

i

i

!

I

I

I

, Control Level Conditioning
~!ndicator~ _______ ~ Indi,?ators __ -"

I

Resulting Indicators

i

,

.
Columns
Operation - - - - - - - - - - , --------~
,9-17
Code
7-8
I Factor 1
I

o

MOVE

0

MOVEA

0

10

MOVEL

iO

:0

MULT

,0

,---

-----

---

0

0

'0

'0

POST

,0

'0

READ

0

R

~---

SETnn'

----_.

0

'R
--_

....

,0
0

,-SETON
SETLL

------

fo

0

10

SHTDN
SORTA

I

0

SUB

0
1

'0
10

SQRT

I~

------1~---

!
,R

0

-

0

TESTB
-

0

TESTZ

0

IR
i

+I

0

io

1

0

--

R

0

10 2
10

0

0

0

0

03

03

03

1I 03

03

03

I
!

i

10
I

I

I

,

I
I

--

0

iR

I

R

ti

I

'R

,R

I

I
I

I

iR

R

R

!R

---------+

I

~

I

I

0

XFOOT

Z-SUB

0

,

0

0
0

:0

0

!o

0

10

i

0

--

0

R
--_____________
--+-__ - 4 -

TIME

--

Z-ADD

I

I

1

TAG
---_._-.

0

0

:0
,0

0

...

I

!o

-----

I

_-_._- . _ _-'R-_. - ----- ---.--

1

-

R

----~~-----_____i_-~ R

0

10

SETOF

I

I

I

'R
- --,----------T-

----

--_ .. _-

R

158-59

._--- __________~ _ _ _ -+R

!

RLABL

R

---t---- --------+

0

-

0

REL

-

56-57

54-55
I

,0
,0
-1--------------+------- __ ~ R
________________' R

I

NEXT

!

--~-----------------------------I

i

MVR

Factor 2

!

Columns

: Result
i Field

10
:0

i

I
I

--tI

03

i0 3

10 3

R

03

i

03

10 3

! R_

!O

0

10

lR

IR

0

0

10

IR

iR

10

0

0

i

I

I

I

!

IR

IR
I

R

'The nn entries in columns 31 and 32 are for message indicator numbers. If the result field of a SET
operation contains the keyword ERASE, factor 2 must contain the name of the CONSOLE file.
Otherwise, factor 2 and the result field must be blank.
2Columns 56 and 57 can contain an indicator when the READ operation is used with a WORKSTN
device.
3At least one resulting indicator must be specified in columns 54 through 59.
"At least one resulting indicator must be specified in columns 54 through 59, but no more than two can
be used.

Fields without entries must be blank.

o
R
SR

Optional
Required
The only allowable nonblank characters in columns 7 and 8 for the BEGSR and ENDSR operation
codes.

Figure 10-1 (Part 2 of 2). Summary of Operation Code Specifications

Operation Codes

10-3

ARITHMETIC OPERATIONS

MOVE OPERATIONS

Arithmetic operations can be performed only on numeric
fields or literals. The result field must also be numeric.
Decimal alignment is performed for all arithmetic
operations. Even though truncation can occur, the
position of the decimal point in the result field is not
affected. For arithmetic operations in which all three
fields are used:

Move operations (MOVE and MOVEL) transfer all or part
of factor 2 to the result field. Factor 2 remains
unchanged. Factor 1 must be blank, and no resulting
indicators can be specified in columns 54 through 59.

•

Factor 1, factor 2, and the result field can be three
different fields.

•

Factor 1, factor 2, and the result field can all be the
same field.

•

Factor 1 and factor 2 can be the same field but
different from the result field.

•

Either factor 1 or factor 2 can be the same as the
result field.

The length of any field specified in an arithmetic
operation cannot exceed 15 characters. If the result
exceeds 15 characters, characters are dropped from
either or both ends depending on the location of the
decimal point. The results of all operations are signed
(+ or -). Any data placed in the result field replaces the
data that was there previously.

The move operations can be used to change numeric
fields to alphameric fields and alphameric fields to
numeric fields. To change a numeric field to an
alphameric field, enter the name of the numeric field in
factor 2 and specify an alphameric result field. To
change an alphameric field to a numeric field, enter the
name of the alphameric field in factor 2 and specify a
numeric result field.
When an alphameric field is moved into a numeric result
field, the digit portion of each character is converted to
its corresponding numeric character and then moved to
the result field. Blanks are transferred as zeros. For the
MOVE operation, the zone portion of the rightmost
alphameric character is converted to its corresponding
sign and is moved to the rightmost position of the
numeric field where it becomes the sign of the field. For
the MOVEL operation, the zone portion of the rightmost
character of factor 2 is converted and used as the sign
of the result field whether or not the rightmost character
is included in the move operation.
When move operations are specified to move data into
numeric fields, the decimal positions specified for the
factor 2 field are ignored. For example, if the data 1.00
is moved into a numeric field with one decimal position,
the result is 10.0.

10-4

Operation Codes

MOVE ZONE OPERATIONS

SETON AND SETOF OPERATIONS

The move zone operations move only the zone portion
of a chFiracter.

The operation codes SETON and SETOF turn indicators
on or Off. Any indicator to be turned on or off is
specified in columns 54 through 59. The headin'gs for
these columns (plus or high, minus or low, zero or
equal) have no meaning in these operations. When
setting indicators, remember:

A minus (-) sign in a move zone operation does not
yield a negative character in the result field because a
minus sign is represented by a hex 60 internally and a D
zone is required for a negative character. Characters J
through R have D zones and can be used to obtain a
negative value (J = hex D1, ... , R = hex D9).
Note: Whenever the word high is used in a move zone
operation, the field involved must be alphameric;
whenever low is used, the field involved can be either
alphameric or numeric.

• The following indicators cannot be turned on by the
SETON operation: 1 P, MR, LO, KA through KN, KP
through KY.
• The following indicators cannot be turned off by the
SETOF operation: 1 P, MR, LO, and LR.
•

If the LR indicator is turned on by a SETON operation
that is conditioned by a control level indicator
(columns 7 and 8 of the calculation specifications),
processing stops after all total output operations are
finished. If it is turned on by a SETON operation at
detail time (not conditioned by a control level
indicator in columns 7 and 8)' processing stops after
the next total output operation is completed.

•

If the halt indicators (H 1 through H9) are set on and
not turned off before the detail output operations are
complete, the system stops. The operator can
continue processing by responding to the halt for
every halt indicator that is on.

COMPARE AND TESTING OPERATIONS
The compare and testing operations test fields for
certain conditions. Resulting indicators assigned in
columns 54 through 59 turn on according to the results
of the operation. No fields are changed by these
operations.

BIT OPERATIONS
The three operation codes BITON, BITOF, and TESTB
set and test individual bits. Use the individual bits as
switches in a program in order to save storage for
binary type switches.
When you use the BITON, BITOF, and TESTB
operations, any field named in factor 2 or result field
must be a one-position alphameric field. A field is
considered alphameric if there are no entries in the
decimal positions column of the input or calculation
specifications. The field specified as factor 2 or as the
result field can be an array element if each element in
the array is a one-position alphameric element.

• Setting L 1 through L9 on or off does not
automatically set any lower control level indicators.
•

Indicators L 1 through L9 and the record identifying
indicators are always turned off after the next detail
output operations are completed regardless of the
previous SETON or SETOF operation.

• Whenever a new record is read, record identifying
indicators (01 through 99) and field indicators are set
to reflect conditions on the new record. The setting
from any previous SETON or SETOF operation does
not apply then.
•

If a numeric indicator (01 through 99) is set on and
not changed in other calculations, it remains on until
it is set off by another calculation specification.

Move Zone Operations

10-5

BRANCHING WITHIN RPG II

WORKSTN OPERATIONS

Operations are normally performed in the order in which
they appear on the calculation specifications. There may
be times, however, when the operations should be
performed in a different order, such as:

The operation codes ACO and REL are used only with
the WORKSTN file.

• Several operations should be skipped when certain
conditions occur.
• Certain operations should be performed for several,
but not all, record types.

For these operations, the operation code must be
entered in columns 28 through 32. Factor 1 specifies
either the name of a 2-character field that contains the
device identification or a 2-character alphameric literal
that is the device identification. Factor 2 specifies the
name of theWORKSTN file for which the operation is
requested. Columns 56 and 57 can contain a resulting
indicator, which is set on if an exception/ error occurs.

• Several operations should be repeated.
Note: For WORKSTN files, a device can be either a
display station or an SSP-ICF session.

SUBROUTINE OPERATIONS
The operation codes BEGSR, ENDSR, and EXSR are
used only for subroutines. In an RPG II program, a
subroutine is a group of calculation specification
statements that can be executed several times in one
program cycle. A subroutine must be written on the
calculation specifications after all other calculation
operations for a program. Subroutine specification lines
must be identified by SR or blanks in columns 7 and 8;
therefore, individual operations within a subroutine
cannot be conditioned by control level indicators in
columns 7 and 8. Within a subroutine, SR or blanks in
columns 7 and 8 can be intermixed.

PROGRAMMED CONTROL OF INPUT AND OUTPUT
The normal program cycle can be altered to allow input
and output operations during calculations. (See RPG II
Program Cycle in Chapter 1 for a brief description of the
program cycle.) The following operations provide this
capability:
•

EXCPT (Exception Output)

• READ (Read)
• FORCE (Force)

LINKING TO EXTERNAL SUBROUTINES

• NEXT (Next)

To provide linkage from RPG II to an assembler
language subroutine, use the EXIT and RLABL
operations. Control cannot be transferred from one user
assembler subroutine to another user assembler
subroutine. The EXIT and RLABL operation codes also
provide linkage to the IBM-supplied message retrieve
subroutine (SUBR23).

• CHAIN (Chain)

Note: User-written subroutines should be placed in
#LlBRARY or #RPGLlB (the library the RPG compiler
resides in), not in the same library as the RPG II source
program.

10-6

Operation Codes

• KEY (Key)
SET (Set)
• SETLL (Set Lower Limits)

Alphabetized Operation Codes

BEGSR (BEGIN SUBROUTINE)

The following section of this chapter discusses, in
alphabetical order, individual operation codes.

7·8

Indicators

Opt:
SR

Result

Resultinll Indicators

9-17

Factor 1

Factor 2

Field

54-55

56-57

58·59

Blank

Required

Blank

Blank

Blank

Blank

Blank

ACQ (ACQUIRE)
Indicators

Result

Resultina Indicators

7·8

19.17

Factor 1

Factor 2

Field

54-55

156.57

OPt

100t

Required

Required

Blank

Blank

10ptionailBIank

158-59

The ACQ operation acquires the device specified in
factor 1 for the program. If the device is available, ACQ
attaches it to the program. If it is not available or is
already attached to the program, an error occurs. If an
indicator is specified in columns 56 and 57, the indicator
is set on. If no indicator is specified, but the INFSR
subroutine is specified, the INFSR automatically receives
control when an exception/error occurs. If no indicator
or INFSR subroutine is specified, the program halts
when an exception / error occurs.

The BEGSR operation serves as the beginning point of
the subroutine. Factor 1 must contain the name of the
subroutine. The control level entry (columns 7 and 8)
can be SR or remain blank. Columns 9 through 17 must
not contain any conditioning indicators. The subroutine
name can be from 1 to 6 characters long and must
begin in column 18 with an alphabetic character. The
remaining characters can be any combination of
alphabetic or numeric characters. However, special
characters are not allowed and blanks cannot appear
between characters in the name.
Every subroutine must have a unique name. This name
cannot be used as the label of a TAG or ENDSR
operation.

No input or output operation occurs when the ACQ
operation is executed.

ADD (ADD)
Indicators

Result

Resultinll Indicators

7·8

19.17

Factor 1

Factor 2

Field

54·55

Opt

lOot

Optional

Reauired

Relluired

OPtional 100tionai 10ptionai

156-57

158-59

Factor 2 is added to factor 1. The sum is placed in the
result field. Factor 1 and factor 2 are not changed by
the operation. If factor 1 is not present, factor 2 is
added to the result field, and the sum is placed in the
result field.

Alphabetized Operation Codes
ACQ-BEGSR

10-7

BITOF (SET BITS OFF)
Indicators

BITON (SET BITS ON)
Result

Resulting Indicators

Indicators

7-S

19-17

Factor 1

Factor 2

Field

54-55

15s-57

15s-59

7-S

OPt

IOpt

Blank

Required

Required

Blank

IBlank

IBlank

Opt

19-17

lopt

Result

Resulting Indicators

Factor 1

Factor 2

Field

54·55

15s-57

ISS-59

Blank

Required

Required

Blank

IBlank

IBlank

The BITOF operation causes bits identified in factor 2 to
be set off (be set to 0) in the field named as the result
field. Factor 2 is always a source of bits for the result
field. The result field is the field in which the bits are
set off.

The BITON operation causes bits identified in factor 2 to
be set on (be set to 1) in the field named as the result
field. Factor 2 is always a source of bits for the result
field. The result field is the field in which the bits 'are
set on.

Factor 2 can contain:

Factor 2 can contain:

•

Bit numbers 0-7: From 1 to 8 bits can be set off per
operation. The bits to be set off are identified by the
numbers 0 through 7 (0 is the leftmost bit). The bit
numbers must be enclosed in apostrophes' and the
entry must begin in column 33. For example, to set
off bits 0, 2, and 5, enter '025' in factor 2.

• Bit numbers 0-7: From 1 to 8 bits can be set on per
operation. The bits to be set on are identified by the
numbers 0 through 7 (0 is the leftmost bit). The bit
numbers must be enclosed in apostrophes and the
entry must begin in column 33. For example, to set
on bits 0, 2, and 5, enter '025' in factor 2.

• Field name: The name of a one-position alphameric
field, table element, or array element can be specified
in factor 2. In this case, the bits that are on in the
field, table element, or array element are set off in
the result field; bits that are off are not affected.

• Field name: The name of a one-position alphameric
field, table element, or array element can be specified
in. factor 2. In this case, the bits that are on in the
field, table element, or array element are set on in the
result field; bits that are off are not affected.

See Figure 10-2 for a summary of BITOF operations.

See Figure 10-3 for a summary

The operation code BITOF must appear in columns 28
through 32. Conditioning indicators can be used in
columns 7 through 17. However, factor 1, decimal
positions, half-adjust, and the resulting indicator
columns must be blank.

The operation code BI!ON must appear in columns 28
through 32. Conditioning indicators can be used in
columns 7 through 17. However, factor 1, decimal
positions, half-adjust, and the resulting indicator
columns must be blank.

10-8

Operation Codes

~f

BITON operations.,

Calculation Specifications

C

Indicators

And

Operation

Factor 1

"5!

0ll

C

rol21 c ,--~f;-~-

C

I ::) I "5 I I

JlLl / 11

--

t~

'':;/'4

~JllG117

Indicators

Factor 2
Name

~

Rcsultln;J

Result Field

I

f----

Length

PlusJM,nusl Zrro
Compare
1> 211

Comments

< 21 1 = 2

Lookup(FJctor 2hs
18 1-3

~O

], 1:0 ):.; ]4 ] i ';iF

"1"

28203031 32 ]J 34:1S 36313339404147434445 4r) 4148 49

:

~!

I

I

I:

I

I

:

I

i

I I!

I

1:

I

~,O

High
51

,

Low

;,4 f".r, :-,G

:

~l

Equal
SR :-,9

r,o r"

1 • 1 "

n

£)2 £)3 (;4 (,:, hfl til f,R (i'! -10 71

','

I

:

I,

':

!J 74

I

i

The following B!TOF operation sets bit 5 off in the field named BITSW. The field is defined -:--~in the same line with a field length of 1.
".-.--'----

- ---l-------,.

.

' '-,--

~---~~~-i~---'~~-=$+~~H
i~-~
:;= ~_= . ~.~.-=::-:•.::.==
S~~Q. '=~-. B.I.tS\tL =-.= -:~ =---:--~~-.-,-.~
o

7

C

,

~~- ~ --

f----'

'

"

.

,

'

,

_ :

~£~ -. n~ ~~~t~;±~~~~i~~==Ja~~-=
~ ~~_~.
,1-·-~, '.
~ :.'
~-. ,.-1=
,
1131c

~--

C

--

1

1

I

:

The following operation sets bits 1, 2,4, and 6 off in the field named BITSW. The one-position -;-~T

--~

-----r--

i

i

:;

1::1

i

~I,

:,

1 : •

-'-,+I-+-,~

The following operation uses a one-position alphameric field as a source of bits. Any bits

~~.-'-~. ~l~:' that are on in the field named ALPHA cause corresponding bits to be set off in the field named ~rr-r-=
~.l~L C f--L ;-Lr BITSW. If bits 5 and 7 are on in the field named ALPHA, the BITOF operation sets bits 5 and
~_2 __ ~ f---~- r-+ 7 off in the field named BITSW.
I
~l,~~ ~f---~--~. ~ ~_~.LLL.Lttti
'i I I :
I ~ iii
! I
i I : I
1 :91 c:
,. r-rI i ' : ' : : 1i
8ItrOIFAI'
!DUAI
i i
Mill
II
I ! i I: Ii
- 1--r-~-- I---------,~
, n l••,.Lnn...
" ~iV,
I

2101

c·:

211

c

C--+, "-

'

cr----r---

~

.

I

1

!'

1

I

I

! : , ;

'I

1

I.

:

i

rP-:

Ii;!

'!.

1

:

!

-~- -:""';"l'-l- : :--~-~.
1

-- - " - - - -

,!

.

212I e :

"213-

i.

!

c---""

:

I!

I

ill

1

i

i

I

!

'

•

,!

!

'r-~-c-.-~;
,,'

!

!

I ' :

I

"

•

'

•

I'

I

1

,!

,

The following operations use a one-position alphameric array element either as a source of bits
or as a result field, or both. In the first operation, any bits that are on in the field named
~,~~_ c ____ ,_ ... _ ALPHA cause corresponding bits to be set off in the array element AR R,NX.
-~-

2.~:.... ~f----216

218'

~19-:""

c

.

:

f---- _ _

i

r-~

:,:.

I'

'----------:1;; --b-"'--: r---- >-,---+---.---

;

'

!!

'.

.:!

' I ' ;

I

,

' . :

3_L3J~

,--+--I

.i '
I

I

;

'I i .

I

f

i

i:

IIIII i ;,.':
I

Iii i i i

I!
, ' I ! I I!
BITS is a one-position field containing hex FO (numeric zero). To change hex FO to hex 40
::

i:

i--r--T

'!

,

r--++ I--~- -+---~~~i--BlI-OJ:~-A/~~~E,J.2
., . , : . '
,', I : ! :

____ -+--

:

i

~l~l. c ___ __~-,-:

I

i

c-'T- f-----h-,-I---r -:--·"'~--~-I=-+--t \ :
..• i .. i~;rr!E:tcz:=~_-· ~1ffi,Jl.L-,c

;

1--...;..-.-'---':---+--'-+---+-..--+-<----'--1

.

.-:._~ ___'-''' ___
: _~:
:~:~, BnO'FAL.21t~_~.a.PvN~

C

l~"-"~~- -::=~~
r?J,~~

.. --,-----...;......
----

___

'- - -~.. -" r'--- - - - - - - '-- -",- , - --'--C"'~ ~,~ 1--";""

cL_ C

iii

-~-f- -r-L--.;..-+--t-~- ~"7+I---'-~-r---,---j
i : : ; ):
. ~
i

I.

. j

iii

::

i
;

~~:
>~ . (bla~nk),~setb~tS~'i2iandm30ffm:
'~m.' m~m ~+-++-Tt-H-'3'6~C ~tlcttttt
t~~~' ~
III
I
I1111

3 7:

--I -

3 8

c

G

I

,

I

I

-r---

I,

"

~--

'

1 I

!

I

I

I ~~

:--f-i,~t---r

",

I

I

1

"

r

'

: '

I

!

1

t-

1

I

1-

t'
I
I
ii

:
:-+-1

-;-[9 i-- ~ r'~---~-+- To create a hex 1 C (dup character) in the one-position field ASTRSK, set all bits off, then --I---:T-t--+-:-+--l
4

-~i ~ i----f-----

i:j.':
_' ~~-s-~t,'fll~IIK~:'"
-,

~t~- ~r-----~t~-~--I--+~-EmBi;'
j3l_- f:I- -t-I -trr-r:- ._T Ter .
-:.L1

c

I

.L

I

set on bits 3, 4, and 5.

.llirL ·

,

-~

~~sPf"

'LL i l l

I
i

+-+-+-1-+-+-+--1

~SitIAISIt<

1

.!

I

_~

!

,
II

Figure 10-2. Summary of BITOF Operations

Alphabetized Operation Codes
BITOF

10-9

Calculation Specifications

C

Indicators

Resulting

Result Field

Indicators
Arithmetic

I--Operation

Factor 1

Plus IMlnusl Zero

Factor 2

Comments

Compare

Name

~

345

o

1

10 11

o2

C

c

~

13 14

I

Lookup(Factor 2lis

1

~1'6117

18192021 22 23242526 27 28293031 32333435363738394041424344454647484950 51

I

I I I I I I I I I

~0-l-4-+,-l-c~--I----t--+-+I-t'---+-+-------+-f--'+-I
I'

07i

c

o

C

8

,:'

i

',: [

i

60 616263646566676869 70 71 7073 74

---

i

:

i

I

I

I'

"I,',

I--+--+-+-l--Ii--+-----I-

I

i

,

,

I

~:trr£-_l--_l~---+----_+-+---l----I-;-r~'----+--~-"-

.

:

II,-+-II\I-r,r--r--,
,
,I

!

I I

i ' i • 8:ttrlO\N \ ~I
-+- ~-t--I--.--l--r-+--l! ~
i; i I ' i ' , : ',
I :

I

o5 C
i
f-+-+-+-+-+-+-~
o 6 C

I

I ! I

5~i9:5 5~O~7 :8q~~

I I I I I I I I I I I I
11 ' I I I I I ' ! I : I I i
I
The following BITON operation sets bit 4 on in the field named BITS. The field is defined in the~
same line with a field length of 1.
! I

C

o 3

,~

Length

"

I

I

~--~~~-~~-+-+~~----~'~
;~--~~

i

The following operation sets bits 0, 3, 5, and 7 on in the field named BITS. This one-position T-+---":"-

~o+-g+:+c--+-l'-+--+-:+i field has been previously defined.

I I

c

:

111

C

iii

1 2

C

113

C

1 4

C

1 5

C

1 6

c

1,0

:

I 'i'
'i
I I ! :
i : ; I , ! ! 18] ra~ ~~§7'

I

Ii:

I

I

I

'

I'

I

!

I

:

:

!

I:

I--t--+-I---+-+-+--t-+-+--+I-+--I-+,-+--+-+i-j---,---+-~~

1 7

C

1 8

C

1 9

c

"

,

+f--I---+--:-

I

':,

I

2 2!

C

I

2 3 i

C

Ii

2

C

i

I I

I I Ii!

,I

I!

ii'

++ -t--H-+-j--j--i--t-rt-+--t-+-t I-t-t;-t ,
I

I I

I

-4-

I'

,

!

I

I:

iii

I,

'

,

II

,I
+-~
I

:

I
'

-

I I

!

I I

I

!

,

'

i

I

I

I

,

II

-4+:
,

:

'

I

tIt
+++-0 :

I

i ---t-

I

:,11,1;:
I

:

'

:

f-~- -I-~ ----'----~-~-+
"

:

+

.-----

-----

or as a result field, or both. In the first operation, any bits that are on in the array element
AR R,NX cause corresponding bits to be set on in the array element ARE,12.

---.-

HI-+---H--l-f--l--ll--li-l--l++tt*t-~
enO.NIAR~,
'NX : '~_A~)1-2:~~:~~~~~-~_---_-+-f- -+- ~: -=- =- =- =- =- =- =- =- =- - - - - l
I
I!;!!!
~:::
.-----=:=
'

1--:1--:iH--l:

I

I

':'

:'.'

--I---cl----I----I--·---------+--+-+-_+-J~++I--+-+---'+---I-+!--TI- it; : ~~nlw~~4-~/~T,

1--+2T---l--g!

C

i'

!

I

!

:

i

t

i

Figure 10-3. Summary of BITON Operations

10-10

-----+-->--'

,

i

The following operations use a one-position alphameric array element either as a source of bits
.............

1--2-l-5-1-+C-l--li-+--~-+-

3 0

,I

I

I

I I ! I, I I 18ttiTldNIAL!P!H'~ I i I I lIrrS
ill ! I II l f i i 1 , 1 1
I

I

C
I
c
I!::'
I--+--i--+-I--I:-+-~--l- -+;-

C

!

I

I

20

218'

,

BII~

'

iii:, i
,i

:

The following operation uses a one-position alphameric field as a source of bits. Any bits that are
on in the field named ALPHA cause corresponding bits to be set on in the field named BITS.
If bits 5 and 7 are on in the field named ALPHA, the BITON operation sets bits 5 and 7 on in the
field named BITS.
I I
I I
I I I I I I I
I I I : I ! I I I I I i
I
IJ
I
I I
I I i I

2 1:

41

,"

'

Operation Codes

:'

-:-r
,i

1

',"

:.

I

i

:

i·'

A8A,Jtx ~~,+-+-+----+----+--+--+---+'I--l--+--~'i--+-~~
'

':

t!

I!
i I

CHAIN (CHAIN)
Indicators

Result

Resultino Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

Opt

IOpt

Required

Required

Blank

Optional Blank

156-57

158-59

I

iBlank

The CHAIN operation causes one record to be read from
a disk file during calculations. The CHAIN operation can
be used either to read records randomly from an
indexed, sequential, or direct file or to load a
nondelete-capable direct file (for more information on
nondelete-capable direct file loads, see Direct Files in
Chapter 3).
Enter the operation code CHAIN in columns 28 through
32. Factor 1 defines the relative record number or the
key of the record to be selected for processing, and
factor 2 names the chained file from which the record is
read. This file must be defined by a C entry in column
16 of the file description specifications.
Indicators can be used in columns 7 through 17, but
columns 43 through 53 and 56 through 59 must be
blank. If the chained file is conditioned by an external
indicator on the file description specifications, the
CHAIN statement should be conditioned by the same
external indicator.
A maximum of 15 chained and / or demand files is
allowed per program.
Columns 54 and 55 should specify an indicator. If the
record is not found (or, for a direct file load, if the
record location does not exist in the file), the indicator
turns on. No update is permitted to a chained update
file when the specified record is not found; however,
adding records to a file is allowed. Duplicate records in
the file are possible after an unsuccessful chain to an
update-add file if the key field is modified prior to an
add to the file.

If an indicator is not specified in columns 54 and 55 and
the record is not found, the program halts and an
operator action is required. When chaining to a file with
packed record keys, the field specified in factor 1 of the
CHAIN operation must have a packed length that is the
same as the length of the key field in the chained file.
Packed key fields can be up to 8 bytes long. The
packed field equivalents for zoned decimal fields up to
15 bytes long are shown in a chart under Packed
Decimal Format in Chapter 7, Input Specifications.
Note: If you chain to one or more files during the same
RPG II cycle, record identifying indicators assigned to
the chained file or files remain on throughout the cycle if
the previous chain operations were executed
successfully. If you chain to the same file more than
once during an RPG II cycle, only the last record
processed is updated during output time unless an
exception output is associated with each chain
operation.

Random Processing

To read a record from a sequential or direct file with the
CHAIN operation, the record must be identified by
relative record number. To read a record from an
indexed file with the CHAIN operation, the record must
be identified by a record key. A field can be specified to
contain the relative record number or record key.
If the record has been deleted from the file, the
no-record-found indicator is turned on. If the no-record
found indicator is not specified, a message is displayed.
Factor 1 must contain a relative record number or record
key, or the name of a field that contains a relative
record number or record key. Factor 2 must contain the
name of the file from which the record is read.
Figure 10-4 shows an example of chaining to and
updating an indexed file.

Alphabetized Operation Codes
CHAIN

10-11

File Description Specifications
File Type

F

Mode of Processi ng

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

r----

End of Fde

Record Address Tvpe
Sequence

Filename

Typeot File
Organization
Nor Additional Area

File Format

Line

Symbolic
Device

Device

...J

Number of Tracks
for Cylif"lcler Overflow

Name of
Label Exit

Number of Extents

Tape

UJ

Rewind

Storage Index

~

~

o Overflow Indicator 8

Block
Length

E:

Record

~ ~

Length

Condition

§

r----

~t:~t~~:ld .~

~ ~

Location

z

Continuation Lines
Option

WJ

Ul-~

~

Entry

RECIN file consists of records sorted by item number, with
each record containing a quantity ordered.
Input Specifications
Record Identification Codes

I

-

0

Filename

Line

al

Position

~
0

~

z U

~

Position

~

:;;

~

~

to
~

Field
Indicators

Field Location

Position

~
0

0
z U <5

Ji

~

From

c:
...J

Vl

~

To

0

:B-o

,~ Q)

u...i.i:

~

g

,£

~

~

Q:

0

~

"-

to

z U <5

Field Name

~

"

-;:

-5

~

:~

~,g

8

:;;u

~
-0
0

Zero
Plus Minus or
Blank

~
0;

u:

record and update it. If it is not fou nd, a SET operation
displays the item number on the screen. Indicator 20
turns on if the record is not found.

ITEMNO is used as a control field. When all the quantities
for one item number are added, a control break occurs. The
CHAIN operation then uses ITEMNO to find the master

Calculation Specifications

C

-

Indicators

~.

...Jc:
=0

4

5

~ (I)~

....

~

85 IE
1

8

o

1

C

o
o

2

cll~

3

CL

4

c[

o

5

C

Factor 1

Operation

Factor 2

S

z

0

z

6

.g I

Plus Minusl Zero

~~

Compare

Comments

1>211<21=2
g~
'u :!: LookuplFactor 2)is
o I High Low Equal

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 4344 45 46 47 48 49 5051 52 53 5455 5651 5859 60 61 62 63 64 65 66 61 68 69 10 11 12 73 14

~~
I

~rrl'l

~N~ -t-l

-~~'

ADD

I I 11::11'1 N:J
11 \ 1t:11'I NU

QIOI~

I

1\ Ie

lUI 111

NM AS Til NI\I
"~T .......
~IU8
II
lU 1\ 1

rl" All

\ [j

l~

1'~

nlE TIA llL Icl~ Lies

~~

C

1.1.1

~A SIT IF-It< Ri~t

Fir N~

FO UiN o? NO -D lSP LArt

VE ~- TIOIIAIL

IGO\-\

I~ Other total calculations

J( 1 I 11 I I
I
If the master record is found, the total quantity for the
item number is subtracted from the quantity on hand.
o

Length

Name

6

o

At

Arithmetic

c£

I- '0

E

3

AL

~!~

Line

Resulting
Indicators

Result Field
'--

0_

JLLl 1 J

After the total calculations, the QOH field in the master
record is updated.

Output Specifications
Output Indicators

Skip

Field Name

a
c:

to

Figure 10-4. CHAIN Operation
10-12

Operation Codes

;;:

0

z

'AUTO

leA L"l<:;

.3
j3

'"

~

>End

II

Position

in
Output
Record

c:

g
Q:

,--Commas

Yes
Yes
No
No

I

Zero Bal,ances
to Pnr.t

r

Yes
No
Yes
No

No Sign

X

=

J
K

Y

=

L

Z

Field Edit
= Zero

CR

A
B
C

M

Constant or Edit Word

Remove
Plus Sign
Date

Suppress

COMP (COMPARE)
Indicators

'C'C'C'C'C'C'}
Result

7-8

19-17

Factor 1

Factor 2

Field

Oot

loot

R~quired

Required

Blank

Resulting Indicators

54-55

156-57

158-59

,c,c,c,c,c,c,

Equal length
alphameric fields

1 required

The COMP operation compares factor 1 with factor 2_
As a result of the compare, indicators turn on as
follows:

'C'C'C'C'C'C'}
,C,C,C,b,b,b,

Unequal length
alphameric fields

Figure 10-5. Comparison of Alphameric Fields

High

Factor 1. is greater than factor 2.

Low

Factor 1 is less than factor 2_

Equal

Factor 1 equals factor 2.

Factor ~ and factor 2 must be both alphameric or both
numeric.
At least one reSUlting indicator must be specified in
positions 54 through 59.
The fields are automatically aligned before they are
compared. If the fields are alphameric, they are aligned
to their leftmost character. If one is shorter, the unused
positions are filled with blanks (see Figure 10-5). The
maximum field length for alphameric fields to be
compared is 256 characters.

Figure 10-6. Comparison of Numeric Fields

If the fields to be compared are numeric, they are
aligned according to the decimal point. Any missing
digits are filled with zeros (see Figure 10-6). The
maximum field length for numeric fields to be compared
is 15 digits.
If an alternate collating sequence is specified,
alphameric fields are compared according to the
alternate sequence.
Figure 10-7 shows some examples of specifications for
compare operations.

Alphabetized Operation Codes
COMP

10-13

Calculation Specifications

C
r---

Indicators

Result Field

At At

1i

Factor 1

Operation

Factor 2
Name

~

Line

j
3

4

5

6

o

1

C

o

2

C

o

3

C

o

4

C

o

5

C

o

6

C

o

7

C

o

8

C

o

9

C

0

0

Length

z
Z
Z
9 10 11 121 314 151 617 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 4344 45 46 47 48 49 50 51

Indicators

~'I ~~ 3~

u: IMEIR'

113 l1~ 15

G,l\ ~p ~~

CO MP
~O MP

-~

-+0-

NE TP ~~

t:(,) Mlp ~

I'ID NTIH

IH1 H1

The contents of the field SLS77 (1977 sales) are compared
with the contents of SLS78. If 1977 sales exceed 1978
sales, resulting indicator 21 turns on; if they are less, indicator 26 turns on; if the two years had equal sales, indicator 30 turns on.
The alphameric constant OCTOBER is compared with the
contents of the field named MONTH, which must also be
defined as alphameric. If the MONTH field does not contain the word OCTOBER, indicator 13 turns on; if it does,
indicator 15 turns on.
The contents of the field named G RSPAY, which must be
defined as numeric, are decimal-aligned with numeric
constant 1250.00. If the value in field G RSPAY is greater
than or equal to 1250.00, indicator 04 turns on; if its
value is less than 1250.00, indicator 05 turns on.
The contents of the field N ETPAY, which must be defined
as numeric, are decimal-aligned with numeric constant 0
and then compared to It. If NETPAY IS greater than zero,
indicator H1 remains off; however if NETPAY is zero or
negative, indicator H 1 turns on.

Figure 10-7. Compare Operations

10-14

Operation Codes

I

1~ 5Qj .~~

'--'--

-

Comments

5455 5657 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

1'("\ IMP SL ~7B

I l

'-f+

Plus Minusl Zero
Compare
1>21<211=2
Lookup(Factor 21i,
High Low Equal

117

~5 'L.S

-_.

Resulting

Arithmetic

I

DEBUG (DEBUG)
Indi~~ato!_s

Records Written for DEBUG

_

iResult

7-8

:9-17

'Factor 1

I Factor

OPt

'OPt

:Optional

[RCQuirCd

2

:Field
10Ptionai

llesuJtiDg Indipators
54-55

156 -57

158-59

I Blank

[Blank

jBlank

The DEBUG operation is an RPG II function that helps
you find errors in a program that is not working
properly. Either one or two records containing
information helpful for finding programming errors are
written to an output file as a result of this operation. All
DEBUG output in a program is written to the same file.
The DEBUG operation code can be specified at any
point or at several points in the calculation
specifications. Whenever the program encounters the
DEBUG operation, either one or two records are written
depending upon the specifications entered. The first
record contains a list of all indicators that are on at the
time the DEBUG operation was encountered. The
second record, if specified, shows the contents of the
field specified in the result field.
Factor 1 can contain a literal or the name of a field to
help identify the particular DEBUG operation. The length
of the specified field can be from 1 to 8 characters. The_
contents of the field or the literal are written in the first
record. If factor 1 is not used, the RPG II generated
statement number of the DEBUG operation code is
written in the first record. Factor 2 must contain the
name of an output file on which the lines are written
and can be any valid output file. The same output
filename must appear in factor 2 for all DEBUG
statements in a program. The result field can contain
the name of a field or array whose contents are to be
written in the second record. Any valid indicator can be
used in columns 7 through 17. Columns 49 through 59
must be blank.

For a DEBUG operation, the first record is always
written and appears in the following format:
Output
Positions

Information

1-8

DEBUG-

9-16

Literal or contents of field entered
in factor 1 (optional) or the
statement number of the DEBUG
operation code in the program.

17

Blank

18-32

The words INDICATORS ON-

33-any position The names of all indicators that
(depending on
are on, each separated by a blank.
length of field) More than one record may be
needed.
The second record is written only when an entry is
made in the result field. The record is written in the
following format:
Output
Positions

Information

1-14

The words FIELD VALUE-

15-any position The contents of the result field
(depending on
(up to 256 characters). If the
length of field) result field is an array, more than
one output record may be needed
to contain the array.

The DEBUG operation can be used in the calculation
specifications only if a 1 is entered in column 15 of the
control specifications. If the control specifications entry
was not made, the DEBUG operation code and its
conditioning indicators are treated as a comment. See
Column 15 (DEBUG) in Chapter 2, Control Specifications,
for more information.

Alphabetized Operation Codes
DEBUG

10-15

DIV (DIVIDE)

EXCPT (EXCEPTION OUTPUT)

Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

Oot

loot

O~ional

RELquired

Required

Optionad

158-59

OPtionallo~tional

Factor 1 (dividend) is divided by factor 2 (divisor). The
quotient (result) is placed in'the result field. Factor 1
and factor 2 are not changed. If factor 1 is 0, the result
of the divide operation is O. Factor 2 cannot be O. If it
is, the job stops immediately_ The operator can continue
processing, however, by responding to the halt. When
processing is continued, the result and remainder are set
to 0_ If factor 1 is not present, the result field is divided
by factor 2, and the quotient is placed in the result field.
Any remainder resulting from the divide operation is lost
unless the move remainder (MVR) operation is specified
as the next operation. If move remainder is the next
operation, the result of the divide operation cannot be
half-adjusted (rounded).

ENDSR (END SUBROUTINE)
Indicators
7-8
Opt:
SR

Result

Resulting Indicators

9-17

Factor 1

Factor 2

Field

54-55

56-57

58-59

Blank

Optional

Optional

Blank

Blank

Blank

Blank

The ENDSR operation defines the end of the subroutine;
therefore, it must be the last statement in the
subroutine. Factor 1 can contain a name that can be
used as a point to which a GOTO operation within the
subroutine can branch. The control level entry (columns
7 and 8) can be SR or remain blank. Columns 9 through
17 must not contain any conditioning indicators.
The ENDSR operation ends the subroutine and
automatically causes a branch back to the statement
that follows the EXSR operation unless the subroutine is
the IN FSR (exception / error processing) subroutine. For
the INFSR subroutine, an optional factor 2 entry on the
ENDSR operation specifies the return point for the
subroutine. The valid entries for factor 2 for the INFSR
subroutine are described in Chapter 13 under WORKSTN
Exception/Error Handling. For all other subroutines,
factor 2 must not contain an entry.

10-16

Operation Codes

Indicators

Result

Resultinalndicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

O~

jom

Blank

Blank

Blank

Blank

I Blank

IBlank

The EXCPT operation allows records to be written
during calculations. Use the EXCPT operation primarily
to write a variable number of similar or identical records
(either detail or total) in one program cycle. (Normally
only the exact number of records specified by the output
specifications are written in one program cycle.) For
example, EXCPT can be used to produce a variable
number of identical mailing labels, to write out contents
of a table, or to produce a number of records having the
same information.
To use this operation, enter EXCPT in columns 28
through 32. Indicators can be used in columns 7
through 17; however, all other columns must be blank.
The lines that are to be written during calculation time
are indicated by an E in column 15 of the output
specifications. Figure 10-8 shows the use of the EXCPT
operation to produce a variable number of identical
records on a printer file.

Input Specifications
Record Identification Codes

I

Filename

Line

~

3

4

:.

\)

7

8

'3

~

Position

-r-

;

~R
c-c-

~ ~

]

Po~itlon

_
;

t

~ ~

't

Position

~ ~ ~~

Field Name
From

c::::

g

Zero

To

PillS r..'inus or
Blank

~u6ci)C:

zuu

zuO

L/)

AND

:

<61! I I

~e

_~ ,

~~f-~f--_I

1

'I

I

!

1:2 13 14 15 1G 17 13 19 2:) 21 22 23 24 ~5 2G 27 28 29 30 31 32 33 34 35 36 37 33 3rl 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 09 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

10 11

~_ :~N.PlcrW
~3___ ~
"
04

_

l

Field
Indicators

Field Location

I---

I

I

:

I

IU__

I

I

I

~ __ I___ ~_:_

- f - - _:_:

I I I LL
i i t1 :2.0

r-I_

I·

_~ _ _

__

ul

!_~~_.J_LL _~_l~_

1

IIII I I I I

!

~AM~_~_~
11'1. Il~0C:O~!L I

__

II:

i

!

II

I

.

I

!

II

i

Ii!

i

!

:

__ LLi

I

Calculation Specifications

c

_

~~

~j ~
~ g e5

I

5

A~d

Factor 1

Operation

~

7

9 10 11 12 13 14 15 1617 18 19 20 21 22 23242526

o
o

1

c

2

o

3

c
c

~

~

,

o

5

o

6

o

7

C

8

c :

Length

Arithmetic

-

I

n

1

§

lookup(Factor 2)is

Comments

>2~~r::;rtl = 2

High

2829 3031 32 333435 36 3738394041 42 4344454847 4a 49 5051 5'

Bcrb

I

f-P-IU'''',-'-IMln--'u,-r'Z'-er-io

~
~

I

c
c
c

~

J

8 s·
8

Resulting

Indicators

Factor 2
Name

6

4

!

And

Result Field

I

~

3

o

I

0

ne

L

Indicators

~.

Low Equal

54 55 565758 fig 60 61 62 6364 6566 67 fiB 6q 7071 72 73 74

C" U ~IT

(/J2
F! Nn I

= (}, I?

,

I

:

2

1

NZ0
i

~

c

I

f"ONSe. r

i

coNSEC

T~cr

I EN:'[)

l

S'U8

I

I

(/)

N'O" rooAfsIN

"ON 5£1(,
I I

i
i

Output Specifications

0

r;:

I--Filename

line

~~~
0 E L

fti"roro

f--

~
3

4

5

6

.;-~"O
7

8

9

0

1

00 U~ plU1'

2

0

I
-

Jd

I_

IE

1L_

Field Name

1

:t

0

z

I

z

z

~ ~
8 U

-1

I

·AUTO

!

~11

~31

~ ~

Position
in
Output
Record

Commas

Zero Balances
to Print

Ves
Ve,
No
No

Ves
No
Ve,
No

No Sign

CR

:

1
2
3

A

J
K
L
M

B
C
0

4

X = Remove
Plu,Sign
V, Date
Field Edit
Z·= Zero
Suppress

a:

g

Constant or Edit Word

Q:

t

2

3

4

5

6

7

8

9

1011 1213 14 15 16 17 1819 2021 2223 24

#

32 33 34 35 36 37 3839 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I III

--

~
cr

0

'"

10 11 12 13 1415 1617 1E 1920 2t 22 232425 26 27 2829 30

0

0 3
0 ___
__
'-_L-.

. Output Indicators

Skip

-

I

!
~ Msi
i lL~L-_l

Records in the input file have two fields, NAME and
COUNT. The NAME field is to be entered into a certain
number of records. That number is indicated in the
COUNT field.
The first calculation line compares COUNT to zero. If
COUNT is equal to zero, indicator 02 turns on and the
GOTO operation skips further calculations. If the
COUNT field is one or more, the EXCPT operation is
performed, and the exception record indicated by the E
in column 15 of the output specifications sheet is printed.

2rl

I

i
I
L

L-L.__

I

-- -

I

The field CONSEC keeps track of the number of records
printed. Each time an exception record is printed, one
is added to CONSEC. CONSEC is then compared with
COUNT, the field that tells how many records should be
printed. If they are not equal (indicator 20 is not on), a
branch is taken back to DOAG IN. Another record is
printed. One is added to CONSEC, and CONSEC is
compared to COUNT. If these fields are equal, another
input record is read. If not, the same operations are done
again. Whenever CONSEC equals COUNT, enough records
are printed. CONSEC is then subtracted from itself, making
it zero. This last operation is necessary so that an accurate
count can be kept for the next record.

Figure 10-8. EXCPT Operation that Produces a Variable Number of Identical Records

Alphabetized Operation Codes
EXCPT

10-17

EXIT (EXIT TO AN EXTERNAL SUBROUTINE)
Indicators

7-8

19-17
·IOpt

Opt

Result

Resulting Indicators

Factor 1

Factor 2

Field

54-55

156-57

158-59

Blank

Required

Blank

Blank

I Blank

IBlank

To specify linkage to a non-I/O subroutine for a
SPECIAL file, use the EXIT operation. You must keep
track of the EXIT that is taken because index register 2
does not point to the DTF on an EXIT operation.
Note: The maximum number of user-written assembler
subroutines that can be used in a program is 2256.

The EXIT operation designates the point in the
calculation specifications when control is to be
transferred from RPG II to an assembler language
subroutine.
The rules for use of the EXIT operation on the
calculation specifications are as follows:

I

Position

Execution of Subroutine

First detail line in
calculation specifications

Immediately following data
routine file, that is, after
data is extracted from
input record

Columns

Entry

Operation
(28-32)

EXIT

Last detail line in calculation specifications

Immediately before heading
records output time

Factor 1
(18-27)

Blank

First total line in calculation specifications

Immediately following input
routine (after determination of
record type and testing for
control level break)

Factor 2
(33-42)

The name of the subroutine to
which control is to be passed. The
name must consist of 5 or 6
characters, the first 4 of which
are SUBR. The remaining characters must be alphabetic for
user-written subroutines. (Numeric
characters are reserved for IBMsupplied subroutines.) The module
name and entry point name must
be the same.

Result field
(43-48)

Blank

Resulting
indicators
(54-59)

Blank

The EXIT operation can be controlled by a control level
indicator (columns 7 and 8) and conditioning indicators
(columns 9 through 17). If no control level indicator is
used, the EXIT operation occurs at detail calculation
time.
The position, of the EXIT operation in the calculation
specifications of the RPG II program determines when
the actual subroutine execution occurs (see Figure
10-9).

10-18

Operation Codes

Immediately before total
Last total line in
calculation sp,ecifications records output time
Any other detailltotal
line in calculation
specifications

Immediately following the
previous calculation operation

Figure 10-9. Relationship between Position of EXIT
Operation and Execution of Subroutine

FORCE (FORCE)

EXSR (EXECUTE SUBROUTINE)
!

Result

7-S

19-17

Factor 1

IFactor 2

Field

! Resulting_Indicators
~5 15s-57 15S-59

7-S

19'-17

Factor 1

Factor 2

Field

54-55

i5s-57

i5s-59

Om

iO PJ

Blank

lRElQuired

Blank

[Blank

Blank

IOpt

Blank

Required

Blank

Blank

[Blank

IBlank

Indicators

IBlank

[Blank

Indicators

Result

Resulting Indicators

The EXSR operation causes the subroutine named in
factor 2 to be executed. The EXSR operation can
appear anywhere in the program. Whenever it appears,
the subroutine is executed. After operations in the
subroutine are performed, the operation in the line
following the EXSR operation is performed.

The FORCE operation allows selection of the file from
which the next record is t9 be read. The FORCE
operation can be used for primary or secondary input
and update files; however, it cannot be used to read
from files assigned to a KEYBORD or WORKSTN
device.

The EXSR operation can be conditioned by any
indicators; thus, the subroutine is executed only when all
conditions are satisfied. Any valid indicator can be used
in columns 7 through 17. If no indicators are used, the
subroutine is always executed.

Factor 2 in a FORCE statement identifies the file from
which the next record is to be selected. If the statement
is executed, the record is read at the start of the next
program cycle. If more than one FORCE statement is
executed during the same program cycle, all but the last
is ignore.d. FORCE should not be specified at total time.

Factor 2 must contain the name of the subroutine that is
to be executed. This name must appear on a BEGSR
operation.

Coding Subroutines
All RPG II operations can be performed within a
subroutine, and these operations can be conditioned by
any valid indicators in columns 9 through 17. Because
SR or blanks must appear in columns 7 and 8, control
level indicators cannot be used in these columns.
However, AND/OR lines within the subroutine can be
indicated in columns 7 and 8.

FORCE statements override the multifile processing
method by which the program normally selects records.
However, the first record to be processed is always
selec~ed by the normal method. The remaining records
can be selected by FORCE statements.
Figure 10-11 shows how the FORCE operation can be
used to control input from primary and secondary files.

Fields used in a subroutine can be defined either in the
subroutine or in the main program. In either instance,
the fields can be used by both the main program and
the subroutine.
Any number of subroutines can be included in a
program; however, a subroutine cannot contain another
subroutine. One subroutine can call another subroutine;
that is, a subroutine can contain an EXSR operation
code. However, a subroutine cannot call itself.
Subroutines do not have to be specified in the order
they are used. Each subroutine must have a unique
name and contain a BEGSR and EN DSR operation.
See Figure 10-10 for an example of coding a
subroutine.

Alphabetized Operation Codes
EXSR-FORCE

10-19

Calculation Specifications

C
I---

Indicators

At

Resulting

Result Field

1

Indicators

Arithmetic

Operation

Factor 1

Plus

Factor 2
Length

Name

Line

Minus Zero

Comments

Compare

1 >2 1 < 2 1 = 2
Lookup(Factor 2)is

0

0

z

z

0

z

High

9 10 11 12 13 14 15 1617 18 19 20 21 22 2j 24 25 26 21 2829 3031 32 333435 36 37383940 41 42 4344454647 4849 5051

345

Low Equal

54 55 56 57 58 59 GO 61 62 63 li4 6566 676869 "'0 71 12 73 74

o 1 C .1
1
!
L~ll
~+~~~-~!~:~-~I+~~~-+~'~~~-+-~~-+-~4-t~~-~~~~~-~~~-r~,
_~_ -t-~~-f~
o2 C
o3 C
:1 i
lEX IR iSR H,
:---~ l
!
Iii I
o4 C
,
I
i>
I
~ Calculation operations
i!
I
o5 C
:i
I
1 I')
J
I
I
1
I ,
~+--+--I--+-+~
If-+--+-+-f- T ~-f-- - f-t- - - - -'E~;":-IR
~
'i :
i
i-1
I Ii:
o6 C

1-1
1

11- '

I

o
o
o

7

C

-I--!.~

8

C

!

H

r-f---t- -r5

i

9

CiS

1 0

C~

11

c

I

I

SIR[IN~
I~ 'l'-ir·IH~l

i

;,; v,,m
.

SRir

iii).

~.,...

!

I!\

II

r-

~1+-2++C-+~-'L'lI--i'"P+1"r--f-jf-+-+-+_~--+--+-+-+-t--Lt--LS~~~\_~ 8~lN:tr-"';'_f1 5
1 6

1 7

I

I~~~~-+-f~++-+-t+-t-+-+--jf-++I-+'-+I- fc

~~

C

r-c

i1n

c;R

Operation Codes

"

H-te~-tD~S.~

Figure 10-10. Example of Coding Subroutines

10-20

-+

i i '

I

H-l'
!

I

,

1

U-

i

1)1
I i i i
I
! B~.~Sf-I~~~~i~rH~I++~i~j' .~44-~~~~~~~~~~~
i i) i
!
i i . _i
+-+-+-+~+-+--+-t--"+-+_11--'+-+--1

!

::

'I

I

i,

'

I

-j--

I

I

. , . -, One subroutine can ca
-Ih-;--"--- -i another subroutine.
:

II

+--I--+--'--+-+--+-+-~

ttL -h-1-f- !-~t- ;---l--+-+--+-~--+--j-+-+:--l---i-+-I+-+--1
~--t--I- -l---j-I--I~l-t-~~+-~--+-+--l-+-+-+'-+---+--+-I---l

File Description Specifications

The NBR field of each primary record contains the number
of secondary records to be read and written after each primary record is read. If NBR is less than or equal to zero, a
halt occurs. No primary or secondary records are read. Processing begins with the next primary record according to
normal selection.

-tnput Specifications

If NBR is greater than zero, the field is reduced by 1 and
tested (line 02 of the calculation specifications). If the
result is not negative, the FORCE operation calls for input
on the next program cycle from the secondary file. The
primary record is written, and secondary records are read
and written until NB R is negative (indicator 03 is on).
The FORCE operation in line 04 then calls for input on the
next primary file.

Calculation Specifications

C
r---

Indicators

Arithmetic

At

4

°
°
°
°
°

2

2

9 10 1112 1314 1516 1718 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 5051

56

NBR

al1

1

C

2

C

N~

3

C

i\lf,

I

t!O i~ p

I. .

"'N n.l

HI1 l-li1

NBiR

Cl!i3

C

5

Comments

5455 5657 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

1(1

SUit
11
Fi~ I' c.. I~IT IN:Y J.r~
IFIt'lIR r. ~Il rJ,pIUT1

NBR

1

~i,~ NIM1

C

4

Length

a

0

0

2

Plus IMinusl Zero
Compare
1>2)1<211=2
LookuplFactor 21is
High Low Equal

Factor 2
Name

!
3

Operation

Factor 1

At

~

Line

Resulting
Indicators

Result Field

NE )(rr tlY I'liE ~EC
NE XiT lei'! CliE IPRl

.-

Output Specifications
-

o

Ii ~ ,
-5 Space

Filename

Line

~ ~~ ~

~ ~~ ~

o R
A"N '0
5

6

7

8

9

0

==>

Output Indicators

Skip

~

z

1

.1

And

And

0

2

F;,1d N,m'

0

Z

lfT:=n
ex:

I

• AUTO

A

J

No

D

M

Oo~r.' ":~"' "';,, '; ~ :: ~~~:;,

Position

No

~~ ~~ ~utPut ~~

Suppress

Constant or Edit Word

Record

!

-t -

Zero Balances

•

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

1011 12 13 14 15 16 17 18 1920 21 222324 2526 27 28 29 30 31 32333435 3637 38 39 4041 4243444546474849 5051 52 53545556 57585960 61 62636465666768 69 70 71 72 73 74

-+-:-J-t-ll~\'t-'r+lu"'P-T+--t-oi- - -

1-:+2-+1

°

-1-t-";~,ti~"':T--If-+--t- -r- .

t--t-t- +- +-1--+-+- - -I-+-+-(--+-+-+-I-+-+-+--+--I

°3
FT J:il t'li6
l1~
!
1-0-+4+-~o:..J.--j--+--+-JI-t---I-±.J--.I----l--W-+-~-+--I--l--+---+-l-l-+-l-t--II=J:.j...I'~J:l;\Joi,ojjn~~~-I-iI--l-il -!o612i1-+-~~:~_+_·-t:--+-r-+r--I_-+_.-+--t-+-+--t-+-+-I-+-+-+-l-+-+--t-++-+-+-+-I
0 5

0

~_,-6~

°

f-+ +-1_t-+-+-+--+'--+I---+.-__ 1_ --r-r- _.-

L __

1__ ' - __

-1_L '-'---

I

_

J

F1

EI~1fl-t-+-j-!,l~"'1~-.3 __ r-I

-l

f--

--~-!--t--t-t---+-+-t---+-t-t---+-+-t---+I-t-t---+'+-+-+-+-+-+--I
__

~LLLL ~."--,_--L_i,--,--"---,--~--,_.L_ '--_'-

Figure 10-11. Example of FORCE Operation Controlling Input

Alphabetized Operation Codes
FORCE

10-21

GOTO (BRANCH TO)
Indicators

Result

ResultinQ Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

T56-57

158-59

OPt

IOpt

Blank

Reauired

Blank

Blank

IBlank

iBlank

The GOTO operation allows operations to be skipped by
instructing the program to go to (or branch to) another
operation. A GOTO operation can be used to specify a
branch:
• To a previous or a succeeding specification line
• From a detail calculation line to another detail
calculation line
• From a total calculation line to another total
calculation line
However, a branch cannot be made from a detail
calculation line to a total calculation line or vice versa.
Neither can a branch be made from calculations
conditioned by LO through L9 to calculations conditioned
by LR or vice versa. (A total calculation line is defined
as one that is conditioned by a control level 'indicator in
columns 7 and 8 of the calculation specifications.)

10-22

Operation Codes

Factor 2 must contain the name of the label to which
the program is to branch. This label is entered in factor
1 of a TAG operation. If the GOTO is within the
subroutine, the label can be specified on the ENDSR
statement in factor 1. The label can be from 1 to 6
characters long and must begin in column 33 with an
alphabetic character. The remaining characters can be
any combination of alphabetic or numeric characters.
Blanks must not appear between characters in the label.
Factor 1 and the result field are not used in this
operation.- The GOTO operation can be conditioned by
any indicators. If no indicators are specified, the
operation is always done.
See Figures 10-12 and 10-13 for examples of the
GOTO operation.

Calculation Specifications

C
-

Indicators

Arithmetic

At At

Operation

Factor 1

."
0

Factor 2

~

Name

line
0

0

z

z

Resulting
Indicators

Result Field

Length

0

~

E
2
0

0

z

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 3031 32 3 3 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

3

4

5

o

1

c

o 2

C

o

3

o

4

o

5

o

6

c
c
c
c
C

o

7

o

8

C

o

9

c

1 0

C

11

C

1 2

C

1 3

c

1 4

C

1 5

c

1 6

C

17

C

1 8

C

1 9

C

IFIt 1t:11

1~

~IQ

[Fit ~II 1.,16

IRirIN12

[suia

tiC II ~IR

~Ort(l

lli11

~'{')h'lll

rr~l1

IIIUI\ rt
Ir~~

[Fit ir:1 nlR

l5~

~~ I~~

~[2

Plus IMinusl Zero
Compare
1>211<211-2
LookuplFaClor 21is
High Low Equal

Comments

54 55 56 57 58 59 60 61 62 63 64 65 66 61 68 69 70 71 72 13 74

111Gl

Some calculation
operations

IRIT tNI1

rr

Ie
Some calculation
operations

INf1~

~(.,

!rIC

[j5

rr~~

IFll ~II II'Ilr

1'It:~ 1111:

k:ltrll;

l21!

~.

fl;jNI~

[N~
1711 I'IT 1r:ll irlr

I~~

1.

If the result of the subtraction in line 01 is minus
(indicator 10 is on), a branch is taken to RTN 1
(routine 1) named by the TAG operation code in
line 09. Notice that both the GOTO (line 02) and
TAG (line 09) are not conditioned by control level
indicators.

2.

If the branch is not taken in line 02, the mUltiplication in line 03 is performed. Then the branch to
RTN1 (line 09) must be taken because this branch
is not conditioned by indicators.

3.

Operations in lines 10 through 12 are then done.
If the operation in line 12 does not turn indicator
15 on, a branch is taken backwards to RTN2
(line 05).

~IT ICII

121~

l2IQ

tNII

I

4.

Operations then go in the order specified again from
lines 06 through 12. Nothing is done in line 09 because TAG gives only a name. These same operations
are performed again and again until indicator 15 does
turn on.

5.

When indicator 15 is on, the branch to RTN2 is not
taken. The TESTZ operation is then performed. If
this operation causes indicator 20 to turn on, a
branch is taken to line 17 (GOTO END). If indicator
20 is not on, the operation in line 16 is done.

Figure 10-12. Using GOTO and TAG (Skipping Operations)

Alphabetized Operation Codes
GOTO

10-23

Calculation Specifications

C

-

Indicators

Result Field

At At

Operation

Factor 1

Plus IMinusl Zero

Factor 2
Name

Line
0

0

z

Z

Length

0

z

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

3

4

0

1

C

E tPIT

0

2

c

t:1~

o

3

C

~

tPit
"'II
"'" "'II

5

Resulting
Indicators

Arithmetic

o

4

C

I:

o

5

C

t-

o

6

C

o

7

C

o
o

8

C

9

C

Compare

Comments

1>211<211=2
Lookup(Factor 21 is
High Low Equal
54 5S 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

t' I

E C. Pit
E cPit
E CIPll

Assume you want to make eight mailing labels for every

However, by using branching, you can code it all in five

customer you have. The customer's name and address are

lines as shown below. An EXCPT line is printed out.

found on an input record. Because you want to write eight
labels for each record, you can use exception lines and the

One is added to COUNT to keep track of how many times
the line is printed. Then COUNT is compared to 8. If

operation EXCPT instead of coding eight identical output
line specifications. (See Exception (EXCPT) in this

COUNT does not equal 8, a branch is taken back to the
beginning (GOTO DOAGIN). If COUNT equals 8, the

chapter for further information.)

branch is not taken. Instead, the COUNT field is set to
zero for the next cycle.
Calculation Specifications

C
-

Indicators

~

0_
...Ja:

~!~
a
E ::. en

3

4

0

1

5

Factor 1

~

8 5-

6

7

8

~

Z

2

c

o

3

C

o

4

o

5

c
c

o

6

C

o

7

C

Factor 2

0

z

...

1

..

1. . .

I..

IN

~I.x llt'll

1

Clo:U'NT

d
I

-I-

Operation Codes

Compare

~tl'[~

1-

-

""'U UNI

fO ft1IP ~
r,n T~ DO Ar, I~
z- ~iD lD'aJ

Ic~ UINIr

54 55 5657 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

lele UNrT
I

i

12~
---

-

I
'-.1

Comments

1 >211 <211 =2
Lookup(Factor 2lis
High Low Equal

!TA~

Figure 10-13. Using GOTO and TAG to Eliminate Duplicate Coding

10-24

Length

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

~2~

Indicators

Plus IMinusl Zero

Name

C

o

Operation

a:~

I-

Resulting

Arithmetic

AL At

=0

Line

Result Field

Bypassing a KEY Operation

KEY (KEY)
Indicators

Result

Resulting Indicators

7-8

13-17

Factor 1

Factor 2

Field

54-55

Opt

10pt

OPtional

Blank

ReQuired

Optional 10Ptional-'Optional

156-57

158-59

The KEY operation causes a pause in calculations during
which the operator can enter data from the keyboard.
All KEY operations are directed to the display station
that loaded the program or to the display station
assigned to the program by the WORKSTN Oel
statement.
To use the KEY operation code, the device name
KEYBORD must be specified in columns 40 through 46
of the file description specifications. KEY can be used
only with a KEYBORD input file. As the data is keyed
by the operator, it is displayed on the screen in one of
two formats:
• If the record length is 40 or less, the display consists
of six lines, with 40 characters per line, centered both
vertically and horizontally on the screen.
• If the record length is greater than 40, the display
consists of 12 or 24 lines with 79 characters per line
(1 character is reserved for field attributes).
When the KEY operation is used, the contents of the
result field are determined by the operator's response.
The possible responses are:
• The operator keys the data and presses an entry
function key. If not all positions of a field are keyed,
numeric fields are right-justified and padded to the
left with zeros; alphameric fields are padded to the
right with blanks.
• The operator presses only an entry function key,
which causes any data in the result field to be
changed to zero or blank.

When the KEY operation causes a pause in the
calculations, the operator can go to the next calculation
without keying any data for the current calculation. To
do this, the operator simply presses an entry function
key, which causes the data in the result field to be
changed to zeros or blanks. After each KEY operation
(regardless of whether data is entered), the operator
must press an entry function key before the next
operation can be done. See SET (Set) in this chapter
for the special situation that allows the SET and KEY
operations to be combined so an entry function key has
to be pressed only once.

Specifications for a KEY Operation

The following specifications are made for a KEY
operation:

Columns 7-8: Enter any valid control level indicator or
AN/OR. However, leave these columns blank if the KEY
operation is not part of a subroutine or if it is to be
performed only at detail time.

Columns 9-17: Enter any valid conditioning indicators,
including command key indicators if they have been
specified in a SET or SETOF operation. However, leave
these columns blank if the KEY operation is to be
performed on every program cycle.

Columns 18-27: Enter the constant, literal, field name,
or table or array element to be displayed on the display
screen.

Columns 28-30: Enter the operation code KEY.

• The operator presses the Dup key and then an entry
function key, which does not modify the data in the
result field.
Note: The operator can use anyone of the following
four keys as an entry function key: Field Exit, Field-,
Field+, or Enter / Rec Adv. However, if data has been
entered into a numeric field, the Enter / Rec Adv key
cannot be used as an entry function key.

Alphabetized Operation Codes
KEY

10-25

Columns 31-32: Enter the message identification code
(MIC) corresponding to the message in the user
message member file that is to be displayed on the
display screen. This message prompts the operator to
perform a KEY operation. Valid entries are 01 through
99. An entry is required in columns 31 and 32 when
columns 18 through 27 are blank. If no user message
member is specified prior to execution with the
MEMBER statement or if there is no message with the
associated MIC, the system prompt 'nn-MESSAGE
INDICATOR' is displayed, where nn is the contents of
columns 31 and 32. If columns 18 through 27 contain
an entry by which the keying operation is prompted, the
contents of columns 31 and 32 are ignored.

Columns 33-42: Leave these columns blank.

Columns 43-48: Enter the name of the field to be
keyed.

Columns 49-51: Enter the length of the keyed field if
the field specified in columns 43 through 48 is not
defined elsewhere. The maximum length for a numeric
field is 15. The maximum length for an alphameric field
is 40 if the record length is less than or equal to 40, or
is 79 if the record length is greater than 40.

Column 52: Leave this column blank for alphameric
fields. For numeric fields, enter the number of decimal
positions (0 through 9) in the keyed field if that field is
not defined elsewhere.

Using KEY Operations in Subroutines
Sometimes it is necessary to write a program that has
the KEY operations performed at several different points
in the program. Instead of writing these KEY operations
and related SET operations every time they are needed,
you can write them just once in a subroutine. Then, call
the subroutine each time it is needed (see Subroutine
Operations in this chapter for information on specifying
and using subroutines).

User Message Member
The System/34 system support program product lets
you create your own message members, which are
called user message members. These message
members can contain prompts or informational
messages to be displayed during your RPG II program.
For information on creating message members, see
$MGBLD Utility Program in the System Support
Reference Manual. The messages contained in user
message members are displayed when you specify the
halt indicators (H 1 through H9) or the message indicator
option of the SET and KEY operation codes. The
messages displayed must be formatted so MIC numbers
0001 through 0109 are assigned to the specific function
as follows:

MIC

Function

0001-0099

Message to be displayed as
specified by the nn portion
of the SET and KEY operation
codes (SETnn, KEYnn, where
nn = 01 to 99).

0100

Message to be displayed at the
end of an RPG II cycle when the
system is finished processing
outstanding halt indicators.

0101 -0109

Message to be displayed at the
end of an RPG II cycle in which
the system has encountered H 1
through H9 halt indicators
(0101 through 0109 correspond
to H 1 through H9 respectively).

Column 53: Leave this column blank.

Columns 54-59: Use these columns to test the condition
of a numeric field (plus, minus, or zero) or to test an
alphameric field for blanks (columns 58 and 59).
Figure 10-14 shows examples of KEY operations.
The KEY operation is normally used with the SET
operation. See SET (SET) for further information on this
topic.

10-26

Operation Codes

For a message contained in a user message member to
be displayed, the message text must exist in an object
message member. The message member must be
specified in the MEMBER USER1 Del statement, and
the SETnn or KEYnn operation or an H 1 to H9 indicator
must be used in the program. (See MEMBER Statement
in the System Support Reference Manual.)
Note: The specified user message member remains

active until the system processes another MEMBER
statement or the display station session is ended (the
display station operator signs off). If one of the user
message members is active (either USER1 or USER2)
and an execution time error is encountered, you will
receive a user message rather than the appropriate
system message (unless you have copied the system
messages into your user message member). For more
information on how long a user message member
remains active, see MEMBER Statement in the System

Support Reference Manual.

Alphabetized Operation Codes
KEY

10-27

Calculation Specifications

C
r---

Indicators

Arithmetic

Jd Jd'

Operation

Factor 1

c;
z

£
9

0

z

to 1112 13 14 15 16 11 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 .5 46 47 48 49 50 51

4

a

1

C

a

2

C

a

3

C

a

4

C

~Il IS;IL

a

5

C

~Olt

a

6

C

a

7

C

a

8

C

,1\11: 111UlIl

a

9

C

Iklt: llUlIL

1

a

C

1 1

C
C

1 3

c

1 4

C

1 5

C

1 6

c

1 7

C

8

C

1 9

C

a

I

2 4

c
c
c
c
c

2 5

C

2 6

C

2 7

C

2 8

C

2 9

C

2

2 1
2 2
2 3

a

C

3 1

C

3 2

C

3 3
3 4

c
c

3 5

C

3

3 6

C

3 7

C

3 8

C

Length

Name

3

1 2

Plu. IMinu.1 Zero
Compare
1 >211 <211- 2
Lookup(F.ctor 2)i.
High Low EQual

Factor 2

line

5

Resulting
Indicators

Result Field

T~:I:

F~ III

I-I!I:

f"lI&lIT N~ OP~

n I(I~ ITt'
BE 11;~ n
Il

~la\ AN
~Il i\ll= l'

~

A~

n

rlH ~ IF"I I 11:1 TNr..
F~ ~L rl ~E ~Il .. 1~1rl PR '~

IPl U~

lev

~

II

us E~

It lIU~

I

~M IAlt"

~L LO~ TH IE

_!.

.ITH11

\ .1L

r.!11 ~IL ~
~Cd ~12 IF~ ~fI
WI-.VII

E lelP ER ~rr ~"

J: U~ IE~

......

,
s::

~

Ht- ~r..
tor

1"fl.1oI

.. It

l

~1

R,{

1 ~ II

I.,

In ~ I~A \IE

11'rt' ~t=

V-

,5,t!

1~

."

Ir~ l211<211=2
Lookup(Factor 2);,
High Low Equal
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

The prompt KEY HALT TO TERMINATE PROGRAM
is the text issued for the KEY01 operation. This is the
contents of the object member loaded into the user
message member specified by the MEMBER statement.
Subsequently, the USER 0101 message text that is
issued when the literal HALT is keyed is HALT HAS
BEEN ENTERED WITH KEY OP.
The second message issued, USER 0100, has not been defined in the user message member; thus it cannot be retrieved, and the message MESSAGE NOT RETRIEVED
(SEE MSG MANUAL) is issued.

Messages are retrieved from the user-created message member MESG1 specified in the MEMBER statement:
II LOAD USER
II MEMBER USER1-MESG1
II RU!'!
Figure 10-15. Issuing a Message

Alphabetized Operation Codes
KEY

10-29

Special Combinations of the SET and KEY Operations
Normally, the operator must press an entry function key
after each KEY operation or after command keys
specified in a SET operation are pressed. However, it is
possible to combine these operations so that the
operator can press command keys (specified in columns
54 through 59 of a SET operation), key a field (specified
in a KEY operation), and only press an entry function
key once. This is only' possible if:

lOKUP (lOOKUP)
Array lOKUP

7-8

19-17

Factor 1

1I

Factor 2

Field

Oot

loot

Reouired

lReauired

Blank

Indicators

•

Factor 1 for the SET and KEY operations can be the
same, different, or missing from one operation. If
factor 1 is specified for both the SET and KEY
operations, the contents of each factor 1 are
displayed.

If the data field is numeric, the operator must first press
the specified command key, key the field, and then
press the Field Exit, Field +, or Field - key. The
Enter / Rec Adv key is not allowed as an entry function
key for a numeric field. For an alphameric fielc;J, the
operator must perform the same sequence of steps, if
the Field Exit or Field + key is pressed. However, if the
Enter / Rec Adv key is used, the operator can press the
command key and then key the field, or key the field
and then press the command key before pressing the
Enter/Rec Adv key.

,-

Ts8-59

1 reauired

_ Re_su!ti.!l9 Indipa~ors

Result

Oat

• The SET and KEY operations contain the same
message indicators. If factor 1 is used to display
messages, then columns 31 and 32 can be blank to
satisfy this requirement.

Resulting In,dicaJors

~~~'5 ~ - [~6-57

Table lOKUP

The SET operation immediately precedes the KEY
operation.
• The SET end KEY operations are conditioned by the
same indicators (columns 7 through 17). Indicators
for both operations must be specified in the same
order.

Result

loot

Factor 1

Factor 2

Field

Reouired

Reauired

Ootional

i54-55

i 56-57

i58-59

. 1 required

The LOKUP operation causes a search to be made for a
particular element in a table or array. The table or array
is ~amed in factor 2. Factor 1 is the search word (data
for which you want to find a match in the table or array
named). Factor 1, the search word, can be:
• An alphameric or numeric constant
• A field name
• An array element
• A table name
When a table is named in factor 1, it refers to the
element of the table last selected in a LOKUP operation,
not to the whole table.
Resulting indicators are always used with a LOKUP
operation. The indicators first specify the type of search
to be made and then reflect the result of the search.
The specified indicator turns on only if the search is
successful.

(
10-30

Operation Codes

Resulting indicators specify the type of search and
reflect the result of the search in the following manner:
• A resulting indicator assigned to equal (columns 58
and 59) instructs the program to search for an entry
in the. table or array equal to the search word. The
first equal entry found turns on the indicator assigned
to equal.
• An indicator assigned to low (columns 56 and 57)
instructs the program to locate an entry in the table
that is nearest to, yet lower in sequence than, the
search word. The first such entry found turns on the
indicator assigned to low.
• The indicator assigned to high (columns 54 and 55)
instructs the program to find the entry that is nearest
to, yet higher in sequence than, the search word. The
first higher entry found turns on the indicator
assigned to high.
At least one resulting indicator must be assigned, but no
more than two can be used. Resulting indicators can be
assigned to equal and high or to equal and low. The
program searches for an entry that satisfies either
condition with equal given precedence; that is, if no
equal entry is found, the nearest lower or nearest higher
entry is selected. If resulting indicators are assigned
both to high and low, the indicator assigned to low is
ignored.

LOKUP With One Table
When searching a single table, factor 1, factor 2, and at
least one resulting indicator must be specified.
Conditioning indicators (specified in columns 7 through
17) can also be used.
Whenever a table element is found that satisfies the
type of search being made (equal, high, low)' a copy of
that table element is placed in a special storage area.
Every time a search is successful, the newly found table
element is placed in this area, replacing what was there
before. If the search is not successful, no table element
is placed in the storage area. Therefore, the contents of
the area remain the same as before the unsuccessful
search.
Resulting indicators reflect the result of the search. If
the indicator is on, reflecting a successful search, a copy
of the element searched for is in the special storage
area.

LOKUP With Two Tables
When two related tables are used in a search, only one
is actually searched (see Figure 10-16). When the
search condition (high, low, equal) is satisfied, the
corresponding elements. from both tables are placed in
their respective special storage areas and are made
available for use.

When you use the LOKUP operation, remember:
• The search word and each table or array element
must have the same length and the same format
(alphameric or numeric).
• A search can be made for high, low, high and equal,
or low and equal only if the table or array is in
sequence.
• No resulting indicator turns on if the search is not
successful.

Factor 1 must contain the search word and factor 2
must contain the name of the table to be searched. The
result field must name the related table from which data
is also made available for use. A resulting indicator
must also be used. Conditioning indicators can be
specified in columns 7 through 17, if needed.
The two tables used should have the same number of
entries. If the table that is searched contains more
elements than its related table, it is possible to satisfy
the search condition. However, there might not be an
element in the second table that corresponds to the
element found in the search table. Unpredictable results
can occur.

Note: If you specify a table name in an operation other
than LOKUP before a successful LOKUP occurs,
unpredictable results can occur because the contents of
the special storage area referenced by the table name
are unknown.

Alphabetized Operation Codes
LOKUP

10-31

Referencing the Table Element Found in a LOKUP
Operation
Whenever a table name is used in an operation other
than LOKUP, the table name actually refers to the data
placed in the special storage area by the last successful
search. Thus, when you specify the table name in this
fashion, elements from a table can be used in
calculation operations.
If the table is used as factor 1 in a LOKUP operation,
the contents of the special storage area are used as the
search word. In this wayan element from a table can
itself become a search word.
The table can also be used as the result field in
operations other than the LOKUP operation. In this case
the contents of the special storage area are changed by
the calculation specification. The corresponding table
element in the table in main storage is also changed. In
this way the contents of the table can be modified by
calculation operations (see Figure 10-17).
Figure 10-18 shows a sample LOKUP operation for a
table.

Using the LOKUP Operation with Arrays
The LOKUP specifications for arrays are the same as for
tables except that the result field cannot be used. In
addition, if the element searched for is found, it is not
moved to a special storage area because these areas are
used only for tables. The indicators reflect only that the
element is in the array; therefore, the programmer does
not have ready access to this item.
Figure 10-19 shows two LOKUP operations performed
with an array.

10-32

Operation Codes

Starting the Search at a Particular Array Element
To save processing time, start the LOKUP search at a
particular element in the array. This type of search is
indicated by additional entries in columns 33 through 42.
Enter the name of the array to be searched in these
columns followed by a comma and a numeric literal or
by the name of a numeric field (with 0 decimal
positions). The numeric literal or numeric field provides
the number of the element at which the search is to
start (see Figure 10-20). This numeric literal or field is
called the index because it points to a certain element in
the array. All other columns are used as previously
described for the normal lookup operation.

TABEMP

TABPAY

441

243

442

321

443

268

444

272

445

310

446

411

TABPAY

TABEMP

G
Special storage areas
Related tables TABEMP and TABPAY are read into storage. Assume that an input record is read with 443 in the
EMPNUM field. With 443 as the search word, the table
TABEMP can be searched for an equal entry. When the
correct entry is found, the table item 443 is moved into
the special storage area for TABEMP. At the same time,
the corresponding item 268 is moved into the special
storage area for TABPAY. The contents of the storage
areas can now be referenced in subsequent calculation
operations by the appropriate table name. The coding
needed to perform the LOKUP operation also shows
how to reference the contents of the special storage
area after a successful LOKUP operation.

443isthe
search word

Calculation Specifications

C

f------

line

~
1l.~
>-'

EE

5

At At
0

Resulting
Indicators

Arithmetic

Factor 1

Operation

Factor 2

·2

Name

Length

I

~~

Plus IMlnusl Zero
Compare

Comments

1>211<211-2
~ ~
'u - Lookup(Faclor 2)is
Q
High Low Equal

:t:

0

of 8

z

6

9 10 \I 1213 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

4

o

1

c

o

2

C

o

3

C

o

4

C

o

5

o

6

c
c

o

7

C

o

8

C

o

9

C

1 0

C

7

1 2

c~
c~

1 3

C

1 4

c~

1 5

C

1 6

C

--

Result Field

I- "0

3

11

Indicators

~

z

z

(is

69 70 71

n

73 74

~Iq
LO KIU .PT AS E~P
UM
rr~ 8P Art
-...
IA
Ir!
IA'tlI''''
..
..,.
P4p
lA '6£ FOIR ~tJ lEN TIRY h'IH AT Ills IEQ UIAL
T E :uv .. OP ER ~T InN ... IW,I\
PN ulHI. IlF ITIHc ICC RR ElclT t:.N .1 I\IT
c~ N'l eN 1'0 OF It\E .Fl r LD INA
T IIr~re
..
...
... - leN ~NnE,M liHE
I~ It iUiNiU ItJ T~ ~E MP
IIU It N"'"
aR
t.lrt: I 1\ , 1~INl\) 1 TIc;
.....
~ ~:, laT I;n
11'\1 liN TA SP 'A~ 'A'RE t1 '0 \lEn 'l!N T"" liN ""..LII~ '~E PA 'R'A TE :., I

~M ~N

t---

~I

~

1"\

,

MI\oo

1\ 'ill-' IA~

.

1-1-

-

IR .... ~r:

I~N

,

',",,,,,

T 'E
U

5

~

Oft

~u. LIT 1,.,

1

.... 1. . . .

nil

~~IH

AIMIr

rr~E Fl £ LtD I~A MEt)
OP ER Air ION MU:- LIT IP Ll ~~ l',~l£: CIU ~ll lI;N I:!oi ICF
IICb Ni -&::N l:l OF THE ::lr t:~ J.AL "'II
TH'E
M'I •
AIR E~ FoR tr'A IDn''''v
IT~ 0:1= iTlHE LA I~T
AR E~ Fb~ itA epIA.'/. C~ NIT ~l No HE
~I'" SF IU.L
LO :~ulF
III O:'N ,T~ ~t\ IjtJ IIK~ T~ lsp A~,.
AiD 'AI\,I~

n .UIVIIOO
_'It.! 111}- B~ litE
J;'f l~H fc1, O~ A{cIE

.~

"'

.

Figure 10-16. LOKUP Operation for Related Tables

Alphabetized Operation Codes
LOKUP

'10-33

Calculation Specifications

-

C

Indicators

Arithmetic

Operation

Factor 1

At

At

Plus IMinusl Zero

Factor 2
Name

Line

4

Length

z

Z

.. "' ... T
r6 PI a=.t.

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

5

Comments

Compare

1>211<211=2
Lookup(Factor 2)is

'0

0

Z

3

Resulting
Indicators

Result Field

Ln III
MU LT

1"1- I ......

High Low Equal
54 55 56 57 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

1_",

1:11

o

1

C

o

2

c

o

3

eM

..

o

4

e~

BY [1.5

o

5

C

o

6

e

2tA

!A FU

11.5

FOR

IF .. ,c:.I... CH ClI,.

~A

nI ]

I

~

l~

HU LIT 115:L!V

Figure 10-17. Referencing the Table Element Found in LOKUP Operation

Tables A and B are described separately on the extension
specifications and are, therefore, entered separately. Tables
C and D are related tables and are entered in alternating
format on the table input records.

These four tables are used in the LOKUP operations
described in Figure 10-18, Part 2.
First
Entry

Second
Entry

Third
Entry

Fourth
Entry

Fifth
Entry

Table A

01

05

08

32

96

TableB

06.13

02.12

47.16

28.70

15.16

Extension Specifications
Number
of

me

Table C

WWW

NNN

LLL

GGG

AAA

Table D

7

8

3

2

5

Table or
Array Name

Entries
Per
Record

Number
of

Entries
Per Table
or Array

Length
of
Entry

o Cl

~~

ill

Table or
Array Name
(Alternating
Format)

0105

) Source

?

Program.

0832

96

**

06130
21247
16287
01516

h''' IPi • r:16

~

~A I~l Iclp
n"a IQI ,.it'

~

Is:

12 A
ftf 12
~

:1 ,

I"'I~

• I:~

L ___ ' - __ ' -

**

TABLEB
Figure 10-18 (Part 1 of 2). Example of Table LOKUP Operations

10-34

Operation Codes

.~ ~
"

~ll
0..

These tables are in the library.
**

.2 00..

Cl '"

24 25 26 27 28 29 30 31 32 33 34 3536373839 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

The table input records are loaded into the system in this
order at compile time.

(

Length
of
Entry

WWW7

NNN8

LLL3

GGG2

AAA5

/*

------------~--------------TABLEC and TABLED

11

~

Calculation Specifications

C
-

Indicators

Resu It Fie Id

At At

Operation

Factor 1

Plus IMinusl Zero

Factor 2
Length

Name

Line
0

0

Z
Z
Z
9 10 1112 13 I. 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3 2 33 34 35 36 37 38 39 40 41 '2 43 44 45 46 47 48 49 50 51

3

•

5

o

1

C

o

2

C

o

3

C

o

4

C

Resulting

Indicators
Arithmetic

,
\ IG ,,
' :0_

\ 'iJ

,

.. 0 KU pr~
,I(

1111

IIM~ ~ ~A

lO ~KUP 1r~8
1_-ILEA

' If.

I

\ I~
\ I~ 0.

I

I

.1111

,
,

I

1ft.

[rll

1ft.

Irll

o

5

c

o

6

C

o

7

C

o
o

8

C

\~
\ Ir.

9

C

\

1 0

C

11

C

1 2

C

1 3

c

1 4

C

1 5

C

1 6

C

17

C

\

I

ILLI'

'tJ lltr'
'0' crt] ,

2
~

I

Il

I

A

'R

c4

I
IIRI~ Ll=r
I nIII II IrA~ II 1:"

,. II U..

,,
~

iTA~ l
I~ II JAIA ~

••

CA
I::~

s:r

s: "

u~!B LIE

54 55 5651 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

~12

TA lU I=B

al3

Ql'l

as

~!6 Q,1
~18

~q

Til IRII
TA IAII

J:~
&:t'

1'A P~\ c:~

1" lilS;

TA R~

~'11

11

1a1

111

iill 1ll
11~

:"'I

leU Ilir AR i=i"I

Specifications above are shown for 15 different LOKUP
operations for tables A, B, C, and D. Indicators specified
in columns 54 through 59 determine the type of search
to be made.

Comments

Q!l1

II ~4
II S:A

1&

, p.11 r:AI=A

OIrIU

TA ;AII
TA IAII

E:A

M

1111
iA

,

\ I 1J'1l '

L~A

Compare

1>211<211- 2
Lookup(Faclor 21is
High Low Equal

1S
1~

Results of the LOKUP operations (in the following table)
show whether the element searched for was found, what
indicator is on to indicate a successful search, and what
item was taken from a related table when one was used.

Specification Entry
Line Number Found

Indicator
On

Table Item
Satisfying
Search
Condition

Table Item
Used From
Related
Table

Alphabetized Operation Codes
LOKUP

10-35

Extension Specifications

E

Record Sequence of the Chaining File
Number

-

Number of the Chaining Field
To Filenar1e

Line

Table or
Array

Na~e

From Filename

3 4

5

o
o

2

o

3

6 7 8

of
Entries
Per
Record

Number

of
Entries
Per Table

Length
of
Entry

or Array

Table or
Array Name
(Alternating
Format)

00

~~

ill

Length
of
Entry

Comments
0:

~

9 10 11 12 13 t4 15 16 17 18 t9 20 2t 22 23 24 2526 27 28 29 30 31 32 3334 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6566 67 6869 70 71 72 73 74

14aIOIC·II~

1

-~

1. . 1.

11aZj~~

I~

~IA

MANNOS, a 2100-element array of employee numbers, is
read in at execution time from the file ARRFILE with ten
6-position elements per record; the array elements are in
ascending order.

Calculation Specifications

-

C

Indicators

At At
Line

Arithmetic

Factor

1

~actor

Operation

&
o

1

C

o

2

C

o

3

C

o

4

C

o

5

o 6

c
c

o

Name

b

b

z

z

Length

b

z

.

9 10 11 12 13 14 t5 t6 17 18 t9 20 21 22 23 24 25 26 27 2829 30 31

2~

1110 ID.=J L'..,

L

GQ TO

N20

33 34 35 36 37 38 39 40 4t 42 43 44 45 46 47 4B 49 50 51
1-

I~E ~rr

.. AD [11

,

~O

7

C

c

o 9

C

1 0

c

11

C

1\

1

2

C

V

1 3

c

I)

1 4

C

I'

NE ~T

~2

..
eo 'to END
~

11 " WJ~ i~b

o 8

"E

() ~n IINX

1...", ~ ,I.., A,.

lAG
,
D

Figure 10-19. LOKUP Operation for an Array

Operation Codes

I

I.
,

~rl1

lNlle
"..1.

,.

Plus IMinusl Zero
Comments
Compare
1>211 <211 =2
LookuplFactor 2Hs
High Low Equal
54 55 56 57 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

2~

2r6

I'~

I

Calculation
operations

The first calculation specification is a LOKUP of array
MANNOS to find the element nearest to, but higher in
sequence than, the search word 100336. If this element is
found in the array, indicator 20 turns on and the GOTO
in line 02 is performed. Indicator 20 indicates only whether
or not the searched for element exists in the array.

10-36

2

t-

3 4 5 6

Resulting
Indicators

Result Field

The specification on line 05 shows essentially the same
LOKUP operation. Indicator 20 turns on when the first
element higher in sequence than 100336 is found. However, in this LOKUP operation, the array MANNOS is
indexed by the field INX. This index field was set to
1 in line 04, so the LOKUP begins at the first element
of MANNOS. If the searched for element is found, the
number of this element (not its contents) IS placed in
the field INX. In this way, the actual element that
satisfied the LOKUP can be used in subsequent calculation operations, as in line 07. If no element was
found to satisfy the LOKUP, the field INX is reset
to 1.

Calculation Specifications

c

~

Factor 1

Operation

Plus IMinusl Zero

Factor 2
Name

o

Z

0

Z

Length

Z

9 10 II 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2B 29 30 31 32 33 J4 35 J6 37 JB J9 40 41 42 43 44 45 46 47 48 49 50 51

5

0 1

C

0 2

C

0 3

C

Resulting

Indicators
Arithmetic

~

8
4

Result Field

]

line

3

Indicators

~

f-

The index provides the number of the element at which
the search is to start.

Compare

Comments

1>211<211-2
LookuplFaclor 21is
High Low Equal
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

An array name plus comma and index that is 10 characters
long can be referenced in factor 1 or factor 2 of the
calculation specifications only. For all other references, the
length is limited to 6 characters.

Figure 10-20. Array Lookup: Starting at a Particular Array Item

The search starts. at the specified element and continues
until the searched-for element is found or until the end
of the array is reached. When a field is specified for the
index, an unsucc~ssful search causes that field to
contain the value of 1. If, however, an element is found
that satisfies the conditions of the LOKUP operation, the
number of that array element (counting from the first
element) is placed in the index field. The index field can
then be used to reference that array element so it can ,
be used in subsequent calculation operations (see Figure
10-19). However, a numeric literal used as an index is
not changed to reflect the result of the search.
Note: If a literal or field index for an array is zero or
greater than the number of elements in the array, the
following occurs:
For a literal index, a severe error occurs and
compilation ceases.
• For a field index, the job halts, allowing'the operator
to cancel or continue the program. If the program is
continued, the· field index is reset to 1.

Alphabetized Operation Codes
LOKUP

10-37

MHHZO (MOVE HIGH TO HIGH ZONE)
Indicators

Functions of the four move zone operations are shown
in Figure 10-21.

Resulting Indicators

Result

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

Oot

lOot

Blank

Required

Required

Blank

IBlank

IBlank

Alphameric

I
.~I_IL-'--L-L...J~L-'--LI_IL..JI
I

Factor 2

MLHZO

MHHZO

The MHHZO operation moves the zone from the
leftmost position of factor 2 to the leftmost position of
the result field. Factor 2 and the result field must be
alphameric.

1

Alphameric
Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

Oot

lOot

Blank

Required

Required

Blank

IBlank

IBlank

, Alphameric

The M H LZO operation moves the zone from the
leftmost position of factor 2 to the rightmost position of
the result'field. Factor 2 must be alphameric. The result
field can be alphameric or numeric.

Result

Resulting Indicators

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

Oot

lOot

Blank

Required

Required

Blank

I Blank

I Blank

The MLHZO operation moves the zone from the
rightmost position of factor 2 to the leftmost position of
the result field. Factor 2 caQ pe numeric or alphameric,
but the result field must be alphameric.

MLLZO (MOVE LOW TO LOW ZONE)
(

Indicators

19-17

Oot

lOot

Result

Resulting Indicators

Factor 1

Factor 2

Field

54-55

156-57

158-59

Blank

Required

Reauired

Blank

IBlank

I Blank

The M LLZO operation moves the zone from the
rightmost position of factor 2 to the rightmost position
of the result field. Factor 2 and the result field can be
either alphameric or numeric.

10-38

Operation Codes

.

I I I I I I I I I I I Result Field

I I I I I I I I I I I Factor 2

Numeric

I I I ~HI~ I I I I I Result Field

Numeric

L-,,--,,--,,--,--,--,--,,--.a..I-.a..I....I1 Factor 2

!

1

7-8

7-8

I I I I I I I I I I I Factor 2

1 ~MLLZO

MLHZO (MOVE LOW TO HIGH ZONE)
Indicators

MLLZO

t

~
~.I . I . It MLLZO

MHLZO (MOVE HIGH TO LOW ZONE)
Result

MHLZO

Alphameric LI...L1--L.....I-.L1...J1L.....I.1--L1..L...L...I ResUlt Field

Numjeric

IndicatorS

.J

Numeric

MLLZO

I I I I I I I I II IResult Field

Figure 10-21. Functions of Move Zone Operations

MOVE (MOVE)
Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

Oot

lOot

Blank

Required

Required

Blank

IBlank

IBlank

The MOVE operation transfers characters from factor 2
to the rightmost positions in the result field. Moving
starts with the rightmost character of factor 2.
If factor 2 is longer than the result field, the excess
leftmost characters of factor 2 are not moved. If the
result field is longer than factor 2, the excess leftmost
characters in the result field are unchanged.
The MOVE operation is summarized in Figure 10-22.

Factor 2 Shorter Than Result Field
Factor 2
a. Alphameric

b. Alphameric

c. Numeric

d. Numeric

Result Field

IP,H,4,S,N,

Before MOVE

+
1 1 I 2 , 3 , 4, 5 , 6 , 7 I 8 I 4,1

IP I H,4,S,N I

After MOVE

I 1,2,3,4IP,H~4,SIN,

IP,H,4,S,N,

Before MOVE

+
111213,415,6,71814,

IP,H,4,S,N,

After MOVE

11,2,314,7 ,8 ,4, 2 ,5 ,

,1,2,7,8,4 2 5,

Before MOVE

11 1 2 ,3,41 5 ,6,7,8,9,

11 12 ,7,8,4 2 51

After MOVE

,1,2,1,2,7,8,4,2,5,

,1,2,7,8,4 2 5,

Before MOVE

,A,C I F,G,P,H,4,SINI

11 12 ,7 18,4 2 5,

After MOVE

1A, C I 11 2,7 18,4 I 2 I 5 1

Alphameric

Numeric

Numeric

Alphameric

Factor 2 Longer Than Result Field
Factor 2
a. Alphameric

b. Alphameric

c. Numeric

d. Numeric

Result Field

,A,C,E,G,P,H,4,S,N,

Before MOVE

15 ,6,7,8,41

IA,C,E,G,P,H I 4 I S I N,

After MOVE

,P,H I 4,SI N ,

,A,C,E,G,P,H,4,S,N,

Before MOVE

,AIC,EIG,P,H,4ISINI

After MOVE

1 5 ,6,7,8,4,
1 7 ,8,4,2 15,

,1,2,7,8,4,2,5,

Before MOVE

1 5 ,6 1 7,4 18,

,1,2,7,8,4,2,5 1

After MOVE

17 ,8,4,2,51

,1,2,7,8,4,2,5,

Before MOVE

I P ,H,4,S,N 1

,1,2,7,8,4,2,5,

After MOVE

,7 1 8 14,2,51

Alphameric

+

Numeric

Numeric

Alphameric

Factor 2 and Result Field Same Length
Result Field

Factor 2
a. Alphameric

b. Alphameric

c. Numeric

d. Numeric

+

4

,P,H,4,S,N,

Before MOVE

15 ,6,7,8,4 1

IP ,H, 4, S , N I

After MOVE

I

IP ,H,4, S, N,

Before MOVE

15 ,6,7,81 4 ,

,P,H,4,S,N,

After MOVE

,7,8,4,2,5,

17 ,8,4,2,5,

Before MOVE

I A ,L,T,5,F,

,7,8,4,2,51

After MOVE

17 ,8,4,2,5,

,7,8,4,2 1 5 1

Before MOVE

I A ,l,T,5,F,

,7,8,4,2,5,

After MOVE

17 1 8 ,4,2,N 1

P ,H,4,S,N 1

Alphameric

Numeric

Numeric

Alphameric

= letter D

5 = letter N
figure 10-2.2.. iviOVE Operations

A'phabetized Operation Codes
MHHZO-MOVE

10-39

MOVEA (MOVE ARRAY)
Indicators

7-S

19-17

ODt

TODt

The MOVEA operation makes it possible to:
Resulting Indicators

Result
Factor 1

Factor 2

Field

54-55

156-57

15s.59

Blank

Reauired

Reauired

Blank

IBlank

IBlank

• Move several contiguous array elements to a single
field.
• Move a single field to several contiguous array
elements.

The MOVEA operation transfers characters from the
leftmost positions of factor 2 to the leftmost positions
of the result field. Factor 2 and the result field cannot
reference the same array even if the array is indexed.
All arrays and fields referenced by a MOVEA operation
must be alphameric.
The length of the move is determined by the shorter of
the lengths of factor 2 and the result field. If factor 2 is
longer than the result field, the excess rightmost
characters of factor 2 are not moved; if the result field
is longer than factor 2, the rightmost characters in the
result field are unchanged.

• Move contiguous elements of one array to contiguous
elements of another array.
Movement of data starts with the first element of an
array if the array is not indexed or with the element
referenced if the array is indexed. The movement of
data is terminated when the last array element is moved
or filled or when the number of characters moved equals
the length of the shorter field specified by factor 2 and
the result field; therefore, the move could terminate in
the middle of an array element.
If MOVEA is specified with a figurative constant and an
array, the constant fills the entire array. If MOVEA is
specified with a figurative constant and an array
element, the array is filled with the figurative constant
from the referenced element to the end of the array.
Figure 10-23 illustrates the use of the MOVEA
operation.

Calculation Specifications
Example: Array-to-array move.
No indexing; different length
arrays, same element length.

Resliit Field

Operation

0

Factor 2

";;;

Name

Length

0

~

E

.~

0
26 21 28 29 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

~Ir

~lR IRIY

,.111 1.1 .... InlY

ARRY

ARRX

" 11 , 213,415,617,819,01

>

'-v-'

Before
MOVEA

One element

,-A-...

11,213,415,617,819,01

After
" MOVEA

IA,AIBIBlc,clD,DIE,EIFIFI

>

'-v-'

One element

,-A-...

11,213,415,617,819,olF,FI

~----------------------------~."
Figure 10-23 (Part 1 of 3). MOVEA Operation

10-40

Operation Codes

Calculation Specifications
Example: Array-to-array move.
Index result field.

Result Field
Operation

Factor 2
Name

Leng

Calculation Specifications
Example: Array-to-array move.
No indexing, different length
array elements.

ARRY

Result Field
Operation

Factor 2
Name

Leng

ARRZ

3 415 617 819 01
1121
<=v='

Before
MOVEA

IA

11 21

After
MOVEA

1~\g::~617 8 gL9

~. One element
3

4J~8Igj

I

A A B B BI

c c

CIO o

0

~One element
0 0/

Calculation Specifications
Example: Array-to-array move.
Index factor 2, different length
array elements.

Resu It Field

Operation

Factor 2
Name

Leng

Figure 10-23 (Part 2 of 3). MOVEA Operation

Alphabetized Operation Codes
MOVEA

10-41

Calculation Sp"ecifications
Example: Field-to-array move.
No indexing on array.

Result Field
Operation

Factor 2
Leng

Name

-

... IVt:.

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

~l

1 . . 1. .

~Ir

lIE L"IA

AR Rri

ARRY

FIELDA
Before
MOVEA

112345671

19 8 615 4 312 lolA B cl
'-v---'

">

~

After
MOVEA

11 2 3 4 5 6 71

One element
0 I ABC I

11 2 314 5 617

~-------------'~~-~~~
Calculation Specifications
Example: Array-to-field move.
Variable indexing.

Result Field
Operation

Factor 2
Leng

Name

....

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

~'" ~It:'

I

a •

I.

IN

s:t S::=l "
N=3

FIELD

ARRX
lo,1/o,Alo,2I o ,BIOj3/o,cl
"--.,.-..-

Before
MOVEA

1

0 , 1 10 , A 1

~ One element

....-"-..

10 , 11o,AIO,210IB10,3101CI
~

~~~EA

10 ,21 0 , BI
~

\'------~/

Figure 10-23 (Part 3 of 3). MOVEA Operation

10-42

Operation Codes

MOVEL (MOVE LEFT)
Indicators

Result

2.

Factor 2 is longer than the result field:
a. If factor 2 and the result field are numeric, the
sign from the rightmost position of factor 2 is
moved into the rightmost position of the result
field.
b. If factor 2 is numeric and the result field is
alphameric, the result field contains only
numeric characters.
c. If factor 2 is alphameric and the result field is
numeric, a minus zone is moved into the
rightmost position of the result field if the zone
from the rightmost position of factor 2 is a D
(minus zone). However, if the zone from the
rightmost position of factor 2 is not a D, a
positive zone is moved into the rightmost
position of the result field. Other result field
positions contain only numeric characters.
d. If factor 2 and the result field are alphameric,
only the number of characters needed to fill the
result field are moved.

3.

Factor 2 is shorter than the result field:
a. If factor 2 is either numeric or alphameric and
the result field is numeric, the digit portion of
factor 2 replaces the contents of the leftmost
positions of the result field. The sign in the
rightmost position of the result field is not
changed.
b. If factor 2 is either numeric or alphameric and
the result field is alphameric, the characters in
factor 2 replace the equivalent number of
leftmost positions in the result field. No change
is made in the zone of the rightmost position of
the result field.

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

OPt

IOpt

Blank

Required

Required

Blank

IBlank

IBlank

The MOVEL operation transfers characters from factor 2
to the leftmost positions in the result field. Moving
begins with the leftmost character in factor 2.
When a numeric field is moved into an alphameric field,
both digit and zone portions of the rightmost character
are transferred if that character is to be moved.
A summary of the rules for MOVEL operations for three
conditions based on field lengths is as follows:

1.

Factor 2 is the same length as the result field:
a. If faCtor 2 and the result field are numeric, the
sign is moved with the rightmost position.
b. If factor 2 is numeric and the result field is
alphameric, the sign is moved with the
rightmost position.
c. If factor 2 is alphameric and the result field is
numeric, a minus zone is moved into the
rightmost position of the result field if the zone
from the rightmost position of factor 2 is a D
(minus zone). However, if the zone from the
rightmost position of factor 2 is not a D, a
positive zone is moved into the rightmost
position of the result field. Digit portions are
converted to their corresponding numeric
characters.
d. If factor 2 and the result field are alphameric, all
characters are moved.

The MOVEL operation is summarized in Figure 10-24.

Alphabetized Operation Codes·
MOVEL

10-43

Factor 2 and Result Field Same Length
Factor 2

a. Numeric

b. Numeric

c. Alphameric

d. Alphameric

Result Field

t

-

t

-

1 7 1 8 1 4 ,2.51

Before MOVEL

f
+
,5 1 6 1 7 ,8,4,

,7 1 8 1 4,21 5 ,

After MOVEL

,71 8 1 4 12,5,

,7 1 8 +
1 4 1 2 1 5,

Before MOVEL

,AI KI T,4 1 0,

,7 1 8t 4 1 2,5 ,(5=letter N)

After MOVEL

,P I H I 4,SI N •

Before MOVEL

.P 1 H,4 I S I N I

After MOVEL

1 7 18 1 4 ,2,5,

, P I HI 4, S 1 NI

Before MOVEL

, A, KI T,4 10,

I P ,H I 4 I S,N 1

After MOVEL

I P I H ,4I S ,N I

Numeric

Alphameric

, ,7,8 1 4,2 I N I
+
, 5 I 6 I 7'1 8 I 4 ,

Numeric

Alphameric

Factor 2 Longer Than Result Field
Result Field

Factor 2
a. Numeric

b. Numeric

c. Alphameric

d. Alphameric

,°1°1°,°1°181412151

Before MOVEL

,5t617,8'~1

,0,0,°1°1°1 8 ,4,2,5,

After MOVEL

1°,0,°1°,° 1

,9, ° 1311 ,7 18 14 ,2,51

Before MOVEL

I 9 1° I 3 I 1 I 7, 8 14 , 2 1 5 1

After MOVEL

,AIKIT,4 I 0 1
,9 1°,3,1 17,

Before MOVEL

15 16 1 7 ,8t:1

,BIRIWICIX,H,4ISINI

After MOVEL

,2 19 1 6 13 t7,

IB,R 1W,C,X 1H,4 I S,N,
I B ,R I W,C,X 1H I 4,S,N,

Before MOVEL

,AIK,TI4 I O,

After MOVEL

,BIRIWIC,X I

I

B I R ,W,C,X,H,4,S,N,

,

Numeric

Alphameric

Numeric

Alphameric

Factor 2 Shorter Than Result Field
Factor 2
(NumeriC
a. 'I

Alphameric

(NumeriC
b.,'

1f\.1 phameric

Result Field

,7,8,4,2 1 5,

Before MOVEL

1t310,9,413.2,11~ I

,7 18,4.2.5 1

After MOVEL ,

,7.8.4.2.5.3,2.1.° 1

,C,P,T I 5 I N,

Before MOVEL

,1 13 1°.9.4,3.2,1,0 ,

,C,P,T.5 I N,

After MOVEL

,3,7 1 3 15,5 13,2,1.0 I

,7 18.4 1 2,5,

Before MOVEL

,B,R.W,C.X,H,4,SIA,

,7,8,4,2,5,

After MOVEL

,7181412.N.H,4.SIA,

lC,P.T,5,N,

Before MOVEL

,B,RIW,C,XIH,4.S.A,

,C,P,T,5,N,

After MOVEL

IC,P,T,5,N,H,4,S.A 1

-

The arrow
Figure 10-24. MOVEL Operations

10-44

Operation Codes

t

t

between numbers indicates a decimal point.

+

Numeric

Numeric

Alphameric

Alphameric

MULT (MULTIPLV)

MVR (MOVE REMAINDER)

Indicators

Resulting Indicators

Result

7-8

19-17

Factor 1

Factor 2

Field

54-55

Opt

IOpt

Optional

Required

Required

Optional IOptional IOptiona,

156-57

158-59

Factor 1 is multiplied by factor 2, and the product is
placed in the result field. Factor 1 and factor 2 are not
changed. If factor 1 is not present, the result field is
multiplied by factor 2, and the product is placed in the
result field.

Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

OPt

IOpt

Blank

Blank

Required

Optiona,IOptiona,IOptiona,

156-57

158-59

The MVR operation moves the remainder from the
previous divide operation to a separate field named as
the result field. Factor 1 and factor 2 must not be used.
This operation must immediately follow the divide
operation.

\

Be sure that the result field is large enough to hold the
product. To determine the'minimum length of the result
field, use this rule: the length of the result field equals
the length of factor 1 plus the length of factor 2.

The maximum length of the remainder (including decimal
positions) is 15. The number of significant decimal
positions is the greater of:
• The number of decimal positions in factor 1 of the
previous divide operation.
• The sum of the decimal positions in factor 2 and the
result field of the previous divide operation.
The maximum whole number positions in the remainder
is equal to the whole number positions in factor 2 of the
previous divide operation. Figure 10-25 shows the
specification for a move remainder operation.

Calculation Specifications
Resulting
Indicators

Result Field

Indicators

C
r---

At Jd

Arithmetic

'.,
0

Factor 1

Operation

Factor 2

';;;

Name

Line

Length

0

~

E

.~

0

0

0
Z
Z
Z
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 36 39 40 41 42 43 44 45 46 47 48 49 50 51 52

3

4

o
o

1

5

C

rlill ~Il!l'

2

c

11'. IklWI?

o

3

C

1=1 r:l l'lA

blV

MV R'

1=1 lJ;l nR

1_-

SA VI~
;:)1

IKI-

Plus IMinusl Zero
Compare
1>211<211-2
Lookup(Factor 2)is
High Low Equal

Comments

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

"m
~e

Figure 10-25. Move Remainder Operation

Alphabetized Operation Codes
MULT:""MVR

10-45

NEXT (NEXT)

POST (POST)

Indicators

Result

7-8

19-17

Factor 1

Factor 2

Field

Opt

IOpt

Reauired

Reauired

Blank

Resulting Indicators

156-57

158-59

7-8

Blank

IOptional I Blank

Opt

The NEXT operation code forces the next input to the
program to come from the device specified in factor 1.
If N EXT is specified more than once between input
operations, only the last operation is executed. The
NEXT operation code can be used only for a WORKSTN
file.
Note: For WORKSTN files, a device can be either a
display station or an SSP-ICF session.
To use this operation, enter NEXT in columns 28
through 32. In factor 1, enter the name of a 2-character
field that contains the device identification or a
2-character alphameric literal that is the device
identification. In factor 2, enter the name of the
WORKSTN' file for which the operation is requested.
An. indicator can be specified in columns 56 and 57.
This indicator is set on if an exception/error occurs on
the NEXT operation. If the INFSR subroutine is
specified and columns 56 and 57 do not contain an
indicator, the subroutine automatically receives control
when an exception/error occurs. (For more information
on the INFSR subroutine, see WORKSTN Exception/Error
Handling in Chapter 13.) If the INFSR subroutine is not
specified and columns 56 and 57 do not contain an
indicator, the program halts when an exception/error
occurs.
For more information on the N EXT operation code, see
Chapter 13, WORKSTN File Considerations and Sample
Programs.

10-46

Operation Codes

Indicators

54-55

Result

19-17

Factor 1

IOpt

Required

Resulting Indicators

Factor 2

Field

54-55

156-57

Blank

Required

Blank

IOptionallBlank

158-59

The POST operation allows the programmer to retrieve
status information for a specified display station that is
attached to a WORKSTN file. The status information
(for the POST operation, the display screen size-960 or
1920 characters) is placed in the IN FDS data structure
that was specified in the result field. The program must
contain the INFDS data structure for the WORKSTN file
to use POST.
Factor 1 must contain a variable or an alphameric literal
that identifies the display station whose status is being
requested. The result field contains the name of the
INFDS data structure in which this information is to be
posted. Columns 56 and 57 can specify an indicator
that is set on if an error occurs on the POST operation.
An error occurs if the specified work station I D is not
attached to the file for which the INFDS data structure
is specified.
If columns 56 and 57 do not specify an indicator but the
program contains the INFSR subroutine, the subroutine
automatically receives control when an error occurs. If
the INFSR subroutine is not present and columns 56
and 57 do not contain an indicator, the program halts
when an exception/error occurs. The display station
must be attached to the WORKSTN file. If it is not
attached, the device will be not found and an error will
occur on POST. (For more information on the INFSR
subroutine, see WORKSTN Exception/Error Handling in
Chapter 13.)
Columns 33 through 42, 49 through 55, and 58 and 59
must be blank for a POST operation.

READ (READ A RECORD)
Indicators
7·8

19-17

Oot

loot

The following files can appear as factor 2 in a READ
operation:
Result

Resulting Indicators

Factor 1

Factor 2

Field

54-55

156-57

Blank

Reauired

Blank

Blank

10ptionaiioptionai

158-59

The READ operation calls for immediate input from a
demand file during the calculation phase of the program
cycle. This operation differs from the FORCE operation
because FORCE calls for certain input on the next
program cycle, not the present one.
The operation code READ must appear in columns 28
through 32. Factor 2 contains the name of the file from
which a record should be read immediately. An indicator
can be used in columns 58 and 59. This indicator turns
on when an end-of-file condition is reached for the
demand file or for each READ operation after an
end-of-file condition is reached. If columns 58 and 59
are blank, a halt occurs on an end-of-file condition and
on subsequent READ operations after the end-of-file
condition is reached. Indicators can be specified in
columns 7 through 17.
An indicator can be specified in columns 56 and 57 if
the READ operation is issued to a WORKSTN file. This
indicator is set on if an exception condition occurs (that
is, the operator pressed one of the function control
keys: Roll Up, Roll Down, Clear, Print, Record
Backspace, or Help) or if an input error occurs. If
columns 56 and 57 do not contain an indicator and
either of these conditions occurs, the program halts
unless the INFSR subroutine is specified. If the INFSR
subroutine is specified, the subroutine automatically
receives control and an exception/error occurs. (For
more information on the INFSR subroutine, see
WORKSTN Exception/Error Handling in Chapter 13.)
The following columns must remain blank for a READ
operation: columns 18 through 27 (factor 1), columns
43 through 48 (result field), columns 49 through 51 (field
length), column 52 (decimal positions), column 53 (half
adjust), and columns 54 and 55 (resulting indicators).

• Sequential disk files processed consecutively and
specified as input or update files.
• Indexed disk files processed sequentially by key and
specified as input or update files.
• Indexed disk files processed sequentially by limits
and specified as input or update files.
• Direct files processed consecutively as input or
update files.
• WORKSTN files.
• SPECIAL files.

REL (RELEASE)
Indicators

Result

Resultina Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

Opt

10pt

Reauired

Reauired

Blank

Blank

100tionai Blank

158-59

I

The REL operation releases the device specified in factor
1 from the program. Either a requesting or
nonrequesting device can be released with the REL
operation code. The specified device is released when
the REL operation is encountered during the calculations
unless the device is the requestor of a single requestor
program. If the device specified in factor 1 is the
requestor of a single requestor program, the device is
released at end of job, not when the operation code is
encountered in the calculations. (If the device is a
display station, it is no longer available to the program,
but it is available for system log messages.)
If an exception/error occurs on the attempt to release
the device, the indicator specified in columns 56 and 57
is set on. If no indicator is specified, the program halts
unless the INFSR subroutine is specified in the program.
If the INFSR subroutine is specified, the INFSR
subroutine automatically receives control when an
exception / error occurs and no indicator is specified in
columns 56 and 57.

Alphabetized Operation Codes
REAO-REL

10-47

When all devices are released from a primary
WORKSTN file, the file goes to end of file and RPG "
sets on the LR indicator. If the program containing the
primary file is an NEP, the system operator must enter
the STOP SYSTEM command before the WORKSTN file
will go to end of file.

RLABL (RPG II LABEL)

When all device are released from a demand WORKSTN
file and the program is not an NEP, the first READ
operation after the last REL operation causes the READ
end-of-file indicator to be set on (columns 58 and 59).
The programmer can then set on the LR indicator unless
the LR indicator was specified as the end-of-file
indicator:. If the program containing the demand
WORKSTN file is an NEP, the end-of-file indicator is
set on when the system operator enters the STOP
SYSTEM command. The programmer. can then set on
the LR indicator unless the LR indicator was specified as
the end-of-file indicator.

The RLABL operation allows the subroutine specified in
an EXIT operation to reference a field, data structure,
table, array, or indicator defined in the RPG " program.
RLABL operations must be specified immediately after
the EXIT operation that refers to the subroutine using
the field, data structure, table, array, or indicator in the
RLABL specification (see Figure 10-26). All external
subroutines become part of the root segment and are
not to be put into overlays.

If RESTORE-NO is specified on the WORKSTN OCL
statement, a display format from the program may
appear on the screen after the display station has been
released. If RESTORE-YES is specified on the
WORKSTN OCL statement, the COMMAND display
appears on the screen immediately when the display
station is released;
For more information on the ACO and REL operation
codes, see Chapter 13, WORKSTN File Considerations
and Sample Programs.

Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

Blank

JBlank

Blank

Blank

Reauired

Blank

iBlank

IBlank

The rules for use of RLABL on the calculation
specifications are as follows:
Columns

Entry

Operation
(28-32)

RLABL

Result field
43-48

Field, data structure, table,
or array name, or indicator
(I Nxx, where xx is the indicator)

Field length
(49-51)

Length of field (optional)

Decimal
positions (52)

Decimal indication (optional)

Only RLABL operations specifying a field, table, or array
name can have entries for field length (columns 49
through 51) and decimal positions (column 52).
The following columns must be blank for an RLABL
operation: columns 7 and 8 (control leve!), columns 9
through 17 (indicators), columns 18 through 27 (factor
1), columns 33 through 42 (factor 2)' column 53 (half
adjust), and columns 54 through 59 (resulting indicators).
A name defined by a TAG, BEGSR, or ENDSR
specification cannot be used in an RLABL specification.

10-48

Operation Codes

Calculation Specifications

C

Indicators

I---

At At

Factor 1

Operation

Plus IM,nusl Zero

Factor 2

4

5

o
o

1

e

2

e

o

3

o
o

4

5

eM
e~
e

o

6

e

o
o
o

8

7

9

1 0
11
1 2
1 3
1 4
1 5
1 6

0

Z

Length

0

1 >211 <211-2
LookuplFaclor 21is

Hi9~1 LOw 1Equal

Z

9 10 1112 1314 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 3031 32 33 34 35 36 37 38 39 40 41 42 434445'4647 48 49 5051

3

lI;;D( IIiI"

~II

I,
IRL Aiel

E:~

.

54 55 56 577 58 59 60 61 62 63 64 65 66 67 68 69 70 71

I I I I I I II I I I I I I I

IA

IRL ~81l

e~
elK
e
e

Comments

Compare

Name
0

Indicators

Arithmetic

Line
Z

Resulting

Result Field

I

~Iu leR ~~

l;)( liT 5U BR ~~
RL AIRl

rr~ lelLtE

, If lIt. LD

12

~Table

name or array name

I II II I I I I
II I I I
I II II I I I I

n

73 74

r-t- t-tr-r- t-t-

I

,I

~ --Field name
IIIIIII

IIIII

I I I II

lIN X~

I I
--Indicator

I

I I I I I II

eM
e~
e
e
e
e

~l>C lit
I~L ~8l

IIIII

I II I I I I
S~ \JE

-Data structure
I I I I I I I I I

II

I

II" I

Figure 10-26. RPG II Coding for RLABL Field Entries

Referencing an Indicator

Referencing a Field

When an indicator is specified in an RLABL operation,
use the form I Nxx as the result field, where xx is the
indicator to be transferred to the subroutine. For
example, if the MR indicator is to be transferred to a
subroutine, specify INMR as the result field for the
RLABL operation.

When a field name is specified in the RLABL operation,
the RPG II compiler generates the following parameters
and passes them to the assembler subroutine:

When an indicator is specified in the RLABL operation,
the RPG II compiler generates the following parameters
and passes them to the assembler subroutine:

B

SUBRxx

DC

IL 1 'Field length-1'

DC

AL2 (right address of field)

B

SUBRxx

Referencing a Data Structure

DC

XL1 '00'

DC

XL 1 ' Mask for the indicator'

When a data structure is specified in the RLABL
operation, the RPG II compiler generates the following
parameters and passes them to the assembler
subroutine:

DC

XL 1 ' Displacement to the indicator from
XR1'

B

SUBRxx

DC

XL3 ' FFFFFF

DC

IL2 'Data structure length-1'

DC

AL2 (leftmost address of data structure)

Alphabetized Operation Codes

RLABL

10-49

Referencing a Table or Array

The subroutine can refer to a table or array defined in
the RPG II program by using the control field created for
that table or array. This control field is called the I;JTT
(define the table), and one is created for each table or
array built by the RPG II program. The control field is in
the following format:
Bytes

Meaning

0-1

Address of rightmost byte of the
first entry

2-3

Address of rightmost byte of the
last entry

4-5

Initialized to the address of the
rightmost byte of first entry;
used at object time for address of right
byte of the last looked-up entry

6- 7

Length of an entry

8-13

Array name (arrays only)

10-50

Operation Codes

The subroutine can obtain the data retrieved from the
preceding LOKUP operation by using the address in
bytes 4 and 5. To access the table or array itself, the
address in bytes 0 and 1 must be used. Data the
subroutine uses is left unpacked.
When a table or array is specified in the RLABL
operation, the RPG II compiler generates the following
parameters and passes them to the assembler
subroutine:

B

SUBRxx

DC

I L1 ' Entry length -1 '

DC

AL2 (leftmost address of the DTT)

See Figures 10-27 and 10-28 for examples of RPG II
linkage specifications.

Calculation Specifications

C

Indicators

f---

At At

Factor 1

Operation

Plus IMonusl Zero

Factor 2
Name

0

Z

4

Z

Indicators

Arithmetic

Line

3

Resulting

Result Field

Length

o

1

C

o

2

C

o

3

C

o

4

C

o

5

C

Comments

Lookup(Factor 2Hs

0

z

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 2829 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 5051

5

Compare

1 >211 <211-2

\~ I

E~ tltf ~Il :",1... '"
IR!1 l4IP.II
~C blMlp I~E RI:

IHE RE

-

High Low Equal
54 55 5657 58 59 60 61 62 63 64 65 66 61 68 69 10 11 12 13 14

Ii
t11~ bl'l ~1

Control passed to the assembler subroutine SUBRA by
RPG II.
SUBRA

'- Assembler subroutine references the field HERE in the
RPG II program and returns control to the RPG II
program.

L...-.-

Control is returned to RPG II by the assembler subroutine and a com p are 0 p eration is p erformed to determine which character was placed in the field HERE.

Figure 10-27. RPG II Linkage to an Assembler Language Subroutine

Alphabetized Operation Codes

RLABL

10-51

Calculation Specifications

C

Indicators

~

Result Field

At At

Factor 1

Operation

Plus IMinusl Zero

Factor 2
Name

Line
a

Z

3

4

a

Z

b

z

.

Length

o

1

C

o

2

c

o

3

C

o

4

C

o

5

C

o

6

C

"'~ !lit"
~L A8L.

\ CI

Compare

triA 1813
lIN ~q

;, AlAI
~C OMP TA ISB

-

Comments

1>211<211=2
Lookup( Factor 2Hs
High

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

5

Resulting
Indicators

Arithmetic

Low Equal

54 55 56 57 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

r1!~ 1.8 57

Control passed to the assembler subroutine by RPG II.
SUBRB

-

L

Assembler subroutine references the table and indicator
in the RPG II program and returns control to the RPG II
program.

Control is ;eturned to RPG II by the assembler subroutine.
The subroutine refers to both R LAB L entries. It first tests
the indicator. If the indicator is off, control is returned to
the RPG II program. If the indicator is on, a character Cis
moved into the last looked-up entry in the table, T ABB.
When control is returned to the RPG II program, a compare operation is performed to see whether or not the
subroutine placed a C in TABB.

Figure 10-28. RPG II Linkage to an Assembler language Subroutine

10-52

Operation Codes

Considerations for the Assembler Programmer

Result Field

Description

To write an assembler subroutine that is linked to an
RPG II program, the assembler programmer must be
aware of the following:

Level

Name of a one-digit numeric field
that designates the user message
member level. A value of 1 in this
field indicates a message level of 1;
a value of 2 indicates a message
level of 2.

Rcode

Name of a one-digit numeric field
that contains the return codes. The
return code and their meanings are
as follows:

• The name of the subroutine must be the same as the
name specified in factor 2 of the RPG II EXIT
operation.
• Upon entry to the assembler language subroutine, the
address recall register (ARR) contains a pointer to the
parameters that represent the RPG II fields to be
referenced by the assembler subroutine. The return
point to the RPG II program is the first byte after the
parameters.
• If the subroutine makes use of registers 1 and 2, the
contents of these registers' must be stored upon entry
to, and restored before exit from, the subroutine.

Return Meaning
Code

o

Note: The user-written subroutines should be placed in
#LlBRARY or #RPGLlB (the library the RPG compiler
resides in), not in the same library as the RPG II source
program.

Message was
successfully retrieved;
however, it was
truncated because the
length of the text area
was less than the
message length.

Message Retrieve Subroutine (SUBR23)
The message retrieve subroutine (SUBR23) allows you
to retrieve messages from a user message member.
After the message has been retrieved, it can be
modified and written to an output file.
Linkage to SUBR23 is by the EXIT operation code, and
input parameters are passed to SUBR23 by RLABL
operation codes. To use SUBR23, specify EXIT in
columns 28 to 31 and SUBR23 in columns 33 to 38.
Four RLABL operation codes must be specified after the
EXIT operation with the following result field entries:
Result Field

Description

MIC number

Name of a four-digit numeric field
that contains the M IC (message
identification code) of the text to be
retrieved.

Text area

Name of the alphameric field or
data structure into which the
message text is read. The
maximum length of a level-1
message is 75 characters and of a
level-2 message is 225 characters.

Message was
successfully retrieved
with no truncation;

2

Message was not found.

3

The field indicating the
message was invalid.

4

An invalid MIC value
was diagnosed.

5

Message member was
not found or message
text length exceeds the
level 1 maximum.

The text area, which is specified by the second RLABL
operation, is blanked before each attempt to retrieve a
mesSage; therefore, a blank text area is returned to the
user program when the return code value is 2 or greater.
A total of 225 positions in the text area is blanked
unless the text area is less than 225 characters in
length.

Alphabetized Operation Codes

RLABL

10-53

SET (SET)
Indicators

Resulting Indicators

Result

7-8

19-17

Factor 1

Factor 2

Field

54-55

OPt

lOot

Optional

Optional

Blank

Optional Optionall Ootional

156-57

158-59

I

The SET operation can be used only with input files
assigned to the device KEYBORD, which is specified in
columns 40 through 46 of the file description
specifications. All SET operations are directed to the
display station that loaded the program or to the display
station assigned to the program by the WORKSTN OCl
statement.
The SET operation allows any or a combination of the
following:
.. Command keys to be pressed
• The field, literal, or table or array element specified in
factor 1 to be displayed on the display screen
• User messages (from USER1 message member) 0001
to 0099 to be displayed when numbers 01 to 99
respectively are specified in the nn portion of the
SETnn and KEYnn operation codes

A total of 24 command keys are designated for the top
row of the keyboard. In the lowercase position, key 1
corresponds to command key indicator KA, key 2 to KB
... -(minus) to KK and = (equal) to KL. In the uppercase
position, key I corresponds to command key indicator
KM, @ to KN ... and + to KY.
If command keys were erroneously pressed and an entry
function key has not been pressed, the operator can
reset all the command keys by pressing the Cmd key
followed by the character backspace (Clear) key while
holding down the Shift key. The operator can then
rekey all the correct keys. If any invalid command keys
and an entry function key were pressed, an error
message is issued.
If no command keys are to be pressed, the operator
responds to the SET operation by pressing only an entry
function key; thus causing the indicators to be turned
off. This is called a null response. Using this null
response in your programs is not recommended because
of the possibility of an accidental null response. For
example, if the operator neglects to press the Cmd key
before pressing the appropriate command key, a null
response occurs.

Specifications for SET Operations

• The buffer for a CONSOLE file to be blanked if
ERASE is specified in the result field of the SET
operation

Allowin.a. Command Keys

to be

Pressed

The SET operation allows you to specify command keys
that the operator is allowed to press at this point in the
program. When the operator presses a command key,
the corresponding command key indicator turns on.
These command key indicators can be used to condition
subsequent calculation or output operations. Command
key indicators remain on until they are used again in a
SET operation or until they are turned off by the SETOF
operation.
When the program is at a particular specification line,
you can give the operator the option of pressing one to
three command keys. For each command key to be
pressed, the operator first presses the· Cmd key and
then presses the digit key corresponding to the
command key indicator (KA through KN, or KP through
KY). After all command key responses have been
entered, the operator presses an entry function key.

10-54

Operation Codes

The specifications required for a SET operation vary
depending upon which function, or combination of
functions, is to be performed. Figure 10-29 shows a
summary of these specifications, and Figure 10-30
shows the possible combination of these SET functions.

Columns 7-8: Enter any valid conditioning indicator.
However, leave these columns blank if the SET
operation is not a part of a subroutine or if it is to be
performed only at detail time.

Columns 9-17.: Enter any valid conditioning indicators for
any SET operation. However, leave these columns blank
if the SET operation is to be performed on every
program cycle.

Calculation Specifications

C

Indicators

r--

At AL

Operation

Factor 1

Factor 2
Name

Line
0

Z
3

4

Length

0

0

C

o
o

2

C

3

c

o
o

4

C

5

o

6

c
c

o
o
o

7

C

8

c

9

C

1 0

c

11

C

1 2

C

1 3

C

1 4

c

1 5

C

1 6

C

1 7

C

1 8

c

,T I, ,\

""1\ HA Tt I"tN,S

OF THE

~I ~~ LA~ c,~ NT Et1I 1r5 O~F

PRo ~~ PI' J1
411

x
;

I"~

IAlll T~

I~s: 1\ I~

A~

~If=

IFI RSir CI

Comments

High low Equal

53 54 55 56 51 5859 60 61 62 63 64 65 66 61 68 69 10 11 12 73 7"

CO iD~
I.... ft I.

ITIHE

'n

II

PA OIM Pit'

~

.LOltJ

~

~elr
110..

niT Ic:;.g I

SEi\" OP It: 1\ "'1 l.LolN

Indicators
Arithmetic
Plus Minusl Zero
Compare

~ 1>211<2il-2
~ lookup(Factor 2)i.

J:

z

Z

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 JO 31 32 J3 J4 35 36 31 J8 J9 40 41 42 43 44 45 46 41 48 49 50 51

5

01

IKtE r/S rr~ BE
IOF 11.U ~1 Icre 11 :J OIF

"T

nil 5F ILA~

IO ...

J

Fl ~LD

pn A..a " ... IA~I~ I~ r.T.

~Err

I_I ..

IKIA Ki!

~0 113

,. ....

fiR "M US (;IR

'·111.

SE rrl~
~n alr!!l~

,..

I.

OR RII 41"'1l
~
I:T , c:

EX iI~ IT1 INI6
SET

1 9

C

2 0

c

141 I ~I\&l

21

C

bP EIRIAT I

2 2

C

3

C

1

Resulting

Result Field

C~ NS ,. LE

too )is FI LE

r-o

au FF ~R

OF SP Ie" TIs: Irs:n

A~~

. PR

"0 MM AND 1{l:Y K~ J IK Pil, nR t(r IT~ BE
In 8'1 MIl- I~a 123
l:::lt: ~\ IL

1K.~Il\.

~1'1

PT

~

~
~

.v

K

C
C

Figure 10-29. Summary of Calculation Specifications for SET Operations

, Alphabetized Operation Codes
SET

10-55

Calculation Specifications

C

Indicators

~

0_

f---

...Ja::

Operation

Factor 1

Factor 2

j«

line

Name'

"0 r£

Length

:=cn

2

o

3

o
o

4

c~

5

C

o

6

c

o
o
o

7

e

8

eN

9

c~

1 0

c~

8

0

c~ rmn~

0

Z

Z

FI\

b~

tNt;

~~ MIR lIN

c
c~ ~l S~ LA I~is

Comments

Art" 1'0 N5 OIF FU Mle. ~l QN~ A:RE

V~ ~,llc

:tlN

~Er

CD NT ENrrs OF Ie- T el. In~ ON..In riH~
~~ 5P LArt C:;;II" grJ; ~I". 1FT 1:1 nlll 115
,..1.
'" 1'-.,.
ft~~ ME
~,~ iiTSP I:; Ie 1'S: rr ~r IN F~ c.rr DR 11 AIND

Inrr ~Io , IA ~S
"'L 1t:111~
I"-n It.tU A~II\ ~IE IYS lal~
'- ~~ 2f:

11

e

c

1 3

e

1 4

1 7

cW IKe Q~ 1M
c
c
c

1 8

C

~,.

A
~,'4 elK K

iF! EL rJ~

1 2

iFlt 1=1
TIHls

SiE T1rJ
"IF r:r lei,

~J ~ND ~.

n~

"() NS bl.E

~i":!

tl\IA

olN Drt c;ip LA~ c,'ft RC .:
1FtIEL ~lQ II~ 1t'1R ""I, IU~~

fl L'E
SErr

Operation Codes

.

IAL .. 0 \liS
AN"..... In.

iA

K 11\1- .. In

1!L1tl

111U, tolt- tot<

1r0 NO

lIN t'Ull

.1.1111:

Figure 10-30. Possible Combinations of Functions Performed by SET Operation

10·56

Compare

1>211<2I1c2
'u - lookup/Factor 2)is
c ::r: Hi!#> Low Equal

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2B 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051 52 53 54 55 5657 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

o
o

1 6

~ ;
~~

Z

4

1 5

Plus IMinusl Zero

7

3

1

.g :r:

8 a:"
...J

5

Arithmetic

~

AL At

=0
~z

Resulting
. Indicators

Result Field

nc~

'-- ONS
,.1

Columns 49-53: leave these columns blank.

Columns 18-27: Enter the constant, literal, field name,
or table or array element to be displayed on the display
screen.

Columns 54-59: Enter the command keys (KA through
KN, KP through KY) that the operator is allowed to
press when the program is at this specification line. One
to three command keys can be specified. If only one or
two command keys are specified, they can be entered in
any of the three sets of columns. When the operator
presses a command key specified in these columns, that
command key indicator turns on and remains on until it
is used again in a SET operation or until it is turned off
by the SETOF operation. A halt occurs if the operator
presses a command key other than those specified in
columns 54 through 59 of a SET operation.

Columns 28-30: Enter the operation code SET.

Columns 31-32: Enter the message identification code
(MIC) corresponding to the message in the ~ser
message member file that is to be displayed on the
display screen. This message prompts the operator to
perform a SET operation. Valid entries are 01 to 99. An
entry is required when command keys are specified in
columns 54 through 59 and columns 18 through 27 are
blank. If no user message' member is specified prior to
execution with a MEMBER OCl statement or there is no
message for the specified MIC, the system prompt
'nn-MESSAGE INDICATOR' is displayed, where nn is
the contents of columns 31 and 32.

Either factor 1 or message indicators in columns 31 and
32 must be specified on a SET operation. If both factor
1 and message indicators are present, the message
indicators are ignored.
If you stack SET operations with a factor 1 (or MIC) and
no command key entries (see Figure 10-31), you can
display several lines on the display screen before the
system halts for input. You can display up to six lines if
the record length is 40 or less. You can display a full
screen if the record length is more than 40. The system
does not halt until a command key function is
encountered or a KEY operation is specified .

Columns 33-42: When the ERASE function is specified
in columns 43 through 48 for a CONSOLE file, enter the
CONSOLE filename in columns 33 through 42. For all
other SET operations, leave these columns blank.

Columns 43-48: Enter ERASE in these columns to clear
. the CONSOLE file specified in columns 33 through 42.
For all other SET operations, leave these columns blank.

Calculation Specifications

C

-

Indicators

~

0_

AL

-'ex:
=0

~~~r£

line

1

Arithmetic

:~ ;:.

Factor 2

Operation

Factor 1

Name

.... (5

E :;

5

~

8 57

4

o
o
o

1

C~

2

C

3

c

o
o

4

C

5

o

6

c
c

o

7

C

a

B

C

o

9

C

1 0

C

Length ~

8

~

0

;

Plus IMinusl Zero
Compare

Comments

1>211<211=2
~~
·u :: Lookup(Factor 21is
o ::t High Low Equal

(J)

6

3

Resulting
Indicators

Result Field

0

Z
Z
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5253 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

lrt'IA
It\'.

IKIIIN

~t:.

Kt::.

"rr
ru

KlJ In

lrt ~IJ:I1 .
,-1 ~I:

L 11 ~ 'J;
Lil rHi
LIT N~

~

ET

IN 1;;5 ITC
.IN l'" LIt

lIS

I.... "

, 1.1

IRE~

... 1.

II.

:J ~L .. b ~S
AI" OINE

lU.I

t' ,

oPOI.-

r:

err
EN

System halts when command key indicators are specified.

EI1

IKA KR II211 <211-2
Lookup(Factor 21is
High Low Equal
54 55 56 51 58 59 60 61 62 63 64 65 66 61 68 69 10 11 12 13 14

it
HI:l

The pr'ompt KEY HALT TO TERMINATE PROGRAM
is the text issued for the KEY01 operation. This is the
contents of the object member loaded into the user
message member specified by the MEMBER statement.
Subsequently, the USER 0101 message text that is
issued when the literal HALT is keyed is HALT HAS
BEEN ENTERED WITH KEY OP.
The second message issued, USER 0100, has not been defined in the user message member; thus it cannot be retrieved, and the message MESSAGE NOT RETRIEVED
(SEE MSG MANUAL) is issued.

Messages are retrieved from the user-created message member MESG1 specified in the MEMBER statement:
II LOAD USER
II MEMBER USER1-MESG1
II RUN
Figure 10-32. Issuing a Message

Alphabetized Operation Codes
SET

10-59

Special Combinations of the SET and KEY
Operations

SETLL (SET LOWER LIMIT)

Normally, the operator must press an entry function key
after eac,", KEY operation or after command keys
specified in a SET operation are pressed. However, it is
possible to combine these operations so that the
operator can press command keys (specified in columns
54 through 59 of a SET operation), key a field (specified
in a KEY operation), ar:"ld only press an entry function
key once. This is only possible if:

7-8

19-17

Factor 1

Factor 2

Field

Oot

lOot

ReQuired

Reauired

Blank

Indicators

• The SET operation immediately precedes the KEY
operation.
• The SET and KEY operations are conditioned by the
same indicators (columns 7 through 17). Indicators
for both operations must be specified in the same
order.
• The SET and KEY operations contain the same
message indicators (see Figure 10-33). If factor 1 is
used to display messages, then columns 31 and 32
can be blank to satisfy this requirement.
• Factor 1 for the SET and KEY operations can be the
same, different, or missing from one operation. If
factor 1 is specified for both the SET and KEY
operations, the contents of each factor 1 are
displayed.
If the data field is numeric, the operator must first press
the specified command key, key the field, and then
press the Field Exit, Field +, or Field - key. The
Enter / Rec Adv key is not allowed as an entry function
key for a numeric field. For an alphameric field, the
operator must perform the same sequence of steps if
the Field Exit or Field + key is pressed. However, if the
Enter / Rec Adv key is used, the operator can press the
command key and then key the field, or key the field
and then press the command key before pressing the
Enter/Rec Adv key.

10-60

Operation Codes

Result

Resulting Indicators

156-57

158-59

Blank ·1 Blank

IBlank

54-55

The SETLL operation allows the lower limits for an
inde~ed demand file being processed sequentially within
limits to be set during calculations.
Factor 1 must· contain a field name or literal representing
the value of the lower limit being set. The length of the
field or literal must be equal to the length of the key
specified on the filename in factor 2.
Factor 2 must contain the name of the file for which the
lower limit is to be set. If a read is performed to the file
prior to a SETLL operation, the record with the lowest
key in the file is fetched. Figure 10-34 shows an
example of SETLL coding.
Note: When a lower limit is specified by SETLL, the
end-of-file indicator specified for the READ operation. to
the file being processed is not set off by the RPG II
cycle.

Calculation Specifications

C

-

Indicators

~

::0

~

'0

E E~
85

5 6

7 8

1

C

2

c~

o 3

C

o
o

4

c

5

c

o

6

C

o
o
o

7

c

B

c

9

C

1 0

C

Factor 1

At

AL

Operation

Factor 2
Name

c£

~

o
o

Indicators

Arithmetic

~~~

Line

3 4

Resulting

Result Field

0_
-Ja:
Length

.g X Plus IMinusl Zero
Compare
~ ;
1>211<211-2
~~ Lookup(Factor 2)is

Comments

·u -

" " "

Z
z
OJ: High Low Equal
9 to tt 12 t3 14 t5 1617 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

z

IN THE

FI~ ~

I

~p

-

\I. L Nl"!l

Of tTHE
THE FIR l"E Fl IE ILD

Tt1 RES:;
KE~

-,.1 o~ IS

ER ~I 1( n~ itH~ llr -=.n Itln I'A~ ru: PbINIl
q ...
11< ~ ~5 5P EC. 1111" lIEn ttJ Ico LU "N~
I

p~ E~!'t

IKt:

11:111:

U5 E~

;J')

'... I I:LJ

.... W'_

T~ ~IHI= ~R ~LL

~

1'\1\

nl'!l

lane: 1It.ic:.

1\IN I:N 1

~,..~

~Q r~LA

'Ir~

rrr ION

IFIU

~l

Illla \l1:l

5(; T~~

KE 'ib~

PR ~tE

ft ...

,-

I:;"

AINtD
IKE ~. TI"E

~,.

5al

Figure 10-33. Special Combination of SET and KEY Operations

File Description Specifications
File Type

F
-

File Addition/Unordered

Mode of Processing

Extent Exit
for DAM

length of Key Field or

File Designation

of Record Address Field

End of File

Record Address Type
Sequence

Filename

Type of File
Organization
Nor Additional Area

File Format

Line

(5 Overflow Indicator

Block
Length

Record
Length

~

c:

~

t:

r--Key Field
Starting
location

e

~ ~

34

9

~F~IIIL~tt:l!

ID

o3
~
r+-r~r+-r~~-+~~t-~
o 4
'r--.

C

I

!

~> ~
Line

And

IF. ;S!.1J2 :Z5bL SIAI
iii

i

7 8

~

~
Condition

a

.~

2

Continuation lines

x

Option

W
~

S5 56 57 58 59

UI~

~

Entry

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

l1 Jjr.SIKJ I i l II I i ; ! I I

iii!

i

i! I II!!

II: LW

II

i

III

i

Calculation Specifications
' "

Result Field

~
Factor 1

a

'- .
_...... ~

~

9 10 11 t2 13 t4 15 16 t7 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

Resulting

Indicators

:~ ~

Factor ;>

-'ation

Name

§ E~
~ 85 ~

Tape
Rewind

8

I-oa:'

3 4 5 6

Number of Extents

Storage Index

~

II

__

I

A~d

!

.

:'

~

Indicators

~

9~

UJ

10 11 12 13 14 15 16 17 18 19 2021 22 23 24 25 26 27 28 29 30 31 32 33 34 3S 36 37 38 39 4041 4243444546 47 4849 50 51 52 53

0
F P"f1-+-+--2--t-1

-

Name of
Label Exit

Symbolic
Device

Device

-J

Number of Tracks
for Cyli.,cier Overflow

Plus

~~::!e Zero

Comments

Length~i'>211<211=2

5-

~

Arithmetic

c :t:

Lookup(Factor 2lis
High

Low Equal

37 Ja 39 40 41 42 43 44 45 46 47 48 49 50 5t 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

ole

o

2

C

o

3

C

o

4

C

R~A

1'111 rlJ. L ~

1

FIE LDA is defined on input specifications as an eightposition alphameric field.
Figure 10-34. SETLL Operation Coding

Alphabetized Operation Codes
SETLL

10-61

SETOF (SET OFF)

SHTDN (SHUT DOWN)

Indicators

Result

7-8

J9-17

Factor 1

Factor 2

Field

Opt

JQQt

Blank

Blank

Blank

Resulting Indicators

54-55

J56-57

158-59

1 required

The SETOF operation turns off any indicators specified
in columns 54 through 59. At least one resulting
indicator must be specified in columns 54 through 59.

SETON (SET ON)
Indicators

Result

7-8

19-17

Factor 1

Factor 2

Field

OJ:lt

lOj:lt

Blank

Blank

Blank

Resultina Indicators

54-55

156-57

1158-59

1 required

The SETON operation turns on any indicators specified
in columns 54 through 59. At least one resulting
indicator must be specified in columns 54 through 59.

10-62

Operation Codes

Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

J56-57

J58-59

Opt

IOpt

Blank

Blank

Blank

Required) Blank

)Blank

The SHTDN operation sets on the resulting indicator
specified in columns 54 and 55 if the system operator
has requested shutdown. The indicator can then be
used to condition termination of the program in an
orderly manner, such as printing some partial totals and
going to normal end of job.
Columns 28 through 32 must contain SHTDN, and
columns 54 and 55 must contain one of the following
valid indicators: 01 through 99, L1 through L9, U1
through U8, H1 through H9, or LR.

SORTA (SORT AN ARRAY)
Indicators

In Figure 10-35, the array ARY is sorted into ascending
order because no entry is specified for sequence
(columns 45) in the extension specifications. ARYA is
sorted into ascending order because column 45 of the
extension specifications contains A; ARYD is sorted into
descending order because column 45 contains D.

Resultinq Indicators

Rc::ult

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

Opt

IOpt

Blank

Required

Blank

Blank

IBlank

IBlank

The array specified in factor 2 is sorted into the
sequence specified in the extension specifications for
the array. If no sequence is specified, the array is sorted
into ascending sequence. The standard EBCDIC
collating sequence is used for the SORTA operation. If
an alternate collating sequence has been defined, it is
not used.

The SORTA operation allows you to sequence the
elements of an array during execution of a program.
You can ensure that the elements of the array are in the
proper sequence for LOKUP operation by performing a
SORTA operation.

For examples of the SORTA operation, see Figure
10-35.
Note: Columns 18 through 27 (factor 1) and 43 through
59 (result field, half adjust, and resulting indicators) must
be blank if an SORTA operation is specified.

Extension Specifications

E

Record Sequence of the Chaining File

t--

Number
of

Number of the Chaining Field

Table or
Array Name

To Filename

Line

From Filename

Entries
POI
Record

Number
of
Entries
POI Table
or Array

.,

.0

length
of
Entry

.;;;
0

cr.
...J

Ol

Ci:
3

4

0

1

5

6

1

8

9

o
o

5

1 [~
1,1_5

1

o 2
E
A RYIA
o 3
E
I-H-+--+--+-+-+-t-+--+-++-+-+-+----+--+-+++-I--+-+-ABY D
4

~

(Alternating
Format)

~

length
of
Entry

.,

.0 0
;;;

Q.

a:
...J

~ £

Ol
Q.

~
u
0

~

Comments

C

&

10 11 12 13 14 15 16 11 18 1920 21 22 23 24 2526 21 28 29 30 31 32 3334 35 36 37 38 39 40 41 4] 43 44 45 46 41 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 10 11 7'1 73 74

I--t-t-+-t-+--I--t-I--t-+-+-+-+-+-+-I--t-I--+--II--+-I'-+-J!,-,Aj!-R Y

0

Table or
Array Name

0

3 _ '.-,:ct---t-t---t-t--t--t-t---+---+-+-t--t-+--+-+-+--+-+-+--t'-+-J--+-+---+-+--tI--+-I
11 _

10

L

.-Lls....

'----L_

~

Po

(60

H- -

E

6

Calculation Specifications

C

Indicators

§

~

I---

AL Jd

-;;

~3

Line

c
0

Factor 1

Operation

·s

Factor 2
Name

1-0

~ ~

~8
3

4

o

1

o

2

c~

o

3

o

4

c~
C

o

5

c

o

6

c~

o

7

c~

o

8

c~

o

9

c
c

1 0

Result Field

5

6

1

c*

1 1

C

1 2

C

Length ~

E

0

0

~

0

Z
Z
Z
9 10 tl 12 13 I. 15 t6 11 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 41 48 49 50 5t 52

~o :Rh"

'AIRY

AND 'iJ. RIY IA

I

I

Resulting
Indicators
Arithmetic
Plus IMinusl Zero
Compar.
1>211<211- 2
lookup(Factor 2)i,
Hilt> Low Equal

Comments

54 55 56 51 58 59 60 61 62 63 64 65 66 67 68 69 10 11 12 73 7.

liN T(' AS CE NO ING OR IOER

SO R~ 'AIA iR~
I~('\

So !RT

\A RY 0 '

Rir 'AlA 'RvIA

IN T'O DE SC EN D1 Nr..

OR DER

S!o RT AA RVD

Figure 10-35. Examples of the SORTA Operation

Alphabetized Operation Codes
SORTA

10-63

SQRT (SQUARE ROOT)
Indicators

7-8
Opt

TAG (TAG)
Result

Resulting Indicators

19-17

Factor 1

Factor 2

Field

54-55

156-57

IOpt

Blank

Required

Required

Blank

I Blank

158-59
IBlank

Opt

The SORT operation derives the square root of the field
named in factor 2. The square root of factor 2 is placed
in the result field. Factor 1 is not used.
An entire array can be used in a SORT operation if
factor 2 and the result field contain array names.
The number of decimal places in the result field can be
either less than or greater than the number of decimal
places in factor 2. However, the result field should not
have less than half the number of decimal places in
factor 2. The result of a SORT operation is always
half-adjusted.
If the value of the factor 2 field is' negative, the job
halts. The operator can continue processing by
responding to the halt. When processing is continued,
the result field is set to zero.

SUB (SUBTRACT)
Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

Dot

lOot

Ootional

Required

Required

OPtionallOPtio~allOPtional

156-57

158-59

Factor 2 is subtracted from factor 1. The difference is
placed in the result field. Factor 1 and factor 2 are not
changed by the operation. Subtracting ~ field from itself
is a method of setting the result field to zeros. If factor
1 is not present, factor 2 is subtracted from the result
field, and the difference is placed in the result field.

10-64

Operation Codes

Indicators

7-8

Result

Resulting Indicators

1~17

Factor 1

Factor 2

Field

54-55

1~57

158-59

IBlank

Required

Blank

Blank

Blank

IBlank

I Blank

The TAG operation names the operatipn to which the
program branches in the GOTO operation. If the TAG
appears within a subroutine, the associated GOTO must
appear within the same subroutine.
Factor 1 contains the label that must begin in column
18. The same label cannot be used for more than one
TAG operation (or elsewhere as a subroutine name or
ENDSR label).
Factor 2 and the result field are not used. No indicators
can be entered in columns 9 through 17 for a TAG
operation. Control level indicators must be used,
however, if branching is to occur only when the
information in a control field has changed.
See Figures 10-36 and 10-37 for examples of the TAG
operation.

Calculation Specifications

C

Indicators

10--

Jd Jd

Factor 1

Operation

Name
0

0

z

z
4

o

1

o

2

o

3

o

4

length ~

E

·u

b

0

z

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 3D 31 32 3 3 34 35 J6 31 38 39 40 41 42 434.4546048 49 50 51 52

5

o

5

o

6

c
c
c
c
c
c

o

7

C

o
o

8

C

9

c

1 0

C

,,

Indicators

:i

Factor 2

Line

3

Resulting

Result Field

lill

Fit I=l.

FiT C. ,,'~

2

C

,

3

c

,

4

C

, 5

C

,

6

,

7

c
c

,

8

C

,

9

C

TN1

~t'lTCl

~Ul~

TNl1

t;~111

Ril" N2

TAG

J:l I:L n~

52

SA I"~

!2

Comments

54 55 56 51 58 59 60 61 62 63 64 65 66 61 68 69 10 11 12 13 l '

11

Some calculation
operations

RIT N1

T B
Some calculation
operations

c

,

".8

t~ I~A

SUB

Arithmetic
Plu. IMinu.1 Zero
Compare
1>211<211-2
Lookup(Factor 21i.
Hi!tl Low Equal

NiP;

T

~~

t'lT

I:~

~'Nl1

'-II
,~~

Ij5

TM2

Ft ~I l'tr

I:

l:N~

If the result of the subtraction in line 01 is minus
(indicator 10 is on), a branch is taken to RTN1
(routine 1) named by the TAG operation code in
line 09. Notice that both the GOTO (line 02) and
TAG (line 09) are not conditioned by control level
indicators.

2.

If the branch is not taken in line 02, the multiplication in line 03 is performed. Then the branch to
RTN1 (line 09) must be taken because this branch
is not conditioned by indicators.

3.

Operations in li~es 10 through 12 are then done.
If the operation in line 12 does not turn indicator
15 on, a branch is taken backwards to RTN2
(line 05),

12~

FT ~L ~"

11r: Tic L~~

1.

~IJ

I

4.

Operations then go in the order specified again from
lines 06 through 12. Nothing is done in line 09 because TAG gives only a name. These same operations
are performed again and again until indicator 15 does
turn on.

5.

When indicator 15 is on, the branch to RTN2 is not
taken. The TESTZ operation is then performed. If
this operation causes indicator 20 to turn on, a
branch is taken to line 17 (GOTO END). If indicator
20 is not on, the operation in line 16 is done.

Figure 10-36. Using GOTO and TAG (Skipping Operations)

Alphabetized Operation Codes

TAG

10-65

Calculation Specifications

C

Indicators

,....--

At At

Operation

Factor 1

Plus

Factor 2
Name

0

0

Z

Indicators

Arithmetic

line
Z

Resulting

Result Field

Length

0

z

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2B 29 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 45 46 47 48 49 5051

3

4

0

1

C

~ f-

0

J

5

2

C

0 3

C

0 4

C

0

5

C

0 6

C

Minusl Zero
Compare

Comments

1>211<211=2
lookuplFactor 2Hs
High low Equal
54 55 56 51 58 59 60 61 62 63 64 65 66 67 6B 6!T 70 71 72 73 74

11

,
,,
II

~

,

~

T

to-

~

Et

,

0

7

C

I:I~ ~t'

o

8

C

t:IJ ~ .. 1

o

9

C

Assume you want to make eight mailing labels for every
customer you have. The customer's name and address are
found on an input record. Because you want to write eight
labels for each record, you can use exception lines and the
operation EXCPT instead of coding eight identical output
line specifications. (See Exception (EXCPT) in this
chapter for further information.)

However, by using branching, you can code it all in five
lines as shown below. An EXCPT line is printed out.
One is added to COUNT to keep track ot'how many times
the line is printed. Then COUNT is compared to 8. If
COUNT does ~ot equal 8, a branch is taken back to the
beginning (GOTO DOAGIN). If COUNT equals 8, the
branch is not taken. Instead, the COUNT field is set to
zero for the next cycle.

Calculation Specifications

C

Indicators

~

0_

~

~3~

line

Factor 1

Operation

Plus IMinusl Zero

Factor 2
Name

t- "00:.

E

~ (I)

8 5·

~

6

7

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 ~1 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

0

Z

0

z

4

0

1

C

o

2

C

o

3

C

1

o
o

4

C

l. JIU In I

5

C

o

6

C

o

7

C

8

...

N~~

r

~N

ITA~
t:~ L.lt'i'

"n~ IWD lINI'
"0 ~p e
~
aD Tt'!

~-

"D

i-

C" UNIT

[)~QJ

Figure 10-37. Using GOTO and TAG to Eliminate Duplicate Coding,

10-66

Length

.f
3

5

Indicators

Arithmetic

AL At

-'a:
=0

Resulting

Result Field

Operation Codes

A

..

54 55 56

~7

j

i

1

Comments

5859 60 61 62 63 64 65 66 67 6B 69 70 71 72 73 74

~I

0-

l,;;\.l UNII

Compare

1>211<211=2
lookuplFactor 2Hs
High low Equal

TESTB (TEST BIT)
Indicators

Result

7-8

19-17

Factor 1

Factor 2

Field

Opt

!OPt

Blank

Required

Required

Resulting Indicators

54-55

.156-57

158-59

1 required

The TESTB operation compares the bits identified in
factor 2 with the corresponding bits in the field named
as the result field. Resulting indicators in columns 54
through 59 reflect the status of the result field bits.
Factor 2 is always a source of bits for the result field.
The result field is the field in which corresponding bits
are compared with the bits specified in factor 2.
Factor 2 can contain:
• Bit numbers 0-7: From 1 to 8 bits can be tested per
operation. The bits to be tested are identified by the
numbers 0 through 7 (0 is the leftmost bit). The bit
numbers must be enclosed in apostrophes and the
entry must begin in column 33. For example, to test
bits 0, 2, and 5, enter '025' in factor 2.
• Field name: The name of a one-position alphameric
field, table element, or array element can be specified
in factor 2. In this case, the bits that are on in the
field, table element, or array element are tested in the
result field; bits that are off are not tested.

See Figure 10-38 for a summary of TESTB operations.

Indicators assigned in columns 54 through 59 reflect the
status of the result' field bits. At least one indicator
must be assigned, and as many as three can be
assigned for one operation. Two indicators can be the
same for a TESTB operation, but not three. For TESTB
operations, the resulting indicators turn on as follows:

Columns 54-55: An indicator in these columns turns on
if each bit specified in factor 2 or each bit that is on in
the factor 2 field is off in the result field.

Columns 56-57: An indicator in these columns turns on
if the bits specified in factor 2 or the bits that are on in
the factor 2 field are ·of mixed status (some on, some
off) in the result field.

Columns 58-59: An indicator in these columns turns on
if each bit specified in factor 2 or each bit that is on in
the factor 2 field is on in the result field.
Note: If the field in factor 2 has no bits on, then this
indicator turns on.

The operation code TESTB must appear in columns 28
through 32. Conditioning indicators can be used in
columns 7 through 17. At least one resulting indicator
should be assigned in columns 54 through 59. As many
as three resulting indicators can be assigned, but not
more than two can be the same. Factor 1, decimal
positions, and the half-adjust columns must be blank.

Alphabetized Operation Codes
TESTS

10-67

Calculation Specifications

c

Indicators

Resulting

Result Field

Indicators

ArithmetIc

"----

Operation

Factor 1
line

~

3

4

~ I .~

5

10 "

I I ~I
113/'4

° 2! C
° 3; C
C

6:

C

07,

C

0:

I

':

I-+--+--r--+-----+--

10"""',8-'+C--+----i-+-1,0

C

1; 1 i

C!

iii

1 !2 i

C

!

I

n

-' I I I I I

2829 303' 32 33 34 35 36 37 38 39 40 4. 42 434445 46 41 4S 49 50 5.

iii i I I
I i : I I I: :
I

I

!
~: I!
i

:

;:

I

:I

iii
I

!

I

I

I ::

I::

i

I

I

'i!

6

C

'

C

1 :7:

C

I i8

C

11

:

:

I:

:!

! !

:

C

C

i

Ii:

•

2 7

C

2' 8

C

2 9

C

1!

! : !

I

!!

:

;

C

3,2:

C

:!

i i

:!

4

°

C

:!!

:

'

!

I

:

I

I!

I!

i

I

~

:

;

i _:
!

:

I

I

Ii

i!!

!!!

I

i

I

:

:

aITSi:

!

I

j

!

~;a2il2.:l

i

i

I

iii

':

I

I!!:

;!

I

!

!

I

'

I

I

;: I
i !

i
!

!

i
1

I

1 I
1

I:

i

:

I Iii

i

:

t-

'i! I

:;

~el~ll2

IBIlrS:
I

:

!:

I_,!

I

TI--+-+!--+!--+i--.,.·--li-l!-----<,-I:f-,f--1

:

I

! :
! ! I ,;
:

i
I

:,

I

Ii:
i

I

:

:

:

I

I~
i 'i

!;

i

I

I

I

i

H-~ !:

i

I

Ii I:

'i

:

' I

I

I

I:

I

I

I

,

I

i
I

!

I
I

: :
! I

I

rtl-

-u-:
+i-:

I

I

I

'III

I

I

I

! : : !

·I

I
II t:~ II~IA,R,E

Figure 10-38. Summary of TESTS Operations

10-68

!

The following operations use a one-position array element either as a source of bits or as a result
field, or both. In the first operation, the bits that are on in the field named ALPHA are compared
rtfto corresponding bits in the array element ARR,NX. For example, assume that bits 1 and 4 are on
in the field named ALPHA. If bits 1 and 4 are off in array element ARR,NX, indicator 20 turns on. ~
If bits 1 and 4 are of mixed status (one on, one off) in array element AR R,NX, indicator 21 turns
on. If bits 1 and 4 are on in array element ARR,NX, indicator 22 turns on.
f-f--

i

i

:

:

'!!!'
~
I:
i ~

I

"

! I I!

;

1-3__
'4-+C--+-----+-C

i

i:

l"'EST1B~LPH~;

;-f-r- ~----·~r---:-r-r--+-:

:3=,3:,:C:==:=
3 \5

i
I

I

13-,o-+c--+-----+-3,1,

I!

i

Iii

II i i

!

s--+-cr--t--t----il-c-,-+~;--'--C

i

;

the field named ALPHA are on in the field named BITS, indicator 22 turns on.

1-2-t-;

2,6

I!

60 6' 62 6364 65 66 61 6869 70 1. 12 13 14

!!

I!

C!

2i3

II I

i ,rESl1B\~71/::
I I
!
!:

I

1-2t-'2-+-C+---+--~--+-j~~-: Ii:
2 4,

i

I

i

~i9:5 5~O:, ::~~
I

I

! I,! • i i
!
: I
I
I I I i ! i! I ,I 1 - I i The following operation compares the bits that are on in the field named ALPHA with corresponding '-_
I i bits in the field named BITS. If the bits that are on in the field named ALPHA are off in the field
f-I I
named BITS, indicator 20 turns on. If the bits that are on in the field named ALPHA are of mixed
'---I
status (some on, some off) in the field named BITS, indicator 21 turns on. I,f the bits that are on in
-1--

:1:: ::
2!1

I i ! I!

i i i

:

l-r-:4_i+c--+-----+-_, J :

I115!

It !

i:!;:;!

I
;:
~~-r~~~~~~~~~--~~
C

Comments

lookup(Factor 2)is
'9 20 2' 22 2324 25 26

i!; I!
:! I! !

C

113:

IMinusl Zero
Compare

1>211<2(1-2

The following TESTB operation compares bits 0 and 7 with corresponding bits inthe field named
BITS. If bits 0 and 7 are off in the field named BITS, indicator 20 turns on. If bits 0 and 7 are
of mixed status (one on, one off) in the field named BITS, indicator 21 turns on. If bits 0 and 7
are on in the field named BITS, indicator 22 turns on.

09

i

Length

I

!

1-0+-i4_i+c--+-----+-_
015 i

Name

~/.6/17.8

C ~!--+---~~I--+-+
:r--t--i

1
1-°1-

Plus

Factor 2

Operation Codes

• ii!2

TESTZ (TEST ZONE)
Indicators

7-8
O~t

19-17
lOpt

XFOOT (SUMMING THE ELEMENTS OF AN ARRAY)
Result

Factor 1

Factor 2

Field

Blank

Blank

Required

Resulting Indicators

54-55

156-57

158-59

1 required

Indicators

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54·55

Opt

IOpt

Blank

Required

Required

Optional IOptional IOptional

156-57

158-59

The TESTZ operation tests the zone of the leftmost
character in the result field. The result field must be
alphameric because this operation can be done only on
alphameric characters. Resulting indicators turn on
according to the results of the test. The characters &, A
through I, and any other character with the same zone
as the character A turn the plus indicator on. The
characters - (minus), J through R, and any other
character with the same zone as the character J turn the
minus indicator on. Characters with any other zone turn
the zero indicator on. Factor 1 and factor 2 are not used
in this operation.

The XFOOT operation can be used only on numeric
arrays. XFOOT adds the elements of the array together
and places the sum into the field specified as the result
field. Factor 1 is not used. Factor 2 contains the name
of the array.

TIME (TIME OF DAY)

Factor 2 is added to a field of zeros. The sum is placed
in the result field. Factor 1 is not used.

Indicators

Result

Z-ADD (ZERO AND ADD)
Indicators

Result

Resultim~

Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

OPt

IOpt

Blank

Required

Required

OPtional IOotional ]Optional

156-57

158-59

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

156-57

158-59

QpJ

IOpt

Blank

Blank

Required

Blank

IBlank

IBlank

Z-SUB (ZERO AND SUBTRACT)
Indicators

The TIME operation accesses the system time of day
and, if specified, the system date.
The system date accessed is not the same field as
UDATE and mayor may not contain the same
information. See the System Support Reference Manual
for a complete description of the system date and the
DATE DCl statement.

Result

Resulting Indicators

7-8

19-17

Factor 1

Factor 2

Field

54-55

Oot

lOot

Blank

Required

Required

OpJional IOptional IOptional

156-57

158-59

Factor 2 is subtracted from a field of zeros. The
difference, which is actually the negative of factor 2, is
placed in the result field. This operation can be used to
change the sign of a field. Factor 1 is not used.

Columns 28 through 32 must contain the operation code
TIME, and columns 43 through 48 (the result field) must
specify the name of a numeric field with zero decimal
positions into which the time of day or the time of day
and the system date are written.
To access the time of day only, specify the result field
as a 6-digit numeric field. To access both the time of
day and the system date, specify the result field as a
12-digit numeric field. The time of day is always placed
in the first six positions of the result field in the format
hhmmss, where hh is hours, mm is minutes, and ss is
seconds. If the system date is included, it is placed in
positions 7 through 12 of the result field. The date
format depends on the system date format and can be
mmddyy, ddmmyy, or yymmdd.

Alphabetized Operation Codes
TESTZ-Z-SUB

10-69

10-70

Operation Codes

Chapter 11. Multifile Processing

In an RPG II program, the processing of more than one
input file, with or without match fields, is termed
multifile processing. Selection of records from more
than one file based on the contents of match fields is
known as multifile processing by matching records.
Multifile processing can be used with input files that are
designated as primary or secondary files but not as
chained or demand files. One of the files used in
multifile processing must be a primary file. If a
WORKSTN file is designated as the primary file, no
secondary files can be specified; therefore, multifile
processing by matching records cannot be used.

NO MATCH FIELDS
When no match fields are used in multifile processing,
records are selected from one file at a time. When the
records from one file are all processed, the records from
the next file are selected. The files are selected in this
order:

1.

Primary file, if specified

2.

Secondary files in the order in which they are
described in the file description specifications

Records without match fields can also be included in the
files. Such records are selected for processing before
records with match fields. If two or more of the records
being compared have no match fields, selection of those
records is determined by the priority of the files from
which the records came. The priority of the files is:
1.

Primary file, if specified

2.

Secondary files in the order in which they are
described in the file description specifications

When the primary file record matches· one or more of
the secondary records, the M R (matching record)
indicator turns on. This indicator can be used to
condition calculation or output operations for the record
that is selected. When one of the matching records
must be selected, the selection is determined by the
priority of the files from which the records came.
Figure 11-1 shows when the M R indicator is turned on
during the RPG II cycle. For more information on the
RPG II cycle, see Chapter 17, Detailed RPG II Program
Logic.
One file can be defined with match fields while all other
input files have no match fields. The files without the
match fields are then processed completely according to
the previously mentioned priority of files. The file with
the match fields is processed last, and sequence
checking occurs for that file.

MATCH FIELDS
When match fields are used in multifile processing, the
program selects the records for processing according to
the contents of the match fields. The program reads
one record from every input file and compares the
match fields in the records. If the records are in
ascending order, the program selects the record ~ith the
lowest match field. If the records are in descending
order, the program selects the record with the highest
match field.
When a record is selected from a file, the program then
reads the next record from that file. At the beginning of
the next program cycle, the new record is compared
with the other records in the read area that are waiting
for selection, and one record is selected for processing.

Assigning Match Field Values (M1-M9)
When assigning match field values (M 1 through M9) to
fields on the input specifications in columns 61 and 62,
consider the following:
• Sequence checking is automatically done for all
record types with match field specifications. The
contents of the fields to which M 1 through M9 are
assigned are checked for correct sequence. An error
in sequence stops the program, and the record that
caused the halt is not processed. When the system
is restarted, the next record from the same file is
read. Thus, all match fields must be in the same
order, either all ascending or all descending. See
Column 18 (Sequence) in Chapter 3, File Description
Specifications.

No Match Fields

11-1

START

\

\

I

,
conditions met?

Halt if halt
indicator is on.

Are multiple input
being used? If so,
determine the next
record to process.

Perform detail
output.

Turn on record
identifying
indicators.

-

Perform detail
calculations. Turn
calculation resulting
indicators on or off.
,

,,

Change in control field?
If yes, turn on control
level indicators.

Move data into processing
area. Turn field indicators
on or off.
Perform total calculations.
Turn calculation resulting
indicators on or off.

Turn MR on
or off.
Perform total
output.

,

Figure 11-1. Simplified Matching Record Logic

11-2

Multifile logic: logic
used to select the
record to process
when more than

Read a
record.

Turn off control
level and record
identifying indicators.

,

I

Multifile Processing

I

• Not all files used in the job must have match fields.
Not all record types within one file must have match
fields either. However, at least one record type from
two files must have match fields if files are ever to
be matched.
• The same number of match fields must be specified
for all record types that are used in matching. The
same matching record values must also be used for
all types (see Figure 11-2).
• All match fields given the same matching record
value (M1 through M9) must be the same length and
type (alphameric or numeric). If the match field
contains packed data, the zoned decimal length,
which is (2 x the packed length) -1, is considered as
the length of the match field.
• Record positions of different match fields can
overlap, but the total length of all fields must not
exceed 144 characters.
• If more than one match field is specified for a record
type, all the fields are combined and treated as one
continuous match field (see Figure 11-2). The fields
are combined according to descending sequence (M9
to M 1) of matching record values.
• Match fields cannot be split, that is, the same
matching field value cannot be used twice for one
type of record.
• Match fields can be either alphameric or numeric.
However, all match fields given the same matching
record value (M1 through M9) are considered numeric
if anyone of the match fields is described as
numeric.
• When numeric fields having decimal positions are
matched, they are treated as if they had no decimal
position. For instance, 3.46 is considered equal to
346.
• Only the digit portions of numeric match fields are
compared. Even though a field is negative, it is
considered to be positive because the sign of the
numeric field is ignored. Thus, a -5 will match with a
+5.
• Whenever more than one matching record value is
used, all match fields must match before the MR
indicator turns on. For example, if match fields M 1,
M2, and M3 are specified, all three fields from one
record must match all three fields from the other
record. A match on only the M1 and M2 fields will
not turn o·n the M R indicator (see Figure 11-2).

• Field names are ignored in matching record
operations. Therefore, fields from different record
types that are assigned the same match level can
have the same name.
• If an alternate collating sequence is defined for the
program, alphameric fields are matched according to
the alternate sequence specified.
• A field specified as binary (B in column 43) cannot be
assigned a match field value. However, a field
specified as packed (P in column 43) can be assigned
a match field value.
Note: Additional rules applying to matching records
when used with entries in the field record relation
columns are discussed under Columns 63-64, in Chapter
7, Input Specifications.

Figure 11-3 is an example of how match fields are
specified.

Processing Matching Records
Matching records for two or more files are processed in
the following manner:
• Whenever a record from the primary file matches a
record from the secondary file, the primary file is
processed first. Then the matching secondary file
record is processed. The record identifying indicator
that identifies the record type just selected is on at
the time the record is processed. This indicator is
often used to control the type of processing that
takes place.
• Whenever records from ascending files do not match,
the record having the lowest match field content is
processed first. Whenever records from descending
files do not match, the record having the highest
match field content is processed first.
• A record type that has no match field specification is
processed immediately after the record it follows.
The M R indicator is off. If this record type is first in
the file, it is processed first even if it is not in the
primary file.
• The matching of records makes it possible to enter
data from primary records into their matching
secondary records because the primary record is
processed before the matching secondary record.
However, the transfer of data from secondary records
to matching primary records can be done only when
look-ahead fields are specified (see Look-Ahead Fields
under Columns 19-20 in Ch~ptcr 7, Input
Specifications).
Figures 11-4 and 11-5 show how records from three
disk files are selected for processing.
Match Fields

11-3

Input Specifications
Record Identification Codes

I

-

1

3

Filename

Line

Field
Indicators

Field Location

2

Field Name

g
Position

Position

Zero

From

Position

To

Plus

Blank

i§Jii
3

4

5

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 2324 25 2627 28293031 323334 35 363738 3940414243 44454647 48 49 5051 52 53 54 55 56 57 58 59 6061 62 636465666768 697071 72 73 74

1M~S IrER

o 1
o

6

2

IAA

011

I

o 3I

I

I
I

o 4!

I

i

o 5

I

o 6

I

I

I

I

81
o i 91

I

I

I

I

1Lo

I

o

I

~!e

I
,
I

I

i

1: 21

I!

I

1 i3 !
1 14 i

I

!

15

I

:

I

17

I

bll
Ii
i

i

I

i

I

i

,

i

!

~3

i
I

I

i

!

I

' I i

;

!

I

I

I
i I

II

1

I

315 D'E PIT

i~

115

i ~I

12~

11~

I

~q

I !

I

I~

I

1I b

! I

I

5

i11~

IlIfi r--hjli

i

i i

i21a

i

!

I
I

11~

IZIt:;

i

I ,
I
I

I

EMip [LiNe

I

i

I

!

CT

I

I

I

i

~11

I

I

I

I

I

l5

25 PiA ~IR lAir
l3~ I ,,~ 1)1- \IS ON

I

~5

I

I
111

!

11~

~~

,

I

i

1WEEKU't',

1 6

I
I

!

11:

IQS CS

i

I

o 7

Minus or

I

I

I

'2~
!
!

MP LNO
'R~

,Kin

I='p \ I
nil \I Se>!N
i

Mi1
!

MJ3

i

"~

I

~

M12.

IK~

I

E'(t1 'P,UN~

1:"ISiO~
I

~

I

I

1

I

Ifi
E,P
....

I

I

I

ii

IIW'oo

Ml1.
"'3
112

,

I

!

I
!

i
i

,

Figure 11-2. Match Fields

Three record types are used in matching records. All

The three match fields in each record type are combined

record types have three match fields specified, and all
use the same values (M 1, M2, M3) to indicate which

and treated as one match field organized as follows:

fields must match. The

MR indicator turns on only if all

DIVSON

DEPT

EMPLNO

M3

M2

M1

three match fields in either of the record types from the
MASTE R file are the same as all three fields from the
record in the WEEKLY file.
The order in which the fields are specified by the input
specifications does not affect the organization of the
match fields in the computer.

11-4

Multifile Processing

i

I

:

File Description Specifications
File Type

F

File Addition/Unordered

Mode of Processing

Extent Exit
for DAM

Length of Key Field or

File Designation

r--

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Blocl<.
Length

Record
Length

2:

e

4

5

o 6

6

7

8

9

II

F

10"

!

Number of Extents

Tape

Option

UJ

I

IIi

II

I

I

I

i

I

II

I

I

I

Z

-

~

Entry

121314 15 1617 1819 2021222374252627282930 31 32333435363138]940414243444546 4148495051525354 55 56 57 5859

I

Condition
Ul·U8

Continuation Lines

~

Startll19
Location

~

Stor3ge Index

-5

~Overfl~~
~ t
Key Field ~

::t' ~
j

Device

UJ

Nor Additional Area

Line

Symbolic

Device

Type of File
Organization

File Format

Number of Tracks
tor Cyllf1cler Overflow

Name of
Label Exit

606162636465 666768697071727374

II

Input Specifications

I

-

!

~

Line

4

~
5

6

8

9
0

RY

o ~u

Z

~

lllR 51 sf ~IAle

~3

j

181c

(f)lJ

lL ciS

~

I~ It'e SIEC
I

1 3

I

1 4

I
I
I

1 6

eH

.L CIP

1 2

5

u is

~

gj2,

1 1

I

~

~

Position

laB

I
I
I
IF
I
I
I
I

1

~o ~
- N :;;

'J.1I'

3

o

Position

J. CP

o
o
o
o
o
o

8

To

RPG
Field Name

il

~J.

I

7

From
-.;

"C

~

3

~A

I .... JlrL 1M~

2

6

'g

0

~

2

1

~

Position

U

g

0

~

~§~

~~

M~

",Co

Data Structure
Occurs
n Times

~
~

.!:!"ii

"§
u

~6

g

Length

"

:2-G
u..u:::
.S g

j

-5

:~

Zero
Plu!

Minus or
Blank

9 10 11 12 13 14 1516 17 18 1920 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4142 43 44 45 46 47 46 49 5u 51 52 53 54 55 56 57 58 5960 61 62 63 64 65 66 67 66 69 70 71 72 73 74

o

4

~

-;;,'"
00

o R §
~Nto Z

Field
Indicators

Field Location
Record Identification Codes

gw'":): ~.~
.8~

Data
7

0 1

5

~

i

:::0
Structure
Name

3

External Field Name

0

Filename
or
Record Name

CS

Ir

2

3 IfIA rcl~

2

3 INoJej

~

3

~

l3 HalM

~

l3 I1A'rTCI1

2.

l3 "oiM

~NC

c

IA~

~~

lL

~rr

'r],IIC

81

~I'

J.

!f'7

~

c:
'-'-'-'-

~A

r c.1J4

III

~a.

~lL

.,

Figure 11·3. Match Field Specifications for Three Disk Files

Match Fields

11·5

I pip I :a I :0 I :a I :0 I P I :0 I :0 I Primary file
o

0

0

S

S

S

S

S

20

30

30

60

® ®

®

® ®

®

No match field

~

S

S

S

S

70

80

80

First secondary file

CD CD CD CD ® ® ® ® ®

Match field

~

T

T

T

T

10

30

50

50

T

T

T

T

60

80

80

Second secondary file

CD ® ® ® ® ® ® ®
The records from the three disk files are selected
in the order indicated by the circled numbers.
Figure 11-4 (Part 1 of 2). Normal Record Selection from Three Disk File!;

(

11-6

Multifile Processing

\

File Processed

I ndicators On

Reason for Record Selection

PRIMARY

02

No match field specified

2

PRIMARY

02

No match field specified

3

FIRSTSEC

04

No match field specified

4

SEC SEC

05

Second secondary low
No primary match

5

PRIMARY

01, MR

Primary matches first secondary

6

PRIMARY

01, MR

Primary matches first secondary

7

FIRST SEC

03, MR

First secondary matches primary

8

FI RST SEC

03

First secondary low
No primary match

9

FI RST SEC

03

First secondary low
No primary match

10

SEC SEC

05

Second secondary low
No primary match

11

PRIMARY

01

Primary low
No secondary match

12

PRIMARY

01, MR

Primary matches second secondary

13

PRIMARY

02

No match field specified

14

SEC SEC

05, MR

Second secondary matches primary

15

SEC SEC

05, MR

Second secondary matches primary

16

SEC SEC

06

No match field specified

17

PRIMARY

01, MR

Primary matches both secondary files

18

FI RST SEC

03, MR

First secondary matches primary

19

FIRST SEC

04

No match field specified

20

SEC SEC'

05, MR

Second secondary matches primary

21

FIRST SEC

03

First secondary low
No primary match

22

PRIMARY

01, MR

Primary matches both secondary files

23

FIRST SEC

03, MR

First secondary matches primary

24

FIRST SEC

03, MR

First secondary matches primary

25

SEC SEC

05, MR

Second secondary matches primary

26

SEC SEC

05, MR

i

Second secondary matches primary

Figure 11-4 (Part 2 of 2). Normal Record Selection from Three Disk Files

Match Fields

11-7

Step
1

Step
2

DDD
DDD

4

Step

5

DDD
DDD

Figure 11-5 (Part 1 of 2). Normal Record Selection from Three Disk Files

11-8

The next P record is read. It contains no match field and comes
from the primary file, so the new
P record is also selected for processing before the S record.

The next P record read has a
match field. The S record has
no match field, so it is selected
for processing.

Step
3

Step

The first record from each file is
read. The P and S records have no
match field, so they are processed
before the T record that has a
match field. Because the P record
comes from the primary file, it is
selected for processing first.

Multifile Processing

The next S record is read. All
three records have match fields.
Because the value in the match
field of the T record is lower·
than the value in the other two,
the T record is selected for
processing.

The next T record is read. The
match ing P and S records both have
the low match field value, so they
are processed before the T record.
Because the match ing P record
comes from the primary file, it is
selected for processing first.

(

\

Step
7

Step
B

Step
9

Step
10

DDD
DDD
DDD
[]DD
DDD

The next P record is read. Because it
contains the same match field and
comes from the primary file, the new
P record is selected instead of the S
record.

The next P record is read. The value
of the match field in the S record is
the lowest of the three, so the S
record is selected for processing.

The next S record is read. Because
the Sand T records match and have the
lowest match field, they are selected
before the P record. Because the S
record comes from the first secondary
file, it is selected for processing before
the T record.

The next S record is read. Because it
also has the same match field as the
S record just selected, it too is selected before the T record.

The next S record is read. The T
record contains the lowest match
field value, and is selected for
processing.

Figure 11-5 (Part 2 of 2). Normal Record Selection from Three Disk Files

Match Fields

11-9

11-10

Multifile Processing

Chapter 12. CONSOLE File Considerations

Using the CONSOLE device in an RPG II program
enables the operator to enter input to an executing
RPG II program from a display station. Display screen
prompts are automatically generated from the input
specifications to prompt the operator for data entry. As
the operator enters data in response to the prompt, the
data is displayed on the display screen. Internally the
data is placed in a buffer, which is independent of the
execution of the RPG II program. At input time of the
RPG II cycle, the program retrieves the data from the
buffer. Data for a CONSOLE file can be entered anytime
during the RPG II cycle. The operator indicates a normal
end of input (end-of-file condition) to the CONSOLE file
by pressing command key 12, that is, the Cmd and =
(equal) keys.

RESTRICTIONS FOR USING A CONSOLE FILE
The following restrictions apply to the use of a
CONSOLE file:

WHEN USED WITH KEYBORD/CRT DEVICE
Both device names CONSOLE and KEYBORD refer to a
display station, that is, a keyboard and a display screen.
When the device KEYBORD is specified in the same
program as the device CONSOLE and the operator is
entering data for the CONSOLE file, the following occurs
when the program encounters a KEY or SET operation
for the KEYBORD file:
• The operator is required to complete data entry for
the current record for the CONSOLE file.
• The prompt for the SET or KEY operation, or the
output to the CRT file, is then displayed on the
display screen. Normal RPG II processing continues
after the SET or KEY operation is completed. The
display screen and keyboard are reenabled for input
to the CONSOLE file when the RPG II program
begins processing the saved record during the next
input cycle.

• Only one CONSOLE file is allowed per program.
• Only one display station is associated with the
program; therefore, prompting for input to the
program is directed to the display station that loaded
the program or that is assigned to the program by
the WORKSTN OCL statement.
• If a program contains a WORKSTN file, it cannot
contain a CONSOLE, KEYBORD, or CRT file.
• The maximum number of record types that can be
used for a CONSOLE file is 10.
• The maximum record length is 1,518 characters.
• The maximum alphameric field length is 66
characters.

AUTOMATIC GENERATION OF DISPLAY SCREEN
FORMATS
When a program includes a CONSOLE device and the
RPG command is used to compile the program, the
RPG II format generator (RPGR) uses the input
specifications to generate source input to the screen
format generator (the $SFGR utility program of the
system support program product). The screen format
generator compiles this source input and generates a
display screen format load member for the program. The
source input to $SFGR is not saved when the RPG
command is used. To save the source input, specify the
NOGEN parameter on the RPG command statement.
The RPGR procedure can be called separately to
generate the source input for the $SFGR utility program,
which is then called to generate a display screen format
load member for the CONSOLE file.

• The maximum numeric field length is 15 characters.
• The maximum number of input fields that can be
displayed on the screen is 80.

Restrictions For Using a CONSOLE File

12-1

To execute an RPG program containing a CONSOLE
device from a display station with a 960-character
display screen, specify the GEN960 parameter on the
RPG or AUTO command statement. GEN960 indicates
that the screen formats for the CONSOLE file will be
generated for a 12-line, 960-character screen.
See Chapter 18, Compiling and Executing RPG II
Programs, for a description of the RPG and RPGR
command statements. For a complete description of the
$SFGR utility program, see the System Support
Reference Manual.
RPG II forms the name of this source member and load
member by adding FM to the RPG II program name
given in columns 75 through 80 of the control
specifications at the time of compilation. Therefore, the
format name cannot be changed after compilation. For
example, if the name of the program is PRNAM E, the
name of the display screen format source member and
load member for that program is PRNAMEFM.
If multiple formats are generated for the same program,
the record identifying indicator is appended to the
program name to distinguish each distinct format in the
program. For example, if the program PRNAME
contains the three record types with the indicators 01,
02, and 03 specifying the record types, the display
format names generated are:
PRNAMEFM
PRNAME01
PRNAME02
PRNAME03
PRNAMEFM is the name by which the set of display
formats is referenced in the library, and PRNAME01,
PRNAME02, and PRNAME03 are the names of the
actual display screen format members of the set.
If OR lines are used on the input specifications to
identify the same record, only one format is associated
with the record.
When CONSOLE is used as a record address file to
provide keys for a limits file, FM is added to the
program name to form the name of the display screen
format source and load members.

12-2

CONSOLE File Considerations

Display Format

The top line on the display screen contains control
information that is used by the operator to identify the
current record and to specify the next record type to be
prompted (see Figure 12-1). The remaining 11 or 23 lines
are used for the formatted record. For each field defined,
14 characters are reserved to contain the field name and
its attributes. Therefore, the record length is limited to
1,518 characters. The format generated for a record
depends on the size and number of fields in the record.
The possible formats are:
• One column: The one-column format is generated
whenever the number of fields prompted for is less
than 12 or 24.
• Two columns: The two-column format is generated
whenever the number of fields is equal to or greater
than 12 or 24 and less than or equal to 22 or 46 (see
Figure 12-2). If any field length in the record
exceeds 26 characters, the screen format is altered to
handle these fields.
• Three columns: The three-column format is generated
whenever the number of fields is greater than 22 or
46 and less than or equal to 33 or 69 (see Figure
12-2). If any field length in the record exceeds 12
characters, the format is altered to allow these fields.
•

Four columns: The four-column format occurs
whenever the number of fields is greater than 33 or
69 and less than or equal to 44 or 80 (see Figure
12-2). If any field length in the record exceeds 6
characters, the format is altered to allow these fields.
If the format is altered so that the four-column
format is invalid, an error message is issued. If an
error message is issued, you must reduce the number
of fields in the record or change the order of the
fields. Remember that all fields for the record must
fit on one display screen format.

Record identification code
for record being prompted
(columns 21 through 27 of
the input specifications)

Record identifying indicator
for record being prompted
(columns 19 and 20 of the
input specifications)

Record identifying indicators for other record
types that can be selected before data is entered

Record identifying indicators for other record
types that can be selected after data is entered

using the current forma/ using the current format

;/

M

/

1

1,2,3,4

7

1,2,3,4

5

Display station field
control character
for prompt, which
appears as a blank

Field name (1 to 6 characters) from columns
53 through 58 of the
input specifications

Type of fieldalphameric (A) or
numeric (N)
(column 52 of
the input specifi. cations)

Field length
(columns 44
through 51
of the input
specifications)

Display station field
control character for
this input field which
appears as a blank

Figure 12-1. Display Generated for the CONSOLE File

Automatic Generation of Display Screen Formats

12-3

Two-Column Format

M
CUSTNO

NAME
ADDR1
ADDR3
STATE

1
A
A
A
A
A

1,2,3,4

5
30
20
2:>
20

PHONE

A

1,2,3,4
11

ADDR2
CITY
ZIP

A
A
A

20
25
5

Three-Column Format

M
ACCTNO
SLSMAN
DIST
CITYST

1
A
A
A
A

1,2,3,4
DISCNT N 3_3

5
40
3
20

REGION A

1,2,3,4
COST

N10.2

4

ZIP

A

5

Four-Column Format

M
ACCTNO A
5
SALES NIO.2

1

1,2,3,4

1,2,3,4
DIST

A

REGION A

TOTAL

3

DISCNT N 4.4

N15.2

Figure 12-2. Display Screen Formats Generated by the $SFGR Utility Program

12-4

CONsoLE File Considerations

Prompt Format

File Description Specifications

The prompts, which are generated from the field names
on the input specifications, are 14 positions long and
have the following format:

Entries for the columns not included in the following list
are described in Chapter 3, File Description
Specifications.

Position

Explanation
Display station field control
character for the prompt, which
appears as a blank.

2-7

Field name.

8

Blank.

9

N for a numeric field or A for an
alphameric field.

10-13

Length of field. For an alphameric
field, positions 10 and 11 are blank
and positions 12 and 13 contain the
length. For a numeric field, positions
10 and 11 contain the length of the
field, position 12 contains a decimal
point, and position 13 indicates the
number of decimal positions in
the field.

14

Display station field control
character for the input field,
which appears as a blank.

Altering the Display Screen Format
Once the RPG II format generator has generated the
source input for the screen format generator and the
input has been cataloged in the library, you can alter this
source input, if desired, by using SEU (see the SEU
Reference Manual) and the FORMAT procedure (see the
System Support Reference Manual). See RPGR Command
Statement in Chapter 18 for an explanation of how to
save the source input.

Column 15: Enter an I in this column to specify this file
as an input file.

Column 16: Enter a P (primary), S (secondary), D
(demand), or R (record address) as the file designation.

Column 17: Leave this column blank if the program can
end whether or not all records from the file have been
processed, or enter an E if all records from the file must
be processed before the program can end. If this
column is blank for all files in the program, all records
from every file must be processed before the program
can end. For a CONSOLE file, the operator indicates a
normal end of file by pressing command key 12, that is,
the Cmd and = (equal) keys.

Columns 20-23: The entry for block length must either
equal the record length entered in columns 24 through
27 or be blank.

Columns 24-27: The record length is defined as the
highest to-field location specified on the input
specifications. This record length cannot be less than 2
or greater than 1,518. If the CONSOLE file is
designated as a record address file, determine the
record length by multiplying the length of the record
address field by 2. This record length cannot be less
than 2 or greater than 58.

Column 28:

Leave this column blank.

SPECIFICATIONS FOR A CONSOLE FILE
To use the CONSOLE file in a program, you must enter
certain codes .on the file description specifications and
the input specifications.

Columns 29-30: These columns must be blank if
column 16 contains a P, S, or D. If column 16 contains
an R, enter the length (1 to 29) of the record key.

Specifications for a CONSOLE File

12-5

Column 31: Use this column only for record address
files. Leave the column blank if the keys in the record
address file are the same as the keys in the index file~
Enter an A for an indexed file with zoned decimal keys.

Columns 32-38:

Leave these columns blank.

Columns 21-34: Position 1 or positions 1 and 2 of
each record in the CONSOLE file must contain a record
identification code to identify which record was keyed.
The 1- or 2-character code specified in these columns
is automatically inserted into each new record when it is
prompted.

The rules for coding columns 21 through 34 are:
• Columns 21-23: Leave these columns blank.

Column 39: Leave this column blank if column 16
contains a P, S, or D. If column 16 contains an R for
record address file, this column must contain an E.

• Column 24: Enter the number 1.
• Column 25: Leave this column blank;
• Column 26: Enter a C in this column.

Columns 40-46: Enter CONSOLE as the device name.
The file can be an input data file or a record address
file. There can be only one CONSOLE file in a program.

Input Specifications

File and Record Identification Specifications

Entries for the columns not included in the following list
are described in Chapter 7, Input Specifications.

Columns 14-16: These columns must not contain the
characters AND; however, columns 14 and 15 can
contain the characters OR. These OR lines can be used
to indicate a relationship between record identifying
indicators or, record types. If column$ 14 and 15 contain
OR, the same number of record identification codes
must be described on this specification line as are
described on the preceding line.

Columns 15-18: RPG II uses the entries from columns
15 and 16 (sequence), column 17 (number), and column
18 (option) to determine which record types are
allowable alternatives to the default record type (those
record types that can be selected before data is entered
for the record type currently displayed) and which record
types are valid after data is entered for the record type
currently displayed. RPG II inserts the valid before and
after record types in the top line of the'display format
generated for a CONSOLE file (see Figure 12-1).

Columns 19-20: Enter a record identifying indicator (01
to 10) to define the command key the operator enters
to select this record type. The same indicator cannot be
used to define more than one record type within the
input specifications for one program.

12-6

CONSOLE File Considerations

• Column 27: Enter the alphabetic character, special
character, or digit that is present in position 1 of the
input record.
• Columns 28-34: If a 1-character record identification
code is used, leave these columns blank. If a
2-character record identification code is used, code
these columns the same as columns 21 through 27,
except that column 31 must contain the number 2 to
indicate record position 2.

Columns 35-74:

Leave these columns blank.

Field Specifications

Entries for the columns not included in the following list
are described in Chapter 7, Input Specifications.

Columns 14-16: AND lines are not allowed for
CONSOLE file records.

Columns 53-58: Enter a descriptive field name (1 t06
alphameric characters) to be used as a prompt for this
data. To enter data into a whole array for a CONSOLE
file, define the whole array as a subfield within a field of
the CONSOLE file record or define each element of the
array with an index and place this entry in columns 53
through 58. The index must be an integer value.

Columns 59-60: If this is a primary or secondary file, a
control level indicator (L 1 through L9) can be entered to
indicate that a control break occurs on a change in the
field's contents.

Columns 61-62: If this is a primary or secondary file, a
match field value (M1 to M9) can be entered to indicate
a match field. Otherwise, leave these columns blank.

When describing the fields in a CONSOLE file record,
remember the following considerations:
• The maximum alphameric field length is 66
characters.
• The maximum numeric field length is 15 digits.
• The maximum record length is 1,518 characters.
• Subfields can be specified within the fields of a
CONSOLE file record. The from and to field locations
for subfields must not overlap the from and to field
locations for another field. Subfields are not
prompted for, but are assigned values from the
prompted field and can be used in calculation and
output specifications. In Figure 12-3, the part
number 01 ROC43CP843987831 is entered in
response to the prompt field PARTNO. LOCATN,
WHSE, BIN, ASMTP, and NUMBER are subfields
within the PARTNO field. The values for the
subfields are extracted from the PARTNO field.

Erasing the CONSOLE File Buffer
To erase, or blank, the entire CONSOLE file buffer, use
the ERASE function with the SET operation code in the
calculation specifications. You must enter the operation
code SET in columns 28 through 30, the filename of the
CONSOLE file in columns 33 through 42, and ERASE in
columns 43 through 47. ERASE indicates to the system
that the buffer is to be set to blanks just before the
program reads a record at the beginning of the next
RPG II cycle.
Because the buffer is not erased until the beginning of
the next RPG II cycle, processing of the current record
continues after the ERASE operation is encountered. If
the ERASE operation is executed because of invalid
input data, you should insert code in your program to
avoid further calculations and to return to the start of
the RPG II cycle. A correct form of the record
containing invalid input data and any records that were
entered after that record can then be reentered.

Specifications for a CONSOLE File

12·7

File Description Specifications
Fde Type

F

-

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or

File Designation

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Type of Fde
Organization
:-.. or Additional Area

File Format

~

'" I

~

~

BlOCK

Record

Length

Length

67'

8

9

1C 11 , 2 , 3

,~

15

ic

~ ~

...J

Location

(

\

Number of Extents
Tape

~

Storage' n dex

_

~OVerfl~~
~~
~t:~t;~:ld ~

a:

~Iw ~ ~

Nameof
Label Exit

Symbolic
Device

Device

Number of Tracks
for Cyl i f1cier Overflow

Condition
Ul.~

Continuation Lines
Option

W

i'O

~

Entry

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 :!9 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

Input Specifications
Record Identification Codes

I

-

_~. .J'

-

~~

~

Filename

Line

__~:

:iI

1

o

2

~

Position

E

_

Position

_

E

Position

_

~~ §

ITRAN.sAC.T

~l !

I

'-j-

2

I

~

'-

-.,.

-t-I-+-----+--+-f-t---j---,--~t-+/

f-0_4-+-Il---_ _ _
C 5

+---+-+-+---+---~
. ..-f I

I

7

I

o

8

I

o

9

I

I

1____

g. '"

To

;0 "

I I I:
:1 1 2

,!:E

Record ~ ~<
Identification ~I-+--+-+---+-+-+-+-vh'.'- 110

I

o

Vi

j
~ -E ~
iZ ~ . .

"

"

"

"

"

"

: i I!

t.O'D~:

"

J.

IWt\S~!

q tp,IN

·11 ~5,M"'~

~

Zero
Plus Minus or

,,1.. ,:: "!,, '" '" " '" ::':: " " " "
I

3 2 rt. PAR THO X
-~, ~. q IL~T:N :'\~
L,.--........

1-0-3

Frolll

« " " ., " .,

C~

-. .J~

Field Name

~ ,,,"" ",,~Ni :",; """"'1":eli::'" '" ""~ ::""i!"'" :!~ ~ :

34

o

Field
Indicators

Field Location

I

I I!

!

I

!'\

t

!

i

I

i

Prompted
Fields

I

----I

--

Prompted Field: PARTNO
01 R0C43CP843987831
Subfields:
LOCATN:
WHSE:

LQ!J
I ROC I

Lm

BIN:
ASMTP:

~

NUMBER:

1 8439878311

Figure 12-3. Specifying Subfields for a CONSOLE File

(
"
12-8

CONSOLE File Considerations

Chapter 13. WORKSTN File Considerations and Sample Programs

The WORKSTN file allows concurrent entry of data from
one or more devices attached to an executing RPG II
program. The devices that can be attached to a
WORKSTN file are display stations and SSP-ICF
sessions. The number of devices that can be attached
to a WORKSTN file is dependent on the value
associated with the NUM continuation line option (for
more information, see Continuation Line Options under
File Description Specifications in this chapter).
WORKSTN can be specified as the input/output device
if you use the display screen format specifications to
define the display screen format. These specifications
must then be compiled by the $SFGR utility program of
the system support program product. Input and output
fields, as well as the indicators that control the
attributes of these fields, are defined on the display
screen format specifications. The RPG II input and
output specifications must relate input and output fields
to the fields in the order defined on the display screen
format specifications. The indicators defined on the
display screen format specifications are controlled by
the RPG II program. For a complete description of the
$SFGR utility program, see the System Support
Reference Manual.
A WORKSTN file must be specified when the Interactive
Communications Feature (SSP-ICF) is used. The
WORKSTN file requires no special coding when it is
used for SSP-ICF. The file description entries are the
same as those for a WORKSTN file that allows an RPG
program to communicate with a display station. In this
chapter, a device can be either a display station or an
SSP-ICF session. For further information on SSP-ICF,
see the Interactive Communications Feature Reference
Manual.

PROGRAM ATTRIBUTES
When a WORKSTN file is specified, an RPG II program
can be coded to support one device or multiple devices.
The supported devices can be either acquired devices or
requestor devices. A requestor is defined as the device
that calls, or requests, the RPG II program. A program
that allows only one requestor is called an SRT (single
requestor terminal) program, and a program that allows
multiple requestors is called an MRT (multiple requestor
terminal) program.
The SRT and MRT attributes, which are assigned to a
program on the COMPILE OCl statement, are external
to the RPG II program. To change an SRT program to
an MRT program, you must recompile the program and
specify a value for the MRTMAX parameter. MRTMAX
specifies the number of requestors that can be attached
to the program. You must also add the NUM keyword
on a continuation line for the WORKSTN file description
specifications. NUM specifies the maximum number of
devices that can be attached to the WORKSTN file at
anyone time. NUM must be equal to the MRTMAX
value plus the maximum number of nonrequestor
devices to be attached to the file at anyone time.
For a more complete description of the SRT and MRT
program attributes, see the System Support Reference
Manual.

Note: WORKSTN file processing is the same whether
display stations or SSP-ICF sessions are attached to the
file. Therefore, you should have a thorough
understanding of WORKSTN file processing before
attempting to use the Interactive Communications
Feature.

Program Attributes

13-1

SRT (Single ~eque5tor Terminal) Program

An SRT program is specified if the COMPilE OCl
statement does not include an MRTMAX parameter
when the program is compiled. Although an SRT
program allows only one requestor per program, more
than one device can execute the program concurrently.
In this situation, the system support program product
loads and initiates a separate copy of the program for
each requesting device.
An SRT program can have multiple devices attached to
it during execution. In this situation, the requestor calls
the program, and other devices are acquired for the
program by use of the WORKSTN OCl statement or the
ACQ operation code. A display station can be acquired
if it is not attached to an executing program and if it is
not in command mode. An SSP-ICF session can be
acquired if it is not already attached as a requestor. A
device acquired by the WORKSTN OCl statement or by
the ACQ operation code can be released from the
program by the REl operation code or by an R entry in
column 16 of the output specifications.

When using the SRT program attribute, keep the
following in mind:
• If the program is called by more than one requestor,
each requestor has a separate copy of the program
executing concurrently.
• The requestor provides the external indicators (U 1
through U8).
• The requestor provides the display station local data
area for the data structure defined by a U in column
18 of the input specifications.
• Program error messages go to the requestor.
• The program, including any acquired devices, is
suspended via inquiry.

The NUM keyword is required on a file description
specifications continuation line for an SRT program that
contains any acquired dev,ices. The NUM keyword for
an SRT must specify a value greater than or equal to
the number of nonrequestor devices plus one (for the
single requestor).

(
13-2

WORKSTN Fi:e Considerations and Sample Programs

MRT (Multiple Requestor Terminal) Program

An M RT program is specified by the M RTMAX
parameter on the COMPilE OCl statement. The value
specified on the M RTMAX parameter limits the number
of requesting devices that the program can process
concurrently. An MRTMAX value of one is valid and
means that only one device can request the program
and that multiple copies of that program are not initiated
when more than one requestor uses the same procedure
to call the MRT program.

Note: Ordinarily different MRT procedures should not
call the same MRT program because more than one'
copy of the MRT program could be in storage at the
same time.
Each requestor of an MRT program is attached to the
same program during execution. The first requestor of
an M RT program causes the program to be loaded and
initiated. Each succeeding requestor of an MRT
program attaches to the executing program at the
beginning of an input cycle or when a READ operation
code is issued to the WORKSTN file. If the program is
handling the maximum number of requestors (specified
by the MRTMAX parameter). the next requestor of the
program is queued by the system support program
product. When the program releases one of its
requestors, the program can process the queued
request.

When using the M RT program attribute, keep the
following in mind:
• If the program is called by more than one requestor,
the first requestor:
- Causes the program to be initiated
Provides external indicators (U1 through U8)
Provides the display station local data area for the
data structure defined by a U in column 18 of the
input specifications
• Each succeeding requestor after the first becomes
attached to the program at input time for primary
files or upon execution of a READ operation code to
the WORKSTN file.
• Program error messages go to the system console
operator.
• Requestors may leave the program without
suspending the program or other devices.
• The display station local data area and external
indicators can be made available to the program for
each requestor if you use SUBR20 and SUBR21.
• When inquiry is used in an MRT program, the
processing of information from the display station
requesting the interrupt is suspended. However, the
program continues to process information from other
program-requesting devices.

Program Attributes

13-3

ATTACHING A DEVICE TO A PROGRAM

WORKSTN FILE INPUT PROCESSING

A display station or SSP-ICF session can be attached to
an RPG II program in one of two ways:

Figure 13-1 shows the RPG II program logic cycle and
the steps that are affected by WORKSTN file input
processing. All steps in the cycle except steps 1, 3, 11
through 13, and 15 are the same as those for the
regular RPG II program cycle.

• As the requestor.
• Using the ACO operation code in the calculation
operations. If the device is not available or is already
attached to the program, the indicator specified in
columns 56 and 57 is set on.
A display station can be attached to an RPG II program
in two additional ways:
• The procedure that is called to execute the RPG II
program includes a WORKSTN OCl statement with
the parameter REOD- YES. The display station is
attached to the program by the system support
program product and must be available for the
program to be initiated.
• The procedure that calls the RPG II program contains
a WORKSTN OCl statement with the parameter
REOD-NO. RPG II attempts to acquire the display
station during startup processing (see Figure 13-2). If
the acquire attempt fails, the display station is
deleted from the file.
If a WORKSTN program is initiated from the input job
queue, a device must be attached either by an OCl
statement or by the ACO operation code. If the device
is not attached by one of these methods, unexpected
results can occur.
Note: A display station is available if it is not attached
to any executing program and if it is not in command
mode. An SSP-ICF session is available if it is not
attached to any executing program.

13-4

WOR KSTN File Considerations and Sample Programs

1 P output to a WORKSTN file is' not allowed ..
Step 1

0WORKSTN input processing can include:

o

Saving the common IND/SAVDS area in the IND/SAVDS
area for the device from which the last input record was read
(if specified).

•

Getting the display station record. If the display station is
new to the file, the record may be blank. Only the last
input-capable display screen format can be read into the
program.

•

Restoring the IN D/SA VDS area of the device from which the
last input record was read (if specifiedl.

•

Inserting value into ID field (if specified).

Step 2

Step 3

Step 4

For a detailed explanation of WORKSTN input processing, see
Figure 13-2 for an expansion of step 3.

Step 6
Step 5
Turn on record
identifying
indicator

SetonL1-L9
and LR

Data keyed at a display station is returned (input) to the RPG II
program for processing when the operator presses a command
key or the Enter/Rec Adv key. The operator can also cause the
data to return to the program by pressing the Field Exit, Field +,
or Field -key if the last input field in the format is defined as
an auto record advance field (column 36 of the D specification).

Step 7

4
V

Step 8
Do total
calculations

All command key indicators are turned off; then the appropriate
one, if any, is turned on.

Note: If an exception/error occurs on the read, the command
key indicators are not reset.
Step 9

If the READ operation code is used, it combines steps 3, 5, 11,
12, 13, and 14. If the EXePT operation code is specified, it
uses the I D field to direct output to the display station whose
ID is contained in the field.

Perform
total output

Step 10

e

Step 11
Set off KA-KN.
KP-KY
Step 13
Step 12
Yes

Step 14

Set on correspond·
ing command key
indicator

Make data from
record just read
available for
processing

E)

Step 15
Do all detail
calculations

Figure 13-1. RPG II Program Logic Cycle With a WORKSTN File

WORKSTN File Input Processing

13-5

Step 3 of Figure 13-1, which is the WORKSTN input
processing step, is expanded and shown in Figure 13-2.
The following explanations refer to the steps shown in
Figure 13-2.
Step 3-1. RPG determines whether the IND and/or
SAVDS continuation line option is specified
on the file description specifications for this
file. If neither option is specified, RPG goes
to step 3-3.
Step 3-2. If the IND and/or SAVDS option is specified,
RPG moves the common IND/SAVDS area
to the IND/SAVDS area for the device from
which the last input record was read.
Step 3-3. RPG determines whether this is the first cycle
for the first requestor of the program. If it is,
RPG goes to step 3-10. All requestors of
the program except the first enter the
program at step 3-10.
Step 3-4. If the device is not a requestor, RPG
determines whether all devices in the internal
device table have been started. If all are
started, the program goes to step 3-10.
A device is started when it has been
acquired and a successful input or output
operation has been executed. If a device is
acquired via the ACQ operation code, the
device is not considered to be started unless
output is sent to the device in the same
cycle.

Step 3- 7. If the display station has not been acquired,
RPG calls work station data management to
acquire the display station.
Step 3-8. RPG determines whether the acquire was
successful. If it was not successful, RPG
goes back to step 3-5.
Step 3-9. If the device is acquired, RPG creates a
first-time blank record to satisfy the first
read t'o the device. RPG then goes to step
3-11.
Step 3-10. RPG reads in the record from the device.
Remember that all requestors of the program
except the first enter the program at this
'point.
Step 3-11. RPG determines whether WORKSTN input is
available. If it is not, end of file has been
reached.
Step 3-12. RPG determines whether the IND and/or
SAVDS continuation line option is specified
on the file description specifications for this
file. If an option is not specified, RPGgoes
to step 3-14.
Step 3-13. If the IN D and / or SAVDS option is
specified, RPG moves the IND/SAVDS area
for the device that satisfied the read to the
common IND/SAVDS area.

Step 3-5. If not all devices have been started, RPG
locates a device that has not been started.

Step 3-14. RPG inserts the device I D of the device that
satisfied the read into the I D field if the I D
continuation line option is specified on the
file description specifications.

Step 3-6. If the device located is a display station, RPG
determines whether it has been acquired.

After the WORKSTN input file processing, RPG goes to
step 4 as shown in Figure 13-1.

13-6

WORKSTN File Considerations and Sample Programs'

Locate a device
that has not
been started

Get a record

Yes

Step 3·2

Save
. function

Move common
IND/SAVDS
area to IND/
SAVDS area of
device from
which the last
input was read

Call work station
data management
to acquire display
station

Yes

Step 3·13

Restore
function

Move IND/
SAVDS area of
device satisfying
this read to
common IND/
SAVDSarea

Create a
first·time
blank record

e

Step 3·14
Insert device ID
into ID field

o
e

One RPG cycle is used to start each nonrequestor, which is a device
that has been acquired by the OCl statement II WORKSTN or by
the RPG operation code ACO. RPG checks each nonrequestor to
see if an input or output operation to the device has previously
been specified. If it has not, RPG physically acquires the device
if necessary and creates a blank record to satisfy the first read.

CD

End of file occurs for a WORKSTN file at the time of the read if:
•

All devices have been released.

•

Input is not allowed from any of the attached display
stations because:
A new format has not been displayed at the display
station since data was last keyed.
Suppress input-yes is specified in column 35 of the S
specification for the format currently displayed and no
input-capable formats are concurrently displayed
at the display station.

•

The program is an N EP, if all devices have been released, and
if the operator has entered a STOP SYSTEM command.

All requestors of the program except the first enter the program
at this step.

Figure 13-2_ WORKSTN File Input Processing

eD
et

If this is the first input for this device, the indicators specified
in the IND field are off and the SAVDS field is blank.
Steps 3-5 through 3-9 occur only for non requestors.

WORKSTN File Input Processing

13-7

End-af-File Considerations
The ways in which a primary or a demand WORKSTN
file rea~hes end of file and causes the program to go to
end of job (the LR indicator is on) are described in the
following discussion. (For a description of the
end-of-job steps that occur when a read under format
is performed, see Read Under Format in this chapter.)

Primary WORKS TN File

For a primary file in a program that does not have an
NEP attribute, end of file causes RPG II to set on the LR
indicator in one of two ways.
• The LR indicator is turned on when all devices have
been released. Devices can be released from the
program in one of the following ways:
An R entry in column 16 of the output
specifications. The device is released when the
output specification is encountered during the
output operations. If a format name is specified in
the same specifications that contain an R in
column 16, the format is displayed or the
interactive communications operation is performed
and thEm the device is released.
- The REL operation code. The device specified in
factor 1 is released from the program when the
REL operation is encountered during the
calculation specifications unless the device is the
requestor of a single requestor program. If the
device specified in factor 1 is the requestor of a
single requestor program, the device is released at
end of job, not when the operation is encountered
during calculations. However, no subsequent
operations to the device are allowed.
Note: If the device is a display station, it is still available
for system log messages after it has been released.

• The LR indicator is turned on when input is not
allowed from any attached device. If the device is a
display station, input is not allowed when:
- A new format has not been displayed since data
was last keyed.
- Suppress input-yes is specified in column 35 of
the S specification for the last format displayed
and no input-capable formats are concurrently
displayed at the display station.
For information on when input is not allowed from an
SSP-leF session, see the Interactive Communications
Feature Reference Manual.

13-8

WOR KSTN File Considerations and Sample Programs

If the programmer sets on the LR indicator in this type
of program, the program goes to end of job.
.If the program has an MRT -.NEP attribute and all
devices have been released or no input-capable formats
are outstanding, end of file does not occur and RPG II
does not set on the LR indicator until the system
operator enters the STOP SYSTEM command.
However, if the programmer sets on the LR indicator,
the program goes to end of job (that is, the system
operator does not have to enter the STOP SYSTEM
command).
Note: An M RT program should not set on the LR
indicator until end-of-file is reached for the WORKSTN
file. If the LR indicator is set before end-of-file is
reached, undesirable results occur for requestors that
are in the sign on process.

Demand WORKSTN File

For a demand WORKSTN file in a program that does
not have an NEP attribute, the programmer must set on
the LR indicator. When all devices are released from a
demand WORKSTN file or no input-capable formats are
outstanding, the first READ operation after the last REL
operation causes the READ end-of-file indicator
(columns 58 and 59) to be set on. The programmer can
then set on the LR indicator or the LR indicator can be
specified as the READ end-of-file indicator.
If the program has an NEP attribute and all devices have
been released or no input-capable formats are
outstanding, the end-of-file indicator on the READ
operation is not set on until the system operator enters
a STOP SYSTEM command. However, if the
programmer sets on the LR indicator based on some
condition other than the end-of-file indicator on the
READ operation, the program goes to end of job (that
is, the system operator does not have to enter the STOP
SYSTEM command).

WRITING A PROGRAM WITH A WORKSTN FILE

You can also use the Screen Design Aid (SDA) to
interactively design the display screen formats. SDA
allows you to design the appearance and specify the
attributes of a new display screen format before the
format is generated. SDA generates the display screen
format specifications for you so you do not need to fill
out the display screen format specification sheets. You
can also specify an option of SDA that generates RPG II
specifications. The specifications generated are the
control, file description, input, and output specifications
for the WORKSTN file:

Creating a Display Screen Format
The first step in writing an RPG II program that contains
the WORKSTN device is to define the display screen
formats to be used. You can use the display screen
layout sheet (GX21-9271) as shown in Figure 13-3 to
layout all the fields as they will appear on the display
screen. You can then use the completed layout sheet as
a guide for filling out the two parts (S specifications and
D specifications) of the display screen format
specifications (GX21-9253) as shown in Figure 13-4.

• The control specifications have columns 52 and 53
(number of formats) completed.
• The file description specifications have the entries for
a WORKSTN file completed.
• The input and output specifications include the input
and output fields that correspond to the input and
output fields specified for the display screen formats.
For a complete description of SDA, see the SDA
Reference Manual.

Display Screen Layout Sheet
COLUMN

I

1-10
I
11-20
1 2 ~ 4 51nl7 S 9 0 1 21~ 41')ln 7 S191( 1

I

I

I

I

21-30
I
31-40
41-50
51-60
61-70
71-S0
I~ 4 Sin 7 819101112131415161~ISI91011121314151617 sI9101112fj141516171sT9101112f31415161718191011121314151617181910

01~~~1~~~~1~~1~~~~1~~1~~~1~~~~1~~1~~~~1~~1~~~~1~~1~~~~1~~~I~~I~~~

02~~~1~~~1~~~~1~~1~~~1~~~1~~~~1~~1~~~1~~~1~~~~1~~1~~~1~~~I~~~~I~~
03~~~1~~~1~~~~1~~1~~~1~~~1~~~~1~~1~~~1~~~1~~~~1~~1~~~1~~~I~~~~I~~
04

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

05

I ,
I. ~~.~~~~~~~~~~~~~~~~~~~~~~~.~~I~~~I~~~~I~~
1-o--,--,--,--,I--'--'--1._~-'_~_-'_..L...L~-,--,-,-l--L-.L-'
''''''~~-'--'--'-.L.I-'-'~--,-+--'--'-i.-'-'-~~-I--L--'--'--'-~~-'--+-'--'-~--'--"L....J.......L-'--I
07 I--'-.L-L.--'-.l-..L..I-,--,-~ ~1J--,--,- .
.L1_~"-.L.,+ . .L ' - , _L1. .L-L.-~ ~t .."-L~-'--'--'-..L-I--<-~..L , I , " , .L..t~.L.~..1..L.-'-L_'._~_.L...-'~--,I--,--,--"---"y

06

....t.-'-..L .. " ..

os
09

, ..........J-~'"

, I,

~,~_L.J

10

I

I

L~

!_.!.L

I

I

111-'~.L-L.-.l-..L..I--,-~,
~12~,~.-'.-'-,I,
0: 13

.1

16

--'-L

.

L~

J

.".1-'-

1 -t-1

I

~

.1.

1 l..Lu.L.1

1

1

.L

21

I

23

1

1

1 1

til

.1.

1

1

1

1 1 1

I

I

I

I

I

I

I

I

1

L".

L

j

I_LI. ~

1

I ..
I
I
I
I
.
I l L j " , L.-'--'+""'_L.~ .. L.-'._.L.-'._+.L'--I.L-L-I '---"I'-'--''---j
1...--.'

1

.~

, , ,

L.1 .

L

I

j.l

L ' . L.L..J

_I

I

22

1"'1+-,'1

L-'--'_L.-'.-f--....-..J..LL_L..L

..L-'-.-'.

~..J. .. ~-'--'--'--LJ_'.L_.L...1. . .L1

20

-'

J ., , '._'_.~ ..
~ J ., , , , ~

1'1 I ,--'-.L ..L.t-....:.~~.~.~...L...L.....L.I~~---1

~ " ~.L_--L.-'-~ ...L...J......L_Ll_,...L_L.L.~_..L_'---'---'-J..........., .~~_.L-L--'---'-..L......L.-I.L--..I......Jy
~ , '.1. .L.~~-'_ L-l._L. _L
+-'---'-...J.--'....J.I-'----'---'--'-!I--'--'........L-I-JIL.L.-~'--I
1.+ ' . J , , '-~+--'--' .~-~..L-'--1.-f---..., I 1 ' .. t I
I
I
I
I
I
, + ..L_..L-~
I .L"., ,
L.. .1 1 L I , ~ 1 1 1 I I
1
1
1
I
I
I
1

19

L . .1.

,~-,--I,

I

,I".~-'-.L...L..-'._~_"--'---'--

I

.L..>.

~ ." _-'----'--1 .L~ ~ !
~ 1 , , _'~~--'-__ -'--'--'--+-'
L

I"

t·,-'----'---'-.L--'-~-'. L..J._..L.

1S

17

I

,.t.-LI

,1'1
,

.L . ..L" ...l..L-'--L. .L_+.'-'-'----'-I'-'-'--'---'~

I" I ' I,
I I,
, I , ,_ ' I
'. ~.L' '-'---..LI--,--,-,--,y
I '-U_L~t__LJ--'-..Lj_L~_L.-'.-'--..L-LI~-,----,--+I-,----,---,--,-,·I--,--,--"---"y

..L-,_t_..L_.L...J..-'._L..L_'-'

I

.L.L..J......L--'-~~..L..-'.._L' 1
"~ ...L .~_, , ! ,_~ 1 , I ~ , , " !

141--'-.l--'_uL
f-.L-L

'

,I.....

_.L...-'...L...L.1.I_' ,--,-I--,--,-.L~..L.'

15

.L-,.L..L--'--"--'--~. .-'._~l..L.~.-'-"-'-~_L~. ....L.....L--'-.LL' L-'--t-"

I"

LJ.L.L..J. .. L-+_I

.1. •

1

1

I '

1

1

I

I

1 +1

1

I . .L

L-'.

,

1

I

.

1

.1.-'-..

I

+.1_1.

1

I

1

1
1

1

I

~--'--'--.~-'---'---'-'----'-+...J.--'.-'---'I_J--L.' ,

I

I~..L.~--'--'--_.l--..L...--'----'--'-'--'--'-I+1

.L.L--.I-

1

-'-L.-'.-L

I
~ '---.l-~.-'-

,

L

1

1

1

1

1

1

1

1

-,.1.,
1

I ,

,I

l--,--~--,--,---,----,L-L..
1..L.....L..~I--'--'--'--'-~I-'---'---'-'---1

.1-+ '

1

I

1

I

1
1
-'---'-+--'---'--'-~.....L...I.-'---'-f---'-'---'-'----'-'--'--'-'-+-'-'---'---L......JL......l-.L-....I--.~.L...J....l.~,--'-_~
I 1

I

I

1

1

L

I

I

I

1

I

I

I

I

1

1

~.~-'----'---'--'---'i-'--'--"---"'--1

1--,- ..L_~..L.....L~I~~'-'-~.1.-"-..~

24
I
1-10

I

I

,111"1",,1,,
1 1 - 2 0 1 · · 21-3-0··

1

1
I

1

1

1

1
1 1
31-40

1

1

1 , 1

I

1

1
1 1
41:"'50

1

1

1

1

1 1 1
51--60 -.-

1

T -.

I
61-70

I

-1

I
·-71-80

-

11213141516171S1910111213141516171S1910 111213141516171819101112131415161718191 0 11213141516171s19Tol112f3141516171Sf91 0111213141516171S1910111213141516171S191 0

Figure 13·3. Display Screen Layout Sheet
Writing a Program with a WORKSTN File

13·9

<·•. • • · ·•· •.•·••·•· .·.• ·• .•.
Sequence
Number

GX21·9253
UIM 050'
Printed in U.S.A.

D

System/34 Display Screen Format Specifications

'No. of sheets per pad may vary slightly.

\VsUOr>IY·

~
f-

j
1 2 3

•

5 6

:

S

!

m

I\1
Starting
Location

-1Ji

Field
Name

Sequence
Number

I - - - - - - r - - - i Field
<;
length.c
"C
E
~

f-

j
1

1/

I

2 3 4 5 6

wsu

Field Name

~~

~b

~~_

~.~
~

~

I

I.••.·

;::

~

8

~
-

~.E

~

1
-

~

o

£

~ ~ ~
~ ~ u:

.E8~

J)

~";:E

It::t

iii

z

0

~

>

~

c]

a:

::I

::J8

Reserved

~

Constant Data

c
0

....

.§

c

c:

c:

8

8,23456789,01112,3,4,5161718192021222

789,0111213"'51617'8'9202'222322526272829303'323 34 35 36 37 38 3940 41 42 ~3 44 45 46 47 48 495051 52 53 G4 55 5€ 57585960 61 626364 65 66 67 68 6970 71 72 73 74 75 76 77 787980

I

0

I

0
0
0
0
0
0
0
0
0
0
0
0
0

Notes:
The shaded columns are not used by $SFGR to
generate the screen formats to be used by an R PG II
program.
The display screen format name used in columns
7 through 14 of the S specifications must be entered
on the output specifications beginning in column 45.
The format name in the output specifications must
be enclosed in apostrophes.
Figure 13-4, Display Screen Format Specifications

13·10

i

Ii:

0

fJ

~

c

0

D

~
~

0

0

~
c

0

0

1I I I I I I I I I I I I I I I I

0

" "

cS
0 &5!~~~t~ ~ Q.loa:
a 8~ ~ ~ ~ ~ ~ 0 ~~3

6 ~f ~~ ~~~

····11

g

w ~

>

i1

I···

WORKSTN File Considerations and Sample Programs

Each field in the record must be described on the
display screen format specifications. You can specify
the following three types of fields:

In addition to specifying the type of field, you can
specify the type of data that can be contained in the
field. The types of data that can be specified are:

• An output field contains data that cannot be changed
by the operator. For a normal output operation, the
data in the field is supplied either as part of the field
definition when the format is generated or is supplied
by the RPG II program (and must be described on ,the output specifications) when the format is
displayed. Whether the output d~ta is supplied by
the field definition or by the RPG II program depends
on the status of the indicator specified in columns 23
and 24 (output data) of the D specifications. Output
data is supplied as follows:
If the indicator specified in columns 23 and 24
(output data) is on, the output data comes from
the RPG II program.
If the indicator specified in columns 23 and 24
(output data) is off, the output data comes from
the constant specified in columns 57 through 79
of the D specification. This constant is often
blanks.
For an explanation of the relationship between the
indicator in columns 23 and 24 (output data) and
the indicator in columns 33 and 34 (override fields)
of the S specification, see Overriding Fields in a
Format in this' chapter.

• Alphabetic only

• An input field is a field on the display reserved for
keyboard entry. Data for the field is entered by the
display station operator. This field type is described
in RPG II on the input specifications.
• An output/input field is both displayed (output) on the
screen and read (input) back into the program. This
field type is described in RPG II on both the input
and output specifications.
All three types of fields can be used in the same display
screen format.

• Numeric only. If special characters are entered in an
N-type field, the data read by the RPG program may
not be as expected. The program uses only the digit
portion of characters entered in an N-type field. The
zone portion is forced to hex F, except for the sign
position (see Zoned Decimal Format in Chapter 7).
• Alphameric
• Signed numeric (the last position of the field is
reserved for a sign). For signed numeric data, the
length of the field as specified on the display screen
format specifications must be one more than the
length specified on the RPG II specifications.
You can also specify other attributes of the field, such
as display intensity, whether the field is a blinking field,
and whether data must be entered into the field by the
operator.
On the S specification, you can indicate the number of
lines to be cleared before the format is displayed. You
can also specify a variable starting line number for the
format. For an example of these two functions, see the
sample program shown in Figure 13-14. For a complete
description of the entries that can be made on the
display screen format specifications, see the $SFGR
utility program in the System Support Reference Manual.
For a summary of the possible entries, see Appendix A
in this manual.
When you have completed the display screen format
specifications, use the $MAINT utility program or SEU
to enter the specifications into a source member. Then
run the screen format generator program ($SFGR utility
program) to process the source specifications. For the
display screen format load member name, the compiler
uses the name specified as the value for the FMTS
continuation line option. If the FMTS continuation line
option is not specified, the compiler uses the characters
specified in columns 75 through 80 of the control
specifications (the program name) and adds the
characters FM to the end of the program name. The
format name cannot be changed after compilation.
Figure 13-5 shows the steps for creating a display
screen format.

Writing a Program with a WORKSTN File

13·11

1.

Arrange all fields on the layout sheet, just as they will
appear on the display screen.

2.

Use the completed layout sheet as a guide for filling
out the two parts of the display screen format
specifications.

3.

Use SEU or $MAINT to transfer the specifications to
a library source member.

4.

Run the screen format generator utility program
($SFG R) by entering the required control statements
or by running the FORMAT procedure. The screen
format generator program produces the following
output:
List of source specifications
Diagnostic messages
List of information about the input and output
records for the format
The display screen format (or formats) in the
specified load member

Layout
Sheet

Screen Format
Specifications

SEU or $MAINT

Screen Format
Generator
Program

•

Format
specifications

• Diagnostic
Messages
•

Input and
output area

Figure 13·5. Steps for Creating a Display Screen Format

13·12

WORKSTN File Considerations and Sample Programs

Restrictions for Using a WORKSTN File
The following restrictions apply to the use of a
WORKSTN file in an RPG II program:
• Only one WORKSTN file is allowed per program.
• A program cannot contain a KEYBORD, CRT, or
CONSOLE file if it contains a WORKSTN file.
• The WORKSTN file must be specified as a combined
file (capable of both input and output).
• If the WORKSTN file is specified 'as a primary file, no
secondary files are allowed in the program.
• Control level indicators, match field values, and
look-ahead fields are not allowed.
• The first page indicator (1 P) is not allowed.
• Packed and binary data should not be sent to a
display station as output data. Such data can contain
IBM 5251 Display Station control characters. The
presence of 5251 control characters can cause
undesirable results. Packed and binary data can be
sent to an SSP-ICF session.
For an SRT program, output can precede input from
the requestor in one of three ways:
No lOis specified.
The 10 field contains the 10 of the requestor.
The 10 field contains blanks.
For an M RT program, the first input/output operation
issued to a requestor of the program must be an
input operation.
• For an acquired device, output can precede input if
the 10 of the device is first placed in the 10 field.

Writing a Program with a WORKSTN File

13-13

Command Keys

File Description Specifications

All 24 command keys can be used for a WORKSTN file.
When RPG makes the data read from a display station
available for processing, all command key indicators are
set off. If a command key was pressed when the data
was read into the program, the corresponding command
key indicator is set on. You can then use the command
key indicator to condition calculation and output
operations.

The following file description specifications must be
made for a WORKSTN file. If multiple display stations
are attached to the WORKSTN file or if you want to
specify the file information data structure (INFDS) or the
WORKSTN exception/error processing subroutine
(INFSR), continuation lines can also be specified. The
continuation lines are described after the file description
specifications.

For example, you can specify that the operator press
command key 2 (rather than the Enter / Rec Adv key)
when the last item for an invoice has been keyed at the
display station. You can then use command key
indicator KB in the program to condition calculation
operations and output operations, such as presenting
the next screen to the operator.
You can use the display screen format S specifications
to selectively enable or disable certain command keys
for your program. For a description of how to
selectively enable ·or disable command keys, see column
28 of the S specifications summary in Appendix A or
see the System Support Reference Manual. For a
discussion of how to determine whether a command key
was pressed, see Specifications for the INFDS Data
Structure in this chapter.
To document the use of the command keys for the
operator, you can use the template assignment form on
the IBM 5251 Display Station Keyboard Template
Assignment Sheet and Display Screen Layout Sheet.

Column

Entry

6

F (the form type).

7 -14

A valid filename.

15

Must contain a C for combined file.

16

Must contain a P for primary file or a D
for demand file.

17 -18

Must be blank.

19

Must contain an F or be blank for
fixed-length record.

20-23

Must be blank. The block length equals
the record length.

24-27

The length of the longest record, which is
equal to the highest end position specified
on the input or output specifications.

28-39

Must be blank.

40-46

Device name WORKSTN.

47-70

Must be blank.

71-72

File conditioning indicators (U 1 through
U8), if needed.

73-74

Must be blank.

75-80

Can contain the program identification.

Control Specifications
Columns 52 and 53 of the control specifications must
specify the number of formats contained in the display
screen format load member. This number must include
all the formats in the display screen format load
member, not just the number of formats used by the
program. If no entry is made in columns 52 and 53, the
program assumes an entry of 32. The entry in columns
52 and 53 can be greater than the actual number of
formats in the load member but not greater than 32.

For an example of the file description specifications, see
the sample programs at the end of this chapter.

13-14

WORKSTN File Considerations and Sample Programs

Continuation Line Options
Several options can be specified for a WORKSTN file on
the file description specifications continuation lines.
. These options can be specified if more than one device
is attached to a WORKSTN file or if you want to specify
the file information data structure (lNFDS) or the
WORKSTN exception/error processing subroutine
(lNFSR). To specify a continuation line, enter a K in
column 53, the option keyword in columns 54 through
59, and the value in columns 60 through 65 (columns 60
through 67 can be used if the FMTS option is specified).
For examples of specifying continuation line options, see
Figure 13-6.

Keyword Value
SAVDS

This data structure can contain
information that is unique to each display
station, For example, it can contain a field
that is used to accumulate the number of
records read or to store a field that is not
used until later cycles, such as credit limit.

The following keywords and values can be specified in
columns 54 through 59 and 60 through 65 respectively:
IND

Keyword

Value

NUM

Maximum number of devices that can be
attached to this file at the same time. The
number specified must be right-justified in
columns 60 through 65. If not specified, 1
is assumed. If specified, NUM must be
greater than or equal to the number of
requestors specified by the M RTMAX
parameter on the COMPilE OCl
statement plus the number of acquired
devices (those specified on the
WORKSTN OCl statement or in the ACO
operation). The number specified on the
MRTMAX parameter is reserved for
requestors. The difference between the
MRTMAX value and the NUM value is the
maximum number of devices
(nonrequestors) that can be attached to
the program at one time via OCl
statements or the ACO operation code.
For example, if the M RTMAX value is 5
and the NUM value is 6, only one
nonrequestor device can be attached to
the program, even if only one requestor is
presently signed on.

Note: If NUM is greater than 1, use
caution when updating a file (see Update
Files in Chapter 3).

Name of a data structure that is to be
saved and restored for each device
attached to this file. The data' structure
cannot be a display station local data
area, a compile-time array, or a
preexecution-time array. If SAVDS is not
specified, no data area swapping is done.

Number of indicators, beginning with 01,
that are to be saved and restored by the
display station. Indicators 01 through the
number specified here are saved and
restored for each display station. If IN D is
not specified or if NUM equals 1, no
indicator swapping is done. The entry
must be right-justified in columns 60
through 65.
For example, error indicators or indicators
used for security cle.arance may be unique
by display station.

Note: For SAVDS and IN D, only one copy
of the data structure and indicators is
available at a time. The indicators and
data structure that are available are those
associated with the device from which the
last input was read.
The data structure and'indicators that are
available change each time an input
operation (either a primary file input or a
demand file read) is executed. On an
input operation, the present copy of the
data structure and indicators in the
program is written to a save area for the
device from which the previous input was
read. The data structure and indicators for
the device now being read from are then
written from the save area associated· with
the device to the program SAVDS and
. IND areas. Fo~ further information, see
Figure 13-2 in this chapter.

Writing a Program with a WORKSTN File

13-15

Keyword

Value

SlN

Name of a two-digit numeric field whose
value determines the first line on the
display screen where the display screen
format is to begin if a variable starting line
number was spec:ified (V in column 17 of
the display screen format S
specifications). If SlN is not specified, all
formats having a variable starting line
number will begin on line 01.

FMTS

*NONE. Indicates that there are only
SSP-ICF formats present in this program.

\

Keyword

SSP-ICF session IDs can be in two
formats. They are either NN where N is
numeric (0-9), or NA where N is numeric
and A is alphabetic (A-Z, #, @, or $). If
the format is NA, a SESSION OCl
statement must be specified with a
SYMID parameter whose value is also in
an NA format.
INFSR

Name of the user-written calculation
subroutine that may receive control when
an exception / error occurs. This
subroutine, referred to as the WORKSTN exception/ error processing subroutine, is
written by the RPG II programmer to
handle the WORKSTN exception
conditions or input/ output errors in the
manner best suited for the application
program. The following WORKSTN
operations transfer control to the INFSR
subroutine: ACQ, ~El, NEXT, POST,
input (READ operation or primary input),
or output (EXCPT or normal cycle output).
If INFSR is not specified, error recovery is
handled by RPG II. See WORKSTN
Exception/Error Handling in this chapter
for more information on INFSR.

INFDS

Name of the data structure that contains
the unique identification of the
exception/error and the WORKSTN
operation that caused the exception / error
condition. This data structure is referred
to as the WORKSTN file information data
structure. The INFDS data structure also
contains the display screen size (*SIZE),
either 960 or 1920 characters, and
information about ideographic support. If
the IN FDS data structure is not specified,
this information is not available to the
RPG II program. See WORKSTN
Exception/Error Handling in this chapter
for more information on INFDS.

Display screen format load member name.
The compiler uses the name entered here
as the display screen format load member
name. The format load member name
entered here can be from 1 to 8
characters in length, left-justified in
columns 60 through 67. If a name is not
entered, the compiler assumes the display
screen format load member name is the
program name (from columns 75 through
80 of the control specifications) with FM
added to the end of "the name.
ID

Name of a 2-character self-defining
alphameric field (that is, the field does not
have to be specified as an input or result
field) that contains the ID of the device
that supplied the record currently being
processed in this file. The ID field is
updated whenever a record is read from
the WORKSTN file. Therefore, it always
contains the identification of the device
from which the last record was read
(unless your program moves a different
identification into the ID field). You can
direct output to different devices in a
multiple WORKSTN file by changing the
value 'in this field to the symbolic ID of
another device in the file.
Display station IDs are in the form AX,
where A is an alphabetic character (A-Z,
#, @, or $) and X is any character. If a
WORKSTN OCl statement exists for the
display station, the I D is the same as the
value of the SYMID parameter.

13-16 WORKSTN File Considerations and Sample Programs

Value

File Description Specifications
File Type ,

F
-

File Addition/Unordered

Mode of Proce5.5.i n9

Length of Key Field or

File Designation

End of File

Record Address

Sequence

Filename

File FOfmat

'0

~
~

C
=u:::a:

=

~ ~ Li:
w

3

•

o

2

o

3

o

4

N

w

line

1

5

8

9·10 11 12 13 14

Extent Exit
for DAM

of Record Addreu Field

Block

Record

Length

Length
External

~
a::

e
Re~rd ~ ~
~

::: 0

Name

Type

Type of File

~

Organization or
Additional Area

c

Device

~

~~~~~liC

I e,a~::?~n

r--T-ape---f

Storage I ndex

Rewind

~
Condition
Ul-UB.

,0

Continuation Lines
K

W

Option

16 \7 18 19 20 21 2223 24 25 26 27 28 29 30 31 32 33 34 35 3G 37 38 39 404' 42 43 44 45 46 47 48 49 50 5' 51 53 54 5556 57 58 59

FWSIIINPUT CP

Number of Extena

Label Exit

~
~ ~

Overflow Indicator

Number of Track'
for Cylinder Overflow

Name of

Entry

Z

~

~

UC

r--

606' 61 63 64 65 66 67 68 69 70 71 71 73 74

WORKSIN

F

IIO~ UlM
KSAVD~ SAVE

o

5

F

o

6

F

o
o

7

KF MT S

11= [0

B

KID

~SID

o

9

KINF1DS EXCDS
Kll NFLS\B ERR S R

1 0

ZL tL OL 69119 L9 99 S9 t9 t9 Z9 19 09 6!l 6!l LS 6!l SS t9 t'i ZS IS OS 6. 9. i t 9. S.

RMIA If S

»

E. Z. I. O. 6[ BE LE BE SE

.r

Et zt It OE 6Z 9Z LZ 9Z SZ .Z EZ ZZ IZ OZ 61 91 LI 91 SI .1 t. Z. II 01

6

9

L

9

S

•

E

Z

I

Figure 13.0. WORKSTN Continuation Line Options

Input Specifications
Entries for the input specifications are described in
Chapter 7. However, the following considerations apply
when the input file is a WORKSTN file:
• Control level indicators (columns 59 and 60), match
field values (columns 61 and 62), and look-ahead
fields (columns 19 and 20) are not allowed.
• The field location entries in columns 44 through 51
refer to the location of the field in the input record,
and in the case of a display station, not to the
location of the field as it is displayed on the screen.
The input fields are placed in the input record in the
order in which they are described on the display
screen format specifications. However, the line
number and horizontal position columns on the
display screen format specifications can be used to
change the order in which the fields appear on the
screen. See Figure 13-7 for an example of the
relationship between the display screen format
specifications and the RPG II input specifications.

• Each record including the blank record at the first
read to a device should be identified on the input
specifications. For display screens, specify a
nondisplay, protected output/input field on each
display screen format for the record code.
• The first input record 'read from a device is blank
unless PDATA-YES is specified in the procedure that
executes the program; unless the program is a
requestor, other than the first, of an MRT program
(see the $MAINT utility program in the System
Support Reference Manual); or unless a read under
format is performed (see Read Under Format in this
chapter).

Writing a Program with a WORKSTN File 13-17

Source Input Screen Format Source Specifications

d{8?b
o

AL

C86f~MK'O

y

Y

)
TI~E

y
y

Y

YS

Y
Y

y
y

L

~:-;--:::;-;~~;;TI~;------CUTPUT
RUFFER JESC~IPTIO~
STAR T

LE,'-IGTH
TOTAL

PGSrTIO.~

C
C

__

EpOr-..JuS
· I T 10'",~

13

13

The line number and horizontal
position columns on the display
screen format specifications are
used to specify the order in which
the fields are to appear on the
screen.

INPUT RUFFER DESCkIPTIOfJ
FIELD

" 2/",\< 2 1 = 2
Lookup \=actor 21 is

181920212:; 2:::24252c 27 2829303' 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 495051

"':r~l

-C~

0 4
0

14

C

~

0

01 ,)
,1, 1~i13

Length

V-

/

REL;
-

v:

;

I

ll'iRKFILE
!

!

i

1

.,.

i

i

;

'W! '

I

!

INE.XT' IWak"F I_LE

;
:

- --

---

I

The device identified by the field STN2 is
released from the program.
Figure 13·8. WORKSTN Operation Codes

13-20 WORKSTN File Considerations and Sample Programs

--

,

1

I

:

I

!

;

I

-

I

I

i
1
1

i

1

!
1

I

i

I

!

:

I

I
1
1

I

I i 1 '1 I
IIIIII

I

I

1

!
I

!

I
1

1

!

:

I

!

i

I

I

NEXT forces the next input to come from device
1 (identified by the alphameric literal W1).

I

Output Specifications

WORKSTN EXCEPTION/ERROR HANDLING

Entries for the output specifications are described in
Chapter 9. However, the following considerations apply
when the output file is a WORKSTN file:

The WORKSTN exception/error processing subroutine
(INFSR) and error indicators in columns 56 and 57 of
the WORKSTN operation codes (REL, ACO, NEXT,
POST, and READ) allow the programmer to control the
program logic if exception/error conditions occur during
WORKSTN file processing. The WORKSTN file
information data structure (INFDS) contains status
information that the programmer can check to determine
what type of exception/error occurred. Using the
information in the IN FDS, the programmer can then
determine which exception / error conditions he wants to
handle in the IN FSR subroutine and which
exception/error conditions he wants RPG II to handle.

• The first page (1 P) indicator is not allowed.
• The end position entry in columns 40 through 43
refers to the end position of the field in the output
record. For display stations it does not refer to the
end position of the field as it appears on the screen.
Use the output from the $SFG R utility program as a
guide when coding the output specifications for
display stations (see Figure 13-9).
• The output fields start in position 1.
• For display stations, the fields must be described on
the output specifications in the same order as they
are described on the display screen format
specifications.
• A device can be released after the output is
performed if you place an R in column 16. If OR
lines are specified, column 16 must contain an R for
each line. The device is released when that output
specification is encountered during the output
operations. If a format name is specified in the same
specification line that contains an R in column 16, the
format is displayed or the interactive communications
operation is performed and then the device is
released.
• The display screen format name from columns 7
through 14 of the display screen format specifications
for this program or the predefined SSP-ICF format
name must be specified as a constant in columns 45
through 54. The line containing the format name
cannot be conditioned by any indicators. You must
also enter Kn in columns 42 and 43, where n is the
length of the format name. For example, if the
format name is FORM1, enter K5 in columns 42 and
43 and 'FORM1' in columns 45 through 51.
• One format name is required for each output record
for the WORKSTN file. The specification of more
than one format name per record is not allowed.

If neither the INFSR subroutine nor error indicators are
specified, an exception/error is handled by the RPG II
error handling routine, which causes a program to halt
and the operator must choose the appropriate option.
Exception conditions refer to the input of an enabled
function control key (Print, Roll Up, Roll Down, Clear,
Help, or Record Backspace) to the program. The display
screen format S specifications must be used to enable
these function control keys for an RPG program. To
enable the function control keys, the program must also
contain the INFDS data structure, which will contain an
indication of the exception/ error condition, and either
the INFSR subroutine or an error indicator specified in
columns 56 and 57 of a READ operation. If the program
does not contain the INFDS data structure, the program
cannot determine whether one of the function control
keys was pressed. No automatic programmed function
is associated with the function control keys. The
programmer can test the INFDS to determine whether a
function control key was pressed and then use that
indication as a signal from the operator to perform
certain routines in the program. For information on how
the function control keys are enabled, see
Enabling/Disabling Function Control Keys in this chapter.
Error conditions refer to input/output errors that occur
during an implicit input/ output operation (such as a
primary file read, EXCPT output, or normal cycle output
operations) or during an explicit input/output operation
(such as ACO, REL, NEXT, or READ).

Note: When the RPG II Z edit code is used for an
output field in a WORKSTN file and the value of the
field is zero, RPG II sends a blank field to work station
data management, 'v-"hich places a zero in ihe rightmost
position of a signed numeric field.

WORKSTN Exception/Error Handling

13-21

Source Input Screen Format Source Specifications
SSHOWITEM

o
o
o
o
o

y
y
y

ITEM NO.
DESCRIPTION
PRICE
ONHAND
SOLO

y

y

OITEMNO
OONHAND
OPENDNG
OPRICE
ODESC
OUTPUT BUFFER DESCRIPTION
START
LENGTH
POSITION

FIELD
NAME
ITEMNO
ONHAND
PENDNG
PRICE
OESC

6
6
6
9

22

The line number and horizontal
position columns on the display
screen format specifications can
be used to change the order in
which the fields appear on the
screen.

END
POSITION

1
7

6

12

18~

13
19

27

28

49

The end positions generated for the $SFG R
output buffer and the end positions specified
on the RPG II output specifications must be
the same for each field.

RPG II Output Specifications
0011 '
0018
0019
0020
0021
0022
0023

o

o
o
o
o.
o
o

o

j

ITEMNO
ONHANDL
PENDNGl
PRICE 2
DESC

K8
6

12
18

27

49

The fields on the display screen format specifications must be
described in the same order as specified by the end positions
in the output specifications.

Note: For the complete program in which this format is used, see WORKSTN Sample Programs later in this chapter.
Figure 13-9. Relationship Between the RPG II Output Specifications and the $SFGR Output Buffer

13-22 WORKSTN File Considerations and Sample Programs

The IN FDS data structure, if specified, contains an
identification of the exception / error that occurred and
an identification of the WORKSTN operation for which
the exception / error occurred. The IN FDS also contains
status information on normal conditions (not exceptions
or errors) such as whether a command key was pressed,
whether end of file has occurred, or whether the size of
the display screen is 960 or 1920 characters. The
IN FDS data structure must be specified if function
control keys are enabled for the program or if the POST
operation code is to be executed; otherwise the
indication that a function control key was pressed and
the results of the POST operation are not available to
the program. The information in the INFDS data
structure is updated for each WORKSTN operation;
however, *SIZE is only updated when the POST
operation is executed. If an exception/error condition
occurs, the programmer can use the INFDS information
to determine the type of exception/error that occurred
and use that information to control the program logic or
to control the return point from the INFSR subroutine, if
specified.
When an exception/error condition occurs for a
WORKSTN operation, information in the INFDS is
updated and control automatically passes to the INFSR
subroutine, if specified, under the following conditions:

In addition, the INFSR subroutine can be called directly
from detail or total calculations by the EXSR operation.
The indicator specified in columns 56 and 57 for a
READ, ACQ, REL, POST, or NEXT operation is set on if
an exception/ error condition occurs on that operation.
Control is then passed to the next executable statement
in the program. If an error indicator is specified for one
of these operations, the INFSR subroutine must be
called by the EXSR operation if the subroutine is to be
executed. Control does not automatically pass to the
INFSR subroutine if the exception/error occurs on a
READ, ACQ, REL, POST, or NEXT operation that has an
indicator specified in columns 56 and 57.
The relationship between these exception / error handling
techniques is shown in Figure 13-10. These
exception / error handling techniques are optional and
can be used individually or in any combination.
However, if function co'ntrol keys are enabled for the
program, the INFDS data structure and either the INFSR
subroutine or an error indicator on the READ operation
must be specified. The programmer can choose the
techniques that best suit his application program.

• If an exception/error occurs on a primary file read,
on EXCPT output, or on a normal cycle output
operation
• If an exception/error occurs on an explicit
input/output operation (ACQ, REL, NEXT, or READ)
that does not have an indicator specified in columns
56 and 57

WORKSTN Exception/Error Handling

13-23

Update
*STATUS in
INFDS

Continue

Set on
indicator

No

Continue

Yes

Execute
INFSR
subroutine

No

Yes

RPG II error handling
(program halts). If
INFSR called by
EXSR, returns to next
sequential instruction

Go to point
in RPG II
cycle specified
by factor 2
entry on ENDSR
*GETIN (beginning of new
cycle)1
*DETC (detail calculations)1
*CANCL (cancel program)1

1 For

the exact point in the cycle that is specified by these
keywords, see Chapter 17.

Figure 13-10. WORKSTN Exception/Error Handling

13-24 WORKSTN File Considerations and Sample Programs

Specifications for the INFDS Data Structure
The INFDS data structure can be used to pass the
WORKSTN file exception/error information to the RPG
program. The INFDS data structure contains the
identification of the type of exception / error that
occurred and an indication of the WORKSTN operation
that was executing when the error occurred. The INFDS
data structure also contains status information on
normal conditions such as whether end of file has
occurred, whether the display screen size is 960 or 1920
characters (*SIZE), and whether your system supports
ideographic processing. The INFDS data structure must
be specified if function control keys are to be enabled
for the program. If the INFDS is not specified, this
information is not available to the RPG II program.
The name of the data structure to be used as the
WORKSTN file information data structure must be
specified on a continuation line for the WORKSTN file
on the file description specifications along with the
IN FDS keyword. The entries for the continuation lines
are:
Column

Entry

6

F

7-52

Must be blank

53

K

54-59

INFDS

60-65

Name of the data structure to be
used as the IN FDS

66-74

Must be blank

75-80

Program identification (optional)

The rules for defining the IN FDS data structure on the
input specifications are the same as for any other data
structure. However, the name of the data structure must
be previously defined on the file description
specifications continuation line with the INFDS keyword.
The location of the subfields containing the status
information in the data structure is defined by special
keywords on the input specifications. The keywords
must be placed left-justified in columns 44 through 50.
These keywords identify the location of self-defining
subfields within the data structure. The keywords are
not labels, however, and cannot be used to reference
the subfields. A name must be ass,igned in columns 53
through 58 in order to reference the subfields (see
Figure 13-11). The valid keywords are *STATUS,
*OpeODE, *SIZE, *REeORD, *MODE, *INP, and *OUT.
In addition to these keyword-defined subfields, there is
an alphameric subfield in the INFDS that contains return
codes (see Appendix e). This subfield is filled in for all
WORKSTN files. The subfield is located in positions 23
through 26 and must be defined on the input
specifications. The subfield is referenced by the name
specified in columns 53 through 58. (For information on
return codes resulting from the use of SSP-leF, see the
Interactive Communications Feature Reference Manual.)

WOR KSTN Exception/Error Handling

13-25

*STATUS Keyword

The *STATUS keyword identifies a self-defining
five-digit numeric subfield with zero decimal positions
within the INFDS data structure. This subfield contains
a five-digit code that identifies the exception/error
condition. The codes are as follows:
Exception/Error
Conditions
(Function Control Keys)

Code

Print
Roll Up
Roll Down
Clear
Help
Record Backspace

01121
01122
01123
01124
01125
01126

(Error Status Codes)

Input rejected, buffer too small
Permanent I/O error occurred
Invalid device, or maximum
number of display stations
already attached
Device bu~y
Display station released by operator
Input rejected, keyboard disabled,
device not available or not found
Attempt to acquire a device
already owned
Other input errors
Change direction received with
no data
Request for change direction
received
Time interval expiration

01201
01251
01261

01271
01275
01281
01285
01299
01311
01321
01331

Note: If an exception / error condition occurs, RPG II
bypasses the move field logic, no fields are changed, no
record identifying indicators are turned on, and the
command key indicators are not reset.

13-26 WORKSTN File Considerations and Sample Programs

In addition, the programmer also has access to the
following successful status codes that are placed in
*STATUS after any input/output operation:
Condition

Code

No exception (with
a display station,
either the
Enter / Rec Adv or
Auto Record Advance
key was pressed)

00000

Any of the 24 command keys 00002
End of file (input rejected,
no display stations ready)

00011

Any code in *STATUS greater than 99 is considered to
be an exception / error condition, and the error indicator,
if specified, is set on. If no error indicator is specified
on an ACQ, REL, NEXT, POST, or READ operation or if
the operation is a primary file read, normal output, or
EXCPT output, control is automatically passed to the
INFSR subroutine.
For information on return codes resulting from the use
of the Interactive Communications Feature, see the
Interactive Communications Feature Reference Manual.
Appendix C of this manual contains a list of return
codes issued by WORKSTN and SSP-ICF data
management.

*OPCODE Keyword

*INP Keyword

The *OPCODE keyword identifies a self-defining,
5-character alphameric subfield within the INFDS data
structure. This subfield contains a value that identifies
which WORKSTN operation was executing when the
exception / error occurred. The value inserted in the
*OPCODE subfield is READ, ACO, REL, NEXT, POST, or
WRITE (for output operations). A value is inserted in the
*OPCODE subfield when a nonzero value is placed in
*STATUS.

The *INP keyword identifies a two-digit numeric field
that indicates if this display station is capable of
producing ideographic characters for input to a program.
Value

Explanation

10

The keyboard is capable of ideographic
data entry.
The keyboard is not capable of
ideographic data entry, or is not
input-capable.

00

*RECORD Keyword

The *RECORD keyword identifies a self-defining,
8-character alphameric subfield within the INFDS data
structure. This subfield contains the format name if
*OPCODE contains WRITE. If *OPCODE does not
contain WRITE, *RECORD is blank.

*OUT Keyword

The *OUT keyword identifies a two-digit numeric field
that indicates if this display station's display screen is
capable of displaying ideographic characters.
Value

Explanation

*SIZ£ Keyword

10

The *SIZE keyword identifies a self-defining, four-digit
numeric subfield within the INFDS data structure that
contains the identification of the character size of the
display screen (1920 or 960). This subfield is reset each
time the POST operation code is executed. For the
1920-character display, the digits 1920 are stored in the
*SIZE subfield; for the 960-character display, the digits
0960 are stored in the *SIZE subfield.

00

The display screen can display.
ideographic characters.
The display screen cannot display
ideographic characters, or is not
output-capable.

*MODE Keyword

The *MODE keyword identifies a two-digit numeric field
that indicates if ideographic support was requested
when the user signed on.
Value

Explanation

10
00

Ideographic support was requested.
Ideographic support was not requested.

WORKSTN Exception/Error Handling

13-27

Positions 23-26
Positions 23 through 26 of the data structure defined as
the INFDS contain the 4-character data management
return code for WORKSTN files. This subfield is filled in
for all WORKSTN files. The subfield must be defined
on the input specifications. The subfield is referenced
by the name specified in columns 53 through 58 of the
input specifications. For information on RPG return
codes for display stations, see Appendix C. For
information on SSP-ICF return codes, see the Interactive
Communications Feature Reference Manual.
Note: This subfield is not updated for an ·STATUS
value of 01261 because no call is made to data
management. If the ·STATUS value is 01281, this
subfield will not be updated unless the error occurs on a
read or ACQ operation.

RPG INPUT SPECIFICATIONS
Program

I Date

Programmer

I

Filename
or
Record Name
0.

Key

5

6

Data
Structure
Name
8

9 '0 "

~~D
'2 '3 ,. '5 '6

0 2

Ie xc PDS
I

o

3

I

0 4
0 5

I
I I

-1

Card Ele<:tro Number

~~
~ 0.

1

2

3

From

To

~

:
Position

~

~~ ~
~ U

19 20 2'

n

6

Position

geH

Position

~~B

goY ~~

~§~ M~
",0..

Data Structure
Occurs
nTimes

[I]

0

RPG
Field Name

g

~~~~;~;:ation I

of

Length

~

~

Field
Indicators

i5
oS

0;

~

u:

e
~

r:

~

III III

~

Zero
Plu. Minus or
Blank

~

23 24 25 26 27 28 29 30 3' 32 33 34 35 36 37 38 3940 4, 42 43 44 45 46 47 48 49 5u 5, 52 53 54 55 56 57 58 5960 6' 62 6364 6566 67 68 69 70 7' 72 73 74

D~

~5 TA !TU~

I

~R

EC ORID

I

fX5 IrE

0 6

I

0 7

I

o

I
I

~M ODE
~r NP
~O UT

1 0

r:

~

0;

PC ODIE

0 9

Page

Field Location

~O

8

I

External Field Name

"0

7

I I
I I

Record Identification Codes

~

~

0 1

1

~

~
E

Line

4

Graphic

0

r--

3

Keying
Instruction

GX21·9094-4 UM/050'
Printed in U.S.A.
75 76 77 78 79 80

1 2

23

ST AT US

OP co Ip E
FM TNM
SI 2£
MO DE

INP
OUT
26 IRe DDIE

I

The keywords and predefined from and to locations in
columns 44 through 51 define the location and size of the
subfields in the INFDS data structure, which contain the
status information. Field .names must be assigned in columns
53 through 58 so the subfields can be referenced in the
program.
Figure 13·11. Subfield Keywords for the INFDS Data Structure

13·28 WORKSTN File Considerations and Sample Programs

Specifications for the INFSR Subroutine
The INFSR subroutine can perform any function
normally allowed in calculations, including exits to other
calculation subroutines and input/output operations.
The INFSR subroutine returns control to the point
specified by the optional factor 2 entry for the ENDSR
operation.

The rules for coding the INFSR subroutine are the same
as for any calculation subroutine. However, the name
specified in factor 1 must be previously defined on the
file description specifications continuation line with the
INFSR keyword. The INFSR subroutine returns control
to the point specified by an optional entry in factor 2 of
the ENDSR operation. Valid entries for factor 2 are:

Factor 2
Specify the INFSR keyword and the name of the
exception / error processing subroutine on a continuation
line for the WORKSTN file on the file description
specifications. Valid entries for the continuation line are:

Column

Entry

6

F

7-52

Must be blank

53

K

54-59

INFSR

60-65

Name of the calculation subroutine
that is to be executed if a
WORKSTN exception/error occurs
on a READ, ACQ, REL, POST, or
NEXT operation for which no
indicator is specified in columns 56
and 57 or on implicit input/output
operations.

66-74

Must be blank

75-80

Program identification (optional)

Description

Blank (no entry) • If the INFSR subroutine was
called explicitly by the EXSR
operation, control returns to the
operation following the EXSR
statement.
• If the subroutine was called
indirectly (that is, control was
automatically passed to the
subroutine), the subroutine is
executed and control is passed to
the RPG II error handling routine,
which in most cases causes the
program to halt, and the operator
must choose the appropriate
option.
Literal

The literal must be one of the
following keywords. (The keyword
must be enclosed in apostrophes.)
'*G ETI N' -Control returns to the
beginning of a new cycle.
'*DETC' -Control returns to the
beginning of detail calculations.
'*CANCL'-Files are closed and
program is canceled.
,-A literal value of blanks is the
same as no entry.

WORKSTN Exception/Error Handling

13-29

Factor 2

Description

Literal
(continued)

If an exception / error occurs on an
operation that attempts to read data
from a file and the exception / error
handling subroutine receives control,
the programmer must ensure that an
output operation is issued to the
WORKSTN file before another read
is issued. Two consecutive read
operations cannot be issued to the
same WORKSTN file. For example,
if the WORKSTN file is a primary
file and the exception/error
subroutine ENDSR statement
specified a return point of *GETIN,
an output operation must be issued
to the file before the EN DSR is
executed. The *GETIN routine will
attempt to read from a WORKSTN
primary file.

Array element or
field name

The array element or field name
specifies a 6-character alphameric
field that contains one of the
'reserved keywords, *GETIN, *DETC,
or *CANCL or that contains blanks
that define the return point from the
subroutine. The reserved keywords
must be left-justified and padded
with blanks in the field specified.
By specifying the return point in a
field, the programmer can use the
subroutine to process all types of
exceptions and errors that occur on
the WORKSTN file.

If a field ~ame or array element is specified in factor 2,
the field or array element is set to blanks upon each exit
from the subroutine. Therefore, the programmer can
control the return point of the INFSR within the program
by placing the return point in the field that best fits the
particular exception / error that occurred. If no value is
placed in factor 2, the subroutine is executed and
control passes to the RPG II error hs"ndling routine if the
subroutine was called indirectly. If the INFSR subroutine
was explicitly called by the EXSR operation and factor 2
is blank, control returns to the calculation immediately
following the EXSR operation.

13-30 WORKSTN File Considerations and Sample Programs

SPECIAL DISPLAY FORMAT CONSIDERATIONS

Overriding Fields in a Format
An override operation allows you to override fields in a
format when you redisplay the same format. To perform
an override operation, you must specify an indicator in
columns 33 and 34 of the S specification. An override
operation is perfornied if the indicator is on when the
format is displayed (see Figure 13-12). A normal output
operation is performed if the indicator is off when the
format is displayed.
During an override operation (the indicator in columns
33 and 34 is on), the following occurs:
• Any field that has an indicator specified in coiumns
23 and 24 of the D specification and that indicator is
off is unchanged. If data was keyed into the field,
that data is unchanged. Any field that had Y, N, or
'blank specified in columns 23 and 24 is also
unchanged.
• Any field that has an indicator specified in columns
23 and 24 of the D specification and that indicator is
on is displayed with data from the RPG II program.
Any data that was keyed into the field by the
operator is lost. Output information is displayed from
the same locations in the output record area as for a
normal display.
• For all fields, the use of indicator-controlled attributes
such as highlight or reverse image is determined by
the state of that indicator. All field attributes that are
not controlled by indicators are unchanged.
For example, you may want to override fields in a
display if the operator keys incorrect data into a field.
To do this, specify an indicator in columns 33 and 34 of
the S specification, which allows the format to be
overridden. If the operator keys incorrect data into a
field, you can then set on the indicator in columns 33
and 34 and redisplay the format. If the indicator
specified in columns 23 and 24 of the D specification is
off for the field, the incorrect data is unchanged. If the
indicator is on, data from the RPG II program is
displayed. You can .also use indicators for field
attributes such as highlight and reverse image and set
these indicators on when the override indicator is set
on.

Read Under Format

Processing the Duplicate Character Value (Hex 1 C)

A read under format allows one program in a procedure
to display a format and the next program in the
procedure to read it. The first program displays the
format using a normal output operation and then goes
to end of job or releases the display station. While the
second program is initiating, the operator keys
information into the displayed format. VJhen the
operator presses the Enter / Rec Adv key, the input
information from the display is sent to the second
program.

If you specify enable dup (column 34 of the D
specification) for a field in a display screen format, the
operator can press the Dup key to indicate to the
program that the contents of the field are to be
duplicated from the f,ield in the previous record. When
the Dup key is pressed, the field, from the position of
the cursor to the end of the field, is filled with the
duplicate character value (hex 1C)' which is displayed as
the character *. The Dup key does not duplicate any
characters; therefore, you must process the duplicate
character values in your program.

The following steps occur in a read under format:

1.

With a normal output operation, the first program
displays a format at the display station.

2.

The first program goes to end of job (if the
program is an SRT program) or releases the
requesting display station (if the program is an
MRT). The display station is released when
column 16 of the output specifications contains an
R, when the REl operation code is used in the
calculations, or when the program goes to end of
job.

3.

The second program is initiated. (Data should not
be passed to the second program from an
INCLUDE OCl statement.)

4.

The second program performs a normal read
operation (either by a READ operation c0ge or by
a primary file input operation).

If you want the operator to either duplicate the entire
field or key the entire field, you need to test only one
character in the field to determine whether the Dup key
was pressed. For example, you can test the last
character in an alphameric field for the duplicate character
value by using the TESTB operation code. If the last
character in the field is not a duplicate character value,
move the contents of the test field to the processing field
(see Figure 13-13).
You can also write your program t6 allow the operator
to change the first part of a field and duplicate the latter
part of the field. For example, if the operator changes
the first 4 characters in a 10-character field and then
presses the Dup key, positions 5 through 10 of the field
will contain the duplicate character value (hex 1C). In
your program, you then have to test each character in
the field to determine where the first duplicate character
occurs, and replace the appropriate positions with the
data to be duplicated.

Indicator in Columns 33 and 34
of the S specification

Indicator in
Columns 23 and 24
of the D
specification

OFF

ON

OFF

Output data comes from
D specification (columns
57 through 79).

No change occurs to
data on the screen.

ON

Output data comes from
the RPG II program.

Output data comes from
the RPG II program.

Normal Output Operation

Override Operation

Figure 13-12. Effect of Indicators on Output Data During an Override Operation

Special Display Format Considerations 13-31

Enabling/Disabling Command Keys

IBM-WRITTEN SUBROUTINES SUBR20 AND
SUBR21

The display screen format S speCification allows you to
specify in column 28 (enable command keys) that
certain command keys be enabled or disabled for a
format. (Normally all command keys are enabled for an
RPG II WORKSTN program.) If the operator presses a
disabled command key, an error message is displayed.
The operator can press the Error Reset key and then
press the correct command key.

Setting and Restoring External Indicators (SUBR20)
The IBM-written *subroutine SUBR20 allows you to set
and restore the external indicators for each requesting
display station when multiple display stations are
requestors in a WORKSTN file. To call the subroutine,
you must make the following four entries on the
calculation specifications:

For a description of the entries required to enable or
disable command keys, see the summary of the display
screen format S specification in Appendix A or see the
System Support Reference Manual.

Result Field
Operation

Factor 1

Name

The INFDS data structure can be used to determine
whether an enabled command key was pressed. For
more information, see WORKSTN Exception/Error
Handling in this chapter.

For a description of the entries required to enable or
disable function control keys, see the summary of the
display screen format S specification in Appendix A or
see the System Support Reference Manual.

'8

~

E

18 19 20 21 22 23 24 25 26 27

~~Ii.IT(21~ 341~

I:

o
~ ~(

I Rl.A!sll

I

RiL AielL

1

I

I

I

Function control keys not supported by the program can
be masked off (disabled) and, therefore, are not returned
to the program. If the operator presses a disabled
function control key, an error message is displayed. The
operator can then press the Error Reset key, followed by
the correct function control key.

Length

.~

I

Enabling/Disabling Function Control Keys
The display screen format S specification allows you to
specify in column 27 (enable function keys) that six
function control keys (Print, Roll Up, Roll Down, Clear,
Help, and Record Backspace) be enabled or disabled for
your program. For these function control keys to be
enabled for an RPG II program, the program must
contain the IN FDS data structure and either the IN FSR
subroutine or a READ operation with an indicator
specified in columns 56 and 57. If the IN FDS data
structure is not specified in the program, the indication
that a function control key was pressed is not available
to the RPG program.

.~

Factor 2

40 41 42 43(4 45 46 47 48 49 5051 52

t)p
:rN[A~ E

I

1

l1

OP is a 1-character field that contains an I to indicate
that the external indicators are to be input to the
program for this display station, or an 0 to indicate that
the external indicators are to be output for this display
station. To enter the appropriate code in the OP field,
you can use a MOVE operation before calling the
subroutine.

I

TNAME is a 2-character field that contains the work
station ID of the display station. Normally the field you
specify for TNAME is the same field you specified on
the file description specifications continuation line as the
ID field.
RCODE is a 1-character field that contains the following
return code:

o = successful
= unsuccessful

(the display station is not
attached to the program)

2 = unsuccessful (the display station is not
a requestor)
The external indicators for the requestor of an SRT
program are automatically available to the program
without the use of SUBR20 and are written out at end
of job. The external indicators for the first requestor of
an MRT program are available without the use of
SU BR20, but they are not automatically written out at
end of job.

13-32 WORKSTN File Considerations and Sample Programs

Record Identification Codes

I

Field
Indicators

Field Location

f---Filename

Line

Field Name

Cl

>

Position

I-

~
3

4

o

1

5

6

Zero
Plus Minus or

To

From

Position

Blank

-f--

o

R

A"NO
7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

~5

56 57 68 59 60 61 62 63 64 65

f;6

67 68 69 70 71 72 73 74

IINPluT

o

2

I

o

3

I

o

4

I

o

5

I

-

Position

c

1

5"
30;

=- 0

c., ,

Indicators

I

And

I

And

b TSTFL.O
" TESIi

Resulting
Indicators

Result Field

Factor 1

Operation

Plus IMlnusl Zelo

Factor 2

H~ L " .~ 1.,1., ~IJ..,"'" '" """""'"" ,,,. "" ", "", "~ """":":'" ",:': '~
__

~

__

~

_________

~

___

Compare

COn11l1ents

1> 211 <'211 = 2
Loo!o.up(Factor 2h$

~~~

High

___

L\J\\'

~_~

EQlJal

___

~

_ _ _ _ _ _4 -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Figure 13·13. Testing for a Duplicate Character Value (Hex 1C)

IBM-Written Sub-routines SUBR20 and SUBR21

13-33

Reading and Writing the Display Station Local Data
Area (SUBR21)

WORKSTI\J SAMPLE PROGRAMS

The IBM-written subroutine SUBR21 allows you to read
and write the display station local data area for each
display station whon multiple display stations are
requestors in a WORKSTN file. (For a complete
description of the display station local data area, see the
System Planning Guide.) To call the subroutine, you
must make the following five entries on the calculation
specifications:

Sample Program ITMINQ

r-

Result Field

Operation

Factor 1

Factor 2
Length

Name

.g :c
~~

~ ~
U '!:

aI

18 19 20 21 22 23 24 25 26 27 2829 .!O 31 32 33343536373839404142 434445484743 495051 5253

S)(il.J1"i I~uIp R21.1
IRLIAlsll
R!L~~l

!

I

~il~Bt

I

I

I

I

~

h"~~IA ~E

~IRie AJ

1

1-1-

~

R.cb mE;

if(l...IAiSl
I

I
o!PI

The sample program ITMINQ displays records from the
chained disk file INV. The display prompts the operator
to enter an item number that is used to chain to the
record in the disk file. If the record is found, the item
number, description, price, on hand quantity, and
quantity sold are displayed on line 6. If the item is not
found, the message ITEM NOT FOUND is displayed on
line 24. After the item record or the error message has
been displayed, the display prompts the operator for the
next item number. The operator enters a / (slash) to
end the job. See Figure 13-14 for the specifications for
ITMINQ, and see Figure 13-15 for the compiler listing
for the program.

1:1
1215~

i

OP is a 1-character field that contains an I to indicate
that the display station local data area is to be input to
the program for this display station, or an 0 to indicate
that the display station local data area is to be output
for this display station.
TNAMEis a 2-character field that contains the work
station I D for the display station.
RCODE is a 1-character field that contains the following
return code:

o = successful
= unsuccessful (the display station

is not attached to the program)
2 = unsuccessful (the display
station is not a requestor)
AREA is a field or data structure into which or from
which the display station local data area is read or
written. AREA can be up to 256 characters long.
Position 1 of the display station local data area is always
placed in position 1 of this field. If AREA is to be used
to pass parameters to OCl, the special characters 7 and
/ (slash) should not be used.
The display station local data area for the requestor of
an SRT program or the first requestor of an MRT
program can be referenced in RPG " if you define a
data structure with a U in column 18 of the input
specifications (see Chapter 7).
13-34 WORKSTN File Considerations and Sample Programs

Display Screen Format

'1
Figure 13-14 (Part 1) shows the display screen layout
sheet that is used to format the display. The individual
display screen format specifications ZITEM,
SHOWITEM, and ZERROR are contained in the format
load member ITMINQFM. (To form the format load
member name, add FM to the end of the RPG II
program name.) The display screen format names are
specified as constants on the output specifications (see
Part 4 of Figure 13-14). The end positions for these
constants are specified as Kn, where n is the length of
the format name.
The fields on the D specifications for the display screen
formats must be specified in the same order as they
appear in the RPG " output record. However, the line,
number and horizontal position columns can be used to
change the order in which the fields appear on the
screen.

Indicator 02 is set on after the execution of the first
READ from the display scre'en. This initial READ is
satisfied by reading a blank record from the display
screen. The ZITEM format is written to the screen on
the next cycle because indicator 02 is on. The operator
can then enter an item number in response to the
ZITEM format.
Indicator 03 is set on when the item number is read
from the ZITEM format (position 1 does not contain a
f). Indicator 03 causes both the ZITEM and
SHOWITEM formats to be written to the display screen.
The ZITEM format is not input-capable, as indicator 03
is on (indicator 03 is specified in columns 35 and 36,
suppress input, of the ZITEM format S specification).
The ZITEM format is made input-capable when the
SHOWITEM format is displayed (the SHOWITEM format
has an N specified in columns 35 and 36 of its S
specification, which enables the ZITEM format for
input). The ZERROR format enables the ZITEM format
for input in the same way.
Note: Only the last format displayed on the display
screen is input-capable. However, through the use of
the suppress input facility, more than one format on the
same display screen can be made input-capable. For
more information on suppress input, see $SFGR-Screen
Format Generator Utility Program in the System Support
Reference Manual.

WORKSTN Sample Programs 13·35

This displayed line is described by display screen format

,

7

0,

I

03
04

I

2,-30
4

!

I

I

I

I

I

,

I

I

I

,

I

I

I

I

I~"

05
06

NO.,
I

I
I

08

I

09
,0

I

I

I

3,-40\
7.
4

\

I

,

\

I \5,-60
0,23.5
7

41-50
7
4

I

I

\

I

(OR L IQ Etml

I

,

I

,

,

,

I

I

I

I

I

,

1\

1

~

I

I

, \,

,

I

I

I

I

I

;Plur~

I

C1>E,6c,)

I

I

I

:C~~Ei

I

I

I

I
I

I

I

I

I

I

I

I
I

I

I

I
I

I

I
I

I

I

I

I

I

1

I

1

I

I

I\NllAttb

I

SftLb

I

I

I

,

I

lON$N6J : {P&N~~)

I

I

I

I

I

I

7,-80
4151617890

1\

I

I

I

6,-70
7
1314

I

I

I

SHOWITEM.

I

L." __ !.~---'--'--~~~

I

,

'~lE"~

1\~(/gTJ)nftN

C 1T1&""~),

I

07

o

,,-20
7
4

ENTEIt 1T[14 ~1IB£&

02

:s:

I

,

,-,0
4

Lines 05 and 06 are described by display screen format

\

ZITEM.

I

I

I

I

I

I

I

I

1

I

L

"

I

I

I

I

I

I

I

I

I

I

I

1

1

1

I

'2

I

I

I

I

I

I

I

I

I

I

1

1

I

1

1

I

I

I

I

I

I

I

I

I

1

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

a: ,3

,4

i-----'-~

,5
,6

,7

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

1

I

1

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

,8

I

I

I

I

I

I

I

I

I

I

I

I

I

1

1

1

1

1

I

I

I

I

I

I

I

I

I

I

1

1

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

,

I
I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

1

J

,9
20

2,
22

23
24

~

I

IT~

l~lU'b
,,-20
#1

,NOT,

,

---'-'--'--

I

,

I
I
I
I
I
I
I
I
1
I"
7,-80
,-,0
4,-50
5,-60
6,-70
2,-30
3,-40
, 23451617 8191J , 234567890, 234567890, 23456789 0, 234567890, 234567890, 234567890, 234567890
I

T

I

I

T

I

I

I.

The error message is described by display screen format
ZE R RO R, and the constant is described in the RPG II
output specifications.

The individual formats ZITEM, SHOWITEM, and ZERROR
are contained in the format load member ITMINQFM.

/

System/~4 Display Screen Format Specifications

: SdL'I~

~lA~

Indicator 03 suppresses Input from this format until
another format is displayed during the same RPG II

/

cycle with suppress input-no specified.
U/M050'
GX21·9253
Printed in U.S.A.

~~

I I

I I I I I I I I I I II I III I I

Starting

Name
Sequence
Number

....

.£E
1 2 3

4

Field
th

I-----..---i L

~

5 6

o

~~

1j

wsu
Field Name

--:r
Location

Field

-

~~
;>

eng

~

a"C

•.

!: ~

],£

~

Z

::.

~!'._
~

~
...

0 -;.9 &

~

c:: a ]~
~ ~"C
~ 5~ ~
~ ~ ~ u:
0

u..

W

8~ ~ ~ to 6~
-.~ 6. :! ~ ~ = -0

6;E oS 0 ::.; ::.; ~



~

~
~c: -

III

Z

s e :: . :
0..

~

8.

>
;;j

0

E
JS
- ~
_~
>
II:

-g

:::> 8

Reserved

8.

~

Constant Data

.g
:J

c:

c

_s

c

81-'-2-3-4-5-6'-7-8-9-'-0-"-'-2-:'3-:-'4-:-'-5-:-:'6-:'-7'8-'9=-=2:-:-0-=-2'-2-=-2--12

u

7 8 9 '01112'31415161718 '9202122 232 2526272829303132 3 3435363738 39404142 344 45464748 49505'5253~45556 575859606'6263646566676869707,72 73 747576 77787980

L7 Z .Y

y

o
Figure 13-14 (Part 1 of 4), 'Sample Program ITMINQ

13-36 WORKSTN File Considerations and Sample Programs

y

y

~~ ]T~H

IY

GX21·9253

No. of sheets per pad may vary slightly.

~

WSU Only
Enter
Mode

~~u~~
Sequence
Number

I

u/M 050"

Printed in U.S.A.

System/34 Display Screen Format Specifications

7 3

Format

!
~

4 5 6

~

g

Reserved

Name

§~~~l~i

III

Review
Mode
Record

Insert
Mode
Record

:~~~~~~i:~g

Indicators

Identifyi~g

Reserved

Key Mask

etet

wwa:: a::

373839404147 3 44 45~6 47~8 49 05157535455565758 5960 61 676364 65 66 67 68 697071

7 8

I I

I

I

~

n

73 74757677 78 79 80

I II I

I

These fields are described in the same order as they appear
in the RPG II input and output records. However, the line
number and horizontal position columns have been used to
change the order in which the fields appear on the display
screen.

GX21·9253

UiM 050"

Printed in U.S.A.

System/34 Display Screen Format Specifications

"No. of sheets per pad may vary slightly.
WSU Only

~

&5

::) .8"

Sequence
Number

~

Format
Name

~
I-

7

3

4

11I1

5 6

J
I I

s

Sequence
~

~
1 7 3 4 5 6

U5

wsu
Field Name

C

~~

~~

~

-g

~.g E

_"

~ ~ ~!!~ ~ ~ ~ ~

~

Ii:

n

-1
~~e~:th

~
~~ ~~
>

1i j ~ ! I i ~ ~
:I:

0

.~
)(

W

j
§

~~~ ~ ~~~ ~

7891011121314151617181920212223225262728293031323

I I I I 0 MSr~ I I I I 11[4 11
U.J 1 0 11111 I I I I

Identifying

Identifying

Indicators

Indicators

2

1

WI I . I
>-

.8 -

~

~ ] I! ~ ~ l

I

Insert

~~:rd

3

2

1

Reserved

Key Mask
'C

a::

3

<37 7576 <77879303132333435 3f 37383940 41 47~344 45~647 84950515253 54555657585960 616263~656667686970 7172 73 74757677 787980

I

2~11/JdJ

~

0

! :; ~ I~ ~

"Reserved

Review

~~:;rd

3,.!l"'¥';:'
-

1l.

~ ~

~~! ~ ~~ ~ ~ ~ : ~
Starting
Location

Field
Name

j

:§

7 8 910 " " 1314 15161718 1970"

J:J
Number

~:.:;

e

j
I

'C

~~'J~

~ 1Y1

I

I III IIIIIIIIIIIIIII

u

"~

'C'C

0;

I I I



~

~

"u:

~8~ ~ ~ ~

~

8,

>

:o!
Z

!

c

l

R

d
eserve

~

~ ~;3
i:

8.

"

Constant Data

~

0

2

C

8

C

I

2

3

4 5 6 7 8

9 10 II 121314151617 18 19202122 7

8

34 35 36 37 38 3940 41 42~3 44 45 46 4748 49 5051 52 53 ,4 55 5f 5758 59 60 61 626364 65 66 67 68 6970 71 72 73 747576 77 787980

I I
.1

I

I I I

11

I I I

I III 111111111111111
I IIIIIIII IIIII IIII II

Figure 13-14 (Part 2 of 4). Sample P.rogram ITMINQ

."-

WORKSTN Sample Programs

13-37

Control Specifications

H

-

1~

I
Size to
Comrile

Line

~
,3 0~
<5

v;

Size to

E

"

~ Numuer

a

Execute

;; Of Frint "0
l=C Positions ~

j

1:3

2:: ~

:J

____~Mrod~el_2To~~~

~

0

I

Rt!fer to the specific System Reference
Library manual for actual entries.

Address

to Start

«~

M

n

2'2 13 24 25 26 27 28 29 30 31 3233 34' 35 36 37 3339 40 41 42 43 44 4546 47 43 49 50 51 52 5, 54 55 56 57 58 59 6061 62 63 64 65 66 67 68 69 70 71

~

III

i \

I

File Description Specifications
FIle Type

Mode of

P~ocessjng

Length of Key Field

File Addition/Unordered

Extent Exit
for DAM

01

of Record Address Field
End of File
Rccord Address Type
Sequ~nce

Filename
Line

Block

Record

Length

Length

Organization
('< or Additional Area

-S

~

~

O v e r fIndicator
lo_w

~

4

5 6

7

8

9

1011 1213 14 15 16 17 IS 19 2021

n

for Cylir(ler Overflow

Number of Extents
Tape
Re\,,,ind

Storage Index

~
Condition

0

~~

~1~~t~:~ld ~

:a:- ~
3

. NUr1"1ber of Tracks

Name of
Label Exit

Symbol
Device

Device

Type of File

File Formal

-Ii

Location

73 74

IIII1111111111111111

Z

Contimhlt10n Lines

Option

LU

-tt

2324752027 28293031 -1233343536373839 ""0414243444546 47484950 51 52 5354 55 56 57 58 59

Ul·~

~

Entry

606162636465666768697071

n

73 74

~~~~~rs.1.l\f1
~L ~~.,.;KrJ--~,
---_' ~.fl
'~,l:. - ---+~
.. !9 - - '+i -~.
WrO~.~l(tS~tNH-IAH+I
.
lIC -.___E~~_B5._1t5
__ '6~:1 __ f--__
U1t--~j..5il,

Filename

Line

Jl

;E

Z

E

4

0

1

I~l<

0

2

I

0

6

7

9

3

I

0 4

I

0 5

I I N~

0 6

I

I

N~

N5

7

I
I

:

I

I

I

~
0

Z

I

i

~!2

~.S

8

1 1

Position

0

Nfs

o

I

~

·0

.,"

~

e~
U

~

Position

2

Position

~~ju
Z

U

~

~

U

0

§

"

1ji

From

To

Field Name

Q.

]

~

g

~

8

0
0

~~
.~

]1

~
"0

.S g'

j

;~

0;

u.u.

-5

:~

:2u

"
u:

Zero
Plus Minus or
Blank

10 11 12 13 1415 1617 18 19 20 2 1222324 2526 27 28 29 3031 3233 34 35 36 37 38 39 40 4142 43 44 45 45 47 48 49 50 51 51535455565758 59 60 61 62 63 64 65 66 67 68 69 70 71727374

0

1 0

to

Field
Indicators

Field Location
3

~~

A~

3

5

::'0

2

1

07 it j

~

0 9

Record Identification Codes

0

~

0L3

11 C
liNtl

-'-

1

l1

:c/
r-~~ " ~\ r-~
~ 1\

I

I

I

1

-1--

I
\

i

L_L

\

i

1

!

I

17

11ll

.-

!

-t--

l1

+- ' -

1\

1\

,

Indicator 02 denotes a blank record. Most WORKSTN
files will start with a blank record for each display
station. Indicator 03 is used for the item number record,
and indicator 04 is used for end of job.
Figure 13-14 (Part 3 of 4). Sample Program ITMINQ

13-38 WORKSTN File Considerations and Sample Programs

L. '--'-

-

-

--

-~-

I

l1il
12~

1

f__--.
6

lill Itl"l llJ\
I

'---

b IIil~K~
111~~~~~
lt~ap:

~~~IIE
111 :

--+-

!
--f- - -- f-f__ --t--- r-r- --t-. -'r- - -

__

i
-

- _.-

-r- f--f--,- -r-r--i

.L Ll' ±'+-f___lL-._
_L

Calculation Specifications

C
I--

Indicators

~
0_

=0

AL AL

...Ja:

~z
~«
"'50:,:0'"

Line

85
345

78

all I

C

01 2 1

c

Factor 2

Operation

~

Length

?lus 'Minus' Z@ro
Compare

1> 211 < 211

Comments

• 2

_ Lookup(Faetor 2}1S
0

"

0

~

Z
Z
12 1314 15 16 17 18 19 20 2t 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 40 47 46 49 50 51

I L

I

Indicators
Arithmetic

~

Factor 1

Name

~1'0

Resulting

Result Field

'i¢3

IIIIIIIII

sl~11~F

II I I I II I I I I I II

~J

'11'1 I

II

IITIEl'ilNIQ I I I JjMAtrlIJ .llJi:v'I I I I I I I II I II II

~

Hi.h Low Equal
54 55 5657 58 5G 60 5t 62 63 64 65 66 57 66 €9 70 71 72 .3 74

~

... ~11

I

IIII I II II III II

I I III I I I I I I I I I I I

Indicator 99 is set on if the item is not found, and is used
to condition the error message ITEM NOT FOUND (see
the output specifications, line 11).

Output Specifications

-

o
Line

Filename

program. No format name is necessary on the release. If
one is given, the format is written to the display station,
then the display station is released from the program.

The PR ICE field is edited by RPG II (edit code 2 in
column 38). ONHAND and PENDNG are edited by the
RPG II L edit code. Because these fields contain
punctuation, they cann9t be used as numeric input
fields.

Figure 13·14 (Part 4 of 4). Sample Program ITMINQ

WORKSTN Sample Programs

13-39

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIONS
03
0124
SZITE""
11 2 6Y
0
Y
Y
DITEMNO
6 225
Y
Y
13 233Y
0
INPUT BUFFER DESCRIPTION
FIELD
NAME
LENGTH
ITEMNO
6

START
POSITION
1

ENO
POSITION
6

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIONS
SSHOWITEM
100
N
Y
8 5 3Y
0
Y
22 514Y
0
Y
9 541Y
0
Y
6
553Y
0
y
6 562Y
0
6 6 3Y
DITEMNO
DONHAND
6 653Y
6 662Y
DPENDNG
9 641Y
DPRICE
DDESC
22 614Y
EXECUTION TIME OUTPUT BUFFER DESCRIPTION
START
FIELD
POSITION
LENGTH
NAME
6
1
ITEMNO
1
ONHAND
6
PENDNG
6
13
9
19
PRICE
2P
DESC
22

CENTER ITEM f'IIUMBER
C OR / TO END

ITEM NO.
DESCRIPTION
PRICE
ONHAND
SOLD'

END
POSITION
6
12
18
21
49

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIONS
SZERROR
2400
N
Y
DMSG
14 1 2Y
EXECUTION TIME OUTPUT BUFFER DESCRIPTION
FIELO
START
NAME
LENGTH
·POSITION
MSG
14
1

ITMINQFM

SCREEN FORMAT LOAD MEMBER

FORMAT lITEM
REQUIRES
FORMAT SHOWITEM REQUIRES
FORMAT lERROR
REOUIRES

256 BYTES OF STORAGE
256 BYTES OF STORAGE
256 BYTES OF STORAGE

Figure 13·15 (Part 1 of 2). Compiler Listing for Sample Program ITMINQ

13-40

WORKSTN File Considerations and Sample Programs

END
POSITION
14

IBM SYSTEM/34 RPGII COMPILER

14

H

ooot

FWK
FWV
IWI,
I
I
I
IWV

0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021.
0022
0023
0024
0025
0026
0027
0028

03

CP
IC
NS
NS

F
49
F 45 4Sr, 6AI
02
1 C
03
1NCI

NS
NS

04
10

ITMINQ

WORt~ 37 3B 394041 42\43444' 46 47434! 50,'5253S45,/5t 57585960616263646566676869707112 73 747576)) 787980

rHHH~~~++++++-~~~~hH~vrH
1-H---H---t:-t-t--HHi-++++-~~2-T.1'~+-!'+.1I'i+-+-1H-+-+++-H
~
1\

o
o

Reserved

i

;

Figure 13-16 (Part 1 of 3). Sample Program INQPUT with Override Fields

WORKSTN Sample Programs

13-43

Control Specifications

i

H

~jze to

~ ....c.~
~~

a~
4

5

9

~;; Nl:mber
Of Print

0

Po!itions

:~

M

...J

10 11

c !!l -5
"" ~ c:...

"

i I

Size to
Execute

Compile.J

Line

3

M~~e

Model 20

~1----"""T"""-'-T"""'1r-T-r--l

f---

Address

~

to Start

~

{

1~

g e.

g'

E

C3

0>

.~

c.

E_~ u~ 1
u

5

~

6

.!: ~

>OO~~N-~~~

V)

".

__

Refer to the specific System Reference
library manual for actual entries.

a

i 11 ~i tIi ~ i !11
~

"C

j

~~Z

22 2J 24 25 26 27 28 29 30 31 32 33 3.( 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5

12 13 14 15 16 17 18

II

III

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

12

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

File Description Specifications
File Type

F

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

f---

End of File

Record Address Type

Sequence

Filename

Type of File

File Format

Line
Block
Length

~

(5 Overflow Indicator

8

4

5 6

7

8

9

FWK

51

I!

II •

I

!

!

~i
!

i

I

CP

IF

Location

Option

MI

6~II

J(IK!)

Ul.~

~

Entry

6061 62636465 66 67 68 69 70 71 72 7374

TN

1 InlT5 1<
1

Record Identification Codes

a

~

i
~

Filename

~

,--,-

o

R

r--r-

2

1

3

~ ~~

2 ~.o

1
i·
o

Field
Indicators

Field Location

1l

!

~

I
I

I
r--Line

~
Condition

W

L19

lIe

'

'

Tape
Rewind

Continuation lines

10 11 12 13 14 15 16 17 18 19 2021 2223 24 25 26 27 28 29 30 31 323334 35 36 373839 4041 4243444546 4748495051 52 53 54 55565758 59

21

o 6i

Number of Extents

Storage Index

~tea~t~~;ld .~

~ ~
3

Number of Tracks

for Cylinder Overflow

-5

~~

Length

w

Nor Additional Area

~

Record

Symbolic
Device

Device

...J

Organization

Name of
Label Exit

..

Field Name

~

Position

a::

~§j

Z

U

U

Position

-~ e·~~
o~
Z U

Position

~

U

~a

~§

~:6 CD~

Vi

From

To

~
]
]

8

c:

0

:2-0 ~
0

.!:!~

"-,,-

.S g'

10

~

:~

"C

:;:u

u::

-5

~~

Zero
Plus Minus or
Blank

0;

AND

3

4

5

6

7

8

9 10 11 12 13 1415 1617 18 19 20 21222324 25 26 27 28 29 3031 3233 3435363738 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6364 65 66 67 68 6970 71 72 73 74

1.1 t

0

1

1~~

0

2

1

i

0

3

1

I

0

4

1

0

5

lIN!\I

0

6

1

0

7

1

I·

o

8

1

0

9

1

lill
11

1 0

1

1 1

1

1 2

1

I

filS

Clll2
~I~

liN fll

NIS

1lJ~

11

NiS

NIS

irlj

~ 11'1: ~JINv

'C,I

12~

i

Record identifying indicator 02 is set on when the first
record (a blank record) is read from the display station.
Record identifying indicator 03 is set on when ~he
operator enters an item number. Record identifying
indicator 04 is set on when the operator requests end of
job.

Figure 13-16 (Part 2 of 3). Sample Program INQPUT with Override Fiel,!s

13-44 WOR KSTN File Considerations and Sample Programs

.

~
~

I~

IT!!

~M

~~"

HJ

~

"E

2pf-

l5 "'E

N[·

r

c
-

OJfi

1-0+-3-r~+C_-I---+-,1!E N.9-9

1

Comments

Compare

Name

o 1-: C
O~'
~,I['E'MNQ I ! I
I NIJ~~ I
I-O+2-i-~4---jCf--I----,o#~r-- -.-~ -~T i ~-SETOF I '

M,nu~ Zero

Plus

Factor 2

Operation

Factor 1

o 41

Resulting
Indicators

Result Field

Indicators

I I

length

~c:
~,

! I

I

--f---

_ _ _ _ __

~~==_~~~

BET{)~ ~.~'~~--~---'---~----t--.---+-+--j--~&:~-+----+-----------'----

C

~O+5--:I-+-C+-"-'+---+-':'-"-+-I-+-- ---I-----+-----O!-1-+---"----.--r--- - - - - ----+--1-1---1------1--+---- - - - - - - -... - - - - - 1
1--L-"---l--I-I-4-._--I-----I----l- 1--';' ____ ~ ___ - __ __I__..:...-__'_.~~-------+------~-.J--I--+--l-.

-~

-------.------- ---

No Sign

CR

~

X •

I

A

J

V •

2
3

C

L

4

0

M

The CHAI N operation uses the ITEMNO field to retrieve
the record from the INV file. Indicator 99 is set on if a
record is not found in the INV file; indicator 05 is set off.
If indicator 99 is not on, indicator 05 is set on.
Indicator 05, if on, suppresses input to the ZITEM
format.

-

~

0

'§
w-L!

Space

Output Indicators

Skip

t: ..
o "
Filename

Line

~
fE

3

4

I

5

0

6

2

0

3

0

4

0

0

7

8

E

L

I

~

And

L

A 'Do

~.!!.-

v;r~

a

~~
iR"
>.;.;. f---

f-

J
o
o
o
o

:caS

a

'"

<

0

a
a:

0

z

z

Field Name

z

'AUTO

~~

~ ~

1>
End
Position
in
Output
Record

iI

Commas

Zero Balances
to Print

Yes
Yes
No
No

Yes
No
Yes
No

B

Remove
Plus Sign
Date
Field Edit
Zero
Suppress

K
Z •

a:

:J

Constant or Edit Word

Cil
Ci:

1 23 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 :20 21 22 23 24 '
AND
9 10 11 t2 13 1415 1617 18 19 20 2122 23 24 25 26 27 28 29 3D 31 32 33 34 35 36 37 38 39 4041 42 4344 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

~

t"'\f'i(

~ -2

i

Qj :3 I

! I I

I
:

I

Ii

JKjj

!

IITIF-M 'Mt)

I

I

I~

2V

'1lJT:T!cl~
i

liTlEW

i - I
'

[

i!

11

i

I

:

I

I

,orr IFO U~

I

1

I

11
I

I

I

I,

I!

I'

I
:

I
I

~

i

0 5

0

6

0

7

0

o
o

8

0

9

0

1 0

0

1 I

0

1 2
1 3

•a
a

I 4

0

i

:

:

5

0

i I

I

I

I

~r~

I

,llI'tn
1'\1

I

I

"7

I~ H'J Mll

J(
Il"
,..,

'"~A I\IJr"It

I

I

I

!

i

t
!

1,.1

D~

~4

'< I~E 2-

Se.

17
:9

T!

I
I

!

I

I

II

I!

I

T

I

II

I

i

I

i

ott
:i

!
I

I

i i

!

I

I

!
! I ,

I

!

!

I

r

1

!

I

tlJV

!

I

o
o

'",

I I

I

The ZITEM format is written to the display if indicator
02 or indicator 03 is on. The SHOWITEM format is written
to the display if indicator 03 is on and indicator 99 is
not on. If indicator 04 is on, the display station is
released from the program by the R in column 16.

Figure 13·16 (Part 3 of 3). Sample Program INQPUT with Override Fields

WORKSTN Sample Programs

13-45

Sample Program I NQRY2

If the item number does not match an item in the disk file,
the message ITEM NOT FOUND is displayed on line 24.
After the item record or the error message is displayed,
the display prompts the operator for a new item number.
The operator ends the job by entering a / (slash).
'Figure 13-14 (parts 1 and 2) show the display screen format
specifications for sample program ITMINO. The same
display screen format specifications are used for sample
program INORY2. For a description of these display
screens, see Display Screen Format under Sample Program
ITMINQ in this chapter.

The sample program INORY2, shown in Figure 13~17,
is very similar to sample program ITM INO. The only
difference is that the WORKSTN file, WK, is processed
as a demand file, rather than as a primary file. The display
prompts the operator to enter an item number that is used
to chain to the record in the disk file. Since WK is a
demand file, the item number must be explicitly read into
the program via the READ operation code. If the record is
found, the item number, description, price, onhand
quantity and quantity sold are displayed on line 6.

Control Specifications

H

I
!

Line

~.~

Size to

Compile

U

8

11 I

Size to

~

~

Pr~nt ~

Number

of

a

PositIOns

~~C> o. ·§o;~

Reserved

(Ii

~

-~c-

c

U

~~

u

o

Jo-

'~-A

:;

VI

u-e,0

~c~ ~ .co. ~ z~ j
_...

-

II

I

I I

I

I

I

I

I I I

I

I

...

48 49 50 51 52 5

F

Length of Key F,eld or
Record Address

Sequence

Filename

Type of File

File Format

Line

o

e
~

Block

Record

-

-

!Q

Length

Length

g~
3

4

a

2

a

3

o

4

a

5

5 6

F

7

8

IlJll<

9· 10 "

N

w.------,-----I

a
j:::

~ ~?:
w

Ty~e

.
~
CI:

::::

~

-'
W

Organization or
Additional Area

CI:

8

Sym' olic
Dev e

Device

!:

F

r.c

f

The WORKSTN file is combined (C in column 15) and
demand (D in column 16). WOR KSTN record length is
the same as the largest input or output record.
Figure 13-17 (Part 1 of 3). Sample Program INQRY2

13-46 WORKSTN File Considerations and Sample Programs

I

I

I I I I

I

I

I I I I

I

File Addition/Unordered

Z
Vi

~

Number of Tracks
for Cylinder Overflow

Name of
Label Exit

Number of Extents

Tape

~

Storage Index

Condition

~~

~i9

I

Extent Exit
for DAM

i2 Overflow IndIcator ~
e
~ )(

Continuation Linl:s

Z

:::J

K

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4546 47'

cln

I I

0

I r~a~~~7;n w
~ I-u--'-------''---="Ex-te-rna-:-I-:!-Re-co'--:rd":":"Na...Jm'-e-L.....L_-'--"'==--......,
:::;

I

~

of Record Address FIeld

End of File

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I

Mode of Processi n9

File Designation

t----

Refer to the specific System RPG
Reference manual for actual entries.

E

~3

I

File Description Specifications
File Type

.~

t;)

i~1~jJ~li

CI:~ -g E cd ~ c a:

>

~

!i

;",2 N
_

c

1:1 13 14 t5 16 17 18 19 20 21 22 73 24 25 26 27 28 29 30 31 32 33 34 35 36 37 3839 40 41 42 43 44 4546

1/1'1

H

~

~Ji;.§

g~ ~ ~ ~
~0 ~~ a
~ 8cu 8~ 1t:' ~~

C

9 10 "

I

Execute g'

83

E

~
a

~ ~

i

~~RKS~N

1 1)1.51<

Option

49"50 51 52 53 64 55 56 57 58 59

Entry

<

U1-U8,
UC r - -

~

60 61 62 63 64 65 66 67 68 69 70 71 72

1/

I

~lllJ

'/

This entry specifies the number of individual formats in
the format load member, INORY2FM.

n

74

Input Specifications

I

External Field Name

0

'---

Filename
or
Record Name

-;'"
c C

2

1

f

3

:0,

Line
Data

'£.!i-

Structure
3

4

8

AND
Name
9 10 11 12 13 14 15 18

o

1

llwl~

liS

o

2

I

o

3

I

o

4

I

5

6

7

o

5

leI: ~iV

o

6

I

o

7

o

B

I
I

o

9

I

1

0

I

1

1

I

Field
Indicators

Field Location
Record Identification Codes

~

~

g

Position

19 20 21

HS

~l3

tJ5
INS

lot./I~

~

.... N :;

Position

~uO

~

1012

C

~2

ge~
~~6

Position

g

c

i

~§a

~

i~

ViC:

From

RPG
Field Name

To

Zero

Data Structure

Plu. Minus or
Blank

Occurs
n Times

Length

I,.

23 24 25 26 27 28 29 30 31 3233 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5u 51 52 53 54 55 56 57 58 5960 61 62 6364 6566 67 68 69 70 71 72 73 74

J.

Ii ,

lLt' C/

~

1.

lL I,. I

lL

1\

17

,

lL~

Ltl7
l2(}

1\

tzl1 EI1 11'40

b fir fM Aile
lL.LI~ 0 Nil AtJP

l1' ItJ PIEI~ j) Il'G

123 z.1~ Rl:z CIG
~!15 [l[ sic

Indicator 02 is set on when a blank record is read from
the display station. A blank record is constructed to
satisfy the first read to a device. Indicator 93 is set on
when an item number is read from the display station,
and indicator 04 is set on when a slash is read (end-of-job).

Calculation Specifications

C
I-

Indicators
Arithmetic

-

.Ja::

::-0

AL

AL

Plus TMinu$f Zero

Factor 1

Operation

Factor 2

~~~
~oa:
§ E
.:: 8 5

~

6

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

(1)_

5

Resulting

Result Field

0_

..

Line

Indicators

§

3

4

0

1

C

o

2

C

o

3

c

o

4

C

7

8

Compare

Name
....

0

z

(Lf~

Length

1

Comments

> if1 < if1 = 2

Lookup(Factor 21is

15
z

High Low Equal
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

qq

SIt: 11r(; f
, 'R IE AlD Iwll<
V CIH At! Nt. HY

ttif 'E f1 N~
V

A WORKSTN demand file requires a READ operation
to read data from a display station into the program.

I, '1'fi

1.1~

111
Indicator 99 is set on if the item is not found, and is
used to condition the error message ITEM NOT FOUND
(see the output specifications, lines 11 through 13).

Figure 13-17 (Part 2 of 3). Sample Program INQRY2

WORKSTN Sample Programs

1347

o

Output Indicators

Skip

Filename
or
Record Name

Line

tp>'

Field Name
or
EXCPT Name

t---

{i ~

6

01, I

0

o 2

0

1

8

10 11 12 13 14 15 16 17 Ie 19 20 21 22 23 24 25 26 21 28 29 3031 32 33 34 35 J6 31 J8

9

~~~
~rrr

i:I9

Output

...J

Record

a:

f-- - -

-;-"t-r+-" - !
r;-;~ 0 --, r ; -t- :t-T
o i6

0

i \ :

~ "Ttltr

u-=::~

---f---

~J";'-+r--'---

t

! ~ r~Ht :~~
0

09

1 O!
T

0

',' ';,',

: " '

,'-

t-~ r,j-~,
I"

3

4

5

6

I

!

,- -

-r ,-+ - -l- t,-~ ~

_Co.l'-- ',.t,

r- -f-

+

'f-"

+ :':-

Remove
Plus Sign
Date

Y

F,eld Ed't
Z

Zer.o
Suppress

5,9·
User
Defined

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

j-+-+-+--+-+--+-+-+-+-+-+--'--t

!

i

:

I

~~-f~T+~~~++~'~~~-+-t~i--+-1~+'+I~

_~~_~~H_, -O-'f-'--IW-F-11+1-t=E=-tII'l----'1--"I--t-+--t---t--!-\---r+-+---+--t-++-lI'-t---1-t--I!
i

,-

~"

['

I

..:......t,

--

-

--~-

++~ ~I~r.! ~~ t~ -= ~ ~ . ~_+_I-+--t-1'-+-+--+--t-+-t-!---+-t--+-t----I--t-+-!;

'i'- -~- ' - ___ PW~ct:.f-_~_
." r

- -

7

-+-+---1f--+---+-+-+-+--+-+-I--

- f-

"/.1.,- fl~ III"

r-

J
K
L
M

A
B
C
0

40 ., 4243 . . 4546 41 48 49 50 51 52 53 54 55 56 51 58 59 60 6t 62 63 64 6566 61 68 69 10 11 12 13 14

030"
'
: ;-!---~H- I
~0~'4-+0~:-,~I~:~:~;~D~~~+44-f-I¢~3-~N+9+,+4-f-~'+f-'

~--;~-t;~li-1

X

CR

Constant or Edit Word
2

W__ ,leJ 2.f- _,
f-- ' lOR_J _+j.
It 3 ~N,,9.!.-!-!9+--+-~-+-..j~_ ,f---f-f--i211<211-2
Low Equal

54 55 56 57 58 59 60 61 62 63 64 GS 66 67 68 69 70 71 72 73 74

1

125

LitlPl Ult'

IAIBiF 11

1

rflljj

1

-I

1

I i i
i

The item in TABF IL that contains 25 is to be changed to
30. The corr~sponding item in TAB LIT is to be changed
to 500. The search word is the constant 25. When a
match is found in the table TABFIL, the item from
TABFIL and its corresponding item in TABLIT are placed

i

I

1

I

I

in their respective storage areas. The number 500 is then
moved into the storage area for TABLlT; the number 30
is moved into the storage area for TABFI L. The contents
of the appropriate original table entry are now modified
to agree with the new entry in the special storage areas.

Figure 14-8. Changing Table Data With MOVE Operations

Calculation Specifications

C

Indicators

~

0_

~

..Ja:

Factor 1

Operation

345

0 I

C

o

2

c

o

3

C

o

4

c

o

5

C

8

a:"
..J

7

8

I

Factor 2

j(1)

line

Indicators

Arithmetic

AL At

=0
§:z

Resulting

Result Field

Name

Length

Plus Minu;f Zero
Compare

Comments

1>211 <2T1-2
Lookup(Factor 21is

0

0

0

Z
Z
9 10 1112 13 14 1516 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33343536373839404142 43 44 45 4647 48 49 50 51

Z

(61
3"

a1

lQ!aJ~

~i5 ~Ct

l!o Kll (.)T A'e~
MO VE NI! '-I A

MO ~[E

1tJ~ ~B

The LOKUP operation is conditioned by indicator 01.
Indicator 01 is on when a record containing information
in the fields NEWA and NEWB is read. These fields are to"
be added to the short tables TABA and TABB respectively.
To get the entry in the correct place in the table, a search
is made to find the first empty entry. Unfilled entries in

"fA ~Q

"A:eA

High
54

~5

Low Equal
56 57 5859 GO 61 62 63 64 65 66 67 68 69 70 71 72 73 74

3~

~IA ItH:

short numeric tables are filled with zeros. Thus, the
search word used is 000. When the first 000 entry is
found, indicator 35 turns on, and NEWA and NEWB are
moved into the storage areas of the related tables T ABA
and TABB. They, in turn, become part of the tables.

Figure 14·9. Adding Entries to Short Tables

Table and Array Output

14·11

EXAMPLE OF USING TABLES

Input Specifications

A payroll job requires two related tables: TABNUM is
the search table containing employee numbers, and
TABRAT is the related table containing employee salary
rates (see Figure 14-10). After an employee's rate is
found, rate is multiplied by the number of hours worked.
The result is the amount earned.

The input file TIMECARD is assigned a sequence of AA
(columns 15 and 16). Record identifying indicator 01
turns on whenever an input record is present for
processing. No record identification codes are specified
in columns 21 through 41 because there is only one
record type. Lines 02 and 03 describe the locations of
the two input fields used by the program. The employee
number (EMPNUM) is in positions 1 through 5 of the
input record. The number of hours worked by the
employee (HRSWKD) is in positions 42 through 44 of
the input record.

The table input records with eight entries in each record
are organized in alternating format. Each table has 500
entries. Therefore, 63 records are required. The first 62
contain characters in positions 1 through 72 (5-character
element in TABA plus a 4-character element in TABB,
times eight entries per record). The last record has only
four entries and contains characters in positions 1
through 36. Figure 14-10 shows the RPG II
specifications needed for the job. The following
paragraphs explain the entries made.

File Description Specifications
The input records are contained in the input file
TI M ECARD, which is designated as a primary file (P in
column 16). When this file reaches end of file,
processing ends (E in column 17). This file is read in
from the disk.
The related tables are contained in the input table file.
This file is designated as a table file by the T in column
16. The file is read in from disk prior to execution time.
An E is required in column 39 to show that additional
information about the file is specified in the extension
specifications.

Extension Specifications
The extension speci.fications complete the definition of
the file RATETABL. The table searched is TABNUM
(columns 27 through 32), which has eight entries in each
record (columns 33 through 35) and 500 entries in· the
table (columns 36 through 39). Each table entry is 5
characters long (columns 40 through 42) with zero
decimal positions (column 44). The table is organized in
ascending sequence (column 45).
The alternating table is TABRAT (columns 46 through
. 51). Each entry is 4 characters long (columns 52
through 54) with two decimal positions (column 56).

14·12

Ta~le~and

Array,s

Calculation Specifications
On line 01, factor 1 specifies the search word EMPNUM
(employee number). The LOKUP operation code is
specified in columns 28 through 32. Factor 2 contains
the name of the table to be searched, TABNUM. The
result field contains the name of the related table,
TAB RAT.
The LOKUP operation causes the employee number
(EMPNUM) to be used as the search word for the data
contained in TABNUM. Indicator 03 turns on when an
, entry that is equal to the search word is found in the
search table.
The operation in line 02 is performed when indicator 03
is on. The rate for the employee, taken from the related
table TABRAT, is multiplied by the number of hours
worked (HRSWKD). The result is stored in the field
EARNS, which is 5 characters long with two decimal
positions. The result is half-adjusted.
When an equal entry is not found in TABNUM (indicator
03 is not on), the operation. in line 03 is performed. The
literal 000.00 is then moved to the field EARNS,
specifying that the employee does not have an entry in
the table.

TABNUM
File Description Specifications
File Type

F

Mode of Processi ng

End of File

Record Address Type
Sequence

Filename

12345

407

12346

593

12347

369

12348

390

12349

1379

length of Key Field or
of R~c')I d Address Field

File Designation

f-

TABRAT

C'\jor Additional Area

Line
BloCk

2

~

Key Field

~~

0:
...J

-§

~O\lerfl~~

~

Record
Length

Length

Symbol ic
Device

Device

Type of File

O,ganlzatlon

File Format

~~:~~~~n ~

Extension Specifications

E

Record Sequence of the Chaining File

f-

Number
of

Number of the Chaining Field

Table or
Array Name

To Filename

Line

Number
of

Entries
Per
Record

From Filename

,= Ci~

Length
of

Entries
Per Table
or Array

cE

Entry

c:
...J
OJ

0:
3

4

5

6

7

8

9

Length
of

(Alternating

Entry

,

'"

~

Comments

c:
...J

Format)

&

OJ



Filename

Line

& ~~
-f- OR

~ c

f8

!

:'0.

j j '
Position

~ E §
:)

z:

E

POSItion

_

Position

~o - ;::~

~ 1

- 0 ?5
;
zuu

....

ZOe:

_!:"o
zuu

A~D

7

o

1

o

2

I

o

3

I

o

S

J

1_,- 1- ..

Inlwi

i

~

IWIii

1

I I

I

I

--r--- r-I·-

I

I

4

_

:u vii

c::.

~; _!:-;::
"Cl u~ "'~_~=. -ll.?
~
u

From

i I !
I :
f-f- - f - l -

-+it

-f-

I

I

:

!

:

i

i

:

:

4~;

I

i

I

__ '-

..5 ~ ~ ;
g .H
:; ';: 1
~u
u.

11

:

j

1

~

I

:5 '..J_:.a''':~N

;

J.'-i........!....[

1

~relo
Blan!..

~~

6G 67 68 GJ 70 71 72 73 74

T

44It tl'K~W\ft
:11

~~

PillS \linus

8c

47 4S 49 50 51 52 53 54 55 5L' 57 5$ 59 GO \,.,1 6::: 63 64

J

:=:lj

---+-n

~=

To

0

tiC::

Field Name

,.:;

9 10 11 12 13 14 15 lG 17 18 19 20 21 22 23 24 25 2ll '27 28 ::9 30 31 3:' 33 .34 35 36 37 38 38 40 41 42 43 44 45

IT IT I'll"

Field
Indicators

Field Location

~-

I

I

I

I

!

I

:

i

:

Calculation Specifications

C
I---Line

Indicators

~

=0
...Jc:

~~~
0 a:

Resulting
Indicators

Result Field

1 1

0_

Arithmetic

Operation

Factor 1

is i

Factor 2
Length

Name

~

E ::: '"

~
3

4

0

1

5 6

0

2

o

3

c
c
c

o

4

C

85·
7

8

0

0

~ ~

Plus IMinusl Zero

Comments

Compare

1>211<211=2

g ~ Lookup( Factor 21 is

ou .z-

0

Z
Z
Z
High Low Equal
9 to 1112 t3 t4 1516 17 18 19 20 21 22 23 24 25 26 27 2829 3031 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5253 ')4 S5 5657 5859 GO G1 6:' 63 64656667 6S 697071

Q!!1
~13

Nl1I~

IIltII
I_I- I ....

-rIA I~IW IAI

IIII' 1~11I1"

I~

,.,:c 1\l1~

1Cl~

t.1U Ul

il ~tl'l~

lr.iI::

lu!rl

.

,~~

rr~BR ~11
ICln!~"

:JI

!

il!; 1.2IH
:

i

i

I

i

~

m
j

I I
-)
I

:

I

1

I
i

I
I
I

II

I

i

n

73 74

I:II
IIII
i I I
i

IIi i

Figure 14-10. Related Tables Used in Payroll Job

Example of Using Tables

14-13

EXAMPLES OF USING ARRAYS

Building an Array Using Field Indexes
Figure 14-11 illustrates a method of loading an array
using fields in input records as indexes. The figure
shows a sample 12-element array, with each element 5
characters long. The array could be defined with any
number of elements (to a maximum of 99) without
additional input specifications. To do this you would
assign different values to fields X1 through X10 on each
input record type 03 and to fields X1 and X2 on each
input record type 04. Succeeding type 03 records can
then load 10 additional elements into array AR, up to
the maximum defined in the array; each type 04 record
can load two additional elements.
Blanks and other fields can appear on the input records
because the array elements and their index are identified
by the from and to entries.
This method requires a minimum of coding and no
calculations to set up the array. Extra work, however, is
required to set up the indexing scheme for the input
records.

Building an Array Using Fixed Indexes
In Figure 14-12 eighteen 5-character elements of array
AR1 are loaded with only two specification lines. On
succeeding input specifications, other elements of AR1
are loaded one after another until the array is full. Each
additional element is coded on a separate line. Each
new record requires a separate means of identification.
For example, if another 03 record followed the first, the
fields on the second record overlay the fields read in
from the first record. This method works well for small
arrays.

Figure 14-14 shows the same tabulations being
performed on arrays. Note the reduction in coding
required to specify the functions. For example, line 5 of
the calculation specifications performs the same function
as lines 5 through 8 of the calculation specifications
shown in Figure 14-13. Similarly, the output
specifications are reduced from 15 lines to 6. The
method using arrays results in only two positions
between array elements.

Using Arrays to Format Field Output
Figure 14-15 illustrates the use of three arrays to format
field output. The arrays are defined as follows:
Array.
Name

Number of
Elements

ARA

4

5

ARB

5

10

ARC

6

4

Array ARA is contained in the input records with record
identifying indicator 01, ARB in the records with record
identifying indicator 02, and ARC in both types of
records. Array ARC and the element of array ARA are
to be included together in an output record as are arrays
ARC and an element (identified by field X1) of array
ARB. Every element in array ARC is edited according to
the edit word 'Ob. b b&CR' (where b represents a
blank).
The contents of the arrays in the first two input records
are:
Record

2

Array

Array Contents

ARA

12345678901234567890

ARC

01234567890123456789876N
(note that N equals minus 5)

ARB

JOHNb DOEb bJOEbSMITHb
LEEb MARXb bJIMb KNOTSb
TIMbTYLERb

ARC

(the same as in record 1)

Calculating Totals with Arrays
The specifications in Figure 14-13 tabulate three levels
of totals. As they are read from input records, the fields
FIELDA, FIELDB, FIELDC, and FIELDD are added to the
first level totals L1A, L 1 B, L1C, and L1 D. These first
level totals are added at the time of an L1 control break
to totals L2A, L2B, L2C, and L2D. Similarly, at an L2
control break the second level totals are added to third
level totals L3A, L3B, L3C, L3D. In addition, as control
breaks occur, L1, L2, and L3 total output is performed;
and total fields are set to zeros after they are written on
the output device.

Element
Length

I

\,
14-14

Tables and Arrays

Extension Specifications

E

Record Sequence of the Chaining File

I--

Number of the Chaining field

Table or
Array Name

To Filename

Line

From Filename

34

o

5

I, I

6

78

9

Number
of

Per
Record

Entries
Per Table
or Array

length
of
Entry

TJble or
Array Name

J~

(Alternating

~ ~ ~

length
of
Entry

Format)

~~&

Comments
0:

~

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4041 42 4344 45 46 4748 49 50 51 525354 5556 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I I IIIIIII IIIIIII

E

Number
of

Entries

~RJ

I I I I I I 1:1J2 I

II

I I III

I,~

01 1 E I I 1111111 1111111 II I L1U.1 III II

.U III I I

2

I I I I I I I I I I I I TTl I

1111111111111111

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

I--

Filename

Line

...
~
3

4

5

6

IS

~ ~n~~o· f_.~
~

~~~~8~

t;:'Nfo
7

8

9

5
00

Position

zou

j§&

Position

E

ZOU

~§3

Po,ilion

~ot-J~~~-!"~
-

zucia~

From

To

~
~

Field Name

...J
~

3
g

8

.~ f---r--..--~

0

:9.0
.~]!

~
"C

~~

]

~u

~

~

r"

Zero
Plus Minus or
Blank

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28293031 32333435 363738 3940414243 4445464748 4950 51 5253 54 55565758 59 GO 61 62 63 64 65666768 G9 70 71 72 73 74

Figure 14-11. Building an Array Using Input Fields as Indexes

Examples of Using Arrays

14-15

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

~

Filename

line

Field Name
Position

3

4

5

6

o

31

I

o

41

I

7

8

lL\1~

~~

IBiEl

~;tI

i

i

i

I

,
!

o

7!

I

From

Zero
Plus Minus or
Blank

To

9 1011 12 13 14 15 16 17 18 1920 21 222324 25 2627 2829303132333435 36 37 38 39 40414243 44454647 48 495051 52 53 54 55 56 57 58 596061 62636465666768 69 70 71 72 73 74

i
I

Position

:

llrM leli

! I
110!a ICl2

!

iii

I

II

I

!

:

11
III

HI

.0_;,_8~i. 1-1_1--1--'-+-'-+!-l---J--.I.'-l---l--li-l---I--I-l---l--l---:-'-+-'I -+-l-+-+-1---+--+-+-I--+-l---+--+-H--l-l--I--l--IH-+-II-+-l--I-+-+lel+~+I---lI---+
0:9

I

:

iii

I I

I

!

I!

~~-~ ~i T:iT1T-:-+-+-++-H-Lr-i--i-!;-+-+~H-+-+-t-'f-+-I--jl-t-+--t-Hf-

I

)

More array eIeni ents

I

,-.- I I , ' ! i l l : I : \
1-'---:-- f-I---+--H-+-t-t-f-l-f- H-f- f-~HH-+-+++-H-+-++-+-HH-++-+-HH-+-+++-HL-+--=+-+-+-~H-+-+-+-+---H-+-+++-HH-+-+-l
~-,

'2'

--!

I

_~~~~~

'i!

i

I_~_~~~_~_~~L~~~~~~~_~~~~~~~~i~~~~~~~~~~~~~~~~~~

Figure 14·12. Building an Array Using Fixed Indexes

14·16

Tables and Arrays

Calculation Specifications
Indicators

C
f--

0

Factor 2

0

0

a

1

a

2

c
c

a

3

C

a

4

e

a

5

C

a

6

a

7

a

8

a

9

1

a

0

z

z

,FlrIE\. nA
IFIT E:ll nR
FII ~Il nr

1 3

D~
D~

ILl
Itll

rI

Ill2

n~

Il A
il lB
IL t...

I

Ill1

D

t'lr fin

r~

cL
el
cll
ell
cll
cll
c

2

1>211<211-2
Lookup(Factor 2)is
High low Equal

E
u

Cl

11
1

~

9 10 11 ,2 '3 '4 15 ,6 17 18 19 20 2' 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4, 42 43 44 45 46 47 48 49 5051 52

5

~ID
~

nt'

.c

n

L

"::

Il3

In

,

l

--

~12.

I

~
~~
~lZ
1~12

IL 'A
Il B
l 'r

I~

~r

L

b12

~

L

_.

~~

~

L

IL12

'12.

{)

L

,

1'1

L21'1

IL

Liz

~

Il
l A
Il

Ll B,.
IL

til

54 55 56 57 5859 GO 61 62 63 64 65 66 67 68 69 70 71 72 73 74

If: 12.

A

L

Comments

Compare

0

Length

Name

z

Plm IMinu'!i17pro

-;;;

Line

4

Indicators
Arithmetic

c

Operation

Factor 1

At

At

3

Resulting

Result Field

:1)

I

Output Specifications

-

0

~

~
~ ~ E

Filename

line

R ~ ~
-f-o E l

0.

>

AroO

I-

j
3

4

o

1

5

6

0

a

2

0

a

3

0

a

4

0

a

5

0

--

Output Indicators

Skip

Space

o

R

Jd

1

;;:

0

Z

Z

8

0

a 8
--a 9

0

- - I-f-1

a

1 __ 12 a_ -1-- ll1

-c- 1 - -

-,---- 1--1----

-- f - - f--- f - -

-

f-I-

---

0

1 3

0

1 4

0

1 5

0

1 6

0

No Sign

CR

~

Ves
Ves
No
No

Ves
No
Ves
No

1
2
3
4

A
B
C
0

J
K
L
M

II

X =

Remove

Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

a:

Constant or Edit Word

...J

co

it
1

4

23

5

6

7

8

I~
i i I~

--

~5 c-f-- c--f13Q
t

\(-

1011 12 13 '4 15 16 17 18 19 2021 22 23 24 •

9

-

r-- - c-_

I!

I

!

1

I!
II

i

!

I
I

I ,

'

tilT
I

i

1_ --f---

t---

-

~-

1---

--t--

--

J

I

-1--

I

I

-1-1-+

--f--

t-I-t

-j-

-I-

-

J

~j~'-=
j

f--f-

tr

- - 1--

-

t--

1

-+T~-+

':

I

- ,

t)-

--

I

-H---;-

I

I

I

J

-

'

I

I

I

I

I

'I
I

,:

!

I

'
I

I

I

I

'

I

I---f-IT

I

i

I

I

i
~

ii i i i I
I

!

!

I

I

---- ,--1- ---.:- ~ ~L-t-+----"-l,-+
:
: I
I
! I I ,
I I I
:
I
~
I

:

I

'!

,_1 r-r-T

! : I

,

-1 --- -,

b~,~-t-r-- ~ ~~ -T-~5
~~ ---j+ ---ti-tl
I

,

'I'

1-

I
r

I

-

!

!

-l-

; L

I

i1---

-r-----t-

1

I

1

----+---T---+--

I

I

1-1

I

I' i '
!"
"

I

I

I

I

!

'

'

I

~--r-

l

--

:

-t- - --

I

I

i i ,i

-r- W'II
j

f-I-f

--

--

!

i ~!F;

I

-- t-t-

- - --

-c-

12

in
Output
Record

Zero Balances
to Print

I

1A
L la' _

f--I

-

--

c-- 1--1--- -- -

-f- ,-- -

-11
0
-- I--

~ ~

"AUTO

End
Position

Commas

J
HI-WCJ
i
r-t-+
'-+-HI--I-;c
I
,
-+
-t-~;a
++i_+
t-- if-_ !~~ -t~'~-:I~
- I+~ ,+--i~ll
i
t~-~- -rir+ 1+
--r ~l-~ H-i L, ~ ~ ~ H~f~ - -tr
~'---=f
-H--.--l~J,~
++~
i':
III
Wt:'-~-: I~
L ~
~ :~
-hI - t1 ----ii Ti-i-- ---tiTT
I
~
--1- Ii" -ti tWl -r~L~ jJJ--,--,--,-+W-1
+ ~=
--rrmi IT-1 --t--I i i I I,I I':: I Ii: IT --+--+--+-\J
-I-t-- - -t- t~Hr 3 ~-~f
+
mI
r~ 2tJ.
- i- -1-1 ~ j-~
t
,
.
.
.
,
I
-t- ~~-- ll3~-t-!i
~L+_L
i~i~+_~_~ ~~=~
I-L J_ ~ H--t
- ----

0
0

8 U

0

z

:>

'0 11 12 '3 14 15 1617 18 '9 20 21 22 2324 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 61 68 69 10 11 12 13 14

9

t-,- - -- r-

a 6
0
- - t-t- 7

a:

'AND
7

a
~ ~

0

co

1--

o

Field Name

II

I :

I

i

I
I

Figure 14·13. Calculating Totals Without Arrays

Examples of Using Arrays

14·17

Extension Specifications

E

Record Sequence of the Chaining File

f-

Number
of

Number of the Chaining Field
To Filename

Line

Table or

Entries

Array Name

Per
Record

From Filename

3

4

a

1

a

4

5

6

1

8

Number
of
Entries
Per Table
or Array

Table or

o 0

Length
of
Entry

~~

Array Name
(Alternating
Format)

i11

Length
of
Entry

e

Comments

~

~

~ i

Q:

9 10 11 12 13 14 15 16 11 18 19 20 21 22 23 24 25 26 21 28 29 3031 32 33 34 35 36 31 38 39 4041 4243 44 45 46 41 48 49 5051 52 53 54 55 56 51 58 59 6061 62 6364 65 66 61 68 69 10 11 12 13 14

~

SL1

'&

Calculation Specifications

C
f-

1•• dicator5

~.

0_

-'a:
::0

Arithmetic

AL At

~!~

Line

Factor

1

Operation

Factor

.g I

2

~

Vl

1

8

&8 5"
3

4

5 6

a
a
a

1

C

2

C

3

C

a
a

4

C

a

6

a

7

~

~ ~

Plus Minusl Zero

Comments

Compare

1>21<211=2

'u - Lookup{Factor 2)i.

0

0

~ ~

z
z
o I High Low Equal
9 10 1112 1314 1516 11 18 19 20 21 22 23 24 25 26 21 2829 3031 32 33 34 35 36 31 38 39 40 41 42 4344 45 46 47 48 49 50 51 52 53 54 55 56 51 58 59 60 61 62 63 64 65 66 61 68 69 10 11 12 13 14

~!I F=ll

mlA

~l

AD

At)

1:1 ~IA
F_' ,-,

~~.
II:'T
~l ~l rr,rr,

cU1
cll2

5

Length

Name

I- (5 r:r:,"

E

Resulting
Indicators

Result Field

5L1

5L2

~IL 111111

11 .. L1

5L1111 12

Sit 11,1.2

3
A

Sl. 11. fq

5L~

~D ~
~D~
An~

ISL12.

AD~

ISLI3

~\. 1111

~Il

111l":!

alL2
~IL3

C

Output Specifications

-

o

1j_~
£

Line

'>

Filename

Space

Skip

t>

Output Indicators

,t..L

F;,Id

",m' ITa:· '".

a. - r -

a

>R

*~ ~ ~

f-;;i:' N 0
3

4

5

a 1
-a 2
a 3

6

1

8

I.LI

~

~

~

0

0

4

a

5

0

a 6
;--,-a 7

0

0

-~

0

Figure 14·14. Calculating Totals With Arrays

14-18

ZO

I
•

I

AUTO

~

II

::.

Position

W

No Sign

CR

_

:~. i ~ i

x

=

Remove
Plus Sign

Y = Oale
Field Edit
Z = Zero

L-.:.:.Nc:..0--'L--'.:.No=-----'L--'4_J--'0'--'_M"----L_ _
S_up_p'_es_s-l

5 ~utPut a:~

~ ~

Zero Balances

Constant or Edit Word

Record

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 •

9 1011 1213 1415 16 17 le 19202122 23 24252621282930:31 32333435363138394041424344454647484950515253545556 515859606162636465666168691071 12 13 14

0

a

11

_

Commas

Tables and Arrays

Extension Specifications

E

Record Sequence of the Chaining File
Number
of

Number of the Chaining Field

Table or
Array Name

To Filename

line

Number
of
Entries
Per Table
or Array

Entries
Per
Record

From Filename

...J

."a ~(;
a
g

'"

'~
Cl

Lenath

.~

of

Entry

a:

0:
3

4

o

5

6

7

8

Table or
Array Name

of

(Alternating

Entry

Length

Comments

Format)

l

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 69 69 70 71 72 73 74

4

Input Specifications
Record Identification Codes

I

Field
Indicators

Field Location

I-Filename

Line

Field Name
Position

Position

From

Position

Zero
PILlS Minus or
Blank

To

r=---

o

7

a

R

'AN"'D
9

10 11 12 13 14 15 1G 17 18 19 20 21 22 23 24 25 2627 282930313233 34 35 363738 39 40414243 44454647 48 49 SO 51 52 53 54 55565758 5960 Cl 62 G3 64 65 66 67

sa

0970 71 72 73 74

Output Specifications

0

"§

.,---

UJ

~ ~

Filename

Line

I-

>

~
6

7

1

00

a

2

0

a
0

a

5
6

e

8

+- f--~
--.~

-

0
- I-f----f----

--

J)- J1 --f-c~8_

- -I-

-

0
0

L....--L--L--. _ _

.,-

T

Z

n

9 to 11 ,2 13 14 15 1617 181920 21

UT

e

~

OJ

-

r--

,----

And

-

0

3
4

I

~

~~'o

a

a

~

D E L

~D'o

l-

5

Output Indicators

Skip

i~
>f-'- ~r3-

0.

3 4

Space

"-

!2 ;;

-

a

z

Z

'AUTO

-

-

-

~ - i-

f--

End

a:

Position

Q)

in
Output

23

~ ~

Record

Commas

Zero Balances
to Print

No Sign

CR

~

Ves
Ves
No
No

Ves
No
Ves
No

1
2
3
4

A
B

J
K

C

L
M

II

D

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

a:

Constant or Edit Word

...J

'"

Ci:

1 2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17

18 19 2021 22 23 24 '

r~+ -t-r- ~llf+·-H
Ji-+- ti--t- I+
HL~± ~
~~_I --~'R'
-~~~
I!
A~aTit+-

~

-

I
_.le_ .

,

[-

-f-

l

:>

23 24 25 26 2728 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4S 4G 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71727374

+~!.1

f-f---

a
;3

e

rr ~~
-JJ -1-:- f--tl- A~:~
~~ J~rr

f--

- -

L

Field Name

_l_

~-

-;- ~
-,1 r
L L,

Ii:

I

,-·J-t~-!-e _-W.-L
H~-I-:T~
t it-t---l-n- f-~--~- ___
--r- j='--

-T~-~

-Ti-

I

I

Ii

I

,I
___
rJI~ _LL __ ILLLl-.
, I

r-I-

I

I

--'I-- '------.L~

I

:

'

_LLL

Figure 14-15, Using Arrays to Format Field Output

Examples of Using Arrays

14-19

Printing Array Elements

In the first output record, the location and contents of
the arrays are ('0 represents a blank):
Array

Location

Contents

ARA
(first
element)

85-89

12345

ARC

37-84

One Element Per Line
Figure 14-16 shows a method of printing one array
element per line on the printer output device. The
contents of one element of a 22-element array, AR2, are
written to the output file ARFILE each time the
specification in line 3 of the calculation specifications is
performed.

'01.23'0 '0 '045.67'0 tJ '0
89.01'0 tJ '023.45'0 '0 '0
67.89'0 '0 '087.65'OCR

For the second output record assume that the content
of field X1 is 4; the locations and contents of the arrays
are:
Array

Location

Contents

ARB
(fourth
e!ement)

91-100

JIM'OKNOTS'O

ARC

37-84

'01.23'0'0'045.67'0'0'0
89.01'0 tJ '023.45'0 t> t>
67.89'0 tJ t>87 .65t>CR

More Than One Element Per Line

Figure 14-17 shows a method of printing more than one
array element per line on the printer output device. The
number of elements printed on a line depends on the
value assigned to the compare on line 10 of the
calculation specifications sheet. If an edit code is used,
each array element is separated by two spaces. You
must take these spaces into consideration when you
compute the end position for the output specifications.

Calculation Specifications

C
f--

Indicators

~

~

Arithmetic

At At

]

line

Operation

Factor 1

0

Factor 2
Name

g

3

4

0

1

8
c[

o

2

C

o

3

C

o

4

c

o

5

C

o

6

C

o

7

C

5

7

Resulting
Indicators

Result Field

Length

E

0

z

.~

0

0

z

z

0

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051 52

-A l)~11

nln ~'p

IL

11

ltl~

IN

iN

.,.",

IN

~c:,

t' I

c~ I4P

l22

Compare

Comments

1>211<211=2
LookuplFactor 2)i,
High

Low Equal

54 55 56 57 5859 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

12a

IN

11

Plus IMinusl Zero

0

~

5rJJ

1010 ~U 1111~
Output Specifications

o

I--Filename

line

:

:

5

~

AR F[lill~

13

141El~

1711

1~(: :~ 22 23

i

4
1R 26 27 28__

~9_::

1

::"':._

0

---f--I-+---t----H-t---,-

r: ::,3~1:;' ~_8_. ~
IQKIL,.I.lIW

40

~1142(3 44

I2J(l

45 46 47 48 49 50 51

:~I:f::

:.

57 58 59 60 61 626364 6566 67 68 69 70 71 72 73 74

~O~3-L°J_~~~~~_~-~~~!4_~~J_j,~~-~~-~~L_L~~J_:_ ~1.~+-~~~~4_~~~~4_~~+4~~~~+4~~~

Figure 14-16. Printing One Array Element Per Line

14-20

Tables and Arrays

Calculation Specifications

C
!---Line

ill.
>-

~
~

1

d

o

2

C

o

3

o

4
5

6

o

7

o
o

B
9

0

2

0

0

.IA ~]]1
AG
;l- ArD Uj
fA""

ell

nn

~1

liN

11ll

~1

N1~

,,{~6
~x ~PT

~'ul\

'1~ ~112

~n

TO

ItJ

2al

)(1

2al

l~

"0 Mil Isa
OT!ll culT
CD H~ l:1d
l"lO T1'I luP

lIN

49 5051 52

Xi

11
11

b'l)

43 44 45 46 47 48

AR 1,. IX1

AR 121J [N

~,O ViE

C

ell
ciL

cL

LookuplFoctor 21i •
High Low Equal
54 55 5657 58 59 60 61 62 63 64 65 66 67 68 69 70 7 t 72 73 74

0

9 to 11 t2 13 14 15 16 17 18 t9 20 21 22 23 24 25 26' 27 28 29 30 3t J2 33 34 35 36 37 38 39 40 41 42

Comments

Compare

1 >2JI <2(1-2

~

0

z

z

z

Minusl Zero

Plus

~

"

Length ~

E
.

UP

C

1 3

Factor

Name

C

1 5

1 2

Operation

Factor 1

c

1 4

11

At At

IDU MP

cL
c
c
c
c

1 0

Arithmetic

f-

o

o

Resulting
IndIcators

Result Field

...J

"0
§ ~
~8
3 4 5 6 7

o

Indicator$

~

l112

I

!1[~

rouIMP

1

Output Specifications
~

0
-

j Space

~~ ~

Filename

line

~~~

A

f-

j
3 4 5 6

o

7 8 9 to

It

o~ I~IF lLiE

0

2

0

- -1-+- -10

oro

al

~

z

Z

t2 t3 14 1516 1718 t9 20 2t 22 2324 25 26 27 28

1

3

R

1

r;~O

0

0

Jd

0 E L

>

II;

r-- - - r--I-

Jl -'-~-I

:>

Output Indicators

Skip

~

LR

---r

Field Name

~J" ~~ J-11-L
"AUTO

rrl
~

"

OJ

;3 5

~ ~

End

Commas

I

Position

In
Output
Record

Zero Balances

No Sign

CR

Ves
Ves

Ves

I

No

No
No

Ves

2
3

No

4

A
B
C
0

to Print

-

X = Remove
Plus$ign

J

V = Date
Field Edit

K
L
M

Z = Zero
Suppress

II:
...J

Constant or Edit Word

al

ii::

:

4

H-++

I

I

1++1'

71 72 73 74

! i1
!~
'III I ! IJfir-tTr
I I I ,- I t II
~ lL~
, ~. ~_lL_'_l~j~:_-·i-·rr!!I
I.LT..L_"':_~-I-~ _1-1LL-L_LLili I ! i ::! iii! ! i :

- -~ 1lJ(-Ji -~
i

2 3

5 6 7 8

9 10 11 12 13 14 15 16 17 18 19 2021 22 23 24
32 33 34 35 3637 38 39 4041 4243 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
1

Figure 14-17. Printing More Than One Array Element Per Line

Examples of Using Arrays

14-21

(
14-22

Tables and Arrays

Chapter 15. Auto Report Function

The RPG II auto report function is a program that
operates prior to the RPG II compiler. Auto report
accepts special, simplified specifications and standard
RPG II source specifications and uses them to generate
a complete RPG II source program. Special auto report
statements control the three separate functions of auto
report, which can be used in any combination:

Format of the Generated Specifications
The generated specifications are in the following format:
Column

Contents

1-4

Sequence number of the specification.
This number starts as 0010 on the
'RPG II control specification and
is incremented by 0010 on
each specification that follows.
If more than 999 specifications
are present in the program,'
the sequence is restarted at 0000.

5

Code that identifies the
specification as follows:

.. *AUTO page headings provide a simplified method of
coding page headings.
• *AUTO output 'provides
output specifications.
•

a simplified method of coding

/ COpy statement provides a method of copying
cataloged specifications from a library to include
them in an RPG II source program.

Blank
AUTO REPORT GENERATED SPECIFICATIONS

Standard RPG II
specification present
in the auto report
program.

Auto report generates a complete RPG II source
program that is ready to be compiled from the following
input:

C

Specification copied from
the library.

M

Specification copied from
the library and modified.

E

Specification generated
by auto report:

• Auto n:mort option specifications
• *AUTO page headings and *AUTO output
specifications in the source program
• Standard RPG II specifications in the source program
• Auto report /COPY statements in the source
program, with or without modifier statements
• Standard RPG II specifications, including tables and
arrays, and *AUTO specifications that are copied
from the library by the' auto report copy function

6-80

Standard RPG II specification.

Compile-time tables and arrays are not changed by auto
'report; they remain in standard tablel array record
format.

Figure 15-1 shows an example of the RPG II
specifications that are generated by auto report, and
Figure 15-2 shows the general method of operation of
the auto report function.

Auto Report Generated Specifications

15-1

Output Specifications

-

0

~ Space

Output Indicators

Skip

'i

~~ :;c

Jd

f--f-

~tf,~

o R
A~'o
5

6

78

9

3

4

o

I

O~ 1<1

o

2

0

o

3

0

o

4

0

o

5

0

o

6

0

o

7

0

- ' - r-I

I

--I

3

0

I 4

0

I

5

0

I 6

0

cr:

~ ~

8 U

0

0

z

z

~ ~

"AUTO

t!11
L2
L1

--

-f----- - - - --

+-

0
0

0

z

f-----

t~t

1+-'

It
~

- -

-I

1-- ---

t

--

- - ---I--I-

1-

i

- - - --

Zero Balances
to Print

No Sign

CR

:

Ves
Ves
No
No

Ves
No
Ves
No

I
2
3
4

A

J
K

Position
in
Output
Record

rUlTO

:.G ION

~O4

I

~'~ A,

g
Ii:

C

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 1819 2021 2223 24 •

«G%~~a~~~~M~~~~~rom~~M~~~~~ro

I

)

J

'r TE ~ I I
I ~ iJf.1 ~E
, Ilt"r PT to tJ J .
' SilL [5'
.... "of.

I--

;1 "--:~

---

.~

, AMO,UN
':0 N- HA NJ)'
'IV AL Ue'
I

'f IN AL

TO T~ LS'

From the * AUTO specifications in this example, auto
report generates the standard RPG II calculation and output specifications shown in Part 2 of this figure.
Figure 15-1 (Part 1 of 2). Using *.AUTO Specifications, Auto Report Generates Standard RPG II Specifications

15-2

Auto Report Function

L
M

Constant or Edit Word
,

EG 10
'R
Ica RA I~C

AN CM
EM NO

B
C
0

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

cr:

IS AL ISS ICE PO RT
'IF OR A y ICO. I

VA~ ue- ~

-

r-1-----l_j....I_ -

Iii I i

ViTO

n st

--

e--

--

~

I

Commas

Iw

I~

~

-1--

2

~

INll el~ IH

0

I

~

1(:

10 11 12 13 1415 16 17 18 19 20 21 22 2324 2526 2728 29 30 31 32 33 34 35 36 37 38 39 4041 42 43

o B 0
- - - -I-o 9
0
ItO

L

~ ~ ~

Filename

Line

Field Name

71 72 73 74

Generated Specifications

0012
0013
0014
0015
0016
0017
0018
0019
0020

0140EC
01
0150ECL1
0160ECL1
0170ECL2
0180ECL2
0190ECSR
0200ECSR
0210ECSR
0220ECSR

0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042

0230EOPRINTER H
0240EO
OR
0250EO
0260EO
0270EO
0280EO
0290EO
0300EOPRINTER H
0310EO
OR
0320EO
0330EO
0340EO
0350EO
0360EO
0370EO
0380EO
0390EO
0400EOPRINTER H
0410EO
OR
0420EO
0430EOPRINTER D
0440EO

0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062

0450EO
0460EO
0470EO
0480EO
0490EO
0500EO
0510EO
0520EOPRINTER T 12
0530EO
0540EO
0550EO
0560EOPRINTER T 2
0570EO
0580EO
0590EO
0600EOPRINTER T 12
0610EO
0620EO
0630EO
0640EO

EXSR A$$SUM
ADD SOLDV1
ADD VALUE1
ADD SOLDV2
ADD VALUE2
BEGSR
ADD SOLDVA
ADD VALUE
ENDSR

SOLDV2
VALUE2
SOLDVR
VALUER
A$$SUM
SOLDV1
VALUE1

206

92
92
92
92

SOLDV1
VALUE1

92
92

1P
OA
UDATE Y
PAGE Z

1

SOLDV2
VALUE2
SOLDVR
VALUER

45 'SALES REPORT
,
56 'FOR ANY CO.
8
89
85 'PAGE ,

1P
OA
6
14
21
36
47
62
71
86

2

1P
OA

1

01
L2

'REGION'
'BRANCH'
'ITEM'
'DESCRIPTION'
'SALES'
'AMOUNT'
'ON-HAND'
'VALUE'

Calculations to
roll totals for
SOLDVA and VALUE
fields

,

Page heading
(includes date
and page number)

)
Column headings

22 'NUMBER'

L1

REGION
BRANCH
ITEMNO
DESC
SOLDQYK
SOLDVAKB
ONHANDK
VALUE KB

3
12
23
40
46
62
69
86

Detail output
specificati ons

L1
SOLDV1KB 62
VALUE1KB 86
87

' ':-::.

L2
SOLDV2KD 62
VALUE2KB 86
88

I

':c :::~ ,

LR

Total output
specifications

SOLDVRKB 62
VALUERKB 86
47 'FINAL TOTALS'
89 ' ~:::::::::;:.: ,

Figure 15·1 (Part 2 of 2). Using *AUTO Specifications, Auto Report Generates Standard RPG II Specifications

Auto Report Generated Specifications

15·3

Output
RPG II and
auto report
specifications
in source
1 - - -....
library

RPG II Auto Report Function

•

Merges specifications copied
from the library with
specifications from the
source program.

Auto report listing
• Merged auto report
specifications
•

•

Diagnoses auto report
coding; produces a
listing.

•

Generates R PG II source
specifications; places
generated source program
in a work file.

Auto report
/COpy
specifications
in the library I - - - - - - J

Diagnostic messages

Generated
RPG II source

t;kfile

d

~ To

--V

(optional)
•

Optionally catalogs the
generated RPG II source
program in the library.

•

Calls the RPG II compiler
if there are no terminal
errors in the auto report
coding.

I

Figure 15-2. Operations of the Auto Report Function

15-4

Auto Report Function

Generated
RPG II source
program cataloged
in the library

compiler

Order of Generated Specifications

Output Specifications

Auto report generates the specifications in the order
required by the RPG 1\ compiler. When specifications
are included by means of a ICOPY statement, those
specifications are initially placed immediately after the
/COPY statement. After all specifications are copied
and before auto report generates RPG II specifications
from the H-*AUTO and D/T-*AUTO specifications, the
entire auto report source program is sorted into the
following order:

Output heading specifications generated for H-*AUTO
specifications appear in the same order they are coded
on the output specifications in relation to other RPG II
and *AUTO output specifications for the file.
Normally, RPG II output specifications generated from a
D/T-*AUTO specification are in the following order:

1.

Heading specifications generated for column
headings

1.

Control specifications

2.

Detail specifications

2.

File description specifications

3.

Total specifications, with the lowest level first and
LR last

, 3.

Extension specifications

4.

Line counter specifications

5.

Telecommunications specifications

6.

Input specifications

7.

Calculation specifications (in the order: detail, LO,
L1 through L9, LR, and subroutines)

8.

Output specifications

9.

Tables and arrays loaded at compilation time,
which must be placed last among the input
statements to auto report

This group of specifications is placed in the same
relative position in the program as the original
D/T-*AUTO specification. All other RPG II output
specifications remain in their original order.
If, however, the programmer specifies a normal RPG II
total output specification conditioned by a positive
control level indicator (no N in column· 23) in columns 24
and 25 for the file that has a D/T-*AUTO specification,
all output specifications in the program are sorted into
the following format:

1.

All heading, detail, and exception output
specifications remain in the same order as they are
in the generated RPG 1\ source program. Total
specifications that are not conditioned by a
positive control level indicator in columns 24 and
25 remain as they were in the program.

2.

Total specifications, which are conditioned by a
positive control level indicator in columns 24 and
25, are sorted into ascending order according to
the control level indicator in columns 24 and 25,
with LR last.

Calculation Specifications

Generated RPG II calculation specifications are placed in
the following order by auto report:
1.

Detail calculations specified by the programmer

2.

EXSR statement for the generated subroutine

3.

Total calculations generated by auto report,
grouped in order by level (all LO calculations, then
all L1 calculations, and so on)

4.

Total calculations specified by the programmer

5.

Subroutines specified by the programmer

6.

Generated RPG II subroutine that accumulates the
lowest level total

See Examples of Using Auto Report in this chapter and
Sample Auto Report Program (EXAUT2) in Chapter 19
for examples of generated specifications.

Comment Statements
Comment statements (identified by an asterisk in column
7) are allowed among the statements read by auto
report. However, because the sorting of RPG 1\
specifications is based on the contents of column 6,
comments may not occur in the expected order. To
ensure that comments remain with the correct
specification, place them after that specification and put
the same entry in column 6.

Auto Report Generated Specifications

15-5

Restriction

OPTION SPECIFICATIONS

The order of tables and arrays is not altered when the
source specifications are sorted. Therefore, when tables
and arrays are included from the library, they may not
occur in the correct order after the sort. For example, if
a file translation or alternate collating sequence table is
present in the auto report source specifications, then
any compile-time tables or arrays included from a library
member are out of order. That is, the included tables or
arrays are placed ahead of the file translation table.
Compile-time tables and arrays must be loaded in the
following order:

Specify options for the auto report program on the RPG
Auto Report Specifications sheet (see Figure 15-3). The
auto report option specifications are not required in the
auto report program. If present, they must appear as
the first specifications in the program. If they are not
present, auto report assumes the options that
correspond to blank entries (see individual entries for
the meanings of the blank entries). Option specifications
cannot be contained in a library member that is copied
by a /COPY statement, but they can be cataloged with
statements that are compiled when you use the
COMPilE OCl statement.

1.

File translation specifications

2.

Alternate collating sequence specifications

3.

Compile-time tables and arrays in the order
described on the extension specifications sheet

A solution to this restriction is to place the file
translation and alternate collating sequence tables in the
library and copy them from the library before any other
compile-time tables and arrays are copied. This
procedure ensures that the file translation and alternate
collating sequence tables are the first compile-time
tables in the generated RPG II source program.

If RPG II control specifications (H in column 6) are not
present either in the auto report source program or in a
copied library member (see /COPY Statement
Specifications), auto report generates control
specifications with blank entries. See Chapter 2 for the
meaning of blank entries for the control specifications.
The following columns on the auto report specifications
sheet are used in the same way as corresponding
columns on standard RPG specifications sheets. See
Common Entries in Chapter 1 for descriptions of these
columns:
• Columns 1-2 (page)
• Columns 3-5 (line)
• Columns 75-80 (program identification)

RPG AUTO REPORT SPECIFICATIONS

IBM

GX21-9139· UM/050'
Printed in U.S.A.

Int>::rnationar BuSiness Machines Corporation

1

Program

Page

Date

Programmer

2

IT]

75 76 77 78 79 80

01 _

~~~~;~I:ation 1

1 1 I. 1 I

Option Specifications

-

u
Reserved

Source Member Reference

3

4

°l'i

5

•. .,

U

7 Z

9

10 "

12 13 14 1!.. 11)

17 1?, 19 20 21 22 2J 24 75 2(j 27

I I : I I I I i I I I ill I I I

Figure 15-3. RPGAuto Report Specifications

15-6

Auto Report Function

2~

2:- ]0 31 32 33 34

3~

36 37 3839 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6364 65 66 67 68 69 70 71 72 73 74

I I I II TTT11 TTl I ITT I I I I I I I I I I I I I I I I I I I I I I I I I I

I

Column 6 (Form Type)

Enter a U in column 6 to identify this line as an auto
report option specification.

Column 7 (Source)
Entry

Explanation

Blank

The generated source program
is not cataloged.

C

The generated source program is
cataloged in a library on disk.

Use column 7 to specify whether the generated source
program is to be cataloged in a library. Whether or not
the source program is cataloged, the generated source
program is written to a disk work file from which it is
immediately compiled.
Generated source programs that are cataloged become
permanent library members (RETAIN-P). These
members can be deleted only by the DELETE function of
the library maintenance utility program ($MAI NT) or by
the SSP REMOVE procedure. See the System Support
Reference Manual for information on the $MAINT
DELETE function and on the REMOVE procedure. A
library member cataloged by auto report, however, is
replaced by any other library member cataloged under
the same name.
The generated source program is not cataloged when
terminal errors exist in the auto report specifications.

If F1 is entered for the library name or the library name
is not specified, the library name defaults to the member
name in the system library. If the member name is not
specified or is specified incorrectly, an error results.
If the name used by auto report to catalog the
generated source program is the same as the name of
an existing permanent member in the library, the old
member is replaced by the new member.

Columns 25-26

Columns 25 and 26 are not used. Leave them blank.

Column 27 (Date Suppress)
Entry

Explanation

Blank

Page number and date are included
on the first * AUTO page heading
line.

N

Date and page number on
the first *AUTO page heading
line are suppressed.

To suppress the generated date and page number from
printing on the first *AUTO heading line, enter an N in
column 27. When these fields are suppressed, the page
title and any other fields specified can occupy the entire
line. See AUTO Page Heading Specifications for further
information on the generated date and page numbers.

Column 28 (*Suppress)
Columns 8-24 (Source Member Reference)
Entry

Explanation

library,
member

Identifies the library member
to be cataloged. Specify the
library name, which can be up
to 8 characters long, beginnin'g
in column 8. Use a comma to
separate the library name and
the member name, which can also
be up to 8 characters long.

Make an entry in columns 8 through 24 if the generated
source program is to be cataloged in a library (C in
column 7). The first character of the library name and
the member name must be alphabetic (any of the letters
A through Z or one of the 3 special characters #, $, or
@). The remaining characters can be alphabetic or
numeric.

Entry

Explanation

Blank

Asterisks are generated for total
output lines.

N

Asterisk indication is suppressed
from generated total output lines.

To suppress asterisks from printing beside generated
totals, enter an N in column 28. See *AUTO Output
Specifications for rules used in generating asterisk
indication.

Column 29

Column 29 is not used. Leave it blank.

Option Specifications

15·7

Column 30 (List Options)

Entry

Explanation

Blank

Source program listing, headings, and
diagnostics are printed, and a source
program is produced if no severe errors
are found.

B

The program listing is not
printed; however, a source program
is produced.

P

A partial program listing
is printed, which includes
appropriate headings and diagnostics.

Column 30 provides for listing options at the time the
auto report function is generating RPG II source
specifications. If any severe errors in auto report
specifications are found, the listing is completed
(provided a listing is to be printed) and the system halts.
The auto report source listi~g consists of the RPG II
specifications included in the input to auto report, RPG
II specifications generated by auto report, and
specifications copied from the library.
Use the B entry to produce a source program for which
you already have a listing, and use the P entry to
determine whether minor modifications to a previously
tested program have generated any errors.

Standard RPG II output specifications are divided into
two general types (see Figure 15-4).
• Record description specifications (columns 7 through
31) describe when and where the output line is to be
printed. One record description specification is
required for each different type of line to be printed.
Only the first record description for a file need
contain a filename in columns 7 through 14.
• Field description specifications (columns 23 through
74) following a record description specification tell
when, where, and how each item of data (field or
literal) is to be printed on the output record. There
can be several field description specifications
following a record description specification.

Auto report page headings and auto report output
specifications are also divided into the two general
categories: record description specifications and field
description specifications. However, the use of entries
on these specifications is different from that of entries
for standard RPG II specifications.
The following output specifications are not changed
when they are used with * AUTO. See Common Entries
in Chapter 1 for descriptions of these entries:
• Columns 1-2 (page)
• Columns 3-5 (line)
• Column 6 (form type)
• Columns 75-80 (program identification)

Columns 31-74

Columns 31 through 74 are not used. Leave them blank.

*AUTO SPECIFICATIONS
The *AUTO page heading function and the *AUTO
output function provide simplified methods of describing
printed output. These functions of auto report are
requested when the characters * AUTO are present in
columns 32 through 36 of a record description
specification on the standard RPG output specifications
sheet. *AUTO can be entered on a heading, detail, or
total specification (H, D, or T in column 15), but not on
an exception output specification (E in column 15). Use
*AUTO with only one printer file in the program.

15-8

Auto Report Function

Columns 71 through 74 must always be blank on auto
report output specifications.

*AUTO PAGE HEADING SPECIFICATIONS
The *AUTO page heading specifications provide an easy
way to produce a page heading at the top of every page
of a printed report (see Figure 15-5). Up to five *AUTO
page heading specifications can be used for a
multiple-line page heading. If both standard RPG II
heading lines and *AUTO page headings are specified in
combination for a file, they are printed in the order
specified by the output specifications. The * AUTO page
headings can be specified for only one printer file per
program.

Output Specifications

-

s

o

~ Space
~

Line

~

4

0

I

5

6

~
A
7

B

~

'And

R

~

0

«

co

~ro

0

0

z

Z

L~

, I , , I U-L_i

0 4

0

5

0

r+-0

LU

co

II

in

~

Output
Record

~

to Print

Yes
Yes
No
No

No Sign

CR

~

X •

I
2
3
4

A

J
K

Y·

ncmove
Plus Sign

Yes
No
Yes
No

B
C

L

D

M

Date
Field Edit
Zero

Z •

Suppress

Constant or Edit Word

-'
•

1

2

3

4

5

I' ttn'----i--H--..lf"1l~I , III I _

.'

Iii

Lf- _-f- _~_

0 6
0
I - - f - - - --0 7
0

~
u

i5 ~

• AUTO

Zero Bal8ncE'S

Commas

6

7

B

9

1011 12 13 14 15 16 17 18 19 20 21 22 23 24 •

9 10 11 12 13l 14 15 16 17 18 19 20 21 22 23 24 2S 26 21 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5J 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

0

0

8

{l
0

z

End
Position

ex:

And

0 2
0
~+-t-t--+-+_+_IHRecord
Description Entries
0 3

--r----r--,

"-

roE~
tti oro

!
3

Field Name

~~ ~

Filename

:>

Lrr

Outplut Indi.Clators

Skip

.~

I I

+

_

I

,

i

1_ 1_

I

I

I

!

!

I

mtrW:

I

,

1

I--! Field Description Entries

1
I,

J- --- -r--r-- H1
L+_ -r---1-Li-I--I·~j~+.
I. I
~, '
-r- - -,-LL..l
~- -f- -~---t-+-I-r-~-t-Ht
-~
-rr
+I-rr-t±r-L-H-t-~~-H-r-~-r'--_U___ LL....l __ ~L~
'-___ ~_J.
_
ul..J.JJ.._~'---_
--,-f- -

i

-+-'f-+-+-+'I- - -

I----l----!--l---L-I.--L--I-l--l-_

I

IiI

,-+,

,

!

_ __

I

Figure 15-4. Two Categories of Output Specifications

Output Specifications
-

0

}

~ 5~

Filename

Line

Output Indicators

Skip

Space

~~ ~

Jd

-!-D E L

~
3

4

0

I

5

6

7

8

0

0 3

0

0 4

0

;3

;;:

0

Z

0

Z

Z

·AUTO

:>
End

ex:

Position

OJ

in

u

Output
Record

~ ~

Zero Balances

Commas

to Print
Yes
No
Yes
No

Yes
Yes
No
No

II

No Sign

CR

I
2

A

3
4

8
C

D

X = Remove
Plus Sign
J
K
L
M

Y = Date
Field Edit
Z = Zero

Suppress

ex:

g

Constant or Edit Word

Q:
1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 '

9 to t1 12 t3 14 15 1617 Ie 19 20 2122 23 24 25 26 2728 2930 31323334353637 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Ci6 67 68 69 70 71 72 73 74

oS AM IPLIE

0 2

co

o R
AND

a
:::

a

'AroD"

t--

1

Field Name

- -

Ii --

- ---

-- - f -

f---

--

r-'- --i-r---

. r-1!AFJt-I±c- rlJ;jl~'=It
-.. UJrl-L~f-H+·1 I+Htt
ISA
It<
±±±
'
±tJ±!
I!iill
I TJ.
_Le- _ I __ LlL_l _J-LLl l ii' I: 1..
1--- -

-

I,

- -

---

!

--+-- -

i:

-

-~+-

I~
-

--

-

1-11Jf)1

0

OJ

~~~
3

Field Name

n-

°

f---0~4.~_04~++_f_f--0

1---+--<5--+-04-4--+-+-+-+_ f--.f-- .--I--.f--

I

I

Cfli/l

MIN ~rE:11I1] IN

Ft~ L I~
_++~~~~_I~~++~~~~+~++'~L~II~11~I~fl~RAFIL~6~'+4~'~~~++~~~~~

,-l-t--+--l--+-+-+-+-+-+----t---l-+-+--l-+-+-~__+_+__l_++-H__+_H_+-f___+_+_t_+_t_f_+_t_f_++_Ilf_+_+_f_++_Ir___t_+_Ir___t_+_Ir___t____H

6
L°..l..---L..JL°L-L .L-1.---L-.L-L-.L.-l_-l ___ L-

--L -L-_L...L---LJI--L---LJc-L---LJ---L..LJ--L..LJ---L...L...!_.L-...L..1---L-L..!---L-L..!---L...L..1----L._LJ.----L.--L-.L----L..L-1.-L-_L_.L---'---'---'----'--.L-1.--'---.L.....l._

·As a result of these specifications, FIELD1 prints on each
detail line under the heading COLUMN HEADING 1.
FI ELD2 and LITERAL 3 print on each detail line without
a column heading.
Figure 15-6. Auto Report Field Description Specifications (Blank in Column 39)

Columns 7-22

Columns 32-37 (Field Name)

Columns 7 through 22 are not used on the field
description lines. Leave them blank.

Enter a field name, data structure name, indexed array
name, table name, or blanks in columns 32 through 37.
If columns 32 through 37 are blank, a constant must be
entered in columns 45 through 70 of the same field
description specification. If a field name, data structure
name, indexed array name, or table name is entered, the
value of the field or element is printed on the detail line
(or on the first total line if group printing is specified).

Columns 23-31 (Output Indicators)
Enter any valid RPG II output indicators in columns 23
through 31 or leave them blank. If these columns are
left blank, the field (or constant when no field is named
on the line) is printed on each detail line conditioned by
the indicator. When group printing is specified
(T-*AUTO specification), the field (or constant when no
field is named on the line) is printed each time the
lowest level total line is printed. If a column heading is
specified in columns 45 through 70 to appear over a
field named in columns 32 through 37, the column
heading is not affected by output indicators entered in
columns 23 through 31.

15-14

Auto Report Function

Column 38 (Edit Codes)
Enter a valid RPG II edit code in column 38 if columns
32 through 37 contain the name of a numeric field, a
numeric array element, or a numeric table. This column
must be blank for alphameric fields, data structures, and
table/ array elements, and for literals. If column 38 is
left blank on a field description line for a numeric field
or table/array element, the auto report program provides
a K edit code. The K edit code causes a numeric field
or element to be printed with commas and a decimal
point, such as 3,489.13. It also causes zero
suppression; zero balances are not printed, and negative
balances are printed with a minus sign on the right.

Column 39 (Blank After)
Entry

Explanation

Blank

Field is not to be reset to zeros
or blank after printing.

B

Numeric field is reset to zeros
after it is printed; alphameric
field is reset to blanks.

Enter a B in column 39 to reset alphameric fields or data
structures to blanks or to reset numeric fields to zeros
after they are printed. Blank after cannot be used for
constants. This entry applies only to the detail line (or
the first total line if group printing is specified).

If a constant is entered in these columns along with a
field name in columns 32 through 37, the constant is
printed on the first column heading line over the field
value. When a column heading is used, the length used
to space the column on the report is the greater of the
longest column heading length or the field length,
adjusted for editing. See Report Format in this chapter
for additional information on how columns and fields are
centered and spaced by auto report.
If a constant is entered in columns 45 through 70 and
field name (columns 32 through 37) is blank, the
constant is printed each time the detail report line is
printed. In group printing, the constant is printed each
time the first generated total line is printed.

Field Description (A in Column 39)

Columns 40-43 (End Position in Output Record)
Either leave columns 40 through 43 blank or enter the
print position of the rightmost character of the field (or
constant if no field is named in columns 32 through 37)
to be printed. If this column is blank, auto report
generates end positions for fields, constants, and
column headings. See Report Format in this chapter for
additional information and considerations.

Column 44
Column 44 is not used because packed and binary data
cannot be specified. Leave this column blank.

Columns 45-70 (Constant)
Enter a constant or blanks in columns 45 through 70
when column 39 contains a blank. Constants are
enclosed in apostrophes according to the standard RPG
II rules for coding constants. If these columns are left
blank, a field name, data structure name, indexed array
name, or table name must be entered in columns 32
through 37. Column heading continuation lines can
follow this field description line, but the first line of the
printed column heading will be blank. See Field
Description (C in Column 39).

Enter an A in column 39 of a field description
specification following a D IT - *AUTO specification to
accumulate and print totals for the field named in
columns 32 through 37 (see Figure 15-7). As many
levels of totals are printed as are defined in the control
level entry (columns 59 and 60) on input specifications.
A final total is also printed when the LR indicator is on.
(This process is called total rolling.)
If group printing is specified and a control level indicator
higher than the lowest defined control level is specified
in columns 23 through 31 on the record description
specification, totals are generated for the indicator
entered, all higher defined indicators, and LR.
The total output record generated by auto report if you
have entered an A in column 39 of a field description
specification is conditioned by the associated control
level indicator defined in the input specifications. One
total output record is generated for each control level
indicator defined in the program.

* Auto Output Specifications

15-15

Output Specifications

i~ ~"

o

I--

t
O"A;nUd IndA'lnad,o"

:

Filename

Line

".Id N.m.

R

to~~

~roro ~
OR....

r;-~to
3

4

5

6

7

8

~"'""·a:I~En-'-'d~-=.5> ~r." '.~~:~= ,.,,~
~

~

~

~

~

m

85

~

~ ~

• AUTO

:osition

Output
Record

L-:N~o----,---,-N~O_-L---,----,-=--D---L-..M,-,--_S_up_pre_ss-,

a:

~
~

'i i : ~ !~:,

Constant or Edit Word

.

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 •

9 10 11 12 13 14 15 16 17 Ie 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6566 67 68 69 70 71 72 73 74

1-+-1-+-Opq-S~Jjl.fI_F-tI~....
L-F1f""'!--t-f'iz:...1- r-i- --+-+--I-I-+--I-I-+-+-l-+_+_~lBl~~.nO I.il\
01 2 0
IOWICIUI'ILH fll)

J-j0

o 13

0

-

-r

-1-1-+--l-+-+--4-+--t-f""+--

~o4.1~4~0+4~+-+4-I-+--4-lf-r-j4~~·~r+-

I.; .\ •.• . -.,
i/

~I_~'~_~~_~_~_L~_J~~~~L-LLJ~_LJ-L_~_~~~;I,~~,~~L~~_'~~~~~~~.~-L~~~-L~~~~~~~

./

The A in column 39 causes the AMOUNT field to be
accumulated. Totals are printed for each control level
and a final total is printed. A column heading is specified
in columns 45 through 70.
Figure 15·7. Describing a Field That is to be Accumulated

Generated Total Fields

When an A is specified in column 39 of a detail or total

*AUTO field description specification, auto report
generates and names total fields to be used in
accumulating the required levels of totals. Auto report
generates the field names for the total fields _based on
the name in columns 32 through 37 of the A-type field
description. Names are generated in the following way:
• If the specified field name has fewer than 6
characters, 1 character is added to the name to.
create a name for the total field. The added character
is 1 through 9 or R, corresponding to the total
indicators L1 through L9 and LR, respectively. For
example, if ITEM is the specified field name and all
nine control levels are defined, the generated field
names are ITEM1, ITEM2, ... ITEM9, and ITEMR.
• If the specified field name has 6 characters, the last
character is replaced by one of the characters, 1
through 9, or R. For example, if AMOUNT is the
specified field name and all nine control levels are
defined, the generated field names are AMOUN1,
AMOUN2, ... AMOUN9, and AMOUNR.

Total fields are generated and named for all control level
indicators defined in the program and for LR. (For an
exception to this rule, see Figure 15-11 under Group
Printing.) For example, if L1 and L3 are assigned to
control fields on the input specifications and the field
QTY is specified, three total fields, QTY1, QTY3, and
QTYR are generated and named by auto report. All total
fields generated for the same level, such as QTY1 and
AMOUN1, are printed on the same total line, and that
line is conditioned by the corresponding control level
indicator.
Generated total fields are two digits longer than the
original field. For example, if the field QTY is defined
with a length of three, OTY1, QTY3, and OTYR all have
lengths of five. The number of decimal positions
remains the same in the generated fields. You can
redefine a field name previously defined in a program
that is the same as a generated field name, giving that
field whatever length and number of decimal positions
you want. If you do this, the generated field is assigned
the previously defined length and number of decimal.
positions (if the previous field is numeric).

I

\
15-16

Auto Report. Function

Considerations

Generated field names can be referenced in RPG II
specifications that are included in the program. The
programmer must be aware, however, that the use of
generated fields in this way can interfere with the
automatic accumulation of totals performed by auto
report.
Field names ending in 1 through 9 or R should not be
used in an auto report program that accumulates totals,
because auto report generates total fields ending in
those characters. This is especially important for
6-character field names because auto report forms total
field names by replacing the last character with 1
through 9 or R. No field name can be used more than
once with an A in column 39. Also, if a 5- or
6-character field name is specified with an A in column
39, a second 5- or 6-character field name in which the
first 5 characters are identical cannot be specified with
an A in column 39. For example, if the following four
field names are specified with an A in column 39 in an
auto report specification, all but the first are invalid:
FIELD
FIELDX

Invalid because the first 5
characters duplicate the first
5 characters of the first field.

FIELDY

Invalid for the same reason as
that for FIELDX.

FIELD

Invalid because it is a duplicate
of the first field.

Columns 7-22

Columns 7 through 22 must remain blank on the field
description lines.

Columns 23-31 (Output Indicators)

Enter any valid RPG II output indicators in columns 23
through 31 or leave them blank. If these columns are
blank, the field described is printed on each detail line.
If indicators are entered in columns 23 through 31, the
field is printed only when the conditions represented by
those indicators are met. Leave these columns blank for
group printing.

If a column heading is specified in columns 45 through
70 to appear over a field named in columns 32 through
37, the column heading is not affected by output
indicators entered in these columns. Also, output
indicators specified when column 39 contains an A do
not affect the generation of calculations for the field.
Output indicators specified on an A-type field
description specification following a D-* AUTO
specification condition the calculations generated for the
field. If the A-type field description follows a T -* AUTO
specification, however, a specified indicator does not
condition calculations generated for the field.

Columns 32-37 (Field Name)

When column 39 contains an A, the name of a numeric
field that is to be accumulated must be entered in
columns 32 through 37. These columns cannot identify
an array, array element, or table. The field named is
printed on each detail line of the report. If group
printing is specified, the total field for the lowest control
level indicator defined (L 1, L2, ... L9, LR, in that order) is
printed on the generated total line. (For an exception to
this rule, see Figure 15-11 under Group Printing.)
Totaling for any particular field by means of an A entry
in column 39 can be specified only once in each
program.
To generate calculation and output specifications that
accumulate and print the various levels of totals
required, auto report creates and names additional
totaling fields. Names for the fields are constructed
based on the. field name specified in these positions
according to a set of rules (see Generated Total Fields).

Column 38 (Edit Codes)

Enter an edit code in column 38 or leave it blank. If this
column is blank, auto report generates a K edit code for
the field named in columns 32 through 37. This causes
the field to be edited with commas and a decimal point,
such as 1,234,567.89. The field is also zero
suppressed. Zero balances are not printe,d; negative
balances are printed with a minus sign on the right. The
edit code specified, or the generated K edit code,
applies to all generated total fields as well as to the field
named in columns 32 through 37.

* Auto Output Specifications

15-17

Column 39

Columns 40-43 (End Position in Output Record)

Enter an A in column 39 to indicate that totals are to be
accumulated for the field named in columns 32 through
37 of this field description. A total is printed for every
control level indicator defined in the input specifications
and for the LR indicator. When column 39 contains an
A, columns 32 through 37 must contain the name of a
numeric field. Columns 45 through 70 can contain a
constant to be used as the first line of a column
heading. (See Generated Specifications for additional
information.)

Enter the print position of the rightmost character of the
field to be printed, or leave these positions blank. If this
entry is blank, auto report generates end positions for
fields and column headings. See Report Format in this
chapter for additional information and considerations ..

When the lowest control level indicator used for a
T-*AUTO specification is higher than the lowest control
level indicator defined in the input specifications, auto
report generates only the total lines corresponding to
the lowest control level indicator used for the T-*AUTO
specification, the higher defined control levels, and LR
(see Group Printing).

Resetting Total Fields to Zero: When column 39
contains an A, the auto report program generates a B
(blank after) in column 39 of all the detail and total field
description specifications generated from the field name
specified. Thus, the value in the specified field and in
any generated fields is reset to zero after the field value
is printed.

If group printing is specified, auto report generates a
calculation to reset the specified field to zero on each
cycle. This prevents the same value from being
accumulated more than once. An unconditioned total
calculation operation (Z-ADD) sets the field value to
zero. This calculation is the first total calculation in the
generated RPG II source program.

Asterisk Indication: To indicate that a printed line is a
generated total line, asterisks are printed on the line to
the right of the highest end position generated from the
D/T-*AUTO specification. One asterisk is printed to the
right on the lowest level total line generated. One
additional asterisk is printed on each higher level line,
including the final total.

For example, if L1 and L3 are defined control level
indicators in a program, one asterisk is printed to the
right of the L1 line, two asterisks are printed on the L3
line, and three are printed on the LR line. As many as
10 asterisks are printed on the LR line if all nine control
level indicators are defined in the program.
To suppress the generation of asterisks on total lines,
enter an N in column 28 of the auto report
specifications sheet.
15-18

Auto

Repo~

Function

Column 44

Column 44 is not used with auto report because packed
and binary data cannot be used. Leave these columns
blank.

Columns 45-70 (Constant)

Either leave columns 45 through 70 blank or enter a
literal. Do not enter an edit word; editing is
accomplished by an edit code. If a literal is entered
when column 39 contains an A, the literal becomes the
first line of the column heading over the accumulated
field.
If these columns are left blank, the first line of the
column heading is blank, but column heading
continuation lines can specify the second and third lines
of the column heading. See Field Description (C in
Column 39). Also see Report Format for information on
how column heading and fields are centered and spaced
by auto report.

Field Description (C in Column 39)
Enter a C in column 39 of the *AUTO field descriptions
to specify a second and third column heading line. At
times you may want more information in a column
heading than can be contained on one line. Auto report
enables you to specify the second and third lines of
column headings by simply specifying the literals to
appear on those lines. No additional heading output
lines need be coded; no end position need be
calculated. The special field description specification
that allows you to do this is identified by a C in column
39 (see Figure 15-8).

Output Specifications

o

~ '~c'

0"';"' "di;"""

""

::

i ~~
-r

Filename

Line

~

And

A

'Ato ro

!

0

co

_"



;3~ 5
~

• AUTO

~'N~

I I :> '"::" '"~::::~''' '":'. ': ; :: :,;~;~"

ar

I

"I"

DEL

o

And

Fi.1d N,m.

I

UJ

Yes
No
No

End
Position

in

a:

Output
Record

::J

2
3
4

B
C
0

K
L
M

Field Edit
Z .. Zero
Suppress

Constant or Edit Word

~
0.

'"

No
Yes
No

•

1

2

3

4

5

6

7

8

9

1011 121314151617 1819 2021 222324 •

10 11 12 13 14 15 16 17 Ie 1920 21 22 2324 2526 27 28 29 30131 3233343, 3637 38 39 4041 4243444546 41 48 '9 5051 52 5354 55 56 5758596061 626364 65666768 69 70 71 72 73 74

D_____+- ___ f--_~-~

I~IE

I I

I!

I

---+-LjJJl~~L~Tt!!

tL~~~ ~i~:1115'l' ~A~liRC~ ~DM~A-Wr~Y~:~E'
~ ~t;I~~3V_l:\.'J_' I~~"I
~:'~----H_U_-Jd_++-H--i-'
I i lei
I,m lE~ H'eADilfG. tn.~NE'
o
L,
!.
o
~
-r 1-11 i:I 1~.Y i~ TITill:
~ I ::n
o

___ 1_1_1_

0

1
-

--

-j--~I-r!

~!Jrna+__-

--

-H---HI

i

I

I

,I

___ '-_~, ____ ,--___L...!- ___ c-

--:- --

_. _______ ' -___

I

I

I

'--'---'---L...L.L_'--._y __
i!

:;:

I
-1- _.

!

I

i

1...

--

I

I

I _!. , ..... , __ -,~ _ _ L

I

I

I

i

I

:

:

'

!

1

' I : 1

I,

i

!

-- - - -- -I

JI

I

I

I

i

;

I __ _

I

I

i

C in column 39 is used to specify second and third column
heading lines. A maximum of three column heading lines
(two C-type field descriptions) can be used.
Figure 15-8. Specifying Second and Third Column Heading Lines

Columns 7-38

Columns 45-70 (Constant)

Columns 7 through 38 must be blank on a field
description that has a C in column 39.

Enter a constant, up to 24 positions long including
blanks, enclosed in apostrophes. The constant becomes
the second or third line of column headings, depending
on whether it is on the first or second C-type
specification. If two or three column heading lines are
specified, the shorter literals are centered on the
longest.

Column 39
Enter a C in column 39. One or two C-type
specifications can follow a field description specification
that has an A, 8, or blank in column 39 and an entry in
columns 32 through 37. The first C-type specification
causes a second column heading line to be generated.
The second C-type specification causes a third column
heading line to be generated (see Figure 15-8).

Columns 40-44
Columns 40 through 44 must be blank on a C-type field
description specification.

* Auto Output Specifications

15-19

Field Description (1-9 or R in Column 39)

This type of field description can print information such
as DISTRICT TOTAL, GRAND TOTAL, or other literal
information. It can also print a field and specify an edit
word, floating dollar sign, or asterisk protection for the
field.

Enter a digit (1 through 9) or R in column 39 of a field
description to specify a field or constant to be printed
on a specific total line.
Auto report allows you to print other information on
generated total lines in addition to the generated totals
resulting from A-type field descriptions. The value
entered in column 39 corresponds to the level of the
total line on which the information is to be printed (the
corresponding control level must be defined in columns
59 and 60 in the input specifications). For example, a 3
in column 39 indicates that the information is printed on
the L3 total line; an R indicates that the information
appears on the final total, or LR, line (see Figure 15-9).
Fields and constants specified in this way are printed to
the left of the leftmost generated total on the line. See
Report Format for exact placement.

If none of the * AUTO output fields is defined with an A
in column 39, then 1 through 9 or R cannot be used in
column 39. In group printing, only specify numbers that
are higher than the lowest control level indicator used to
condition the T -*AUTO specification. If the T -*AUTO
specification is not conditioned by a control level
indicator, use only numbers that are higher than the
lowest control level defined in columns 59 and 60 on
the input specifications.

Output Specifications

-

o

-5

f-

o

I

_

~~..!:.. e
ADD

R

i

~

4

5

6

7

8

ffi161
4!

T'

oi 5 :o

0
0
-.

0

0

t

e

DL
- -

- - i

!
"I"
I

Z

~:~tion

~~

ct

~ ~
i2

I

i
i i i

Z

Commas

8

:g

• AUTO

Z

II +
.-t~U!N1Y;
~A;Yl1a .{
-+rrr- --t-;-f--:i :--1 : I/ni
UJ

~

II

- - -

--1---

Record

~::

No Sign

x ""

CR
A
S
C

Yes
No
Yes
No

o

J
K
L

M

Remove

Plus Sign
Y = Date
Field Edit

Z = Zero
Suppress

Constant or Edit Word

~

•

I

;

1

-

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 2021 22 23 24 •

I

I

!

--f.-

-

--T--

iT ;'

-T-

;

UP:Jn~Ektl'l

l i T _ Til 1 i l l

I

,'!A,MldUIN71 I

I

\

I

-

---t-.

!

I

I

!

--

In this example, the literal 'GRAND TOTAL AS OF'
followed by the current date prints on the left of the
generated final total line, as shown below.
AMOUNT

xxx.xx
xxx.xx
x,xxx.xx
GRAND TOTAL AS OF

1/31/78

74,341.50*

Figure 15·9. Specifying a Literal and a Field to Print on a Generated Total Line

15-20

to Print

2

OJ

--~1-+"I:
I'
i i
!: -1_~~'
.
~15>
i
:
I-it-+----~--~-I--:+
-~-,
:
:
;
,
'
.
~LL~'__ ___________ U_J_,--_,-~ _
_ --'-_--'- ~'-- ___ --'--_l_---L.
I

'--'-----1-1._-'--- _

Zero Balances

ct

In

Output

I

I-- -

till'
I I I i :
+--'--.J-r,- -

-..

I

~-,------r--'

9 1011 1213 1415 16 17 18 192021222324'2526271282930131 32333435363738394041424344454647484950515253545556 575859606162636465666768697071 72 73 74

01, 1 0 ~~ M~L
01 21 0
I
013!

I

_
~"



Output Indicators

Skip

~~i i

Filename

Line

Space

§~
e~ ~

Auto Report Function

1 I 1
I I!
I
~RANI.lJ iTOi71Ali., R:S OFI
I:
i II I i
I I

! ~

1i

!

:!

11

I

i

Ii:

Lili~L;

I

I
I

I

I

I
I
-'--------l---L---'--'--.l---L------l---L-.:.----1-.l---L_-L-I

Columns 7-31

Columns 7 through 31 must be blank on a field
description line with 1 through 9 or R in column 39.

Columns 32-37 (Field Name)

Enter the name of a field, an indexed array name, or a
table name. The corresponding field or element value
prints on the total line indicated by the entry in column
39. If columns 32 through 37 are blank, a constant
must be entered in columns 45 through 70.

Column 38 (Edit Code)

Enter an edit code in column 38 to edit a numeric field
named in columns 32 through 37, or leave column 38
blank. If column 38 is left blank, an edit word can be
entered in columns 45 through 70. If column 38 is
blank, no edit code is assumed by auto report.

Column 39

Enter a digit (1 through 9) or R. These entries
correspond to the indicators L1, L2, ... L9, and LR. The
entry identifies a specific total line on which the field or
literal described is to be printed. The entry in column 39
must correspond to a control level that is defined by the
input specifications. In group printing, the entry in this
column must be higher than the control level of the first
total line generated.

Columns 40-43 (End Position in Output Record)

Do not make an entry in columns 40 through 43 on field
description specifications with 1 through 9 or R in
column 39. See Report Format for additional information
and considerations.

Column 44

Leave column 44 blank ..

':. Columns 45-70 (Constant or Edit Word)

Leave columns 45 through 70 blank, or enter a constant
or edit word. If field name (columns 32 through 37) on
this specification line contains an entry, then columns 45
through 70 can contain any of the following:
• Blanks, if no editing is needed for the field or if the
field is already edited by an edit code in column 38
• Edit word, if special editing is desired
• Floating currency symbol or asterisk protection entry
used with an edit code
Columns 45 through 70 cannot contain a constant when
field name contains an entry. However, when field name
is blank, columns 45 through 70 must contain a
constant.

Group Printing

In group printing, data is summarized for a group of
input records and only totals are printed on the report.
Totals can have subtotals with a final total or only a
final total.

Specifications

To specify group printing using auto report, enter a T in
column 15 and *AUTO in columns 32 through 36. A
control level indicator can be specified in columns 23
through 31. When a T-*AUTO specification is used, a
line is not printed for each individual record that is read,
but only after a complete control ·group is read.
Fields and literals defined by field description
specifications that have a blank or B in column 39 and
follow a T-*AUTO record description are printed on the
lowest level total line. Fields defined with an A in
column 39 are not printed on the total lines, but the
total fields created by auto report are. Generated
calculations are printed on their associated total lines.
Continued column headings (C in column 39) and
total-indicated fields (1 through 9 or R in column 39)
can also be specified by field descriptions following a
T-*AUTO record description.
Output indicators can be entered in columns 23 through
31 of a field description specification following a
T-*AUTO record description if column 39 of the field
description specifications contains a blank or a B. If
output indicators are used in a field description that has
an A in colurnn 39 following a T - *AUTO specification,
those indicators are ignored by auto report. Output
indicators cannot be used in a field description that
contains C, 1 through 9, or R in column 39.
* Auto Output Specifications

15-21

Examples

Figure 15-10 shows the file description and input
specifications for the group printed reports shown in
Figures 15-11 and 15-12. BRANCH and REGION are
defined as control fields.
Figure 15-11 shows the output specifications and the
group printed report showing sales totals for a company.
Since the T-*AUTO specification is conditioned by L2,
only the totals for REGION (L2) and for the entire
company (LR) are printed on the report. The totals for
BRANCH (L1) are not printed.
A disk summary file, DISKSUM, is also produced by this
program. The summary file contains a summary record
of the sales data for each branch. The output
specifications for DISKSUM illustrate the use of
standard RPG II output specifications in the same
program with *AUTO specifications. The output record
described is written on the disk file, DISKSUM, when
there is an L1 control break (BRANCH field changes).
Since the T-*AUTO specification is conditioned by L2,
auto report does not generate fields for the L1 control
level. Therefore, standard RPG II calculation
specifications must be used to calculate the L1 totals.
The L1 total fields that are written on the DISKSUM file
(SOLDQ1, SOLDV1, and VALUE1) must be defined in
the calculations.
Figure 15-12 shows a group printed report similar to the
one shown in Figure 15-11. However, the T-*AUTO
specifications are not conditioned by a control level
indicator, so totals are printed for all defined control
levels and for LR.

/COpy STATEMENT SPECIFICATIONS
The auto report copy function provides a way to include
cataloged RPG II source specifications in an RPG II
program. The source specifications that are included
must reside as a library member on disk. Create the
library member by using the library maintenance disk
utility program. Use the copy function to include source
specifications that are identical or nearly identical in
several different programs, thereby reducing the need to
repeatedly code specifications that are used in several
programs. For example, if file description and input
specifications for a particular file are similar in different
programs, these specifications can be placed in the
library by the library maintenance program or the source
entry utility (SEU) and included in any program by the
copy function.

Auto report specifications and any valid RPG II
specifications, including tables and arrays, can be copied
in this manner. The auto report option specifications
and other copy statements cannot be copied. See
Examples of Using Auto Report in this chapter for an
example of using the copy function.
The specifications included in an auto report program by
the copy function are initially placed in the program
immediately following the /COPY statement. When all
specifications are copied from the library, the entire auto
report program is sorted into the order required by the
RPG II compiler (see Order of Generated Spedfications in
this chapter).
To request the copy function, use the /COPY statement.
This statement identifies the library and library member
containing the RPG II specifications to be included in
the source program generated by auto report. /COPY
statements must follow the auto report option
specifications, and they must precede source tables and
arrays (file. translation tables, alternate collating
sequence tables, and compile-time tables and arrays).
The format of the /COPY statement is:
Column

Entry

1-5

Page and line number indicating
the placement of the statement
in the sequence of auto report
source specifications.

6

This column can contain any entry
except H or U, or can be blank.

7-11

Enter the characters /COPY.

12

Blank.

13-29

Identifies the library member to
be included. Specify the library
name, which can be up to 8
characters long, beginning in
column 13. Use a comma
to separate the library name
and the member name, which
can also be up to 8 characters
long. If an entry is not made
for the library name or if F1
is specified, the default is to
the system library.

30-49

Blank.

50-80

Enter any information or comments.
The contents of these columns are
not read by auto report.

Figure 15-13 shows an example of the /COPY
statement.
15-22

Auto Report Function

File Description Specifications
File Type

F

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Rel.:UIJ AJJre~s rield

File Designation

f--

End of File

Recol d Address Type
Sequence

Filename

Type of File
Organization
Nor Auditlondl Artta

File Format
Line

...J

Symbolic
Device

Device

Number of Tracks
for Cyllrcier Overflow

Name of
Label Exit

Number of Extents
Tape

UJ

~

Storage Index

-5

o Overflow Indicator <3

Block
length

~

Record
Length

~ ~

~ ~
4

J

5

6

7

A

9

n

10 11 12 1314 15 16 1'1 If! 19 '2021

Condition

r---- ~

~tea~t~~;ld ~
Location

Z

Continuation Lines
Option

W

L3 :'4 25 26 21 28 29 ]0 31 323334 35 36 37 3839 4041 424144 4fl 4€ 4748495051 52 53 54 5556575859

Ul~

~

Entry

60 61 62 Fi3 64 65 G6 67 68 "'9 70 71 72 7374

L1 and L2 are the defined control levels.

\

Input Specifications
Record Identification Codes

I

0

;:;

Filename

Line

.~

Position

.-1-.-

~~IAND

7

8

Z

1

I~la'I~S

o

2

I

o

3

I

o

4

I

o

5

I

i

I

o

6

I

!

!

o

7

I

11

I

~

U

~

3

~ 0 iij
N
0
z u <5

Position

~ 0
0 N
z u <5

3i

I

a:

From

~

~

...J

~

III

'" a:

~

:2~

~

j

LLU:

g

-5

J

-;;

8

0

0
.~ ~

.~ ~
:~

~~

:2u

."

-;;

Zero
Plus Minus or
Blank

u:

II
I

!

+-

i
I

!

I

I

II

!,

I

i

!

!

1

I

!
I

I

!

I

1

i i

A C

!,

,r..

it

),

!

i

1

5

2<,
ii/I>

II
!

!

;T,

,

I

'

!

.- . i--97 - !~~"~IV~~~:L=..:!U=-='E~II---+--";'-+-+--1f-,--+--+_-l---------I

"I
i !
:
I .li
1-1---'-1--,--+-~HH-l-+-+-+-+-f-I--t--+-'MH-t-t~+-I.J

i

ii

!

I

,
~

I I

IIU

I'"' •• ~

!
I

I 1\

1

!
I

!

To

!

I
I

;

Field Nan

0

0
.;;

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 19 60 61 62 6364 65 156 67 68 69 70 71 72 73 74

o

o8 I
o 91 I
oi I

~

Position

Field
Indicators

Field Location

I----

I

i

~ _~~~

I

iii

'I

i

i

I

'+-f-....--,. -+--'-+-+-f-.i--I--+-+---+--+- ;_ ~
I

I

_~

Figure 15·10. File Description and I nput Specifications for the Group Printed Reports Shown in Figures 15-11 and 15-12

ICopy Statement Specifications

15·23

Calculation Specifications
Indicators

C

-

Plus IMinusl Zero

Factor 2

Operation

Factor 1

AL

At

0

a

1

0

0

z

z

~n I

C

a

2

C

a

3

C

a

4

C

~C)

~

11 1'>1

LD I~L1

II.

.'JA LIJ E1

~

~In , 11

IV

Sb LD

~

~A .~~

~~ L~ ~1

o

W

~~

I
spac'!l

Because L2 is entered under output indicators, total lines
are printed only for L2 and LR, although L1 is also a
defined control level.

o

~ ~+~

a 1
a !21

;tt

1 G

6

7

13J~

B 9 1011 12

And
0

Rico

15 16

o

I-

~

21<211=2
Lookup(Factor 21is
High Low Equal

9 10 1112 13 14 1516 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

5

Comments

Compare

Length

Name
z

4

Indicators
Arithmetic

Line

3

Resulting

Result Field

Auto Report Function

1

Output Specifications

-

s

0

]

~~~

Filename

Line

Output Indicators

Skip

Space

1L

~~i
DEL

"ACoD
o

o

4

o
o

6

0

I

~-

o

5

1---

0

2

1

8

eR[N TER

H_ -

a:

0

z

z

'AUTO

-

-

-

~!UL

-

1-

-1-1---1 - - 1--- I -

0

4

I_

----'-

Z'

0

5

9

0

I 0
1--I I

0

1--'- -

1--

-

---

-,

<\

- -

2

0

I

3

0

T- BfiI;:~ -

-c-ir

--

I

I'

f-i--- - /

f-I- - - f0

n1

I:

~

1--

-- --

~11~~~c

-~\l
-~Atu ~rjl'jl

~~
- -

Ves
Ves
No
No

Ves
No
yt;~

No

No Sign

CR

:

I
2
3
4

A
B

J
K
L
M

C
D

X = Remove
Plus Sign
V = Date
Field Edit
Z '" Zero

Suppress

a:

g
0:

Constant or Edit Word
•

---- f--

-

t

2 3

4

5

6

1

8

9

to 11 12 13 14 15 16 11 18 19 20 21 22 23 24 '

1----1---

1--

-- -- - - - -

-

-I-

- I-I-

-

-

-

I
I

-

- -H-I J

-~-

'- I~LU. '-

I--

r---

-t- --

R

---

1-----

-

-

l~

~

I I
--I' H-~-- ---r-r

tV'~L~lEI ,QFI
,is. oq~ +1,II:;]I ,1+ I
N I
I

-;-- -

T-

I

I

,

:
I

-\--

---+-t -r-

I~
~ ~~'IDr lilul;~H~+i r t
'DJ:~I,~lr
'~~1or[j\~
~W '4--H1 +I -+-t-r
'COMP~M'{, "tR#t'
I

I

1

I

I

I

t -t------j!
II I 11 - -I 'Tr~+~ ,-;------.-- W--!I
I

'
lIfFli-- --if -tH-+ it
I

--- - - -

1-,--

I

I-----i----

1--

?

f- - f -

I

--

~

·b I(dJb~
~NI~jicldlip~INI'{
1~ICH
l~R1-GrdN
~, .L ~'~' 'J~',
tl f'
~A~~I"11
~1 b~1Il1,.~ ,~~-'~II"'B~,jOl ~~ IEf '''-1'- -itI

f-- f-f-

,R~GI& r
..

-

-

i - -1-

0

-

:---:-:

-I~ ;'~

-

- I - 1----- ,-1--- -

0

1--1-

1 5

in
Output
Record

~~y[!O

0Y--

--.::. 17-- - - -- -- --

1 - - --,---1-

o 7
0
r-r- 1--0
o 8
-I-- 1--- ---I----r-

I 4

~~

1----1-----

--:

-,--1--

6
0
r - - I - --

,--1-

Position

0

3

o

o

0

z

~

Zero Balances
to Print

Commas

9 10 11 12 13 141516 1718 19 20 21 22 23 24 25 26 2128 29 30 31 32 33 34 35 36 3 7 38 39 4041 4243 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 G6 67 Ga 69 70 11 72 13 14

r-c- 1 - - 1-, f-- --c- ---

o

0

~

'"

R

'A"t"o
3

Field Name

C I

-l t-j

,

----:--i-f--

I

rni

. d!

indicators are entered under output
When no
:rol
indicators, a total line is generated for each defined control
level indicator (L 1 and L2, in this case) and for LR,

SALES FOR ANY COMPANY BY BRANCH AND REGION
BRANCH

~~~

~REGION

i~

.~

1 :::LS

REGION 3 TOTALS

t~COMPANY

TOTALS

NUMBER ,OF SALES

VALUE

PAGE

1

VALUE OF STOCK
ON HMm

6

53,000.00
18,000.00

12,000.00
7,000.00

:::'
:::'

23

71,000.00

19,000.00

':c::::'

30

70,000.00

29,000.00

::::::

30

70,000.00

29,000.00

::::::::::'

53

141,000.00

48,000.00

::::::::::c::::'

17

Figure 15-12. Using *AUTO to Produce a Group Printed Report Showing Branch, Region, and Final Totals

ICopy Statement Specifications

15-25

Library name. For F 1 entry, the default I ibrary is the
system library

\

I

I nput Specifications
1)

~

FH"",m\ i

line

~
f-

ell

3

4

,

5

2

a

3

a

4

~:_L

6

g :J. ~~
::6 ~ <5
11 ~ ~ :-

§ ~
'0" t;"r- z 0
l-;:;: t-;;to

j
a
a

Record Identification Codes

0

I---

7

8

9

Positron

~

Ii;

~

e

z

u

-0 t::I

~

Positron

~

.s

III ~V
'F11 I'~ ~L11;]11«
I~
III IC~ :PIY I(JS ~'R lI-I I~i!· l~B ~k~ lII<
I
i

o~

zU

vr

V ...

Iv

k"V

ge
I~~

Field
Indicators

ration

3

2

i

10 11 12 13~4 15 16 1718 19 20 21 2 .... 23 24 2526 27 28 29 3031

... rv

/'

Name of member to be copied

v~

~e ~~

o U~

Z

V34 35 36 37 38 39 40

V
0
.;:;

.;;;

0;

&1

a:

g
ii:

From

To

Field Name

~
]

~

g

0

.3

~

0
0

1?~
.~

Q.i

LLLi:
"'",

11
;';;u

~
"0

J
"0

a;
Ii:

Zero
Plus Minus or
Blank

4142 43 44 4546 47 48 49 50 51 52 53 54 55 56 57 58 5960 61 62 63 64 6566 6768 69 70 71 72 73 74

1

I

I

L

~_L_

Note: It is convenient to code the /COPY statement on
the input specifications sheet if input specifications are to
be modified as they are copied.
Figure 15-13. Example of the ICOPY Auto Report Statement

Modifying Copied Specifications
Statements can be included in the auto report
specifications to modify file description and input field
specifications as they are copied from the library. No
other types of specification can be modified. /COPY
modifier statements from the source program that add,
change, or delete entries on cataloged input field
specifications are identified by an X in print position 6
of the auto report listing.

Modifying File Description Specifications
To modify a file description specification that is copied
from the library, enter the filename in columns 7 through
14 of a file description specification (F in column 6).
Then make only those entries on the line that are to
replace existing entries in the copied specification or
that are to be included as new entries. Blank entries in
the modifier statement do not affect the copied
statement.

15-26

Auto Report Function

For example, the file description specifications for a
frequently used file named SALES are to be copied from
the system library. The original specification contains an
I in file type (column 15), defining SALES as an input
file (see Figure 15-14). To update the sales file, change
column 15 to a U by including a modifier file description
specification in the auto report source program. The
modifier statement must contain the filename, SALES,
and the new file type entry, U. As a result of the
modifier statement, the file type on the copied file
description specification is changed from I to U.
To set an entry to blanks, enter an ampersand (&) in the
first position of that entry on the modifier statement,
and leave the remaining positions blank. For example, to
remove the block length entry (columns 20 through 23)
from the cataloged specification shown in Figure 15-14,
add an ampersand to the modifier statement in column
20, as shown in Figure 15-15, and leave columns 21
through 23 blank.
Modifier statements for file description specifications do
not have to be in any particular order in the auto report
source pro.gram, except that they cannot immediately
follow the /COPY statement if input field specifications
are also being modified.

Input Specifications
Record Identification Codes

I

Field

f--

Filename

Line

/COpy statement to copy specifications for
SALES file from the system library member
named SALETR

From

Position

Position

Position
~--

o R
1--:3

4

5

6

7

e

AND

9

10 t 1 12 13 14 15 lG 11 18 19 20 21 22 23 24 25 2& '21 28 29 30 31 32 33 34 35 36 37 38 ~9 40 41 42 43 44 45 46

-l--l--l-+-+-----+-l--I--+-+-+---+-+I- - -l--f-l-l--+-l-l

l

o 2 I
~o4-3~~-I~~4-~-+~-I-~I-l--l--~-+~+-1~~-+-4-+-4-+-I-~~+-~+I~-}-·}-I-1- ~-L-l-J...-L-'---L--L-l---L--L-L--l-.I--L-~--L_L--L_ .L-t-"----'--'--l--I. _ _ ' - ' -

____ 1--l---l.-L-L...L..l-L-l.--L_L-L.--L

File Description Specifications
Mode of Processing

File Type

F

Length of Key field or
of Record Address Field

File Designation

f--

End of File

Record Address Type
Sequence

Filename

Type of File
Organization
C"oIor Additional Area

File Format
Line

o Overflow IndLcator 8

File description specification as it is cataloged in the system library

Block

Record

Length

Length

~

4

5

6

7

8

9

~~-;~~I

-5

~~

c::

~t:~t~~;ld ~

~ ~

...J

3

Device
~

Location

UJ

[±Ir JE±tM~--Iii w!r~1< It- C=UL ______ '-:TII--

10 "

12 13 14 15 16 17 18 19 7021

n

73 74 7~ 76

~~_ ~_LL_L Lt[~~L==-

'}7

28 29 30 31 323334 35 36 37 38 39 4041 4241444546

~

ilL

!

File Description Specifications
File Type

F

Mode of Processing
Length of Key Field or

File Designation

r----

of Record Address field
End of File

Record Ad,jress Type
Sequence

Filename

Type of File
Organization
Additional Area

File Format

Nor

Line

Copy function modifier statement

BlOCk

length

Rccord
Length

Device
~

~OVerfl~~
~ ~
~tCa~t~~:ld .~

c::

~ ~

...J

Location

UJ

File Description Specifications
File Type

F

Mode of

Proc~s5ing

Length of Key Field or

File DesLgnation

of RecOLd Address FIeld

End of File

Record AddLcss Type

Filename

Sequence

Type of FLle
Olganization
Nor Additional Area

FLle Format
Line

Resulting file description specification that
is included in the RPG II source program

Device
~

o Overflow ImlLcator 8

Block

Recold

length

Length

5

~

t::

a:: ~

 LZ> VA

I

q3 R

co'RlI

r0-

,-0

I I I
I
I I I

1&

B

Field Name
From

r7 I

1\\

1

11

Itl~

NIC

9 IS AN ,..uIU1
1 R ~I ON
~

2~

I....

~

: I i

III Added L1 indicator

Zero
Plus Minus or
Blank

To

:

J<-

Resulting input specifications
for SALES file showing:

Field
Indicators

Field Location

-

~FJ If--/'"

I

41 42 43 44 45 46 41 48 49 50 5152 53 54 55 56 51 68 5960 61 62 6364 6566 61 68 69 10 11 12 13 14

1\\

~

0

~

0

~: ~

iI j
Z

Field
Indicators

Field Location

r

i~

9 10 11 12 13 14 15 16 11 18 1920 21 22

4

o

1

8

3

~

0

.8~ ~:.

.-1-.- § ~

lIS ~L E~

o

i

~

I-

5

r-I--r-

o

~/

0

::l

]

~

~

Add a new field description

I

Filename
l-

Blank out minus field
indicator on SOLDVA
description

D

~

line

Add an entry to BRANCH
field description

fI-

0

I

r-----

II

IfJ Blanks in place of minus
field indicator

II Added field description
lAD

SC

f-f-

1/ 11

14S liDIGl Y

2S LrD ~IA

[I,'

3 r>IO lolA ~lE

1~312;V ~U1E

/~

~8

R

CO ~It

, .... t--- .....

D

I

I

I

Figure 15-16. Modifying Copied Input Field Specifications

/Copy Statement Specifications

15-29

For best results, first place those statements that modify
existing input field specifications; then place those that
are to be added as new input field specifications. This
procedure is suggested because input field modifier
statements that do not fit into the special main storage
table for modifier statements are added to the RPG II
source program as new input field specifications. This
order of specifying modifier statements increases the
likelihood that excess statements, if any, will be valid
field descriptions.

REPORT FORMAT
One of the advantages of auto report is that it frees the
programmer from the task of specifying the format of
his report on the output specifications sheet. Auto
report can completely format the report by spacing,
skipping, centering lines, and calculating end positions
for fields and constants.

Spacing and Skipping
Spacing and skipping can be either left to auto report or
specified by the programmer. Figure 15-17 shows
spacing and skipping generated by auto report. For the
specifications used to produce the report, see Auto
Report Generated Specifications in this chapter. If
columns 17 through 22 are left blank on an H-*AUTO
specification, a skip to line 06 is done before the first
heading line is printed and space-two-after is done for
the last heading line. If more than one heading line is
specified, space-one-after is done for the first and all
succeeding lines except the last. To specify spacing and
skipping, follow the standard RPG II rules for spacing
and skipping.

Space-two-after is generated for all total lines produced
by auto report from a D-*AUTO specification. In
addition, the lowest level total line and the final total line
are also generated with a space-one:-before.
If spacing and skipping entries are made on a T -*AUTO
specification, the entries apply to the lowest level total
line generated, but not to column headings or higher
level total lines. If spacing and skipping are not made,
the lowest level total lines are generated with
space-one-after; all higher levels 'are generated with
space-two-after. Space-one-before is always
generated for the second-to-the-Iowest level total and
the final total (see Figure 15-12 for an example).

Placement of Headings and Fields
Auto report generates end positions for fields and
constants and centers column headings, columns, and
report lines (see Figure 15-17 for an example).
However, if an end position is specified for a field or
constant on a D IT -* AUTO field description line, that
end position is used on all column heading, detail, and
total specifications generated from the field description.
(The specified end position may be altered slightly by
auto report when the line is centered or when the
column heading and field are positioned in relation to
each other.) If the specified end position causes an
overlay with a previous field or constant, auto report
generates a new end position.
Specify end positions only to eliminate the automatic
spacing between fields or to spread out or expand a
report on the page.

Page Headings
Column heading lines are spaced like page headings.
Space-one-after is done for all except the last.
Space-two-after is done for a single heading line, or for
the last heading line if more than one is specified.
Spacing and skipping entries cannot be specified for
column headings. If spacing and skipping entries are
made on a D-*AUTO record description specification,
the entries apply to the detail line" generated. The
entries do not apply to column headings or total lines
generated by auto report from the D-*AUTO
specification. Standard RPG II rules for spacing and
skipping must be followed. Space-one-after is assumed
for the generated detail line if spacing and skipping
entries are not made.

15-30

Auto Report Function

If the date and page number are printed on the first
*AUTO page heading line (that is, if they are not
suppressed by an N in column 27 of the option
speCifications sheet), the date is always printed in
positions 1 through 8. The page number is printed with
an end position equal to the highest end position of the
longest line in the report. When the first *AUTO page
heading (including date, title, and page number) is the
longest line in the report, one blank space separates the
title from the date and the word PAG E from the title. If
the resulting line exceeds the record length of the
printer file, the excess information on the right of the
line is not printed.

Skip to line 06 occurs before printing of the first line.

SALES REPORT FOR ANY CO.

1/15/78

REGION
1

Highest end position in the report.

BRANCH
17

I TEl"
NUMBER

DESCRIPTION

AG7701T
AG7705S
AP6545B

2-TON TRUCK
PICK-UP
CAMPER

SALES
5
10
2

PAGE
At10UNT

25,000.00
20,000.00
8,000.00

ON-HAND
2
1

3

25

AG7701T
AG7705S

AG6545B
AP6549P

2-TON TRUCK
PICK-UP

CAMPER
1/4 TON TRUCK

2
4

10
'20

FINAL TOTALS

Auto report generates a blank line (space-two-after)
following the last page heading line (in this case,
there is only one page heading line) and following the
last column heading line.

10,000.00
8,000.00

VALUE
10,000.00
2,000.00
12,000.00 .,..

53,000.00
22

1
1

5,000.00
2,000.00

18,000.00

7,000.00

71,000.00

19,000.00

40,000.00
30,000.00

1

5
6

*
~~

i.e

20,000.00
9,000.00

70,000.00

29,000.00

>!'

70,000.00

29,000.00

","""Y"

141,000.00

48,000.00 :::c**

Auto report generates a blank line before the lowest
level total (in this case, there is only the L1 total)
and before the final total (space-one-before).

Auto report generates a blank line following
each total line (space-two-after).
Figure 15-17. Report Illustrating Format Generated by the Auto Report

Report Format

15-31

If a line generated from a D/T-*AUTO specification is
the longest report line, that line is printed starting in
print position 1, and the title portion of the first page
heading line is centered in relation to that line.
Additional * AUTO page headings are then centered on
the first * AUTO page heading line.
If an *AUTO page heading is the longest line in the
report and a D /T-* AUTO specification is present, any
other *AUTO page heading lines and the line generated
from the D/T-*AUTO specification are centered on the
longest page heading.
Fields and constants appear in the order specified in the
* AUTO output specifications from left to right. Auto
report provides one blank space before and after fields
on the heading line. No spacing is provided between
constants.

Reformatting *AUTO Page Headings
You can reformat an *AUTO page heading line if you do
not want to use the end positions for fields and
constants that are generated by auto report. If you want
to find what end positions are generated for page, date,
and title information, see the listing of the generated
source program that is produced by the RP~ II compiler
(see Generateq Specifications).
Catalog the generated RPG II source program in a
library by specifying the C option in column 7 of the
auto report option specifications, and change the end
positions on the generated source statements by using
the library maintenance program or the source entry
utility.

Body of the Report

Placement of column headings above columns depends
on which is longer, the heading or the associated field
(including edit characters). If any column heading is
longer than the associated field, the field is centered
under the longest column heading constant. If, however,
the field is longer than the longest column heading
constant, the column heading is left-justified over an
alphameric field and right-justified over a numeric field.
When more than one column heading line is specified,
shorter column headings are always centered on the
longest column heading.

1 5-32

Auto Report Function

Fields and constants appear from left to right on a line
in the order they are specified by the output
specifications. At least two blank spaces appear before
each field on the line. However, no spaces are provided
before a constant; the programmer must incorporate
blanks within constants to provide for additional
spacing.
Total indication information (fields and constants
specified with 1 through 9 or R in column 39) is placed
to the left of the first total field (A in column 39) on the
corresponding total line, followed by two spaces. If two
or more such fields or constants are specified for a total
line, they appear from left to right in the order specified
on the left of the first total on the line. Each field is
preceded and followed by one space. No spacing is
provided for constants.

Overflow of the DfT -*AUTO Print Lines
If the lines generated from a D/T-*AUTO specification
are longer than the record length specified for the
printer file, a second print line (overflow line) is
generated for each column heading line, detail (or group
print) line, and total line. (Remember, a second print line
is not generated for * AUTO page heading lines.) The
excess information is placed on the overflow line in the
order specified, right-justified.
Figure 15-18 shows the result of an overflow condition.
In the output specifications for the report shown in
Figure 15-18, no spacing or skipping is specified. If
spacing and skipping were specified, however, auto
report spaces the report as follows:
• Column heading lines and total lines are spaced as
shown in Figure 15-18.
• The space-before and skip-before entries specified
are for the original detail (or group print) line. Auto
report generates space-one-after for this line.
• The space-after and skip-after entries specified are
for the overflow line. Auto report generates blanks
for space-before and skip-before for the overflow
line.

Auto report prints those columns that}
cannot be completely contained on
.the original line on overflow lines.

CASH RECEIPTS REGISTER

1115/78

REGION

ACCOUNT

ACCOUNT NAME

Nur~BER

INVOICE
NUMBER

INVOICE
DATE

PAGE

DATE PAID
AMOUNT
PAID

1

11243

JONES HARDWARE

27541

7111/71

712111

AMOUNT
OVIED
BALANCE
DUE
23.75

1

DISCOUNT
TAKEN
EXCESS
DISCOUNT
.47

23.28
1

11352

NU-STYLE CLOTHIERS

27987

7114/71

7/2611

40.00
1

11886

MIDI FASHIONS INC

15771

7/04/71

7/14/1

87.07
47.07
107.22

2.14

105.08
1

12874

ULOOK INTERIORS

25622

7/09/71

7/2311

1

1827 /-+

STREAMLINE PAPER INC

29703

7/21/71

7/30/1

67.95

67.95
170.55

REGION TOTALS
406.86
2

23347

RITE-BEST PENS CO

20842

7118/71

7/2011

10.00
2

25521

IMPORTS OF NM

29273

7120/71

7/2711

585.47
2

26723

ALRIGHT CLEANERS

19473

7/07/71

7/23/1

2

28622

NORTH CENTRAL SUPPLY

17816

7/05/71

7/22/1

274.03
101.10

2.38

560.02
148.17

4.99

15.80
5.80
797.40
200.00
462.00

:::::

11.93

462.00
75.97

75.97
2

29871

FERGUSON DEALERS

27229

7/10/71

7/2211

61.91

61.91

REG I ON TOTALS
1,195.35
3

30755

FASTWAY AIRLINES

26158

7/06/71

7/19/1

1,413.08
205.80
742.72

725.87
3

31275

ENVIRONMENT CONCERNS

20451

7/06/71

7 130/1
15.00

3

32457

B SOLE SILOS

27425

7/10/71

7/20/1

3

37945

HOFFT A BREAKS INC.

18276

7/06/71

7/2311

11. 93
-.-

16.85
1.90

29.43
14.43
110.05

110.05
47.23

47.23

REGION TOTALS
898.15
4

42622

EASTLAKE GRAVEL CO

16429

7/05/71

7/23/1

929.43
14.43

16.85
1.90

~::::

29.37

29.37

REGION TOTALS

29.37
-,-

29.37

COMPANY TOTALS
2,529.73

2,931.90
368.40

33.77
1.90

~:::::::::

Figure 15-18. Report Illustrating Overflow of O-*AUTO Print Lines

Report Format

15-33

GENERATED SPECIFICATIONS
Standard RPG " specifications are generated by auto
report and are combined with RPG II specifications
included in the input to auto report and specifications
copied from the library to produce the final RPG II
source program. This section describes the generated
RPG II specifications and the order of those
specifications in the RPG " source program.
Figures 15-19 and 15-20 show auto report specifications
for a sales report and the resulting RPG II source
specifications that are generated for the report.
Numbers are inserted in the figures to identify the auto
report functions and to show the specifications that are
generated by each function.

Generated total fields are defined (given length and
number of decimal positions) when the total field is the
result field in a generated calculation. In the input
specifications, SOLDVA and VALUE are numeric fields
defined with a length of seven and two decimal
positions. Figure 15-21 shows that the total fields
generated from SOLDVA and VALUE are defined as
two positions longer than the original fields, with the
same number of decimal positions.
When group printing is specified (T-*AUTO
specification), auto report generates total calculations to
reset each of the accumulated fields (A in column 39) on
the lowest level total line to zero on each cycle. A
Z-ADD calculation, conditioned by LO, is generated for
each accumulated field. These calculations are the first
total calculations in the generated RPG II source
program.

Generated Calculations
Calculations are generated to accumulate totals for fields
named on *AUTO field description specifications that
have an A in column 39 (see Figure 15-21).
An RPG " subroutine is generated to accumulate the
values from these fields into the lowest-level generated
total fields. The name of the subroutine is always
A$$SUM. The subroutine specifications are conditioned
differently, depending on whether detail or group
printing is specified:
• If detail printing is specified, as in Figure 15-21, the
EXSR statement.is conditioned by the same.
indicator(s) that conditions the D-*AUTO specification
(01 in this example). Each ADD statement in the
subroutine is conditioned by the field indicator(s)
specified with the field in its field description
specification (none in this example).
• If group printing is specified, the EXSR statement
and all ADD statements in the subroutine are
unconditioned.
Total calculations are generated to roll the total from the
lowest-level defined total field through the higher-level
defined total fields and the final total. The total
calculation to add the total from one level to that of the
next higher level is conditioned by the control level
indicator corresponding to the field name of the lower
level. As shown in Figure 15-21, total calculations to
accumulate L2 and LR totals are followed by the
subroutine to accumulate the lowest level total, L 1.

15-34

Auto Report Function

Generated Output Specifications
Figure 15-22 shows the output specifications generated
by auto report. To identify specifications supplied by
auto report (column heading specifications, total
specifications, conditioning indicators, spacing and
skipping values, end position values, blank after)
compare the listing with the auto report specifications.
Auto report generates specifications to reset
accumulated fields to zero after they are printed. See
Field Description (A in Column 39) for a discussion of
resetting fields to zero. In this example, blank after is
generated for accumulated fields.

File Description Specifications
Moue of Processing

F

File Addltion:Unorcit'rcd

Extent Exit
for DAM

Length of Key Field or
uf Rec(lId Address FielJ

File Designation

I--

End of File

Rccord Address Type
Sequence

Filename

Symbolic
Device

Device

Type at File

Nllmber of Tracks
fur Cyl.p~lt't OIl~llIuw

Name of
Lauel Exit

Number of Extents

File Format

line

Input Specifications
Record Identification Codes

I

Filename

Line

Position

:.-.

!!....

~~~

zuG
3

4

5

o , ,

6

I

o

2

I

o

3

I

1

8

9

1011 12 13 14 15 16 17 18 1920 21 '2'22324 25 2621 28 '2

I corp Y

11=[ j

/

5AL[ E1 R

..

Position

1
_

. .Position
..

!!

In~~

~u6

~
...

_

~

';;;

Field Name

0

~

... a:

~~~~g

From

To

~
Oi

~

g
.3

~

~

zu6~~

Copy function and
modifier statements

III

0

';;

0

:9.0

~

......

~

~

~2

Oi

.~ ~

.S
-5

:~

::
End

II

Commas
Yes
Yes
No
No

Zero Balances
to Print

No Sign

CR

:.

X '" Remove

J

No

A
B

K

Plus Sign
Y = Date
Field Edit

Yes

C

L

Z

No

D

M

Yes

=

Zero
Suppress

Constant or Edit Word

Figure 15-19. Auto Report Specifications for a Sales Transaction Report

Generated Specifications

15-35

0010 H RG 004

R - 0001
0002

D

D

~

0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062

If you do not specify a control specification,
auto report generates an all-blank control
specification for you.

0020 FPRINTER 0
F 120 120
0030CFSALES
IP F 473 43
0040 I ':'/COPY Fl,SALETR
0050CISALES
AA 01
0060CI
0070MI
0080MI
0090CI
0100CI
0110CI
0120CI
0130CI
0140EC
01
0150ECLl
SOLDV2
0160ECLl .
VALUE2
0170ECL2
SOLDVR
0180ECL2
VALUER
A$$SUM
0190ECSR
0200ECSR
SOLDVl
0210ECSR
VALUEl
0220ECSR
0230EOPRINTER H
206
IP
0240EO
OR
OA
0250EO
0260EO
0270EO
0280EO
0290EO
0300EOPRINTER H
1
IP
0310EO
OR
OA
0320EO
0330EO
0340EO
0350EO
0360EO
0370EO
0380EO
0390EO
0400EOPRINTER H
2
IP
OR
OA
0410EO
0420EO
0430EOPRINTER D
01
1
0440EO
L2
0450EO
Ll
0460EO
0470EO
0480EO
0490EO
0500EO
0510EO
0520EOPRINTER T 12
Ll
0530EO
0540EO
0550EO
0560EOPRINTER T
2
L2
0570EO
0580EO
0590EO
0600EOPRINTER T 12
LR
0610EO
0620EO
0630EO
0640EO

OA

PRINTER
DISK
1
8
10
11
26
28
35
37

EXSR A$$SUM
ADD SOLDVl
ADD VALUEl
ADD SOLDV2
ADD VALUE2
BEGSR
ADD SOLDVA
ADD VALUE
ENDSR

UDATE Y
PAGE Z

Auto Report Function

SOLDV2
VALUE2
SOLDVR
VALUER

92
92
92
92

SOLDVl
VALUEl

92
92

45 'SALES REPORT
56 'FOR ANY CO. ,
8
89
,
85 'PAGE
6
14
21
36
47
62
71
86

'REGION'
'BRANCH'
'ITEM'
'DESCRIPTION'
'SALES'
'AMOUNT'
'ON-HAND'
'VALUE'·

22 'NUMBER'
REGION
BRANCH
ITEMNO
DESC
SOLDQYK
SOLDVAKB
ONHANDK
VALUE KB

3
12
23
40
46
62
69
86

SOLDVIKB
VALUEIKB

62
86
87

SOLDV2KB
VALUE2KB

62
86
88 t,:-c::::::,

SOLDVRKB
VALUERKB

62
86
47 'FINAL TOTALS'
89 ' ,:c)::::~, ,

Figure 15-20. RPG II Source Program Generated from Auto Report Specifications

15-36

7 ITEMNO
9 BRANCHLl
10 REGIONL2
25 DESC
270S0LDQY
342S0LDVA
3600NHAND
432VALUE

' ~~,

,

Output Specifications

0

~ Space

!------

~ 5~

Filename

Line

11

~~ ~

r+-D E L

'A'Do

D R

en

';i

0

z

4

5

6

7

B

9

Field Name

z

ar
c:

0

Z

/if-;:jf[j
3

>

Output Indicators

Skip

·AUTO

;3 '"
J1

~

End
Position
in
Dutput
Record

r-Commas

II

Zero Balances
to Print

Yes
Yeo

Yes

No
No

Yes

Nu
No

No Sign

CR

:

X

<

1
2
3
4

A
D

J
K
L
M

Y

<

Remove
Plus Sign

C
D

Date

Field Edit
Z = Zero
Suppress

c:

g

Constant or Edit Word

ii:
1

2 3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 20 21 22 23 24 '

10 11 1213 1415 16 17 lP 1920 21 222324 2526 27 28 29 3031 32333435 36373839 4041 4243444546 474849 5051 52 53545556 57 58 59 60 61 626364 65666768 69 70 71 727374

Total calculations roll higher level totals.

~{ggi~
~

0014
0015
0016
0017
0018
~ { 0019
~
0020
Subroutine accumulates the lowest level totals
(L1, in this example).

0140EC
01
0150ECL1
SOLDV2
0160ECL1
VALUE2
0170ECL2
SOLDVR
0180ECL2
VALUER
0190ECSR
A$$SUM
0200ECSR
SOLDV1
0210ECSR
VALUE1
0220ECSR

EXSR A$$SUM
ADD SOLDV1
ADD VALUE1
ADD SOLDV2
ADD VALUE2
BEGSR
ADD SOLDVA
ADD VALUE
ENDSR

SOLDV2
VALUE2
SOLDVR
VALUER

92
92
92
92

SOLDV1
VALUE1

92
92
~

Length and decimal position of generated total fields.

Note: Placement of the generated calculations in the RPG II source program is shown in Figure 15-20.
Figure 15·21. Calculations Generated from Auto Report Coding for Sales Transaction Report

Generated Specifications

15-37

Output Specifications

0

i 5~

Filename

line

And

~

~~fAND

4

1

O~

2

0

56

Kll INI 1t:.IK

0

~:_

0

I

0

1

o

~ ~
8 U

0

z

z

~ ~

'AUTO

I

End
in
Output
Record

6

8

0

~

0

1--- -

- -

- -

-- --

I--

f-;-- _~ Ol-f---I-f- ___

r.c,'i-'- - - -

---+

-+---

I I

L

I

I

0
0

f--- -

f-~

-

-i9!1

-

-+ ,- f

-

I

t- -

I

,.'.~~ -j!":~

i

CR

-

1
2

A

J
K

B
C

4

D

l
M

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero

Suppress

Constant or Edit Word

-'
co

a:

IAiUlTKJ

I

~~O
A~IAI ,c
N
,,_L
'dt

~~~-~f-~-t-,---r-+--rL~ L:L~.l 1 Li i J:,...:""

15-38

3

, SIA LES IRE p~ RrT
a
q:

~
-t.-• -~'I+f-+I~~OL~I
- -+ -1- t I 1

- -

'~I +--+-t
" r- I--f- I
I

:

-I-:

+-1-

1--I

t

"-t
r~
I i

-- -

'-'-1 1--t--

I

1 i 2:

No Sign

Ves
No
Ves
No

a:

lAU TO

f-- - f - f-I-

+~ +,--+~IJ.Z
t

f'-+."~ f!-t t-r4'
H~ ~--~~---f-I~,'I"

to Print

Ves
Ves
No
No

Position

t

~i,i
0: ~
~--~
o

0

a:

- --- - I -

3

"

0

z

ffrl

Zero Balances

Commas

9 1011 12 13 14 15 16 17 18 19 2021 22 23 24 •
9 10 11 12 13 1415 1617 121920 2122 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 738 39 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

78

3

:;;:

?>

Field Name

L

I

~~~
o E l

f-;D"I-o

o
o
o

Output Indicators

Skip

] Space

I---

ated for column
headings because
ITEM NUMBER is
a two-I ine heading,

PROGRAMMING AIDS
The chart shown in Figure 15-23 should be helpful in
,determining valid *AUTO output entrie~, depending on
the contents of column 39.
The following programming suggestions may be helpful
in specific programming situations:
• One column heading can be printed over two or more
fields if automatic column spacing is taken into
consideration. For example, if the heading DATE is to
print over a month field and a day field as follows:

Code the output specifications as follows:

Output Specifications
-

o
Field Name
Line

a
c::

>

I-

j

3

4

5

6

~mo
7

8

9

10 "

;3 \2'"
~

~

>
End

---r::--::-Co
Zero Balances
mmas

Yes
Yes

II

No
No

PosItion

in
Output
Record

to Print

No Sign

CR

~

Yes

A
B

J

No

1
2

Yes

3

C

No

4

0

K

L
M

X = Remove
Plus Sign
Y = Date
Field Edit
Z = Zero
Suppress

c::

Constant or Edit Word

...J
OJ

0:
1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17

18 19 20 21 22 23 24 '

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 18 39 4041 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6566 67 68 69 70 71 72 13 74

Programming Aids

15-39

• To print a constant on only the first detail line under
a column heading, move the constant to a field in
calculation specifications and print that field as
shown in Figure 15-24.
• If group printing is being done and more than one
record type is present in the input file, certain
precautions must be taken. If a field to be
accumulated is present in all record types, but only
one record type is to be processed, the correct total
is not generated unless additional coding is used.
The specifications shown in Figure 15-25 give
incorrect results because the T -*AUTO specification
causes an unconditioned ADD subroutine to be
generated if a field is to be added. Therefore, OTY is
added when indicator 10 is on and when indicator 11
or 12 is on. Figure 15-26 shows a method of
obtaininb the correct results.
• Figure 15-27 shows the specifications for counting
records. This method is especially applicable when
you want to print a detail list, to take totals by
control level, or to eliminate 1's from bein~ listed
down the page.

39

7-22

23-31

32-37

38

40-43

44

45-70

Blank

Blank

Blank or
indicators

Field name

Blank or
edit code

Blank or
end position

Blank

Blank or
column heading

Blank

Blank or
indicators

Blank

Blank

Blank or
end position

Blank

Literal

B

Blank

Blank or
indicators

Field name

Blank or
edit code

Blank or
end position

Blank

Blank or
column heading

A

Blank

Blank or
indicators

Field name

Blank or
edit code

Blank or
end position

Blank

Blank or
column heading

C

Blank

Blank

Blank

Blank

Blank

Blank

Column heading

1-9, R

Blank

Blank

Field name

Blank or
edit code

Blank

Blank

Blank or
edit word

Blank

Blank

Blank

Blank

Blank

Blank

Literal

Figure 15-23. Valid *AUTO Entries Depending on the Contents of Column 39

15-40

Auto Reoort Function

Assume L 1 is defined in columns 59 and 60 on input
specifications,
Calculation Specifications

c
-

Indicators

~

~

~
8.~

Operation

Factor 1

Factor 2

>- ...J

Line

§ ~

~

8
7

0

1

C

0

2

C

0 3

C

Arithmetic

.g :r:

Plus IMinusl Zero

.~ ~

Lookup(Factor 2)is

Comments

'§ ~
Compare
Length ~ ~ 1 > 2~1 < 2Ll • 2

Name

... "0

5 6

Resulting
Indicators

Result Field

bOb
z

z
z
0 :I: High Low Equal
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 3334 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6364 65 66 67 68 69 70 71 72 73 74

Output Specifications

-

o

Space

Filename

Line

...>
4

0

1

Output Indicators

5

6

0

I

~~~~

~ ~!:..::.
... 0 E L

"A1[j"ii

j

3

Skip

w ...

t :t<1-r-+--.---+---..---..-,---1

o

'"
7

8

9

Field Name

.I

And

And

o
Z

Z

GI
ex:

0

'AUTO

~
~

en

U

~

End
Position
in
Output

Record

I

>

Zero Balances

Commas

to Print
Yes
No
Yes
No

Yes
Yes
No
No

No Sign

CR

:

X

=

1

A
B
C
0

J
K
L
M

Y

=

2
3
4

0

4

0

Field Edit
Z = Zero

Suppress

ex:

g

Constant or Edit Word

Q:
1

2

3

4

5

6

7

8

9

1011 1213 14 15 16 17 18 19 20 21 22 23 24 •

D

~ ADUlt~

_

'A

,

CnL"MAJ

I

1 i t

-V-l::A"r11~!-.t'Ie-

1----'f-+-+--f-+-+--II--+-+--f---+-+-t-1-+--+--+-+-t---le-t-+--t--+-+-I---t-+-+-t-L.-+-+~-'-r_r_
--FA.J-t-+--II--+-t--+-+=-i~r-r--~ ~I.I~- p.P,- ~~
0
3

Date

1011 12 13 1415 16 17 18 1920 21 22 23 24 25 26 2728293031 32333435 36373839 4041 4243444546 474849 5051 52 53 54 55 56 57 58 59 60 61 626364656667 fiB 697071 727374

H-+-t-t-+-t---+-;f---+-+-+-F/--t-+-j-+-t-+-t-+--t-t---Ir+--t-t-+--t:~~~
IA
0 2
0
a

Remove

Plus Sign

- - - f - - f----

I

1i1

+--If-+--f--+--t-t--t-+--+- r---H--

I-

+-,f-+-+-+---t-t--t--+-ftl

Ii:

f-=tt
I

Figure 15·24, Printing a Constant Only on the First Detail Line

Programming Aids

15-41

Input Specifications

I

-

Record Identification Codes

0

:) i~

i

Filename

Line

~

-r--

o

!a

~

ell

....

3

2

1

R

Q

0

:5.

Position

~ a

~

Position

~ §~

0::

-~ e ~e
o ~U

Z

4

5

7

6

8

Position

2

~~

~ U

U

0

1

IINIF ~1

2

I

0 3

I

4

I

o

5

I

o

6

I

0 7

I

o

B

I

o

9

I

1 0

I

From

Iji

To

Zero

Plus Minus or
Blank

f:[
«;2
::ou

1011 12 13 1415 1617 18 19 20 21 22 23 24 2526 27 28 29 30 31 3233 34 35 36 37 38 39 40 4142 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6566 67 68 69 70 71 72 73 74

9

0

o

"-,,-

0;

A'NO
3

~~

Field Name

~

~

E.

o

Field
Indicators

Field Location

1l

~

!AA

11q

1 CI\

~

~fJ, ~It:

211

~Il

~
f

88

0«

1 ~Il
1 CIN

11

1~

~

IDI~ S~

18

12 }t::Q TY
2" 12S~IL IES

119

1212
1

I

11

Output Specifications

o

~ Space

r--

Output Indicators

Skip

~ ~.

?>

Field Name

Filename

line

Commas

Zero Balances

Yes
Yes
No
No

Yes
No
Yes
No

I

End
Position

o

o

Z

Z

3

4

5

6

7

8

9

in
Dutput
'AUTO

Record

0
0
0

0131

CR

:

X

=

Remove

1
2

A

J

Y

=

Plus Sign
Date
Fi.,d Edit

3

B
C

L

4

D

M

K

Z = Zero

Suppress

0::

Constant or Edit Word

...J
CD

ii:

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 •

I

1 _I.

_L

-

I

li___ _ __

1~~~,tJ~A~N1!T~ljI:t1rT;JIJr~~'~~L~-l-H--+-+-U++-H---l-+~~

I

I

~Mlr iA '7'
i
- -- I---r---- I-+-+-+--+--+-+-I'----+-+-+---+-+-I-+'----+-+---f--+-i------l'----+-+~

-,

-1--1-- .

f-t- -

_

'--L-_L-_ _

Figure 15·25. Incorrect *AUTO Specifications for More Than One Record Type

Auto Report Function

r----:-ajt---:t--t-+-----+-t-t-t--If-+-t-t-----t-t-t--t-t--t-i

I ntl~rIQIIPlrro~ I

---1

!

t- ;
-t1
~~L __ .
L,_ ~__ _______ ~ _~_

1 5-42

No Sign

10 11 12 13 1415 16 17 18 1920 21 22 23 24 2526 27 28 29 3031 32333435 36373839 4041 4243 44 4546474849 50 51 5253545556 575859 GO 61 6263646566676869 7071 72 73 74

PRllit~Ij. __L JT ___ --H--'- __ ... ,'1
"1'I~~tc~ ---r-III i I I
'cl~
I : ! TT+~mY
R
o 41 0 ! ~I
-rHi-+-II-A
---r t- t-r '- --- - f-- - ----H-1-1-- - , - )~1±'("
-~-;~t-~
I--t 1- -. -- - f - - - r '--H-f-r-I--~- ---f---- o 1\

o 21

to Print

L-_L...J_-l-~+--JI- I----.+-l----l--l--l---I--I-+--+-+--I--+--+--+--I--I-+---I-+-I--I

Calculation Specifications

C
-

Indicators

At

!

line

•

O-r,

0

0

g

Factor 2
Length

Plus IMinusl Zero

I

~~

~i

Comments

Compare

1 > 211

< 211

- 2

U :: Lookup(Factor 21is

0

lil1

c
c
c

oh

°

Operation

Factor 1

Z
Z
Z
o :I: High Low Equal
9 10 1112 131. 1516 17 18 19 20 21 22 23 24 25 26 21 2829 3031 32 33 34 35 36 31 38 39 40 41 42 434445464748 49 50 S1 5253 54 55 56 51 58 59 60 61 62 63 64 65 66 67 68 69 70 71

56

0; 2

1

Indicators
Arithmetic

Name

~

3

Resulting

Result Field

2- AD itOITY
~- AD DS ~l. E~

11

n

73 74

l3kt

~T IY~

SA LIE SA

I
I

1512

!

I

C

4

Output Specifications

o

Skip

Output Indicators

f-

Field Name
Filename

Line

a:

~
I-

o

j
3

4

::

5

6

a

"£~'AND
1

8

o
Z

'"

Z

·AUTO

;3 5'"
~

~

End
Position
in
Output
Record

II

>

Commas

Zero Balances
to Print

Ves
Ves
No
No

Ves
No
Ves
No

No Sign

CR

~

X •

1

A

2
3

J
K

V ' Date
Field Edit

C
0

L
M

Z - Zero

4

Remove
Plus Sign

B

Suppress

a:

g

Constant or Edit Word

Q:
1

2

3

4

5

6

1

8

9

1011 12 13 14 15 16 17

18 19 20 21 22 23 24 •

9 10 11 12 13 14 15 16 17 18 19 20 21 22 13 24 25 26 27 28 29 3031 32 33 34 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 50 51 52 5:1 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

:1~~IINll

rr

LI1

I~~ ~~I-

l-o+-3+-+-o--+--+''-+-+-f-----j-f-+--+-+-+--+-+--+-+----+---1f-+-+-+--+-+--+-+-I-I~:I~'1~Y1~-·+!-+l,-t ~
-

I

I

!

I

D\!q,-;.c~;rl~tT I~ Ii::

i ::

~ I:

Q~UAWIl !ITrlY I'-+~~~i-i--ji~1+----+---+-i-+-+--l-I-!-I--+I---+-i--+--~; ~
I

::

i

I--O+-4~oH-+--+-+-+-+-+-+-+-l--+-+-~--I-+-+-+-I-+-,H---+---+-f~S~~L~E:3-.S1J ~i I \~MC UI~lli'
IIII
I:
1
°
°
,
.
I
!
I I i i i
i
I:
I
!
I
1-+---+---+--+-+----1-+-+-1-1-- - --t---+-+---f-+- - .
I---r H- --IT-Ir-+_+__+__--I-+-l---L-J------+-~+_+__+____._;-+-+-----+--+--i
I

I

5

L°--'-6-L-l_°-l-l_-L_--'-_L-J.--L-L_'--L _ _ '-- _

_L-_'--'-- __

L-L--'--L-J_L"-'--J-Lll1-. __ i I I

-I---+--+I---+-,

!

;

!

:

I

:

I.

~_l._L___L.l__i:_IL-...i_~"_J.:_-,-!j_1'-----Ll_LI,~--,-I-L___'__.LI_ _1__~:~-"---.-J

Figure 15·26. Correct *AUTO Specifications for More Than One Record Type

Programming Aids

15-43

Calculation Specifications

C

Indicators

~

Arithmetic

At At

Operation

Factor 1

.g

Factor 2

15

0

Plus TMinu;r Zero

I

~ ;
~ ~
"2 ";;

15

Comments

Compare
1>21<21=2
Lookup(Factor 2)is

z
z
o ::t: High Low Equal
9 10 1112 1314 15 16 17 18 19 20 21 22 2324 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051 5253 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

z
4

Length

Name

Line

3

Resulting
Indicators

Result Field

5

0

1

C

0

2

c

0 3

C

I"In

~- lAD Dig
lAlOD ron
"'~ uN 111

11

~g

UNrr
" UN
",0
III

Output Specifications
LL

~ Space

Output Indicators

Skip

?>

w~

.t
Filename

4t h -+-..---+--r----.-----1
~ ~ ~ ~

At

i~~~

1

Field Name

h-r--t-"T"""""1--t---r--r-~----i '" e:.

>-~~~

'"

:;:

0

0

z

z

0

z

'AUTO

~

Position

to Print

Ves
Ves
No
No

5 ~U1Put

~

Record

CL

~ ~

Zero Balances

Commas

Ves
No
Ves
No

No Sign

X =

CR
A

J

B

K

C

L
M

D

Remove
Plus Sign

V = Dale
Field Edil
Z = Zero
Suppress

Constant or Edit Word
•

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 2021 22 23 24 '

9 10 11 12 13 14 15 16 17 18 19 20 21 22 2324 25 26 27 28 29 30 31 32 33 34 35 3637 38 39 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

LR

OUNIT

-~

'W~

IIIN

Calculation Specifications
Line 01

This instruction is needed only to define the field COUNT for
accumulation.

Line 02

This instruction accumulates the total for the first control level.

Output Specifications
Line 03

This instruction causes the generation of calculation and output
specifications for the detail and total lines. The LR conditioning
indicator prevents the generated detail calculation from occurring.
It also prevents printing at detail time.

sp~cified in the program, a 1 is added to COUNTR
rather than to COUNT1 on the calculation specifications.

Note: If no control levels are

Figure 15-27. Method of Using * AUTO for Counting Records

EXAMPLES OF USING AUTO REPORT
Examples 1 through 4 explain how auto report is used
to generate report page headings and such output
specifications as column headings, detail lines, and total
lines. Examples 5 and 6 illustrate the use of the auto
report copy function to copy specifications from the
library and to modify copied specifications for a
particular job.

15-44

Auto Report Function

EXAMPLE 1

* AUTO Page Headings

.-------~~

...---------11 Problem 11--------.....,

J

I

Procedure

* AUTO Output

\1-----------.

II Code normal RPG II file description and

Produce the sales report shown below using the
* AUTO page headings and * AUTO output
functions of auto report.

input specifications for the job.

II Code * AUTO page headings to produce
a one-line page heading that includes
date and page number.

II Code * AUTO output to produce oneline column headings, detail report lines,
and final totals.

Letters refer to fi el ds
on the following page.

10/26/78

m1

Ii)

REGION

BRANCH

1
1
1
1
1
3
3

17
17
17
22
22
25
25

m

SALES REPORT FOR ANY CO.

m

Ii

ITEM

DESCRIPTION

SALES

AG7701T
AG7705S
AP6545B
AG7701T
AG7705S
AG6545B
AP6549P

2-TON TRUCK
PICK-UP
CAMPER
2-TON TRUCK
PICK-UP

5
10
2
2
4
10
20

CA~lPER

1/4 TON TRUCK

Ii

AMOUNT
25,000.00
20,000.00
8,000.00
10,000.00
8,000.00
40,000.00
30,000.00
141,000.00

m

ON-HAND

PAGE

1

m

VALUE

2
1

10,000.00
2,000.00

1
1
5
6

5,000.00
2,000.00
20,000.00
9,000.00
48,000.00

Examples of Using Auto Report

~"<

15-45

D Code RPG II file description and input specifications.
Fi Ie Description Specifications
File Type

F

Mode of Processing

f---

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

End of File

Record Address Type
Sequence

Filename

Type of File
Organization
Nor Additional Area

File Format

Line

Name of
Label Exit

Symbolic
Device

Device

...J

Number of Tracks
for Cylincier Overflow

Number of Extents

UJ

Tape
Rewind

Storage Index

~

~

o Overflow Indicator 8

B! ::c~~
Length

~
~
0: . . . .

. Record

5

Length

Condition

-,5

~ ~

~

Key :ield
Starting

x

Location

UJ

Z

Continuation lines
Option

U1.~

~

Entry

n 12 13 14 15 16 17 18 19 2021 22 23 24 252627 28 2930 31 3233 34 3~ 36 37 3839 4041 4243444546 474849 sO 51 52 53 54 5556575859 6061 62636465 66676869 70 71 72 7374

10

~H.~n1~&~3~~~i~'~I~~~H:~H,'l~Hl~~:~~~~~~~~
o

4

1

F

'i

:

i,

.

i'

I i !

I

I

ill

1 1

1

1-

1

Input Specifications

-

I

i

Filename

~

;E

til

4

o

5

6

I

01 3 : I
01 4 1 I

!

o 5:

I

:::§

7

8

ES

1

I

:

!

I

,

I

I

~

"C.

H-i

I

!

:

"~I
I

Position

j

~ e~
o

z

r

IAA

Position

~ ~

u u

- ~
~~j
z u u

'~

Position

~

0

o~

z u

Jj ;

From

!

~:;rI!1
11
:o!. - ' -I - . 'I i i

To·

!
]

0

)

7

I

1

I

!

1
2

i

I
I!:

d-;-

'.

!2

I

ij
:

- r- -c--

I

i

B

:

I

--+- -+tl

,~

-

I

a

Contents

m

ITEMNO

Item number

II

BRANCH

Number of the branch office where the item was sold

[I

REGION

Sales region in which tne branch office is located

m

DESC

Description of the sales item

SOLOQY

Quantity of the item sold

SOLDVA

Total value of the items sold

ONHAND

Quantity of the item remaining on hand

m

VALUE

Total value of the items remaining on hand

15-46

Auto Report Function

m

~
e

~

.~

Field Name

II
II

Field Name

!:.

0;

-to

911

I

o iBiIi

';;

~

0

E."

7!
I i I
I
WcO-1~Hl
I
o

3

0
0

:2-0
.~ "ii
u..i.i:

.~ ~

"5

:~

~1

:2u

~
"0

~

"0

Zero
Plus Minus or

Blank

0;

u:

10111213 1415 1617 181920 21222324 2526 27 28 29 30 31 3233 34 35 16 37 38 39 40 4142 43 44 45 46 4 7 48 49 50 51 525 3545556575 8 59 60 6162 63 64 65 66 67 68 6970 71 72 73 74

9

i

t-

2

1

~~

::l.

r;:;:r;;-o

I IS~l

121

~

~ ,~
~r;- t g

~
3

Field
Indicators

Field Location

Line

011

Record Identification Codes

0

]

Ie
11~

r~ ~N

RA NC
~~

2S:

10

""~~

III sn LO:Q
2. SO lD~
Bb OIN HAN
~3 2~ LUE
I
1

!2

3~

"

---'--

fJ Code * AUTO page heading specifications.

m

III The title information is centered by auto report; do

Enter an H in column 15 and * AUTO in columns
32 through 36 to request an auto report page head-

not enter end positions in columns 40 through 43.
Fields and table/array elements can also be used.

ing. Up to five page heading lines can be described.
The system date is printed on the left and the page
number on the right of the first heading line on each
page. To suppress the date and page, enter an N in
column 27 of the auto report option specifications

sheet. ~
Output Specifications

,

o

-

.

~ ~--~, ~i"'"
~ ~
I

Filename

Line

Output IndicJtors

:; S"ace

ci5

0

- -,,-

~

~

\ .- "* -6-~

And

~ ~

a

,,O Sf 52 53 54!l& DE S7 58 59 GO Gl 626364 65666768697071 72 73 74

16 17 IE 192021 2223 24i25 26 27 28 29 30 j1

I __

0

II

Commas!Z

~ ~ ~utPut 2

I iN.

,I'

'~~Jt> k

50

o 6

9

I ;I
!

a:

And

Ot"'Kl.N I E&A" ___ J ______ 1 1_

o

o

~

7

Field Name

:>

10

_

~ ~~,.::.

~~.......
3

I

lfr

ITGTrtS:A~lES ~ lOX I i ' ,
f T '-;·TIjF~R1=AtN5'L:C~O~•• ,

'i

-ti

I ~ I

Ii:

:!

-tT -I>~ : , -=:~ I I! i
~-t- I i~d
: ,1111 I Iii T ~C ! i l l '
T --,--++II,
'irl ! ............ I
!l!·I·'·lt!! Ii: •. , I!
:! I
I
--;-+-~- -+~ - -- ~-i-- - -'T' rc---+-t-i-....-~I--~.:-,_---+-;-i-,--i'---r---t---:---~
~ _~ __U __ ~~ I '
I I
lI:!::-.. . . '_1_1 '
! ~~~~ __ ~;_!1-'.1--'--1'-------'---'
'n

I

I

___

'

i

i

1

:_

I

I

I

i

i

i

:
I

i

__

I

.

'

:

m

iii When space and skip entries (columns 17 through
first heading line; single spacing is done between

When output indicators (columns 23 through 31)
are left blank, auto report page headings are printed
on each page (conditioned by 1P or overflow). If

heading lines, double spacing after the last heading
line. (See Example 4 for an example of multiple

auto report assigns an unused overflow indicator to

page heading lines.)

the printer line.

22) are left blank, skip to line 06 is assumed for the

no overflow indicator is defined for the printer file,

11

Line 06

Blank line

REGION
1
1
1
1
1
3
3

m

m

m

PAGE

SALES REPORT FOR ANY CO.

10/26/78

BRANCH
17
17
17
22
22
25
25

ITEM

DESCRIPTION

AG7701T
AG7705S
AP6545B
AG7701T
AG7705S
AG6545B
AP6549P

2-ToN TRUCK
PICK-UP
CAMPER
2-ToN TRUCK
PICK-UP
CAMPER
1/4 TON TRUCK

SALES
5
10
2
2
4
10
20

AMOUNT
25,000.00
20,000.00
8,000.00
10,000.00
8,000.00
40,000.00
30,000.00
141,000.00

ON-HAND

1

VALUE

2
1

10,000.00
2,000.00

1
1
5
6

5,000.00
2,000.00
20,000.00
9,000.00
48,000.00

::::::

Examples of Using Auto Report

15-47

IJ Code * AUTO output specifications to produce:

m

Detail report lines

III Column headings
II Final totals
Output Specifications

o

fj

Space

Filename

line

I

~~0~

'& ~! i

~ %r5 -5-

OR'"

'A~ D
3

4

Output Indicators

Skip

~ ~

r----

5

6

7

8

~



7

I

~

8

I

1-" '"
1·"'0

I~

·.1> I··
.... I <

a

9

I

1

a

I

11
H

..,
I- 7

Z

~6[

II

n

0 HA

11~~ VA~U:

.

.i 1····1

1 ..

1

I

•.•

!/ • •
•••·.i

........

Because two control levels are defined, the SO LDV A and
VALU E fields (see following page) are accumulated to two
levels of totals (branch and region) and a final total (LR).

Examples of Using Auto Report

15-49

As in Example 1, an A in column 39 of the output specification causes,SOLDVA and VALUE to be accumulated.

Output Specifications

-

o

£

34567

aI' I
a !2
a 3
a

4

8

9 10 "

I

~R
A

I I
,I
-;:

i '": I
zi,

z'
I

I,

F;,1d N,m,

': I
~

I
I

ar

0

'

ii,

~___

I

Record

I

Zero Balances

1

2

3

4

X =

::00,,"'", 0,

co

0: •

Ii!

01, ~

0

:

I

5

6

7

8

9

Ed;' : , , :

-

~---~-r---;---·---r--f--f~~ ,~______

g~

1

,

~JP

-~

V

iT"'MN~'O
_,~ __ ~-+- ~.!_c.n

I j

: ,

i

!

i

i

:

I

i

rlttlVICOT7'! : ' ! '

V'; : + I ; iii

7:

41
EGlON
('RARCU
--.,

'I '):"0'

\ ; ,

:'

Ii'
'REGILO~'i I I I ! :

-'IB.::IDfANC.:UI! \
I 'I~TI\~'MT'~ . I
_ .~~~J) Iii

I

.!

':

I

;,'

I Ii: . '
'u_E~~CRilpmI:OK,
a 9
0
• :
)OL 1\
c: AILES;': i I : i : i
~ 0 -'-~--'-f---'- ---~-'-:- ,--'--.-- ~OJ-l.MD-WA0nj~:~'-I~t-Qb-u-~""'-:- ~ ! !

__ ~ __ESC!

'

If

J

"V ,/ :; ,

I

~_o -"--__ ~==,_=~==~~----~'----~.~~=~~~~W:D)
.2.~~ ___ ._______

III _ -~-

, 3
0
~_--'-.l...-l. ____ .___ . __ ,. ~I ~

i

.

:

.

~~;A

;7!'

.::

. . . •:• -; --

I

DESCRIPTION

:

!

i

:.

!

I

!

17

5

10

17

2

I

i

-;

3
3

22
22

25
25

AG6545B
AP6549P

CAMPER
1/4 TON TRUCK

15-50

Auto Report Function

!

II:

I iii!
ill I

II
I

!

I

I

I

I
I

I

I :

1

i

I

I

I

!

'

, ;

I
I

,

~ I,

.

Ii! T~

i!!

;

i

!

!

\ ;

I

I

:

:

!

I

i

Auto reportprints asterisks (*) to the
right of generated total lines to aid in
identifying them. If you want to suppress
the asterisks, enter N in column 28 of the
auto report option specifications sheet.
PAGE

1
1

5,000.00
2,000.00

18,000.00

7,000.00

71,000.00

19,000.00

40,000.00
30,000.00

5
6

20,000.00
9,000.00

70,000.00

29,000.00

70,000.00

29,000.00
48,000.00

Total fields are always two positions longer with the same
number of decimal positions as the original fields.

Ii!

I

,_--L __

10,000.00
8,000.00

AG7701T
AG7705S

I

i

i

!

I

ii'

I:

12,000.00
1
1

.

i

SALES

17

:

III
I

Ii
i
. ~ TL-LL_-"--,
' , '
i
i
i
,
i
-~----~-----...-,--,,-----"--..........- .......

VAillE ,

SALES REPORT FOR ANY CO.
BRANCH

!,

~l:.mlD'T-~

Auto report places a blank line after each total line and an
additional blank line before the lowest level total and before
the final total. If you enter spacing and skipping values on
the D- * AUTO specification, they apply to the detail print
line only.
10/26/78

i

!

i

:'

I,

1
1
1

, . ::::;''''

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 "

~-t- j J~llJJ ~~.I. I I I il I 1'
1 i /
I :S8!.~~SR!E:PORrr:

'i i::

" I i : '

~~f~ __-_L ___ ,---- -I-'-V~--

REGION

Remove

1213 1415 10 17 le 19202122232425 2Gb7 1 28 29130 31 32333435363738394041424344""""4f 4647484950 5152 5J 54 55 56575859606162636465666768697071 72 7374

o

0

IArr , : :"' , , , '" 'i ! ,. ::i:'::"
Com",

~ ~ ~::~: ~ L:
~~

"AUTO

II .

<

0 PR[Nif~H r - r - , - _~-+-I---r-+--+--f--+--IF~'-\L~mO!

~';--:~:,.
016

~u

'N '0

:>

Output Indicators

Skip

~,

Filename

Line

Space

/

EXAMPLE 3

* AUTO Output

1

.--_ _ _ _ _--1

I

Problem

r--------I-\

11---------,
I

D Code file description and input specifica-

Expand the sales report from Examples 1 and
2 to contain:

tions as for Example 2_

m

fJ Code * AUTO output with:

Group indication for REG ION and
BRANCH fields

iii Second

iii

JI---------

Procedure

m

Output indicator on field description
specifications

column heading line

III C in column 39 and a literal in

Literal (constant) on the final total line

columns 45 through 70.

II R in column 39 and a literal in
columns 45 through 70.

II

File Description Specifications
File Type

F

-

Mode of Processing

File Addition Unordered

Exten, Exit
for DAM

Length of Key Field or

of Reccli d Address Field

End of Filt'

Z

Record Address Type

Filename

Type of File

til

Device

Numbt'r of Tracks

for Cylif'l(1cf O\erfl.:> ...

Name of
Label Exit

Organization

Storage Index

Input Specifications
Record Identification Codes

I

~

,

Filename

line

Position

3

4

o

1

Field
Indicators

Field Location

r--

5

6

7

8

I~

o

2

I

o

3

I

o

4

I

o
o

5

I

6

I

o

7

I

o

8

I

0 19

I

1 0

I

111

I

9

Position

Position

From

To

ci:

~

Field Name

]

0
0

-.;

u:

..

.;:

~

j

g ~ ·c
.5 ~ 6 u:

Zero
Plus

~'1i"U5 or

81<1nl...

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 .16 37 38 39 40 41 42 43 44 4~ 46 41 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6364 65 66 67 68 69 70 71 72 73 74

ALIE5

I

i

!

I

I

i

Examples of Using Auto Report

15-51

Output Specifications

o

'5

!~~ ,

'R" ;;:

Filename

Line

~
A
3

4

5

6

7

Space

Output Indicators

Skip

F;,1d N.m,
Jd

~~~

~

_

ADD

-

E c!

'"



15-54

X· Remove
Plus Sign

J
K
L

-r~-r+1-r~-r~~~~~~r+~r+-~~~~~h+4-~4-~

A second auto report page heading is specified. Because spacing
is not specified, space-one is done
after the first and space-two after
the second. Because no output
indicators are specified, the
second heading is conditioned
like the first.

0

:

A
B

Constant or Edit Word
•

!

1
+.-+-..+.-.+.,;,:;;.h.
J-'

H-+-+-'

214
25
2.6

CR

9 404' 4243444546 47 48 49 5051 52 5354 65 56 57595960 61 626364 65666768 69 70 71 727374

!

I

Zero Balances

Commas

~:~tion

al

AUTIO

titii-I-t'+.:oI-+++++-++-H--+4-'++--+-'I -+-1 AU 110
H

I

;3-0 5~

• AUTO

L2
OFNL 2

I

i

~-~-~t-·+++-J-!rl,

v

'"
~ ~

1920 X22 23 24 2526 27 28 29 3031 323334 35 363738

OPKINTEIR H
o
o

'"
Field Name ({,...::...;::.=:..~",,-,-:::c:.;;;"ur~-~I""'I

I

'"

IJ

Output Specifications

ZS LS OS 6" Bt ltr 9tr gtr "" Ctr ltr

'tr

)

2

11\J TIAL5'
I

COMP~

/

m

-

,-

printed on generated
total lines if you enter
the number of the control level in column 39.

V ITOTAL~I'

0.6e Bt Lt 9£ SF; 17£ £c ze u: at Sl az LZ 9Z CiZ tot: cz ZZ LZ OZ 61 8L LL 9L SL '"

£L ZL LL 01

6

B

L

9

S

"

£

-

-

-

l

L

EXAMPLE 5

.-----------I~ Pro~edure

Problem

ll----------

D Catalog the file description and input

Use the copy function to obtain specifications
for the sales report below (same as in
Example 1).

specifications for the SALES file in a
library.

B Code the /COPY statement in the specifications for auto report.

SALES REPORT FOR ANY CO.

10/26/78

REGION
1
1
1
1
1
3
3

BRANCH
17
17
17
22
22
25
25

ITEM

DESCRIPTION

AG7701T
AG7705S
AP6545B
AG7701T
AG7705S
AG6545B
AP6549P

2-TON TRUCK
PICK-UP
CAMPER
2-TON TRUCK
PICK-UP
CAMPER
1/4 TON TRUCK

SALES
5
10
2
2
4
10
20

PAGE
AMOUNT

25,000.00
20,000.00
8,000.00
10,000.00
8,000.00
40,000.00
30,000.00
141,000.00

ON-HAND

1

VALUE

2
1

10,000.00
2,000.00

1
1
5
6

5,000.00
2,000.00
20,000.00
9,000.00
48,000.00

Examples of Using Auto Report

~:,

15-55

.D Catalog specifications for the SALES file in a library using the library maintenance utility program.
File Description Specifications
File Type

F

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

--

End of File

Number of Tracks
for Cylincier Overflow

Numher of Extents

Sequence

Filename

File Format

line

These specifications could be replaced by a single statement
as shown on the following page if they were cataloged in a
library.
Input Specifications
J

Record Identification Codes

I

-

v

Field Location

Field Name

~
]

g

.3

o

2

I

o

3

I

o

4

o

5

I

o

6

'I

·::·.)1 .• •·:.

:/
\

I

I.>

I···•.

.r: .: .: . : •.

8

I······

o

9

i •·• •

.:..

h::·:·
:··ci:'.

1

I)IF

I.:···.:

/:< . •: • .

/(

7

o

\. ::...

Ii . .

.c:c: 1< ...... 1

o

....

<.:.

l

• ":·:i

.:...

•i

II

<

11

:.:.

0

:2-0

~

.~ ~

~

~~

0;

.~ "ii
u..LL"

-5

:~

::;;u

"0

Zero

Plus Minus or
Blank

"

u::

Ir..~.

r.7 58 59 60 61 61 63 64 65 66 67 68 69 70 11 72 73 74

'1

\.

GIO

2
2
3

>...

::.:.•.

I

J

I
1

0_

1-:

?

::. ··.·1
.c::

I 0

is

,.:::..

I:···.·

i

7
q

i

Field
Indicators

.,c

.0

Ii

r.

".:
f···.···..

I.i

..:..

Output Specifications

o

Output Indicators

Skip

I--

>

3

4

At

Filename

Line

5

I-

0

j

'"

6

7

8

9

e

:{

0

Z

0

Z

L
Z

1>

Field Name

'AUTO

End
Position
in
Output
Record

Zero Balances
to Print

No Sign

CR

Yes
Yes
No
No

Yes
No
Yes
No

I
2
3
4

A
B
C

I I

X = Remove
Plus Sign

0

J
K
L
M

Y

=

Z

=

Date
Field Edit
Zero
Suppress

0::

g

Constant or Edit Word

Q:
1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 2021 2223 24 •

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3233 34 35 3637 38 39 4041 42 43 44 45 46 4748 49 5051 52 53 54 55 56 57 58 59 60 61 6263 64 6566 67 68 69 70 71 72 73 74

I

AUTIO

EGlON
BRANCH

15-56

Commas

Auto Report Function

I
I

FOR A IV "10.

EG[ON'
~ANCI{l

I

i

I

fJ Code the ICOPY statement to include the file description
and input specifications. (For a detailed description of the
copy function, see /COPY Statement Specifications.)
File Description Specifications
Fd. Type

F

-

Flit! Addltion/UnorLiereJ

Mode of Processing

Extent Exit
for DAM

length of Key Field or
of Record Address Field

File Designation
End of F:le

Accord Address Type
Sequence

Filename

Type of File
Organization
N or Additional Ared

File Format
Line
Record
Length

7

R

9

10 11 17 13 14

'6 P

'Ij

n

18 19 :'0 11

21 14

:l~

5

0:
~
t

Symbolic
Device

Device

..J

Number of Extents

LU

Cl: ~
~ ~

~

<3

Condition

r--?
Key Field

Rewind

Storage Index

.g

Overflow Imhcdtor

Number of Tracks
for Cyli.,cier Overflow

Nameof
Label Exit

€

COlltirwdtLon

Z

Lines

LOCdtlon

Entl Y

Option

UJ

26 17 28 79 30 31 37 33 14 35 36 37 JR :lq 40 41 42 41 .t4 45 46 47 4R 49 50 51 51 53 S4 55

~lG

57

1)8

59

6J r,1 Ii? (}3

Ul·~

~

Starting;;;
(i4

GS C.G 67 GR 69

7{)

11 72 73 70.1

Input Specifications

I

-

~
Filename

Line

~

Ul

l-

~~

:J.

~

j

Or;-

0

"Af-;:Jo
5

01'1

~

6

7

8

9

Position

-

~ o
;

Z

Position
u

~

~ ~
U

~e~

Position

~

o Ut3

,,~ ~
Z U U

U

From
0

Z

To

Jii

I/ICIOPi'll IF!b"J.SALETRI I I
I I I I I I I ~~.... .l: -I ] ]

II I
II I

.

Column 6 of a ICOPY statement
must not contain a U or an H.

I·H-

4~ GO 51

~
0;

~

~

g

0

.3

~

10 II 12 13 14 15 16 17 18 19 20 21 22 23 24 2526 27 28 29 30 31 3233 34 35 .16 37 38 39 40 4142 43 44 45 46 47 48

\

Field Name

0;

J

§ .~

Z

.~

0

-0.

C

Field
Indicators

Field Location
3

2

1

::§
~ ."
II

cr

0-

34

Record Identification Codes

0

0

~-o

~

.~ ~

j

.9:.'~
u..u:

TI

:~

~~

:8 58 60 61 62 6364 65 66 67 68 69 70 71 72 73 74

Lll_ . .ltl~~ mil±H-'

---

0

I I I
I I !

I

~-

I

i

+11-

The ICOPY statement can appear anywhere among
the auto report specifications following the auto
report option statement and preceding table and
array input records. It is convenient to code the
ICOPY on the input sheet when you want to override
copied input specificaitons, as in Example 6. After
specifications are copied, all specifications are sorted
into the order required by the RPG II compiler.

/

The source member is in the system library.
The ICOPY statement copies file description and
input specifications for the SA LES file from the
library member named SALETR.

Output Specifications

0

:§
LU

!-----

Space

Output Indicators

Skip

u.

tit
o
~

I~

Filename

line

&"R
>I-

j
3

4

o
o

3

o

4

2

a 5

5

6

Jd

~~

"AroD

I-

o ,

0

~ ~

o

'"

R

"A~'o
7

8

9

~

L

Field Name

0:

~

;3 '"

0

Z

Z

Z

ar

"AUTO

~

~

End
Position
in

Oulput

Record

II

>

Zero Billances
to Print

Commas
Yes
Yes

No
No

No Sign

Yes

,

CR

No
Yes
No

2
3
4

A
B
C
D

J
K
L
M

X

=

Y

=

Z

=

-Remove
Plus Sign
Date
Field Edit

Zero

Suppress

0:

g

Constant or Edit Word

ii:
1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 18 19 2021 22 23 24 '

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4041 4243 44 45 46 47 4849 50 51 52 53 54 55 56 57 58 59 6061 62 63 64 6566 67 68 69 70 71 72 73 74

o tJl:::

To produce a report that has subtotals for branch and
region, L1 must be assigned to B RANCH and L2 to
REGION as the specifications are copied from the library.

Cataloged input specifications for the SALES file.

I

1

VALUE

53,000.00

-

:1---------.

......-------:. Procedure

0
0

~~

.~ "ii
u..i,L

.~~
"fi :E
~~

~u

~
-0

~

-0

a;

Zero
Plus Minus or
Blank

u:

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

!
I
11
Z5 O~ ~
Iii <
T+-+-+'--+-j-- f-- - H--j-r-I-t-t-t-t-t-t-H-t-t-t--r-H-l~;:;ii"t--j-2~7~s;f,n~LiiGtillMi±;i7"r-t--1-H--j-H--r-H---HH
,I

++

--i-I- -t- -+- i - - - f - - ' i II II -r-r-I"
:
i',
.

I'

--

t-

~
?

I",

·.. 11

IJI~

S."OLD'IV

L
- "l
+ ._- -+- -J---J+{--+-+--I+-t--~-f-lC---+--+--I-4--1--_H-+.+--l=t:::::-~-f-lr=.-'l-.'-\~~~.~-t'o&-'l--+--+-f-+-+-+-+--+--+---II--\---o
I ! "
"II
I' "'...
•.. L
O'N H ,ill
f--~ ---,-;r-, . ,---:- '-1-- -;-+-+-{--+-f-+--+-+-\-+-+-+--I----t-+-+__+_\-j--I-!.J:::!"~wJ-+___f"'!C~!U~t'''''.i',~~~I1~-+_+_+__+_I__+__+_+__+_+_+__+_1f_+__H
~~
i i i ! I-h---+ _____.:. __ L_~j
i I
__ I- __ 3±~ ___ ~,L-\l~, t iE
, 'o!
i ~ ~ I i I :
I
I
j
Ti- ---+---+--+---+--+---!~
-L--h-, ~---~---I--- + - - - I

i8 ,

~1;+-i

I,

:,

I

I
I

I

+-+,

II'

f- - ; - ; -

i

-+---;-1-

I I

~~L _~~L.LLLL~ ~ ___ ~ ~_'-- ,_ JJ_J_l-I---L_'--L-.l---L,-l-__'-- __

C- ___

L __ ~__

-1-+-l-l---t--1-1----\--f---,-

.L-'--'---L--L-L---L--L_..L..Jl--'----'--_-'---'----'--_1-JL.L---'--_l ___ _

(
15-58

Auto Report Function

fJ and II Code /COPY and modifier statements.

As a result of the modifier statements, three levels
of totals are accumulated for the SOLDVA and VALUE fields (L1, L2, and LR).
File Description Specifications
File Type

F

I--

Mode of ProcessII19

[nd of File

Lrmgth of Key Field or

Extent Exit

of Record Address Field

for DAM

Record
SeqllcnCe

Filename

Ad(lr~ss

Type

Number of Extents

Type of File

Line

The field names, BRANCH and REGION, identify the
input field specifications that are to be modified.

Entries on the modifier statements override the corresponding entries in the copied specifications.

~
0

I

5

~

I-~

Filename

Line

oJ;

....

3

4

1

a

2

a

3

5

G

::'0
] ~

'0 :-r- Z5 0~

~
0

::J.

7

8

9

~ord Identification Codes

""-

1

f23

]
~

..........

:"

3

i"- .....

i'

~

0

~

Position

~ §U

'A ~'o

\

Field Location

2

0
Position

\

Input Specifications

ge
o~

Z

u

I~ ~~ jM
6
0;

~

~

0

Vl

tJ 5

~.:

10 11 12 13 14 15 16 1718 1920 21 22 23 24 252G 27 28 29 30 31 3233 34 35 3G 37 38 3940 4142

II CO tJ~ Fl .. 6 A"" ErrR

From

a:

To

..J

en

~~454647

I

I""":-...,

I

!

I

I

I

48 4950 51

'

...... ~

l

~t\'""

" " " ",,>co

~
-:;;

j

e

.3

L+,1
~~~
IQ:N LiZ.

~

0

~~

~

u.,;:
S~

~

~w

~

-5

~~

:2u

PillS

""0;
,;:

Zero
Minus or
Blank

59 60 61 G2 63 64 65 66 67 68 G9 70 71 72 73 74

_!~_~_L . I

......

Field
Indicators
0
.:;

I

I

I

I

!

I
[

i

I

! I

,rt-

i

i

!

Output Specifications

-

o

w~

Space

~! ~ i

Filename

line

~ ~ ~..::.

And

.... "7 -.:'OE -=-OL

A

o

R

5

6

7

8

9

OJ

~

-

Z

Z

Field Name

Ves

~:~tIOIl

Ves

a:

Z

I
I

i

. AUTO

8~ -£.~l~
~ ~

in

Output
Record

Zero Balances

Commas

_-,-_ _,.-,

And

O

r;- N 0

_---'------,>

ar.

Output Indi,C,ators

Skip

t :ith-+--.--+--1r----r----i

II

to Print
Ves
No
Ves
No

~~

a:

x

CR

A

J

B

K

C

L
M

o

V

Z

= Remove
Plus Sign
= Date
Field Edit
=

Zero
Suppress

Constant or Edit Word

...J

~

No Sign

.

1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17

18 19 20 21 22 23 24 '

1011 1213 141516" 17 18 192021222324252627282930131 32333435363738394041424344454647 4B 495051525354555657585960 6162636465666768697071 72 73 74

Cataloged file description or input specifications are
overridden as follows (see /COPY Statement Specifications for examples):
•

Entries in a modifier statement override corresponding entries in a copied file description or input field
specification.

•

Blank entries in a modifier statement remain unchanged in a copied specification.

•

Ampersand (&) in the leftmost position of an entry in
the modifier statement sets the entry to blanks in the
copied specification.

•

New fields can be added to input specifications by new
input field specifications added as modifier statements.

•

Modifier statements do not change the cataloged specifications. The modification is only for the program into
which the specifications are copied.
Examples of Using Auto Report

15-59

15-60

Auto Report Function

Chapter 16. Programming Considerations

STORAGE SAVING TECHNIQUES

Creating the Overlays

When a program is too large to fit into the execution
storage size (specified in columns 12 through 14 of the
control specifications), some storage saving techniques
can be used to help reduce the program size. Before
you can use these techniques effectively, however, you
need to understand: (1) how the RPG II compiler
creates overlays to make a program fit into the storage
area available for execution and (2) how the compiler
determines when a program is too large to fit into the
storage available for execution. The following text
discusses the overlay process and provides some
suggestions for saving storage.

To create overlays, the compiler first determines which
routines go into the overlay area and which routines go
into the suboverlay area. Then it calculates the size of
the largest overlay and the size of the largest
suboverlay. The compiler rounds off these sizes upward
in increments of 256 bytes (1 sector) and then adds the
sizes of the root segment, the largest overlay, and the
largest suboverlay. If the sum is larger than the
available storage, the program is too large and storage
saving techniques must be used if the program is to be
run in the available execution storage size.

Note: The maximum object program size before the
overlay structure is created is 64K.

Region
Root segment
Overlay Process
When a program exceeds the storage size available for
program execution, the compiler places some RPG II
object program routines on disk. These routines are
then called into main storage as they are needed by the
program. This is known as the overlay process.
When the overlay process is used, main storage is
divided into two main parts: the root segment and the
overlay area. The root segment contains constants and
data used more than once during the program execution.
For this reason, the root segment always remains in
main storage. The root segment can be used by
routines in the overlay area and can call a routine in the
overlay area by using a branch instruction. The overlay
area contains the major routines of the RPG \I object
program. Routines in this area can be called by the root
segment or by other routines in the same overlay area.

Overlay fetch routine
Overlay area

1------- Suboverlay area
Secondary root segment

Figure 16-1. RPG II Storage Map

Some large programs require that storage be divided
into two additional parts: the secondary root segment
and the suboverlay area. The secondary root segment
supplements the root segment. If the root segment and
the overlay area fill main storage, the secondary root
segment is not created. The suboverlay area, created by
the RPG II compiler, contains subroutines and other
RPG II code needed to support a routine in the overlay
area. Figure 16-1 shows the location of the main
storage areas.

Storage Saving Techniques

16-1

Special Open/Close

The compiler uses a special open / close when the
overlay requirements for open and close exceed the
overlay requirements for the rest of the program.
Special open / close can be easily identified because
overlay $##002 is the first overlay identified in the main
storage usage map (see Figure 16-2).
The initial load of the program brings in the code
specified in the main storage usage map between and
including the root segment and the overlay fetch area.
Open is completely self-contained and does not need
any of the nonoverlay code. When open is complete,
overlay code is loaded.
Overlay code consists of all code that is identified as
nonoverlay and was not loaded during the first load.
(Overlay code is also identified as overlay $##002 in the
overlay map following the storage usage map. The
other overlay numbers correspond to their respective
overlay numbers as they appear in the storage usage
map shown in Figure 16-2.) The program then executes
as a normal overlay program until close is needed. At
this time, close is brought into main storage starting at
the overlay fetch area and using as much main storage
as is needed. To find the overlay fetch area size for the
rest of the program, subtract the start of the overlay
fetch area from the lowest start address of the
nonoverlay code that was not included in the first load.
For example, in Figure 16-2 the input control routine
starts at hex 2340 so"hex 2340 minus hex 2340 equals
hex DODO-therefore, in this example there is no overlay
fetch area.
After identifying the root segment and the largest
overlay and suboverlay, you can determine whether they
contain routines that can be manipulated to reduce the
overlay size. Remove routines that can be manipulated
from the largest overlay and place them in the smaller
overlay. When the root segment, largest overlay, and
largest suboverlay are calculated, the storage area
needed is less. Storage saving techniques can be used
to control the following routines:
• Input records

Input Records: You can process one or more of the
input or update files as a demand or chained file using
the READ or CHAIN operation code. With a demand or
chained file, the instructions to read the file can be
moved into the total or detail calculation routines.
Remember that total calculations are not done on the
first cycle.

Detail or Total Calculations: Use the following
techniques:

• Use subroutine calculations. In some instances using
subroutines can increase, rather than decrease, the
storage required because of the nature of the existing
calculation routines. However, it can reduce the
overall storage requirements. If one subroutine calls
another subroutine, both subroutines must be in
storage at the same time. This can increase the size
of the suboverlay area and the total storage required.
To ensure the smallest requirement, do not call a
subroutine from another subroutine.
• Eliminate exception output if possible. This moves
the logic for those output operations to either total or
detail output routines.
• Eliminate READ and/or CHAIN operations by using
matching records and consecutive processing. This
moves the logic to input records routine.
• Move part of the detail calculations to total
calculations (or total calculation logic to detail
calculations). Total calculations are not done on the
first cycle.

Detail or Total Output: Use the following techniques:

• Use exception output. This moves part of the output
logic to detail or total calculation routines.
• Do some of the output at total (or detail) output time.
This moves logic to the total (or detail) output
routine.
• Do not specify blank after for fields; instead, clear
them at the beginning of detail or total calculations.

• Detail calculations
• Total calculations
• Detail output
Total output
The following storage saving techniques can be used for
these routines; however, they might not work for all
programs.

(
16-2

Programming Considerations

MAIN STORAGE USAGE OF RPG It CODE
START
ADDR
0000
226E
2340
23B2
244E
2509
2340
23AA
252F
253B
27B3
2730
2955
2BBO
292E
27F6
4112
2BA1
37B9
409C
3BIC
3B16
28A9
3603
3907
3A13
3C05
300B
3481
3E46
3EOE
2BBl
35AO
2899
3EAl
35CC
3553
3ABB
4106
3F5F
3628
4227
421B
4419
4495
44AO
2340
2412
2568
286F
23EF
2340
2541
2596
23E3
2B63

NAME IF
OVERLAY

St:::002
S::::002
S::::003
S::::003
S::::003
S::::003
$::::003
S::::003
S::::003
$::::003

OVERLAY
NAME
$::::001
$::::002
$::::003

::LI BRAR Y
::L I BRARy

CODE
LENGTH
226E
0002
0600
009C
OOBB
0026
006A
0008
OOOC
01F5
0043
00B3
OB2C
0011
0027
00A3
00A9
0008
0093
006A
OOSA
0161
0008
00B6
003C
0078
0106
0103
0002
005B
0038
OOOC
002C
0008
OOBE
OOSC
0040
017A
006C
0130
OOAB
01F2
OOOC
007C
OOOB
0024
0002
0021
002E
0016
0152
00A3
0027
02(0

noDe

OOOC

NAME
RGROOT
RGSUBS
RGSUBS
RGMA IN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
iilPGDM
RGMAIN
@PGRI
iilPGCI
RGMAIN
RGSUBS
RGSUBS
RGSUBS
iilPGAA
RGSUBS
RGSUBS
iilPGMC
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
@PGIC
iilPGMA
RGSUBS
RGMAIN
RGSUBS
@PGCO
RGMA I N
RGMAIN
RGMAIN
RGSUBS
RGMAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
@PGOM

TITLE
ROOT
OVERLAY FE TCH ROUTI NE
OVERLAY FETCH AREA
INPUT MAINLINE
RECORD IDENTIFICATION
CONTROL FIELDS
INPUT CONTROL ROUTINE
INPUT HOOK
DATA MANAGEMENT CALL
INPUT FIELDS
RESET RESULTING INDICATOR
UNPACK
DETAIL CALCULATIONS
CONSTANTS
CONSTANTS
OUTPUT CONTROL ROUTINE
TAG FETCH
INPUT HOOK
SUBSEG
MULTIPLY
SUBSEG
SUBSEG
INPUT HOOK
CHAIN CODE
SUBSEG
SUBSEG
SUBSEG
SUBSEG.
EXCEPTION
SUBSEG
SUBSEG
OUTPUT HOOK
FETCH OVERFLOW
INPUT HOOK
SUBSEG
CHAIN CODE
OVERFLOW SUB SEGMENT
SUBSEG
DIVIDE
MOVEA
CHAIN CODE
DETAIL OUTPUT
OUTPUT HOOK
PACK
TOTAL OUTPUT
LR & OVERFLOW PROCESSING
OPEN MAINLINE
TRANSFER VECTOR
CLOSE MAINLINE
TRANSFER VECTOR
CONSTANTS
OUTPUT CONTROL ROUTINE
CONSTANTS
LR OUTPUT
OUTPUT HOOK
DATA MANAGEMENT CALL

17728
MNL035 MAIN STORAGE REQUIRED TO EXECUTE.
1B705
MNL035 MAIN STORAGE REQUIRED TO EXECUTE WITHOUT OVERLAYS.
RELATIVE START
NUMBER OF
STARTING MAIN
DISK ADDRESS
TEXT SECTORS
STORAGE ADDRESS
0025
22
2340
0040
01
2340
004F
06
2340

SOURCE MEMBER INPUT LIBRARY.
LOAD MEMBER OUTPUT LIBRARy.

Figure 16·2. Main Storage Usage Map

Storage Saving Techniques

16·3

Influencing the Overlay Structure
You can influence the overlay structure that is created
for a particular program if you have subroutines in the
detail calculations.
As the calculation subroutines are generated, the
compiler assigns a priority to each subroutine for going
into the overlay. The priorities are assigned from 1 to 6
with the first subroutine in the calculations being
assigned priority 1. The remaining subroutines in the
calculations are assigned priority 2 through 6 as they are
encountered. All subroutines after the sixth are also
assigned priority 6. The subroutines are placed into the
overlay, if required, according to the assigned priority.
Priority" 6 subroutines go into the overlay first, and the
priority 1 subroutine goes in last. You should place the
most frequently used subroutine first in your calculations
and the least frequently used one last. This may reduce
the number of overlay or suboverlay loads.

General Storage Saving Techniques
When the compiler finds that a program is too large for
the storage available for execution, an error message is
written. You can reduce the main storage needed for
your program either by using some general storage
saving techniques or by reducing the size of the
overlays.
You can use some of the following techniques:
• Divide the program into separate tasks, creating a
separate program for each task. For example, if you
want to update a file and print a listing of the
updated file, you can save storage by updating the
file with one program and printing the listing with
another program.
• Eliminate unreferenced indicators. Eliminating
unreferenced indicators can eliminate the instructions
required to set the indicators on and off.

• Elil .• Inate unnecessary conditioning indicators. Two
possible forms of unnecessary indicator tests are as
follows:
If only one type of input record is to be processed,
the indicator associated with that record is always
on except during the first detail output time. It is,
therefore, not necessary for any calculation to be
conditioned with this indicator.
When two subsequent operations on the same
result field are conditioned on opposite indicator
conditions, one of the conditions is not necessary.
For instance, the N09 conditioning is not required
in this example:
N09 Z-AOO FLO

FLOB

09

FLOB

Z-AOO FLOC

This technique might not work for certain operations
if the same field is used as the result field and as
factor 1 or factor 2.
• Reuse calculation work areas and temporary hold
areas. Once the data stored in these areas is used
for the last time in a given cycle, .the area is available.
Reusing these areas can eliminate the need for two
or more additional areas to be defined. However, the
areas must be used for the same type of data.
• Reuse input field names. You can reuse input field
" areas by using the same name for fields in two or
more files. This can be done only if the fields have
the same attributes (length, alphameric/numeric,
packed/binary) and each field is used only in the
cycle in which the record is processed. Both files
cannot be used in the same cycle.
• Reduce calculation result field sizes. Be sure that no
result field is defined any larger than is necessary.
Reducing the result field size can cause a warning
that the result field may not be large enough. If you
know that the largest possible number fits into the
result field specified, you can continue compiling the
program.
• Include the necessary intervening blanks when
describing alphameric fields and constants for output.
This makes the fields adjacent. The output
optimization phase moves all adjacent fields and
constants with one instruction instead of using one
instruction to move each line:
Not Optimized

Optimized

5'OAILY'

18'OAILY TRANSACTIONf>'

17'TRANSACTION'

26'REGISTER'

26'REGISTER'

16-4

Programming Considerations

• Use data structures to define the same internal
storage area for multiple record types and to reduce
the use of MOVE and MOVEL operations.
• Design files to contain record lengths that are an
even multiple of 256 bytes or that divide into 256
bytes an even number of times.
• Design files so that match fields and control fields
are assigned the same position within all record
types.
• Do not designate a field as numeric unless the field is
used in an arithmetic operation in the program. This
saves on the amount of storage required to store the
field and allows the input and output fields' transfer
routine to be optimized.
• Use the shared input/output access method (SIAM)
to process disk files. This may reduce the storage
required for programs using input disk files; however,
using SIAM can decrease program throughput.
• Group calculation statements that are conditioned by
the same indicators. When a large number of
indicators are required, try to use GOTO or EXSR to
reduce the number of indicator tests required on each
statement.
• Use the actual bit pattern in factor 2 when using
TESTB, BITON, or BITOF.
• Do not use half adjust unless absolutely necessary.
• Try to use either factor 1 or factor 2 as the result
field whenever possible.
• Try to use numeric fields of the same length and with
the same number of decimal positions. If the fields
cannot be the same length, try to have the number of
decimal positions the same.
• Do not sequence check your records unless
absolutely necessary.
• Use OR lines rather than multiple record lines
because OR lines require less code.
• Specify the fields in a record in ascending order by
record position.

Reduce the Overlay Size

To reduce the size of the overlay, you can reduce the
size of the root segment or the overlay areas. First,
however, you must identify the contents of the root
segment and the largest overlays in main storage. Then
you can determine whether the contents of these areas
can be reduced to fit into the storage available for
execution.
Use the program listing to find the contents of the root
segment, overlay area, and suboverlay area. The root
segment contains the data and routines that are not
given an overlay name in the main storage usage of the
RPG II code section of the program listing (see Figure
16-3).
Two sections of the program listing determine the
contents of the overlay and suboverlay areas. The
section shown in Figure 16-4 gives the:
• Overlay name
• Number of sectors in the overlay
• Start address of the overlay
The start address separates overlays and' suboverlays.
Two start addresses appear in the start address column.
The lower address (1868 in Figure 16-4) identifies an
overlay; the higher address (1 B68 in Figure 16-4)
identifies a suboverlay.
The text sectors column indicates the largest overlays.
In Figure 16-4, overlay 002 is the largest suboverlay;
overlay 004 is the largest overlay.
Relate the name given in the overlay name columns
shown in Figure 16-4 to the main storage usage of RPG
II code section shown in Figure 16-5. The name and
title columns in this section identify the routines or
subroutines in the overlay.
Note: If overlay 001 does not appear in the overlay
name column, a special open/close overlay construction
took place. When this occurs, overlay 001 is not treated
as an overlay, but remains in main storage.

• Do not use halt indicators unless absolutely
necessary.

Storage Saving Techniques

16·5

MAIN STORAGE USAGE OF RPG II CODE
START
ADDR

r--_ _..

Root

NAME IF
OVERLAY

jlm

.t----~

'----~

lFCB
1F54
1FA5
1E68
1B68
1B68
1B10
1868
1990
1940
1 FE 1
1868
IB3l
lA41
1935
1941
lAF8
1910
1929
IB14
lABC
IB24
1918
1868
1935
1929
lA98
1910
lAIC
IFE3
19A8
1868
1929
196C
1910
19CC
1909
19A1
lA06
1868
195E
1929
19CF
1910
19FA
19A 8
lABB
1965
1868
1929
191D
lAAF
lAA2

S:::JOOI
St.!:J002
S:::J002
S::::003
S::::004
S:H:004
S::::004
S::::004
S:'::004
S::::004
S::::004
S:::'004
S:H:004
S:H:004
S::::004
S::::004
S::::004
$::::005
S:::'005
S::::005
S:H:005
$::::005
S::::005
S:'::005
5::::006
S::::006
$:'::006
$:::'006
S:,::006
$::::006
$::::006
S::::001
$:':'001
S::::001
$::::001
$::::001
$:'::001
$::::001
$:'::001
S:'::008
S:'::008
5::::008
S::::009
S#::008
$:'::008
S::::008
S::::008

CODE
LENGTH
1143
0125
0600
0099
0016
0051
0026
0053
01FC
0008
01FC
0049
OOBI
0043
0002
00B5
0043
001B
OOOC
OOOC
002C
OOOC
OOOC
OOOC
003C
0000
00A4
00B5
0043
OOOC
OOOC
OOOC
001C
OOOB
002'4
00B5
0043
003C
OOOC
0000
OOOC
002E
0016
00B5
0043
0035
002B
OOOC
OOOC
OOFA
0021
0043
00B5
003C
OOOC
OOOC
0000
08111
08492

::LI BRAR Y
::LIBRARY
Figure 16·3. Overlay Usage Map

16·6

Programming Considerations

NAME
RGROOT
RGSUBS
RGSUBS
RGMAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
@PGTA
RGSUBS
QlPGTA
RGMAIN
RGMAIN
RGSUBS
RGSUBS
RGSUBS
@PGRI
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
@PGDM
RGSUBS
RGSUBS
RGMAIN
RGSUBS
RGSUBS
RGSUBS
~PGDM

RGSUBS
@PGCO
RGMAIN
RGMAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
@PGDM
RGMAIN
RGSUBS
~GSUBS

RGSURS
RGSUBS
RGSUBS
RGSUBS
~PGDM

RGMAIN
RGSUBS
RGSUBS
RGSUBS
RGSURS
RGSUBS
~PGDM

RGSUBS

TITLE
ROOT
OVERLAY FETCH ROUTINE
OVERLAY FETCH AREA
INPUT MA I NLI NE
TRANSFER VECTOR
RECORD IDENTIFICATION
CONTROL F I HDS
INPUT CONTROL ROUTINE
CONSOLE - IDE DATA MANAGEMENT
INPUT HOOK
CONSOLE - IDE DATA MANAGEMENT
INPUT FIELDS
DETAIL CALCULATIONS
CONSTANTS
CONSTANTS
OUTPUT CONTROL ROUTINE
RESET RESULTING INDICATOR
EXCEPTION
OUTPUT HOOK
OUTPUT HOOK
FETCH OVERflOW
OUTPUT HOOK
OUTPUT HOOK
DATA MANAGEMENT CALL
OVERFLOW SUBSEGMENT
SUBSEG
DETAIL OUTPUT
OUTPUT CONTROL ROUTINE
CONSTANTS
OUTPUT HOOK
DATA MANAGEMENT CALL
OUTPUT HOOK
PACK
TOTAL OUTPUT
LR & OVERFLOW PROCESSING
OUTPUT CONTROL ROUTINE
CONS TANTS
OVERFLOW SUB SEGMENT
OUTPUT HOOK
SUBSEG
DATA MANAGEMENT CALL
CLOSE MAINLINE
TRANSFER VECTOR
OUTPUT CONTROL ROUTINE
CONSTANTS
CONSTANTS
LR OUTPUT
OUTPUT HOOK
DATA MANAGEMENT CALL
OPEN MAINLINE
TRANSFER VECTOR
CONS TANTS
OUTPUT CONTROL ROUTINE
CONSTANTS
OUTPUT HOOK
DATA MANAGEMENT CALL
SUBSEG

RPF148 MAIN STORAGE REQUIRED TO EXECUTE.
RPF148 MAIN STORAGE REQUIRED TO EXECUTE WITHOUT OVERLAYS.

SOURCE MEMBER INPUT LIBRARY.
LOAD MEMBER OUTPUT LIBRARY.

OVERLAY
RELATIVE START
NAME
DISK ADDRESS
Largest
S::::OOl
0021
0024
S::::002- Suboverlay
5::::003
0028
S::::004- Largest
002A
S::::005
002F
Overlay
S::::006
0033
S::::007
0036
S:J::008
0039

NUHBER OF
TEXT SECTORS
02
03
01
04
03
02
02
03

STARTING HAIN
STORAGE ADDRESS
Suboverlays ~1868
1868

aba

Overlays

Figure 16-4. Overlay Identification Area

r

1868
1868
1868
1868
1868

HAIN STORAGE USAGE OF RPG II CODE
START
AODR
0000
1743
1868
1EBB
1FCB
1F54
1FA5
1E68
Suboverlay 001
1B68
Suboverlay 002 llB68
1810
Overlay 003
1868

(t::~

1FEI
1868
1B31
1A4l
1935
1941
1AF8
1910

Overlay 004

1929

1874
1ABC
Z4

1918
1868
1935
1929
1A98
1910
lAIC
1FE3

f
r

Overlay 005

9AB

1868
1929
196C
1910
19CC
1909

Overlay 006

1A06
f9Al
1868

Overlay 007

.

195E
1929
19CF
1910

19FA
1ABB
f9Aa
1965

Overlay 008

1868
1929
1910
1AAF
1AA2

NAHE IF
OVERLAV

$::::001
S::::002
S:::J002
$:::J003

$::::004
S::::004
$::::004
S::::004
S::::004
S::::004
S::::004
$::::004
$::::004
$:::004
S::::004
$::::004
S::::004
$::::005
$::::005
S::::005
S::::005
S::::005
$::::005
S::::005
S::::006
S::::006
S::::006
S::::006
S::::006
S::::006
S::::006
S::::OOl
S::::OOl
$::::007
S::::OOl
S::::007
S::::007
S::::OOl
S::::OOl
$::::008
S::::008
S::::008
S::::008
S::::008
S::::008
S::::008
S::::008

CODE
LENGTH
1743
0125
0600
0099
0016
0051
0026
0053
01FC
0008
01FC
0049
00B1
0043
0002
00B5
0043
007B
OOOC
OOOC
002C
OOOC
OOOC
OOOC
003C
0000
00A4
00B5
0043
OOOC
OOOC
DOOC
001C
OOOB
0024
00B5
0043
003C
OOOC
0000
OOOC
002E
0016
00B5
0043
0035
002B
OOOC
OOOC
OOFA
0021
0043
00B5
003C
OOOC
OOOC
0000

O:Hn
08492
:JLIBRARY
::L I BRARY

NAHE
RGROOT
RGSUBS
RGSUBS
RGHAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
Q)PGTA
RGSUBS
~PGTA

RGHAIN
RGHAIN
RGSUBS
RGSUBS
RGSUBS
iaPGRI
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
Q)PGOH
RGSUAS
RGSUBS
RGHAIN
RGSUBS
RGSUBS
RGSUBS
~PGDH

RGSUBS
~PGCO

RGHAIN
RGHAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
~PGDH

RGHAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
~PGDH

RGHAIN
RGSUBS
RGSUBS
RGSUBS
RGSUBS
RGSUBS
~PGOH

RGSUBS

TITLE
ROOT
OVERLAY FETCH ROUTINE
OVERLAY FETCH AREA
INPUT HA I NLI NE
TRANSFER VECTOR
RECORD IDENTIFICATION
CONTROL F I EtDS
INPUT CONTROL ROUTINE
CONSOLE - IDE DATA HANAGEHENT
INPUT HOOK
CONSOLE - IDE DATA HANAGEHENT
INPUT FIELDS
DETAIL CALCULATIONS
CONSTANTS
CONSTANTS
OUTPUT CONTROL ROUTINE
RESET RESULTI~G INDICATOR
EXCEPTION
OUTPUT HOOK
OUTPUT HOOK
FETCH OVERFLOW
OUTPUT HOOK
OUTPUT HOOK
DATA HANAGEHENT CALL
OVERFLOW SUBSEGHENT
SUBSEG
DETAIL OUTPUT
OUTPUT CONTROL ROUTINE
CONSTANTS
OUTPUT HOOK
DATA HANAGEHENT CALL
OUTPUT HOOK
PACK
TOTAL OUTPUT
LR & OVERFLOW PROCESSING
OUTPUT CONTROL ROUTINE
CONSTANTS
OVERFLOW SUBSEGHENT
OUTPUT HOOK
SUBSEG
DATA HANAGEHENT CALL
CLOSE HAINLINE
TRANSFER VECTOR
OUTPUT CONTROL ROUTINE
CONSTANTS
CONSTANTS
LR OUTPUT
OUTPUT HOOK
DATA HANAGEHENT CALL
OPEN HAINLINE
TRANSFER VECTOR
CONSTANTS
OUTPUT CONTROL ROUTINE
CONSTANTS
OUTPUT HOOK
DATA HANAGEHENT CALL
SUBSEG

Rprl.;a MAIN STORAGE REQUIRED TO EXECUTE.
RPF148 HAIN STORAGE REQUIRED TO EXECUTE WITHOUT OVERLAYS.
SOURCE MEMBER INPUT LIBRARY.
LOAD MEMBER OUTPUT LIBRARY.

Figure 16-5. Overlay Usage Map
Storage Saving Techniques

16-7

PERFORMANCE IMPROVEMENT TECHNIQUES

CODING TECHNIQUES FOR CALCULATION
OPERATIONS

Some relatively simple program changes can make
significant improvements in a program's performance.
However, these performance techniques do not improve
performance in all programs. Therefore, study these
techniques and determine whether they can improve
your program's performance. The performance
improvement techniques are:
• Unblock all randomly processed indexed files.
Blocking is not necessary because each record has its
own index entry with the direct address of the
record.
• Block all sequentially processed indexed files.
• Use the storage index. For a minimum cost in main
storage, this allows the system to read the single
track of indexes it needs rather than reading the
entire index to look for an entry.
• Reduce or eliminate blocking of consecutive files and
double the buffer instead. For example, instead of
using a block of 1,600 bytes with 80-byte records,
use a block of 800 bytes and a double buffer.

This section contains the number of bytes of object
code generated for RPG " operation codes. When used
with the preceding information in this chapter, this
information helps you determine the amount of storage
that you can save by using certain coding practices. For
example, one storage saving technique is to use numeric
fields of the same length and with the same number of
decimal positions. If the fields cannot be the same
length, try to have the number of decimal positions the
same.
For example, Figure 16-6 shows that if the decimal
positions of factor 1, factor 2, and the result field are all
different, an ADD operation generates 27 bytes.
However, if all the fields are defined as having the same
number of decimal positions, the same ADD operation
generates only 15 bytes. Uniformity of fields saves main
storage not only for ADD and SUB, but also for most of
the other arithmetic operations as well.

Calculation Specifications

C
I---

Indicators

~i

~

~

Line

I-

.s"0

§

g

~

8

6

7

3

4

0

1

C~

o

2

C~

o

3

o

4

C~
C~

5

0 5

C

o

0 7

C~
C~

o

8

C

o

9

C

1 0

C

1 1

C

6

Factor 1

Operation

15

Length

~

c

IA~~ ~~E 15 1F ~~ 20 It~ 231~1~1:~~i: 30 15 331~1~~ I;~I~I;O 41IPb~~~III~~~ 51;

Comments

Compare

o

ii:

0

Z

17

Plus IMinusl Zero

";;;

E

0

Z

1>21<211=2
Lookup(Factor 2)is
High

Low Equal

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 73 74
72

32

IFll~lj

fIL~!l

Programming Considerations

1211 Il:ljllllt:~

IRfllo.lD
~nn

l!NPtlT

Figure 16·6. Bytes of Code Generated for ADD Operation

'16·8

o

Factor 2
Name

Z

Indicators
Arithmetic

At At

0;

Resulting

Result Field

I~FLn

q~

1~~

BYTIE~

Abbreviations and symbols used in the following text
are:
F1
F2
RF
L1
L2
LR
01
02
OR
HI A
RAF

#:
>
<

+

Factor 1
Factor 2
Result field
Total length of factor 1
Total length of factor 2
Total length of result field
Number of decimal positions in factor 1
Number of decimal positions in factor 2
Number of decimal positions in result field
Half adjust
Record address file
Equal
Not equal
Minus
Greater than
Less than
Plus

Bytes

Operation

AOO
F1
F2

= RF
= RF

F1 #:

= 02 = OR
and 01 = 02 = OR
F2 #: RF and 01 = 02 = OR

6

and 01

6
15

F1 = RF and 02 > OR

14

F2 = RF and 01 > OR

14

F1

= RF

and 02 > OR

F2 = RF and 01 > OR
F1

= RF

F2

= RF and

01

= 02

HI A
HI A

18
18
18

and 02 < OR

18

01 < DR

< OR

23

F1 = RF and L2-02 > L1-01

27

F2 = RF and L1-01 > L2-02

27

F1
F2

= RFand
= RF and

L2-02 > L1-01 H/A

35

L1-01 > L2-02 H/A

35

All other combinations
All other combinations

27

HI A

35

Operation

Bytes

SETON (each indicator set on)

3

02 = OR

6

SETOF (each indicator set off)

3

02 > OR

14

BITON

4

02 > OR H/A

18

BITOF

4

02 < OR

18

TESTB

Z-AOO

COMP

Test bit off

10

F1 and F2 are numeric and 01

= 02

10

Test bit mixed

17

F1 and F2 are numeric and 01 #: 02

18

Test bit on

10

F1 and F2 are alphameric and L 1

Test bit off and mixed

23

F1 and F2 are alphameric and L1 ::f:. L2

22

Test bit off and on

23

F1 and F2 are alphameric and F1 is a table

26

Test bit mixed and on

23

10

Test bit off, mixed, and on

29

Alternate collating sequence (add these
bytes to the appropriate COMP listed
previously)

SUB
F1

= RF

and 01

= 02 = OR

F1 #: RF and 01 = 02 = OR
F1 #: RF and 02 = OR
F1 #: RF and 02

= OR

H/A

All other combinations
All other combinations

and L1

~

L2

6

= OR

TESTZ
RF is a field

9

23

RF is a table

20

27

39

MULT

23

with H/A

27

OIV
01 - 02

Z-SUB

= OR

14

01 - 02 #:- OR

02 #: OR

18

01 - 02

02 #: OR H/A

22

01 - 02 :;f OR

02

6

15

31

HI A

= L2

23
27

= DR +

HI A
+ 1 HI A
1

31
35

Coding Techniques for Calculation Operations

16-9

Operation

Bytes

Operation

Bytes

KEYnn (base = 27)

MVR
D2 = DR

5

When RF is a variable indexed array·

11

D2 #: DR

9

When RF is numeric, and a table element

6

with each resulting indicator

XFOOT
D2 = DR

9

D2 #: DR

13

When RF is alphameric, and
with resulting indicator and field

FORCE
with external indicator

13 + 7 = 20

Conditioning indicators (does not apply to CHAIN,
FORCE, LOKUP, and READ)

14
0

length> 1

23

length = 1

7

When Fl is numeric and with resulting
indicator and field

3

length> 1

8

each AN D type

3

length = 1

6

Resulting indicators (does not apply to
CHAIN, FORCE, LOKUP, and READ)

5

with each resulting indicator

3

each indicator

SETnn (base = 27)
With ERASE function

CHAI N (base = 16)

4

When F1 is numeric and with resulting
indicators and field

6

length> 1

8

When F1 has a variable index

11

length = 1

6

When key is not packed

14

SETnn/KEYnn combination (base = 27)

When key is packed

23

When key is packed and F1 is a table
element

6

See KEYnn operation for code in
addition to base. If F1 code appears
on both SET and KEY instructions,
both counts should be included.

When key is a record number

8

When key is a record number and F1 is a
table element

6

When record-not-found indicator is given

1

When record-not-found indicator not given

16

With external indicator

READ (base = 29)
With external indicator

6

With EOF indicator with BSCA

6

With EOF indicator without BSCA

12

With BSCA without EOF indicator

6

Without BSCA without EOF indicator

19

With RAF limits

6

LOKUP (base = 15)
When F1 is a table

6

When F1 is a variable

11

With each resulting indicator

12

SORTA
Inline calculation code

7

Subroutine

428

16-10

Programm ing Considerations

SETLL (base = 18)
When key is packed

12

EXSR

4

GOTO

4

TIME
Time only

21

Time and system date

21

ACQ
Inline calculation code

12

Subroutine

350

REL
Inline calculation code

12

Subroutine

402

NEXT
Inline calculation code

12

Subroutine

231

POST
Inline calculation code

8

Subroutine

437

Operation

Bytes

SHTDN

22

MOVEA
Inline calculation code

14

Subroutine

367

MOVE, MOVEL, MHHZO,
MHLZO, MLHZO, MLLZO

The number of bytes
specified includes all
array control code
lengths (see Figure 16-7).

Array control code (initialization and processing) is
generated for all calculations except LOKUP, CHAIN,
READ, and FORCE.
Array initialization
F1 or F2 is an array

6 bytes

F1 or F2 is a table

4 bytes

F1 or F2 is an array with variable
index

11 bytes

Array processing
F1, F2, RF are arrays

28 bytes

F1 and RF, F2 and RF arrays

22 bytes

RF arrays

16 bytes

If a SUB operation code is specified and has the
following conditions:
F1 = RF
D1 = D2 = DR
F1 and RF = full array
F2 = table
the length of object code generated is as follows:
Array initialization
F1 is an array

6 bytes

F2 is a table

4 bytes

RF is an array

6 bytes

SUB

6 bytes

Array processing
F1 and RF are arrays

22 bytes

Thus, the total bytes of code generated for a SUB
operation code is 44 bytes.
Whenever an array with a variable index is specified in a
program (except with a MOVEA operation), the following
are also generated:
Inline code
Subroutine

11 bytes
173 bytes

Coding Techniques for Calculation Operations

16-11

Field to Field

6

26

10

6

6

6

20

20

20

20

Array to Array

42

55

45

42

42

42

42

42

42

42

Field to Array

29

43

32

29

29

29

29

29

29

29

Table to Array

35

53

38

35

40

35

35

41

40

35

Array, Variable
Index to Array

40

66

43

40

52

40

40

5?

52

40

28

57

38

28

35

35

35

35

47

42

Field to Array,
Variable Index

17

34

27

17

17

24

24

31

24

31

Table to Array,
Variable Index

20

52

33

20

24

30

30

24

36

20

Array, Variable
Index to TablE'

20

46

27

20

30

24

24

24

36

20

Field to Table

9

23

16

9

9

13

13

9

13

9

Table to Table

15

41

22

15

19

19

19

19

25

15

Array, Variable
Index to Field

17

40

21

17

24

17

31

24

36

31

Table to Field

9

29

13

9

13

9

9

13

13

9

Array, Variable
Index to Array,
Variable Index

Figure 16-7. Bytes of Code Generated for MOVE Operations

16-12

Programming Considerations

Chapter 17. Detailed RPG II Program Logic

For each record that is processed, the RPG II object
program goes through the same general cycle of
operations. Within each program cycle, calculation and
output operations can be performed at two different
times: total time and detail time. First, total calculation
and total output operations (those conditioned by control
level indicators) are performed. Second, all detail
calculation and detail output operations are performed.
(Detail calculation and output operations are those not
conditioned by control level indicators in columns 7 and
8 of the calculation specifications or a T in column 15 of
the output specifications.) Total calculation and total
output operations are performed on data accumulated
for a control group. Detail calculation and detail output
operations are performed for individual records as they
are read, provided conditioning indicators are satisfied.
See RPG 1/ Program Cycle in Chapter 1, Introduction, for
a general description of the logic flow.
The specific steps taken in one program cycle are
shown in Figure 17-1. The item numbers in the
following description refer to the numbers in the figure.
The program cycle, which occurs for each record read,
begins with step 3 and continues through step 26.
1.

The system reads in the external indicators and
the display station local data area, if specified, and
opens all data files to be used by the RPG II object
program; that is, the files are prepared to be
processed by the object program. Data structures
are blanked, and preexecution-time tables and
arrays are loaded before the first program cycle.

2.

The object program performs all output
conditioned by the 1 P (first page) indicator. This
output is performed only once per job and does
not fall within the program cycle (steps 3 through
26).

3.

The object program performs all specified heading
and detail output operations whose conditions are
satisfied. This includes specifications that are
conditioned by the overflow indicator if the
overflow routine has been fetched.

4.

The object program tests to determine whether the
overflow line was encountered during detail
calculations in the previous cycle or when heading
and detail records were written in the current
cycle. If so, the overflow indicator is set on.
Otherwise, the indicator is set off unless the
overflow routine was fetched in step 3.

5.

The object program tests the halt indicators. If the
halt indicators are off, the program branches to
step 6.
a. The execution of the program is stopped once
for each halt indicator that is on. The operator
selects one of three options: continue,
controlled cancel, or immediate cancel.
b. If the operator selects the option to continue
the job, the program returns to step 5 to test
for other halt indicators. If the operator selects
one of the cancel options, the program
branches to step 35.

6.

All record identifying indicators and indicators 1 P,
L1 through L9, and H 1 through H9 are set off.

7.

The program tests to determine whether the LR
indicator is on. If it is, the program branches to
step 27.

8.

The program tests to determine whether the
KEYBORD is the primary file or if no primary file is
specified. For either condition, the program
branches to step 18.

9.

The program reads (and translates, if necessary)
the next input record. At the beginning of
processing, one record from each input file (except
forced files and demand files) is read. If the file
has look-ahead fields, the file is read only on the
first cycle. After that, records with look-ahead
fields are identified only. If this is a WORKSTN
file and the SAVDS and/or IND option is
specified, the common SAVDS and/or INO area is
moved to the active display station's SAVOS
and/or INO hold area. The next record is
accepted, and the current display station's SAVDS
and/or INO area is moved from its hold area to
the common SAVOS and/or INO area.

.. 0

10.

The program tests to determine whether the
record is an end-of-file record. If an end-of-file
condition has occurred, the program branches to
step 12.

11.

If end of file has not occurred, a test determines
whether the input records are in the sequence
specified on the input specifications sheet. If the
sequence is incorrect, the program branches to
step 33. The program also branches to step 33 if
nonsequential input records are specified and the
record cannot be identified.

Detailed RPG II Program Logic 17-1

12.

If end-of-job conditions have been met, the
program branches to step 27. All files for which
an E is specified in column 17 of the file
description specifications must be at end of file.

13.

When multiple input files are used, the program
must select the next record to process, so it
branches to step 28.

14.

If there is only one input file, no record selection is
needed. A test determines whether sequence
checking is requested. If so, the program branches
to step 31.

15.

16.

The record identifying indicator specified for the
current record type is set on. Data from the
current record type is not available for processing
until step 25.
If the record contains control fields, the object
program tests to determine whether a control
break has occurred (the contents of the control
field are not equal to the contents of the
previously stored control field). If a control break
has not occurred or control fields are not
specified, the program branches to step 18.

17.

If a control break has occurred, the control level
indicator reflecting the condition is set on. All
lower level indicators also are set on.

18.

A test is made to determine whether the total time
calculations and total time output should be
performed. If no control levels are specified on the
input specifications, the totals are bypassed only
on the first cycle. If control levels are specified on
the input specifications, totals are bypassed until
after the first record containing control fields is
processed. Totals are always processed when the
LR indicator is on.

19.

All calculations conditioned by control level
indicators (columns 7 and 8 of calculation
specifications) are performed, and resulting
indicators are set on or off as specified. If the LR
indicator is on, calculations conditioned by LR are
done after other total calculations. File translation,
if specified, is done for exception output and
CHAIN and READ operations. Fetch overflow is
performed if it is required by exception output. If
the overflow line has been reached because of the
exception output, the overflow indicator is set on.

17-2 Detailed RPG II Program Logic

20.

All total output that is not conditioned by an
overflow indicator is performed. The program
tests to determine whether an overflow condition
has occurred. If an overflow condition has
occurred at any time during this cycle, the
overflow indicator is set on. If the LR indicator is
on, output conditioned by LR is done after other
total output. File translation, if specified, is done.
for total output. Fetch overflow is performed if
required.

21.

The program tests to determine whether the LR
indicator is on. If the indicator is on, the program
branches to step 38.

22.

The program tests to determine whether any
overflow indicators are on. If no overflow
indicators are on, the program branches to step
24.

23.

All output operations conditioned by a positive
overflow indicator (no N preceding the indicator)
are performed. File translation, if specified, is
done for overflow output.

24.

The M R indicator is set on if this is a multifile job
and the record to be processed is a matching
record. Otherwise, the MR indicator is set off.

25.

Field indicators are set on or off as specified.
Data from the last record read and from specified
look-ahead fields is made available for processing.
Command key indicators (KA through KN, KP
through KY), for a WORKSTN file only, are set off,
and if a command key is pressed for the
WORKSTN .file being processed, that command
key indicator is set on.

26.

Any calculations not conditioned by control level
indicators (columns 7 and 8 of the calculation
specifications) are performed, and resulting
indicators are set on or off as specified. File
translation, if specified, is done for exception
output and CHAI N and READ operations. Fetch
overflow is performed if it is required by exception
output. If the overflow line is reached because of
the exception output, the overflow indicator is set
on. Processing continues with step 3.

27.

The LR indicator and all control level indicators (L 1
through L9) are set on and processing continues
with step 19.

28.

If a file was forced or if NEXT was specified, the
next record in that file is selected for processing
and the program branches to step 15.

29.

If a record with no match fields is found in a
normal input file that is not at end of file, the
record is selected for processing.

30.

When match fields are specified, the normal file
with the highest priority matching record field is
selected. If two or more files have equal and
highest priority matching record fields, the highest
priority file is selected. (The primary file has the
highest file priority, the first specified secondary
file is next, and so forth.)

31.

The match field value is compared to the match
field value of the last record. If it is in sequence,
the record is accepted, and processing continues
with step 15.

32.

The execution of the program stops because a file
with match fields is out of sequence. The
operator's options, indicated in step 34, are to
bypass (read the next record from the same file) or
cancel the job.

33.

The execution of the program stops because of a
record type sequence error or an unidentified
record.

34.

The program tests the operator's decision either to
bypass the record that caused the error condition
(branch to step 4) or to cancel the job.

35.

If the operator elects to terminate the job by
means of a controlled cancel, steps 36 through 40
are performed. If the operator selects an
immediate cancel, the job is terminated.

36 and 37.
All operations conditioned by the LR
indicator are done.
38.

The program writes any tables or arrays for which
a filename entry is specified on the extension
specifications (columns 19 through 26). Output
tables or arrays are translated, if necessary.

39.

All files used by the program are closed (final
termination functions are done). The external
indicators and display station local data area, if
specified, are written out.

40.

End of job occurs.

Detailed RPG II Program Logic 17-3

."

-.J

1.
C

...
CD

~.

en
c..

ce'
c
;

-a

'-a
:-I
::;
III

:0
"C
G)

0

-ft

=

~

Ql

3

2!,
iii"

r-

:D

"C

a
co
0

co
0'

•

Get external indicators and display
station local data area, if specified

•

Open all files

•

Load preexecution·time tables and
arrays

::l

...C
(I)

a.
"'tI

C')

0

C"

CD'

27

...n

"'tI

a

4~

cc

__________~__________- - ,

9

Set on LR, L1·L9

Set off overflow indicators if per·
formed last cycle, leave on if fetched
during detail cair:ulations of previous
cycle or during detail output of
current cycle

iil
3

n

 BY THE.. H:'-'<" "NU Auru ...H~OC.a IN "'~""'(.Llu.
- HALT ON H:.J·H4(NAL t..:R~O~S OUH1NG CrJhtPILE.
- DUN'r HALl ON ff:R""INAL fo.lRO~'i.
- CALL SCHEtN FOiV4Ar '~ENFRATO'" FOH CO""'SOL~. FILE
I - DONer CALL FOR"'IAT GENEflArOi-l.
2 - GENERATE CUNSOLE FORJ04AT::; FrJl-l '160 CHAR SCi-H E::",I.
I - rEQMINAL £RkORS IN P~OGRAlo4 --> SCT tlY .RPKA.
I REPLACE DUPLICATE: Io4E""]('l-lS W( THOUr A ~E.SSAc..C
- Nor USEO
ME"'OER NAME OF SOURCE PRi.JC.RAlo4.
INPUT LIAi-lA~Y NAME.
SUA"'IT Jon TO OAfCH Jon (lUEU(.
RUN JOB FHO'" wORKSTATION.
CALL C~IJSS wEFERf,NCE PHOGRAtrot.
DON'T RUN CROSS REFERENCF.
F~ AUfJ HEPORT,
rlUN AUTI') nl'.,lLY

IJ'S

-

22..]
I

224

-

o o

225-229
230-231

¢:

C

JQ

REPORT,

H£SERVf.D t=Oft

RUN

AlifO

-SPECIAL

HPG

ANO

OPTIONS-.

JOB SUlJ" I T rEU ro Jot! -256

:c ¢c-;: co: -;;.~¢o::o:::: 0.0 -0'00:0: :0:00: ¢
//

AUf 0

FOR

-

ME"OER

-

¢¢¢ 0.0: ¢-;:¢¢¢¢¢¢-oc: ¢ ¢¢

¢.c c¢:o:c¢:¢; ¢¢¢¢t:. ¢¢¢¢¢¢:c;.¢¢¢"¢.¢¢ ¢¢¢¢.::r:

USEQI-IRPICPLI

¢

IF

C

IIITH DEFAULrs

PRtJGRAII4

NAME

~AS

OR

NOf

SPECIFIED

PREVIOUSLY

DISPLAY

A

SPECIFIEO USER

M(NU

PARAMETER CHOICES

OF

VALUES.

c
/ / TAG PHOMf:tT
/ / IFF 1'11'/
GOTO NA~EP
/ / PROMPT FURMAT-RPC.,
SCREEN
/ / IF OSJ..'LY-IGC MEMBEH-MRP"HELP
/ / ELSE ME"lJER-IRPolHELP
/ / rAG NA"EP
/ / IFF 1'11'/
Goro NAMPRES
// ¢
1016
/ / Goro PROMPr
TAG NAJ04PRES

l"'IfIALllE OYfES 201-2Sb

/ / LOCAL
/ / LOCAL

:c
//

IF

//

IF

//
//

IF
IF
IF
IF

//

LUCAL

OFFSc.T-201.0ATA-'OOOOO
OFFSET-229.0ATA-'

pus I

PUT

OF

~UR"Ar

TI ONAL PARME TERS

IN

THE

LOCAL

LOCAL

=::

flVf!:.S
AYTES

""40HA.L T • TEI--iMI NAL EHqORSI
NOSTUP (fERMINAL £i-ource
program. If the library name is not specified, the
system library, #LlBRARY, is assumed.
Note: No diagnostic checking is provided with the RPGX
procedure. Therefore, you should use this command
only for RPG II source programs that have been
successfully compiled and for which object programs
have been produced. Unpredictable or confusing results
may occur if auto report source statements or RPG II
source statements containing terminal errors are used as
input to the RPGX procedure.
The RPGX procedure exists in RPG's library #RPGLlB
and is called by the RPGX procedure that exists in the
system library. Figure 18-2 shows the OCl statements
included in the library procedure named RPGX.
Note: The RPGX procedure is not valid for auto report
source. Auto report must be executed, producing RPG
specifications, before the RPGX procedure can be
executed.

18-4

Compiling and Executing RPG II Programs

RPGR Command Statement

If the NOGEN parameter is specified for the RPG
procedure and the program contains a CONSOLE
,device, you can use the RPGR procedure to execute the
RPG II format generator. The RPG II format generator
produces and saves source input for the $SFGR utility
program of the system support program product. The
$SFGR utility program then produces the display screen
formats for a CONSOLE file. The command statement
for the RPGR procedure is:
source and format file siz~
RPGR program name, [ 20

J'

NOSAVE] [source program library namel
[ SAVE
'#LlBRARY

J'

load module library namel
rGEN9601
[ #LlBRARY
'LGEN

J

~EPLACEl

J' [

J

where:
program name is the name of the RPG II source
program. This parameter is required. If it is not
specified, a prompt requests the name of the
source program.
source and format file size is the number of
blocks (each block is 2,560 bytes) for the
source file and SFGR file. If the file size is not
specified, the default is 20.
NOSAVE specifies that the source statements
for the $SFGR utility are not to be saved. If
NOSAVE is not specified, the source
statements are saved in the library specified as
the source library and are assigned the program
name plus FM.
source program library name specifies the name
of the library that contains the RPG II source
program. If it is not specified, the system
library, #LlBRARY, is assumed.

load module library name specifies the name of
the library that will contain the load module
created by the $SFGR utility program. If it is
not specified, the system library, #LlBRARY, is
assumed.
G EN960 specifies that the screen formats
generated for the CONSOLE file will be for a
12-line, 960-character screen. If GEN960 is
not specified, the screen format defaults to a
24-line, 1920-character screen.
REPLACE specifies that the system replaces an
existing library member with the newly compiled
object that has the same name. The replace is
done automatically; no message is issued.
Note: The RPGR procedure reserves bytes 201 through
256 of the display station local data area for its use.
Therefore, any user data in these bytes will be
destroyed.

The RPGR procedure exists in RPG's library #RPGLlB
and is called by the RPGR procedure that exists in the
system library. Figure 18-3 shows the OCl statements
included in the library procedure named RPGR.

Compiling the RPG II Source Program

18-5

THIS PROCEDURE

SHOULD

EXIST

ONLY

IN

.RPGLI6

AS

'RPGX'

RPGX PGNAME, SSOURCE. I NL 10
THIS PRLlCEDURE

THE POSI
1ST 2ND 3RO ~~

:::

"EMBER

IF

r

EXECUTES

THE RPG

CROSS

REFERENCE

PRDGRA"

IONAL PARAMETERS AS INPUT ARE THE FOLLDWINGPROGRAM NAME, ,REQUIRED),
II BLOCKS FOR SSOURCE FiLE, DEFAULT- 20.
INPUT LIORARY. DEFAULT- MLIBHARY,

USERI-.RP,CPLI

PROGRAM

NAME

wAS

Nor

SPECIFIEO.

IT

WILL BE PJ.lOMPTED FOR.

/ / LIBRARY NA"E-'RPGLIB
/ / TAG PRO"PT

/ ' IFF ?I?/
GOTO NAMEP
/ / PROMPT FiJRfr.4AT-RPGX.
//

IF

DSPLY-IGC

MEMBER-'RPSHELP

/ / ELSE MEMRER-.RPilHELP
/ / TAG NAMEP
/ / IFF ! J ! /
GOTO
/~
/~

//
//

¢
1016
GOTO PRO",PT
TAG NAMPRES
IF J(JBQ-NO IF

EVOKED-NO"

102S

~~ LIBRARY NA"E-O
/ / LOAD SFBLD
/ / RUN

/ / FILE LABEL-SYM8FLE.ATTRI B-1.RECL-24.BLOCI(S-?,l'20· ?,LOCAT10N-Al,
/ / RErAIN-J.POSITiON-l.LENGTH-14
/ / END
IF

PROGRAM

//

iF

?1?/11111111

NAME

/~

LOAD

IS

11111111

GUrD

THE

SOURCE

IS

IN

'WQ"K2

SKIP

SMAINT

/ / FILE NAME-SWORK2.UNIT-Fl,8LOCKS-?Z'20'?RlTAIN-J
/ / RUN
/ / COpy FR0ill4-?3' 6L IBf.l:ARY·? TO-DISK.LIBRARY-S,FILE-S.ORK2.FolECL-Q6.
/ / N"'~E-?l?
/~

END
TAG 51<. I P
LIBRA'lY NAMF.-'RPGLIB
/~ LOAD .FlPRF 1
/ / FILE NAME-SSDURCE.L ABEL-SWORK2
/ / FILE NAME-SYMBFLE
/ / RUN

//
/~

/ / LIBRARY
/ / LOAD
/ / FILE

"'AM£-O

.GSlJIH

NAME-INPur.LA:3t:::L-SY"'8FLE.BLOCKS-?2?QETAIN-J
/ / FILE NA\Io4E.-DUTPUT.LABEL-SYMAFLE.ALOCKS-?2?RErAIN-J

/ / RUN
HSOqrR
FNC
F"C
FOC
FDC
ENO

1
15

II

141.
10
IB
14
24

1~
//
/ / LIBRARY NAMI:.-MRPCLlfi
/ / LOAD .RP4F 2
/ / F ILE .o",jAMt:-SYMHFLE,~ETI\IN-S
//

24

TYPE
STMT

OF

REFECI

SYMB.)L

S't"M(30L
NUhl BE I-?
R~FEI>ENCE

OF SYMOOL
I NF()Rlo4AT t ON

RUN

Figure 18·2. IBM·Supplied Library Procedure (RPGX) for Producing a Cross· Reference Listing

18·6

Compiling and Executing RPG II Programs

THIS PROCEDURE

SHOULD EXIST ONLY

PGNAME ,SOURCE.

'N05~VE.·.

IN

.RPGL 1f1 AS "PGR

INL I n .DUlL Ill. CoE N'1bO

THIS PROCEDURE EXECUTES THE CUNSOLE SCREE N FORMAT GENERATOR
TO PRODUCE SFGR SOURCE STATEMENTS DtoSCRI,HNC; TtiE SCREEN FORM .. T
FOR THE CONSOLE FILE.
"IE POSITION"L PAR .... ETERS .. S INPUT
1ST - PROGRAM NAME. IH:EOUIREDI.
J~O

OON'r SAVE SFGR SOURCE. OEFAULT- SAVl.
INPUT L1UR ... RY. OEFAULT- 'LIURARY.
OUTPUT LIIJRARY. DEFAULT- MLlfJRAHY.
SCREEN FORM"'T SIZE. DEF"'ULT- GEN -->1920
... UTOMATlC ... LLY REPLACE OUPLICATto ME"OER». OEFAULT-

..

-

SOURCE FILE.

/ / "EMIlER USERI-'RP'CPLI
/ / IF JOIlO-NO
IF EVOKED-NO"

..

LOC .. L OFFSET-243.DAT ... -·OOOOOO
IFF !1?I'
GOTO NA,",PRES
T ... G PROMPT
PROMPT FORM",T-RPGII.
IF DSPLY-IGC "E"UER-'RPSHELP
ELSE "("IlER-'RP.HELP

//
"
//
//
//
//
/1
//
//

.. 1016
GOTO PIIQMPT

"

TAG

?l?/

Ut:FAULT-

20.

NO

1020

INITI"'LIZE UYTES 202-205 AND

IFF

THE FOLLOW INC;-

•

4"1
5TH
bTH
7TH

ULOCKS FOR

ARE

2NU -

243-256 OF LOCAL

wAS

AHEA •

SOURCE NAME

SPECIFIED

SCREEN FOR ...... T

Goro NAHPRES

NAMPRES

/ / IF !6?/c.EN960 LOCAL OFFSET-202.DATA-·2'
TeLL GENERATOR 960 SCREEN
/ / ELSE LOCAL OFFSET-202.DAT .. - · 0 ·
TELL GENERATOR 1920 SCREEN SIZE
..

IF PROGR ... "

N"'''E

/ / IF ?1!/1l11l1l1
/ / LOAD S""'INT

IS

11111111

THEN

THE

SOURCE

IS

IN

Silt':

SWOQK2

GO TO SKIP

' / FILE NAME-SWORK2.RE TAl N-J .UN 1 T-F I. BLOCKS-? 2' 20'?
/ / RUN
//

COPY F UOM-?4' "L I OHARY·?

10-0 I SK. L I BRARV-S. F I LE-"'VIIORK2. REeL -96, NAME -? I?

/ / END
/ / T ... G SKIP
/ / LO"U 'RPC;EN
/ / FILE NAr-E-SOURCE,RETA I N-J,UNI J-F I.LAOEL-SWORK2
.I/ FILE NAME-WORK, RET A I N-.J. UN I T-F 1. LAOEL- 5WORK2. OLOCK S-?2' 20'?
; / FILE NAfoE-SFGR.RETA IN-J.UNI T-Fl. BLOCK'S-?Z' 20'1

/ / RUN
/ / IF ?L'246,1'?.11
'RPG-I021'
/ / IF ?L' 246", ?/.
#
1021
/ / IF ?L'245,1' ?/1
'RPG-1022'
/ / IF ?L'245,.'?.I1
1022
/ / IF ?L'244,1'?.11
Co 'RPG-I023'
IF ?L' 244, 1 '?.1 I
1023
/ / IF ?L' 243, I ' ? / I
'RPG-1024'
/ / IF ?L'24.J,'·!.I1
# 1024
IFF !L'243.4'?.I0000
PAUSE
.II' IFF ?L'244,3'!.I000
RETURN
/ / LOAD S""'INT
/ / FILE NAME-5FGII.RETAIN-J.UNIT-F 1
/ / RUN
/ ' IF !7?,REPLACE COpy FROM-OISK,TO-?4'''LIB'''ARY'!,FILE-SF('R,REfAIN-R
I"
ELSE COPY FROM-DISK,TO-?4·.LfURARY'?FILE-SFGR
/ / ENO
/ / LOAD SSF"R
/ / RUN

..

//

IF

/.1

I NL I 6-14' _LI BRARY' ?, ~UlL I 8-?S' ML 1 AH:ARY'? ,PR I NT-Yf S
CREATE SOURCE-?L'249,S'?,NUMt::IER-?L'2"7.2'?
END
IFF ?3?/NOSAVE RETUHN
LOAD SMAINr
RUN
DELETE NAME-?L'249,6'?,LIBRARY-So.LlflRNAME-?4?

//

//
//
.II'

//
.I,
//

?7?.IREPLACE

LOAOMBR

NAME-?L'249,e'?,REJ-ILACE-Yl:.S

I Nour

~ND

Figure 18-3. IBM·Supplied Library Procedure (RPGR) for Executing the RPG II Format Generator

Compiling the RPG II Source Program

18-7

COMPILING THE AUTO REPORT SOURCE
PROGRAM

AUTO Command Statement

To compile an RPG II source program that includes auto
report specifications, the auto report program must be
loaded into main storage. To load the auto report
program, the operator enters the following command
statement that executes an IBM-supplied library
procedure named AUTO:
source file size,
'
AUTO program name, [ 20

J

work fi!e size,
[ 20

J '

NOSTOP~
REPLACE

~

NOHALT
HALT

source program library namel
[ #LlBRARY

J

If the source program name is not specified and no
other parameters are specified, the system displays a
menu requesting the name of the source program and
listing the default values for all the parameters. The
default values can be overridden at this time. If the
source program name is not specified but other
parameters are specified, the system displays a menu
requesting the name of the source program and listing
the user-specified parameter values and the defaults for
all unspecified parameters. These values can be
overridden at this time. If the AUTO procedure is placed
on the input job queue, the program name must be
specified. See the description of the special options
parameter for the RPG procedure for an explanation of
how to direct the AUTO procedure to place the job on
the input job queue after you enter values into the
menu.
If the default block size of 20 is not going to be used in
the command statement, determine the blocks required
as follows:
Number of specifications
Blocks

25
[Qmrtmax ValUe] ,
object program library name]
[ #LlBRARY
,

where:
the positional parameters are the same as for
the RPG procedure. The last positional
parameter, special options, has an additional
option for auto report. If the third special
options position contains a zero (the default),
the RPG compiler is called after the auto report
specifications are generated. If the third special
options postion contains a one, the RPG
compiler is not called after the auto report
specifications are generated. The AUTO
procedure exists in RPG's library #RPGLlB and
is called by the AUTO procedure that exists in
the system library.

For the number of specifications, use the greater of: the
number of specifications read by auto report or the
estimated number of specifications in the generated
source program. The calculated number of blocks
should be used for both $SOURCE and $WORK. If the
compiler is assigned a region size greater than or equal
to 48K, a minimum of 30 blocks must be specified for
the $WORK file for any size program.
The AUTO procedure builds a source file for processing
by RPG and RPGR, and provides a cross-reference
listing, if requested. This intermediate source is saved if
you specify in the option specifications that the
intermediate source is to be cataloged. If the RPGR or
RPGX procedures were requested from the AUTO
procedure and you did not specify that the intermediate
source is to be cataloged, the intermediate source is
saved in a work file named $WORK2. $WORK2 is a job
file and is deleted at the end of the AUTO procedure
execution.
Note: If the catalog option is not specified in the option
specifications, the library name printed by the compiler
is where the auto report source originated. Otherwise,
the library name printed is the library name specified in
the catalog option.

'18-8

Compiling and Executing RPG II Programs

Figure 18-4 shows the Oel statements included in the
library procedure named AUTO.
Note: The AUTO procedure reserves bytes 201 through
256 of the display station local data area for its use.
Therefore, any user data in these bytes will be
destroyed.

..

THIS PROCEDURE

..

SHOULD EXIST

ONLY

IN

MHPGL10

5726-RGI COPYIHGHT 10M CORP I'H7
LICENSED MATERIAL - PROPERTY OF IIlM
REFER TO 10M COPYRIGHT '-NSTRUCTlDNS FORM

AS

'AUTO'

NO.

G120-2083

AUTO PGNAME. SSOURCE. SWORK.NUHAL T.INL I B.DurL 10. MRTJotAX.NEP.NOc.t:.N .SPCLOPT
..
..

THIS PROCEDURE EXECUTES THE AUTO REPORT FUNCTION AND CONDITIONALLY
EXECUTES THE CONSOLE SCREEN FORMAT GENERATOR FROM THE RPG LlOi38
0021

0041::: 0047
0028 0029

LEGEND **
D::

F~J

0003
OC04

REFERENCES
C023* 0023 0024
,)024::: OC26'::

0027* 0027

C027

......... FP:Lc) ANO CATA STRUCTURE U:GEND .:;::::

SY"1o'JL

LNG

r:lEC

D::PI

C E~H5
COS T
r:l ES C

oe02
OG07
0:;18
OC05
:;:[,5 :::
OGOl
::J08e
00,:)5
O::lC

C
2

0815
0018
0:)19
(:014
C':'12

DOLLAR

INVDTA
IX
NA"1E
PARHJO
STJCK

C
C

8822
CC'16

C

0813
C,)17

REF[RENCES

COC7
0008

OC39':: 0039
OC33:::

OGI0
OC23

0046
C023

';0')6

OC21

OO't 8
0024

0024

......... LACJt:L L Er,E~JC ....,.

SY"I.'Y1L

TYPE

AD1RCD

!'l.cGSR

~r:)

TA~

l)P~R(D

n,E";Sq,

JC

F~~

C'J 31

co 30
C~37

Rt:HRfNCES
0028
CC'?O
CC?9

Figure 18-5. Symbol Information Provided by the Cross-Reference Listing

18-12

Compiling the Auto Report Source Program

0025::: ':)025

1)026

0027

Chapter 19.' Sample·Programs

The sample programs contained in this chapter are
designed to illustrate some of the functions of RPG II.
A!though they are relatively simple programs, they are
complete jobs that can be run on any System/34. For
additional sample programs that use the WORKSTN file,
see Chapter 13.

SAMPLE PROGRAM 1 (SAMPL1)
SAM PL 1 loads an indexed disk file that consists of 100
data records created by calculation operations. (Each
record contains two fields: COUNT and RECNBR.) The
program only requires the operator to enter a blank data
record at the beginning of the job and press command
key 12, that is, the Cmd and = (equal) keys, to end the
job when the first prompt appears for the field EOF.
SAMPL 1 should be followed by SAMPL2, which prints
the indexed file loaded in SAMPL 1 to verify that the file
was loaded properly. Figure 19-1 shows the
specification sheets required for SAMPL 1.

Control Specifications
Control specifications (see Figure 19-1, Part 1) should
be present for every program. They are the first record
in the source program and identify the program.

File Description Specifications
All files used in SAM PL 1 are first described on the file
description specifications sheet (see Figure 19-1, Part
1). The primary input file, INPUT, is assigned to the
device CONSOLE. The E in column 17 ensures that the
program does not end until after the last record is read
from INPUT. At the end of the job, the indexed output
file, DISKOUT, consists of 128-position records with a
6-position key field starting in the first record position.
Messages indicating that the job was completed
successfully are written to the printer output file,
OUTPUT, at the end of job.

Input Specifications
The input file, INPUT, is further described on the input
specifications sheet (see Figure 19-1, Part 1). The input
record contains a 1-position blank field called NODATA
(blank in position 1) describing the record identification
code. The field NODATA is not prompted. A 1-position
field called EOF will be prompted and is described for
position 2 of the input. record. When the prompt for
EOF is made and command key 12 (the Cmd and =
keys) is pressed (end of file for CONSOLE file), the LR
indicator turns on.

Calculation Specifications
All calculations (see Figure 19-1, Part 2) are conditioned
by the LR indicator; therefore, they are executed at LR
calculation time (see Chapter 17, Detailed RPG 1/
Program Logic). The record number field (RECNBR)
keeps track of the number of records written to
DISKOUT. The COUNT field accumulates in increments
of five to provide a unique key field for each record
written to DISKOUT. The EXCPT operation code and
exception output (E in column 15 of the output
specifications) are used to write the records to disk.
These calculations are part of the REPEAT loop and are
executed 100 times, until COUNT equals 505 and 100
disk records have been created. At the end of the loop,
one is subtracted from RECNBR to indicate the actual
number of records that have been loaded.

Output Specifications
The output specifications (see Figure 19-1, Part 2)
conditioned by LR cause a message to be written to the
OUTPUT file, providing the following information:
• Job completion
• Number of records loaded
• File and key field descriptions
9

Brief description of the function of- program SAM PL2

Sample Program1 (SAMPL 1)

19-1

RPG CONTROL AND FILE DESCRIPTION SPECIFICATIONS

IBM

GX21·9092· UM/050'
Printed in U.S.A.

International Business Machines Corporation

1 2

75 76 77 78 79 80

~~~~;~f:ation Is~I"'lp ILlll

page~of _
Control Specifications

1~

H

-

~

Line

~

Size to
Compile

]
3

4

5

6

0\ 1 \

~ .~a.~

~

Size to
Execute

...

~~

';;

§

H

8

9

10 "

Of Print (5
~ ~ ~ Positions ~

Address
to Start

Refer to the specific System Reference
Library manual for actual entries.

o

II

~

12 13 14 15 16 17 18 19 20 21 22

10111~

\ \

Number

.£;;

iij~

!~
7

_____Mrod~erI2T°-r'-~

Zu.

'232425 26 27 28 29 30 31323334' 35 3637383940 41 4243444546 47484950 51 525

I

II

54 5556575859

60 61 62636465 6667686970 71 7273 74

J J II I 111II 11 1JII III II

1 11
File Description Specifications

File Type

F

File Addition/Unordered

Mode of Processi ng

length of Key Field or

File Designation

!---

~

of Record Address Field

End of File

Record Address Type

Sequence

Filename

Type of File

!

§I

j

0: w ~

Record

u::

*~+

o 6

F

HI

i

1

0 7

F

i

!

1

1

o 8

F
F

1 0

F

,

i

I

:

I

I

i

1

1

IL OL 6989 L9 99 59 P9 C9 19 19 0965 85 L5 95 55 P5

lL

K

47 48 49 50 51 52 53 54 55 56 57 58 59

PR! NTER

i

I

I
I
C5

I

1

1

I

I

I

I

I

!

15 05 6P 8P LP 9P 5P PP CP lP IP OP 6C 8C LC 9C SC PC CC lC IC OC 6l 8l Ll 9l Sl Pi Cl II Ii Ol 61 81 LI 91 51 PI CI II "01

l5

6 8

INPUT SPECI FICATIONS

L

9 S

P

C l

I

GX21·9094· U/M050'
Printed in U.S.A.

2

liml

75 76 77 78 79 80

~~~~;~f:.tion Is IA 1M (1'-1 ~

of _

Record Identification Codes

0

Field

Field Location

~

Line

!

Filename

;:

Jl

~
5 6

'OR7 8

II

0

2

I

0

3

I

0

4

I"
I

~=:
~6

.3

~

Z

0

~ .~

3

2

1

~~
~

-

"C

.

j

Position

~

e
o~

Z

U

Posit'lon

~

~

U

~

ge

~

Z

U

b

Position

~ ~
U

r;ND"

9 to 1t 1213 1415

N'P UiT
~H

1617

~s

1 t

,EIN PR OM PIT E:lJ FOR FI ELl>

Sample Programs

From

~

0

Z

U

b ~

To

~

43 44 45 46 47

EOIF I

2

Indicators
0
0

12-0
.~ C)

]

LL.LL

g

-5

8

.~ ~

~
"C

j

:~

"C

::;;u

u::

~~

Zero

Plus Minus or
Blank

0;

48 49 50 5t 52 53 54 55 56 57 58 5960 6t 62 6364 6566 67 68 6970 71 72 73 74

1

~

Field Name

~

Jii

18 19 20 21 22 23 24 2526 27 28 29 30 3t 3233 34 35 36 37 38 39 40 4142

1(01

~

0

."t:.

0

Figure 19·1 (Part 1 of 2). Sample Program 1 (SAMPL 1)

19-2

70 71 72 7374

I

1

I

0 5

~

60 61 62 63 64 65 66 67 68 69

International BUSIness Machines Corporation

I--

1

~

:J

Page

0

Ul.~
Z

Entry

Option

AMPLe

3 4

~

CON so LS

I

RPG

IBM

W

1 0:1&11(

I

-

~

Location

1

!

iii

F

Rewind

i

1

F

f-----

I

i

Tape
Storage Index

Condition

I

i

I

Starting

~I~ ~II

!

F

o 9

II

~ ~

!

o 5

Number of Extents

Continuation Lines

24 25 26 272B 29 30 3132 3334 3536373B 3') 40 41 424344 45 46

10 11 12 13 14 1516 17 18 19 20 21 22 23

FDIS

0 4

e

~

~

FIN'P

1

~

length

Urr! ; i IIPiE 1-1 i2
~o'ut- 0
f ll!S!, iI12
,..,
11!
FO~tt
~f-:f---- _E r-1'!113:2
,

o 21
o 3

~
o >

cI\

4 5 6 7 B 9

J

Block
Length

Number of Tracks
for Cyli ncler Overflow

Name of
Label Exit

0

~OVerfl~~
t:
Key Field ~

0

~

~

~

~

0

Vi

w

Nor Additional Area

Line

Z

Symbolic
Device.

Device

...J

OrganizD

Re ell Sl~

co VAl

CONiP

11

IE ¢5

.pIZ

ex CPT
GO r;o IRE PIE' ~7

2E C"" BR

SAMPLE PRO(3R.AM #: j. I

SUB

1

RPG

OUTPUT

I

Punching

I

Date

o

RIE

eN B~

SPECI FICATIONS

I I

I
I

I

Instruction

At

Filename

I I

Field Name

1

End
Pos'ltion
in
Output
Record

0

OJ

5

6

7

8

9

I I
I I

Graphic
r----+~r-+-~-r-+~~
Punch

GX21-909Q.

UM/050·

Printed in U.S.A.

0

~

0

0

Z

Z

Z

·AUTO

1
Card Electro Number
Page

>

Output Indicators

Skip

Line

4

3211 <211-2
Lookup(Factor 21is

.~

0

Programmer

4

Plu. IMinusl Zero
Compare

0

~

International BUSiness Machines Corporation

Program

3

Length

Z

Z

eLR
e

IBM

0

Factor 2

9 10 1112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4S 46 47 48 49 5051 52

c 1/ IHJ tit')
cL RJo., q)2

7

1

Operation

1

C

° 3

°

Factor

Name

85 ~
e LR

LI<
e L.R
e1L.:1i

Arithmetic

AL At

~.s~
I- '0 cr."

line

Resulting
Indicators

Result Field

I

2

75 76 77 78 79 80

~ 01_ ~~~~:~f:ation Is~ lijpl L1.11

Commas

Zero Balances
to Print

No Sign

Ves
Ves
No
No

Ves
No
Ves
No

1

A

J

2
3

13
C

4

D

K
L
M

~

CR

X = Remove
Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

c:

Constant or Edit Word

---'
OJ

:i:

1

2

3

4

5

6

7

8

9

1011 12 13 14 15 16 17 1819 2021 22 23 24 •

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3233 34 35 36 37 38 39 4041 4243 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6566 6768 69 70 71 72 73 74

2411

D
o
o

1G>1

N~ ~ Arr~

-

--t---t--+::sot--+-t--l-f--t-t--t--t----r- -I--t-+-+----t---t-t--f-r-t-+-t--+ +-+-t--+-t----t---i

-t-f-++-I--+-f-+-t-j4--f-f--+--II--+-+--hE..J-O--+-::::;;F:F-t-+-+--t---t-++11~ltI~r----,t--t-+-t----t---t-+-t-t--t-

o e,l.. T:PIU T _1---+--'--111---+--I=2-t-=--+~1-t
i--t---1t-+_L-=+=-R+-+-+-+-+-+-+-+--+-t-+--t---f_
o
- -'--~1f
o
-- - -- - -- -t-+--+--t--f--f-+++-t-t-+---l-t--t-t---t-.....-t-t-t-f::=:iL-f,-

fO-l-7+-+-0-t-+--t-+-H-t--t--t-t- --t- -

- -+- -

f- f- -

+- -

-

8

1-°_+-1f-+O-t-t-t-r+-t-++-t - t- -- -- -t- -

t-0+-9+-t--°_t-f_+-_t-+-+-+--+-1'='-+-~c-I_+-_ I-f-I-- Dt:l -

1-:+°--+1-+-:-+-+-+-+-1--+--+- -- [f- -

~ --I-I-

t-

_I

~ --

RIE CIN BIRIi!

2
- r- 311-f--r:a. -

I- t- -

--- - -f-- - H-

-- - - - - -- - r- - -

1-- -- t - -

1- --

\

~IPL

l.OA DE

PIRO~

A

I

1 "'AS'

-+-+-I-+-+-+-t-+~t--+-+-

-r-r-f--

-L-t+=l-;;~~+..-t--:;;;h-t-I---+--t-t-+

r-~ ~ - ~J~!~~ P R S I :;.:+-.t=-l=1-:-::-t=l-::,;o+-f=t-:~--h-l~+-l--+-+-+-1-+-t
~~ \ liN TO AN I tJ J) E~,E-=+=Il+-+F--I-I=+=Il._F·E,+-I_I-+-_+-+-+-+-_+--+~

f-- --- - - --f- - - f - -

f-+-+-+--+-t-l---l-+-+--r-- --i---t--i- -I-----t-I----t-+-~-_t__l___l_-------0
1 2

\S

21 f- ,~ e~~t-AR f

]JJI-- ACE NIDI! N6 I

'12 \ S [QUe CE Sl1

IR

1 6 Ai'

:1:3::0::::::_+_+f-+_--t-_::::~+-I--~H+-H~Ht-r++-~~_-t4+-++_~_t-t-f~~q~~\_~~~~~_~NP tl~~-~~RA~S~I~N+G~/++++-++-~
:: ~
T ---+-+--+-+--+cC~-- - - 8J1 \ I~ _~~~8EMEtJ ~ 0 ~II
1 6

0

1 7

0

1 8

0

1 9

0

2

°

oJ>rS!I<~~1

21 ' AMft p~ IDG ~A
'1l, ,, IN T IFIR Otr1 Tfl

ILE

~5

e

o
o

to U~T

•

o
o
o
ZL 1< OL 69 89 L9 99 S9 1>'9 £9 Z9 19 09 6S

8"

LR IN,

RE C.N ,B:~
sv

vv

tv

ro

191~

i2e

~ SH o~

I~

S Pf( rJP fR LV L

\

tOR

! L1'I LL'

~J) EX el>'
111 ~ 11 I11'

'"

~ L I

NU £ilIB fiR'

Z> ~v OV 6£ 8C L£ 9£ S£ V£ ££ Z£ 1£ O£ 6Z 8Z LZ 9Z SZ >Z £Z ZZ ~Z OZ 6~ 8~ L~ 91 S~ vI £1 ZI 11 01

6

8

L

9

S

>

£

Z

~

Figure 19·1 (Part 2 of 2). Sample Program 1 (SAMPL 1)

Sample Program 1 (SAMPL1)

19·3

SAMPLE PROGRAM 2 (SAMPL2)

Output Specifications

SAMPL2 must be preceded by sample program 1
(SAM PL1). SAM PL2 reads the indexed file created by
SAM PL 1 and prints fields from each record read. Thus,
SAM PL2 allows you to verify that SAM PL 1 loaded the
indexed file properly. The specifications required for
SAMPL2 are shown in Figure 19-2.

In the output specifications (see Figure 19-2, Part 2) the
1 P andOF tndicators, specified in an OR relationship,
cause a heading line to be printed on the first output
page and on each succeeding page. Conditioned by
indicator 01, the disk record just read is printed.

Control Specifications
Control specifications (see Figure 19-2, ~art 1) should
be present in every program. They are the first record in
the' source program and identify the program.

The next record is read from DISKOUT, and the same
calculation and output operations are repeated until
there are no more records in the disk file. When end of
file is reached on DISKOUT, the LR indicator turns on.
Conditioned by LR, a total line is printed indicating how
many records are read from DISKOUT. If the number
printed (COUNT) is 100, SAMPL1 and SAMPL2 were
executed properly.

File Description Specifications
SAMPLE PROGRAM 3 (SAMPL3)
The files in SAM PL2 are described on the file
description specifications sheet (see Figure 19-2, Part 1).
The indexed file, DISKOUT, loaded in SAMPL 1 is
defined as the primary input file for SAMPL2. The E in
column 17 ensures that SAMPL2 does not end until end
of file is reached on DISKOUT. The records read from
DISKOUT are printed on the output file, OUTPUT. An
overflow indicator is specified in columns 33 and 34 so
that subsequent operations can be conditioned on
overflow.

The programs SAMPL3, SAMPL4, and SAMPL5 are
designed to be run in sequence.
SAMPL3 loads master records into an indexed file and
creates a consecutive file of transactions. The
transaction file is processed against the master file in
SAMPL4. SAMPL4 should follow SAMPL3. Figure 19-3
shows the completed specifications for SAM PL3.

Control Specifications
Input Specifications
The primary input file, DISKOUT, is further described on
the input specifications sheet (see Figure 19-2, Part 2).
DISKOUT records are 128 positions long and are
identif,ied by a zero in position 1. When an input record
containing a zero in position 1 is read, indicator 01 turns
on.

Calculation Specifications
The calculation specifications (see Figure 19-2, Part 2)
add one to COUNT when indicator 01 is on. The
COUNT field keeps track of the number of records read
from the DISKOUT file.

19.:.4

Sample Programs

Control specifications should be present in every
program. They are the first record in the source
program and identify the program.

File Description Specifications
The file description specifications describe the files used
in the program. The input record file, I N PUT, is read
from CONSOLE. An E in column 17 indicates that the
program ends when the last data record keyed in is
processed. The indexed output file, MASTER, consists
of 26-position records with a 5-position key field
starting in the second record position.
A consecutive output file, TRANS, with a 1a-position
record length is specified by the file description
specifications. A printer output file, PRINT, with a
record length of 78 is also defined by the file description
specifications.

RPG CONTROL AND FILE DESCRIPTION SPECIFICATIONS

IBM

GX21·9092· UM/050'
Printed in U.S.A.

International Buslneu Machines Corporation

Program

SAMPl.E. PR06RAM 1* Z

PrograrTlrn~r

1

2

75 76 77 78 79 80

~~~~;~f:ation Is1AIMlpll.121

paye~of _

Date

Control Specifications

-

H

i

i

."o

Model 20

~r---~ro-.TO-'~

~ 8

J;
Size to
Line

E

0

a

Size to

0

Compile

I-

.it:

Execute

0

E

c3 ~

&

I!J

_

E ._
tf ;:B

t3

~ ~

"0

~

o

~\11L1

;:::
0

Positions U
0

Address

M

n

I

74 ?S 2617 2A 2930 31 J7 3~ 34 35 3637383940 41 4243 44 45 4G 47 4R 49 SO 51 525

II

I

Refer to the specific System Reference
library manual for cH.:tual entrlCS.

<.:l
Q.

i~ij~

to Start

({
']J

o

"00

0

0

9 10 11 11 13 14 15 15 17 18 19 20 11

O\l\H\\

co Number
Of Print

0

~

III

54555657

sa

59

nO 61 13163646566676869 70 71

n

73 74

11111\liLI\I\I\\IIl..LL
File Description Specifications

File Type

F

-

Mode of Processing

File Addition/Unordered

Extent Exit

Length of Key Field or
of Record Address Field

File Designation

End of File

for DAM

Record Addlcss Type
Sequence

Filename

Type of File
OrganizJtion
\"\lor Additional Area

File Format

line
Block

Record

Number of Extents

Tape

UJ

length

Length

5 t:

a: e

S

9

10

n 12 13 14 15 16 17 18 19 :to 21

n

2~

23 24

Condition

60 61 67 63 64 65 {)(; 67 68 G9 70 71

INPUT SPECIFICATIONS

Record Identification Codes

I

Printed in U.S.A.

2

75 76 77 78 79 80

0

Position

g
0

z

2

o

3

o

4

6

7

a

9

Position
0

g0

S <5

z"

N

~

Position

~
0

u <5

z

~

§ <5~

.;;;

a:
...J

VJ

co
Q;

From

To

Field Name

~

NS

.~1

1

~
]

.,c

0

~iS

~

"0;

"0

~g'

~

::;u
8 ~~
"u::

~

~9

Field
Indicators

.0

U:::U:::

g

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 3031 32 33 34 35 36 37 38 39 40 41 41 43 44 45 4641 48 49 50 51 52 53 54 55 56 57 58

I~~ 811<0U1

~~~~;~f:ation Is IA 114M L 121

Field Location

Filename

Line

o

7J 74

GX21·9094· U/M050'

f--

5

n

International Business Machines Corporation

page~Of_

1

Ul.~

~

Entry

Option

1

4

~
z

Continuation Lines

x

76 27 28 2930 31 32 33 34 35 36 37 38 39 4041 41 4.1 44 45 46 41 48 49 50 51 52 53 54 55 56 57 sa 59

RPG

3

Rewind

Storage Index

~

r--- g
Key ~ield ~
Starting
Location
UJ

~

~ ~

o

Number of Tracks
for Cylinder Ovedlow

o Overflow Indicator 8

1

IBM

Symbolic
Device

Device

...J

Name of
Lobel Exit

Zero
Plus Minus or
Blank

6061 62 63 64 65 66 67 68 69 70 71 72 13 74

I

Figure 19-2 (Part 1 of 2). Sample Program 2 (SAMPL2)

Sample Program 3 (SAMPL3)

19-5

RPG

IBM

Form GX21·9093
Printed in U.S.A.

CALCULATION SPECIFICATIONS

International Business Machine Corporation

Program

1 2

SA MPLE

c
-

Indicators

~

9 cc

I

:;:; Q

And

~ j a:~
§ SE ~ a

Line

,I

~

Factor 1

And

Operation

_

u.
7

4

o
o

1

c

2

C

o

3

C

o

4

C

IBM

0
z

z

8

0

z

till!

':

J:

Lookup(Factor 2)is
High low Equal

COllltJT

~DD

11

RPG

OUTPUT

alet

COiLJIN T

GX21-9090.2 U!M050"
Pru'ltedin U.S.A.

SPECIFICATIONS
1

Page

Date

0

~

Space

Output Indicators

Skip

~~

0-

Filename

Line

~

7

o 1

00

o 2

0

o 3

0

o 4

0

0

5

0

o

6

0

o

7

0

o

8

0

o 9

0

1

0

0

1 1

0

1 2

0

1 3

0

1 4

0

1 5

0

1 6

0

1

0

Jd


End
Positon
in
Output

Zero Balances
to Print

Ves
Ves
No
No

II

Record

Commas

Ves
No
Ves
No

2

75 76 77 18 79 80

~ 01_ ~Z~;~I:ation Is ~lij;pILI,21

No Sign

CR'

1

A
8

2
3

C

4

D

X = Remove

J
K
L
M

Plus Sign
V = Date
Field Edit
Z = Zero
Suppress

0:

Constant or Edit Word

---'
!Xl

Q:

9 10 11 12 13 1415 16 17 181920 2122 23 24 2526 27 28 29 30 31 32 33 34 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

ur P~T

H

11P

2tllLl

PF

OR

J)

D1

1

---

T S

~1

Sample Programs

IS
Z

PA GE

!

l~elY

ID,I-

IIJIM

,(/J
~

\ l< lEY'
\ 1) ES ~R I PJI O'N'
Ip~G E'

:~

DE sc

21

It""

L~

Figure 19·2 (Part 2 of 2). Sample Program 2 (SAMPL2)

19-6

.~
0

Comments

1>211<211=2

SAMPLE PR.OGRAM #

r----

7

~:5-

0

~

0

~ ..J:~

~
~

10 11 12 13 14

1(; 17 18

Size to

line

~

I-

u.
3

4

~
c ..

~ ~

~ Compile

7

B

9

a.

~

Cl

~

Number
Of Print

~~

"'Cl~"C_! :C~ MS!
...

M~~el

Model 20

~
Positions

S

~
8

: >~

a

I~
~~

Address

E

-5

.-

(5

6.

~

g

g '§

~:; ~o. o_~, ""_;, ~.:c "_ :o.~ ~_S:!~ .~g~ ;~: ~.8~" :.~c- " , "I~O

~E

c:

~ ~

a~ ~
ti

~

~

~~
Cl

R~fer

e,:)

~ g ~ ~ g: ~ ~

-::::::::.'~'::;-~.-"O_~c~~~zi
~]~~~~E
OOCCI-N-a:~til
~V)u..u.a:~~

to Start

......::

..

C

':

........ .:::

70 21 22 23 24 25 26 27 28 29 30 31 3233 34' 35 36 37 38 39 40 41 42 43 44 4546 47 48 49 50 51 52 5: 54 55 56 57 58 59

I

II

I

to the specific System Reference

Liblary manual for actual entries.

I

I

I

I

I

I

I

I

I

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
I

I

I

I

I

I

I

I

1·1

I

I

I

I

I

File Description Specifications
File Type

F

File Addition/Unordered

Mode of Processing

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

r---

End of File

Record Address Type
Sequence

Filename

File Format
N

line

Type at File
Organization
or Additional Area

Device

Symbolic
Device

Number of Extents

Tape
Rewind

Storage Index

~

~

o Overflow Indicator 8

Block
Length

Record
Length

~

~

~

t:

e

:«' ~
J

..J
W

Number of Tracks
for Cyliflcier Overflow

Name of
Label Exit

Condition

r--6
Key Field
Starting
Location

~

Z

Continuation Lines

~

Option

W

UH~

~

Entry

4

o

2

o
o

3

o

5

o

6

o
o
o

8

4

--,
7

9

1 0

11

12
13
q
5
~

1
- ~F T1pft(-~~I- :NN_$t
.. ~
F!I'-+-+F-Ft"'41Ij~4=+:....:.t-=--+--+-r- ~

-I- -

r; -+--+--+-+-t--1f--+ --

H++-F'-+-+-I----I-·

F: - - ~. ·~7 ~ - .IF

---

_+--+-~~:::-¥.lI:I--:::S~"--1=L+.-!--+-+--+-+-t-++-+-+--+-+-l-+++- --- -

+--+-+-I--t- - -+-+-t--1--+-+-+--+--+-t-t--t- t-If-+-+-+--t--t--1rl-t-+ +-HH-+-+-+-H-+- , - -

-- -

-- -

-f--f---f---

- -f--

.....
IB't_f--t-L-i·-"'l--~+-+--t--1~-+-i--t-+-+--+-+-t-P_;.R,-=tI=t
I'-'1-"1-'F'E==t"R+-+-\--+-+-t-~-t--t--t-Irl-r-+-+- I--+--t-+-t-l--+-+-+-+--t-JI-H

- - -- -

-. -

- -

--. --

·-+-+-~f-+-+-

.•

'--j

!-+--+-+-+-t--1-+-+--+--+-+--+f-+-+---+--+

Figure 19-3 (Part 1 of 3). Specifications for SAMPL3

Sample Program 3 (SAMPL3)

19-7

SAMPLE PROGRAM #3

Punching

Instruction

.1

I

1 Graphic 1

I

Punch

11

1

1

1

1

1

Record Identification Codes

0

:l.

>

j
5

'0 r-rA

6

0 1

I

o 2

I

0 3

I

8

7

to tt

9

o 4

I

5

I

o 6

I

o 7

I

o 8

I

o 9

I
I

11

I

'g j

§
Z

0

_Q
~
U

~E

. Position

Position

Z

U

0

~§

b ~ ~

2

U

~

U

ji;

D

0

k'I.l "'1

:"'I~

From

11

~'\tI

~f-

f - t-

m2 a1

f-19S

IB1~ f-r- f - 1 I-'

10
-r-r-1
t---+H.--t--~f-rI

I

I

1 9

I

2 0

I

: 11
U

tI H-I

1
1

C

I rC

I('
~

o 3

o

4

-5

:5

~2

:2:u

j

Plus

Zero
Minus or

Blank

"0

~

LUiEA
f - - f-f-

-f-f-f-

--r- f-f- 1--

C~r:

-1-- r-r- .t-- t--t---

-

D

11

(,

t:rY

l~le Mil

CALCULATION SPECIFICATIONS

:til

Form GX21-9093·2
Printed in U.S.A.

3

1 2

p.ge~Of_

AL At

~~~
'0 a:
tI)

6

7

8

c
c

CO~
COR

o 6

C

o

C

75 76 77 7B 79 BO '

~~~;~f:ationISIAIMIPlI31

Aesulting

Result Field

Indicators
Arithmetic

Factor 1

Operation

.g

Factor 2
Name

t-

C

Length

:r;

~ ~

Plus lMinu~ Zero
Compare

]~ 1>21<211=2

Comments

b
0
'0 - Lookup(Factor 2lis
Z
Z
o :t: High Low Equal
9 1011 12 13 14 15 1617 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
49 5051 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

91
l2

101M AS

IAD[)

1

IIIU .In!AS

[liB 1915

lY

I'IU II 11l(j'14

lAIC 0

1

lllJ 1111 It<: I"

~Ie ~~

I~

Figure 19-3 (Part 2 of 3). Specifications for SAMPL3

19-8

.Sg'

-t--I-

Indicators

-'a:
::0

o 5

7

0

:!J4) ~"0

.~ ~

U-LL

~~I t'H~~

lO'NS

t-

~85~
0 1

Field
Indicators

~C

1

1 IJ

-t-+-

PROGRAM

~

E !:::

0 2

1

7

Date

0_

J---

5

~

..,0

1 IO
6 -Er-I

~

~~ ~e rr~
D~
c ·-t

RPG

Programmer

4

e

78 79 80

International Business Machine Corporation

I Program SAMPLE

3

j

g
~

2

t -0
'~g

I

0;

0

C~

RD
~f~NIS~ ~[I ~OIN RIE
1 "'"

I

To

~

Field Name

in
0

77

~~~~;~f:ation 1s IA IMlpl L 131

.~I\IN

I

-I-

IBM

!;.e e

-

f-1 8

!-t-.t-

~
'0

Z

~n: Ira

!A

1 4
I
r'f- t-. - r-+1 5
I
1 6

Position

"0.

f; 'Nto

NPUrr

112
I
r-f- r---1 3
I

Line

c

.,

.0

1

1 0

7

ii

1

g

~
~ ,~

75 76

page~Of_

12 13 141 516 1718 19 20 21222324 25 26 27 28 29 3031 3233 34 35 36 37 38 39 40 41 42 43 44 45 46 4 7 48 49 50 51 52 53 54 55 56 57 58 59 60 6162 6364 6566 67 68 6970 71 72 73 74

srr iER

~

o

~e

til

l-

Card Electro Number

3

2

z ;:) ~~(5

i

Filename

Line

1

1 2

Field Location

cr

~

r----

1

1

IDate

Programmer

4

Printed in U.S.A.

International Bultiness Machines Corporation

Program

3

GX21·9094· U/M050'

INPUT SPECIFICATIONS

RPG

IBM

Sample Programs

RPG

IBM

OUTPUT

f-pr_ogr_amS~A,-=M~P=-L..:::;..E~P----=.R....:..::O::....::G:r-R=-I\.:..=...M-=------#-=3_~1 Punching
Programmer

I

Date

Instruction

I

Punch

I

a::

!
5

6

'AUTO
7

8

9

a::
...J

OJ

1

No Sign

Ves
No
Ves
No

I
2
3
4

Ves
Ves
No
No

II
ii::

to Print

Zero Balances

Commas

1====

Position

~

j

4

:>

End
in
'"
;3 5 Output
Record
~ ~

Line

I

2 3

.

2

75 76 77 78 79 80

Page ~Of_ ~~~~;~f:ationISIAIM!pILI31

I

a

Field Name

3

GX21·909(). UM!050·
Prin1ed In U.S.A.

Card Electro Number

If-G_rap_hiC-fI-t--+--+I-t--+-+I-j

I

o

-

SPECIFICATIONS

International Business Machines Corpora lion

CR

:

A
B

J
K

C
0

M

X •

L

Remove

Plus Sign
V• Date
Field Edit
Z • Zero

Suppress

Constant or Edit Word
5

7

6

8

'0,112'."'5'617 18 19 2021 22 23 24 '

9

10 11 12 13 14 15 16 17 lP 19 20 21 2'2 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 4.1 42 43 44 45 46 4748 49 50 ~1 52 S3 54 55 56 51 58 59 60 61 62 63 64 6566 67 68 69 70 71 72 73 74

:: ~MAsrr~iRf--_~ ____+ ____ f--gl_H____ 0----------1-!
l -: t~-H- I i i
a 3 0
- -1KBY'
Ib--f-i --:"1: ill: I i i
i, i
a
0
il£TS~!
l]jq
II
'H=t'rI I
I :: :;

f--

++1-

::--rT 'tL

!

if--

--++-tlT-;-T I
il--rr6
1
Arn~B---l-?t;: -rl-TI--H nl
I!:.:
~
f- ~t~'E''''
-i-~~ 1-+ tt-- +-+ It- r-tt1-ti--~rtrr- -tT~
I~\il'.
I~-r--- -f-----+ ~I.f-t-~----f-l~
-+-+---mt±b-+--W+J-"-+-h~-I~
'
~.~. :~R~:=~=Q~~ -f-- -r-f--S~--I-r f1:=~W:ti:~ Jl~ -rt i--~~==-I-tHj_!+tt+fd+W-~:it±I/; i
~~-~.
-rOB r-r'~ --.I;J-++- - -t~--l -mrt- 1--- - l-lj_I~_+J_W ~-t-L-4-r-+++~~

--r-----r--'-+-f---1-1---'--~;LUfEI~

4

a

0

I

0

--1- -

-;-1-'0 - - - - - - 1 - -

l·-118c---,-rrr-~

--

- - - - -

I : :

i

j:

-+-

i

-

'I

I

-

+

I

0

12

0

I 3

0

I

0 t-Jl

Position

f-

Position

From

Position

To

j
4

5

6

7

8

o 2

I

AA

I

o

I

5

0

fj~

OIR

- f - 1-1-

I

~.~

g

c

Field
Indicators

0

0

:9-0

.~ Qi

u...u:

.~ ~

~~
.3 :;;u

~
"tl
0

~

Zero
Plus Minus or

Blank

"tl

0;

u:

9 1011 12 13 14 15 16 17 18 19 20 21 22 23 24 25 2627 28293031 3233 34 35 36 37 38 39 40 41 42 43 44454647 48 495051 5253 54 55565758 596061 62636465666768 69 70 71 72 73 74

IT RA NS

o 4

0;

j

0

o 1

o 3

~

Field Name

0;

0

0-

3

75 76 77 7B 79 BO

Record Identification Codes

~

Line

2

~ 01_ ~~~~;~I:ation IslAIMlplL 1q.1

81"- .

OR

o 6

1MAS TI=R

o 7

I

S!q

~B

1 CA
1 C~
1 C~
1

Z

6 KEY

l~{iJIAHT

17

eM

1--

RPG

IBM

Form GX21·9093

CALCULATION SPECIFICATIONS

Printed in U.S.A.

International BUSiness Machine Corporation

1

2

Page W O I _

C

Indicators

~

0_

I---line

Operation

Factor 1

:e ¢

Factor 2
Name

E ;, '"

4

5

6

o 1

C

o 2

C

o 3
o 4
o 5

7

8

0
z

COR
COR
C

o 6

C

o 7

c

o 8

C

0

z

Length ~

;

Plus 1Minusl Zero
Compare

Comments

1>211<211=2
~~ LookuplFactor 2)is
'u o ::t: High Low Equal

9 1o 11 12 13 14 15 1617 18 19 20 21 22 23 24 25 26 27 2829 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051 5253 54 55 5657 5859 60 61 62 63 E4 65 66 67 68 69 70 71 72 73 74

rt
1-·

1~

~

02
3

o 9

C

1 0

c!1 RNIOl

1 1

C

1 2

C

1 3

C

"

IK Erf
~

LU ~~

V LU ~~

~ L~~

E 10

Sample Programs

"5

1:)"-

I UII1

r

D I NIVI

G TO

~

~
~

A

A

,)

~

~

,

::;

Figure 19-6 (Part 2 of 4). Specifications Tor SAMPL4

19-14

Indicators
Arithmetic

a:,"

&85~
3

Resulting

Result Field

AL At

-'II:

::-0

~~~
.- 0

75 76 77 78 79 80

:~;~f:ation IslNMlplLlql

ON

~rr

ER

li'
V LU E~
V

LU E~

V LUE

~~

OUTPUT

RPG

IBM
Program

SI\MPLE PROGR.AM #1.\-

Programmer

0

w

~R
>-

~
f-

f-

~
5

6

o

8

9

op RI NIT
0

o 3

0

o

4

0

0

5

0

8

o

9

GX21-909(}

UM/050'

Printed in U.S.A.

0

0

0

I

I

0

2

0

I

3

0

I

0

.2

! !

Jd

~7

A 'Do

Field Name

1

~

~':i

en

R

0

:;(

Z

~~

0

z

Z

a
CC

0

II

End

2

I

Card Electro Number

75 76 77 78 79 80

~~~~;~f:alion Isl~IMlp IL Iq I

p,geMOf_

>

Commas

Zero Balances

Ves
Ves
No
No

Ves
No
Ves
No

Position

in
Output

~ ~

'AUTO

lP

H - lB.4
-- H

to Print

No Sign

CR

~

I

A
B
C
0

J

2
3
4

K
L
M

X •

Remove

Plus Sign
V • Date
Field Edit

Z • Zero
Suppress

cc

g

Record

Constant or Edit Word

0:
1

-e-

_. -

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 •

H_ _I

4

0

1 5

0

---

1--

H

I

6

a

OR

I

7

0

I

8

0

I

9

0

2 0

a

i2--

--I- ----

UDiATE V

-I- 1-----

--

._--

-

r-

-- --

-- ---

:1[P
OF 1-1-liP
IOF

1--

-x

~AGIE~ -

f- - 1----- - -

-l-

--- -

-

--- --- - -- --~

-

--

._-

1--

--

--,

----

I-- --I-- -I--

- - --I-

Sr-

liB

0

~6

--'--

--

--.-

p

OG'RA 1'1'
1-- f---

i--

-+-r

- --- - I -1-- -f--

,- - f - -i--

- --

-- - - -

I

--I- 1--1-

1

I

~

I

5
172.

0

-r

-I-

-UP DAmE

I~C RIP 10 N'
, '~-V "11= JE
~
VA l UE 8'
, ~ E

1

KJ=V

- ---

-'--

-z 11-- ,-. iE\AJ '
~ 1_ '~E.~'
-N---~ 1_ ~ _EW'

2b

0

1~~i

J

I

,
=~1z~: ~fI1IG~ lE

~

D 11

S~ Sit ElM /3:q'

'IiB~

37

OF

-- - - -- _.-

_0 R_ e--

-+--

OF

if

H 2

OR

1-1- '-1- - - - I - e-I

! !

Output Indicators

Skip

OR

0

I

Space

Punch

I I
I I

I I

10111213 1415 1617 18 19 20 21 22 2324 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4041 42 4 3 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 (;] 64 65 66 67 68 69 70 71727314

o 2

o

!

I I

r;;-ND
7

o t

o 6
0
I-I- 1-1o 7
0

"§

Graphic

Punching
Instruction

~

1: ..
i ~

F;lename

line

4

I

Date

r--

3

SPECIFICATIONS

International Business Machines CorporatIon

,
I

01 I

t:1A S[ E:R FI U:l

OR ft~1h'

0
0
Zl Ii Ol 69 89 19 99 59>9 C9 Z9 19 0965

as

L5 95 55 I>S C5 Z5 15 056.8. L> 9.5 ••• C. Z••• 0.6C Be LC 9C 5C .C CC ZC 'C OC 6Z BZ LZ 9l SZ .Z £Z ZZ lZ OZ 6' 81 L. 91 S ••• £1 Z. "

A.

6

8

L

9

5

•

C

Z

.

Figure 19-6 (Part 3 of 4). Specifications for SAMPL4

Sample Program 4 (SAMPL4)

19-15

RPG

Bu~iness Machines CorporatIon

IBM

International

fprogram

SA~PLE PROG-R~M$"

: , Programmer

BSpace

t:o ~'
~~

Filename

Line

f-

>

f-

j
5

Punching
Instruction

I Graphic
,

Punch

I
I

I

6

.2

~

r,;D~

8

At
0

CD

.£~I-

7

~

;;:

0

1

Z

Z

Field Name

@I
a:
-c _

'"

8 U

z

·AUTO

~ ~

1

End
Position
in
Output
Record

I

75 76 77 78 79 80

page~Of_

I

i:>

2

"Commas

Zero Balances
to Print

Yes
Yes
No
No

Yes
No
Yes
No

~Z~;~f:ation Is ~MPI1-~ I

No Sign

CR

:

X· Remove

1

A

J

Y •

2
3

8
C

Z •

4

D

K
L
M

Plus Sign
Date
Field Edit

Zero
Suppress

a:

Constant or Edit Word

...J
CD

a:

1 2 3 ' 4 5 6 7 B 9 1011 t213 14 15 16 17 18 19 2021 22 23 24 '
AND
9 10 11 12 13 1415 1617 18 19 20 21 22 2324 25 26 2728 29 30 3132 33 34 35 36 37 3839 4041 4243 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

11

1~1 Nilig

0

1

0

o
o
o

2

0

3

0

4

0

0

5

0

o

6

0

0

7

0

o
o

8

0

9

0

1

0

0

~IE~

1

1

0

OESC

1

2

0

1

3

0

1 4

0

1

5

0

1

6

o~ lAS rrlE~

1

ErY

II

1

IS~ N11~

11~

ALUE 13

218

KEY

5
1&

OE~ C

b

II

1
2.

I~

IQJ8 Nl~

I...

R I~~

~A~

!

5

I=JS~

UE ~IJ

~8

5

11&

vrAL UE ~IJ

141S

'IN~

132

II
INll IEJll: CC ZC

~C

O£ 6Z 8Z LZ 9Z 9Z OZ EZ ZZ

~Z

OZ

6~ 8~ L~ 9~ 9~ .~

tl

Z~

~~ O~

6

8

L

9

9

•

£

Z

~

Input Specifications

SAMPLE PROGRAM 5 (SAMPL5)

Two types of files are specified by the input
specifications: transaction and master. An A, S, or C in
position 1 of the input record turns on record identifying
indicator 01, 02, or 03, respectively. An M in position 1
of the update record. turns on record identifying indicator
04, indicating an update record. No sequence checking
occurs for either type (AA and AS in columns 15 and
16).

SAM PL5 must be preceded by SAM PL4. SAM PL5
reads from the indexed file, MASTER, and performs the
following calculation: value A + value B - value C. If
the result is negative, a message is printed. Figure 19-7
shows the completed specification sheets for SAMPL5.

Calculation Specifications

Control Specifications
Control specifications should be present in every
program. They are the first record in the source
program and identify the program.

When indicator 01, 02, or 03 is on, two operations
occur:
File Description Specifications

1.

2.

A matching master record is retrieved for a
transaction record (lines 02, 03, and 04 of the
calculation specifications).
The AMT field of the transaction record is added
to the appropriate value (VALUEA, VALUES, or
VALUEC) on the master record depending on the
type of record (record identifying indicator 01, 02,
or 03).

The input file for SAM PL5, MASTER, is an indexed file
(I in column 32). An E in column 17 indicates that the
program ends when the last data record in the input file
is processed. The file consists of 26-position records
with a 5-position key field starting in the second record
position. A printer output file, PRINT, with a record
length of 78 is also defined by the file description
specifications.

If no matching record is found, indicator 10 turns on.
Input Specifications
Output Specifications
Nine printer output lines are described in these
specifications. Four header lines conditioned by the first
page indicator (1 P in columns 23 through 25) or an
overflow indicator (OF in columns 23 through 25) are
printed. They are printed at the top of each page of the
listing.
Four detail lines are also printed. A detail line is printed
for each transaction record with no matching master
record. For each type of transaction record, A, S, or C,
the accumulative value is printed (detail lines conditioned
by indicators 01, 02, or 03, and not 10). These detail
lines are single spaced ..
A total line is printed if no transaction records were
entered.
A detail record is written on disk for the indexed update
file, MASTER, when indicator 04 is on and indicator 10
is off. Indicator 04 turns on for an update record, and
indicator 10 turns on if no matching record is found.

An M in position 1 of the input record turns on record
identifying indicator 01.

Calculation Specifications
Record identifying indicator 01 conditions all
calculations. Values A, S, and C are accumulated (lines
03 through 05). The calculation, value A + value S value C, is performed and accumulated (lines 01, 02,
and 06). If the calculation is negative, resulting indicator
22 is set on to condition the printing of a message;

Output Specifications
These specifications print four header lines, each
conditioned by the first page (1 P) indicator or an
overflow indicator (OF).
One detail line is printed for each program cycle. One
total line is also printed when the last record indicator,
LR, is on.

Sample Program 5 (SAMPL5)

19-17

RPG CONTROL AND FILE DESCRIPTION SPECIFICATIONS

IBM

GX21-9092- UM/050·
Printed in U.S.A.

International Business Machines Corporation

75 76 77 78 . 79 80

1 2

page~of_ ~~;~;:f:ation

IS IAMI plL 151

Control Specifications

-

i

H
8.

Line

~

Size to
Compile

~
3

4

5

6

~ ....o.~
oJ

~c;

8

r;2E....

~

.g
t'

iIF~~:1 ~::; HHihBi~HH hlllH

Size to
Execute

!~
1

~odel

Model 20

~

9 10 11 12 13 14 15 16 17 18

20 21 22 13 24 25 26 27 28 29 30 31 3233 34' 35 3637 3839 40 41 42 43 44 45 46 47 48 49 50 51 52 5

II

I

I

I

I

Refer to the specific System Reference
Library manual for actual entries.

54 55 56 57 58 59

I

I

I

I

I

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

I

I

I

I

I

I

I

I

I

I

I

I

I

I

I

File Description Specifications
File Type

F

Mode of Processing

File Addition/Unordered

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

f--

End of File

Record Address Type

Filename

Sequence

Type of File
Organization

File Format

~or Additional Area

Line

-J

Device

Symbolic
Device

Number of Tracks
for Cylinder Overflow

Name of
Label Exit

W

Number of Extents
Tape
Rewind

Storage Index

~

~

o Overflow Indicator U

!

Block
Length

]

3

4

5 6

Record
Length

~

t:

e

~ ~
7

8

9

Condition

r-§
Key Field

Starting
Location

"Vi

~
W

Continuation Lines

Option

1011 12 13 14 15 16 17 18 19 2021 22 23 24 25 26 27 28 2930 31 323334 3536373839 4041 4243444546 4748495051 52 53 54 5556515859

~~:t4:--~ -j-~_-~-

as

617 817 Lt 917 C;t "" Ct Zt i t CIt 6e 8C It 9£ sc t'C CC lC Lt DC 6l 8l it 9Z C3Z

Figure 19-7 (Part 1 of 4). Specifications for SAMPL5

Sample Programs

Entry

:;)

3 U1J~

-;,:

ii:

60 61 62 63 64 65 66 67 68 69 10 71 72 13 74

--1 ----~~~ ~- -i~-l~~~~~~~~~~~~~~~+~~~~

II lL OL 6989 L9 99 c:;~ 179 t.9 19 19 09 Se:; B'i lS 9J C;;S I1S (9 iii LS

19-18

~

f:

tZ tl ZZ LZ Ol 6L aL l L 9L SL "I CL II U OL

6

8

l

9

S

"

elL

RPG

IBM

GX21,9094, U'M050'

INPUT SPE'CIFICATIONS

Printed in U.S.A.

International Business Machines Corporation

1

75 76 77 78 79 80

2

page~Of_
Record Identification Codes

o

I

~ '"., ..
.5 u: u:

0

,

Filename

Line

Position

From

Position

Position

Field Name

0
0.

To

0;

-,;
E

g

g

8

0

3

4

5

6

7

Field
Indicators

Field Location

~

r--

~~~~;~f:alion Is~mplL ISf

0;

~
~

0

'"

~

"0

£

6

u::

'~

Zero

0

l'

..

PillS Minus or

81ank

"0

B 9 10 11 1213 14 15 16 11 18 19 20 21 222324 25 2627 28293031 3233 34 35 363738 39 40414243 44454647 48 4950 51 52 53 54 55565758 5960 G1 62636465666768 69 70 71 72 73 74

Nl~ff-'A--'f"""Sf-I-jJJI~...,....~~Ayl&.~"H-+-,lm'9-lo11+--++--+"""llt_+CN
\ \ \
I I
I J I
O 2
H -4-I_1+--+-+-H-+-+--I--I-'+--HH-4---+-+-~I-H--I---+-+-+----I-+-I-+-+--I-+--+-+---H-+--+-I_+--f!""l2.~:-+"E':f--Il:l~~!!~IE'i~YI=+-I-+-+--+I-+ I
I i
o 3 I
11 ~
)_E~SJCLl i ~
Ii!
1-0+-4+-+1--+-H-+-t--+-H-+--+-+-H--t-+---ii-t-+-+-+---Ir--I-++-+---I'-t--t-t--+---I-t-++--H'-t-+-t--+:--+~+-1il~'1~I~;'"r.;;;~~"l
UE ~ -T -i-t--f--t--+-!I -/------'I-t--~I
-+-+----',--+---1
1

0

1-+-+-1-t-4

I

~0+5~I-1~_I_-I-+_I_~_I_+-~_I_~_-I-~_I_+-+--I-+-+_I_+-+-I-~_I_~-I-~_I_~_I_~~~~:.i~~~V~,',~,lltER-'

I

I

1

I

I

I

I

I

f-0+-6+-+-1-+-+--+-+----+-+-+-I-+--+-+-_f-+--+-+-'-I-t--+--+--+-+--+-+-+-l-+-1f-t-+-+--+-+-+-+-t--t-+-~'F"'_t_,+_____t"!z."'I!I,~..,~'"'t_~......~J.'-"I'LllE<' I 1 f--+I I :i
o 7 I
I
I
1
I
'ii
I
1-+-+-t-+-+--+-+-+-++-+--iH-+-+--+-+--+-+-+----H--+--I-+--t-++-I--+-t---+---H--+--iH--t-++-+--+-I--+-+-t-+---tt-t-t--I--+-+iT ---1---i ~- r-r- --- f--; ----;--- r--r--+--tI
08
I
I
f-r++1-+-+-1-+--+--I--t-+-+--+-H-+-+-+-+---+-I-+---II--+-+--+--+--+--+-+-+---t-+---lI-+-+-t-+-+--+-+-+-+-+-f--+-+-+-++-+--+
I ! I I i i 1_
0 +9
l l __-tLL----T!-lIL-l!-------'-~:.1_ I I
1

I

1

I

1

1

I

I

1

1

I

RPG

IBM

CALCULATION SPECIFICATIONS

Form GX21-909J-2

Printed In U.S.A.

International Business Machine Corporation

1

2

page~Of_

-

C

Indicators

~

0_

line

E :: '"

4

0

56

1

c

o 2

c

o

C

3

o

4

C

o

5

C

o

6

C

o

7

C

o

8

C

o

9

C

8 5"
7

8

Factor 1

Operation

Factor 2
Length

Name

~

0

Indicators

Arithmetic

"'00:,'

~
3

Resulting

Result Field

AL AL

-'a:
=0

~!~
I-

75 76 77 73 79 80

~Z~;~f:alion IslAIHlplLSI

0

g
~

I

Plu,lMinu,l Zero

s 1 >211 <211 =2
Compare

Comments

~ ~ lookup(Faclor 21 i,
U :!:
High low Equal

Z
Z
OJ:
9 10 1112 13 14 1516 t7 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 4 4 45 46 47 48 49 50 51 5 253 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 11 72 73 74

VAL 'EA
All

1
1

1

0

0
0

0

~

~
~

CAL

0

IPI I=~

ID
0
10
ID['\

LU .. ~

U

Il UE

LU .. 3

LU .. ..

~ilr

C
C

~

L"

0

1212

~

~

~

"'

At

.,""

Figure 19-7 (Part 2 of 4). Specifications for SAMPL5

Sample Program 5 (SAMPL5)

19-19

OUTPUT

RPG

IBM

,lprogramSAMPLE

l

PROGRAM "5

Programmer

I

"§

U.J

Space

".'

~~~~

I

A 0 0

R

"ii:'No

3

4

5

:-~~
o 5~

6

7

GX21·9090- UM/050'
P,inted in U.S.A.

I

0

o6

I

I

~
E

0

C

I

'0

9 (9 Z9

~9

0965

as

LS 9S SS .S (S ZS

~S

L
OS 6. 8' L' 9' 5 ••• (. Z'

Figure 19·7 (Part 3 of 4). Specifications for SAMPL5

19-20

Sample Programs

~.

I"-

O' 68 8!: L8 9( S( M: (( Z(

~(

O( 6Z 8Z LZ 9Z 5Z 'Z (Z ZZ

~Z 6~ 8~ L~ 9~ S~ (~ Z~ ~ O~
OZ

..

I

6

8

L

9

g

•

(

Z

~I

------I

-

Int~rMtlona! BuSlntU Machlnel Corporation

_"-:;

o

;-::

~

Space

t :;

~ ,!]

>-

~~-t- ~ <~

~~~

OJ

AND

3

4

a

1

o

a 2

0
0

a

3

05

5

6

7

8

9

0

0l!
Z

I

-- - - _L. I- -f-\45~.

rr

r

i

11

!

f-f-f- __

-

err

And

a:

"III " I

Z

Z

H+ -

.>

!~'nma,

Field Name

II

~~ 5
~utPut 2
~ Record ~

• AUTO

I

~~~tion

Paye

Zera BaIances
to Print

Y

mOf _
1

Card Electro Number

I

No Sign

2

I CR

No

~~s

No

~

75 76 77 78 79 80

~~~~;~f:ationIS~!tw1!piL5'

-

X = Remove

J

y. O.t.

Plus Sign

Yes T f f i A
2
B

I ~~:

g

K

F ,eld Ed,t

~

Z

=

~~~opress

I
:

Constant 01 Edit Word

•

1

2

3

4

5

~I_

f-~I~ -f
10:1
tD

r-.i

IT:

r-r--

qA~\C~L-. ~e _L,~8
I

I

I

I: I

_

:

•

I!;

:

:!

i'

•

1711

6

7

8

9

10 11 12 13 t4 15 16 17 18 t9 20 2t 22 23 24 •

1

!

:1~

1 I '. ; 1. .1
I

r-f--

,
-r+
- - - -,:

.J.._ 1_
i

-1- -

'm'. :

:-r-

I

-

I

f- __ -

--~c-l.
---L

I

I

!,

,

I

i

'1"'~:14
r(\" c---r-:~

!,

H-- -Lj- ~:\L
,I,

I:

T

-l-

I[

~

~-'--;1l f,i~

:

I

:FII"~[

i.

.! ~

i

1

morr:t\c·'--·[

i

lIT. !:

,

' _!

Iii

!

f-Ll

1 I Ti I :
i I
I,
i

~~

I!

.

:

!

'I

I

;

i

'

I : ' : '~_.
!:
!,

.

:

___--'-

~---f-

.=-1== =;=~~-: -~=~~-F=-----~--'----- - - -1_~.~=::_-I_

I:

I~;~ :1 L~LJ,~~~~ _~-~_~l IE r=~~-±:i-~

i

I

:'i~i!;i
I
':
""
!
r~:---,--~.-----,~-f--

I

'i;'

'~iotCA1..Ll~ -. -. 5~ _ ~. ~J '

,I

!

'*NEG~~;I[VIEJ ,! 1
. I I:
i :1
. i ~j , : , I

f! -t -~~~-L~---H-+ : [~ ~! 28f-__~11

~~'-~ __ ~~--11- -~019

And
I

f- __ _

0

060

Punch I T

GX21·9091l- UM/OSO'!
Printed In U.S.A.

1011 1213 1415 16 17 18 192021222324,252627282930 ' 31 32333435363738394041 42434445464748495051525354555657585960616263646566 67 68 69 70 71 72 73 74

_ 0

~~f- ~

Graphic

InstructIon

I I

;

I I I I I
1T I I I

I I

Punching

Output Indicators

Skip

~ ~! 3..

Filename

Line

~~

SPECIFICATIONS

OUTPUT

RPG

IBM

I

;

I'

I.

.

L!-'

Figure 19-7 (Part 4 of 4). Specifications for SAMPL5

SAMPLE AUTO REPORT PROGRAM (EXAUT2)

Control Specifications

This job prepares a cash receipts register using RPG \I
with the auto report function. The *AUTO page heading
function and the *AUTa output function generate the
RPG \I output specifications forthe report and the
calculation specifications to accumulate final totals for
several fields on the report. RPG \I calculation
sp.ecifications that cannot be generated by auto report
are included in the auto report program to verify the
discount taken by each customer and to calculate the
balance due.

The RPG \I control specifications shown in Figure 19-11
should be included in the auto report program because
they are not present in the cataloged specifications (see
Figure 19-8). None of the control specification options
are required in this program, so the specification need
contain only an H in column 6 and the program
identification, EXAUT2, in columns 75 through 80. This
program identification is placed in columns 75 through
80 of all specifications in the generated RPG \I source
program.

The file description specifications for the cash receipts
register printer file, CSHRECRG, and the file description
and input specifications for the input file, CASHRC, are
cataloged as separate members in the library (see Figure
19-8). The cataloged specifications are included in the
program by the auto report copy function.
The input data for the file CASHRC in EXAUT2 is
generated by the program EXAUT1 (see Figure 19-9).
Figure 19-10 shows the input data.

/COpy Statements
The ICapy statements shown in Figure 19-11 copy the
file description and input specifications for the job from
the system library. The first statement copies the file
description specifications for the printer file from the
library member named EXAUT3. The second statement
copies the file description and input specifications for
the disk file, CASHRC, from the library member named
EXAUT4. A modifier statement adds an input field
definition for the REGION field. As a result of these
ICapy statements, the file description and input
specifications shown in Figure 19-8 are included in the
RPG II source program generated by auto report.

Sample Auto Report Program (EXAUT2)

19-21

D

fI The file description and input specifications for the

The file description for the printer file is in the library

disk file, CASHRC, are in the library member named

member, EXAUT3.

EXAUT4.

File Description Specifications

-

File Type

F

File Addition/Unordered

Mode of Processing

Extent Exit
for DAM

Length of Key Field or
of Record Address Field

File Designation

End of File
Record Address Type

Sequence

Filename

Type of File

Number of Extents
Tape

UJ

~

Storage Index

-5

Nor Addidonal Area

Line

Nameof
Label Exit

Symbolic
Device

Device

-'

Organization

File Format

Number of Tracks
for Cylinc1er Overflow

o Overflow Indicator 8

BloCK
Length

Record
Length

~

eo

t::

e

~
~ ~

a:
-'

Condition

5

r---

.~

Key FIeld

Continuation Lines

~

Starting
Location

Option

UJ

Ul'~

z

~

Entry

Input Specifications
r - - ~"----'-----'--IIT7-r-------------------------rIT---------''-------'-'--'-'-------'---'

i

I

I

Record Identification Codes

0

Filename

Line

::>

i~

Q~

5

~ ~

Position

o~ 8 ~

~

0

~
~

~ §~

POSition

~
~e ~

~~6

Field

Field Location

r - - ]

-g.~
Position

"

3l

U <5

V)

~ ~ ~ ~ ~

~

From

To

Field Name

ci:

~

Indicators

~ ~ il ~
~ ~ ~ j,
'e r~
"0

~

0::

.g

5

~ ~·6 ~

Plus Minus ;:ro
Blank

AND
3

4

o

1

o

2

5

6

7

8

9

t2 t3 t4 t5 t6 t7 t8 t9 20 21 22 23 24 25 26 27 28 29 30 3t 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 6t 62 63 64 65 66 67 68 69 70 71 72 73 74

to 11

~~

ClABHRiC

I
I

II

01 1618 C~~II-+I--t-I-t-t-t--+-i-t--+!-+-t-H-t-+-t-+I-+,-t-+-+-++-t--1I-++-++-+-t-f-H-t-I-t-H-t-II-t-+-H-II--j-1+-t
! I
JJ J
j
I I ,I I I I I
1

I i i

+-

! i
I I
Ii!I
I ' " ~CC !N"! . . ~--Account number =:
II
I
: II
i ~
!2.i
AleC 'tJM
Account name
5
1-+-• +-1++1+i-+-+-+-!r-+-+-+-+-+-+-+~-+-r-I,+-+-+-+-+-I-tl-<.I-+-I-+-+-+-++I+-+-H--t--1-+-~~
I,.2n'61-+~13~];~~-j"..,I!~N~!V?-"~i0'1d-1
I nvo ice number =:
p
o 6
I Ii!
I I
'ii.;)
131;, JINVID~I, ~ Invoice date
_
o 7
I
i I I I
I
: :I I !
i i
~ 1 14) ) A~irJO'W:DI~ Amount owed
r_
oi s I
i i iI f
I~ 1 Sr1 )O:IS1C ! ~D'
II'
d

o

3

I

04

I

1

m

I

1

-t

r

~

~-~~~~~'~~I~~~'T'~i~~'~~~l~~~~!'~~~t~~~~~~')~~5~1~~~l~~~~~II~li~~!K~~-~

I-~-ri~-I:H-,_-I~

-+i-f-+-++--+--:-Ir-I--'-;,_-rr -

--T-,...L
i'

i

~.~

-xlP
1,4

I"

I

Ii

; i

i

i

-+-~-t-...,....-t---- _I- _
r
i

'.

,;

,- _

~+i-

_~+_ ~-L;-,- ~.'r!

-Vii·~tTiT--~·
I
Ii
I.LL
~'i
~'. G i l I i I
I ·+-+-~~::I:=:~I::+.~+,---+_-+-.+~_L ~ __ ~_L-_clJl_·.1...
I

.....1......l.._'-.+-

!

Ii
I

I

I

I

,. I

iii iii
!

I;

+- ~ate,pald,

J-i Ll..._i
I

I"

f

!

iii'

1J.

I

I 1.

I

Sample Programs

t

I

,

t
l

I I ~.

,I

'

1_ _

I I

,'Ij--rit

I I I I \I\

Figure 1908. File Description and Input Specifications that are Cataloged in the Library Members EXAUT3 and EXAUT4

19-22

i

:+-::::.::;~:::~:.:~!:i~" ", -+t- +-t- -~+- +-+-;'-:'~ ~'~ r-+-'-'t~l"a~ ~ :~ ~ ,A"'~-I:!:.F~j-P~=-"lgI'1l,-+_m ~.~coo,uu~~t. ;:i~.en

I_-;.....~f-- --+-+----,-l--+--+-+-iI-.-'---~f--r--~~+-.r-I-+-+-+--.-Ll-r--t+Lr-'-1

!

I!

+-

~~ounta owe

,

IBM SYSTEM/34 RPGII AUTO REPORT
0001 01010H
008
0002 0102 FKEYIN
IP F 100 100
0003 0103 FCASHRC 0
F10ZO 68
0004 0104 FPRINTER 0
F 120 120
0005 0203 C
SETOF
0006 0204 C
SETON
KEY01
0007 0205 C
02
0008 0301 OPRINTER T 301
LR
0009 0302 0
02DUMMV
0010 030210
LR
0011 0303 0
T 2
0012 0304 0
0013 0305 0
0014 0306 0
LR
0015 0307 0
T 2
0016 0308 0
0017 0309 0
0018 0310 (1
LR
0019 0311 0
T
0020 0312 0
0021 0313 0
0022 0314 ~
0023 0401 0
T 2
LR
0024 0402 0
0025 0403 0
0026 0404 0
LR
0027 0405 0
T 2
0028 0406 0
0029 0407 0
0030 0408 0
0031 0409 0
T 2
LR
0032 0410 0
0033 0411 0
0034 0412 0
0035 0413 0
T 2
LR
0036 0414 0
0037 0415 0
0038 0416 0
0039 0501 Q
T 2
lR
0040 0502 0
0041 0503 0
0042 0504 lJ
0043 0505 0
T 2
LR
0044 0506 0
0045 0507 0
0046 0508 0
0047 0509 0
T 2
LR
0048 0510 0
0049 0511 0
0050 0512 0
0051 0513 0
T 2
LR
0052 '0514 0
0053 0515 a
0054 0516 0
0055 0517 0
T 2
lR
0056 0518 0
0057 0519 0
00513 0520 a

KEYBORD
DISK
PRINTER
02
lR
DUMMY
54 'DATA FOR SAMPLE PROGRAM'
56
24 '11243JONES HARDWARE
48 '27541123199 2375CASH
68 '47
47 2328123199'
24 '11352NU-STYLE CLOTHIERS'
48 '27987123199 8707CASH
68 '174
4000123199'
24 '11886MIDI FASHIONS INC
48 ' 15771123199 10722CASH
68 '214
214 10508123199'
24 '12874ULOOK INTERIORS
48 ' 25622123199 6795CASH
68 '136
6795123199'
24 '18274STREAMLINE PAPER IN'
48 'C29703123199 27403
68 '548
238 17055123199'
24 '23347RITE-REST PENS CO
48 '20842123199 1580
68 '31
1000123199'
24 '25521IMPORTS OF NM
48 ' 29273123199 79740
68 '593 1193 58547123199'

I'

24 '26723ALRIGHT CLEANERS
48 ' 19473123199 46200CASH
68 '924
46200123199'
24 '28622NORTH CENTRAL SUPPLe
48 'Y17816123199 7597CASH
68 '152
7597123199'
24 '2987rFE~GUSON DEALERS
48 ' 27229123199 6191CASH
68 '124
6191123199'
24 '30755FASTWAY AIRLINES
48 ' 26158123199 74272CASH I'
68 '495 16R5 72587123199'
24 '31275ENVIRONMENT CONCERN'
48 'S20451123199 2943
68 ' '59
1500123199'

Figure 19-9 (Part 1 of 3). EXAUT1 Program

Sample Auto Report Program; (EXAUT2).

19-23

0059 0601 a
0060 0602 a
0061 0603 0
0062
0604 a
0063 0605 a
0064 0606 a
0065 0607 a
0066 0608 0
0067 0609 a
0068 . 0610 0
0069 0611 a
0070 0612 0
0071
0613 OCASHRC
0072 0704 CJ
0073 0705 0
0074 0706 a
0075 0707 0
0076 0708, 0
0077 0709 a
0078 0710 t1
0079 0711 U
0080 0712 0
0081 0713 a
0082 0714 'J
OG83 oeOl 0
0084 0802 0
0085 0803 0
0086 0804 a
0087 0805 0
0088 0806 0
0089 0807 0
0090 0808 0
0091
0809 0
0092 0810 0
0093 0811 0
0094 0812 0
0095 0813 0
0096 0814 0
0097 0815 iJ
0098 0816 0
0099 0901 a
0100 0902 0
0101 0903 0
0102 0904 0
0103 0905 0
0104 0906 0
0105 0907 0
0106 0908 0
0101 0909 0
0108 0910 0
0109 0911 0
0110 0912 0
0111
0913 0
0112 0914 0
0113 0915 0
0114 0916 0
0115 0917 0
0116 0918 0
0117 0919 0

T

2

lR
24 '324578 SOLE SILOS
48 , 27425123199 1l005CASH
68 '220
11005123199'

T

2

lR
24 '37945HOFFTA BREAKS INC
48 , 18276123199 4723CASH
68 , 94
4723123199'

T

2

lR

T

lR

Sample Programs

.

24 '11243JONES ~ARDWARE
48·
27541123199 2375CASH
68 , 47
2328123199'
47
T

lR

,

24 '11352NU-STYlE CLOTHIERS
48 , 27987123199 8701CASH
68 '174
4000123199'
T

lR
24 '11886MIOI FASHIONS INC
48 , 15771123199 10722CASH
68 ' 214 214 10508123199'

T

lR
24 '12874UlOOK INTERIORS
48 , 25622123199 6795CASH
68 ' 136
6795123199'

T

'

,

lR
24 ' 18214STREAMLINE PAPER It\l'
48 'C29103123199 27403
68 '548
238 17055123199'

T

lR
24 '23347RITE-BEST PENS CO
48 , 20842123199 1580
68 ' 31
1000123199'

T

lR
24 '25521IMPORTS OF NM
48 , 29273123199 79740
68 '593 1193 58547123199'

T

1'

lR
24 '26723AlRIGHT CLEANERS
48 , 19473123199 46200CASH
68 '924
46200123199'

T

lR
24 '28622NORTH CENTRAL SUPPL'
48 'Y1781612319'9 1591CASH
68 '152
7591123199'

T

lR
24 '29871FERGUSON DEALERS
48 , 27229123199 6191CASH
68 '124
6191123199'

T

lR
24 '30755FASTWAY AIRLINES
48 , 26158123199 74272CASH 1 •
68 '495 1685 12587123199'

T

lR

Figure 19-9 (Part 2 of 3). EXAUT1 Program

19-24

,

24 '42622EASTlAKE GRAVEL CO
48 , 16429123199 2937CASH
68 , 58
2937123199'

24 '31275ENVIRONMENT CONCERN'
48 'S20451123199 2943

J 1 1 Ii

011 q

092C U
1 ,JO 1 G

n

O12C
Q 121
G122

1003 l.i
IG84 ()

0123

110') il

0124
G125
0126
u127
u 12 PI
U 12'1
u130

lu0,) CI
le07 LJ
100~ ,J
1004 Ll
IJL.: J
1 'HI ()
lu12 !]

U::02

,

h~

T

T

T

5q

1500123199'

LR
24
48

S'JL F SILJS
,' 32457')
27't2512319~ 110'JSCASH

6,')

,

24
4B
69

',7'J45i1C'FFTA B? EM;' S II\IC
, 18276123199 '17 2 3C ASH
, 94
4723123199'

24
48
68

G~AVEL CD
,'42622EASTLA~:E
16429123199
2937CASH
, 5:1
2'137123199'

;~

2')

l1C05123199'

LR

LR

,

Figure 19-9 (Part 3 of 3). EXAUT1 Program

OATA FOR

11243JUNES rlARDWARE
CLOT~IERS

11352NU-STYLE

1188bMIOI FASHIONS

I~C

12874ULOOK INTERIORS
~8274STR~AMLINE

23347RITE-BEST
25521IMPORTS OF
26723ALRIG~T

SA~PLE

27541123199

2375CASH

47

27987123199

8707CA$H

174

4000123199

15771123199 1072ZCASH

214

214 10508123199

2562212319q

136

6795123199

6795CASH

PAPER INC29703123199 27403
P~NS

CO

N~

CLEANERS

P~oGRAM

209421231'19

1590

29273123199 79740
19473123199 46200CASH

549
31

47

238

23281231'19

17055123199
1000123199

1593 1193 59547123199
924

46200 123199

28622NORTH CENTRAL SUPPLY17B16123199

7597(ASH

152

7597123199

29871FERGUSON DEALERS

27229123199

6191CASH

124

b191123199

)0755FASTWAY AIRLINES

26158123199 74272CASH 1495 1685 72587123199

31275ENVIRONMENT CONCERNS20451123199

2943

324578 SOLE SILOS

27425123199 11005CASrl

37945HOFFTA BREAKS INC

19276123199

4723CASH

42622EASTLAKE GRAVEL CO

16429123199

2937CASH

59

1500123199

220

11005123199

94

4723123199
2937123199

Figure 19-10. Input Data Generated by EXAUT1 for Auto Report Sample Program EXAUT2

Sample Auto Report Program (EXAUT2)

19-25

RPG CONTROL 'AND FILE DESCRIPTION SPECIFICATIONS

IBM

GX21·9092· UM/050'
Printed in U.S.A.

InternatIOnal Business Machines Corporation

1 2

Program

page[D0f_
Date

Programmer

Control Specifications

1~

_____Mrod~el_2T°-r~~

J;

!

line

Size to
Compile

~
5

6

ojll

7

8

9

g

6

0

l§

;;.

~

I

~112

Refer to the specific System Reference
library manual for actual entries.

Address
to Start

~

M
:

0

~
"0

!
"0

Zero
Plus Minus or
Blank

0;

u:

CALCULATION SPECIFICATIONS

Form GX21·9093
Printed in U.S.A.

1

Program

C

Indicators

~

.... "0 a::::
E ;, en

8 5·

~

6

7

9 10

:;
z
tin

1
2

o

3

o

4

C

o

5

C

o

6

C

o

7

C

.g

Factor 2

:;

75 76 77 7B 79 BO

of _

~~~~;~f:alion I

II I I I]

Length

:c

Arithmetic

Plus IMinusl Zero

Compare
ce S
1 >211 <211 =2
~~ Lookup(Faclor 2)is

'u -

Comments

z
OJ: High Low Equal
13 14 1516 171 8 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3 3 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051 52 53 54 55 5657 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

c
c
c

0

Operation

Name

~

8

Factor 1

2

OJ

Resulting
Indicators

Result Field

AL At

--'a:
::0
~j~

0

Page

Dale

0_

5

Field
Indicators
0

International Business Machine Corporation

Programmer

Line

]
e

I I I In

~~~~;~f:alion I

15 IG 17 18 19 20 21 22 2324 25 2627 28293031 3233 34 35 36373839 40414243 44454647 48 495051 52 53 54 55565758 f.9 6061 62636465666768 69 70 7t 72 73 74

RPG

IBM

Field Name

.~

z

.LI':-i

, RIl<

fooF
~T OWiD
I lJ :WIU

S

C P

S
S

~[ ~C

.

AI

~ ~

1

AK

M~ ~D

DI 171=
HE fO \fJIO
~!A ...

ttl
1f]
61

62

Figure 19-11 (Part 1 of 2). RPG II and Auto Report Specifications to Produce the Cash Receipts Register

19-26

I

75 76 77 7B 79 BO

of _

g

.,

.0

Filename
Position

4

I

Field Location

~

Line

2

OJ

Page

o

I

3

I

GX21·9094· U/M050'
Printed in U.S.A.

Date

r---

-

I

INPUT SPECIFICATIONS

Program

4

60 61 62 63 64 65 66 61 68 69 10 71 72 73 74

I

International Business Machines Corporation

Programmer

3

I

Sample Programs

11"

OUTPUT

RPG

IBM

-------.-------1'
Date
I

II-p_rog_ra_m

Punching

( Programmer

Instruction. f

-

o

'§
w

Filename

'Anfo

~
5

6

0

I

0

o

2

0

o

3

0

o

4

0

0

5

0

o

8

0

o

9

0

I

0

--

Skip

Output Indicators

u..

i~ ~~

>

---

Space

And

o

R

A~ro
7

8

9

a

Field Name

And

a
a:

;3 '"

a

Z

"'

I

I

Punch

f-OEL

f-

4

UM/050·

GX21·9090-

Printed in U.S.A.

If-G_ra_Ph_iC-I1--1f--f--,I---"I,If----1f--,lf--.I,1 Card Eleclro Numuer

§~I-o-'-~I--r-t---'I'---"'.I---i

Line

3

SPECI FICATIONS

International BUSiness Machines Corporation

·AUTO

~

i

:>
End

Commas

Zero Balances
to Print

Ves
Ves
No
No

Ves
No
Ves
No

II

Position

in

a:

Output
Record

...J

I

Page

2

OJ

75 76 77 78 79 80

~~~~;~f:ation I

of _

X = Remove

No Sign

CR

~

I

J

V

3

A
8
C

Z = Zero

4

0

K
L
M

2

IIIIII

=

Plus Sign
Date
Field Edit
Suppress

Constant or Edit Word

"'

Q:
1

2

3

4

5

6

1

8

9

10 11 12 13 14 15 16 17

1819 2021 222324 '

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4041 42 43 44 45 46 47 48 49 5051 52 53 54 55 !';6 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

0
f - - --r-0
I I
0
I 2
t----l-t--t--t-t-t-t--f--+-+··0
I 3
I 4

0

I

5

0

I

6

0

I

7

0

I 8

0

I 9

0

2 0

0

Z~

0

2.2-

r- -,-

~I"'I

TPD

Pt

'llS

\)

~

r'

\
FI=

£'

~

0

:"

Z3

0

1

2.'\

0

~

11~11

OMP

~

'il' H L

S'

0
lL It at 69 89 L9 99 g9 >9 £9 19 19 09 6g Bt ££ zr It at 6l BZ

a

9l gl .0 £l II IZ OZ 6181 i l 91 gl .1 tl II "01

6

B L

9

g

•

r

l

I

Figure 19-11 (Part 2 of 2). RPG II and Auto Report Specifications to Produce the Cash Receipts Register

Sample Auto Report Program (EXAUT2)

19-27

Calculation Specifications

*AUTO Specifications

The calculation specifications shown in Figure 19-11 are
included in the auto report program to perform special
operations that cannot be generated by auto report.
First, the discount allowed for each customer is
subtracted from the discount taken by each customer.
Indicator 10 turns off if the difference is greater than or
equal to $1.00. The remaining calculations subtract the
discount taken and the amount paid from the amount
owed.

The coding for the * AUTO page heading and the * AUTO
output functions is shown in Figure 19-11. Notice that
the Y edit code is used for the date fields (lines 10 and
12). Auto report generates a K edit code for numeric
fields when an edit code is not specified. No edit code
is generated for numeric fields when they are described
with a digit (1 through 9) or R in column 39. The edit
code 3 is specified for the INVNO field to suppress the
printing of the comma edit character.

The order in which these calculations are placed in
relation to the calculations generated by auto report is
shown in the auto report listing of the generated RPG II
source program (see Figure 19-12).

DIFF is printed on
more. Remember,
the printing of the
affect the printing
line.

the detail line only if it is $1.00 or
output indicator 10 conditions only
field on the detail line; it does not
of the generated field on the total

The J edit code allows zero balance to print for the
AMTOWD field.
Totals are accumulated and printed by auto report for
five fields as indicated by A entries in column 39.
Because an L1 control level is defined in the input field
specifications for REGION, which is added to the input
specifications for CASHRC (see Figure 19-11), regional
and final totals are accumulated for each field that has
an A in column 39. The total lines are identified by the
literals shown in lines 23 and 24 of the *AUTO
specifications (see Figure 19-11).
Figure 19-13 shows the output data produced by
EXAUT2.

19-28· Sample Programs

IBM SYSTEM/34 RPGII AUTO REPORT
U
N
0001
012
0002
H
0003 0101 I/COPY Fl,EXAUT3
PRINTER
FCSHRECRGO
F 132 132
OA
0004C
0005 0102 I/COPY Fl,EXAUT4
DISK
02 FCASHRC
IPE FI020 68
OOObC
0001C
01. ICASHRC AA 01 68 C9
5 ACCTNO
I
03 I
0008C
6
25 ACCTNM
04 I
0009C
26 300INVNO
05 I
OOlOC
06 I
31 360lNVDAT
OOllC
01 I
37
422AMTa~D
aOl2C
09 I·
41 5l2DISCAL
0013C
10 I·
52 562DISTAK
0014C
57 622AMTPD
0015C
11 I
63 680DATPD
12 I
00l6C
1 REGIONll
01 I
0011
1
OISTAK
SUB DISCAL
DIFF
62
01 C
OOlH
DIFF
COMP 1.0J
10 10
02 C
0019
AMTOWD
NETOWD 62
SUB DISTAK
0020
03 C
BAL
62
NETOWO
SUB AMTPD
0021
0204 C
0022 0301 OCSHRECRGH
*AUTO
'CASH RECEIPTS REGISTER'
0023 0302 0
01
0
*AUTO
0024 0303 0
0350
REGION
'REGION'
0025
'ACCOUNT'
ACCTNO
0026 0304 0
'0021 0305 0
C
'NUMBER'
'ACCOUNT NAME'
ACCTNM
0028 0306 0
'INVOICE'
INVNO 3
0029 0310 0
'NUMBER'
C
0030 0311 0
I~VDATY
'INVOICE'
0312 0
0031
'DATE'
C
0032 0313 0
DATPO Y
'DATE PAID'
0033 0314 0
AMTOwOJA
'AMOUNT'
0034
14 0
'OWED'
C
0035 0402 0
DISTAK A
'DISCOUNT'
0
0036
'TAKEN'
C
1031 0404 0
AMTPO A
'AMOUNT'
lJ038 0405 0
C
'PAID'
0039 0406 0
A
BAL
0040
0
'BALANCE'
0408 0
C
'OUE'
0041
10
OIFF
A
'EXCESS'
0042 0409 0
'DISCOUNT'
0043 0410 0
C
'REGION TOTALS'
1
0044 0411 0
'COMPANY TOTALS'
R
0045 0412 0

EXAUIZ

Figure 19·12 (Part 1 of 3). Auto Report Sample Program (EXAUT2)

Sample Auto Report Program (EXAUT2)

19·29

I.BM SYSTEM/31t RPG II .COMPILER

0010 H

012

EXAUTZ

0001
0002

0020CFCSHRECRGO
F 132 132
0030CFCASHRC
IPE Fl020 68

0003
0004
0005
0006
0001
0008
0009
0010
0011
0012
0013

0040 I*/COPY Fl,EXAUT3
0050 I*/COPY Fl,EXAUT4
0060CICASHRC AA 01 68 C9
0010CI
0080CI
0090CI
OlOOCI
o 110CI
0120CI
0130CI
0140CI
0150CI
0160 I

0014
0015
0016
0011
0018
0019
0020
0021
0022
0023
0024
0025
0026
0021
0028
0029
0030

0110 C
0180 C
0190 C
0200 C
0210EC
01
02 20EC Ll
02 30EC II
0240EC Ll
0250ECLl
0260EC Ll
0210EC SR
0280ECSR
0290ECSR
0300ECSR
0310ECSR
0320EC SR 10
0330ECSR

0031
0032
0033
0034
0035
0036
0037
0038
0039
0040

0340EOCSHRECRGH
0350EO
OR
0360EO
0310EO
0380EO
0390EO
0400EOCSHRECRGH
0410EO
OR
0420EO
0430EO

DISTAK
DIFF
AMTOHD
NETOWD

PRINT(R
IJISK

~3

1

DIFF

Sample Programs

5 ACCTNO
25 ACCTNM
300INVNO
360lNVDAT
422AMTOHD
512DISCAl
562DISTAK
622AMTPD
680DATPD
1 REGIONU

1)2
10

NETOWD
BAl

62
62

AMTOWR
DISTAR
AMTPDR
BALR
DIFFR

82
12
82
82
82

AMTOWI
DISTAl
AMTPDl
BALI
DIFFI

82
12
82
82
82

10

IP
OA
UDATE Y
PAGE l

16 'CASH RECEIPTS REGISTER'
8
131
127 'PAGE '

IP
OA
6 'REGION'
15 'ACCOUNT'

Figure 19·12 (Part 2 of 3), Auto Report Sample Program (EXAUT2)

19-30

EXAUT2
EXAUTZ

1
6
26
31
31
41
52
51

SUB DISCAl
COMP 1·.00
SUB DISTAK
SUB AMTPD
EXSR A$$SUM
ADD AMTOH1
ADD DISTAl
ADD AMTPOI
ADD BAll
ADD DIFFI
BEGSR
ADO AMTOHD
ADD DISTAK
ADD AMTPD
ADD BAl
ADD DIFF
ENDSR

AMTOWR
DISTAR
AMTPDR
BALR
DIFFR
A$$SUM
AMTOW1
DISTAl
AMTPDl
BAll
DIFFI

206

OA

EXAUTZ
EXAUTZ
EXAUTZ
EXAUTZ
EXAUTZ
EXAUT2
EXAUTZ
EXAUTZ
EXAUTZ
EXAUTZ
EXAUT2
E;oXAUIZ
EXAUTZ

EXAUTZ
EXAUTZ
EXAUTZ
EXAUT2
EXAUT2
EXAUTZ
EXAUT2
EXAUTZ
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2

EXAUT2
o
EXAUT 2
EXAUTZ
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2

0041
0042
0043
004't
0045
0046
0041
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0061
0068
0069
0010
0071
0012
0013
0074
0015
0016
0011
0078
0019
0080
0081
0082
0083
0084
0085

0440EO
0450EO
0460EO
0410EO
0480EO
0490EO
0500EO
0510EO
0520EO
053GEOCSHRECRGH 2
OR
0540EO
055JEO
0560EO
0510EO
0580EO
0590EO
0600EO
OblOED
0620EO
0630EO(SHRECRGD
0640i:O
0650EO
0660EO
0610EO
0680EO
0690EO
0700EO
0110EO
0120EO
0130EO
0140EO
0150EOCSHRECRGT 12
0160EO
0110EO
0780EO
0790EO
0800EO
0810EO
0820EOCSHRECRGT 12
0830EO
0840EO
0850EO
0860EO
0810EO
0880EO

29
46
56
61
80
92
105
118
130

'ACCOUNT NAME'
'INVOICE'
'INVOICE'
'DATE PAID'
'AMOUNT'
'DISCOUNT'
'AMOUNT'
'BALANCE'
'EXCESS'

14
45
54
19
90
104
116
131.

'NUMBER'
'NUMBER'
' DATE'
'OWED'
'TAKEN'
'PAID'
' DUE'
'DISCOUNT'

1P
OA

01

10

REGION
3
ACCTIIJO
14
31
ACCTNM
INVNO 3
45
56
INVDATY
DATPf) Y
66
AMTOI'IDJB 80
OISTAKKB 92
MHPD KB 105
KB 118
BAL
DIFF KB 131

Ll

AMTOWIJB 80
DISTAIKB 92
AMTPOIKB 105
BALL KB 118
01 FFl KB 131
61 'REGION TOTALS'
LR
AMTOWRJB 80
DISTARKB 92
AMTPDRKB 105
BALR KB 118
DIFFR.KB 131
61 'COMPANY TOTALS'

EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUTZ
EXAUT2
EXAUT2
EXAUT2
EXAUTZ
EXAUT2
EXAUTZ
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUTZ
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUTZ
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUT2
EXAUTZ
EXAUTZ
EXAUT2
EXAUT2

Figure 19-12 (Part 3 of 3)_ Auto Report Sample Program (EXAUT2)

Sample Auto Report Program (EXAUT2)

19-31

(0
I

W
N

en

Q)

3

!!
c
...
It!

-0

ii1
3
en

ACCOUNT
NUMBER

.:..
to)

CD 0

"tJ

REGION

to

"0

a
co

CASH RECEIPTS REGISTER

Ie

...c

"C

S.
....

0

1
1
1
1
1

11243
11352
11886
12874
.18214

ACCOUNT NAME
JONES HARDWARE
NU-STYLE CLOTHIERS
MIDI FASHIONS INC
ULOOK INTERIORS
STREAMLINE PAPER INC

INVOICE
NUMBER
21541
21981
15111
25622
29703

3

INVOICE
DATE

GATE PAlO

12/31/99
12/31/99
12/31/99

12/31/99
12/31/99

12131/99

12/31/99.
12/31/99

12/31/99

12131/99

REGION TOTALS

:t>

AMOUNT
OWED

r

PAGE
OIS:OUNT
TAKEN
.41

AMOUNT
PAID

BALANCE
DUE

23.15
81.01
101.22
61.95
274.03

2.14

23.28
40.00
105.08

2.38

110.5!

101.10

560.02

4.99

406.86

1-.8.17

10.00
585.47
462.00
15.97
61.91

5.80
200.00

EXCESS

DISCOUNT

41.07

61.~

c

0'
::c
It!

"C

...~

(J)
QI

2
2
2
2
2

23341
25521
26723
28622
29871

RITE-nEST PENS CO
IMPORTS OF NM
ALRIGHT CLEANERS
NORTH CENTRAL SUPPLY
FERGUSON DEALERS

20842
29273
19413
11816
27229

3

"C

0

12/31/99

15.80
791.ltO

12/31/99

12131199
12131/99
12131/99

12/31/99

12/31/99

R.EGION TOTALS

CD
'"C

iil

3

3
3
3

iii

3

Ie

12/31/99
12/31/99
12/31/99

30755
31215
32451
31945

FASTWAY AIRLI~ES
ENVIRONMENT CONCERNS
B SOLE SILOS
HOFFTA BREAKS INC

26158
20451
27425
18276

12131/99

12131/99

12/31/99

12/31/99

12131/99

12131/99
12131/99

12/31/99

11.93

462.00
15.97
61.91
1,413.08

11.93

1,195.35

205.80

742.72
29.43
110.05
41.23

16.85

125.81
15.00
11 O. 05
41.23

14.43

929.43

16.85

898.15

14.43

1.""90

368.40

1.90

1.90

X

:t>

REGION TOTALS

C

~

~

4

42622

EASTLAKE GR'AVEL CO

16429

29.31

29.31

REGION TOTALS

29.31

29.31

COMPANY TOTALS

2,931.90

12131/99

12131/99

33.77

2,529.73

SAMPLE WORKSTN FILE PROGRAM (ORO)

Functions 'Not Used in Sample Program ORD

The sample program ORD creates records for the disk
file TRANS (see Figures 19-14 and 19-15). The display
format ZCNUM prompts the operator to enter a
customer number. The display format ZSHIP displays
the customer name and ship-to headings and fields, and
allows the operator to change the ship-to fields. The
display format ZITEM prompts the operator for the item
number and quantity on line 22 of the display screen.
The display formats SHOWITEM and ZITEMHED display
the item number, quantity, description, price, amount,
and total headings and fields. The ZITEMHED format
also requests the operator to enter the next item number
and quantity (line 22).

The following functions were not used in the sample
program ORD:

A code 2 indicates that the customer name and address
record is written to the TRANS file. A code 4 indicates
that the ship-to name and address record is written to
the TRANS file. A code 6, which is created when three
items have been entered, indicates that the items record
is written to the TRANS file.

• ACQ operation code. The ACQ operation code is
used only to cause a specific device to be allocated
to me program.
• N EXT operation code. The N EXT operation code is
used to force the next input record to come from a
specific device.
• READ operation code. The READ operation code is
used to provide input from a WORKSTN file on
demand. When you use the READ operation code,
you must set on LR when the file is at end of file.

The following command keys are allowed in this
program:
• Cmd key 1 (which corresponds to indicator KA)
completes an order and:
- Creates a final code 6 record, if needed
- Creates a code 8 (total) record
- Enables input to allow the operator to enter the
next customer number
• Cmd key 2 (which corresponds to indicator KB)
cancels an order and:
- Creates a code 0 (cancel order) record
- Enables input to allow the operator to enter the
next customer number
• Cmd key 3 (which corresponds to indicator KC) ends
the program and updates the HEADER record to
contain the group number of the last order written to
the disk file TRANS.
The following error messages are displayed for the
program: CUSTOMER NOT FOUND, ITEM NOT
FOUND, and INVALID COMMAND KEY.

Sample WORKSTN File Program (ORO)

19-33

Display screen format ZCNUM

Display screen format ZSH IP
Display screen format SHOW ITEM - - - - - - - - - ,

01

02
03
04
05

11

12
13
14

15

The headings ITEM, OTY, and TOTAL are described by
the display screen format ZITEMHED. The fields TOTAL,
ITEM NO, and OTY are described by the display screen
format ZITEM.

Display screen format ZER ROR. The constant for the
error message is defined on the RPG II output specifications (see Part 10 of this figure).
Display screen formats ZCNUM, ZSHIP, ZITEM,
ZITEMHED, SHOWITEM, and ZERROR are contained
in the format load member ORDFM.

Figure 19-14 (Part 1 of 11). Sample Program ORO

19-34

Sample Programs

GX21·9253
U1M 050·
Printed in U.S.A.

System/34 Display Screen Format Specifications
~

-;:

8

Sequence
Number

I

~

1234 5 6

s

~
ii g

~ ~

"O§

c

,.
z
51 ~ i~
e :5 ~: ~ -;; ~ c5 ;;{ ~ 8
5~ ~ ~ ~a § ~ ~
...
Vi Z~..Ja::a::~ c5l Ww

1':-

.~_

;5

t~

_~

Format
Name

·No. of sheets per pad may vary slightly.

f-Er:n:7te::-r-r-1--r-,w:..:.:.:sU:....O:.:n...:.ly=----,----~

>
~

a
0

!

~

~

~ ~"'~>

0

Mode

1

Review

3,.s.u~ce
"'~

Reserved

a: _

Insert

~~:rd
~I z:

~~:;rd

Key Mask

:::
Identifying
Identifying
Reserved
gl-l_nd,-ica_to,-rs_l-l_nd,-ica_t_O,-rs---l

"0

§ 'EI~ ~ ~ :~I~
Vlwwa::a::d:d:

a

l

~

a::
'"
W
7 8 910111213141516171819202122 23 2'25 2627 28 29303132333435 3€ 3738 39404142 344 45~647 8 49r.;0 5152535455565758 59 606162 63iE;4 65 66 67 68 6970 71727374757677 787980

II

I

I

II 1

Starting
Location

Field
Name
Sequence
Number

I~
I.!
~

~T

~

:5 a

wsu
Field Name

Field

Length

~~

~

z

"".!5_;;.

..J

:I:

~

i ~

~
~

c

~

w ~

>

~

E

~

>

'E ~

1[1

a~l ~ ~ ~~i

0

~ ~

a. ~

~ ~ ~ ~ ti '= a
8 ~ ~ ~ ~ ~ ~ g ~~~
~~2
'C

~

~

L:

t

:I:

a;

Reserved

(!

[

~ ~ -a: ~: >

u:

.£ ~8.i:f.

IQ)
I!-

Q.I...

>

"U

i

c

~

g

Constant Data

j

g

8

c:

J

z:J8

8123456789101112131415161718192021222

7 8 9 101112131.151617 18 19202122 23 2 25262728293031323 3435313738 3940.1 42f43 U 45 4t 474149505152 53 ~4 55 5€ 57585960 61626364 65 66 67 68 69707172 73 74 75 7677 78 7980

1 2 3 4 5 6

D 1~1111r.1.£

It bl

0;
~

;;;

~

c
.s::

:f.

:i:

C

i3.

8.

~

0;
~
.>C

a;

>!
g.
~

~

c

Reserved

J!

a::

c

c

.3

§8
.~

c

Constant Data

I-

5

3738 3940 4142 3 " 45 4t 47 4S

I~

505152 53

~4

.g
~

.3
1 2 3 4 5 6 7 8 9101112131415161718192021222

55 56 5758 59 60 61 626364 65 66 67 68 6970 7172 73 74757677 78 79 80

ilZl1lf

I

D

Mode
Record

:~~7~~~i;'9

.B

>

.-=

'0

~8
..J
:I:
0 ;EECl:;:;J!< 7 8 910111213141516171819202122 232 25262726293031323 3435

zli

Insert

Mode
Record

I

8

';it

Length

Review

-;:

f-'"[
]a

Field Name

I I

Starting
Location

I--_ _ _-.-~ Field

...

~"
.§

"0

t 2'4

Field
Name

1 2 3 4 5 6

Enter

LL
z2...Ja:a:~ ~ ww co
w
0
~
V)wwa:a:~Q:
7 8 910111213141516171819202122 232 2526212829303132333435 3.€ 3738 3940.142 344 45~647

S ~~~11P1

Sequence
Number

·No. of sheets per pad may vary slightly.

lL~lLlY

o

o
D

It:

ofJ
D

y

o
D

f

o

lAl<

v

l~

i
It
The order in which these fields appear on the screen is not
the same as the order in which they appear in the RPG II
output record (see Part 11 of this figure).

, Figure 19-14 (Part 2 of 11). Sample Program ORO

Sample WORKSTN File Program (ORO)

19-35

System/~

>

8
~

Sequence
Number

1 2 3

I~

4 5 6

~

Format
Name

18

.~_

~

~

~
Z::::;
"0

1 2

3 4

~

5 6

'C

~ .8'"
51 ~ >~

~..
-

o~;U ~ ~ ~~

§

~

g 'i

~ EE

"5

~j g E~8 ~...

:§

rE~n~te~r--.,-r'-----~-'~------~

~""

5

i.i:

8

0

Mode
Se...9..u.!!'ce

i.i:

:>

a f

Reserved

:g

~~ ~

Review

~

Insert
Mode

Mode
Record

......,;.,----~r-

is'''
-.;
_~

.~

Record

Identifying
Indicators

~

Field Name
7 8

-;.

·i

-T;5
F Id
I n9 th

4;
.c

9 1011 1213141

o r~t='ftf
o JJ.!TY

~

-g

~~

8
0

i ~~!ji~~

5

~ ~~~~i~i ~

:z:

;, ~
..

ox:

2535455~657585960616263~656667686970 71727374757677787980

1
g

a

~ ~"

~ij]o : ~ i ~, :
~E~

w8ct

-

.c

It

:I:

3.

8.

>

~ ~

iii

Z

_

ox:

c:

1?

Reserved

I

el!
~

~

1

5

Constant Data

~

.g
8

c:

:l 8

8,234567891011,2,3,4,5,617,8,9202,222

16 17 18 19 20 21 22 23 2 25 26 27 28 2930 31 J2 3 3435 36 37 38 3940 41 42~3 44 45 46 474S 49505152 53 ~4 55 56 5758 59 60 61 626364 65 66 67 68 69 70 717273 74 757677 78 79 80

3Y

:1

IY
y

2

o f"~ ("~

Key Mask

~ ~ ~ .21~

w ~

>

~~~

~ ~o~

~

: 3:

~~

Reserved

~ ~ :;; ~I.? gt---..---r--+--..---r--f
~

J!

Identifying
Indicators

YI

Starting
location

~~

WSU

J!

I~

M

Field
Name

-,~o

"No. of sheets per pad may vary slightly.
WSU Only

~ >
~~

...
 W W ox: ox: -

;5
:l
~~
C ,,2
8~

i
>
:: c:

u.w
~

8.

B

>

~~~

~ ~i ~j ~~~

w
0

:>

u

c:

0
;;

1.1

g
~

-.;<1:
""

a..L'E

O~~
!lIoe::

o

"-.;
Ii:

>
;;;

e

c:
.c

"-.;

i.i:

i

~

8.

1

3.

eel!

c:

Reserved

~ ~

e
;;;
~ ~ B 0
6? ~8.i ct: :i iii
a:
0
7 8 9 1011 12 1314 1516171 81920 2122 232 2526 2728 2930 31323 3435 363738 3940 41 42 34445464741 45505' 52 53
0>

e

o
o
o

o
o
o
o
o

~

0

:I:

.g

!!!.

Constant Data

8

:l8

8'23456789,0'1121314,5,6,7,8,9202,222
~4

55 5{ 5758 59 6061626364 65 66 67 68 69 70 71 72 73 74757677 78 79 80

17 3rt

111Y
17~ ';y
17~ ~ y

0

~g

n

It

111.1 111 1I 1111

St.~l

I

IV

ITI ~~

I

" hlTA

Figure 19·14 (Part 3 of 11). Sample Program ORO

,l
19·36

Sample Programs

System/~4

GX21·9253
U/M 050'
Printed in U.S.A.

Display Screen Format Specifications

"No. of sheets per pad may vary slightly.
WSU Only
Re>iiew
Mode
Record
IdentifYing
Indicators

Sequence

Number

Insert
Mode
Record
Identifying
Indicators

Reserved

Key Mask
'0

a:
1234

849,05152535455565758596061626364 65 66 67 68 6970 71727374757677 78 79 80

I I I I I I I I I IJ II I! I I I 1111 l
Starting

Location

Field
Name

I - - - - - - . - - - i Field

Sequence
Number

!j
1 2

3

r-T

4 5 6

~oJ ~>
z

WSU
Field Name
7 8

a

i

a.U:~ ~

~~~

~

LL

c

~8~

a':

~~2 a

6

:I:

~

>

"ii 1434445464748 •

9 '0 t1 12 13 14 15 , 6 17 18 19 20 21 22 23 2

c:

~

Reserved

a

>.§

't:I

8
1

23456789,0"'2'3'415'6'7'8192021222

50515253,455565758 59 6061626364 65 66 67 68 69 70 71727374757677 78 79 80

'I
I~

D~li~

IY

o

I

~

Format ZITEM clears no lines (00 in columns 19 and 20 of
the S specification). Because ZITEM clears no lines, it must
output a blank field on line 24 to clear the field from the
format ZER RD R (see last line of ZITEM).

The length of the field QTY, which is defined as 5 in
RPG II, for the display format is increased to 6 to allow
for the sign position.

The format ZER RDR does not clear any lines (00 in
columns 19 and 20).

\
System/~4 Display Screen Format Specifications
Sequence

!

Number

j
1

2

J

4

5

G

x
,
-or mat
lame

7 8

9'

~
5l

~
C

-

IV

_

5~

~

~.J
0

S ........
...J

§ _
u..
V')

'0

-

CUd
§uo ~ t ~~
z_...Ja:a::~

j
123456

§ E

0

~
u:::

5.

~

'C

__

U

-g

c.

.:

>

g-

E

;;

§

~

~

E

8
~~
ww

:J

CD

:J

g.

~

f}

Reserved

0

w

WSUOnly
Review

I-Ser'!~n~
~

~~:rd

Identifying
Indicators

Identifying
Indicators

Reserved

Key Mask

= ~I ~ cul-...,...-,---f---r---.---l
g
'01,

>

§ ~ ~ ~ ~ gl~
U3WWCCa:a..a..

V')

Insert

~~:;rd

1

2

WSU
Field Name

I I I

Starting
Location

Field
Name

~
~

~r;;~~

~

3

1

2

'0

3

a::

"'2'314 1516 17 18 '9202112 23 2 2526272829303132 JJ 343531 J1 J8 394( 41 42fU 44451"647 8 49~0 5152535455 56 ~758 5960 6162 631s< 65 66 67 68 69 707172 7374757677 78 798C

II I: SI7"~~IKld~ I I ~~

Sequence
Number

~

«

0 _

5: ~ ~~

IV -

.8: ~ E ~

:5
fi

GX21·9253
U/M 050·
Printed in U.S.A.

"No, of sheen per pad may vary slightly.

~~

~~

~~~:th

>-

i ~~ ~ ~ j
1 6;B
~ i.:_~a.~~~
rf. . 6_:i g ~~28.i
8 ::; ::;

J~

W

>

c.

,fi

~

~~

u:

'E

1 1

II 1I I I I I I I 1I 1

0

~.;;

6 -0~ a:~ u:
111

"

0
:I:

I III

"x u
c:

r----r----a..

i

I I I

.E

~:t

0

,fi

0

.t

~

c
c

u:

>-

~

a.

.§

c

a:

::J;3

c]

iii

z

!

Reserved

~
C

In

.c

I

3.

Constant Data

C

~ 5

8

c

<3

0
:::J

.~
1 2 3 4

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2

7891011121314151617181920212223225262728293031323 3435363738 3940414214344 45 4647~8 4950515253,45556 5758596061626364656667u86970 71727374757677787980

I I 1I 0 ~ S~ I I I 1 l2J9 Jt ~ Y1
I I;'
L-J,.·I-I-I.II_..L-D-'
. . . . . --'.I----'-I-L-.J.
I!----'-I-'--'I----'-.-"-I_J J ~.l.._./.._.L--'---'IL~_.L....L--'--.L-'--'-~~I'---L-.L..JI

Y

L..l.-.l-.L....L-I...-.L..-'

I I T
I IIII

I I I I I I I I 1I I I I I 11111
I III IIII1IIIIIItIII

Figure 19-14 (Part 4 of 11). Sample Program ORO

Sample WORKSTN File Program (ORO)

19·37

The format load member contains six display screen
formats.

Control Specifications

-

H
Line

3

4

5

Size to

Size to

Compile

Execute

9

10 11

I

Refer to the specific System Reference
Library manual for actual entries.

12 13 14 15 115 17 18

II

I

I;

~ i 1.1111111111111111 11

It i
File Description Specifications

-

File Type

F

File Addition/Unoro red

Mode of Processing

Extent Exit
for DAM

Length of Key Field or
End of File

of ReeD!!."! Address Field
Record Addless Type

Filename

SeqUF.nce

F:le Format

Type of FIle
Organization

..J

Device

Symbolic
Device

UJ

Name of
Label Exit

Number of Tracks
for Cylif'"lcier Overflow

Number of Extents
Tape
Rewind

Storage Index

Lme

~
Condition

z

Ul.~

~

The WORKSTN file is specified as combined (C in
column 15) and primary (P in column 16).

Figure 19·14 (Part 5 of 11). Sample Program ORO

19·38

Sample Programs

/

The WSID field will contain the work station ID for the
display station. The SLN field will contain the starting
line number for the display screen format SHOWITEM
because a variable starting line number (V in column 17 of
the S specification) is specified.

Indicator Summary
Circle Indicators Used:

F*

Indicators

Note: All indicators are not valid with III syst!ms .

Genera~aton
01
02

~

(10

Line

11

Control

03

IV

12

>

a: "

06

07

08

09

L1

14

G)

16

17

18

19

H.lt Indic.tors
H2
HI

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

(90

91

92)

93

94

95

(96

97

98

c '"

~lE

§
~

a
as
3'

5

6

7

o

1

o

2

F •
F •

o
o

3

F •

4

F

o
o

5

o

7
8

o

9

9

10 "

H

1 0

F.

11

F •

fB

1 3
1 4

F ..

U2

d

~

U3

L5

L6

L7

L8

L9

H5

H6

H7

H8

H9

U4

US

U6

U7

U8

&A

KB

Kc"," KO

KE

KF

KG

KH

KI

KJ

KK

KL

KM

KN

KP

KG

KR

KS

KT

KU

KV

KW

KX

KY

Overflow Indicators
OA
08
OC

00

OE

OF

OG

OV

§~

99)

~ecial Pt(f0se In~~ators MA

1115

F •
F ..

LR

..

FU Nlc tTl ON OF IN 01 clA1r0 RS
- I_I ...liN
11=11 IRSh" rrll "Is F~~ ITI~ IlS
INI:~ IGIR ~IU P, Cllu 11PIUIY !Clu lSI'
INtl~~ IEIR I"!~
Iclu1STItiM ~I~ 1\1111 Mia ICR III~ pluIT, Ic!u ll:P lui,. ~~!A ~c 4
k:.~ lIN
1'01'" III'" rill Ill,. I~~ -IG ~TI'4
I"~ ~E 14
IIh' IEre, -G h';'/ rtN Ipll' 11IJ '~I~ IC~\tj IlIHIE. Ith' EM ~IN~
II'II~

1"\

Ir t"11

1-

1_1-

I-

lUI'" ",1M

II

Sis ISleIRle e~j
I

IFblR NE ~IT

IFR IQ~I~ ~~Ic; Ic:cleuIRIR I;D
liN I\IIAIllllt1 c:o ~'~ ~~i' IKIEri
lIlT I~IM INlorr IFlo llN~
IC.IU I~'\ I\oIil"' i~I" NIC~T Fb UINttJ

~
~

11

F .'
F ..

L

' a

11

F •

Ul

L4
H4

r"Il~l"

i1

F •

1 5

C

1
l1

*

H3

13 14 15 16 17 18 19 20 21 22 23 24 25 26 21 28 29 JO 31 32 33 34 35 36 37 J8 39 40 41 42 43 44 4S 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

N~

F •

1 2

12

10 F

F •
F •

6

o

8

0

L2

External Indicators

60

I

Indicators
L3

05

~

~

Le~el

04

~11

1'112

F ..

h"P orr IIlc /Pm 141Q IQlalv
IN IEIEb rtlc11"11 .. Irlu
.,
~I) lalft
Illc; IF 11Ill\
11'1.0. I.. In 1\:h'Ir:;
leI)
~INln lAIR IcIA¥ 11B IN bh" I~II" 11""11
I
..
~Io IRI.c 11r.1 lUll I.. ~II I\.III~ I=:J
I...
IAI ...
~I~
1w;lllE Ill,. I\J~ ICII IT In Ills: 1c;1' IA~ ,.11 l~lG ~r:~ IGiR Jolu PI)
..
tIlf IM I(IT I~I" IAll 11m IIIF ~IT lAIR rrll IN It; IM~~ IGIR bu pi)
lfolJlN Il~m ~F 1.1lo/B Illl INru ~IL lIlt IIF ~nlT ~I IPI~ lEI. INI6 Irlo 110. .. Irl ,
I-

~I

F •
F •

1....

1. . .

I_I_~

I ..

Extension Specifications

E

Record Sequence of the Chaining File
Number

I-Line

Number of the Chain'jng Field

To Filename

;:

:

From Filename

~

3

4

5

6

011 I

E

2

E

01 1

of

Table or
Array Name

7

8

9

'0 "

Entries
Per
Record

Number
of

Entries
ppr Table

Length
of
Entry

or Array

c 0

~ ~
a: ~

i11

Table or
Array Name

Length
of

(Alternating

Entry

Format)

~ a

]~

Comments

ill

t2 '3 '4 '5 '6 17 '8 '920 2t 22 23 24 25 26 27 28 29 30 3' 32 333435 36373339 4041 42 4344 45 46 47 48 49 50 51 525354 5556 57 58 59 60 6' 62 63 64 65 66 67 68 69 70 7' 72 73 74

I I /I /I I I I I /I I /I I IJCI~ I I I II ~ I'fJIJ
I I 1111111 III/LIIIII I I III I I

I!i I

!

,,--U~JI

II
Ii

/I I I I I /I 1 I I I I I I :
II LL: I I I II i I I I
i

!

This array is used to output three ITEM, QTY, PR ICE,
and DESC entries.
Figure 19·14 (Part 6 of 11). Sample Program ORO

Sample WORKSTN File Program (ORO)

19.39

Indicator 10 identifies a blank record.

The record identification codes are output as constants
in the formats and are used to control which set of
calculations is executed.

Input Specifications

I

r-Filename

line

~z

Record Identification Codes
il

~
~

1l

t;; ~fo

3

4

o

1

5

6

7

8

9

10 11 12 13 14 1516

t4~

II.tJj

o

2

I

o

3

I

o

4

I

5

I

o

6

I

o

7

I

o

8

I

o

9

It~
I

I~

1 2

I

1 3

I
I
"I

~

~~
~

3

U

t

l

Position

~e

o~

zu

19 20 2122232' 25 26 27 2B 29 3031 J233

\

\[12

'CS

l(~

tI

Nlc;
~Is

Ilrl

tJlS

~t1

Iv

!A

/

V
~

~

tI

V

Field Location

0

ii

t
0

V

t;

Vl

t

§ ~l

0::

From

.f

To

~

-'

ii:

I

0

V

17

I{UI~

IN

~ 2~i7

IV ..

II

f')1'

I

it

11111- JIlIN'

11~~1tl; II T

2.~~

l1
12

I lit "'IN

1

~ "I

1.(

I~

,. t:

1 6

I

17

IrT

1 8

I

1 9

It

2 0

I

~

IUI~ .\IN~

2

1

I

Ij!Q~

IUI:J , lAin

2 2

I

2 3

II~ lErt' ~,L~

2 4

I

2 5

I

2 6

I

2 7

I

2 8

I

2 9

I

3 0

I

3

1

I

3

2

I

3 3

I

3 4

I

3 5

I

~~

~2

S

(]1

~

ICIE

tJl~

IC~

~

1111~l

l:lld

12~~

~II ~

SHI PI~ID
,. Slll)

1IPfI

Ie'

I

CaDlE

I

~ I~EQI~

~15

[IV

II

~~

1

II

The data structure KEYHLO allows manipulation of the
fields within the key for the TRANS file. The data
structure containing IGPOOO is used to build an element
for the array IGPO.
Figure 19·14 (Part 7 of 11). Sample Program ORO

..
111111:: 1("11"

~

Sample Programs

1<1t'

r:y

II

I

19·40

5

~I~

RIE CiD

Field
Indicators

0

:243

.~ "'i)

] "-.;:
g S'gt
8 ~~
C

~"

j
"0

Zero
Plus Minus or
Blank

"ii

u:

35 J6 37 J8 J9 40 4142 43 44 45 46 4 7 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 6354 6566 67 68 69 70 71 72 73 74

11

IRA NS

~

c:
0

~

~

CD

~

~,~

Field Name

in

0;

V

/''''

1\

1 1

1 5

Position

j

NS

1 0

1 4

"0

It 11

N~

o

2

~

j ~

ro 1-.A

1

11

1 !a Tr/
1 ~ IRl 1'(:

fq~

IIlE~~

Calculation Specifications

C
I---

Indicators

Resulting

Result Field

Indicators
Arithmetic

Operation

Factor 1

Factor 2
Name

<;

Length

High

Ole

4

C

1.

a

C

K!j

I

I

.
1

I
I

C

1 4

C

1

5

C

1 6

C

1. 7 ~

C

I:

• c

ME

•

".!:II"

Low Equal

54 55 56 57 SA 59 6061 62 6364 65 66 67 6869 70 71 72 73 74

!

I

to

~

II

roo

~::
!

N'9 ; i GR!OUPri
1 3

Comments

1> 2 1 < 211 = 2
LookuplFactor 2hs

•

Z

9 10 11 12 13 14 15 16 17 18 19 20 '21 2'2 23 24 25 26 27 2829 3031 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5051

a

Plu, IM,nu,1 Zero
Compare

I

I

Iii i

EN!D
fo

rf:)

i

ltlE

IA . I 1

Ei :~)Ri

~

iI

KIIJU

I' ' : ' ;
1 1....P1S !
I

GRO; 1.1'1
!.

~

i

i
II Kt.! DOlES rrtH E
I

i ~

Iii

i

1.. lllK ~ll

.~
.

TI MiE

I~E

J

~

~i

no

I~ 'r' ; i
~"l ~: 11l Co t!)l : :

ij

ItJttUll ..... 1'\ I IN II"

I
!

1:8 C. Nt~
1 9'

C

2 a

C

2' 1

C

1----- - [-I- •. -.

~~+ =9YOj

r+-- - --t- '.JI '
2 4

C

!

2 5

C

!

~-t--+--j.

(Calculation specifications are continued on the next page.)

Figure 19·14 (Part 8 of 11). Sample Program ORO
Sample WORKSTN File Program (ORO)

19-41

(Calculation specifications continued from the previous page.)

(, 4 cE Nin::l InR
I. ~

~~

~ 7 c
~ g c

I !

-r-

I~lfr- c

ZrP

c

I{J:' \'

i

I
,! '

c
c

I

E'N DcrOB
:

ii, i

:

:

I

KEY

c

e l i

71s

c

i

7'~

c

78

c
c

1
:I

l' t.,,!)

:
;

I:!
"!! i " ,

7~

177

OR

(: ..

E 'S,R
i!

i ;
:
'1 2 c; !'
, i ~ S[iD! I !
713 e , i ,
l'

I

I
I I

:

i,
I

N

.. ~.Dj

;O~ rE,:

I:
I

:~ ~p:

~:

I

'

KEYi

IFi rn:R I
~A'

lS'

:

: :

!

I:

I

I

311

I

!

i

I

I

i

[

f

I

!

I

r

'

I I

!

I

I

j!:

I

H1
lil :

!

i

I

:

!

I

;(Et-1I~ IS "~on
EA~M R~C.
! i
:
I

rrHEi

111Nt:

t'~\.

It- ~~i1-S

I
i

I

I

I

I

I

!

!

I

:

Figure 19·14 (Part 9 of 11), Sample Program ORO

",

Sample Programs

:

I

i
I

(Calculation specifications are continued on thenext page.)

19·42

i

WI:;
lie

;

I'!

G: :01># : 'PHOtD

iyu I

i!;:-: 0, f-

i

i

, I

:

"

.

/

..

I

:

I

(Calculation specifications continued from the previous page.)

I

_~

!:

-L--.I

I
!

i,'!

1'1

I

i

i i
--- +- I
-+ -+-. --+------+---+--..-I-t-+-i-+-jH
I

i,

t:
iii

:

i

OUtput Specifications

(Output $pecifications are continued on the next page.)
Figure 19·14 (Part 10 of 11). Sample Program ORO

Sample WORKSTN File Program (ORO)

19·43

(Output specifications continued from the previous page.)

9111 ,-I
i - ,i-I [ : I
~~
, . I1 I!
._~~. ',- ; j,: +--·-;--·,---r-+·-1--~+J·i--+-+-+-+-\-~----+-~-+-+--l
' :~ . ~:'E'l
i I I :
'I
1-2-6--+0-+-~-...........-~-I-+++-+-i,-+-~ f--T-r f--+-- ~- i . ~ ~ + +- -, -. - f--+
1 ,'-t-+--~+-+--+,
'
2 7
0
___ ~-_= I) AID D
I
1!21Nq <1 i- - -~ ---t-r
i : T'-~T-t' -,-+,--+-+--+--+-+-+-+-+--+--I-+---I-~+-'--t
f------+--+-_
~
, !
lJ,.-,,"
',~, ---~I---+--~,'
'+-+-" +-, -,+- ..,.-,+-+-+-+-+-+-+-+-+---t-

+

j:

I

:

1

lioiItAtl

:

'.KC N9q
:;!

-- ~fr,,--j ......,~
_+-

1-

... ~, .,.

~ i IT ,---GDU:'~,t\
-;r,' a.~.

,ltn:Ni15 ..... _ -U~.
I' i
,; ~E'yr I
I· I : - --+ i

'~-,

~w

I+!, r -~~:; i~ ~

+

B·t If~-~r.,·t--t--·-:-·rt-~4+---+--+--+"';"'+-+-+--+--+-+-+-+-+-+--IH
:~I-

-

'

t!! :. 1 I

:

;.1

~

·ti-.-I- ,t,--l.-

Customer number as first screen

•

Customer number precedes ship to'

•

Ship to or item precedes an item

•

Item precedes displaying the item

L A~~

!,

:

i

Sample Programs

i

.

'--+---+-+-+-+-+--+---I-+-+--+-+--t-+---+-i

-'-t!

:'

,
j

-+--+-++-++++-++-++--l-HH

HI

!

lrli! TTt-tf~-+i-1i-l-+-li-+--+-j-I-+-+--+I--+--I-+-+-+--+--+-+-+-+~
'1

i

IllLLLli.~i-'---J'---L--'---.L_.L...JL......L. .

The WOR KSTN error record (ITEM NOT FOUNLJ) is separate from the preceding order.
However, because the ZE R RO R format allows input, the correction can be made as if
no error had occurred.
Figure 19·14 (Part 11 of 11). Sample Program ORO

','

; '1Tf'-~' + I·t -li~-+---:--+-+-+-+-I--++-t--+--++-+-+-+-+-+-H

Records output to the WOR KSTN file are conditioned on a successful (N99) input of the
previous record type:
•

1

ii,

!;
-t. 1i
ill
i~+-I+-,!- 1 '10~~ I
i ir I !
I i r i , I I !: I i

'13~~Q
:
~ -~ ~~~1~~ ~ -t- PE NDNG
'. j_,LlL_i..1
:_

',: '" ,.'
i

c •...

: ,

~ ? --l--+-~-+~J. __ ~..L __ L.

~

tf

f-

E

.

!---.++-- -- .--... ~,

11;

-i~ --.

.J_-_~-.

0

19-44

I

1-+:

4 5

~-

;'

I

--I-

t

0'

4

-

'
!
·~;1,~8
,t-+-!
~
-_j- f--f-~--t-~- ~--4--it-~+-f--+--+-t-t--t-+-t-+-+--+-+--+--ii-+-H
!

I

~- ; -~-+-1-: -~-+
4

' .

+--i'.;...;

tuSttiA 0
+
~,
+- vtu~ti -

'~-+--'f-+--+-+~f--+--+-T-r----'--~

:::
4

: ' :

!

f--3~4-+-t-10t----+----+---+--lf--t--+----+---<-+-+-+
1--+-_+-+-,-+:--+=';'--.1=i_ J.,~
r- ADn
I i ' S:~lPi~LJ
0
t:. 1J
!-t'e,,:
i,
3
3

,

"lid''','

f-jI-z ~~
0

-

t-,

+

3 3

:-'

...I.-I.--.L.-"--,--L-.1.--.L.-.L..-I

SJUkCE INPUT

SCRF~N

124

SZO!U~

DCODf

1

o

l BOY

b L 6

SC~EEN

SZSHIP
ocoeE
L)

0

DCUSTNC
l)CNAME
DCAl
DCA?
DCA3
l)SNAME
DSAl
DSA2
8SA3

S;\JA~F

1
7

2

FLJR.MAT SOURCE SPECIFICATIONS

124
1 180Y
15 1 3Y
13 l2lY
7 151Y
6 2 3Y
25 221Y
25 321Y
2~ 421Y
25 521Y
25 251Y
25 351Y
25 4S1Y
25 551Y

0

SAL
SA2
SA3

END
POSITION

PCSITIO~

b

SOURCE It-.:PUT

EXECUTION

START

1

CODE
(USTNC

Ct.)

Y

CC
CCuSTOr-IEt{ NUMBtR

Y

Y
y

LEf\iGTr

NAME

CUSPJC
(NAME
CAL
CA2

SPFCIFICATJO~S

RUFFEr{ JESCRIPTION

F aLD

FIELD
NAME

~ruRlF

Y

15 L )Y

DCUSTNC

I~PUT

FGRMAT

TI~E

y

y

Y

Y

y
y

y

Y

y

CS
(CuSTOMEK ~UMBER
(CUSTOMER NAME
C.SHIP TO

Y
Y
Y
Y

Y
Y

Y
y

y
y
y

Y

y
y

OUTPUT BUFFER DESCRIPTION
LENGTH
6
25
25

25
25
25
25
25
25

START
POSITION
1

7
32
57
82
107
132
157
182

ENO
POSITION
6
31
56
81
106
131
1.56
181
206

INPUT RUF=FER DESCRIPTION
FIELD
NAME
ceDE
CuST!'.JO
C\iAMI=
CAL
CA2
CA3
S,\J.l\MF
SAL
SA2
SA3

L E \JG 1 H
L
6
25
25
25
25
25
2~

25
2':>

START
POSITION
1
2
8
33
58
83
lC8
133
158
183

C::ND

PClSITIUN
1

7
32
57
A2
107
L32
157
1.82
207

Figure 19·15 (Part 1 of 6). Compiler Listing for Sample Program ORO

~ample WORKSTN File Program (ORO)

19·45

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIONS
SSHOwITEM
DITEM
DQTY
DOESC
DPRICE
DAfJlOUNT

V

6
6
22
10
11

2.

1 3Y
lloY·
126Y
l5lY
l63Y

EXECUTION TIME OUTPUT BUFFER
FIELD
NAME

START
PCSITION

LE~GTH

ITEM
QTY
DESC
PRICE
AMOUNT

DESCRIPTIO~

6
6
22
10
11

END
POSITION

1

6
12
34
44
55

7

13
35
45

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIONS
SZITEMHEC

o
o
o
o
o

100

3Y
714Y
22 726Y
9 752Y
10 764Y
52157Y
422 3Y
32221Y
8

CITEM ~O.
CQUANTITY
(DESCRIPTION
CPR ICE
CAMOUNT
CTOTAl
CITEM
CQTY

7

8

D

o
o

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIONS
SZITEM
100
Y
OCODE
1 laOY
Y
Y
OTOTAl
132163Y
Y
DITEMNO
622 8Y Y
Y
Y
DQTY
62225Y YS
Y
Y
o
392402Y

CI

c

C
C

EXECUTION TIME OUTPUT BUFFER DESCRIPTION
FIELD
NAME

START
POSITION

LENGTH

TOTAL

END
POSITION

13

13

INPUT BUFFER DES CRIP T I m~
FIELD
NAME
LENGTH
CODE
ITEMNO
QfY

START

END
POSITION

POSITIO~

1
6

1
12

1
2

7

8

5

SOURCE INPUT SCREEN FORMAT SOURCE SPECIFICATIJNS
SZERROR
DMSG

2400
39 1 2Y

Y

Y

EXECUTION TIME OUTPUT BUFFER OESCRIPTION
FIELD
NAME

START
POSITION

lE~GTH

MSG

39

OROFM
FORMAT
FORMAT
FORMAT
FORMAT
FORMAT
FOR ~AT

39

SC REEN FORMAT LC.AD MEfJlBER
lCNUM
lSHIP
SHOWITEM
I I TEr-1HED
lITEM
lERROR

REQUIRES
REQUIRES
REQUIRES
REQUIRES
REQUIRES
REQuIRES

512
768
512
512
512
512

BYTES
cYTES
BYTES
8YTES
BYTf-S
8YTF5

OF
OF
OF
GF
OF

STORAGE
STORAGE
STORAGE
STORAGE
STORAGE
OF STORAGE

Figure 19-15 (Part 2 of 6). Compiler listing for Sample Program ORO
19-46

Sample Programs

END
POSITILJN

IBM SYSTEM/34 RPGII COMPILER

RG 004
0001
0002
0003
0004
0005
0006

WORKSTN

207

FWK

CP

F

FCMAST
FINV
FTRANS

IC
UC
UC

F 206 206R 6AI
1 DISK
F 45 45R 6AI
1 DISK
A
F 256 12aR 8AI
1 DISK
FUNCTION OF INDICATORS
FIRST TIME FOR THIS WORKSTN
NEW GROUP, OUTPUT CUSTOMEK NUMBER PROMPT
CUSTOMER NUMBER INPUT, OUTPUT NAME ~ ADDRESS SCREEN
NAME ~ ADDRESS IN, OUTPUT ITEM-QTY PROMPT
ITEM-QTY INPUT, SHOw THE ITEM ~ PROMPT FOR NEXT

F
F

F:::

F~:

F:::NO 1
F* 10
F::: 11
F::: 12
F::: 13
F:::
F::: 99

F:::

F*
F*
F*
F*
F*
F*

90 91 92
KA
KB
KC

F*
F*
F*

0007

E

0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026

IwK

I
I
I
I
I
I
I

IOPD
NS

11

CC

NS
NS

12
13

1 CS

NS
NS

10
90

IINV

NS

91

ITRANS

~S

92

I
I
I
I
I
I

ICRECD

I
I
I

IKEYHLD

I
I
I
I
I
I
I
I
I
I
I

WSID
SLN

NEED TO OUTPUT IOPD ARRAY
A ARRAY IS FULL
B ORDER COMPLETE AND ARRAY IS NOT EMPTY
WORK INDICATORS
ORDER IS COMPLETE
INVALID IF STARTING NEW GROUP
INVALID IF STARTING NEW GROUP
CANCEL ORDER
INVALID IF NOT STARTING GROUP
END OF JOB

ICMAST
I

KID
KSLN

ERROR HAS OCCURRED
INVALID COMMAND KEY
ITEM r-..OT FOUND
CUSTO~ER NOT FOuND

96
97
98
15

Ft.:

0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041

ORO

06

H

3 40

2
7 CUSTr-..O
2 207 C~ECC

1 CI

2
8

1 C

3 CH

4 Cf

OS

OS

OS

'5 CA

7 ITE~~~
120~TY
.
.

I

1 206 CRECC -----7
1
6 ITEMt.O
7 1100NHAt-.D
12 160PENO~G
17 232PRICE
24
45 OESC
9
110LSTGRP

1
b CUSTf\,O
7 106 CUSTAD
100l 206 5HIPAD
1
1
3
6
7
1
1
7
12
19

t3 KFY
2 wSID
50l,RUUP::
6 CODE
80SECJ :~
40 IOPDOO
6 ITE"'t.O
110WTY
182PRICi::
40 OESC

The data structure CRECD is used to define input records
and an output record (see Part 5 of this figure). The data
structure for the output record is defined further by the
ZSH IP displav screen format. See Part 1 of this figure for
the relationship between the display screen format and the
input and output records.
Figure 19·15 (Part 3 of 6). Compiler Listing for Sample Program ORO
Sample WORKSTN File Program (ORO)

19-47

0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055

(
(
(
(
(

99
KA
KB
(
K(
(
KA
(OR KB
(.OR KC
(
11
(
9d
(
IlN98
(
13
(

(t.:

0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072

(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(

0073
0074
0075
0076

(
(
(
(

0077
0078
0079
0080
0081

(
(
(
(
(

0082
0083
0084
0085
0086
OOtH
0088
0089

(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(

0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113

EXSk
EXSR
GOTO
EXSR
EXSR
EXSK.

1'401

(USTNO
GROU P:~
END
NEW

90

KEY

(MDr211<211=2
Lookup/Factor 2)i •
High Low Equal

Comments

54 55 56 57 58 59 60 61 62 63 64 65 66 67

sa

69 70 71 72 73 74

1

Figure 20-1. Calling SUBR40

20-4

Key

0_

6

7

Graphic

..Ja:

345

1

Instruction

Indicators

§

I--

Line

1

I Date

Programmer

GX21·909J. UM/060'
Printed in U.S.A.

Ideographic Support

EM PNO

Is!o ciS EC
Re: ITC CE
SN ~L EN
RE CIL EN

10
8
I
3~

3¢

SE NO I NG IF
RE (£ IV ING

\ ELO
FI E Lie

RE TU RN CO DES
Sf NID I NG LE NG TH
RE CE IV ING LEN

MOVE IDEOGRAPHIC DATA WITH ADDITION OF
CONTROL CHARACTERS (SUBR41)
SUBR41 is a move and edit routine that moves the
contents of one field into another field. If the S/O and
S/I control characters are not found in the first and last
positions of the field, SUBR41 adds them to the field
when it is moved.
SUBR41 is called as shown in Figure 20-2.
If you want the 'receiving field to contain all the data
that is in the sending field, you must specify the length
of the receiving field to be two positions 'Ionger than the
length of the sending field (to hold the S/O and S/I
control characters). If you specify a receiving field that
is longer than the sending field plus two, the data is
padded on the right when it is moved into the receiving
field. If the receiving field is shorter than the sending
field plus two, the data is truncated on the right when it
is moved. If the receiving field is specified either longer
or shorter than the sending field plus two positions, the
S / I control character is still placed in the correct
position (the rightmost position).

Five RLABL fields must be specified when SUBR41 is
called. The first two specify the sending and receiving
fields for the move. The third field is where the return
codes are written to indicate the status of the move
operation. The fourth and fifth fields must be loaded
with the lengths of the sending and receiving fields.
These are the lengths of the fields specified on the first
two RLABLs for the call to SUBR41 (in Figure 20-2, you
would need to load the lengths of SOCSEC and
EMPNO). The return code field must be defined as a
one-position alphameric field; the length fields must be
defined as three- position numeric fields with zero
decimal positions.
SUBR41 produces return codes to indicate the status of
the move. The following list contains these return codes
and their meanings:
Return
Code

Explanation

o

Move executed; no errors.
Move executed; padding occurred to
left of S/I control character.
Move executed; data truncated to
left of S/I control character.
Move executed; S/O and S/I
already present.
Move not executed. Either odd field
length found, length of zero found,
length greater than 256, or invalid
character found in field length.

2

3
4

If more than one return code can be issued, only the
highest return code is issued.

RPG CALCULATION SPECIFICATIONS
.'

1

Program

IDate

Programmer

C

3

4

ld

...Ja:

=0

~~~

Line

I Graphic

Keying
I nstruction

I

Key

E~

Factor 1

Name

~ ~

E

~

b

85

~

6

7

g '0 11 '2 '3 ,4 15 16 ,7 ,8 '9 20 2, 22 23 24 25 26 27 28 29 30 3' 32 33 34 35 36 37 38 39 40 4, 42 43 44 45 46 47 48 49 50 5' 52

0

z

z

EX

o

2

3

c
c
c
c
c
c

RL ABL

o

4

5

o

6

o

7

Length ~

~

8

RL

liT

A8L

RL ABL

RL ABL
·RL ABL

pagernot

75 76 77 78 79 80

~~~~:~f~ation I

III III

Resulting

'il

Factor 2

I

Indicators
0
';:;

Operation

C

o

: Card Electro Number

c

At

~ocr

5

I
I

Result Field

0 1

o

I
I

Indicators

~
o_

f---

t

GX21-909J. UM/050'
Printed in U.S.A,
1 2

Arithmetic

Plus IMinu,1 Zero
Compare

Comments

1> 2 11<2\1=2
Lookup(Factor 2)is
High Low Equal
54 55 56 57 58 59 60 6' 62 63 64 65 66 67 68 69 70 7' 72 73 74

SU BR 41

18
EM FNO
las
RE TC DE
SN DL EN
30
RE CL EN 31¢
SO CS EC

,

Move Ideographic Data With Addition of Control Characters (SUBR41)

20-5

IDEOGRAPHIC DEVICE SUPPORT
Three new keywords have been added to the INFDS for
ideog'raphic' devices. For more information on these
keywords, see Specifications for the INFDS Data
Structure in Chapter 13.

MESSAGES
The RPG displayed messages (both compile time and
execution time) are displayed in either the· standard
character set or an ideographic character set. The
messages are displayed in an ideographic character set
,if ideographic support was requested when the user
signed on.
The RPG· compiler messages are printed in either the
standard character set or an ideographic character set.
The messages are printed in an ideographic character
set if ideographic support was requested when the us~)r
signed on.

20-6

Ideographic Support

Appendix A. Summary Charts

CONTROL SPECIFICATIONS

Columns

Name

Entry

Explanation

Page

Page
number

Entry used to assign a page number to each specification sheet.

3-5

Line

Line
number

Entry used to number the specification line.

6

Form type

H

Identification for the control (or header) specification ..

*

Asterisk in this column identifies this Iine as a comment line.

1-2

6

7
7-9

Size to compile

Blank

10

Object output

Blank
0

Blank entry causes the system to halt for terminal errors only.

o entry causes the system to halt fo.r both warning messages and
severe errors.

11

Listing
options

12-14

Size to execute

12

Blank
B
P

Program listing is produced.
No program listing is produced.
Partial program listing is produced.

Blank or 0

Entry in columns 13 and 14 determines the size to execute.
Entry in columns 13 and 14 is rounded up to next even number.

a,H, T
13-14

Blank
02-64

15

Debug

Blank

1
16-17

Main storage available for object program execution defaults to
region size specified.
Enter the main storage available in a multiple of 2K bytes
(K = 1,024). If entry is odd number, it is rounded up to.next
even number.
DEBUG operation is not used.
DEBUG operation is used.

Blank

18

Currency
Symbol

Any character The currency symbol used in edit words and with edit
except *, 0,
codes. Blank entry defaults to $.
&,., -, C, R,
or ,.

19

Date format
(UDATE)

Blank or M

0
Y

Month/day /year format. If column 19 is blank and column 21
contains a D, I, or J, the day /month/year (ddmmyy) format
is used instead of the month/day/year (mmddyy) format.
Day/month/year (ddmmyy).
Year/month/day (yymmdd).
Control Specifications

A-'

CONTROL SPECIFICATIONS (continued)

Entry

Columns

Name

20

Date edit (Y edit code) Blank

&
Any other
character

Inverted print

21

Blank
D

J

Explanation

A blank entry defaults to slash (/) if column 19 contains an M,
or if column 21 contains a D or blank and column 19 is blank.
A blank entry defaults to period (.) if column 19 contains D or
Y, or if column 21 contains I or J and column 19 is blank.
A blank separates the date field.
Character entered separates the edited date field.

Numeric fields use decimal point (.). Date format is mmddyy
if column 19 is blank.
Numeric fields use decimal point (.). Date format is ddmmyy
if column 19 is blank.
Numeric fields use decimal comma (,). Date format is ddmmyy
if column 19 is blank.
Numeric fields use decimal comma (,) and leading zero remains
for zero balance. Date format is ddmmyy if column 19 is blank.

Blank

22-25
Alt~rnate

26

collating

sequence

Blank
S

Normal collating sequence is used.
Alternate collating sequence is used.

Blank

27-36

Inquiry

37

Blank or I
B

Program, when interrupted, will not allow the operator to enter
new procedures or commands.
Program, when interrupted, will allow the operator to enter new
procedures or commands.
(For an explanation of inquiry, see Column 37 (Inquiry) in
Chapter 2.)

Blank

38-40
41

1P forms positions

Blank
1

File translation

Blank
F

Nonprint characters

Blank
1

A-2

No file translation is needed.
Input, output, update, or combined files are translated.

Blank

44
45

posi~ion

Blank

42
43

First line is printed only once.
First line can be printed repeatedly to allow operator to
forms.

Summary Charts

Program halts if unprintable character was in last Iine printed.
Program does not halt for unprintable characters.

CONTROL SPECIFICATIONS (continued)

Columns

Name

46-47
48

Entry

Explanation

Blank
Shared I/O

49-51

Blank
1

All disk files use a separate input/output area.
All disk files share a single input/output area.

Blank

52-53

Number of
formats

54-56

Blank

57

Transparent
literal

58-74

Blank

75-80

Program
identification

Blank
0-32

Blank
1

An entry of 32 is assumed.
Entry specifies number of formats in display screen format load
member for WORKSTN file.

No transparent literals or constants are present in this program.
Transparent literals or constants can be present in this program.

Entry used to assign a unique name to the program and to name the
display screen format load member used by the CONSO LE or
WORKSTN file.

Control Specifications

A-3

FILE DESCRIPTION SPECIFICATIONS

Explanation

Columns

Name

Entry

1-2

Page

Page numbers Entry used to assign a page number to each specification sheet.

3-5

Line

Line number

Entry used to number the specification lines.

6

Form type

F

Identification for a file description specification.

*

Asterisk in this column identifies this line as a comment line.

7
7-14

Filename

Filename

Each file requires a unique name. The filename can be from 1 to 8
characters long, must begin in column 7, and must be a valid
RPG II name.

15

File type

I
0
U
C

Input
Output
Update
Combined (SPECIAL or WORKSTN device only)

16

File

Blank
P
S
C
R
T
D

Blank for all output files except chained output files
Primary
Secondary
Chained
Record address
Table or array
Demand

17

End of file

Blank

The program can end whether or not all records from this file
are processed. This column must be blank for a WORKSTN or
KEYBORD file. All records from the file must be processed before
the program ends. An E can be specified here only if column 15
contains I or U, and column 16 contains a P, S, or R.

E

Note: If column 17 is blank or contains E for all files, all records
from every file must be processed before the program can end.
18

Sequence

Blank
A
D

No sequence checking is to be done. This column must be blank
for a WORKSTN file.
Sequence checking is done. Records are in ascending sequence.
Sequence checking is done. Records are in descending sequence.

Note: Sequence checking is required when match fields are
used. Column 18 applies only to primary and secondary files.
19

A-4

File format

Summary Charts

F or blank

Fixed-length record format.

FI LE DESCRIPTION SPECIFICATIONS (continued)

Columns

Name

Entry

Explanation

20-23

Block length

Blank
1-9999
2-1518
1-79
1-132
1-79
1-9999
1-4075

These columns must be blank for a WORKSTN file and can be
left blank for any other file.
Disk (record length or multiple of record length)
CONSOLE (if specified, must equal record length)
KEYBORD
Printer
CRT
SPECIAL (record length or greater than record length)
BSCA (record length or multiple of record length)

24-27

Record length

1-4096
2-1518
1-79
1-132
1-79
1-4096
1-4075
1-9999

Disk
CONSOLE
KEYBORD
Printer
CRT
SPECIAL
BSCA
WORKSTN

28

Mode of processing

Blank

Sequential by key
Consecutive

Note: Columns 28 through 32 must be blank for nondisk files.
L
R

29-30

Length of key field
1-8
or record address field 1-29
3

Sequential within limits
Random by relative record number
Random by key
By addrout file
Direct file load (random load)
Length of record keys in packed format (for indexed files)
Length of record keys in unpacked format (for indexed files
and record address files)
Length of relative record number in addrout file

Note: These columns must be blank for nondisk files.
31

Record address type

Blank
P
A

I

Sequential or direct file
Indexed file with packed keys
Indexed file with alphameric keys
Addrout file or processed by addrout file

Note: Column 31 applies to disk files specified as input,
update, or chained output files

File Description Specifications

A-5

FI LE DESCRIPTION SPECI FICATIONS (continued)

Columns

Name

Entry

Explanation

32

File organization or
additional I/O area

Blank

1-9

Sequential or direct file; one input/output area for the file
Indexed file
Addrout file
Sequential or direct file; two input/output areas for the file

I
T

33-34

Overflow indicator

Blank
OA-OG,OV

No overflow indicator used
Overflow indicator used to condition records in printer files

35-38

Key field starting
location

1-4096

For indexed files, enter the beginning position of the key
field in the record. This entry must end in column 38.

39

Extension code

Blank
E
L

No file-related Iine counter or extension specifications are used.
Table file. array file, or record address file is further described
by extension specifications.
Printer file is further described by line counter specifications.

DISK
KEYBORD
PRINTER
CONSOLE
CRT
SPECIAL
BSCA
WORKSTN

Disk
Display screen - keyboard (display station)
132-position printer
Display screen - keyboard (display station)
Display screen
Used for devices not supported directly by RPG II
Binary synchronous communications adapter
Display screen - keyboard (display station)

K

Continuation line specified

Blank
SUBRxx

No SPECIAL device used.
Name of the user-written subroutine that performs the input/output
operation for a SPECIAL device (x = any alphabetic character).
Name of the IBM-written subroutine (5-character name in
library is @yzzz) that performs the input/output operation for a
device supported by SPECIAL (y = any of the following:
B, C, D, F, G, H, I, L, M, 0, P, R, S, T, or U; z = any of the
following: A, B, C, D, F, G, H, I, L, M, 0, P, R, S, T, or U).
Name of array to be used by user-written subroutine.

40-46

Device

47-52

Blank

53
54-59

Name of label exit

SRyzzz

Continuation line
option for SPECIAL
device

A-6

Summary Charts

Array name

FI LE DESCRIPTION SPECIFICATIONS (continued)

Columns

Name

54-59
(continued)

Continuation line
options for WO RKSTN
device

Entry

For WOR KSTN options if multiple display stations are attached
to a WORKSTN file or if the file information data structure
(INFDS) or the exception/error processing subroutine (INFSR)
is specified.
NUM
SAVDS

IND
SLN

ID

Continuation line
options for DISK
device

Explanation

I

Specify the maximum number of display stations that can be on this
file in columns 60 through 65. If not specified, 1 is assumed.
Enter the name of a data structure in columns 60 through 65 that
is to be saved and restored for each display station in this file.
If not specified, no swapping is done.
Specify the number of indicators (beginning with 01) to be swapped
by display station. If not specified, no swapping is done.
In columns 60 through 65, specify the name of a two·digit numeric
field whose value determines the first line on the display screen
where the display format is to begin if variable starting line number
was specified in the format.
In columns 60 through 65, enter the name of a 2-character
alphameric field that contains the ID of the display station currently
being processed in this field.

INFSR

Enter the name of the user·written subroutine that may receive
control when WORKSTN exception/error conditions occur.

INFDS

Enter the name of the data structure that contains file related
information when exception/error conditions occur during
WORKSTN operations or when the display screen size is
to be posted.

FMTS

Enter *NONE in conjunction with FMTS if there are only SSP·ICF
formats present in the program. Otherwise, enter a name to be used
as the display screen format load member name. If a name is not
entered on the FMTS continuation line option, the compiler assumes
the display screen format load member name is the program name
(from columns 75 through 80 of the control specifications) with
FM added to the end of the name.

RECNO

In columns 60 through 65, enter the name of a seven·
position, numeric field with zero decimal positions. This
field contains the relative record number of a record to be
added to a sequential or direct file processed randomly.

File Description Specifications

A· 7

FILE DESCRIPTION SPECIFICATIONS (continued)

Explanation

Columns

Name

Entry

60-65

Storage index

Blank
6-9999

No storage index is kept in storage.
Number of bytes reserved for storage index.

66

File addition/
unordered load

A
U

New records will be added to the file.
Records are to be loaded into an indexed file in unordered
sequence.

Note: This column applies to sequential and indexed disk files.
67-70
71-72

Blank
File condition

Blank
U1-U8

An external indicator does not condition the file.
Specified external indicator conditi~ns the file.

Note: These columns apply to output files, primary and
secondary input files, and update files. A record address file
can be conditioned by an external indicator if its associated
primary or secondary file is conditioned either by the same
indicator or by no indicator.
Blank

73-'74
75-80

A-8

Program identification

Summary Charts

This space is available for comments.

EXTENSION SPECIFICATIONS

Columns

Name

Entry

Explanation

1-2

Page

Page number

Entry used to assign a page number to each specification sheet.

3-5

Line

Line number

Entry used to number the specification lines.

6

Form type

E

Identification for an extension specification.

7

*

Asterisk in this column identifies this line as a comment line.

7-10

Blank

11-18

From filename

Blank

Filename

Table or array load at compilation time if columns 33
through 35 contain an entry. Array is loaded at execution
time if columns 33 through 35 are blank.
Name of the table or array input file loaded at preexecution time
or name of the record address file defined on the file description
specifications sheet. Entry must be left-justified.
Blank if the table or array is not written at end of job.
Name of the primary or secondary input or update file containing
the data records to be processed if the file named in columns
11 thr'ough 18 is a record address file. Name of the output file to
which the table or array is written at end of job if the file named
in colum ns 11 through 18 is a table or array file.

19-26

To filename

Blank
Filename

27-32

Table or array name

Table or array Name of a table or array used in the program. If alternating tables
name
or arrays are described, enter the name of the table or array whose
entry is first on the input record. Entries must be left-justified and
must be valid RPG II names. Table names must begin with TAB;
array names must not begin with TAB.

33-35

Number of entries
per record

Blank
1-999

These columns must be blank for execution-time arrays.
Number of entries on each table or array input record. These
columns must contain an entry for compile- and preexecution-time
tables and arrays. Entry must be right-justified.

36-39

Number of entries
per table or array

1-9999

Maximum number of entries in the table or arrays; corresponding
items are considered one entry. Entry must be right-justified.

40-42

Length of entry

1-15

Length of numeric entry. For packed or binary numeric data,
enter the number of digits required to represent the data in zoned
decimal format. Entry must be right-justified.
Length of alphameric entry.

1-256

Extension Specifications

A-9

EXTENSION SPECIFICATIONS (continued)

Entry

Columns

Name

43

Packed or binary field Blank
P
B

44

Decimal positions

Blank
0-9

45

Sequence

Blank
A
D

Explanation

Alphameric or zoned decimal numeric data
Packed numeric data
Binary numeric data
Alphameric table or array
Number of positions to the right of the decimal
No particular sequence
Ascending sequence
Descending sequence
Note: This column describes the sequence of data in a table or

array. Column 45 must contain an entry if high or low lookup
is used.
Description of a second table or array entered in alternating format
with the table or array named in columns 27 through 32. These
entries have the same significance as the corresponding entries
in columns 27 through 45.

46-57

58-74

Comments

Any helpful information about the specification line.

75-80

Program
identification

This space is available for comments.

A-10

Summary Charts

LINE COUNTER SPECIFICATIONS

Columns

Name

Entry

Explanation

1-2

Page

Page number

Entry used to assign a page number to each specification sheet.

3-5

Line

Line number

Entry used to number the specification lines.

6

Form type

L

Identification for the line cou nter specification.

*

Asterisk in this column identifies this line as a comment line.

7
7-14

Filename

Filename

Name of a printer file for which form size and overflow line
are specified.

15-17

Line numbernumber of lines
per page

1-112

Number of lines available for printing on the printer form.

18-19

Form length

FL

Identification that the previous entry is the form length.

20-22

Line numberoverflow line

1-112

Number of the overflow line.

23-24

Overflow line

OL

Identification that the previous entry is the overflow line.

Blank

25-74
75-80

Program
identification

This space is available for comments.

Line Counter Specifications

A-11

TELECOMMUNICATIONS SPECIFICATIONS

Columns

Name

Entry

Explanation

1-2

Page

Page
number

Entry used to assign a page number to each specifications sheet.

3-5

Line

Line
number

Entry used to number the specification lines.

6

Form
type

T

Identification for a telecommunications specification.

*

Asterisk in this column identifies this line as a comment line.

7
7-14

Filename

Filename

Every BSCA file in a program requires a valid filename. The same
filename must appear on the file description specifications.

15

Configuration

P or blank
M

Point-to-point, nonswitched network.
Multipoint network, where the control station selects the tributary
station through polling or addressing. System/34 cannot be the
control station.
Point-to-point switched network.

S
16

Type of station

T

R

17

Type of control

T

Blank

A-12

Summary Charts

This station transmits messages from the file named in columns
7 through 14. The file must be designated as an output file by
file description specifications and must appear on the output
specifications sheet.
This station receives messages into the file named in columns
7 through 14. The file must be designated as an input file by
file description specifications and must appear on the input
specifications sheet.
Tributary station on a multipoint network. System/34 cannot
be the control station and transmit the polling supervisory sequence.
Column 17 must contain a T if column 15 contain"s an M (multipoint
network).
Polling is not used.

TE LECOMMUNICATIONS SPECI FICATIONS(continued)

Columns

Name

Entry

Explanation

18

Type of code

A or U

ASCII transmission control characters are used. When ASCII is
used, the necessary file translation is done for System/34.
EBCDIC transmission control characters are used.

E or blank
19

Transparency

y

N or blank

20

Switched

Blank
M

A
B
21-31

Blank

32

Location of
identification this station

Blank
S
E

33-39

Identification this station

Alphameric
characters

EBCD IC transparency is used. ,The data being transferred may
contain transmission control characters. Column 18 must be
E or blank.
EBCD IC transparency is not used. Zoned decimal numeric or
alphameric data is transmitted and received. The data being
transferred cannot contain transmission control characters.
Not a switched network.
Operator using this program makes the connection by dialing the
number (manual dial).
This program uses autoanswer.
This program uses manual answer.

Nonswitched network or a switched network where no ID is desired
for this station.
Switched network. This station's identification is at the position
specified by the symbolic n'ame in columns 33 through 39.
Switched network. The entry in columns 33 through 39 is this
station's identification.
When column 32 contains an E, this entry is the actual identification
sequence of this station (from 2 to 15 characters). The station
identification must not contain a control character sequence. When
column 32 contains an S, this entry is the symbolic name of the
location of this station's identification. The symbolic name must
not be an array name. If the BSCA file is primary or secondary,
this symbolic name must refer to the first element of a table.

Telecommunications Specifications

A-13

TELECOMMUNICATIONS SPECI FICATIONS (continued)

Columns

Name

Entry

40

Location of
identification remote station

Blank
S
E

41-47

Identification remote station

48-51
52

Alphameric
characters

Explanation

. Nonswitched network or a switched network where no ID is desired
for the remote station.
Switched network. The remote station's identification is'at the
position specified by the symbolic name in columns 41 through 47.
Switched network. The entry in columns 41 through 47 is the
remote station's identification.
When column 40 contains an E, this entry is the actual identification
sequence of the remote station (from 2 to 15 characters). A station
identification must not contain a control character sequence. When
column 32 contains an S, this entry is the symbolic name of the
location or the remote station's identification. This symbolic name
must not be an array name. If the BSCA file is a primary or
secondary file, this symbolic name must refer to the first element
of a table.

Blank
ITS

Blank
I

ITB is not used.
Intermediate block check (ITB) is used. ITB can be used only if
records are blocked.

Note: Both ITB and EBCDIC transparency cannot be specified
for a BSCA output file.
53-54

Permanent error
indicator

Blank
01-99,
L1-L9,
LR, H1-H9

A-14

Summary Charts

No permanent error indicator is specified. If a permanent error
occurs, a system halt occurs. The program cannot be restarted.
This indicator can be specified for every BSCA file. If you are using
more than one BSCA file, each file can have a permanent error
indicator. The indicator does not have to be unique for each
file, however.

TELECOMMUNICATIONS SPECIFICATIONS (continued)

Columns

Name

Entry

Explanation

55·57

Wait time

Blank
1·999

System convention for timeout, 180 seconds, is used.
Length of time in seconds (1 through 999) that BSC waits with
no messages being sent or received before a permanent error occurs.

58·59

Record available
indicator

Blank

No record available indicator is specified. The file cannot be
used again.
This indicator must be assigned to every BSCA file that is to be
reopened. (If a file is used again after end of file has been reached,
the file is reopened.)

01·99,
L1·L9,
LR,
Hl·H9
60

Last file

Blank
L

This BSCA file cannot be the last input file processed.
This BSCA file is processed after all other input files are
processed.

61·62

Poll ing characters

Blank
Alphameric
characters

This station is not transmitting on a multipoint network.
The polling identification of this station is needed if this. station
is part of a multipoint network and the BSCA file is a transmit
(output) file.

63·64

Addressing
characters

Blank
Alphameric
characters

This station is not receiving on a multipoint network.
Addressing identification of this station is needed if this
station is a part of a multipoint network and the BSCA file
is a receive (input) file.

Note: Enter polling and addressing characters in System/34 code;
the compiler converts the characters to the form required by the
code specified in column 18. (Enter uppercase addressing
characters, and they are converted to lowercase ASCII characters.)
65·74
75·80

Blank
Program
identification

Th is space is available for comments.

Telecommunications Specifications

A-15

INPUT SPECIFICATIONS

Columns

Name

Entry

Explanation

1-2

Page

Page number

Entry used to assign a page number to each specification sheet.

3-5

Line

Line number

Entry used to number the specification lines.

6

Form type

7

7-14

Filename

Identification for an input specification.
*

Asterisk in this column identifies this line as a comment line.

Filename

Enter a valid RPG II filename for every input, update, and
combined file your program uses.
Name of a data structure (maximum of 6 characters).

OS name
14-16

AND/OR

AND or OR

Enter AND in columns 14 through 16 on the next line of the input
specifications sheet if more than three record identification
code subfields are needed to identify the record. Enter OR in
columns 14 and 15 if either of the codes can be present to identify
the record. A maximum of 20 AND or OR lines in any combination
can describe the record identifying code.

Note: AND lines are not allowed with CONSOLE files.
15-16

Sequence

Alphabetic

Numeric

17

Number

Blank

N

18

Option

Blank

o
U

These two alphabetic characters indicate that record type sequence
is not being checked. Alphabetic characters must be used for
chained files, demand files (except CONSOLE), WORKSTN file,
and look-ahead records. Within a file, record types with an
alphabetic sequence entry must be described before record types
with a numeric sequence entry.
This two-digit number assigns a special sequence to record types
in a file and requests that the record type sequence be checked
by the program.
Columns 15 and 16 contain alphabetic characters·(record type
sequence is not being checked).
Columns 15 and 16 contain numeric characters; only one record
of this type is present in each sequenced group.
Columns 15 and 16 contain numeric characters; one or more records
of this type can be present in the sequenced group.
Record type must be present.
Optional; record type mayor may not be present.
Data structure defined in columns 19 and 20 is a display station
local data area.

Notes:
1. Column 18 is used when record types are being sequence checked
(columns 15 and 16 contain a numeric entry).
2. Columns 15 through 18 are no~ used for a data structure except
to define a display station local data area (U in column 18).

A-16

Summary Charts

INPUT SPECIFICATIONS (continued)

Columns

Name

Entry

Explanation

19 and 20

Record identifying
indicator

01·99

Record identifying indicator. (CONSOLE files can use indicators
01 through 10 only.)
Control level indicator used as a record identifying indicator when
a record type rather than a control field signals the start of a new
control group.
Last record indicator.
Halt indicator used as a record identifying indicator when the system
checks for a record type that causes an error condition.
Look-ahead fields (not valid with CONSOLE or WORKSTN files.)
Data structure, which must be the last entries on the input
specifications.

L1·L9

LR
H1·H9
**
DS

Note: Columns 21 through 41 are divided into three identical
subfields that are described separately: (1) columns 21 through 27,
(2) columns 28 through 34, and (3) columns 35 through 41. An
AND relationship exists between these three fields. These columns
are not used for a data structure.

21-41

Record
identification
codes

21-24, 28·31,
or 35-38

Position

Blank
1·4096

No record identification code is needed.
Record position of the record identification code.

25,32,or39

Not (N)

Blank

Either the record identification code is present in the specified
record position, or no record identification code is needed.
Record identification is being used, but this identification code must
not be present in the specified record position.

N

26, 33,or40

C/Z/D

C
Z

D

27,34,or41

43

Any alphabetic character, special character, or digit identifying the
character used in the record as the record identifying code.

Character

42

Entire character
Zone portion of character
Digit portionof character

Blank
Packed or
binary field

Blank
P
B

Input field in zoned decimal format
Input field in packed decimal format
Input field in binary format

Note: Column 43 is used for disk files only and is invalid for a
field in a data structure.
44-47
and 48·51

Field location

Numeric
field

44-50

Field location

Reserved
keyword

Two 1· to 4-digit numbers to identify the beginning of a field
(From) and the end of a field (To) in the input record or data
structure. The entries are identical for a one·position field.
For the WORKSTN file information data structure (INFDS), specify
keywords (*OPCODE, *RECORD, *SIZE, *STATUS, *MODE,
* INP, or *OUT) to define the subfields that are to contain the file
related information.
Input Specifications

A-17

INPUT SPECI FICATIONS (continued)

Columns

Name

Entry

Explanation

52

Decimal
position

Blank
0-9

Alphameric field. This column must be blank for a data structure.
The number of decimal positions in the numeric field named in
columns 53 through 58. This column must contain an entry for
numeric fields.

53-58

Field name

Field name

Valid RPG II field name, array name, or array element for each
field defined in columns 44 through 51. If an array name is
entered, columns 59 through 64 must be blank. PAGE and
PAGE1 through PAGE7 are special words.

59-60

Control level

Blank

Field described is not a control field. These columns must be
blank for chained files, demand files, WORKSTN files, and data
structures. Field described on this line is a control field.

L1-L9
61-62

Matching fields

M1-M9

Enter a match value (M 1'through M9) to indicate match fields and
sequence checking on primary and secondary files with match fields.
When you have just one input, update, or combined file with match
fields, this entry causes only sequence checking. Match fields are
not allowed for demand files, chained files, WORKSTN files, or data
structures.

63-64

Field record
relation

Blank
01-99
L1-L9
MR
U1-U8
H1-H9

Must be' blank CONSOLE files.
Record identifying indicator assigned to a record type
Control level indicator
Matching record indicator
External indicator
Halt indicator

65-70

Field indicators

01-99
H1-H9

Field indicator.
Halt indicator for an error condition in the data.

Note: An indicator used in these columns is turned on if the
condition tested for is true. For numeric fields, more than one
condition may be tested at a time, but only the indicator that
reflects the result of the test is turned on; the others are turned off.
If a field is alphameric, an indicator can be specified only in columns
69 and 70. Field indicators are not valid for a data structure.
71-74
75-80

A-18

Blank
Program identification

Summary Charts

This space is available for comments.

CALCULATION SPECIFICATIONS

Columns

Name

Entry

Explanation

1-2

Page

Page number

Entry used to assign a page number to each specification sheet.

3-5

Line'

Line number

Entry used to number the soecification lines.

6

Form type

C

Identification for a calculation specification.

*

Asterisk in this column identifies this line as a comment line.

Blank

Calculation operation is done,at detail time or is part of a
subroutine.
Calculation operation is done at total time (always on).
Calculation operation is done when the appropriate control break
occurs or an indicator is set on.
Calculation operation is done after the last record is processed or
after LR has been set on.
Calculation operation is part of a subroutine. Blank entry is also
valid.
Indicators specified on this list are either in an AND relationship or
in an OR relationship with indicators on the preceding Iine. A
maximum of seven AN, OR, or mixed AN and OR lines is allowed
to condition an operation.

7

7-8

Control level

LO
L1-L9
LR
SR
AN,OR

Note: Control level entries must be in the order listed.
9-17

Indicators

18-27

Factor 1

28-32

Operation

31-32

Indicators

One to three indicators. Any indicators except 1P and LO can be
used. Columns 9, 12, and 15 may contain blank or N. An AND
relationship exists between indicators on a line. Additional lines
may be used for entering indicators in columns 9-17. These are in an
AND or OR relationship with those on the first line. Enter AN or
OR in columns 7 and 8.
Name of any field that is defined.
Alphameric or numeric literal.
Subroutine, table or array name, or array element.
Date field name (UDATE, UMONTH, UDAY, UYEAR).
Special name (pAGE, PAGE1 through PAGE7).
Label for a TAG, BEGSR, or ENDSR operation.
Field containing work station ID for a display station or
two-position literal that is the work station ID for a display station.
Figurative constant (*BLANK, *BLANKS, *ZERO, *ZEROS)

Operation
code

Must be left-justified.

01-99

Message identification code (MIC) to be displayed from the user
message member during SET or KEY operations. (Entries are
ignored by the compiler when factor 1 is also present on the :J
<

Factor 1
Factor 2
Factor 1
Factor 2
Factor 1 =
Factor 2

1

Immediately
when the
specified
condition is
met upon execution of the
operation

Summary of Indicators

A-29

SUMMARY OF INDICATORS (continued)
Where Normally

Where LOI:ated

Indicators

TESTZ

j"'"'

Minus
Blank

Plus

TESTB

Minus

Used as
Conditioning
Indicators

Normally Turned On
By

Normally Turned Off

When

By

When

Presence of a C
zone
Presence of a D
zone
Any zone other
than a Cor D
zone
Each bit specified by factor
2 is off in the
result field
Bits specified
by factor 2 are
of a mixed
status in the
result field
Each bit specifi~d by factor 2

a;'"
Q)

, Equal

.c

tI)

c
.C2
ctI

~

U
Q)

LOKUP

a.

f9

h

Low

tI)

c

\ Equal

a
c
C2

tou
a

..J

KEY

I '

is on in the result
field

<
>

Factor 1
Factor 2
Factor 1
Factor 2
Factor 1 =
Factor 2

Plus
Minus

Plus result
Minus result

Immediately
when the

Failure to satisfy
the assigned

Zero
Blank

Field contents
zero or blank

specified condition is met
after the field
is keyed

condition when
the field is keyed

Exception/
error
condition

Immediately
upon execution
of operation
if exception/
error condition occurred

Immediately
preceding
execution of
operation

Record
specified in
factor 1 not
found in file

Immediately
CHAIN
upon execution operation
of operation
code
if specified
condition exists

Immediately
preceding
~xecution of
operation

Immediately
upon execution
of operation
if exception/
error condition occurred

Immediately
preceding
execution of
operation

ACQ
(exception/
error, cols

56-57)

CHAIN
(no record
found, cols

54-55)

NEXT
(exception/
error, cols

56-57)

A-30

Summary Charts

Exception/
error
. condition

Immediately

SUMMARY OF INDICATORS (continued)

Indicators

Where Located
End
of
file

Where Normally
Used as
Conditioning
Indicators

Normally Turned On
By

By

When

End of file

Immediately
Programmer
upon execution
of operation
if end of file
occu rred

Exception/
error
condition

Immediately
upon execution
of operation
if exception/
error occurred

Immediately
preceding
execution of
operation

Exception/
error
condition

Immediately
upon execution
of operation if
exception/
error occu rred

Immediately
preceding
execution
of operation

READ

Except/
error,
cols
56-57

Normally Turned Off

....
If)

Q)

When
By execution
of the SETOF
operation or
through use
as resulting
indicator of
another
operation

Ql

.J::

U)

c:
0

';;
co

~

'u

REL
( exception/
error, cols
56-57)

Q)

0.

U)

c:
0

c:

0

';;
co

SETOF
(cols 54-59)

Immediately
upon execution of
operation

u
0
..J

SETON
',cols 54-59)

Immediately
upon execution
of operation

SETnn

Operator
pressing
specified
command
key

SHTDN
(cols 54-55)

System
operator's
request to
shut down
system

Immediately
preceding
execution of
operation

Immediately
upon execution
of operation
if specified
condition
exists

Immediately
preceding
execution of
operation

Summary of Indicators

A-31

SUMMARY OF INDICATORS (continued)

Q:;
.0

E
::l

Where Normally Specified to be

When Turned On by

When Turned Off by

Indicators

Turned On or Off

Program Itself

Program Itself

L1- L9 (control
level)

Control level: cols 59-60-input
sheet

Before total time upon control
break

After each detail-time output

LO !level zero)

Nowhere

LR !last
record total)

Nowhere

Before total time following last
data record (after / * L' )

At the start of the program

1P (first page)

Nowhere

At beginning of program execution

After first detail-time output

OA-OG,OV
(overflow)

Nowhere

When end of page is reached

After next detail-time output
unless fetch overflow is specified

H1-H9 (halt)

Field and resulting indicators

Never, but if on at detail-time
output, halts system thereafter

When system is restarted after
halt

01-99 (general)

Field and resulting indicators

During calculation

During calculation

KA-KN, KP-KY

Resulting indicators

During calculation or by display
station operator at input

During calculation or by display
station operator at input

U1-U8

External or resulting indicators

During calculation

During calculation

Always on

Never

Z

--E
( l)

C1l

z

A-32

Summary Charts

DISPLAY SCREEN FORMAT SPECIFICATIONS
S Specifications
Columns

Name

Entry

Explanation

1·5

Sequence number

Line number

Entry used to number the specifi~ation lines.

6

Form type

S

Identification for an S specification.

*

Asterisk in this column identifies this line as a comment line.

Display
screen
format name

Name of the display screen format that the $SFGR utility program
creates from the Sand D specifications.

7
7·14

Format name

Blank

15·16
17·18

Start line number

01-24

Number of the line at which the display begins.

V

Start line number is determined by the user program.

(column 17)
19·20

Number of lines
to clear

00-24

Number of lines to clear, including and following the starting line.
The specified number of lines are cleared, beginning with the start
Iine specified in columns 17 and 18.

21

Lowercase

y

With the Shift key, operators key uppercase characters. Without the
Sh ift key, operators key lowercase characters.

N or blank

Operators key uppercase characters only.

Y or blank

Input fields on this display are returned to the user program, even if
the operator enters no data.

N

Input fields on th is display are not returned to the user program
unless the operator enters data in one or more of the fields. Then all
input fields are returned to the program.

22

Return input

23·24
25·26

Blank
Sound alarm

Y
(column 25)

The alarm sounds when th is display appears.

N (column
25) or blank

The alarm does not sound when this display appears.

01-99

The alarm sounds when this display appears only if the specified
indicator is on.

Display Screen Format Specifications A-33

S Specifications (continued)
Columns

Name

Entry

Explanation

27

Enable function
keys

y

The function control keys identified by numbers in the key mask
entry (columns 64 through 79) are enabled (allowed). If the key
mask entry contains no numbers, all function control keys are
disabled.

N

The function control keys identified by numbers in the key mask
entry are disabled (not allowed). If the key mask entry contains
no numbers, all function control keys are enabled. If the operator
presses a disabled function control key, an error message is
displayed. The operator can then press the Error Reset key, followed
by the correct function key.

R

The function control key mask that is active for the display station
is retained when this format is displayed.

Blank

All function control keys are enabled. In this case, the key mask
entry must not contain any numbers.

Note: Function control keys that are not masked off and that
are not supported by the program cause an error message to be
displayed, which indicates that an invalid key was pressed.

28

A-34

Enable command
keys

Summary Charts

y

The command keys identified by alphabetic characters in the key
mask entry (columns 64 through 79) are enabled (allowed). If
the key mask entry contains no alphabetic characters, all
command keys are disabled.

N

The command keys identified by alphabetic characters in the key
mask entry are disabled (not allowed). If the key mask entry
contains no alphabetic characters, all command keys are enabled.
If the operator presses a disabled command key, an error message
is displayed. The operat~r can then press the Error Reset key,
followed by the correct command key.

R

The command key mask that is active for the display station is
retained when this format is displayed.

Blank

All command keys are.enabled. In this case, the key mask entry
must not contain any alphabetic characters. If a command key is
pressed, the corresponding indicator (KA through KN, KP through
KY) is set on in the RPG II program.

S Specifications (continued)
Columns

Name

Entry

Explanation

29-30

Blink cursor

y

The cursor blinks when this display appears.

(column 29)

31-32

33-34

Erase input fields

Override fields

N (column
29) or blank

The cursor does not blink.

01-99

The cursor blinks only if the specified indicator is on.

Y
(column 31)

All unprotected input fields on the screen are erased, the keyboard is
unlocked, and no output occurs. All D specifications are ignored.
The use of Y is not recommended.

N (column
31) or blank

The input fields are not erased.

01-99

All unprotected input fields on the screen are erased and the
keyboard is unlocked if the specified indicator is on.

Y

An override operation is performed. The use of Y is not
recommended.

(column 33)

35-36

37-63

Suppress input

N (column
33) or blank

The operation is not an override operation.

01-99

An override operation is performed if the specified indicator is on.
An override operation allows the screen to remain unchanged except
for those fields that have indicators specified for them in columns
23 and 24 of the 0 specification, and those indicators are on. See
Special Display Format Considerations in Chapter 13 for a more
detailed description of an override operation. The record displayed
by RPG II is exactly the same whether or not override is specified
when the indicator in columns 23 and 24 of the 0 specification is
on.

Y
(column 35)

No input is returned to the user program until a format is displayed
with suppress input specified as N or with the specified indicator off.

N (column
35) or blank

Input is returned to the user program.

01-99

Input to the user program is suppressed if the specified indicator is on.

Blank

Display Screen Format Specifications

A-35

S Specifications (continued)
Columns

Name

64·79

Key mask

Entry

Explanation

The key mask is a string of numbers and/or alphabetic characters
that identify keys to be enabled or disabled when this format is
displayed. The key mask must begin in column 64 and cannot
contain embedded blanks. The numbers and alphabetic characters
can be intermixed.
Numbers in the key mask identify function control keys:
Number

Function Control Key

1

Print
ROLLt
ROLL+
Clear
Help
Record Backspace

2
3
4
5

6

Alphabetic characters in the key mask identify command keys:
Alphabetic
Character
A
B
C
D

E
F
G
H
I
J
K
L
M
N
P
Q

R
S
T
U
V
W
X
y

A·36

Summary Charts

Command Keys

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

D Specifications
Columns

Name

Entry

Explanation

1·5

Sequence number

Line number

Entry used to number the specification line.

6

Form type

D

Identification for a D specification.

*

Asterisk in this column identifies this line as a comment line.

Field name

Name of an input field, output field, or output/input field.

Blank

This D specification line specifies only constant data.

7

7·12

Field name

Blank

13·14
15·18

Field length

1·1919

The entry must be right·justified, but leading zeros are not required.

19·20

Line number

01·nn

Relative line number on which data appears. The actual line number
is start Iine number (column 17 and 18 on the S specification) plus
this line number, minus one.'
nn (maximum)

= 24 - starting line number

21·22

Horizontal position

01·80

Column number of the first position of the field. Columns 19
through 22 cannot be 0101.

23·24

Output data

Y
(column 23)

If constant data or a message identification code is also specified
in columns 57 through 79, that constant data or the specified
message is displayed in the field.
If no constant data or message identification code is specified in
columns 57 through 79, data from the user program output record
is displayed.

N (column
23) or blank

The field is not an output field.

01·99

If the specified indicator is on when the format is displayed, data
supplied by the user program is displayed in the field.
If the specified indicator is off when the format is displayed, data
specified in columns 57 through 79 is displayed. If no data is
specified in columns 57 through 79, blanks are displayed.
If the user program performs an override operation and the specified
indicator is on, data supplied by the user program is displayed in the
field. See Special Display Format Considerations in Chapter 13 for
a description of an override operation.
If the user program performs an override operation and the specified
indicator is off, the field is unchanged.

25

Blank

Display Screen Format Specifications

A·37

D Specifications (continued)
Columns

Name

Entry

Explanation

26

Input allowed

y

The operator can enter information into the field from the keyboard.

N or blank

The operator cannot enter information into the field from the
keyboard.

A

The field can contain only alphabetic data.

B or blank

The field can contain only alphameric data.

K

The field can contain Katakana characters.

N

The field can contain only numeric data. Commas, a period, a plus
sign, or a minus sign can also be entered in this field.

27

Data type

Note: If special characters are entered in an N-type field, the
data read by the RPG program may not be as expected. The
program uses only the digit portion of characters entered in
an N-type field. The zone portion is forced to hex F, except
for the sign position (see Zoned Decimal Format in Chapter 7).

28

Mandatory fill

S

The field can contain only signed numeric data; the last position of
the field is reserved for a sign. Only decimal digits (0 through 9)
can be entered in the field. The field can be from 2 to 16 characters
long.

y

Operators must key all or key none of the field.

N or blank

Operators can key all, none, or part of the input field.

Note: Mandatory fill and adjust/fill (column 31) cannot be specified
for the same field.
29

30

A-38

Mandatory entry

Self check

Summary Charts

Y

Operators must enter at least one character or a blank in the input
field.

N or blank

Operators can bypass the input field.

T

The input field is a modulus 10 self-check field.

E

The input field is a modulus 11 self-check field.

Blank

The input field is not a self-check field.

D Specifications (continued)
Columns

Name

Entry

Explanation

31

Adjust/fill

z

Information entered into the field is right-justified, and unused
positions are filled with zeros.

B

Information entered into the field is right-justified, and unused
positions are filled with blanks.

Blank

For signed numeric fields, the information entered in the field is
right-justified and blank fill is assumed. For alphameric fields,
the information entered in the field is unchanged.
Note: Mandatory fill (column 28) and adjust/fill cannot be specified

for the same field.

Display Screen Format Specifications A-39

D Specifications (continued)
Columns

Name

Entry

Explanation

32-33

Position cursor

y

Cursor appears at the first position of the input field when this
format is displayed.

(column 32)

34

35

36

37-38

Enable Dup

Controlled field
exit

Auto record advance

Protect field

N (column
32) or blank

Cursor does not appear at the first position of the input field.

01-99

Cursor appears at the first position of the input field only if the
specified indicator is on.

y

When the Dup key is pressed, the position of the cursor and the
remainder of the field are filled with the duplicate character value
(hex 1C), which is displayed as an asterisk (*). The duplicate
characters must be processed by the user porgram.

N or blank

The Dup key has no effect in the field.

y

Cursor does not leave the input field until the operator presses a
field exit key (Field Adv, Enter/Rec Adv, Field Exit, Field +, Field[if the field is a signed-numeric field] , Field Backspace, Home,
Erase Input, or Dup).

N or blank

Cursor automatically skips to the next unprotected field when the
operator keys the last position of the field.

Y

The input fields on the screen automatically return to the user
program when one of the following occurs:
• The operator enters the last character in the field.
• The cursor is in the input field and the operator presses the
Field Exit, Field +, or Field - key (if the field is a signea-numeric
field).

N or blank

Automatic record advance does not occur for this field.

y

The cursor skips the field.

(column 37)
. N (column
37) or blank
01-99

The cursor does not skip the field.

The cursor skips the field if the specified indicator is on.
Note: If an override operation is used, this indicator is ignored.

A-40

Summary Charts

D Specifications (continued)
Columns

Name

Entry

Explanation

39-40

High intensity

y

The field is displayed with high intensity.

(column 39)
N (column
39) or blank

The field is displayed with normal intensity.

01-99

The field is displayed with high intensity if the specified indicator
is on.
Note: High intensity, reverse image (columns 45-46), and underline
(columns 47-48) cannot all be specified for the same field at the
same time.

41-42

Blink field

y

The field blinks.

(column 41)

43-44

45-46

47-48

Nondisplay

Reverse image

Underline

N (column
41)orblank

The field does not blink.

01-99

The field blinks if the specified indicator is on when the format is
displayed.

Y
(column 43)

The field is nondisplay; that is, information in the field when the
format is displayed or information entered into the field by the
operator is not visible on the screen.

N (column
43) or blank

The information in the field is displayed.

01-99

The field is a nondisplay field if the specified indicator is on when
the format is displayed.

Y
(column 45)

The characters in the field appear as dark characters on a light
background.

N (column
45) or blank

The characters in the field appear as light characters on a dark
background.

01-99

The characters in the field appear as dark characters on a light
background if the specified indicator is on when the format is
displayed.

y

The field is underlined.

(column 47)
N (column
47) or blank

The field is not underlined.

01-99

The field is underlined if the specified indicator is on.

Display Screen Format Specifications A-41

o Specifications (continued)
Columns

Name

Entry

Explanation

49

Column separators

Y

Each character position in the field is preceded by a column
separator (a vertical line). The column separator does not require an
additional character position.

N or blank

Column separators are not used.

Blank

50-55
56

57-79

Constant type

C

The constant information in columns 57 through 79 is to be
displayed in the output field. C is required only if columns 57
through 79 are blank and you want to display all blanks in the field.
C is invalid if an indicator is specified in columns 23 and 24.

M

A message identification code and a message member identifier are
entered in columns 57 through 79.

Blank

If columns 57 through 79 contain constant information, that
information is displayed. If columns 57 through 79 are blank, then
information from the program output record area is displayed.

Constant data

This field specifies the information to be placed in an output or
output/input field when the format is generated. If information is
to be placed in the field, columns 57 through 79 should contain one
of the following:
• The actual information to be display"ed.
• A four-digit message identification code in columns 57 through
60 and a 2-character message member identifier in columlls 61
and 62.

Notes:
1. If columns 57 through 79 are blank and the field is an output
field (Y in column 23), then information from the program
output record is displayed.
2. If a message identification code is specified in columns 57
through 79, then only 6 bytes need be reserved for the field in
the program output record area.
80

Continuation

x

If more than 23 characters of data are required, an X in column 80
indicates that the record ,is continued. Use columns 7 through 79 of
the following record for the continued constant data.

Note: A comment cannot follow a record with X in
column 80.

A-42 Summary Charts

Appendix B. Printed Messages

This appendix describes the printed messages generated
by the ·RPG II compiler. The compiler prints a message
when an error is detected during compilation of RPG II
source specifications. No operator action is required
when these errors occur. The messages are for use by
the programmer.
Each message includes:
• Program identification code (RPG). Auto report
messages are printed with the identification NOTE
instead of RPG.
• A four-digit message identification code.
• Message text.
• Severity code:
-

-

W (Warning) Warning that an abnormal condition
exists. Corrective action is required only if
the condition is unintentional. The
compilation is completed, and the program
can be executed with warning errors.
T (Terminal) An error condition exists that requires
corrective action before the system can
compile the program. The program cannot
be executed with terminal errors.

• The specification type of the error causing the
message to be issued.
An explanation of the message, when included,
describes the message in more detail, describes any
action taken by the system, and suggests a response to
correct the error condition.

RPG II MESSAGES

RPG-0002 INVALID ENTRY IN COLUMN 10,
ASSUME BLANK.

RPG-0003 INVALID LISTING OPTION IN
COLUMN 11, ASSUME BLANK.
Severity: Warning
Specification Type: H
Explanation: The listing options entry in column 11 is
not B, P, or blank. Blank is assumed. Therefore, a
source program and the object program are
produced.

RPG-0004 INVALID OR BLANK STORAGE
SIZE TO EXECUTE ENTRY IN
COLUMN 12-14, ROUNDED UP
TO 2K MULTIPLE OR REGION
SIZE ASSUMED.
Severity: Warning
Specification Type: H
Explanation: (1) Columns 12 through 14 are blank, or
(2) they contain an entry greater than 64K, or (3)
the entry is not a multiple of 2K. The size of the
region used for compiling is assumed, or, if item
(3) is the error, the entry is rounded up.

RPG-0005 INVALID DEBUG CODE IN
COLUMN 15, ASSUME BLANK:
Severity: Warning
Specification Type: H
Explanation: The debug code in column 15 is neither
1 nor blank.

RPG-0006 CONTROL SPECIFICATION WAS
PREVIOUSLY DEFINED. CURRENT
SPECIFICATION IS IGNORED.

Severity: Warning

Severity: Warning

Specification Type: H

Specification Type: H

Explanation: The object output entry in column 10 is
not D or blank. Blank is assumed.

Explanation: Only one control specification per
program is allowed. The specification is ignored
and the job continues.

RPG Messages

8-1

RPG-0007 INVALID ENTRY IN COLUMN 57,
ASSUME TRANSPARENT LITERAL
SUPPORT.
Severity: Warning

RPG-0008 INVALID ENTRY IN COLUMN 37,
ASSUME BLANK.

Specification Type: H
Explanation: The inquiry entry in column 37 of the
control specification is not I, 8, or blank.

RPG-OOI0 INVALID ENTRY IN COLUMN 18,
ASSUME BLANK.
Severity: Warning

SEQUENCE ENTRY IN COLUMN
26, ASSUME S.
Severity: Warning

Explanation: The alternate collating sequence entry in
column 26 of the control specification is neither
blank nor S. The S entry alters the normal
collating sequence.

RPG-0015 INVALID ENTRIES IN COLUMNS
27-36 AND/OR 38-40, ASSUME
BLANK.
Severity: Warning

Specification Type: H
Explanation: Valid entries for column 18 are any
characters except those having special significance
in edit words or edit codes. The .following are not
valid:

& (ampersand)
. (decimal point)
- (minus)
R (letter R)

, (comma)
C (letter C)

RPG-0014 INVALID ALTERNATE COLLATING

Specification Type: H

Warning

* (asterisk)

Severity: Warning

Explanation: These columns must be left blank.

Explanation: A character other than a 1 or a blank
was found in column 57. Column 57 is assumed
to contain 1.

o (zero)

22-25, ASSUME BLANKS.

Specification Type: H

Specification Type: H

Severity:

RPG-0013 INVALID ENTRIES IN COLUMNS

Specification Type: H
Explanation: These columns must be left blank.

RPG-0016 INVALID 1 P OUTPUT REPEAT
ENTRY IN COLUMN 41, ASSUME
1.
Severity: Warning
Specification Type: H

RPG-OOll INVALID ENTRY IN COLUMNS
16-17, ASSUME BLANKS.

Explanation: Column 41 (1 P forms position) of the
control specification is neither 1 nor blank.

Severity: Warning
Specification Type: H

Explanation: These columns must be left blank.

RPG-0012 INVALID INVERTED PRINT ENTRY
IN COLUMN 21, ASSUME BLANK.
Severity: Warning
Specification Type: H
Explanation: The inverted print entry in column 21 of
the control specification is not I, D, J, or blank.

8-2

Printed Messages

RPG-0017 INVALID ENTRY IN COLUMN 42,
ASSUME BLANK.
Severity: Warning
Specification Type: H
Explanation: This column must be left blank.

RPG-0018 INVALID FILE TRANSLATION
ENTRY IN COLUMN 43, ASSUME

F.
Severity: Warning
Specification Type: H
Explanation: The file translation entry in column 43 is
neither F nor blank.

RPG-0023 INVALID OR BLANK FILENAME IN
COLUMNS 7-14.
Severity: Terminal
Specification Type: F, I, L, T, or 0
Explanation: Filename specified in columns 7 through
14 is invalid. The job is terminated and the entire
specification is ignored.

RPG-0019 INVALID ENTRY IN COLUMN 44,

RPG-0024 FILENAME PREVIOUSLY DEFINED

ASSUME BLANK.

IN COLUMNS 7-14.

Severity: Warning

Severity: Terminal

Specification Type: H

Specification Type: F

Explanation: Column 44 must be left blank.

Explanation: The filename is not unique. The job is
terminated and the entire specification line is
ignored.

RPG-0020 INVALID NON-PRINTABLE
CHARACTER ENTRY IN COLUMN
45, ASSUME 1.
Severity: Warning
Specification Type: H
Explanation: This column must contain a 1 or blank.

RPG-0021 INVALID ENTRIES IN COLUMNS
46-47, 49-51, 54-56, OR 58-74,
ASSUME BLANKS.
Severity: Warning
Specification Type: H
Explanation: These columns must be blank.

RPG-0025 INVALID DEVICE NAME IN
COLUMNS 40-46, ASSUME DISK.
Severity: Terminal
Specification Type: F
Explanation: The entry in columns 40 through 46 is
not a valid device name. DISK is assumed, but the
job is terminated.

RPG-0026 INVALID OR BLANK FILE TYPE
ENTRY IN COLUMN 15, ASSUME
DEFAULT FOR DEVICE.
Severity: Terminal
Specification Type: F

RPG-0022 INVALID ENTRY IN COLUMN 6
OR SPECIFICATION TYPE OUT OF
SEQUENCE.
Severity: Terminal
Specification Type: H, F, E, L, T, I, C, or 0
Explanation: Valid entries for column 6 are H, F, E, L,
T, I, C, or 0, in the order listed. The job is
terminated and the entire specification is ignored.

Explanation: The file type entry in column 15 is not I,
0, U, or C or a record address file (R in column
16) is specified and the file type is not I. 0 is
assumed for files assigned to CRT or PRINTER; I
is assumed for files assigned to KEYBORD, BSCA,
or CONSOLE; U is assumed for files assigned to
DISK; C is assumed for files assigned to SPECIAL
or WORKSTN. The job is terminated.

RPG Messages

8-3

RPG-0027 POSITION 19 IN CONTROL
SPECIFICATION NOT BLANK, M,
D, OR Y, ASSUME M IF POSITION
21 BLANK.
Severity: Warning
Specification Type: H
Explanation: Position 19 should be M, D, V, or blank.
Assume M if position 21 is blank, or assume D if
position 21 is I or J.

RPG-0028 FILE DESIGNATION IN COLUMN
16 IS INVALID FOR EITHER FILE
TYPE OR DEVICE, ASSUME
SECONDARY.
Severity: Warning
Specification Type: F
Explanation: The entry in column 16 is not valid for
an input or an update file. S is assumed and the
job continues.

RPG-0029 INVALID ENTRY IN COLUMNS
52-53, ASSUME 32.
Severity: Warning
Specification Type: H
Explanation: An entry other than blank or 01-32 was
entered in columns 52 and 53, or 00 was entered
in columns 52 and 53 and *NONE was not
specified on an FMTS continuation line.

RPG-0030 FILE DESIGNATION ENTRY IN
COLUMN 16 INVALID FOR
OUTPUT FILE, ASSUME BLANK.

RPG-0032 NO PRIMARY FILE SPECIFIED IN
COLUMN 16, ASSUME FIRST
SECONDARY AS PRIMARY.
Severity: Warning
Specification Type: F
Explanation: If a primary file is not specified (P in
column 16) in the file description specifications
and one or more secondary' files are specified, the
first secondary file is assigned as the primary file.
When no primary or secondary files are assigned,
you must provide an exit for your program by
turning on the LR indicator.

RPG-0034 MULTIPLE PRIMARY FILES
DEFINED IN COLUMN 16,
ASSUME SECONDARY.
Severity: Warning
Specification Type: F
Explanation: More than one primary file (P in column
16) was defined in your file description
specifications. All primary files except the first one
are assumed to be secondary.

RPG-0036 INVALID END OF FILE ENTRY IN
COLUMN 17, ASSUME E FOR
INPUT FILE TYPE WITHOUT
RANDOM PROCESSING.
Severity: Warning
Specification Type: F
Explanation: The entry in column 17 of the file
description specifications is neither E nor blank. E
is assumed for input files not processed randomly;
blank is assumed for all other files.

Severity: Warning
Specification Type: F
Explanation: Column 16 must be blank for output
files (0 in column 15).

RPG-0037 INVALID FILE FORMAT ENTRY IN
COLUMN i9.
Severity: Warning
Specification Type: F
Explanation: The file format entry in column 19 of
your file description specification is not F. F is
assumed.

8-4

Printed Messages

RPG-0038 END OF FILE ENTRY IN COLUMN
17 INVALID FOR FILE TYPE.
Severity: Warning
Specification Type: F
Explanation: Column 18 must be blank for output,
demand, and table files. Blank is assumed.

RPG-0039 INVALID SEQUENCE ENTRY IN
COLUMN 18, ASSUME PREVIOUS
ENTRY.

RPG-0043 DUAL I/O ENTRY IN COLUMN 32
INVALID FOR TYPE OF FILE OR
MODE OF PROCESSING, ASSUME
BLANK.
Severity: Warning
Specification Type: F
Explanation: Dual I/O (1-9 in column 32) cannot be
specified for demand, table, and update files, or
for any file processed randomly. Dual I/O also
cannot be specified if shared I/O (column 48 of
the control specifications) has been specified.

Severity: Warning
Specification Type: F
Explanation: The sequence entry in column 18 is not
A, D, or blank. The entry in column 18 from the
previous line is assumed.

RPG-0040 SEQUENCE ENTRY IN COLUMN
18 INVALID FOR TYPE OF FILE
OR MODE OF PROCESSING,
ASSUME BLANK.
Severity: Warning
Specification Type: F
Explanation: Column 18 must be blank for demand
files, output files, record address files, and for any
files processed randomly.

RPG-0041 INVALID RECORD LENGTH ENTRY
IN COLUMNS 24-27, ASSUME
DEFAULT FOR DEVICE.
Severity: Warning
Specification Type: F
Explanation: Incorrect record length was specified in
columns 24 through 27. The maximum record
length for the device is assumed, except DISK
which is assumed to be 256.

RPG-0044 INVALID ENTRY IN COLUMN 32,
ASSUME BLANK.
Severity: Warning
Specification Type: F
Explanation: The entry in column 32 was not 1-9, I,
T, or blank.

RPG-0045 OVERFLOW INDR IN COLS 33-34
PREVIOUSLY DEFINED.
Severity: Terminal
Specification Type: F

RPG-0046 INVALID OVERFLOW INDICATOR
IN COLUMNS 33-34, ASSUME
BLANK.
Severity: Terminal
Specification Type: F
Explanation: The overflow indicator entry in columns
33 a'nd 34 was not OA-OG, or OV. Blank is
assumed, but the job is terminated.

RPG-0047 OVERFLOW INDICATOR IN
COLUMNS 33-34 INVALID FOR
DEVICE, ASSUME BLANK.
Severity: Warning

RPG-0042 INVALID BLOCK LENGTH
ENTRIES IN COLUMNS 20-23,
ASSUME RECORD LENGTH.
Severity: Warning

Specification Type: F
Explanation: The overflow indicator in columns 33
and 34 was not assigned to a printer file.

Specification Type: F
Explanation: The block length entry in columns 20
through 23 is neither equal to nor a multiple of the
record length specified in columns 24 through 27.

RPG Messages

8-5

RPG-0048 INVALID OR BLANK EXTENSION

RPG-0055 FILE CONDITIONING ENTRIES IN

CODE ENTRY IN COLUMN 39
FOR TABLE FILE OR RECORD
ADDRESS FILE, ASSUME E.

COLUMNS 71-72 INVALID FOR
TABLE FILES OR KEYBORD,
ASSUME BLANK.

Severity: Warning

Severity: Warning

Specification Type: F

Specification Type: F

RPG-0049 INVALID EXTENSION CODE
ENTRY IN COLUMN 39; ASSUME
L.
Severity: Warning

Explanation: Columns 71 and 72 must be left blank
for table files, because table files cannot be
conditioned by U 1 - U8.

RPG-0057 INVALID FILE CONDITIONING
ENTRIES IN COLUMNS 71-72.

Specification Type: F
Explanation: The entry in column 39 is neither L nor
blank for output files assigned to the printer. L is
assumed and the job continues.

RPG-0051 EXTENSION CODE ENTRY IN
COLUMN 39 INVALID WITH
DEVICE, OR WITH P, S, C, OR D
IN COLUMN 16, ASSUME BLANK.

Severity: Terminal
Specification Type: F
Explanation: Columns 71 and 72 of your file
description specification are not blank nor do they
contain one of the external indicators (U1-U8).

RPG-0058 INVALID ENTRIES IN COLUMNS
67, AND/OR 73-74, ASSUME
BLANK.

Severity: Warning
Specification Type: F

Severity: Warning
Spec~fication

RPG-0052 DEVICE IN COLUMNS 40-46
PREVIOUSLY ASSIGNED TO
OUTPUT OR, NON-TABLE INPUT
FILE OR MORE THAN EIGHT
PRINTER FILES DEFINED.
Severity: Terminal
Specification Type: F
Explanation: The device name in columns 40 through
46 was assigned to more than one output or
non-table input file. The job is terminated and the
entire specification may cause other errors to be
generated.

Type: F

Explanation: Columns 67, and 73 and 74 must be left
blank.

RPG-0060 INVALID ENTRY IN COLUMN 48,
ASSUME BLANK.
Severity: Warning
Specification Type: H
Explanation: To indicate shared input/output buffer
areas for disk files, enter a 1 in column 48;
otherwise, leave column 48 blank.

RPG-0061 INVALID ENTRIES IN COLUMNS
RPG-0053 INVALID ENTRIES IN COLUMNS
47-52, ASSUME BLANKS.
Severity: Warning
Specification Type: F
Explanation: These columns must be left blank.

8-6

Printed Messages

7-10, ASSUME BLANK.
Severity: Warning
Specification Type: E
Explanation: Columns 7 through 10 must be left
blank.

RPG-0062 INVALID OR UNDEFINED FROM
FILENAME ENTRY IN COLUMNS
11-18.
Severity: Terminal
Specification Type: E
Explanation: The from filename in columns 11
through 18 of your extension specifications is
invalid or has not been previously defined in file
description specifications. (The from filename
must start in column 11.)

RPG""0067 INVALID TABLE OR ARRAY NAME
IN COLUMNS 27-32.
Severity: Terminal
Specification Type: E
Explanation: The table or array name in columns 27
through 32 was not specified properly. A table or
array name must start in column 27. A table name
must begin with TAB; an array name must not
begin with TAB.

RPG-0068 INVALID OR MISSING NUMBER
RPG-0063 TYPE OF FILE INVALID FOR
FROM FILENAME ENTRY IN
COLUMNS 11-18.
Severity: Terminal
Specification Type: E
Explanation: The from filename does not refer to a
table or record address input file.

RPG-0064 INVALID OR UNDEFINED TO

OF ENTRIES PER RECORD ENTRY
IN COLUMNS 33-35, ASSUME 08.
Severity: Terminal
Specification Type: E
Explanation: The entry in columns 33 through 35 is
missing on a specification line that has a from
filename in columns 11 through 18, or it is not a
one- to three-digit number (1-999). 08 is
assumed, but the job is terminated.

FILENAME IN COLUMNS 19-26.
Severity: Terminal
Specification Type: E
Explanation: The to filename in columns 19 through
26 of your extension specifications is invalid or has
not been defined in file description specifications.
(The to filename must start in column 19.)

RPG-0065 TYPE OF FILE INVALID OR
INCORRECT FOR TO FILENAME
ENTRY IN COLUMNS 19-26.
Severity: Terminal
Specification Type: E
Explanation: The to filename entry does not refer to
an output file or to a file processed by a record
address file.

RPG-0070 INVALID OR MISSING NUMBER
OF ENTRIES PER TABLE OR
ARRAY IN COLUMNS 36-39,
ASSUME 05.
Severity: Terminal
Specification Type: E
Explanation: The entry in columns 36 through 39 is
missing or it is not a one- to four-digit number
(1-9999). 05 is assumed, but the job is
terminated.

RPG-0071 NUMBER OF ENTRIES PER
RECORD IN COLUMNS 33-35
EXCEEDS NUMBER OF ENTRIES
PER TABLE/ARRAY IN COLUMNS
36-39.
Severity: Terminal
Specification Type: E

qPG Messages

8-7

RPG-0072 INVALID OR MISSING LENGTH
OF ENTRY IN COLUMNS 40-42
OR 52-54, ASSUME 05.

RPG-0076 INVALID DECIMAL POSITION
ENTRY IN COLUMN 44 OR 56,
ASSUME O.

Severity: Terminal

Severity: Terminal

Specification Type: E

Specification Type: E

Explanation: The length of entry specified is missing
or is not a one- to three-digit number (1-15 for
numeric entries; 1-256 for alphabetic entries). 05
is assumed, but the job is terminated.

Explanation: The decimal position entry in column 44
or column 56 is not 0-9 or blank. Zero is
assumed, but the job is terminated.

RPG-0077 INVALID SEQUENCE ENTRY IN
RPG-0073 LENGTH SPECIFIED FOR EACH
TABLE/ARRAY RECORD, IN .
COLUMNS 33-35 AND 40-42 OR
52-54, EXCEEDS RECORD
.
LENGTH.
Severity: Terminal
Specification Type: E
Explanation: The table record length specified (length
of entry times number of entries per record) is
greater than the record length you specified for the
table file in the file description specifications.

RPG-0074 INVALID PACKED OR BINARY
ENTRY IN COLUMN 43 OR 55,
ASSUME BLANK.
Severity: Warning
Specification Type: E
Explanation: The entry in column 43 or column 55 of
the extension specifications is not P, B, or blank.

RPG-0075 PACKED OR BINARY VALID ONLY
FOR PRE-EXECUTION TIME
TABLES OR ARRAYS.
Severity: Terminal
Specification Type: E
Explanation: Packed or binary format can be specified
(column 43 or column 55) only for
preexecution-time tables or arrays. Blank is
assumed, but the job is terminated.

8-8

Printed Messages

COLUMN 45 OR 57, ASSUME
BLANK.
Severity: Terminal
Specification Type: E
Explanation: The sequence entry in column 45 or
column 57 is not A, D, or blank. Blank is
assumed, but the job is terminated.

RPG-0079 INVALID ALTERNATE
TABLE/ARRAY NAME IN
COLUMNS 46-51.
Severity: Terminal
Specification Type: E
Explanation: The table or array name in columns 46
through 51 was not specified properly. The table
or array name must start in column 46. A table
name must begin with TAB.

RPG-0080 ALTERNATE TABLE/ARRAY
NAME IN COLUMNS 46-51
AND/OR 27-32 MISSING FOR
ENTRIES IN COLUMNS 33-45
AND/OR 52-57, ASSUME
COLUMNS 33-57 AND/OR 46-57
BLANK.
Severity: Terminal
Specification Type: E
Explanation: Columns 52 through 57 contain entries
describing an alternating table or array, but no
alternating table or array name was specified in
columns 46 through 51 or no table or array name
was specified in columns 27 through 32.

RPG-0082 LENGTH OF TABLE/ARRAY IN
COLUMNS 40-42 OR 52-54 FOR
ALPHAMERIC FIELD EXCEEDS
MAXIMUM.
Severity: Terminal

RPG-0086 FILENAME IN COLUMNS 7-14
DOES NOT REFER TO PRINTER
FILE.
Severity: Terminal
Specification Type: L

Specification Type: E
Explanation: The length of table or array entry
specified in columns 40 through 42 or 52 through
54 is too large. 256 is assumed for noncom pile
time tables or arrays; a record length of 96 is
assumed for compile time tables or arrays.

RPG-0087 FORM LENGTH ENTRY IN
COLUMNS 15-17 INVALID OR
GREATER THAN 255.
Severity:. Terminal
Specification Type: L

RPG-0083 LENGTH OF TABLE/ARRAY
ENTRY IN COLUMNS 40-42 OR
52-54 FOR NUMERIC FIELD
EXCEEDS 15, ASSUME 15.

RPG-0088 INVALID OR MISSING FORMS
LENGTH ENTRY IN COLUMNS
18-19, ASSUME FL.

Severity: Terminal

Severity: Warning

Specification Type: E

Specification Type: L

RPG-0084 FILE AND RECORD TYPE ENTRIES
COLUMNS 7-42 AND FIELD TYPE
ENTRIES COLUMNS 43-74 ON
THE SAME LINE, ASSUME 7-:-42
BLANK.
Severity: Terminal
Specification Type:
Explanation: Field type entries (columns 43 through
74) are not specified one line lower than file and
record type entries (columns 7 through 42).

RPG-0085 INVALID, MISSING OR
UNDEFINED FILENAME OR DATA
STRUCTURE.
Severity: Terminal
Specification Type: L, I, C
Explanation: Either (1) the filename was missing, (2)
the filename was not specified properly, or (3) the
filename was. not previously defined in the file
description specifications.

This message is issued when the entries in
columns 7 through 14 of the input specifications
are not in the filename table or the name table (for
data structureL or the name is invalid (for example,
more than 6 characters used for data structure).

RPG-0089 OVERFLOW LINE ENTRY IN
COLUMNS 20-22 INVALID OR
GREATER THAN 255.
Severity: Terminal
Specification Type: L

RPG-0090 INVALID OR MISSING
OVERFLOW LINE ENTRY IN
COLUMNS 23-24, ASSUME OL.
Severity: Warning
Specification Type: L

RPG-0091 OVERFLOW LINE IN COLUMNS
20-22 EXCEEDS FORM LENGTH
IN COLUMNS 15-17, ASSUME
FORM LENGTH.
Severity: Terminal
Specification Type: L

RPG-0092 INVALID OR UNDEFINED
FILENAME IN COLUMNS 7-14.
Severity: Terminal
Specification Type: L, I, C, 0
Explanation: The filename entry is not specified
properly, or it was not previously defined in the file
description specifications.

RPG Messages

8-9

RPG-0093

FILE AND RECORD TYPE ENTRIES
IN COLUMNS 7-42 AND FIELD
TYPE ENTRIES IN COLUMNS
43-74.

RPG-0097

Severity: Terminal
Specification Type:
Explanation: Field description entries (columns 43
through 74) are not specified one line lower than
file and record identification entries (columns 7
through 42). Field type entries (columns 43
through 74) are assumed to be blank and the job
is terminated.

RPG-0094

FILE AND RECORD TYPE
DESCRIPTION MUST PRECEDE
THIS SPECIFICATION.

Severity: Terminal

NO FIELD DESCRIBED FOR THIS
OR PREVIOUS RECORD OR DATA
STRUCTURE. IF DATA
STRUCTURE, LENGTH DEFAULTS
TO ONE.

Severity: Warning
Specification Type:

RPG-0098

INVALID SEQUENCE ENTRY IN
COLUMNS 15-16, ASSUME
ALPHABETIC SEQUENCE ENTRY.

Severity: Warning
Specification Type:
Explanation: The sequence entry in columns 15 and
16 is neither a two-digit number nor a 2-character
alphabetic entry; or numeric entry is invalid for
device type or file type.

Specification Type:
Explanation: File and record type entries in columns 7
through 42 do not precede the related field
description entries in columns 43 through 74:
Enter the file and record type entries in columns 7
through 42 of the specifications line immediately
preceding the related field description entries in
columns 43 through 74.

RPG-OIOI

NUMERIC SEQUENCE ENTRY IN
COLUMNS 15-16 NOT IN
ASCENDING ORDER OR THE
FIRST IS NOT 01, ASSUME
PREVIOUS NUMERIC SEQUENCE
OR 01 IF FIRST NUMERIC
RECORD.

Severity: Warning

RPG-0095

AND OR OR LINE OUT OF
ORDER.

Severity: Terminal
Specification Type: I, C
Explanation: The AND or OR line does not follow the
proper file or record type entries or is on the first
line of the calculation specifications. (The system
may have dropped your file and record type
specifications because of other errors in your
program.)

RPG-0096

AND LINE FOLLOWS LINE WITH
NO RECORD IDENTIFICATION
CODES.

Severity: Terminal
Specification Type:

8-10

Printed Messages

Specification Type:
Explanation: Either the first numeric sequence entry is
not 01 or the numeric sequence entries are not in
ascending order. If this is the first numeric
sequence entry, 01 is assumed; otherwise, the
numeric sequence entry from the previous
specification line is assumed.

RPG-OI02

INVALID NUMBER ENTRY IN
COLUMN 17 FOR NUMERIC
SEQUENCE, ASSUME N.

Severity: Warning
Specification Type:
Explanation: The number entry in column 17 is
neither 1 nor N.

RPG-OI03 INVALID OPTION ENTRY IN
COLUMN 18 FOR NUMERIC
SEQUENCE, ASSUME O.
Severity: Warning
Specification Type:
Explanation: The option entry (column 18) must be
blank, 0, or U (if DS has been specified in
columns 19 and 20 of the input specifications).

RPG-OI07 INVALID NOT ENTRY IN COLUMN
25, 32, OR 39, ASSUME N.
Severity: Warning
Specification Type:
Explanation: The entry in column 25, 32, or 39 is not
N or blank.

RPG-OI08 INVALID C/Z/D ENTRY IN
COLUMN 26, 33, OR 40, ASSUME

RPG-OI04 NUMBER/OPTION ENTRIES IN
COLUMNS 17-18 INVALID WITH
ALPHAMERIC SEQUENCE
ENTRIES. ENTRIES NOT
SPECIFIED CORRECTLY FOR
DATA STRUCTURES.
Severity: Terminal

C.
Severity: Warning
Specification Type:

RPG-Olll INVALID ENTRY IN COLUMN 43,
ASSUME BLANK.

Specification Type:

Severity: Warning

Explanation: Columns 17 and 18 must be blank when
columns 15 and 16 contain an alphabetic sequence
entry.

Specification Type:

Column 17 must be blank for a data structure.
Column 18 must be blank or contain a U for a
data structure specified as the display station local
data area.

RPG-OI05 NUMBER/OPTION ENTRIES IN
COLUMNS 17-18 INVALID FOR
AND OR OR LINE, ASSUME
BLANK.
Severity: Warning
Specification Type:
Explanation: Columns 17 and 18 must be blank in an
AND or OR line.

RPG-OI06 INVALID POSITION ENTRY FOR
RECORD IDENTIFICATION CODES
IN COLUMNS 21-24,28-31, OR
35-38, OR TO POSITION
COLUMNS 48-51, ASSUME 1.
Severity: Terminal
Specification Type:
Explanation: The position entry for record
identification codes or the to position for a field
exceeds the record length.

Explanation: The entry in column 43 is not P, B, or
blank.

RPG-Ol12 INVALID OR BLANK FROM
AND/OR TO ENTRY OR INVALID
USE OF A KEYWORD, COLUMNS
44-51 AND 52, ASSUME 1 FOR
FROM AND TO POSITIONS.
Severity: Terminal
Specification Type:
Explanation: Columns 44 through 47 and/or 48
through 51 do not contain an entry from 1 to
4096; or for the WORKSTN file information data
structure (lNFDS), columns 44 through 50 do not
contain *RECORD, *OPCODE, *SIZE, *MODE,
*INP, *OUT, or *STATUS or the keywords are
specified incorrectly. Columns 51 and 52 must be
blank if a keyword is specified.

RPG-Ol13 FROM ENTRY IN COLUMNS
44-47 EXCEEDS TO ENTRY IN
COLUMNS 48-51, ASSUME TO
ENTRY EQUAL TO FROM ENTRY.
Severity: Terminal
Specification Type:

RPG Messages

8-11

RPG-Ol14 LENGTH OF NUMERIC FIELDS IN
COLUMNS 44-51 EXCEEuS 15,
ASSUME 15.

RPG-0119 INVALID CONTROL LEVEL
INDICATOR IN COLUMNS 59-60,
ASSUME BLANK.

Severity: Terminal

Severity: Terminal

Specification Type:

Specification Type:

RPG-Ol15 ALPHAMERIC FIELD SPECIFIED
AS PACKED OR BINARY,
ASSUME NUMERIC FIELD.
Severity: Terminal
Specification Type:
Explanation: Leave column 43 blank for alphameric
fields, or make an entry (0-9) in column 52 for
numeric fields.

RPG-Ol16 INVALID DECIMAL POSITION
ENTRY IN COLUMN 52, ASSUME

Explanation: The control level entry in columns 59
and 60 is neither L1 - L9 nor blank. Blank is
assumed, but the job is terminated.

RPG-0120 INVALID MATCHING FIELD
ENTRY IN COLUMNS 61-62,
ASSUME M1.
Severity: Terminal
Specification Type:
Explanation: The matching field entry in columns 61
and 62 is not M1-M9 or blank. M1 is assumed,
but the job is terminated.

O.
Severity: Terminal
Specification Type:
Explanation: The decimal position entry in column 52
is not 0-9 or blank.

RPG-0121 FROM FILE CANNOT HAVE AN E
IN COLUMN 17 OF FILE
DESCRIPTION SPECIFICATION
WHEN TO FILE IS A DEMAND
FILE.
Severity: Terminal

RPG-Ol17 DECIMAL POSITION IN COLUMN
52 INVALID FOR ARRAY,
ASSUME BLANK.
Severity: Warning
Specification Type:
Explanation: No decimal position entry can be
specified in column 52 for an array. Decimal
positions for arrays must be specified in your
extension specifications.

RPG-Ol18 FIELD NAME IN COLUMNS 53-58
MISSING OR INVALID.
Severity: Terminal
Specification Type:
Explanation: The field name entry in columns 53
through 58 is missing or is not specified properly.
An array element or a table name cannot be
specified in a data structure.

8-12

Printed Messsages

Specification Type: E
Explanation: End of file, E in column 17 of the file
description specifications, cannot be used for a
record address file that is used to process a
demand file. Leave column 17 blank.

RPG-0122 FIELD WAS PREVIOUSLY
DEFINED WITH DIFFERENT
LENGTH OR DECIMAL
POSITIONS, OR FIELD WAS
ALREADY DEFINED IN ONE DATA
STRUCTURE. FIRST DEFINITION
IS ASSUMED, OR FIELD IS NOW
DEFINED AS A LOOK AHEAD
FIELD.
Severity; Warning
Specification Type: I, C

RPG-0123 INVALID CONTROL LEVEL ENTRY
IN COLUMNS 7-8.

RPG-0128 INVALID OPERATION CODE IN
COLUMNS 28-32.

Severity: Terminal

Severity: Terminal

Specification Type: C

Specification Type: C

Explanation: The control level entry in columns 7 and
8 is not AN, OR, LO-L9, LR, SR, or blank.

RPG-0124 INVALID NOT ENTRY IN COLUMN
9, 12, OR 15, ASSUME N.
Severity: Warning

RPG-0129 FACTOR 2 FIELD NAME IN
COLUMNS 33-42 EXCEEDS SIX
CHARACTERS.
Severity: Terminal
Specification Type: C

Specification Type: C
Explanation: The entry in column 9, 12, or 15 is not
N or blank.

RPG-0125 INVALID FIELD NAME OR
CONSTANT FOR FACTOR 1 IN
COLUMNS 18-27.
Severity: Terminal

RPG-0130 TO FILE MUST BE A LIMITS FILE
IF FROM FILE IS A RECORD
ADDRESS FILE, OR TO FILE
MUST BE A RANDOM ACCESS
FILE IF FROM FILE IS AN
ADDROUT FILE.
Severity: Terminal
Specification Type: E

Specification Type: C, H
Explanation: The field name or constant in columns
18 through 27 of the calculation specification is
not specified properly. Both must begin in column
18. If a constant contains ideographic data, you
may have forgotten to code the transparent literal
option in column 57 of the control specification.

RPG-0126 LENGTH OF TABLE/ARRAY
EXCEEDS MAXIMUM STORAGE.
Severity: Terminal

RPG-0131 FACTOR 2 IN COLUMNS 33-42
INVALID.
Severity: Terminal
Specification Type: C
Explanation: The field name or constant in columns
33 through 42 of the calculation specification is
not specified properly. Entry must start in column
33. If a constant contains ideographic data, you
may have forgotton to code the transparent literal
option in column 57 of the control specification.

Specification Type: E
Explanation: The number of entries per table/ array
(columns 36 through 39) multiplied by the length
of entry (columns 40 through 42) exceeds
maximum storage. Reduce the number of entries
or the length of the entries.

RPG-0127 FIELD LENGTH ENTRY IN
COLUMNS 49-51 INVALID WITH
NO RESULT FIELD, ASSUME
49-51 BLANK.
Severity: Warning
Specification Type: C

RPG-0132 FACTOR 2 MUST BE A
FILENAME.
Severity: Terminal
Specification Type: C

RPG-0133 NUMERIC FIELD LENGTH
EXCEEDS 15, ASSUME 15.
Severity: Terminal
Specification Type: C
Explanation: Length specified in columns 49 through
51 for numeric field is too large.

RPG Messages

8-13

RPG-0134 ALPHAMERIC FIELD LENGTH
EXCEEDS 256, ASSUME 256.
Severity: Terminal
Specification Type: I, C
Explanation: Length specified in columns 49 through
51 of the calculation specifications or in columns
44 through 51 of the input specifications for an
alphameric field is too large.

RPG-0139 INVALID DECIMAL POSITION
ENTRY IN COLUMN 52, ASSUME

o.
Severity: Terminal
Specification Type: C
Explanation: The decimal position entry in column 52
is not 0-9 or blank.

RPG-0140 INVALID HALF ADJUST ENTRY IN
RPG-0135 INVALID RESULT FIELD ENTRY IN
COLUMNS 43-53.
Severity: Terminal
Specification Type: C

COLUMN 53, ASSUME H.
Severity: Warning
Specification Type: C
Explanation: The half-adjust entry in column 53 is
neither H nor blank.

RPG-0136 INVALID IDEOGRAPHIC LITERAL,
ASSUME LITERAL IS
ALPHAMERIC.
Severity: W
Specification Type: C, 0
Explanation: A literal or a constant beginning with an
apostrophe and the S/D control character was
found, but either no S/I control character was
found, a S/I control character was found but was
not immediately followed by an apostrophe, or an
odd number of 1-byte characters were found
between the S/O and S/I control characters.

RPG-0137 INVALID RESULT FIELD LENGTH
IN COLUMNS 49-51, ASSUME 15
FOR NUMERIC OR 256 FOR
ALPHAMERIC FIELD.
Severity: Terminal
Specification Type: C

RPG-0141 DEBUG CALCULATION
OPERATION USED BUT DEBUG
OPTION NOT SPECIFIED IN THE
CONTROL SPECIFICATION.
Severity: Warning
Specification Type: C
Explanation: You used the DEBUG operation code in
your calculation specifications, but you did not
specify the DEBUG option (1 in column 15) in your
control specifications. DEBUG operations are not
executed.

RPG-0142 FILE AND RECORD
IDENTIFICATION ENTRIES IN
COLUMNS 7-31 AND FIELD
DESCRIPTION ENTRIES IN
COLUMNS 32-74 ON SAME LINE.
Severity: Terminal
Specification Type: 0

RPG-C138 DECIMAL POSITION ENTRY IN
COLUMN 52 INVALID WITH NO
FIELD LENGTH ENTRY IN
COLUMNS 49-51, ASSUME
BLANK.
Severity: Terminal
Specification Type: C

8-14

Printed Messages

Explanation: Your field description entries in columns
23 through 74 are not specified one line lower
than the file and record identification entries in
columns 7 through 31. Blanks are assumed for
columns 7 through 31 and the job is terminated.

RPG-0143 INVALID LINE TYPE ENTRY IN
COLUMN 15.

RPG-0148 INVALID FIELD NAME IN
COLUMNS 32-37.

Severity: Terminal

Severity: Terminal

Specification Type: 0

Specification Type: 0

Explanation: The line type entry in column 15 is not
H, D, T, or E. An E can be used only if an EXCPT
operation is used in the calculation specifications.
H is assumed; the job is terminated.

Explanation: The field name entry in columns 32
through 37 is not specified properly or was not
defined previously in input or calculation
specifications.

RPG-0144 AND OR OR LINE NOT PRECEDED
BY RECORD IDENTIFICATION.

RPG-0149 INVALID OR MISSING
CONSTANT.

Severity: Terminal

Severity: Terminal

Specification Type: 0

Specification Type: 0, H

Explanation: An AND or OR line is not preceded by
record identification entries in columns 15 through

Explanation: The constant in columns 45 through 70
of the output specification is not specified
properly. If the constant contains ideographic data,
you may have forgotten to code the transparent
literal option in column 57 of the control
specification.

31.

RPG-0145 INVALID SKIP/SPACE ENTRIES IN
COLUMNS 17-22 FOR AND LINE,
ASSUME BLANK.
Severity: Warning
Specification Type: 0
Explanation: Columns 17 through 22 of an AND line
contain space/skip entries; they should be blank.

RPG-0146 INVALID FILENAME OR ENTRY IN
COLUMN 15 MISSING ON FIRST
OUTPUT SPECIFICATION.
Severity: Terminal
Specification Type: 0
Explanation: Either columns 7 through 14 contain an
invalid filename or no line type entry was specified
in column 15 of the specification line.

RPG-0147 INVALID NOT ENTRY IN COLUMN
23, 26, OR 29, ASSUME N.
Severity: Warning
Specification Type: 0
Explanation: The entry in column 23, 26, or 29 is
neither N nor blank.

RPG-0150 INVALID BLANK AFTER ENTRY IN
COLUMN 39, ASSUME BLANK.
Severity: Terminal
Specification Type: 0
Explanation: The blank after entry in column. 39 is
neither B nor blank.

RPG-0151 MISSING OR INCORRECTLY
SPECIFIED END POSITION IN
COLUMNS 40-43, ASSUME END
POSITION IS BLANK.
Severity: Warning
Specification Type: 0

RPG-0152 INVALID PACKED OR BINARY
ENTRY IN COLUMN 44, ASSUME
BLANK.
Severity: Warning
Specification Type: 0
Explanation: The entry-in column 44 is not P, B, or
blank.

RPG Messages

B-15

RPG-0153 BLANK END POSITION WAS
SPECIFIED; END POSITION WAS
CALCULATED.
Severity: Warning
Specification Type: 0
Explanation: The end position was calculated from
the last end position specified in this record or
from position 1 if no end positions were specified.

RPG-0159 MISSING RECORD IDENTIFYING
INDICATOR IN COLUMNS 19-20.
Severity: Warning
Specification Type:
Explanation: No record identifying indicator is
specified in columns 19 and 20. Check your input
specifications to determine whether or not a
record identifying indicator should be entered in
columns 19 and 20.

RPG-0154 ENTRIES IN COLUMNS 7-22
INVALID FOR A FIELD
DESCRI PTION SPECI FICATION,
ASSUME BLANK.

RPG-0160 FILE NAME IN C'OLUMNS 7-14
NOT SPECIFIED AS AN INPUT OR
UPDATE-SECONDARY, DEMAND,
PRIMARY OR CHAINED FILE.

Severity: Terminal
Specification Type: 0
Explanation: The file and record identification entries
in columns 7 through 22 are not specified one line
above the first related field description entries.
Place your file and record identification entries
(columns 7 through 22) one line above the field
description entries (columns 32 through 74).

RPG-0155 INVALID ENTRY IN COLUMNS

Severity: Terminal
Specification Type:
Explanation: The file named in columns 7 through 14
was not previously defined in file description
specifications as an input or update file with a
designation of primary, secondary, demand, or
chained.

RPG-0161 AND OR OR LINE INVALID WITH

71-74, ASSUME BLANK.

LOOK AHEAD RECORDS, DATA
STRUCTURES, OR RLABL.

Severity: Terminal
Specification Type: I, 0
Explanation: Columns 71 through 74 mustbe blank.

RPG-0158 TABLE NAME INVALID FOR FIELD
NAME ENTRY IN COLUMNS

53-58.
Severity: Terminal

Severity: Terminal
Specification Type: I, C
Explanation: An AND or OR line was used with
look-ahead fields or RLABL. Make sure that AND
or OR lines are not specified for look-ahead fields
(** in columns 19 and 20) or for RLABL. AND or
OR lines are not valid with a data structure on
input specifications.

Specification Type:

RPG~0162

RECORD IDENTIFYING
INDICATOR IN COLUMNS 19-20
INVALID FOR AN AND LINE.

Severity: Warning
Specification Type:
Explanation: A record identifying indicator is in
columns 19 and 20 of an AND line. Blanks are
assumed.

8-16

Printed Messages

RPG-0163 ENTRIES IN COLUMNS 17-18
AND 21-42 INVALID FOR LOOK
AHEAD RECORD. ENTRIES IN
COLUMNS 59-74 INVALID FOR
LOOK AHEAD FIELD, OR FOR
FIELD IN A DATA STRUCTURE.
Severity: Terminal
Specification Type: .1
Explanation: Columns 17 and 18 and 21 through 42
must be blank for look-ahead records; columns 59
through 74 must be blank for look-ahead fields.
Entries in columns 59 through 74 are not valid for
a field in a data structure.

RPG-0165 INDICATORS IN COLUMNS 65-70
INVALID FOR TABLE/ARRAY OR
FOR FIELD DEFINED AS DATA
STRUCTURE.
Severity: Terminal
Specification Type:
Explanation: Field indicators cannot be used if
columns 53 through 58 contain a table / array
name. Use the field indicators to test numeric
fields. Field indicators in columns 65 through 70
are invalid with a field defined as a data structure.

RPG-0167 RECORD IDENTIFICATION
POSITION COLUMNS 21-38 OR
TO ENTRY IN COLUMNS 48-51
EXCEEDS RECORD LENGTH,
ASSUME RECORD LENGTH.
Severity: Terminal
Specification Type:
Explanation: Field location entries (columns 21
through 38 and 48 through 51) exceed record
length specified in the file description
specifications.

RPG-0168 FIELD NAME IN COLUMNS 53-58
IS A RESERVED WORD OTHER
THAN PAGE, PAGE1 - PAGE7.
Severity: Terminal
Specification Type:
Explanation: PAGE1-PAGE7 are the only RPG II
reserved words that can be entered in these
columns.

RPG-0169 CONTROL OR MATCHING FIELDS
INVALID FOR AN ARRAY OR
DATA STRUCTURE.
Severity: Terminal

RPG-0166 PLUS OR MINUS INDICATOR IN
COLUMNS 65-68 INVALID FOR
ALPHAMERIC FIELD.
Severity: Terminal
Specification Type:
Explanation: A plus or minus indicator in columns 65
through 68 cannot be used to test an alphameric
field. Use plus or minus indicators only to test
numeric fields. An alphameric field can be tested
only for a blank condition (entry in columns 69 and
70). Blank is assumed.

Specification Type:
Explanation: Control or matching fields must not be
specified for arrays. Columns 59 and 60 control .
levels and columns 61 and 62 matching fields are
not valid for a data structure.

RPG-0170 MATCHING OR CONTROL FIELDS
INVALID WITH DEMAND OR
CHAIN FILES OR WORKSTN
DEVICE.
Severity: Terminal
Specification Type:
Explanation: Matching or control fields cannot be
specified for demand or chain files or WORKSTN
device.

RPG Messages

8-17

RPG-0171 LOOK AHEAD RECORDS INVALID
WITH FILE TYPE, OR WITH THIS
DEVICE.
Severity: Terminal
Specification Type:
Explanation: Look-ahead records cannot be specified
for demand files, chained files, CONSOLE files, or
WORKSTN files.

RPG-0172 INCORRECT SEQUENCE OF
INPUT SPECIFICATIONS. IF DATA
STRUCTURE SPECIFIED IT MUST
BE LAST INPUT SPECIFIED.
Severity: Terminal

RPG-0178 BINARY INVALID WITH CONTROL
OR MATCHING FIELDS.
Severity: Terminal
Specification Type:
Explanation: Binary fields have been used as control
or matching fields.

RPG-0179 ARRAY LENGTH SPECIFIED IN
DATA STRUCTURE NOT LARGE
ENOUGH TO CONTAIN ARRAY
AS SPECIFIED IN EXTENSION
SPECS.
Severity: Terminal
Specification Type:

Specification Type:
Explanation: All records from one input or update file
are not specified consecutively. A data structure
. must be specified last on the input specifications.

RPG-0173 NO FIELDS SPECIFIED FOR LOOK
AHEAD RECORD.
Severity: Terminal
Specification Type:
Explanation: A look-ahead record is specified (** in
columns 19 and 20), but no look-ahead fields are
defined (columns 53 through 58).

RPG-0174 LIMITS FILE NOT PROCESSED BY
RECORD ADDRESS FILE OR
SETLL OPERATION CODE.
Severity: Terminal

RPG-0180 ARRAY LENGTH EXCEEDS
LENGTH SPECIFIED IN COLUMNS
36-42 OF EXTENSION
SPECIFICATIONS OR NOT A
MULTIPLE OF THE ENTRY
LENGTH IN COLUMNS 40-42 OF
THE EXTENSION
SPECIFICATIONS.
Severity: Terminal
Specification Type:

RPG-0181 INCONSISTENT FIELD LENGTHS
FOR CONTROL OR MATCHING
FIELDS OF ONE LEVEL. ASSUME
FIRST VALID LENGTH.
Severity: Terminal
Specification Type:

Specification Type: F, C
Explanation: A file is designated to be processed
sequentially within limits, but does not have a
record address file or a SETLL operation code
associated with it.

RPG-0182 INVALID SPLIT CONTROL FIELD
SPECIFICATION. ASSUME
PREVIOUS TOTAL LENGTH FOR
THIS LEVEL.
Severity: Terminal

RPG-0175 INVALID FILE TYPE FOR SETLL
OPERATION.
Severity: Terminal
Specification Type: C
Explanation: The file to be processed by a SETLL
operation code must be a limits file that has not
already been specified to be processed via a
record address file.

B·18

Printed Messages

Specification Type:
Explanation: Specifications for split control fields of
the same level are not specified on successive
lines.

RPG-0183 CONTROL OR MATCHING FIELDS
OF A LEVEL SPECIFIED AS BOTH
ALPHAMERIC AND NUMERIC.
ASSUME NUMERIC.

RPG-0188 FIELD RECORD RELATION
INDICATOR USED IMPROPERLY
WITH MATCH OR CONTROL
FIELD.

Severity: Warning

Severity: Terminal

Specification Type:

Specification Type:

Explanation: All control and matching fields assigned
the same level are not the same type (alphameric
or numeric). Numeric is assumed for all fields
assigned the same control or matching level. If
any field specified as alphameric is greater than 15
characters, only a portion of the field will be used.

Explanation: When used with match or control fields,·
the field record relation indicator in columns 63
and 64 does not match a record identifying
indicator used for this record.

RPG-0189 INVALID SEQUENCE FOR
CALCULATION SPECIFICATIONS.

RPG-0184 ALL OF THE VALID MATCH
LEVELS WERE NOT REFERENCED
IN THE LAST RECORD GROUP.
Severity: Terminal
Specification Type:
Explanation: The same number of match levels are
not specified to all record types in a file.

Severity: Terminal
Specification Type: C
Explanation: Calculation specifications must be
specified in the following order: detail, total,
subroutine.

RPG-0190 INVALID SEQUENCE FOR BEGSR
AND ENDSR OPERATION CODES.

RPG-0186

MATCH OR CONTROL FIELDS
WITHOUT FIELD RECORD RELATION
ENTRIES MUST PRECEDE MATCH OR
CONTROL FIELDS WITH FIELD
RECORD RELATION ENTRIES.
ASSUME PART OF A NEW GROUP
OF MATCH FIELDS.

Severity: Terminal
Specification Type:

RPG-0187 MATCH AND CONTROL FIELDS
WITH FIELD RECORD RELATION
ENTRIES MUST BE GROUPED
ACCORDING TO THE FIELD
RECORD RELATION INDICATOR.
ASSUME NEW GROUP OF
MATCH FIELDS.
Severity: Terminal
Specification Type:
Explanation: When field record relation is used, all
match and control fields assigned the same
indicator (columns 63 and 64) must be grouped
together.

Severity: Terminal
Specification Type: C
Explanation: BEGSR operation code does not precede
ENDSR operation code.

RPG-0191 A SUBROUTINE MUST NOT CALL
ITSELF.
Severity: Terminal
Specification Type: C
Explanation: An EXSR specification within a
subroutine must not call the subroutine it is in. If
you wish to branch to another point within the
same subroutine, use a GOTO and TAG operation.

RPG-0192 BRANCHING BETWEEN
SUBROUTINE AND OTHER
CALCULATIONS INVALID.
Severity: Terminal
Specification Type: C
Explanation: Branching (GOTO and TAG) can only
occur within a subroutine. You cannot branch into
a subroutine or out of a subroutine.

RPG Messages

8-19

RPG-0193 BRANCHING BETWEEN DETAIL,
TOTAL AND LR CALCULATIONS
INVALID.
Severity: Terminal
Specification Type: C
Explanation: Branching must be from detail operation
to detail operation or from total operation to total
operation. It cannot be from detail to total
operation or vice versa.

RPG-0194 SETOF OPERATION INVALID FOR
LR INDICATOR.

RPG-0198 INDICATOR ENTERED IN
COLUMNS 54-57 INVALID WITH
LOKUP ON AN UNSEQUENCED
TABLE OR ARRAY.
Severity: Warning
Specification Type: C
Explanation: Do not specify a search for high or low
in a LOKUP operation on an unsequenced table or
array. Unpredictable results may occur. Specify
the LOKUP operation on an unsequenced table or
array for an equal condition only (indicator in
columns 58 and 59). The system accepts the
indicator as specified.

Severity: Terminal
Specification Type: C
Explanation: The LR indicator cannot be turned off by
the SETOF operation code.

RPG-0199 TEST FOR BOTH HIGH AND LOW
INVALID FOR LOKUP OPERATION.
Severity: Terminal
Specification Type: C

RPG-0195 LENGTH OF SEARCH WORD NOT
EQUAL TO LENGTH OF ELEM ENT
IN TABLE OR ARRAY.
Severity: Terminal
Specification Type: C
Explanation: The length of the search word (factor 1)
is not equal to the length of the element in the
table or array being searched.

RPG-0196 FACTOR 2 OR RESULT FIELD
INVALID FOR LOKUP OPERATION
CODE.
Severity: Terminal
Specification Type: C

RPG-0197 SEARCH TABLE HAS MORE
ENTRIES THAN ITS RELATED
TABLE.

RPG-0200 RESULTING INDICATORS IN
COLUMNS 54-59 REQUIRED OR
NOT ALLOWED FOR OPERATION.
SPECIFIED.
Severity: Terminal
Specification Type: C
Explanation: The resulting indicator entry in columns
54 through 59 is not specified properly. Check to
determine whether resulting indicators are required
for this operation. If so, make the proper entries
(01-99, H1-H9, L1-L9, LR, OA-OG, OV, or
KA-KN, KP-KY).

RPG-0201 HALF ADJUST ENTRY IN
COLUMN 53 FOR DIVISION
OPERATION FOLLOWED BY AN
MVR OPERATION, ASSUME NO
HALF ADJUST.

Severity: Warning

Severity: Warning

Specification Type: C

Specification Type: C

Explanation: The search table (factor 2) contains more
entries than its related table, which is specified in
the result field.

Explanation: When an' MVR operation follows a DIV
operation, the DIV operation must not be
half-adjusted.

8-20

Printed Messages

RPG-0202 MVR OPERATION CODE DOES
NOT FOLLOW DIV OPERATION.

RPG-0209 FILE TYPE INVALID FOR USE
WITH THIS OPERATION CODE.

Severity: Terminal

Severity: Terminal

Specification Type: C

Specification Type: C

Explanation: The MVR operation must immediately
follow a DIV operation.

RPG-0204 HALF ADJUST ENTRY IN
COLUMN 53 INVALID FOR
OPERATION OR NUMBER OF
DECIMAL POSITIONS SPECIFIED,
ASSUME BLANK.
Severity: Warning
Specification Type: C

. Explanation: DEBUG must be used with an output
file; EXCPT must be used with an output file or a
combined file; FORCE must be used with an input,
update, or combined primary or secondary file.
READ must be used with an input, update, or
combined demand file.

RPG-0211 DEBUG SPECIFIED FOR MORE
THAN ONE OUTPUT FILE.
Severity: Terminal
Specification Type: C

RPG-0205 COMP, TESTZ, OR MVR INVALID
. FOR AN ARRAY.

Explanation: The filename entered in factor 2 is not
the same for all DEBUG operations .

Severity: Terminal
Specification Type: C

RPG-0206 INVALID USE OF COMP OR
LOKUP.
Severity: Terminal
Specification Type: C
Explanation: COMP or LOKUP operation specified
improperly. Make sure that factor 1 and factor 2
of a COMP operation are both alphameric or bo.th
numeric. Make sure the search word and the table
or array to be searched are both alphameric or
both numeric.

RPG-0212 EXCPT OPERATION CODE
SPECIFIED BUT NO EXCPT
OUTPUT RECORDS SPECIFIED.
Severity: Warning
Specification Type: C
Explanation: The EXCPT operation code is used, but
no EXCPT records are specified (E in column 15 of
the output specifications).

RPG-0213 PROGRAM CONTAINS
UNASSOCIATED OR MISSING
EXSR/BEGSR LABEL.
Severity: Terminal

RPG-0207 FIELD TYPE, ALPHAMERIC OR
NUMERIC, INVALID FOR
OPERATION SPECIFIED.
Severity: Tenninal

Specification Type: C
Explanation: The label in factor 2 S:
~=!f
n
~

s:

Cl

:::l

c:
!:!..

III

.....
~

3

........

W
~

Comment

CJ)

(")
r-J
.....

~

CJ)
CJ)

-....I

IBM may use and distribute any of the information you supply in any way
it believes appropriate without incurring any obligation whatever. You may,
of course, continue to use the i~formation you supply.

~

Name ______________________________________
Address

• No postage necessary if mailed in the U.S.A.

SC21-7667-4

Fold and tape

Please do not staple

Fold and tape

IIIII

NO POSTAGE
NECESSARY I F
MAl LED IN THE
UNITED STATES

OJ
~

en

~

(ti'

3'

W'
~,

BUSINESS
FIRST CLASS

REPLY

:xl

MAil

PERMIT NO. 40

"0 '
C),

ARMONK, N. Y.

POSTAGE Will BE PAID BY . . .

IBM CORPORATION

".

General Systems Division
Development Laboratory
Publications, Dept. 532
Rochester, Minnesota 55901

Fold and tape

--- ---~::f~
..

International Business Machines Corporation
General Systems Division
4111 Northside Parkway N_W.
P.O. Box 2150
Atlanta, Georgia 30301
(U:S.A. only)
General Business Group/International
44 South Broadway
White Plains, New York 10601
U.S.A.
(I nternational)

Please do not staple

Fold and tape

;

11 ... '"' ....... n

~

,",UIYIIYII;I\l1

rUnlYI

Please use tt,is form only to identify publication errors or request changes to publications. Technical questions about IBM systems, changes in IBM programming
support, requests for additional publications, etc, should be directed to your I BM representative or to the I BM branch office nearest your location.

JJJJ
CD

iJ OJ

CD
::J

=!f
,..

~G)~
n

Error in publication (typographical, illustration, and so on). No reply.
Page Number

Error

. Inaccurate or misleading information in this publication. Please tell us
about it by using this postage-paid form. We will correct or clarify the
publication; o'r tell you why a change is not being made, provided you
'includ'e your name and address.
Page Number

CD

s:
QI

::J

c::

'"CD

3
-..
W

~

~

Comment

Cf)

()

I\J

.....

.!.J

O'l
O'l

-...J

IBM may use and distribute any of the information you supply in any way
it believes appropriate without incurring any obligation whatever. You may,
of course, continue to use the information you supply.

.J:.
Name _________________________________________
Address

• No postage necessary if mailed in the U.S.A.

5C21-7667-4

I

\
»

0'

::J

to

c:

::J
CD

Please do not staple

Fold and tape

Fold and tape

II "I
BUSINESS
FIRST CLASS

REPLY

NO POSTAGE
NECESSARY IF
MAILED IN THE
UNITED STATES

MAil

PERMIT NO. 40

ARMONK,

I\!.

=

Y.

JJ
~
CD

CD
n

POSTAGE Will BE PAID BY . . .

::J
CD

s:

Dl

::J
C
~

IBM CORPORATION
General Systems Division
Development Laboratory
Publ ications, Dept. 532
Rochester, Minnesota 55901

Fold and tape

Please do not staple

Fold and tape

::J

C

en
~

International Business Machinas Corporation
General Systems Division
4111 Northside Parkway N.W.
P.O. Box 2150
Atlanta, Georgia 30301
(U.S.A. only)
General Business Group/International
44 South Broadway
White Plains, New York 10601
U.S.A.
(International)

-~--- ---.--

-- - - --~----

=~=":'=(!)

International Business Machines Corporation
General Systems Division
4111 Northside Parkway N.W.
P.O. Box 2150
Atlanta, Georgia 30301
(U.S.A. only)
: .•

~~!~ "<:

Gene;~1 Business Group/International
44 South Broadway
White Plains, New York 10601
U.S.A.
(International)

to

s:

en

~CD

~

~
(,J
~

:0
"'0

C)

:0
~
~

CD

:::::I

n

CD

s:

CIl

:::::I

c:

~
/I

i1

CD

z

?
en
(,J
~

t..J

~

~

~"
CD

a.
5"

c
en

?>
en

(")

~

.!.J

m
m
'-I

~

SC21-7667-4



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date                     : 2011:10:07 19:27:29-08:00
Modify Date                     : 2011:10:08 09:15:14-07:00
Metadata Date                   : 2011:10:08 09:15:14-07:00
Producer                        : Adobe Acrobat 9.46 Paper Capture Plug-in
Format                          : application/pdf
Document ID                     : uuid:0f4d4343-ed9b-471e-8518-4ba09a4699b8
Instance ID                     : uuid:28e0cd3a-fc8a-433a-b510-3f81a6529a0a
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 703
EXIF Metadata provided by EXIF.tools

Navigation menu