96768710c Itos RPG II Version 2 Oct77

Download as pdf or txt
Download as pdf or txt
You are on page 1of 234

96768710

r:;J c:\ CONTI\.OL DATA


\::I r::J COI\POR<\TION

RPG II
VERSION 2
REFERENCE MANUAL

CDC@ OPERATING SYSTEM:


INTERACTIVE TERMINAL-ORIENTED
SYSTEM (ITOS)
REVISION RECORD
REVISION DESCRIPTION
A :Y1anual released.
(4/77)
B Manual revised; TRACER utility added.
1-. .
(6/77)
c Revised to reflect ITOS 1.1 changes
(10/77)
f-.

L~
-

Publication No.
96768710

REVISION LETTERS I, 0, Q AND X ARE NOT USED


Address comments concerning this
manual to:
Control Data Corporation
Publications and Graphics Division
4455 Easlgate Y1all
© 1977 La Jolla, California 92037
by Control Data Corporation
or use Comment Sheet in the back of
Printed in the United States of America this manual.

ii

AA 4005 REV. 8175


LIST OF EFFECTIVE PAGES

New features, as well as changes, deletions, and additions to information in this manual, are indicated by bars in the margins or by a dot
near the page number if the entire page is affected. A bar by the page number indicates pagination rather than content has changed.

PAGE REV PAGE REV PAGE REV PAGE REV PAGE REV

i:over -- 1-1-2 A
Title pl:lge -- H-3 thru H-6 C
ii r' H-7 A
'-'
iiiiiv ,~ 1-1 C
v/vi B 1-2 C
vii C 1-3 A
viii (' \-4 A
ix C 1-5 C
1-1 thru 1-3 A 1-6 C
2-1 thru 2-7 A J-l C
~-1 A J-2 C
:3-2 A J-3 A
4-1 A Index-l B
4-2 '\ Index-2 B
4-3 C Index-3 A
5-1 thru 5-3 A Index-4 B
ro
5-4 ,- Index-5 A
5-5 thru 5-8 A Index-6 B
5-9 ro
v Comment sheet C
5-10 A Cover --
5-11 A
6-1 thl'u 6-6 A
7-1 A
8-1 thru 8-14 A
9-1 thru 9-8 A
9-9 C
9-10 thru 9-18 A
9-19 C
9-20 A
10-1 thru 10-10 A
10-11 thru 10-15 C
11-1thru11-3 A
12-1 A
12-2 A
12-3 C
12-4 C
12-5 tlJru 12-12 A
13-1 A
13-2 thru 13-9 B
13-10 C
A-I thru A-4 A
8-1 A
C-l thru C-9 A
0-1 thru D-ll A
0-12 C
0-13 thru 0-17 A
£-1 C
£-2 thru E-6 A
£-7 C
£-8 thru E-12 A
;';-13 C
E-14 thru E-28 A
E-29 thru E-32 8
£-33 thru E-36 A
F-1 thru F-6 A
G-l A
G-2 A
H-l A

96768710 C iii/iv

"

AA 5935 REV 7 '76


PREFACE

'l,&@WA4 1+i6iii@".'P'*+"N·4§WQl 't,l • .,,?tfflNk.AwiP;~\ A:8MJMN}W EMAW

a
This is reference manual for the CDC® Small Computer ignored during compilation and execution of an RPG II
Report Program Generator (RPG II) programming language. program. References to- computer memory in this manual
It is intended for programmers having at least one year's involve bytes, characters, and bits rather than words.
programming experience and having some knowledge of file
organizations. For users familiar with IBM's System/3 RPG U. appendix B
lists the important differences between this version of
The RPG II compiler operates directly under the Mass RPG (I and System/3 implementations.
Storage Operating System (MSOS 5) which operates through
the Interactive Terminal Oriented System (ITOS). The following publications are related to RPG U:
This RPG II compiler system is completely byte-oriented,
meaning that word boundaries in computer memory are

Publication Publication Number


Mass-Storage Operating System (MSOS) Version 5
Reference Manual 96769400

(MSOS) Version 5 Diagnostic Handbook 96769450

Interactive Terminal-Oriented System


(ITOS) Version 1 Reference Manual 96768.290

Real-Time Operating System (RTOS) Version 3


Reference Manual 96769560

Sort/Merge Version 1 Reference Manual 96769260

Magnetic Tape Utility Prnessor Reference


Manual 96768400

This product is intended for use only as described in this document. Control Data.
cannot be responsible for the proper functioning of undescribed features or
undefined parameters.

v/vi
96768710 B
CONTENTS

1. INTRODUCTION 1-1 Record Length 5-4


Mode of Processing 5-4
Input/Output 1-1 Consecutive Processing 5-6
RPG II Cycle 1-1 Sequential Processing by Key 5-6
Single Input File Processing 1-1 Sequential Processing Within Limits 5':"61
Multiple Input File Processing 1-2 Processing by ADDROUT File 5-7
Cycle Summary 1-2 Random Processing 5-7
Valid RPG II Names 1-2 Length of Key Field or Record Address Field 5-7
Record Address Type 5-7
File Organization or Additional I/O Area 5-8
2. RPG II SPECIFICATIONS FORMS 2-1 Overflow Indicator 5-8
Key Field Starting Location 5-8
Extension Code 5-8
3. COMMON ENTRIES 3-1 Device 5-9
Symbolic Device 5-9 I
Page 3-1 Continuation Line 5-9
Line 3-1 Continuation Lines Option 5-9
Form Type 3-1 Buffer Offset Length 5-9
Comments 3-1 Name of Label Exit 5-9
Program Identification 3-2 File Addition/Unordered Output 5-9
Number of Extents 5-10
Tape Rewind 5-10
4. CONTROL CARD SPECIFICATIONS- File Condition 5-11
FORM H 4-1

Debug 4-2 6. EXTENSION SPECIFICATIONS - FORM E 6-1


Inverted Print 4-2
Al terna te Collating Sequence 4-2 From Filename 6-2
IP Forms Positioning 4-3 To Filename 6-2
'- ..
File Translation 4-3 Table or Array Name 6-2
Shared 1/0 4-3 Number of Entries per Record 6-2
Intemal Code Specification 4-3 Number of Entries per Table or Array 6-3
Execution in ITOS Environment 4-3 Length of Entry 6-4
Packed or Binary Field 6-4
Unpacked Decimal Format 6-4
5. FILE DESCRIPTION SPECIFICATIONS- Packed Decimal Format 6-4
FORM F 5-1 Decimal Positions 6-5
Sequence 6-5
Filename 5-1 Alternate Table or Array 6-5
File Type 5~1 Comments 6-6
Input Files 5-1
Output Files 5-1
Update Files 5-1 7. LINE COUNTER SPECIFICATIONS -
Combined Files 5-1 FORM L 7-1
Display Files 5-2
File Designation 5-2 Filename 7-1
Primary Files 5-2 Line Number - Number of Lines per Page 7-1
Secondary Files 5-2 Form Length 7-1
Chained Files 5-2 Line Number - Overflow 7-1
Record Address Files 5-2 Overflow Line 7-1
Table or Array Files 5-2
Demand Files 5~3
End-of-File 5-3 8. INPUT SPECIFICATIONS - FORM I 8-1
Sequence 5-3
File Format 5-4 Filename 8-2
Block Length 5-4 Sequence 8-2
Disk Files 5-4 Number 8-2
Tape Files 5-4 Option 8-3

96768710 C vii
Record Identifying Indicator, Look-Ahead Fields, Stacker Sleect/Fetch Overflow 10-2
or Spread Cards 8-3 Stacker Select 10-3
Record Identifying Indicators 8-3 Fetch Overflow 10-3
Look-Ahead Fields 8-4 Overflow Printing with EXCPT
Spread Cards 8-4 Operation Code 10-3
Record Identification Codes 8-6 Forms Control-Space/Skip 10-3
Position 8-6 Space Forms Control 10-;)
NOT(N) 8-6 Skip Forms Control 10-5
C/Z/D 8-6 Output Indicators 10-5
Record Identification Character 8-7 Field Name 10-6
Additional Record Identifications 8-7 Field Names 10-f)
Stacker Select 8-7 PAGE, PAGEl, PAGE2 10-6
Packed or Binary Field 8-7 *PLACE to-7
Field Location 8-8 Date Field 10-8
Decimal Positions 8-8 Edit Codes 10-8
Field Name 8-8 Blank After 10-10
Field Names 8-8 End Position in Output Record 10-10
Special Words (PAGE, PAGEl, PAGE2) 8-8 Packed or Binary Field 10-10
Control Level 8-9 Constant or Edit Word 10-10
:v1atching Fields 8-10 Constants 10-10
Field Record Relation 8-13 Edit Code Modifiers 10-11
Field Indicators 8-14 Eelit Words 10-11
Output Specifications Examples 10-1t
Lines 010 through 190 10-11
9. CALCULATION SPECIFICATIONS- Lines 200 and 210 10-12
FORM C 9-1

Control Level 9-2 11. OTHER RPG II INPUT FORMS 11-1


Indicators 9-2
AN/OR Lines 9-3 Fi Ie Translation Tables 11-1
Factor 1 and Factor 2 9-3 Positions 1-8 11-1
Literals 9-3 Positions 9-10 11-1
Names and Elements 9-4 Positions 11-12 11·-1
Date Field Names 9-4 Positions 13-16, 17-20, 21-24 11-2
Special Names 9-4 Alternate Collating Sequences 11-2
Labels 9-4 Positions 1-8 11-2
Filenames 9-4 Positions 9-10 11-2
Operl1tion 9-4 Positions 11-12 11-2
Arithmetic Operations 9-4 Positions 13-16, 17-20, 21-24, ... 11-2
Move Operations 9-6
Move Zone Operations 9-8
Compare and Testing Operations 9-8 12. USE OF TABLES AND ARRAYS IN
Bit Operations 9-9 RPG II PROGRA:v1!'.1ING 12-1
Setting Indicators 9-10
Branching Operations 9-10 Forming Tables and Arrays 12-2
Lookup Operations 9-10 Compilation Time 12-2
Subroutine Operations 9-13 Pre-Execution Time 12-4
Programmed I/O Control 9-14 Execution Time 12-4
Debug Operation 9-16 Using Tables and Arrays 12-5
Result Field 9-17 Searching Tables and Arrays 12-8
Field Length 9-18 Modifying Table and Array Elements 12-8
Decimal Positions 9-18 Using Arrays 12-9
Half Adjust 9-18 Table and Array Output 12-10
Resulting Indicators 9-18 Example of Using an Array 12-10
Comments 9-19
Calculation Specifications Examples 9-19
13. RPG II FILE PROCESSING 13-1

10. OUTPUT SPECIFICATIONS - FORM 0 10-1 Sequential File Processing 13-1


Matching Records 13-1
Filename 10-1 Look-Ahead Fields 13-2
AND/OR Relationships 10-2 Indexed Fi Ie Processing 13-10
Type 10-2 Direct Fi Ie Processing 13-10 I
Add a Record 10-2

viii 96768710 C
APPENDIXES
A Glossary A-I F RPG II Object Program Logic (Detailed) F-1
B Deviations From IB:YI System/3 RPG II B-1 G Use of External Subroutines G-l
C Summary of RPG II Specifications C-1 H Coding of Sample RPG II Programs H-l
D RPG II ReferenceTables D-l I RPG II Utility I-I
E RPG II Error :vJessages E-l J TRACER Utility J-1 I
INDEX
FIGURES
1--1 General Program Cycle 1-3 10-1 Output Specifications Sheet 10-1
2-1 Arrangement of the RPG 11 Source Program 2-2 10-2 Specifications of Fetch Overflow Feature 10-5
2-2 RPG Control Card and File Description 10-3 Example of Coding with the *PLAC E
Specifications Sheet 2-3 Feature 10-7
2-3 RPG Extension and Line Counter 10-4 Example of *PLAC E Output 10-8
Specific8tions Sheet 2-4 10-5 Output Specifications Examples 10-12
2-4 RPG Input Specifications Sheet 2-5 12-1 A Use for Related Tables 12-2
2-5 npc Calculation Specifications Sheet 2-6 12-2 Two Methods for Defining Related Tables 12-3
2-6 RPG Output Specifications Sheet 2-7 12-3 Placement of Compilation Time Tables
4-1 Control Card and File Description and Arrays 12-4
Specifications Sheet 4-1 12-4 Input Specifications for Contiguous
5-1 End-of-Fi Ie Processing (Letter E Array Elements 12-5
Designated for Primary File Only) 5-3 12-5 Input Specifications for Scat tered Array
6-1 Extension and Line Counter Specifications Elements 12-6
Sheet 6-1 12-6 Input Specific8tions for Array Elements
6-2 Nonrelated Tables 6-3 and Indexes 12-6
6-3 Related Tables 6-3 12-7 Building an Execution Time Array through
6-4 Number 1,492 in Unpacked and Packed Calculations 12-7
Decimal Formats 6-5 12-8 Adding Elements to Short Related Tables 12-9
8-1 Input Specifications Sheet 8-1 12-9 :vIodifying a Table During Calculation 12-9
8-2 Record Type Sequence Checking 8-4 12-10 Accumulating Totals Without Arrays 12-11
8-3 Example of Spread Cards 8-5 12-11 Accumulating Totals With Arrays 12-12
8-4 Input Specifications for Spread Card 13-1 Record Selection Based on Matching Fields 13-3
Example 8-6 13-2 Read and Process Areas for Records in
8-5 Specifying Around Unwanted Control Figure 13-1 13-4
Breaks 8-11 13-3 Look-Ahead With Update Files 13-6
9-1 Calculation Specifications Sheet 9-1 13-4 An Application for Look-Ahead Fields 13-8

I
9-2 Examples of :vIOVEL Operations 9-7
9-3 Examples of LOKUP Operations 9-12
9-4 Example of DEBUG Operations 9-17
9-5 CalCUlation Specifications Examples 9-20

TABLES
4-1 Inverted Print Specifications 4-2 9-3 Move Zone Operations 9-8
5-1 Specifications Identifying Methods for 10-1 Overflow Indicator Usage 10-4
Retrieving Records 5-5 10-2 Edit Codes 10-8
5-2 File Addition/Unordered Output for Indexed 10-3 Edit Code Usage 10-9
Files 5-10 10-4 Edit Word Example 10-12 I
6-1 Alternate Table and Array Specification 11-1 PLAYGROUND Equivalents 11-1
Codes 6-6 13-1 Records Available for Look-Ahead 13-6
9-1 Operations for Calculation Specifications 9-5 13-2 Records Available for Look-Ahead with
9-2 Arithmetic Operation Codes and Factors 9-5 Update File 13-8

96768710 C ix
INTRODUCTION 1

Report Program Generator (RPG II) consists of a symbolic SINGLE INPUT FI LE PROCESSING
programming language and a compiler program. Through the
symbolic programming language the programmer describes In the simplest RPG II program, a single input file is
his program requirements on RPG II specification sheets. processed. When an employee payroll report is to be
These specifications serve as input to the compiler program. produced, the input file may consist of a single card for each
The compiler also accepts additional data arranged in tables employee. This card might contain the employee's name,
and arrays. This type of table and array data is fixed the hours worked, and the amount of pay per hour. As part
information that is unlikely to change for the life of the of the desired output, the name and hours worked may be
program. Compiler output includes an executable object transferred from the card to the report. In addition, the
program (stored by the compiler on disk) and/or a listing of employee's hours would be multiplied by the hourly pay rate
the specifications plus any error messages and a core map. to produce the gross pay; this figure would also be shown in
The programmer can leave the object program on disk to be the output report. RPG II specifications for this application
processed later, or he can proceed directly to executing the would contain the following:
object program.
• A description of input and output files and records
• A single calculation statement in which the multipli-
INPUT/OUTPUT cation is performed

The object program plus data stored in files make up the Records in the input file would be processed one at a time
input to the execution phase. The execution phase can occur within the basic RPG II cycle.
repeatedly with different data. The output of that phase is
determined by the application. It may include reports, With a single input file, at least three areas of complication
modifications to the input data files, completely new data may be added to the basic cycle:
files, or combinations of these functions.
• Different record types within the file
Input· to the compilation and execution phases may come
from any input device listed in appendix D. During the • Look-ahead fields
execution phase, the object program can perform sequential
access with files on any device. In addition, a disk file • Different report levels
allows the following:
In addition to the input record described above, the input
file might contain records listing the home address of each
• Indexed and random access by key or record number
employee as well as records containing any overtime hours
worked by each employee. For an input file containing more
• Access according to a separate file called a record than one record type, programmers may assign internal
address file switches to be used as indicators to condition alternate
calculation and/or output steps. The home address record
Record address files list the locations of records to be could trigger a switch saying "bypass the calculation phase
processed and the order in which those records are to be for this record" while the overtime record could set another
indicator requesting a time-and-a-half calculation, the
processed.
result of which would be added to the straight-time product.
The programmer has considerable flexibility in the
processing of indexed files. An indexed file may be With multiple input record types the basic cycle remains the
developed through an RPG II program or the RPG II disk same, but different activities may be programmed to Qccur
within the steps of the cycle. For each employee in the
utilities (appendix J). input file a record type group is speCified. In addition, the
program can indicate that the home address record is
required with each straight-time record, while the overtime
~ecord may be omitted if no overtime was worked this week.
(In some applications, any number of a specified record type
RPGIICYCLE may be accepted by a program; for example, multiple sales
records for a single salesman.)
RPG II operates on the premise that most business applica-
tions involving the processing of data files adhere to a fixed Look-ahead fields permit the examination of specified fields
sequence of processing steps: namely, read a record, in the next record during processing of the current record.
process it, and output some data. These three steps make up This is useful in the determination of proper processing of
the basic RPG II cycle and are repeated for each record in the current record. For example, if employee records are
the input files. grouped according to company department and if the last
record belonging to a department is to be processed
uniquely, the look-ahead feature can be used to trigger this
unique processing.

1-1
96768710 A
The output report may show, in addition to each employee's occurs, a matching record indicator is automatically set on,
gross pay, payroll totals for each department within each and a record is selected for processing based upon the order
plant within the company. The breakdowns by department, in . which the files were specified in the File Description
plant, and company are termed control levels, department Specification sheets. With no match, a record is selected
being the lowest level and company the highest. A change in according to the program's collating sequence for the
control level can require differe'nt activities: when depart- matching record fields. As with record type and control
ment number changes, the department total must be reset to level indicators, the matching record indicator can be used
zero while payroll accumulation continues at the plant level to condition calculations and output in the program.
until the plant identification changes. RPG II allows an Returning to the example, record matching can be used to
indicator to be set automatically when a change in control incorporate this week's payroll information into an annual
level (called a control break) occurs. The programmer payroll file.
specifies the control level indicator to be set on when a
programmer-specified control field changes.
A change in plant identification implies a change in CYCLE SUMMARY
department. Thus,. when a control break occurs at the plant
level, that control level indicator, as well as all lower As described above, RPG II distinguishes between functions
control level indicators (in this example, the department performed each cycle (detail operations) and functions
control level indicator), is turned on. This function is performed when a control break occurs (total operations).
performed automatically by RPG II, provided control level Because the processing of a control group should be
indicators are properly specified in the program. When a completed before starting the processing of a new control
change in plant identification does occur, the current plant group, total operations are performed before detail opera-
and department totals in the output report should be shown tions in the RPG II cycle. All input records processed
before accumulating fresh totals for the new plant. Thus, between one control break and the next comprise a control
when control break processing is specified in the program, group.
the RPG II cycle is expanded to the following sequence:
In addition to detail and total operations, there are IP (first
1. Input a record. page) and LR (last record) operations. IP processing is
unique to the first cycle. The IP indicator can be used to
2. Determine if a control break has occurred; if not, go to condition report headings and is very useful in the proper
step 5. positioning of preprinted report forms. RPG II auto-
matically turns the LR indicator on when the last input
3. Perform total calculations. record from the last input file has been reached. This
indicator is commonly used to condition summary lines in a
4. Perform total output. report.
5. Perform detail calculations. The general operations involved in a single cycle are shown
in figure 1-1. Appendix F contains detailed information
6. Perform detail output. about internal RPG II operation.

MULTIPLE INPUT FILE PROCESSING VALID RPG II NAMES


With multiple input files, RPG II processing can become The following rules apply to names used in RPG II programs:
quite complicated. Each file may contain the complexity of
a single input file, and the input files may be. interrelated as • RPG II filenames are from one to eight characters long;
well. The programmer has complete control over the order RPG II field names are from one to six characters long.
in which files and each record within each file are
processed. When a particular processing order is not • Field names and filenames are left-justified in the
specified in the program, the files are processed in the order specification fields in which they appear.
in which they are specified on the File Description Specifi-
cation sheets, as if they were strung end-ta-end as· a series • The first character of either a filename or a field name
of single input files. must be alphabetic (see appendix A, Glossary, for a
definition of alphabetic characters). The remaining
When the files are interrelated, the program probably should characters are any combination of alphabetic and
not process the files on the end-to-end basis. Rather, the numeric characters (special characters are not allowed).
files should be processed on the basis of matching records ..
Record matching is accomplished through the comparison of • Blanks cannot appear between characters in the name.
fields from records in two or more files. When a match

1-2 96768710 A
TURNOFF
INDICATORS

TURN ON THE
~~--.... PROPER CONTROL
LEVEL INDICATORS

DO TOTAL
CALCULATIONS

PERFORM
TOTAL
MAKE DATA FROM OUTPUT
RECoRD JUST READ
AVAILABLE FOR
"PROCESSING

DO- ALL DETAIL


CALCULATIONS

0299

Figure 1-1. General Program Cycle

1-3
96768710 A
RPG II SPECIFICATIONS FORMS 2

After the programmer has determined his report because the number of table entries varies from program to
requirements (input and output formats and calculations), he program.
codes the information on RPG II specifications forms. Seven
types of preprinted forms are available to tHe programmer. Each RPG II program has one optional control card
There is a control card for the whole job, and there are six specifications line. The numbers and types of other
form types for the input, calculation, and output logical specifications vary with the application, but RPG II requires
specification areas: that the specifications be presented to the compiler in the
order shown in figure 2-1. The ** and 1* delimiting records
• Control Card Specifications (form H) provide informa- illustrated in the figure are also required in the source
tion pertaining to the compilation as a whole. program, as appropriate. For convenience, records are
illustrated as punched cards. As the figure indicates, the
• File Description Specifications (form F) and Extension minimum. requirement for an RPG II source program is one
Specifications (form E) describe files, tables, and arrays file description specification record, one input specifications
to be used by the program. record, and the trailing 1* record.
• Line Counter Specifications (form L) provide informa- In the logical specification area of input, the programmer
tion about line printer files produced by the program. describes files, records, fields, and file devices.
• Input Specifications (form I) and Output Specifications In the calculation area, operations to be performed on the
(form 0) describe records in the files named in forms F input data are described. These operations may be condi-
and E. tioned (for example, by MR, the matching record indicator
or by a zero result in the last calculation operation).
• Calculation Specifications (form C) describe operations Calculation operation codes provide arithmetic functions,
to be performed on the input data. field movement, the definition of internal subroutines, usage
of internal and external subroutines, setting and testing of
In addition, the programmer may specify: flags, table lookup, and special input and output.
• Compilation time tables and arrays (tables and arrays In the logical specification area of output, the user describes
that do not change for the life of the program) files, records, fields, and file devices. When a file is being
updated, specifications in this area augment the input
• Translation tables (according to which characters in the specifications for the file. When a new file is being created,
input and output files are changed) the user also describes. record organization and field
positions. In addition, when the output file is a listing file,
• Alternate collating sequence tables (used to modify the the user specifies any editing to be performed by RPG II.
collating sequence of the standard character set)
Figures 2-2 through 2-6 contain copies of the preprinted
These three specification types do not have preprinted specifications forms. To the experienced RPG II program-
forms. Table and array formats are defined by the mer these pages and the summary of features in appendix'C
programmer within his program. Each record in the table or should be a sufficient introduction to this version of RPG II.
array must adhere to the format so defined. Translation and Sections 3 through 13 contain a detailed description of
alternate collating sequence tables have fixed formats (see RPG II functions and usage.
section 11), but they are not entered on preprinted forms

96768710 A 2-1
CONTROL CARD
SPECIFICATIONS

NOTE: REQUIRED SPEC!FICATIONS ARE SHADED.

Figure 2-1. Arrangement of the RPG II Source Program

2-2
96768710 A
CoNTRoL DATA RPG CONTROL CARD AND FILE DESCRIPTION SPECIFICATIONS I'Iin.... In U.s.A.
CORrQ'"R(\nON'

~~
I
...
--_--_..--._--------------TI-Da-~-·--~------~ I I~i~
Punching I::c I I I I I I I I~rdEIKtroNwnoo I 12

PIoo[Dof _ ~donl
7671177181980

IIIIII
Control Card Specifications

~
Model 20

i ~
ii I
~=
= ~II
Refer to !he specific SysI8m Rem- Ubnry IftIIIUIi for _ I I entr ....
Sizato 1ID1D i t:1&
Une ! Compile c3 8 e - 5 !:! jf I~ PaIltipni

!~ Ii
!:5 r!
lit e~l@
00_.
II 4 II • 7 8 II 10 " '2 I' 14 15 " 17 18 III 20 21122 n:M 25 21 28 211 30 I" niD 3t I . 311121 311 .. 40 41 42 la 44 144 41 47 48 44 50 .'1 52 53 54 66 58 57 58 MI 10 II 12 13 14 IIIi IIIi .7 . . . . 70 71 72 72 74
01 H I

File Description Specification


Mode of "'-Ing File AddItionIUlWdencI

f---
F File DesiQNtlon

Filename

U..
It
~

!
l:l 4 II • 1 8 II 10 11 12 13 14 l ' I' U 18 j f 20 21 22 2:11. 2S 28
o2 F
o3 F
o4 F , I' :!:
o& F
o II F
o7 F
08 F
o II F
1 0 F
F
F
u " OL . . . . LI . . . . . . £I ZI III 011 . . . . tI III III .. £I n II 01 D • Lt • It .... £t tt it Ot • • U 11£ 11£ IC a: a: 1I: CIt II: II: LE lit lit K a: U it ot I i Il U Il I i ti I:i ti U Oi 8 • L II • t I: I: i

Figure 2-2. RPG Control Card and' File ,Description Specifications Sheet

98788710 A 2~3
~=
RPG EXTENSION AND LINE COUNTER SPECIFICATIONS
il8 Printed in U.S.A.

........
I I=~ II
I 1 2 7571777878.

I III I I ..... [1]01_ =-~I I I I I I I


F'IIncIIing Card llectro Humblr
~ 10- 1..1nICtion

Extension Specificationt

E fI-.I . . . . . . o1 the 0IIInkIt File

.
NumIIw
1- ........... 0IIIMIe ..... of Numblr I!-
.II~
Tillie 01 J-
i~
Table or IMriII of LIfIIIII lIngIh
line To'i...,.". of j- An-vName of Commtntl
! Array Name !ntrle
IAIWNIInI

~iJ
Entry Entry

ill
"-II "-Table
frOm 'ilenlme ~
1 or Array

3 4 I e 7 • • 10 112131411111711 11202122232421211 12721129303132 333431 31 37 31 39 «14142 4344 1411 41 47 41 • 10 ., 125314 II !III ~1I.IO~aGMIIIIVII.~HnnM

o 1

o2

o3

o •

o II

o II

o 7

o 8

E


Line Counter Specifications


-L
1 2 3 5 II 7 8 8 10 11 12

h ~J I~ ~J II ~J Jj ~J II ~J 11 ~J Ii ~J 11 ~J II ~I 11 ~J JI ~J II
Line
! filename
-I
1 ~J ... "
02

3 4
1 1
I.
L
7 • • 10 11 12 13 14 111117 ,. I. 202122 23 24 2121127 2829 303132 3334 313137 3139 «14142 4344 414147 4149 101112 5314 II.~ II .. eolIa G&t • • 17 II .. ~n72 n74

1 2 L
L

FilW'e 2-3. BPG Extension and Line Counter Specifications Sheet

2-4 96768710 A
CONTRPL DATA RPG INPUT SPECIFICATIONS
CORPO~T10N I 2 75 76 77 78 79 BO

Programmer 0.,.
pageITJo,_ ::~:~':"ion I I I I I I I
Record Identification Codes Field.
Field Location
Indicators

8 ".
Filename ta - ~·o Field Name
1. ~ § ~ Position Position Position From To
Z.. o
Plus Minus or

r-f-r-
o R
t t "a:~
Z 0
Blank

fp:~'D
9 10 1\ 12 13 14 1& 18 17 18 19 20 21 22 23 24 25 26 21 28 29 30 31 32 13 34 35 36 31 38 J9 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 61 88 69 10 11 12 13 14

-----+-~~_+-r;-+_r-r;-+_+_r;_+4

H-+-+-++++++-H-+-H-++++-H--H-+-H-+-+-++-++-H-HI-+-H--H--++-H-+-t·-+--'I-+--I-+++-+-·-f-t-+-+-l-+-+--+-+-f-+~-~-+-~

~~~4-+-+-~~-+-l-4-+-~~~-+-l-+-+-~~~-l-+-+-~~-+-l-4-+-~~-+-l-4-+-~~-4-+-r~~-+-~-~T t-t--+---r1-+-~~_+-r~-+-~-+-+~

Figure 2-4. RPG Input Specifications Sheet

96768710 A 2-5
RPG CALCULATION SPECIFICATIONS P"nled in US.•.

1 2 7!'> 76 17 78 79 80
P'09'.m
,.HJCOJO'_ ~:~':'Mnl IIIIII
"09''''''''''

_
c ~
0
Indicators
I I
Result Field
R'·'i.ultlr~1
,,,.he •• Inn
A,.Ihmo-I.e

&
=-t z
om And And F
actor.
1 o ·
peratto"
F~to'
-
2
~;
_3_ ;
... ~:\fnp :~ . '.
Pt.- I'M,·nus·IZ-,o
Comments
L."~ ;! ~ ~
e ~ en
Name length ~
:
f1
_
211 < 211
LuukupIF.IC.:'Of 2h~
2

~ J5 j i i d i H"~l Low E'lual


J .. 5 G 7 a 9 10 11 12 13 14 lS 1\; H '8 19 20 21 ".l'J 23 24 ~ '6 " ~ 1!t 30 31 X' 33 34 3S 36 31 18 39 ... 41 47 43 ..4 45 4(j 41 4& ,.g 50 51 !,:, ~ :04 t.!: 56 f')7 ":-!!J9 ;0 li1 62 6:! t)4 h~' hI) t.I ~WoC f,'J m l' 1.' 1: '4

~::~: I~+~_~::~~~ -~ i~ -~:;:::t!!;:


o! 61 C "_~.'.~._.~._':. t:.~.: :'
: :'
:~~~=~::~:~±~~,l,.,~~4_:":.~~!I~~f'-~i'
-
- -
i I;
. ,--t-+~~t--t-.- ....- .• --.- r--r- - - "--r-+- . _- .--,,-~,-,,----.---"";~~-r-'-'--I
o 1 ._. ___ ~_ 1i l' j I __.__ I i i
-f--I-+-II-+-:...-t-H-+-+--r-H-+-,-+ ...... -.-.-l-~!.+-+-1~'+~+--+-------." '-~-H'-++-H-+-+--+I-:...'-'---.;~~!~'-r-...;.....-+-i'-J,.i~
i
HH-~-t-""""-';"-i--t-------_·-........-;- - -I----....++--f---~+-~-+_+_-+-;......;.-'-_+_I
I ! !
do i :i i ii :!: -,
..
i
. • - f - ~-t-i-r·+-+-
i ; !. '-r-t- -- --
,t--+--"- .---- - --- r-
"1 Ii:
- r--' ~t- '-fH--+-~'''''''''1~'--i,-t-+--r-+-I:-'--+-I
i
1 • ! I I i I !"t ' I
1 3 ~.- ..--- ·-+-ii·-!-!-·o........t;-'-...i~-+-·---·:.....----r-r- - - .... t--t---t-.........-'--+-+-l-II+-h-+I'~-~ii-t,-t

114 '--i-+-_I--j.-+--+--.-+-..........-t--..-"--_._-+-t-+-+--f-f-,- f-i_ Iiii : ; i :I


......1+!'>-H_CI--+-HH--+4-4--J-+-HH--+--4H--+4-4-.f-+-+-l14 I . I I II I I I: ! ! 1 i I I I

~-I~.I_ ~
C
r- - r-" -t-t-t-f·-t-t-t-t-+-+-t--t-i-t-t-t--I---t---t-ii-+-++--t-t-I-t-++-+-t-tJLl)-
I t
'!
f-- I I ! I IJ
. : i I
1 7' I

I--l-+-e+--1I--C+-+--If-+·-t--t-hH...+++-HH-+-++-H-+-+-+-H........-+-+-+-HH--+++-r·~ ~- :-~- -
, I

f-!~>- -,... ~- - -f-: -i~


H-++--HI-+-++--Hf--f--!--~4-f--t--+-4-+--+--I-~-+1 4,-+I!_ -t-+·~-t-+-H-'-·~I-_-~I-t -. --:. -- -: - ~ -- - r- ; f- - . ;
I
+-f--..-I
i
~'---I
+-tl .- t-+~--+-~4--+i-Hf-I'-~·-.-'~f-rl- -.: f-- - : + --+-+[--1·-'-:....1-1
1 9 C , . I ,

2 0 c I'

It It Ot ell 119 t9 99 S9 t9 t9 19 19 09 6S II'i tS go; SS ~ tS lS IS os 6t 8t tt 9t St n tt It It (It 61: 9t tt 9t st K tt It It 01: 6l 8l II 9l Sl tl £l II Il Ol &1 91 tI 91 SI tl £1 II "01 6 8 t 9 S ttl I

Figure 2-5. RPG ~alculation Specifications Sheet

2-6 96768710 A
CONTRPL DATA RPG OUTPUT SPECIFICATIONS
CORPORt\TlON
1 2 7578777879110
ul_Pt.....:, ---I1 I Graphic I I I I Clrd Electro Number
_ _ _ _ _ _ _r -_ _ _ _
_InI

IPt,,"mmer Dill I
l'Imching

Instruction I Punch I I I I
PI9l[OO'_ =-:"ti"'O IIIII
~--~----------~~--~----.r-----------,---~--_r--------------------------------------------- .. ----
~
o ~ ~pace Skip

~ ~I--I--~-+-....,~--r---i ~1eId Heme ~'I


Output Indicators I ~;z::::::::::::::::::==i"~»
. Commas Zero Bal.nces No Sign CR _ X· Remove
~=Y=es=~,,;;to;;,;YPr;,;~;;;,nt~4===l=A=I==J~ Y • 61~tSeSign
line Filename ~!x';:C
~ 1: 1 :4nd
J
And
Ib1
ILl End
Positon
Yes
No
No
No
Yes
No
8
C
D
K
l
M
Field Edit
Z· Zero
Suppress
!
l-
I- olS
1-;:'0'0 i g I;
in
Output
a:
::J
1) Constant or Edit Word
e ~ Iii z: Z "AUTO Record ~
of ~~~
AND
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 I' 20 21 22 23 24 25 26 27 28 211 30 31 32 33 34 35 38 31 38 b9 40 41 42 43 44 45 ~ 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
o , 0
1-1--4-+++-+-1-1- +-+-+-++- 1-- -. ,..... f- +-+-+-'''-If--f~- ~-f--- - ..+-I-+-~H_t_f_ I-++.J-H-+++++-+ .~- - - ~- .. .f--- - f-----I-
o 2 0
~~-+-4--+ .. - "-~- .. ~- 1;-1-- ·-+·+-+_HH-++_++-l
o 3 0
o .- 0
+--+~~_++-++-~f-+_+~_++--+_~~-+ +-r_++_~H_+-r+~'+-I_;_t~-_++_t-f---f---f----
o 5 0
o 6 0
o 7 0
o 8 0
o 9 0
1 0 0
11 0
1 2 O·
1 3 0
~f- ...
+-+-~~_4-++.-l-+-~- _4-+.~f_-I +_++-'+-I-+'-++~ .J-+--+-++-+-I~-I-- 1-. ,.- ~
1 .- 0
t-H-+-+_++-HH-+-+-+-+-HI-~_+_4· - f- .. ~ -. - ~ - --Hf--f-+-+--+--+-.....f-+-+-of- -
I 5 0
I 6 0
I 7 0
1 8 0
1 9 0
2 0 0
0
0
0
0
0
., U It III • • " • st ., £11 E9 .1 09 H II!; " \III ft til t!I tS &I 09 . , " n II' U ... r.. It It 0' It It Lt lit i t tC tt tE It DC til It Lt It II: ,I; tl U " at II II LL 9L ~I " tl tl II 01 • • L • S • C t I

Figure 2-6. RPG Output Specifications Sheet

98'168'110 A 2-'1
COMMON ENTRIES 3

This section defines entries that are common to all RPG II The single control card specifications line. if used. is always
coding sheet formats except file translation table and line 010 of a program. Any other sequence numbers used
alternate collating sequence records. which are described in need not be consecutive. but they should be in ascending
section 11. The common entries are: order.
Columns Entries

1-2
pagel Page and line together form a FORM TYPE
five-digit sequence number.
3-5 Line Column Values Meanings

6 Form type 6 H Control Card Specifications


sheet (or header card)
7 Comments
F File Description Specifi-
75-80 Program identification cations sheet
During processing of the specifications forms. the RPG II E Extension Specifications
compiler checks for proper ordering of the sequence sheet
numbers. When proper order is violated. that fact is noted
in the printout produced by the compiler but otherwise has L Line Counter Specifications
no effect on the compilation. Blanks found in columns 1 sheet
through 5. are treated as zeros.
Input Specifications sheet
C Calculation Specifications
PAGE sheet
Columns Values o Output Specifications sheet

1-2 01-99 The form type is preprinted in column 6 of each line of each
specifications sheet. The letter identifies the type of
Columns 1 and 2 in the upper right corner of the specifica- specification of each line of coding.
tions forms are used to number the pages of the RPG II
program. Number the pages in ascending order. The forms The H in column 6 of the Control Card Specifications form
are presented to the compiler in the following order: stands for header record. Each RPG II source program has
only one header record. and. if used. that record must be the
1. Control Card Specifications first line of the program.

2. File Description Specifications

3. Extension Specifications COMMENTS


4. Line Counter Specifications Column Value Meaning

5. Input Specifications 7 * Comment line

6. Calculation Specifications Any specifications line containing an asterisk in column 7 is


entirely commentary. Columns following the asterisk may
7. Output Specifications contain any members of the character set. The compiler
performs sequence checking on the line and includes the line
A program may require more than one sheet or none of a in the source program listing, but aside from that the line is
particular specifications type, but in any case the above ignored.
order must be maintained.

LINE
Columns Values

3-5 000-999

96768710 A
3-1
PROGRAM IDENTIFICATION Any combination of alphabetic and numeric characters may
be used in columns 75 through 80; however. the first
Columns Values Meanings character must be alphabetic. Blanks must not be used
between characters in the name. The program name should
75-80 Blanks RPGOBJ be unique. If columns 75 through 80 are left blank. the
compiler automatically assigns the name RPGOBJ to the
Valid RPG Program identification object program.
II name
Columns 75 through 80 of all source program specification
Columns 75 through 80 of the Control Card Specifications sheets. except the Control Card Specifications sheet. may
sheet are used to name the object program. This name is contain any characters or may be left blank. These entries
used in a program directory to identify the location of a are ignored by the compiler but are produced in the source
program on disk. program listing.

3-2 96768710 A
CONTROL CARD SPECI FICATION - FORM H 4

Only one control card may be submitted for each program. Description Specifications sheet (figure 4-1). The remainder
It provides information about the program and the system to of this section describes the columns of form H that are
the RPG II compiler. If the control card is omitted, a blank used. Any column that is not specifically described must be
control card is assumed. For coding the control card, one filled with a blank.
specifications line is provided on the Control Card and File

CONTRPL DATA RPG CONTROL CARD AND FILE DESCRIPTION SPECIFICATIONS Printed In U.S.A.
CORrQRi\TlON
1 2 75 76 77 78 79 SO
Progrlm

Progrommer Dote
page[JJ0'_ ::~;~f~Cltion I IIIIII
Control Card Specifications

H
Refer to the specific System Reference library manual for actual entries.

File Description Specification


Fill Type Mode of Processi ng File Addition/Unordered

-F Fill Designation Length of Key Field or Extent Exit Nu_ of TrKks


End of Fil.
of Record Address Field ~ for DAM for Cylinder Overflow
Record Address Type Z Name of
Filename Sequence Symbolic ca Label Exit
Number of Extents

~
Type of Fil. Device Device T_
-'
File Format Orglnization w
~ Storage Index Rewind
Une or Addition.1 Ale. ~ ~
Overflow Indicator U Condition

! 810ck Record ~~ ~.~ Ul.~

E
.f
Length Llngth
~ a
~ ::::
Stlrting;
location W K
Continuation lines

Option Entry
:::>
"<
~
~
3 4 5 6 7 8 9 10 11 12 13 14 t6 16 17 18 19 20 21 22 2 24 26 28 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 . . 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

o 2

o3
o4
o5
o6 F
o 7

08

o 9

1 0

Figure 4-1. Control Card and File Description Specifications Sheet

'--.

96768710 A 4-1
DEBUG Column 21 is used to describe the format and punctuation
used for numeric literals on the Calculation Specitications
Column Values Meanings sheet, the order of the system date (referenced by UDATE)
field, and edit codes used on output.
15 Blank Do not perform DEBUG
operations.
NOTE
1 Perform requested DEBUG
operations. The input for UDATE must be in the
format expected as output. For example,
This specification in column 15 indicates: if D (United Kingdom format) is specified
in column 21, the input format must be
• Whether DEBUG operations are to be performed by the dd/mm/yy (where dd=day; mm=month;
object program, and yy=year).
• Whether lines containing the DEBUG operation code are
diagnosed as errors in the program listing Inverted print specifications and resulting formats are shown
in table 4-1.
As the name implies, the DEBUG operation code in the
calculation specifications is a tool to be used in checkout of
the object program. Intermediate debugging output is
produced only when requested by this specification and a ALTERNATE COLLATING·
DEBUG operation code on form C. S~QUENCE
When checkout of the object program has been completed, Column Values Meanings
changing this entry to a blank eliminates· the then extrane-
ous debugging output; i.e., changes need not be made to the 26 Blank Use normal collating
Calculation Specifications·sheet. sequence.
.S Use alternate collating
sequence.
INVERTED PRI NT
Every alphabetic, numeric, or special character holds a
Column Values Meanings special position in relation to all other characters. This
special order is known as the collating sequence. The
21 Blank Domestic format normal (default) collating sequence is based on the way
characters are represented in the machine and is listed in
Foreign format appendix D.
J Foreign format (leading zero If characters are to appear in a sequence other than the
remains for zero balances) normal sequence or if two or more characters are to have
the same position in the sequence (this means they are
D United Kingdom format considered equal), an alternate collating sequence must pe
described.

TABLE 4-1. INVERTED PRINT SPECIFICATIONS

Inverted Print Numeric Literal using Edit Codes using Zero Suppress to the UDATE Appears with
Option Period/Comma as Period/Comma as Left/Right of the a Slash/Period
a Decimal Point a Decimal Point Decimal Point
Blank 1234.56 1,234.56 .10 mrn/dd/yy
D 1234.56 1,234.56 .10 dd/mm/yy
I 1234.56 1.234,56 ,10 dd.mm.yy
J 1234.56 1.234,56 0,10 dd.mm.yy
mm=Month
dd =Day
yy =Year

4-2 96768710 A
An alternate collating sequence applies to matching fields, SHARED 1-0
sequence checking of files, and alphanumeric compare
operations (COMP operation code). The alternate sequence Column Values 'Vleanings
does not apply to numeric comparisons, lookup operations,
48 All disk files share a single
and cont rol levels. (Refer to section 11 for additional
details on alternate collating sequences.) input/output area.

An alternate collating sequence table is printed out with the Blank Each di"k file u"e-; a .-;ep-
compiled program. The order of an RPG II source program arate input/output area.
including an alternate collating sequence table is shown in
figure 2-1. Column 48 applies to disk files only. Norma1\y H.n RPG II
progr.am uses one input/output area for each file. An entry
In thiS column allows all disk files to use one input/output
lP FORMS POSITIONING area. Specifying a shared input/output area reduces the
amount of core storage needed by the object program. This
Column Values Meanings is particularly important if a program is so large that it
cannot run in the available core storage. However, t he use
41 Blank First 1 P line is printed only of a shared input/output area increases the time required to
once. execute the object program. Therefore, it is a good idea to
make sure that the program exceeds the capacity of the
First 1 P line can be printed system before specifying shared input/output.
repeatedly.

This entry in column 41 j:.; used only when the first output NOTE
line conditioned by the first page (IP) indicator is written to
a printer' file. Ordinarily it is used when the output is going A shared input/output area cannot be
to preprinted forms, such as check blanks, where the proper specified for multivolume file (entry
alignment of forms is very important. When requested, greater than 01 in columns 58 and 69 of
the File Description Specifications sheet).
I forms positioning allows the operator to correctly position
the forms by first printing a test line.
Additional input/output areas (entry in
column 32 of the File Description Speci-
fications sheet) cannot be specified for
disk files using a shared input/output area.
FILE TRANSLATION
Column Values Meanings
I NTERNAL CODE SPECI FICATION
43 Blank No file translation is
needed. Column Values Meanings

F
50 Blank Internal code is ESC DIC
Input, output, update, and/or
combined files are to be
Non-blunk Internal code is ASCII
translated.

An F character in column 43 indicates the information


The normal internal RPG II code is EBCDIC. If the ASCII
option is selected, execution is not compatable with the IBM
I
contained in an input, output, update, or combined file is in system 3.
a form not usable by the object program. For example, this
option is used when an input file was produced by a
computer that has a different character set than the one EXECUTION IN ITOS ENVI RONMENT
defined in appendix D.
Column Values Meanings
With an input file, translation occurs before the data is
processed by the object program. For output files, transla- 51 Blank RPG II object code i~ pro-
tion occurs as the output data is produced. When an update vided in ITOS--compatible
or combined file is translated, t he conversion is performed form.
for both the input and output phases for the file.
Non-blank Object code is provided for
Note that since an external medium is implied in file MSOS batch-type execution.
translation, the internal collating sequence of the object
program is not affected by the translation. MSOS batch type code should be used only for systems that
lack any nos capability; this type of code should not be
Refer to section 11 for further information on file used in an nos environment under the job processor.
translation.

4-3
96768710 C
FILE DESCRIPTION SPECIFICATIONS FORM F 5

File description specifications are required for every. file The file type entry in column 15 indicates whether the
used by the object program. The File Description Specifica- object program is to read data from the file, write data to
tions sheet is illustrated in figure 4-1. Generally, only one the file, or both.
line is needed to describe a file.
Form F describes all files except compilation time tables
and arrays; these are described only on form E. Records in INPUT FILES
form F files are described on other specification sheets:
Input files are records that a program uses as a source of
• Input data records are described in the input specifi- data. When an input file is described in a program, it
cations (form I). indicates that records are to be read from the file. All input
files except table, array, and record address files must be
• Output data records are described in the output further described on the Input Specifications sheet.·
spe<;ifications (form 0). Table/array and record address files must be further
described in the extension specifications.
• Update and combined files are described on both forms I
and O.
Record address files and pre-execution and execution time OUTPUT FI LES
tables and arrays are further described on form E, Extension
Specifications. Display file records need no further Output files are records written, punched, or printed by a
descriptions. program. All output files, except table and array output"
. files, must be further 'described on the Output Specifications
sheet.
FILENAME
Columns Values UPDATE FILES
7 -14 Any valid RPG II filename Update files are disk files from which a program reads a
record, updates fields in the record, and writes the record
o Columns 7 through 14 are used to assign a unique filename back in the location from which it was read. Update files
to every file used in the object program. Every file must be must be further described on both the Input and Output
named, with the following exceptions: Specifications sheets; however, only the fields to be updated
need be described on the Output Specifications sheet. A
• Compilation time tables and arrays do not require a record in an update file can be updated only once during a
filename. cycle. A chained file or a demand file may be updated at
detail time, total time, or at exception output time. All
• If multiple tables or arrays are read in at pre-execution other disk files should be updated only at detail time (during
time from the same device, only one filename is the same program cycle in which a record is read) to avoid
required. unpredictable results. .
Filenames may duplicate field names~

COMBINED FILES
FILE TYPE A combined file is both an Input and an output file. A
program reads records from a combined file and includes
Column Values Meanings output data on the records in the file. The result is one file
that contains both input and output data.
15 Input file
An output record to a combined file is stored in a hold area
0 Output file until another record is read from the combined file. The
output record is produced just before the new record is read.
U Update file Each record stored in the hold area overlays and replaces
any record previously stored in the hold area. Thus, only one
C Combined file record can be available as output to a combined file during
anyone RPG II cycle. This record is the last record that
D Display file satisfied output conditions during the cycle. The RPG II

5-1
96768710 A
program should be written in such a way that only one Note that table, array, chained, record address, and demand
record of ·a combined file satisfies output conditions in a files are not involved in record selection in multifile
single cycle. In addition, output should not be conditioned in processing.
such a way that output conditions are satisfied for more
than one combined file in a single cycle.
CHAI NED FI LES
DISPLAY FI LES A chained file is a disk file that uses the CHAIN operation
code to do one of the following:
A display file is a collection of information from fields used
by a program. The DSPLY operation code must be used in • Read records randomly
the calculation specifications in order to print a field or
record directly from storage and/or key data into a field or • Load a direct file
record in storage. Display files need only be described on
the File Description Specifications sheet. A chained file can be an input, output, or update file.

FILE DESIGNATION RECORD ADDRESS FILES


Column Values Meanings A record address file is an input file that indicates to the
- -- object program:
16 Blank Display file or nonchained
output file • Which records are to be read from a disk file
P Primary file • The order in which the records are to be read from the
disk file
S Secondary file
Only one record address file can be specified in a program.
C Chained file A record address file must be further defined on the
Extension Specifications sheet.
R Record address file
Record address files contain record key limits or relative
T Table or array file (pre- record numbers in binary format. Files that contain limits
execution time) are used with indexed files only. Record address files on disk
that contain binary relative record numbers are called
D Demand file address output (ADDROUT) files. They are produced by disk
sort programs and can be used with any type of disk file.
Column 16 is used to further identify the use of input,
update, and combined files. The column is left blank. for
display files and all output files except chained output files
(direct load). TABLE OR ARRAY FI LES
A table or array file is a sequential input file that contains
table or array entries. The entries can be read into the
PRIMARY FI LES program during compilation or immediately before execution
of the program. Only pre-execution time table or array files
A primary file is the main file from which a program reads are defined on the File Description Specifications sheet.
records. In multifile processing, the primary file is used to However, all tables and arrays must be described on the
control the order in which records are selected for process- Extension Specifications sheet.
ing. (More information on record selection in primary files
can be found in section 13.) A primary file can be an input, A table or array output file (produced after LR output) is
update, or combined file. In programs tl)at read records defined as a normal output file and does not require an entry
from only one file, that file is the primary file. Every in colUmn 16.
program must have only one primary fil~.
Entries read during compilation become a permanent part of
the program. Both compilation and pre-execution time
tables or arrays can be changed at execution time. Com-
SECONDARY FILES pilation time tables or arrays, however, can be permanently
altered only by recompiling the program. Pre-execution
Secondary files apply to programs that do multifile time tables can be permanently altered each time the
processing. All files involved in multifile processing, except program is executed.
the primary file, are secondary files. A secondary file can
be an input,. update, or .combined file. Secondary files are Table and array files ilre not involved in record selection and
processed in the order in which they are written on the File processing. They are only a means of supplying entries for
Description Specifications Sheet. tables and arrays used by the program. When pre-execution

5-2 ·96768710 A
ti me table or array files are read prior to the execution of In sum mary, if the records from all files must be processed,
the program, the program reads all the entries from the column 17 must be blank or contain Es for all files.
table and array files before it begins record processing.

PRIMARY FILE SECONDARY FILE


DEMAND FI LES

Demand files can be input, update, or combined files. A I I


2 2
demand file is accessed only after a READ operation code in
the calculation specifications is executed, not during the ----~---I1_ _ _ - - - - -~- - - - -
normal record selection process. Demand files can be 4
processed either sequentially by key or consecutively. More
than onc demand file may be designated; the operand of the
REA D speci fies which of several demand files is meant. I I
2 2
____ 1 _______ ~O_M~Ts::fj!"J~ QEJ/~
/* NO MA TCHlt'>JG r IELD
END-OF-FILE 4

Generally, execution of the object program continues until


the end-of-file has been reached on all primary, secondary, I I
and record address files for which an E has been specified in 2 2
\his column of the File Description Specifications sheet. _. _ _ _ ~ _ _ _ I NO MATC~ING FIELD

Colu~n Values Meanings L ___ t.:l0_M~ T~f-iL~ IJ.E.b.D_


4
17 131ank a. If none of the primary,
secondary, or record
address files has !in E in NOTES: I. NUMERIC VALUES SHOW COI'>JTENTS OF
its specification, each MATCH FIELDS.
such file is read to its 2. RECORDS ABOVE DOTTED LINE ARE
end. PROCESSED BEFORE END-OF -JOB.
0301
t:>. If any has an E in its
speci fication, those
Figure 5-1. End-of - File Processi'lg (Letter E
with a blank in eolu~n
17 need not be exhaust-
Designat8d for Primary File Only)
ed.

E All records from this file SEQUENCE


must be processed before
the program can end. Column Values Meanings

This column applies only to input, update, and combined files 18 Rlank No sequence checking is to
that are used as primary, secondary, or record address files, be done.

In single file processing, the primary file is read to its end Sequence checking is to be
regardless of the entry in column 17. Neither is column 17 done. Records in the file
significant to the data file associated with a record address are in ascending order.
file.
D Sequence checking is to be
In multifile processing, all pertinent files are processed to done. Records in the file
end-of-file unless Some files do and some files do not have are in descending order.
an E in column 17. In that case only those files having the E
specifications are necessarily processed to end-of-file. Column 18 is used to indicate whether or not the object
There is an important exception. When the primary file is program is to check the sequence of records.
the only file with an E in column 17 and matching records
have been specified between that file and at least one This ?olumn applies to input, update, or combined files used
secondary file, execution is terminated only after: ~s prlm.ary or secondary sequential files. Sequence checking
IS reqUIred when matching fields are used in the records

• All secondary records that match the last primary from the file (entry in columns 61 and 62 of form Files n.
record have been processed, and/or with m~tching fields must be either all ascending or all
descendmg. An equal condition does not violate the
• The first secondary record without matching fields has sequence of a file.
been processed.

These situation::; are illustrated in figure 5-1.

96768710 A 5-3
I This column does not apply to table, array, chained, demand, TAPE FI LES
record address, or output files.
The block length for EBCDIC tapes with fixed-length
records (F in column 19) is a multiple of the record length.
For ASCII tape files having fixed-length records, the block
FILE FORMAT length is a multiple of the record length plus the length of
the buffer offset (see Continuation Lines).
Column Values Meanings
For tapes with variable length records, the block length
19 F Fixed-length records specified need not be an exact multiple of record length.
However, the following things should be remembered in the
V Variable-length records block length specification:
(EBCDIC tape files only)
• Add four bytes (characters) per block and four bytes per
o Variable-length records record.
(ASCII tape files only)
• The minimum specification is the length of the longest
An F entry in column 19 indicates all records in the file are record plus eight (four for one block and four for one
the same length (i.e., have the same number of characters). record).
A V entry indicates records in a tape file are variable-length
EBC DIC, and a 0 entry indicates records in a tape file are
variable-length ASCII.
RECORD LENGTH
Enter an F in column 19 for any file that does not reside on
magnetic tape. Columns Values Meanings

24-27 1-8191 Number of characters per


record
BLOCK LENGTH
18-8191 Numbel' of characters per
Columns Values Meanings tape record

20-23 Blank Block length for this file is A record length in columns 24 through 27 is right-justified,
the same as record length. and leading zeros may be omitted.

1-9999 a. Record length or multi- Except for tape files having variable length records, Ill!
ple of record le:ngth for records in one file must be the same length. The length of
disk file the longest record is specified for tapes having variable
length records.
b. Record length .for non-
disk or nontape file
For an update file, record length must not vary between the
input and output phases.
18-9999 Tape file block length
The maximum record length allowed for a file depends upon
The use of columns 20 through 23 is interrelated with the
the device assigned to the file (appendix D). A specified
device assigned to the file. Charts of record and block
record length can be shorter than the maximum length but
lengths appropriate for each device in the system are listed
no longer.
in appendix D.

When a block length is speci fied, the length is right-justi fied


in columns 20 through 23, and leading zeros may be omitted.
MODE OF PROCESSI NG
Criteria to be used in the specification of block lengths for
Column Values Meanings
disk and tape files are discussed below.
28 Blank a. Access is consecutive,
or
DISK FI LES b. Access is sequential, in
the order the records
A block length specifies the number of characters to be read appear in an index
from or written to a file at one time and must therefore be (sequential by key).
a multiple of the file's record length. The maximum block
length for any file is 9.999 characters. L Access is sequential, within
limits defined by a record
The function of a block length entry is to specify the amollnt address file with record key
of core storage to use for an input/output area. Most users limits.
will leave this entry blank, as the RPG II compiler automati--
cally assigns an efficient block length to all files.

5-4 96768710 C
Column Values Meanings An entry is made in this column only if:
28 R a. Access is random by • This is an input, update, or combined file.
relative record number,
or • This is a primary, secondary, demand, or chained file.
b. Access is random by
key, or • The file resides on disk.
c. Access is by ADDROUT All other types of files have sequential organization, and
file, or . consecutive processing is the only possible method.
d. This. is a direct (ran-
dom) file load. Users must coordinate the file type (column 16) with the file
processing mode (column 28), the record address type
Column 28 is used to indicate the method by which records (column 31); and the file organization (column 32) for all
are to be read from the file or to indicate that a direct file input, update, and combined files. Legal specifications for
load (random load) is to take place. the retrieval of records from disk files are indicated in
table 5-1.

'fABLE 5-1. SPECIFICATIONS IDENTIFYING METHODS FOR RETRIEVING RECORDS

Allowable Entries
File File Possible Access Modes
Designation Organization Column
16 28 31 32

P ~ ~ ~or 1-9

Sequential Consecutive S ~ ~ ~or 1-9

or 0 ~ ~ ~

direct p R I ~or 1-9


8y ADDROUT file
S R I ~or 1-9
Primary,
P R I I
secondary, By ADDROUT file
S .R I I
demand
p ~ AlP I

Indexed Sequential by key S ~ AlP I


0 ~ AlP I

P L AlP I
Sequential within limits S L AlP I
0 L AlP I

Record Sequential Consecutive (record R ~ ~ ~


or key limits)
address direct
Consecutive (ADDROUT) R ~ I T

Sequential Random by relative C R ~ ~


Chained or direct record number
input
Indexed Random by key C R AlP I

NOTE: ~ = Blank

96768710 A 5-5
CONSECUTIVE PROCESSI NG the lower limit only, but access of data records proceeds as
described above, with the upper limit being defaulted to the
The consecutive method applies to sequential and direct address of the last record in the file. The lower limit may
files as well as indexed input files. During consecutive be reset before the end of the file is reached.
processing, records are read in the order they appear in the
file; for example, one card after another. A direct The following steps are involved in sequential access within
organization is similar to sequential, but gaps may occur in limits:
the file to allow for future additions. (One might simulate
direct organization by inserting blank cards every so often in 1. A limits record is read from the record address file, or
a card deck.) The gaps are really records filled with blank a lower limit is set by the SETLL operation code.
characters. The user should check for these blank records in
his program. 2. Data records having keys greater than or equal to the
lower limit and less than or equal to the upper limit are
Consecutive processing takes place until the file ends or read and processed (the upper limit being end-of-file
until the program ends for another reason (see End-of-File). when the SETLL operation code has been executed).
These two steps are repeated until either the end of the
record address file is reached or the progr'am is terminated
SEQUENTIAL PROCESSI NG BY KEY due to the end of another file (see End-of-File).
Sequential by key access applies to indexed files that are A record address file containing limits must conform to
used as primary, secondary, and demand files. Sequential by these rules:
key access is similar to consecutive access in that the index
entries are processed consecutively. However, the asso- • Each record in the record address file contains only one
ciated data portion of the file is processed according to the set of limits.
order designated by the index. The index portion of a file is
similar to, the index of a book; key words are scattered • A record key can be from 1 to 29 characters in length.
throughout the book but are listed alphabetically along with Both the lower and upper limits must be equal in length
their locations in the index. to the key field length specified in columns 29 and 30.
,Thus, the length of a record in the record address file
The program reads records until the file ends or the program must be twice the length of a record key.
ends due to end of another file (see End-of-File).
• The lower limit must begin in character position 1 of
the limits record. The higher limit immediately follows
the lower limit in the record.
SEQUENTIAL PROCESSING WITHIN LIMITS
• Numeric limits are right-justified in their record fields,
Sequential within limits access can be performed through but leading zeros must not be suppressed.
the use of either:
• Alphanumeric record keys may contain blanks. A
• A record address file containing limits, or record key must not contain any X'FF' characters,
however.
• The SETLL operation code on the Calculation Speci-
fications sheet A record address file containing limits and the associated
file of keys may have different formats. For example, one
The first use applies to indexed disk files used as primary, file may be in packed decimal format while the other is in
secondary, or demand files. A limits record contains the unpacked decimal format. During execution RPG II auto-
lower and upper limits of key values for records to be matically changes the format of the record address file
processed. This organization effectively divides an indexed containing limits to that of the object file, if necessary.
file into a series of subfiles, each of whose record keys fall The format of each file is designated by an A or P in
within a set of limits. A record in the file is actually column 31. The unpacked key length must be twice the
accessed sequentially by key but only if the record's key packed key length minus one or two. Refer to Record
falls within the specified limits. Each set of limits is a Address Type and Packed Decimal Format, section 6, for
record of a record address file. further clarification of these specifications.
The second use applies only to indexed files used as demand
files and cannot be used with a file for which a record
address file also sets limits. The SETLL operation code sets

96768710 A
5-6
The record address file may contain duplicate limit sets. LENGTH OF KEY FIELD
Thus, the. data records can be processed more than once, OR RECORD ADDRESS FIELD
with or without intervening record retrieval, in a single
execution of the object program. Columns Values Meanings
When an upper and lower limit in one set are equal, only one 29-30 Blank Sequential or direct file or
data record is processed via that set. chained input file accessed
by relative record number
1-29 Length of record key
PROCESSI NG BY ADDROUT FI LE
3 Length of ADDROUT file
Address output (ADDROUT) files are record address files record
produced by disk sort programs. ADDROUT files are similar
to indexes for indexed files, but they do not contain keys. A Colu:nns 29 and 30 apply only to indexed disk files and
single object file (the data file pointed to) can be processed record address (including ADDROUT) files. Enter one of the
by one ADD ROUT file in one execution time and a totally following:
different ADDROUT file in another execution time.
• The length of record keys in' record address files that
An ADDROUT file may be a tape or disk file, but the object contain limits. Unpacked decimal format is implied,
,file must reside on disk. The ADDROUT file contains 3-byte and the maximum entry in columns 29 and 30 is 29
disk records or 18-byte tape records, either of which (bytes). Remember that the length of records in the
contains binary relative record numberst of the object file's record address file is twice the length of the record
records. During processing the relative record number is keys.
converted to a disk address, and the data record at that
address is read. • The length of record keys in indexed files. The
maximum entry is 29 if the keys are in unpacked
Processing by ADDROUT file continues until either the end decimal format or 8 if the format is packed decimal.
of the ADDROUT file is encountered or the program ends All of the key fields in the records of an indexed file
due to the end of another input file (see End-of-File). must be the same length.
• The length of records in ADDROUT files. Three is the
only possible entry here for ADDROUT files.
RANDOM PROCESSING
An entry is right-justified in these columns, and leading
Random processing applies to chained files and occurs only zeros may be omitted.
when a CHAIN operation code in the calculation specifica-
tions is executed. The operand of a CHAIN operation
designates the chained file from or to which records are to
be read or written. RECORD ADDRESS TYPE
For sequential and direct files, records are identified by Column Values Meanings
relative record number.
31 Blank Records in this file are not
With indexed files, record processing is based on information accessed by key or record
,from the key field of a record. Indexed files may also be address file; i.e., sequential,
accessed by relative reeord number if they are input files. direct, or consecutive pro-
cessing requested.
Since records from chained files are read at the time of
execution of a CHAIN operation code (in the calculation A Records in this file are
phase), it is simple to process chained update files. A record accessed by record keys
can be read at total calculation time, fields of the record having unpacked decimal or
can be modified in ensuing calculation steps, and the alphanumeric format.
updated record can be returned to the file at total output
time. The same sequence of update events can be P Records in this file are
programmed to occur during detail calculation and detail accessed by record keys
output time. having packed decimal
format.
This file is accessed via an
ADDROUT file, or this is an
ADDROUT file.

t Relative record numbers identify the positions of records relative to the beginning of the file; for example, the relative
number of the second record of a file is 2.

96768710 A 5-7
Column 31 applies to indexed disl( files specified as input, An overflow indicator is commonly used to condition the
update, or chained output files. Columns 28 and 31 together production of heading lines (records), and it is also asso-
indicate: ciated with the area of the printer page starting with the
overflow line and ending with the bottom of the page. The
• The method through which records in a file are accessed indicator is turned on during execution of the object
program when a space" or skip terminates in the overflow
• Whether this is a direCt file load area. It may also be turned on through the execution of a
SETON operation code. See Overflow Line, section 7, and
When a chained outpu~ file with packed keys is being Stacker Select/Fetch Overflow, section 10, for further
created, packed format must also be specified for the keys discussion of overflow indicators.
in the output specifications.

KEY FIELD STARTING


FILE ORGANIZATION OR LOCATION
ADDITIONAL 1/0 AREA .
Columns Values Meanings
Column Values Meanings
--- 35-38 Blank This is not an indexed file.
32 Blank Sequential or direct file.
Use one input/output area 1-9999 This is an indexed file, and
(buffer) for the file. the key field begins in this
character position of each
Indexed file record.
T ADDROUT file An entry is required in columns 35 through 38 for indexed
files; the columns must be left blank for any other type of
1-9 Sequential or direct file. file.
Use two buffers for the file.
The key field starting location identifies the first (high-
Column 32 has two distinct functions: order) position of the key field for every record in the file.
That position must be the same for every record in the file.
• To declare the organization of a file as Indexed, The key field contains the information that identifies a
sequential, direct, or ADDROUT record and is used in the index portion of the indexed file.
• To request double buffering for a sequential or direct A key field must not contain any X'FF' characters. This
file should be taken into consideration by the user when the key
field has binary format or when an RPG II program is
File organizations were described in Mode of Processing and generating an indexed file.
are discussed further in section 13.
A key field starting location is right-justified in these
The use of two input/output areas, also known as double columns, a~d leading zeros may be omitted.
buffering, leads to faster execution of the object program.
Any of the digits 1 through 9 requests double buffering, but
2 is preferred for a more readable source program.
EXTENSION CODE
Column Values Meanings
OVERFLOW I"NDICATOR
39 Blank Extension specifications and
Columns Values Meanings line counter specifications
have not been prepared for
33-34 Blank a. This is not a printer this file.
file.
b. An overflow indicator is E Extension specifications fur-
not assigned to this ther describe this file.
printer file. L Line counter specificaitons
OA-OG, The specified overflow indi- further describe this printer
cator is used to condition file.
OV
reeords in this printer file. The Line Counter Specifications sheet can be used to further
This entry allows the user to assign an overflow indicator to describe printer files.
a printer file. All record address files and table and array files must have
Columns 33 and 34 apply only to printer output files. Only further definitions OR the Extension Specifications sheet.
on~ of the indicators OA, OB, ••• , OG, or OV can be
assigned to a file, and an assigned indicator should be unique
to its printer file.

5-8 96768710 A
DEVICE BUFOFF is only specified for ASCII files. Therefore, if
columns 54 through 59 of this continuation line contain
Columns Values Meanings BUFOFF, the same columns must say ASCII in the imme-
40-46 See Device assigned to this file diately preceding specifications line. The usc of BUFOFF
appendix also requires an entry in columns 60 through 65 (Buffer
D Offset Length).

Each file in the program is associated with a physical An entry in columns 54 through 59 is left-justified.
device. Appendix D lists the device mnemonics to be
ente['ed in these columns. The name is left-justified (starts BUFFER OFFSET LENGTHS
in column 40) in this specification.
Columns Values Meanings

SYMBOLIC DEVICE 60-65 Blank This is not a continuation


line having BUFOFF as the
Columns Values Meanings continuation lines option

40-52 Blank Use the logical unit for this 0-99 This is a continuation line,
device shown in appendix D. BUFOFF has been specified,
and this is the length of the
1-99 Use this logical unit. block prefix
100-255 Use this address as the An entry is required in columns 60 through 65 if BUFOFF
location containing this has been specified in columns 54 through 59 of this
logical unit. continuation line.
This entry allows the user to assign a logical unit other than BUFOFF and buffer offset length must !lot be specified for
that shown in appendix D. ASCII tape output files.
The offset length (the number of bytes by which records are
CONTINUATION LINE offset within the buffer) is right-justified in these columns,
and leading zeros may be suppressed Note that since an
Column Values Meanings entry is required here if ~olumns 54 through 59 say BUFOFF,
53 Blank This is not a continuation a zero is required here if the block prefix is empty.
line; i.e., this is the first (or
only) specifications line for NAME OF LABEL EXIT
this file
Columns Values Meanings
K This is a continuation
record. 54-59 Blank A SPECIAL device is not
used by this file.
As thp. title of the entry implies, a continuation line is a line
of additional specifications for a TAPE or SPECIAL file. Any valid Name of user-supplied
(TAPE and SPECIAL are valid entries in colUmns 40 through RPG II external subroutine that
46.) One or two continuation lines can be supplied for a name performs input/output oper-
TAPE file, but a SPECIAL file can have only one continua ations for this special
tion record. Continuation lines must immediately follow the device.
initial specifications line for a file.
An entry is required in columns 54 through 59 if the file's
When a K is entered in column 53, an entry is required in declared device is SPECIAL. Name of Label Exit is a
columns 54 through 59 (Continuation Lines Option) and may misnomer in that the subroutine performs all input/output
be required in columns 60 through 65 (Buffer Offset Length). operations for the SPECIAL device, including any required
tape label processing.
CONTINUATION LINESOPTION The subroutine name is left-justified in columns 54 through
59.
Columns Values Meanings
54·-59 Blank This is not a continuation FILE ADDITION/UNORDERED
line.
OUTPUT
ASCII This tape file has ASCII
format.. Column Values Meanings
BUFOFF This ASCII tape input file 66 Blank No file addition and no
contains a block prefix. unordered output are
required for this file.
Table or This table or array is refer·-
array enced by a user-written A New records are to be added
name external subroutine. The to this pre-existing file.
table or array cannot be
named ASCII or BUFOFF. U New indexed output file, and
records are to be wri tten
EBCDIC This tape file has EBCDIC (loaded) in unordered
format sequence.

96768710 C 5-9
Column 66 applie ... to indexed, sequential, or direct disk TABLE 5-2. fILE ADDITION/UNORDERED
fi les. OUTPUT fOR INDEXED FILES

Rf'('ords tire added to the end of a sequential file. The file


must be a declared output file (0 in column 15 of this sheet). Column 15 Column 66 Meaning

With an indexed file, entries are also added to the ends of Blank Read records from the
Ihe index and data portions of the file. But then at the end file without adding or
of object program execution, RPG II reorganizes the entire upda ling records.
index into a"cending key sequence. This reorganization is I
more efficient when Ihe key fields in added records are A Read records from I he
dlready in ascending sequence. File addition cannot be fi Ie and add new rec-
speci fied for an indexed fi Ie being accessed via the ords to the file. Do nOI
sequential-within-limits method. update record".

When records are to be added rtmdomly to an indexed file, Blank Write records to the
the new records may have keys that are lower than, higher file in ascending key
than, or between pre-existing keys in the file. When record" sequence. (RPG 1/
arc added to an indexed file sequentially: does not perform the
ordering automati-
• A new record must have a key that is lower than the cally.)
0
key reI rieved and higher than the preceding key, or
A Add records to the
• The file must be single-volume and at end-of-file. exi"ting file.

Direct files have gaps into which records may be added. U Write records to the
With a direct file, file addition can take place through the file in an unordered
speci fica t ion of a file as an update fi Ie processed consecu- key "equence.
t ively or through the execution of CHAIN operation codes.
When the CHAIN operation code is used, records may Blank Update records in the
replRce the gaps. Otherwise, new records are added to the file without adding
end of the direct file. new records.
U

Records can be added at detail, total, and exception time. A Update records in the
Records to be added are identified by ADD in columns 16 file and add new rec-
through 18 of the corresponding Output Specifications sheet ords to the file.
(form 0).

<\ U in column 66 indicates that an indexed file is to be


created from records supplied in an unordered sequence.
After the new file has been loaded and an index has been With indexed random processing, the records wit hin a
created, RPG II reorganizes the index into ascending volume may be processed randomly, but the volumes are
sequence. processed sequentially; i.e., processing cannot be switched
back and fo['th between volumes.
The various combinations of entries in column 15 (file Type)
and column 66 and their meanings to indexed files are shown The number of extents is right-justified, and a leading zero
in table 5-2. may be omitted.

NUMBER OF EXTENTS TAPE REWIND


Columns Values Meanings Column Values Meanings

68-69 Blank Single volume file 70 Blank Not a tape fi Ie or tape


rewind information not
1-50 Number of volumes in the supplied here·
file
R Rewind this tape file at end-
Columns 68 and 69 apply to disk files only and indicate the of-file.
number of volumes (disks) that contain the file. Multivolume
files cannot be specified with shared input/output (1 in U Rewind and unload this tape
column 48 of form H), sequential processing within limits (L at end-of-file.
in column 28 and A in column 31), or an unordered load (U in
column 66). N Leave this tape at end-of-
file.
A disk file must occupy consecutive cylinders of any
individual disk. Column 70 applies only to files assigned to magnetic tape.

5-10 96768710 A
FILE CONDITION update. output. display. chained. demand. and combined
files. A record address file may be conditioned only if
Columns Meanings associated with a primary or secondary input. update, or
combined file, and the associated file is conditioned by the
71-72 Blank There is no external indi- same external indicator or no indicator.
cator for this file.
When a specified external indicator is off. the file is treated
U1-U8 The file is conditioned by as if it were at end-of-file (i.e •• no records are read from or
this external indicator. written to the file).
The entry in columns 71 and 72 allows a single program to Since these indicators are only set externally. the SETON
function differently. depending upon conditions at run time. and SETOF operation codes have no effect on them.
U1 through U8 are external indicators that can be set by the
computer operator (see appendix B). External indicators may be used:
A typical application for the use of external indicators • To condition calculation operations
would be a sales report package including weekly reports and
a month-end summary report. An external indicator could • To condition output operations
be used to condition month-end calculations and/or output.
• In a field record relationship (see Field Record
Conditioning by external indicator applies to primary and Relation. section 8)
secondary input (excluding table and array input files).

96768710 A 5-11
J
EXTENSION SPECIFICATIONS · FORM E 6

RPG II requires more information about record address files The Extension and Line Counter Specifications sheet is
and pre-execution time table and array files than space shown in figure 6-1. Also shown in the figure are columns
permits on the File Description Specifications sheet. The used by the four types of data sets described in Extension
Extension Specifications sheet provides this extra space and Specifications:
allows a complete description of compilation' time tables and
arrays. Another type of table or array, execution time, is • Record address files (including ADDROUT files)
partially described on this sheet. Previously unmentioned,
an execution time table or array may be. loaded at execution • Compilation time tables and arrays
time via input or calculation specifications and/or output at
execution time through calculation or output specifications. • Pre-execution time tables and arrays
• Execution time tables and arrays

":I t::\ CONTRPL DATA RPG EXTENSION AND LINE COUNTER SPECIFICATIONS Printed In U.S.A.
-::. r::J CORfOR('TION

I::~ II I I I I I I
1 2 7678n787880

Ic.te
Punching
InsUUction
Clre! Electro Hum .....
P.[TI0f_ ~~I I I I I I I
Extension Specifications

-
E ,,~File
NumbIr

1~li
of Number

I~
Table or
I! To Filename Table or
...
E. . . of lAngIh length
Comments

Ii II
Entries of kravName of
Une Array Name (AItIrnItlng Entry
Record PerTibie
From Filename
:~
FonNt)
orArr.y Entty

3 4 5 6 1 8 • 10 11 12 13 14 15 16 17 18 III 20 21 22 23 24 25 26 21 28 29 30 31 32 !33 34 35 36 31 36 39 140 41 411.11 4a 1511 SI 6263 511 60 61 112 63 54 65 66 61 68 IIlI 10 11 12 n 14


L..
o 1 E leo ~:'I -~y ION:T: l~lE:T;AI~L ;E~ A~) ~FtRA ~

o 2 E
o 3 E :'PI= .1=)( :('1 ITIC N:T i/~iEA N~ T,~8 .L. ~S .t.R ~ ~,(~
o
o
01&
4
5
E
E
IE
,. I~
ji :rIM .T,\E L.~~ }fl\ D.:A RI~J

o t7 IE ~ ~L. ' -
~'~h.
,.... ,.... '-' " :ILI ~S~
018 IE
IE
IE

Line Counter Specifications


9 10 12

-
L 1 2 3 4 5 6 7 8 11

~ !
~
t~
Line Filename
I-
·e
of
21
a! !
2 e
::J£ ~ ~ ::3£
o E
..J
oz
21
:>
~:i
It

2~ 6£E ::J£
~~
C21
1i
CoO
t ~.8
C
2 :>
uz
E 2e
! ~.8e
::3£ 6~
C
~i
..Jz uz
!.!E
C
2 :>
J
2 e
:J~
~!
C

6~
E 21
::3~ 11 !! 11 !J 11 6~ ~I
!.8E
C

6~
~z

3 4 5 6 1 8 9 10 11 12 13 14 15 18 11 18 19 20 21 22 2324 25 28 21 2829 30 31 32 3334 38 36 37 3839 40 41 42 4344 45 48 47 48 49 505152 5354 58 58 11 58 59 101162 6364 • • 61 IIlI 69 10"72 1314
1 1 L
1 2 L

NOTEl SHADED COLUMNS MUST BE BLANK FOR THE FILE NAMED.

Figure 6-1. Extension and Line Counter Specifications Sheet

96768710 A 6-1
Columns applicable to each type of data set are shaded in If a table or array file is named in columns 11 through 18,
figure 6-1 .. . the entry here specifies an output file to which the table or
array is written at the end of execution of the object
Comprehensive descriptions of the use of tables, arrays, and program. An execution time table or array cannot be
record address files are located in sections 12 and 13. written out at end-of-job under RPG II control; it can be
output earlier, however, through calculation or output
specifications.
FROM FILENAME The filename is left-justified and must be identical to the
appropriate filename in the file description specifications.
Columns Values Meanings
11-18 Blank a. Compilation time table
or' array -if columns 33 TABLE OR ARRAY NAME
through 35 (Number of
Entries Per Record) Columns Values Meanings
contain an entry, or
b. Execution time table or 27-32 Blank Record address file
array if columns 33 Valid Name of primary table or
through 35 are blank. RPG II array
a. Pre-execution time name
Filename
table or array file, or This is the first opportunity to name a table or array in the
b. Record address file program; all previous references to tables and arrays have
been to the files containing such data sets. A table name
An entry is required in columns 11 through 18 for record must begin with the three characters TAB; any other name
address files and pre-execution time table and array files. in these columns belongs to an array. No two tables or
For the latter" use, this entry specifies the input file arrays may share the same name.
containing the table or array. Since one file may contain
more than one table or array, the same filename may appear If this line of coding describes alternate (or paired) tables or
in th~ From Filename column more than once on the sheet. arrays, columns 27 through 32 designate the first or primary
one; and the alternate is defined in ensuing columns.
The filename is left-justified in this field and must be
identical to the corresponding filename on the File RPG II processes tables and arrays in the order in which they
Description Specifications sheet. are defined on the Extension Specifications sheet. In
particular, when more than one table or array is assigned to
a single file, the tables and arrays are read from or written
to the file in the order stated here.
TO FILENAME
A table or array name is left-justified in columns 27 through
Columns Values Meanings '32.

19-26 Blank a. Execution time table or More information on tables and arrays can be found" in
array, or section 12.
b. Compilation or pre-
execution time table or
array that is not to be NUMBER OF ENTRIES
output at end-of-job
PER RECORD
Name of The name of the file to Columns Values Meanings
output which this compilation or
file pre-execution time table or 33-35 Blank Record address file or
array is to be output at end- execution time table or
of-job array
Name of The name of the data file 1-999 Number of entries per
input or associated with the record record in a compilation time
update address file or pre-execution time table
or array file "
When columns 11 through 18 name a record address file,
columns 19 through 26 designate the primary or secondary Each physical record of a compilation time or pre-execution
input or update data file that is processed via that record time table or array file must have the same number of
address file. entries, except the last, which may have fewer entries.

6-2 96768710 A
Entries must begin in the first character position of a NUMBER OF ENTRIES PER
record, and gaps are not allowed between entries in the TABLE OR ARRAY
record. The absence of gaps, however, does not preclude the
use of leading blanks within an entry. Furthermore, a record Columns Values Meanings
need not be filled to the end, and in fact cannot be if the
record length is not a multiple of the length of an entry. An 36-39 Blanks Record address file
entry must be totally contained within a record; i.e., an
entry may not start in one record and be continued into the 1-9999 Maximum number of table
next record. or array entries
When this line of coding describes a pair of alternate tables Columns 36 through 39 specify one of two things:
or arrays, the entry in columns 33 through 35 defines the
number of pairs of entries in a record. A pair of entries may • The exact number of entries or pairs of entries in this
not be split between two records. table or array
The number of entries per record is numeric and right- • The maximum number of entries or pairs of entries in
justified, and leading zeros may be omitted. this table or array
An example of a nonrelated table is shown in figure 6-2, and When the table or array is full, these columns indicate the
related tables are illustrated in figure 6-3. In each figure, exact number of entries. It is permissible, however, to leave
the input medium is shown as punched cards for simplicity. space in a table or array for entries to be added at a later

ITEM' I ITEM 2 ITEM 3 ITEM 4 ITEM 5 .. ITEM 12 ITEM 13

I 6 12 18 24
" CARD
30 66 72 78
COLUMNS
NOTES: NUMBER OF ENTRIES PER RECORD = 13
LENGTH OF ENTRY (COLUMN 40 - 42) =6

Figure 6-2. Nonrelated Tables

"

ITEM IA ITEMIB ITEM2A ITEM 2B . ITEM5A ITEM 58

, 6 15 21 30
.. ;0 66 75 CARD
NOTES: NUMBER OF ENTRIES PER RECORD = 5 COLUMNS
LENGTH OF ENTRY (COLUMNS 40 - 42) = 6
(COLUMN 52 - 54) = 9
0302
Figure 6-3. Related Tables

96768710 A 6-3
time. This is called a short table or array, and for this case Y!!!!!! Meanings
columns 36 through 39 describe the number of entries the
table or array will have when filled. 43 Blank c. Pre-execution or execu-
tion time table or array
As stated above, if related tables or arrays are being having unpacked deci-
described in this coding line, columns 36 through 39 indicate mal or alphanumeric'
the maximum number of pairs of entries in the tables or format
arrays.
P Pre-exeeution or execution
Since there must be a one-to-one correspondence between time table or array with
items in related tables, the entry here app!Jes to the table or packed decimal format
array named in columns 46 through 5f as well as that named
in columns 27 through 32. B Pre-execution or execution
time table or array with
The number of entries per table or array -is right-justi,ied, binary format
and leading zeros may be omitted.
Numeric data is stored in external media' in one of three
formats - unpacked decimal, packed decimal, or binary.
Unpacked decimal format requires the most external space
LENGTH OF ENTRY for the representation of data. RPG n uses data only in
unpacked decimal format and automatically converts packed
Columns Values Meanings decimal and binary fields to that representation before the
data is used. For nontable and array data,' the conversion
40-42 Blank Record address file takes place when an input record is selected for processing.
RPG n converts an unpacked or binary table or array
1-256 Number of characters in element just before it is moved to a hold area, from which it
alphanumeric table or array is used, and restores the element' to its original format
entry before moving it back to the table or array.
1-15 Number of characters in The amount of space required to store a table or array and
nonbinary numeric table or the amount of time required to perform .conversions on
array entry unpacked and binary data should be taken into consideration
in determining the format for bibles and arrays.
1-9 Number of characters in
binary table or array entry
For a numeric table or array having packed decimal format, UNPACKED DECIMAL FORMA'T
enter the unpacked length of an entry in columns 40 through
42. For a numeric table or array having binary format, In unpacked decimal format every byte (eight bits) of
specify here the number of digits of memory required to storage can contain one character. (The character can be a
contain one entry. A two-character, binary field requires decimal number as well as any alphabetic or special
four digits of memory; a four-character binary field character.) Each character is divided into a high-order four-
requires nine. In other words, for any format table or array bit zone (or sign) and a low-order four-bit digit. In.an
entry, columns 40 through 42 indicate the amount of space unpacked decimal field the sign of the rightmost digit
in memory required for a single entry. determines the sign of the entire field; other zone positions
in tl'!e field are ignored. In binary notation a positive sign is
A numeric table or array entry that is shorter than the 1111, and a negative sign is 1101. RPG n does not check the
length specified here may be padded with leading zeros or validity of numeric fields; the digit portion of any character
blanks. A short alphanumeric entry . may be padded with is assumed to be the numeric value of the character.
blanks at either end.
Unpacked and packed representations of the decimal number
If related tables or arrays are being described on this coding 1,492 are shown in figure 6-4. Notice that the unpacked
line, columns 40 through 42 specify the entry length for the decimal representation of a positive number is identical to
table or array named in columns 27 through 32. the alphanumeric representation of the same number
(appendix D).
The entry length is right-justified in these columns. Leading
zeros may be omitted.
PACKED DECIMAL FORMAT
PACKED OR BINARY FIELD In packed decimal format, zones are stripped from
characters so that digits are packed two per byte. The sign
Column Values Meanings stripped from the low-order character is then placed in the
low-order four bits of the field. (Signs or zones for higher-
43 Blank a. Record address file order digits are again.ignored.) Packed decimal representa-
b. Compilation time table tion cuts the amount of space required by unpacked decimal
or array format nearly in half.

6-4 96768710 A
+-1 BYTE-++-I BYTE-+4-II3YTE-+ .... 1 BYTE--+
ZONE DIGIT ZONE DIGIT lONE DIGIT SIGN DIGIT
SEQUENCE
I~I~I~I~I~I:;I~I--:;I~~AKLED Column Values Meanings
I
+--------
F F 4 F 9 F: 2 HEXADECIMAL
~
4 BYTES - - - - - - -... 45 Blank Record address file, or table
or array entries are
+-1 BYTE-+4-1 BYTi:::-++-1 BYTE--' unordered
DIGIT OIGI r DIGIT DIGIT DIGIT SIGN

1~1~1~1~1--:;1~16~~~~L
A Entries have ascending order
o I 4 9 2 F HEXADECIMAL o Entries have descending
...- - - - - 1 BYTES -----.~ order
O!J03
Column 45 is used to describe the sequence of the entries in
Figure 6-4. Number 1,492 in Unpacked and a table or array. Ascending sequence means that the items
Packed Decimal Formats are ordered with the lowest entry (according to the collating
sequence) preceding all higher entries in the table or array.
With descending sequence the highest entry precedes all
BINARY FORMAT lower entries.
In twos complement binary notation the high-order bit of the When an entry is made in column 45, the table or array is
field designates the sign of the number (0 is positive, 1 is checked for the specified sequence. When order is violated,
negative). an error occurs; recovery procedures are outlined in
appendix B.
A binary field is either two or four bytes long. In the first The order of a table or array determines how RPG II
case, the binary field consists of the I-bit sign and a I5-bit performs LOKUP operations (section 9). An entry is
numeric value that can range up to 9,999. RPG II reserves a required in column 45 for execution time tables and arrays
4-digit hold area [-or a 2-byte binary element. For a 4-byte only if high or low LOKUP is used on the tables or arrays;
binary field RPG II sets aside nine digits of core storage to elements of this type of table or array are not sequence
accommodate the field when it is unpacked. Clearly, binary checked, however.
format requires the least storage, but the conversion process
takes longer.- Packed decimal format is thus a compromise Consecutive equal elements are considered to be in
between unpacked decimal and binary notations. sequence. This means that a short table or array can be
padded with elements of all blanks or zeros at the front end
and all nines at the back end if ascending sequence is
A 2-byte binary field having a value greater than 9,999 or a specified.
4-byte binary field having a value greater than 999,999,999
cannot be converted to unpacked decimal without a loss of If this line of coding describes alternate tables or arrays, the
data. Data is lost from the high-order or most significant specification in column 45 applies to the table or array
,- end in this case. named in columns 27 through 32.

DECIMAL POSITIONS ALTERNATE TABLE OR ARRAY


Column Values' Meanings - Columns 46 through 57 are used to describe one of two
things:
44 Blank Record - address file or
alphanumeric table or array • If columns 27 through 32 name a compilation time or
pre-execution time table or array, these columns
0-9 Numeric table or array,· with specify a table or array that is paired with that table or
this number of places after array.
the decimal p<?int
• If columns 27 through 32 name an executio~ time table
An entry in column 44 distinguishes a numeric table or array or array, these columns may describe another table or
frOID an alphanumeric table or array. The digits 0 through 9 array that is not related to the former and is not loaded
indicate the number of positions to the right of the in alternating format with the former. In other words,
(assumed) decimal point in a numeric table or array element. with execution time tables and arrays, each form Eline
A zero is entered for integer data. may be used to describe two distinct tables or arrays.
If this line of coding describes alternate tables or arrays, the Ordinarily, columns 46 through 57 are used for an alternate
specification in column 44 applies to the table or array table or array. The rules listed for describing the primary
named in columns 27 through 32. table or array apply to the alternate. Remember that the
two names must be l1!lique. Corresponding specification
fields are listed in table 6-1.

96768'110 A 6-5
TABLE 6-1. ALTERNATE TABLE AND ARRAY COMMENTS
SPECIFICATION CODES
Columns Values
First Table Second Table 58-74 Any characters
Field Or Array Or Array
Col~mns 58 through 74 may contain any. characters.
Table or array name 27-32 46-51 typIcally they are used for documentation of the RPG II
source program.
Length of entry 40-42 52-54
A comments field does not affect compilation or execution
Packed or binary field 43 55 of the program, but it is produced in the program listing by
the RPG II compiler.
Decimal positions 44 56
Sequence 45 51

6-6 96768710 A
LINE COUNTER SPECIFICATIONS - FORM L 7

gMtPW;·jaw #'1'008. Hg ,M. Ii :1' t t4 0f k i

The Line Counter Specifications form should be used for The entry of FL in columns 18 and 19 indicates that the
each printer file in the RPG II program and must be provided preceding field specifies the number of lines per page (form
for each printer file having an L in column 39 of the File length).
Description Specifications sheet.
Line counter specifications designate the length of the form
used in the printer and the line at which overflow occurs. LI NE NUMBER - OVERFLOW
When a printer file does not have line counter specifications,
the form length defaults to that listed in appendix B. and the Columns Values Meanings
overflow line is assumed to be six lines less than that length.
20-22 1-112 This line number is the over-
Both the form length and the overflow line must be specified flow line.
on any form L line. The Extension and Line Counter
Specifications sheet is shown in figure 6-1. When the destination of a space, skip, or print operation
falls beyond the overflow line (but before end-of-form),
overflow occurs and the overflow indicator specified for this
printer file on the File Description Specifications sheet
FILENAME turns on. When the overflow indicator is turned on, the
following occurs before forms advance to the next page:
Columns Values Meaning
• Detail lines are printed, if this is the detail time of the
7-14 Filename Filename entered on corres- cycle.
ponding form F
• Total lines are printed.
Columns 7 through 14 are used to identify the output file to
be written on the printer. The name must be identical to • Total lines conditioned by this overflow indicator are
the appropriate File Description Specifications entry, and printed.
that form F line must contain an L in column 39. The output
device assigned to the file must be a printer. Use of overflow indicators with other indicators can cause a
variable number of lines to be printed when overflow occurs.
The filename is left-justified in this field. The user should allow for the maximum number to be
printed, keeping pleasing spacing in mind, when specifying
the overflow line.
LI NE NUMBER - NUMBER Different overflow lines may be specified for different
OF LINES PER PAGE printer files. This may be necessary for a varying number of
lines to be printed in overflow conditions.
Columns Values Meanings
The overflow line number is right-justified, and leading
15-17 12-112 Exact number of available zeros may be omitted.
printing lines on a page

Columns 15 through 17 indicate the exact number of lines


available on the printer page or form (measured from one OVERFLOW LINE
top-of-form to the next). If a number less than 12 is
specified, RPG II indicates an error. Columns Value Meaning
The entry in these columns must be right-justified, and 23-24 OL Overflow line
leading zeros may be omitted.
The entry of OL in columns 23 and 24 indicates that the
preceding field specifies the overflow line number.
FORM LENGTH
Columns Value Meaning

18-19 FL Form length

96768710 A 7-1
INPUT SPECIFICATIONS - FORM D 8

4U*,',
I: 1 P{' , A'MjJli' ',f • .' Ii I Mi ,j {, " ' it

Input specifications describe the files, records, and fields The columns used by each category of description are shown
that serve as input to the object program. The files in figure 8-1. For each file there is at least one coding line
described on form I are input, update, and combined files. of record description followed by as many field description
Each file consists of one or more records, and each record lines as are required to completely describe the record. If
contains one or more fields. appropriate, another record description line, followed by
field description lines, is supp~ied until the one file is
The specifications serve two purposes: completely described. The combination of record and field
specification lines are provided for each input file in the
• To describe input records and their relationships to program (except record address and table and array files).
'other records in the file
• To describe fields of each record

CO~OLDATA RPG INPUT SPECI FICATIONS ..... nted .n U.S.A

CORrO~TlON 1 2 75 76 77 78 79 80
Program
Programmer D.II
pa~rno'_ ::::c.liCM11 IIIIII
I; Record Identification Codes

-I
Field
.~ Field Location
Indicators
~
~.
1 2 3
; I;
I
.
~

l =5§t i €.~ §-s II:


Line

!
Filename Z
~-
~ Position ~ Position - !! PosItion ~lll:
ge ~ -
From To
J! Field Name
! ......
"5

g
.!!:i

rf j Plus MillUl or
Zero

ge~ ~ e ~ Blank
~ ~S !~g
lZ
C§. ~6
.~

~ ~~- ZO II: ~ S~ ~S6 enG: 0 ~


f;:f;;"D
3 4 5 6 7 8 9- 10 II 12 13 14 15 te17 " 19 20 21 22 23 24 25 25 27 21 a 30 31 3231 34l51537l11 3940 41 42 4l 44 45 45 47 48 49 50 51 52 53 54 55 56 51 58 51160 61 62 6384 6566 8788 6970 71 72 73 74
0 1 I
o 2 I RECORO DENTIFICA TlON I
o 3 I i I
o 4 I F I~LD DESCRIPTION
I
o 5 I I
!
o 6 I !
I I I
I

0 7 I i i ; I I
~
~
o 8 I i ~ i
! :
o 9 I ! I
1 0 I :I I I
' ! :
11 I I
:
1 2 I i i
I !
1 3 I ; I I !
1 4 I i I !
1 5 I I
1 6 I
i
1 7 I I
I

!
1 B I i I
I
1 9 I i
; j
2 0 I I
I i
!
I I I
I I : I

I ; i i !

I i I . ,I I I

Figure 8-1. Input Specifications Sheet

96'168710 A 8-1
FILENAME would be sequence numbered in the order in which they
should appear in the file.
Columns ~ Meanings
The first record in a sequence must have sequence number
7-14 Blank a. Field description 01. (Note that the leading zero must be used in. column 15.)
Ensuing sequence numbers need not be consecutive, but ~hey
b. Filename is the same as must be in ascending order. In other words, records In a
that on the previous sequence are described on the sheet in the order in which
record description line they appear in the file. With a numeric sequence entry, an
entry must be made in column 17, and column 18 should be
Valid The name of the file associ- considered.
RPG II ated with this input speci-
filename fication Records within a single file may have alphabetiC and
numeric sequence entries, but those having alphabetic
When an entry is made in columns 7 ~hrough 14, t.his i~ a entries must be listed first on the sheet. Also, only one
record description line, and the entry names the fIle with record sequence is allowed per file. AND or OR lines
which the record is associated. The filename goes on the (description continuation lines) cannot have sequence
first line describing records in the file for a particular entries; presumably, the line preceding the AND or OR line
record group. A record group must be completely described specified" any required sequence checking for the record.
before another filename entry is made in these columns.
When RPG II detects an error in record type sequence, the
The filename specified here must be identical to the indicator HO is turned on. If HO is not turned off by a
filename used on the File Description Specifications sheet SETOF operation, execution is stopped before the next
for this file. The name is left-justified in this field. record is read •. Recovery from this type of sequence error is
described in appendix B.

SEQUENCE
Columns Values Meani!!&s
NUMBER
Column Values Meanings
15-16 Blank Field description
17 Blank Columns 15 and 16 contain
01-99 Check for special sequence alphabetic characters or
blanks.
Any two No check for special
alphabetic sequence 1 Columns 15 and 16 are
characters numeric, and only one
record of this type is
NOTE allowed in the sequence.
The words AND or OR may be left- N Columns 15 and 16 are
justified in columns 14 through 16. See numeric, and any number of
Additional Record Identifications for a records of this type may be
description of these entries. present before record type
changes.
This entry allows the user to request a· check of the An entry is made in column 17 only if ·the entry in
sequence of record types; a sequen~e specification .on columns 15 and 16 is numeric. In the example of the sales
form F requests sequence checking· based on matchIng and salesmen records, the record description for salesmen
record specifications. would contain a 1 in column 17, while the record description
for sales would contain N in column 17. The N would
An alphabetic entry is any two alphabetic characters (for indicate that any number of sales records could follow a
example, AA, OK, ZT) and indicates that this record type is salesman's record (including zero). Note that the sequence
not part of a predetermined sequence of records. The of salesman plus sales records may be repeated in the file;
. record type may appear any time in the file, so long as !t the file is not limited to one occurrence of the sequence, but
does not interrupt another sequence of records. AlphabetiC it is limited to one record type sequence. AND and OR lines
sequence specifications are required for chained files and cannot contain entries in column 17. As with entries in the
look-ahead records. Sequence column, the line preceding the AND or OR line
should contain entries appropriate for the ~ecord.
A numeric entry requests sequence checking. This could be
required when a salesman's name record must precede his
records of sales in a file. Each type of record would need a
record identification code, and the record description lines

8-2 96768710 A
OPTION Columns Values Meanings
Column Values Meanings 19-20 L1-L9 Control level indicator used
as a record identifying indi-
18 Blank a. Columns 15 and 16 con- cator when a record type
tain alphabetic charac- rather than a control field
ters or blanks. triggers a control break (see
b. Columns 15 and 16 are section 1)
numeric, and this
record type is required LR Last record indicator (see
in the sequence. section 1)
HI-H9 Halt indicator used as
o Columns' 15 and 16 are
record identifying indicator
numeric, and this record
type is optional in each when this record type causes
group. an error condition

Column 18 is used in conjunction with columns 15 through 17 ** Look-ahead fields


for sequence checking of record type. If all record types are Spread cards
declared optional, sequence errors are never found. TR

AND and OR lines should not contain entries in column 18


for the same reason cited for Sequence and Number. RECORD IDENTIFYING INDICATORS
The usage of columns 1~ through 18 can be ill~strated. us!ng When a record has been selected for processing, the
the salesman/sales file as an example. That fIle descrIption indicator specified by this entry is turned on by RPG II. The
can be expanded to include the following record types: indicator is commonly used to condition calculation and
output functions appropriate for the record type within the
SaleslJlan's name cycle. All other record identifying indicators are. off during
the cycle, unless chained files or demand files are being
Salesman's street address processed, at which time pertinent indicators are on
[ Salesman's apartment number] simultaneously. A record identifying indicator is on for thc
duration of a program cycle.
Salesman's city/state/zip code The specified indicator may be unique for each record type,
[Sale] but sometimes it is useful to assign the same one to
different record types - to condition identical calculation
and output processing for more than one type of record.
Bracketed records are optional. If the salesman has an This type of assignment can be made by using the OR
apartment he has only one at the stated address. Hopefully, relationship.
he will ha;e zero sales records ooly while he is on vacation,
but any number of optional sales records are allo~ed for. A record identifying indicator need not be assigned if the
The appropriate encoding of columns 15 through 18 IS shown program is not concerned with different record types.
in figure 8-2. Also shown in the figure are record sequences
for salesmen A and B in a card file. Note that one of B's When a control level indicator is used as a record identifying
sales .w.as credited to A; record type sequence checking does indicator lower level indicators are not automatically
not detect that type of error. turned o~, as they are when a control field triggers a .control
break. No record identifying indicators are on durmg last
record time (see appendix F). Record identifying indicators
RECORD IDENTIFYING INDICATOR, need not be assigned in any particular order.
LOOK-AHEAD FIELDS, Record identifying indicators may not be specified in the
OR SPREAD CARDS AND line of an AND relationship. However, different
Meanings identifying indicators may be assigned to the record types in
Columns Values an OR relationship. A record identifier in an OR line that is
a. Field description, or not specified anywhere else in the program may be used to
19-20 Blank bypass unwanted records (for example, blank records).
b. No distinction need be
made between this
record type and the
preceding record type.
'"

01-99 General record identifying


indicator

. 96768710 A 8-3
available while the current record is being processed from
Sequence Number Option the same file. Thus, in the case of update and combined
Record Type (Column 15-16) (Column 17) (('olurnn I R) files, look-ahead fields apply to the current record unless
the current record is still in the read area (i.e., has not been
selected yet). In single file processing, look-ahead for
Nome 01 I ~ update and combined files always applies to the current
Street address 02 I ~ record. For other single input files, look-ahead applies to
Apartment number 03 I' 0 the next record, as RPG n reserves two memory buffers for
City/state/zip code 04 I ~ the file when look-ahead is specifi~d.
Sale 05 tJ 0
Look-ahead fields cannot be specified for chained or demand
files or files that contain header/trailer records (spread
cards).
Only one set of look-ahead fields can be described per file,
and the set of fields applies to every record in the file,
regardless of record type. Look-ahead fields cannot be
altered by the program, either by calculations or by blank-
after operations.
Look-ahead field specification lines require alphabetic
sequence codes, and columns 17, 18, and 21 through 74 must
be blank.
If a field is to be available before and after its record is
selected, the field must be described on two specifications
lines - as a look-ahead field and as a normal field.
After the l~t record has been processed from a file. every
character position of each look-ahead field for the file is
automatically filled with nines.
Record selection is described in detail in section 13.

SPREAD CARDS
0304
Figure 8-2. Record Type Sequence Checking Some applications require that a data tile be structured in
such a way that a set of records in the file conSists of a
header record and some number of item or transaction
records. An example of this could be a tile organized by
salesman number in which the salesman's identification
would be the header record and that record would be
LOOK-AHEAD FIELDS followed by a variable number of his sales records, which
could be called trailer records.
When columns 19 and 20 contain a pair of asterisks, fields
contained on the current line and succeeding lines are look- With the spread card capability of RPG II, trailer card
ahead fields. A look-ahead field can be examined in the information can be included on the header record and
next record of the file, while the current record is still being following records so as to conserve space in the input file.
processed. Look-ahead fields are used for two purposes:
An example of the usage of spread cards is shown in
• To determine when the last record of a control group is figure 8-3. In the example, each job classification contains
being processed a variable number of pay codes, and a pay rate is associated
with each code. Through th~ use of spread cards, the 14-
• To extend the matching record capability record file is reduced to three cards.
Look-ahead fields apply to input, update, and combined files. The spread. card option is' available for any sequential file
In multifile processing, one record from each file is read that is defined to be a primary or secondary input file. Each
into a read area, and record selection occurs in core from spread card consists of a header portion followed by trailer
that read area. 'When a record is selected for processing, portions, the maximum number of which is determined by
that record is moved to a process area, and the next record the file's record length. The trailer portion may contain
from the file is read into the read area in preparation for more than one field; however, each trailer portion must
the next selection. In this way, fields of the next record are contain the same number of fields. Fields of a trailer
available for look-ahead while the current record is being portion may not be split between records. Look-ahead fields
processed. The exceptions to this procedure are update and cannot be specified for spread cards.
combined files. In these cases, a second record is not

8-4 96768710 A
(CODE/RATE
(CODE IRATE I
LCLASS2
I
(CODE /RA TE I
(CODEIRATE I
(CODE/RATE /
~ CODEIRA TE I
LCODEIRATE I
(,CODE IRATE I
(CODEIRATE I
(CODE IRATE I
(CODEIRATE I
(CODE~ATE
CLASS I
I 10 80

PAY RATE FILE WITHOUT SPREAD CARDS

(CLASS 2 ICODEIRATE CODE RATE I


(CLASS I ICODEjRATEfODE RAT~

{"CLASS 110 14 18 22 26 30 34 38 42 46 '50 54 58 62 66 70 74 80


n n ::0
> 0 > n n ::on ::on n::o
::0 ::0 ::0
8 0> 8 >0 >0 > ::0
0>
rn ~ ~ ~ ~ ~ ~ .~ ~ ~~ ~~ ~ ~nt
PAY RATE FILE WITH SPREAD CARDS
,0305

Figure 8-3. Example of Spread Cards

Spread ,cards are specified in the following fashion: program need be described, although the fields at the
start and end positions of the trailer portion must be
1. Enter a proper file and record type specifications line described to indicate the length of the trailer. In
for the file. If the spread card record has a numeric addition, only the first trailer portion need be
record identifying indicator, an N must be specified in described, as each trailer portion must have fields
column 17, indicating a variable number of records. identical to those of the first trailer.
2. Describe the fields of the header portion as ordinary One trailer portion is processed per program cycle; RPG II
fields on separate specifications lines immediately treats a trailer portion combined with the header portion as
following the file and record type line. Any character one logical record. During processing, a physical record
posi tions up to the first trailer portion ru:e considered to consisting of only a header portion is bypassed.
be part of the header. Any record identification codes
for the record must be contained within the header; i.e., RPG II calculates the number of trailer portions per physical
they must not occur in any trailer portion. record according to record length and the lengths of the
header and trailer portions. During spread card processing,
3~ Enter TR in columns 19 and 20 of the next line to a new physical record is read when:
indicate that fields of the trailer follow on ensuing
lines. All of the other columns of the TR line after • The calculated number of trailer portions has been
column 6 must be left blank. processed, or
4. Describe the fields of the trailer on separate lines • An all-blank trailer portion has been encountered.
following the TR line. The fields are described as
ordinary fields, except that columns 59 through 62 Proper input specifications for the spread card example are
(Control Level and Matching Fields) must be left blank. shown in figure 8-4.
Only fields that are to be used 'elsewhere in the RPG II

96768710 A 8-5
RPG INPUT SPECIFICATIONS
(Iii) ~DATA "''''ttd tft U.S.A.

I~-~ I I I I I I I I
CORrO roN 1 2 757177717V80

I:::. 10... I ~i~


InstructIOn Puncfl
~E~.Num_1 ,.lQJilot_ ::=~tiCM>1 I I I I I I
Record Identification Codes
I .1
1 1 2 3
Field location Field
Indicators
I--- !.,:. 15
j
Line Filename
I. Z f:15
=2 j ....... ...... .1 j Field Name =
] !! j Z.o
...! • • at From To Plus ~
J II I
PWtIan or

! ro'i'- II j i
j
~i
~
Z~i
j ~ j~ ~
ii::!
~ J 81ank

3 • I • 7 • • 10 "

o 1 0 1 tr., f:% L.[E


t; ii~
12 13 I. II
'-17 ""20 21214324
OJ .. 01J. fn ·tt
2521 27.213031 ~S3 34~.37. 3940 .1 i«z 43 . . . . .7 41495011 ~ 53 54 55 56 57 II
•• 81.2 aM 85 II .7. .. 70 " 72 72 7.

o 2 "1 f ~C (It. ASls


o 301 .,.I~
o .. ""'I :11 l.tl~ f'(J. ~E
o 5 ~1 iii..; JIB I~ Arrlf
o• 1
'-- '- l-

Figure 8-4. Input Specifications for Spread Card Example

RECORD IDENTIFICATION CODES Each record identification code is one character in size.
The record position (number of characters from the begin-
These entries tell RPG D how to distinguish between record ning of the record) is entered here. The position is right-
types in a file. Up to three identifying codes may be justified, and leading zeros may be dropped.
specified per line of input specifications. When more than
three codes are required to identify a record, additional
codes are described on following lines - iri either an AND or
an OR relationship. Codes on a single line are in an AND NOT (N)·
relationship: code 1 AND code 2 AND code 3.
Columns Values . Meanings
When a file contains only one kind of record or when it is not
important to distinguish between records in the file, 25, 32, Blank a. Record identification
columns 21 through 41 may be left blank. or 39 code not needed, or
b. Record identification
Only one input record is processed per cycle. When a record code must be present.
is selected for processing, its record identifying indicator, if
any, is. turned on. If a record fits the description of more N Record identification code
than one record type, only the record identifying indicator must not be present.
for the fi~t specificati~n is tumed on.
The NOT specification is used to indicate that the record
When RPG D encounters a record that cannot be identified, identification character must not be.present in the specified
it turns on indicator HO. Execution is terminated before the record position. .
next record is read unless HO is turned off by a SETOF
calculation operation. Recovery from this type of error is
described in appendix B.
Crz.ID
Columns Values . Meanings
POSITION
26, 33, .Blank Record identification code
Columns Values Meanings or 40 not needed
21-24, Blanks Record identification code C Full character comparison
28-31, or not needed
35-38 Z Zone comparison
1-9999 Record position of the
record identification code D Digit comparison

8-6 96768710 A
These columns indicate what portion of the· record identi- STACKER SELECT
fication character is used as part of the record identifying
code: the zone portion (upper four bits). the digit portion Column Values Meanings
(lower four bits). or both (full 8-bit character).
42 Blank a. Input device is not a
Many characters have either the same zone or same digit card reader. or
portion. The character set is grouped according to equal
zone and equal digit in appendix D. b. Cards automatically
fall into primary card
stacker. or .

RECORD IDENTIFICATION CHARACTER c. This card reader does


not have multiple
Columns Values stackers.

Blank or any alphanumeric character 1-4 Stacker into which this


27.34. record type is stacked
or 41
Use any alphabetic character. numeric character. or special An entry· in column 42 indicates that certain input record
character to designate the character in the record that types must be stacked in a specific stacker. (An entry of 1
serves to identify the record. A blank is a valid record designates the primary stacker.) Stacker select applies to
identification character. input and combined files. Stacker select may also be
specified for the output phase of combined files on the
Output Specifications sheet.

ADDITIONAL RECORD Any record type that is stacker-selected on the Input


Specifications sheet should not have output operations
IDENTIFICATIONS specified for it. If output operations are specified for a
Columns Values Meanings record type. the input stacker select specification is ignored
if the output is performed.
14-16 AND The record identification
codes on this line are in an Ordinarily. if the same stacker is used for both input and
AND relationship with codes output files. an output record precedes an input or combined
on the previous line. file record in the stacker. However. if look-ahead fields or
dual input/output areas are specified for the input file. an
14-15 OR The record identification input record precedes an output record in the stacker.
codes on this line are in an Furthermore. stacker select may not be specified for input
OR relationship with codes files having dual input/output areas.
on the previous line.
A record type specified on an OR line may have a stacket
More than three record identification codes can be select specification. If the OR line does not have a stacker
designated for a record type by entering the word AND in selection. the records automatically fall in the primary
columns 14 through 16 of the next line and using columns 21 stacker. A stacker selection may not be specified for a
record type described on an AND line.
through 41 as described in the previous paragraphs.
RPG II permits an OR relationship between record identi-
fication codes for one record type or between record types PACKED OR BINARY FIELD
for efficient field description when:
Column Values Meanings
• One record type can be identified by different
combinations of record identification codes. For
-example. one record type can be identified by the 43 Blank a. Record description line
character A or B or C in column x. b. Alphanumeric or un-
packed decimal format
• Two or more record· types have identical field descrip- field
tions but must be considered as different records.
P Packed decimal format field
• Two or more record types may have nearly identical
field descriptions. but· a small number of fields have B Binary format field
different descriptions or may occur in one record type
and not in another. Field descriptions begin in column 43.
Grouping record types in OR relationships can simplify Data may be stored externally in packed or binary format to
coding by allowing identical fields to be specified only once. conserve space. RPG II converts these fields to unpacked
The few fields that are unique can then be linked to their decimal format for internal storage. An entry of P or B in
corresponding record types through entries in columns 63 column 43 indicates too RPG II that reformatting of a field is
and 64 (Field Record Relation). required.

96768710 A 8-7
Any table or array that was read in packed or binary format is entered for an integer field. The number entered here
should have f:ln entry in column 43 of. the Input Specifications cannot be larger than the effective field length designated
sheet. Field positions indicated on form I should define the under Field Location.
positions the table or array occupies in the record in packed
or binary format. The unpacked decimal length of each If a field is to be used in arithmetic operations, or if it is to
table or array element is defined on the Extension Specifi- be edited, the field must be numeric (i.e., column 52 must
cations sheet. When whole arrays are being used, each array have an entry).
element should be treated as a field.
Complete discussions of unpacked decimal, packed decimal,
and binary formats are found in section 6. . FIELD NAME
Columns Values Meanings
FIELD LOCATION 53-58 Valid Field mime, array name, or
RPGn array element name
Columns Values Meanings field
name
44-51 Two one- Beginning (From column)
to-four- and endi~ (To column) PAGE, Special words
digit character positions of the PAGEl,
numbers field or PAGE2
The field location is the starting and ending character Columns 53 through 58 are used to name the fields found in
positions of the field in the record. The starti~ position is input records. The name listed here is used throughout the
entered in the From column (columns 44 through 47), and the RPG II source program to reference this particular field.
endi~ position is" entered in the To colum"n (columns 48 The names of fields in all the record types must be
through 51). A one-character field is designated by encoding indicated; however, only the fields actually used elsewhere
the same position in both the From and To columns; in the RPG n program need be listed. If the field is a table
otherwise, the entry in the From column must be smaller or array, the name must have already appeared on the
than the entry'in the To column. The positions are right- Extension Specifications sheet.
justified, and leading zeros may be omitted.
The entries indicate both the position and the size of the
field. The maximum size for numeric data is 15 characters FIELD NAMES
(eight if packed, four if binary); for alphanumeric data, 256
characters. To determine the length in bytes of a packed Different fields in the same record should have different
field, divide the unpacked length by 2, add 1, and ignore the names; thus, each field of a record is defined on a separate
remainder. (The 1 is added to account for the sign.) A coding line. If two or more fields in the same record type
binary field of four or fewer digits occupies two bytes; have the same name, only the last definition of the field is
otherwise, a binary field requires four bytes. A field that is used.
read from a card is limited to the length of a single card.
Fields in different record types may have the same name if
they have the same format and length. Such fields may
Fields within a record may be defined in any order on the occupy different record positions, however. To avoid
Input Specifications sheet.· Fields may overlap, and the duplicate coding when describing the same field in two or
same positions may be given different field names. more' records, an OR relationship may be used (see
Additional Record Identifications).
The From and To columns need not allow space for a whole
array. When an array is read in, it is read from element 1 up When a field is to be used in arithmetic operations, or if
to as many elements as will fit into the Field Location field contents are edited or zero suppressed, the field must
specifications. be declared to be numeric. If a field is to be used as both an
alphanumeric and numeric field, it must be defined twice by
designating two different field names for the same record
position.
DECIMAL POSITIONS
Column Values Meanings
--- SPECIAL WORDS (PAGE,
52 Blank Alphanumeric field PAGEl, PAGE2)
0-9 Numoer of decimal places in A reference to PAGE on the Output Specifications sheet
numeric field causes pages of the affected output file to be numbered.
RPG II will automatically number the pages of the file,
Column 52 is used to specify the number of positions to the starting with page 1. "
right of the (assumed) decimal point in a numeric field. An
entry must be made here only if the field is numeric. A zero

8-8 96768710 A
To start the page numbering with a number other than one, a by the importance of a control field in relation to other
field with the name PAGE can be input and an alternate control fields. For example, a control field that triggers a
starting page number minus 1 in the field can be given. regional total calculation should have a higher control level
(Page number minus 1 is given because RPG II increments indicator than a salesman's control field.
page counters just before they are output.)
Several fields in an input record can be used as one control
The forma,t specified for a special word must be numeric, up field by assigning the same control level indicator to all of
to 15 positions in length, and there must be zero decimal the fields. This is known as a split control field. Fields of a
positions. The contents. of a PAGE field should be right- split control field must be described on adjacent specifica-
justified, such as 0012. tion lines~ The first field specified is considered the high-
order part of the control field, and the last is the low-order
Page numbering is restarted during execution of the program part. Any fields in between have the significance of the
whenever the PAGE field is read from an input record. order in which they are defined. Split control fields must
Because a page counter has a field name, the page number adhere to the following rules:
can enter into calculations like other input fields.
• For a single control level indicator, control fields may
The special words PAGEl and PAGE2 provide three page be split in one record type and not in another if the
counters for a single RPG II program. The definitions of field names are different. However, the total length of
PAGEl and PAGE2 are identical to the definition of PAGE. a control field, split or not, must not vary between
Use great care when using the same page counter for more record types.
than one output file.
• The length of the portions of a split control field may
vary between record types, but again, the total length
of the control field must be constant between record
CONTROL LEVEL types.
Columns Values Meanings • No other specification lines may come between lines
specifying a single split control field.
59-60 Blank A control level indicator is
not associated wi th this • A split control field is considered to be numeric if any
input field. portion of it is defined to be numeric.
LI-L9 Control level indicator to be • A numeric split control field may exceed 15 characters
associated with this input as long as no portion of the field exceeds 15 characters
field and as long as the sum of control fields is not greater
than 256 characters.
These columns allow the assignment of control level
indicators to input fields. Control level indicators are used • A split control field cannot be made up of a mixture of
to specify the point at which certain calculation and output packed and unpacked decimal portions.
operations are to be done •.
General rules for the specification of control fields are the
A control level indicator can be assigned to any field except following:
a binary field. Furthermore, control level indicators cannot
be associated with chained or demand files. • If a single control level indicator is used with different
record types or even different files, the control fields
A field having an assigned control level indicator is known as associated with that indicator must be the same type
a control field. When information in a control field changes, (alphanumeric or numeric) and the same length.
a control break occurs. All records having the same
information in the control field are known as a control • In one record type, record positions in control fields
group. may overlap. However, the total number of character
positions specified for control fields in the record type
Control level indicators are ranked from L9 (highest) to L1 must not exceed 256.
(lowest), but may appear in any order in the input specifica-
tions. The LO indicator is always on and thus may not be • Fields from different record types that have been
. assigned as a control level indicator. LO can be used as a assigned the same control level indicator may have the
conditioning indicator, however, as if it were a true control same name.
level indicator.
• Except for elements of a split control field, control
When a control field enters processing, the contents of that fields may be specified in any order.
field are compared with the contents of the same field from
the previous record. If they are not equal, the specified • Decimal positions are ignored when numeric control
control level indicator is turned ort along with all lower fields are being compared with one another.
'- control level indicators. For example, if indicator L3 has
been assigned to the field in question and a control break • Signs are ignored when numeric control fields are being
occurs, indicators L3, L2, and L1 are turned on. These compared with one another. Therefore, a numeric
indicators would then be used to condition calculation and control field is always considered to be positive, and -4
output functions - typically summary operations. The is considered equal to +4.
assignment of control level indicators should be determined

8-9 .
96768710 A
• All control fields assigned a single control level· • Record selection based upon matching records and
indicator are considered numeric if anyone of the fields sequence checking of multiple input, update, and
is numeric. In this case, the sign portion of each of the combined files
control fields is ignored, even the sign portion of
alphanumeric fields. In record matching, the file sequences must be consistent-
all ascending or all descending, as encoded on form F. The
• The control field area in memory is initialized to order in which fields are matched depends upon the value
hexadecimal zeros for numeric control fields. With (Ml through M9) assigned. M9 designates the highest order
alphanumeric control fields, the control field is initial- field, and Ml the lowest.
ized to the lowest collating (or alternate collating)
sequence value given. In single file processing, the assignment of Ml through M9
determines the order in which fields are checked for
• It is very likely that a control break occurs when the sequence. As in record matching, the higher order code
first record containing a control field is read. For this must be assigned to the higher order field.
reason, total calculations and output are bypassed for
the first input record containing a control field. Sequence checking occurs automatically when files are being
matched. When a sequence error is detected, indicator HO i i
• Ordinarily, all types of input records in a program turned on. If HO is not turned off during the calculation
contain the same number of control fields. However, phase, the object program halts before the next record is
some applications do not permit an equal number of read. Recovery from a sequence error is outlined in
control fields in all record types, and the result could be appendix B.
some unwanted control breaks. This situation is
illuatrated in figure 8-5. The input file has two record Ml through M9 are not indicators but cause the MR
types, one having the configuration: indicator to turn on when a match occurs.
Column 1 1 . The following rules apply to the specification of matching
Columns 2- 4 Project number fields:
Columns 5 - 15 Project name • Matching is allowed only with primary and secondary
files.
and the other containing these fields:
• A given record may have as many as nine matching field
Column 1 Blank codes.
Columns 2-4 Project number
• The number and lengths of fields to be matched (those
Columns 5-6 Pay rate code with corresponding Mn codes) must be equal. The
Columns 7-10 Pay rate length ot the combined matching fields of a record must
be the same as for any record against which matching
Columns 11-15 Employee number takes place. The sum ot the lengths of all matching
Columns 16-19 Hours w,orked this week fields of a record must not exceed 256 characters.

Without special handling, in addition to the expected • Matching fields within a record may overlap, but the
total number of characters may not exceed 256 (i.~.,
control breaks,a control break occurs when the first overlapped character positions are counted twice).
eQlployee record following a project identification
record is read. Figure 8-5 contains excerpts of an • .Fields to be matched may be either alphanumeric or
RPG II program 111 at inhibits the unwanted control numeric (but not binary). All matching fields having the
break and demonstrates the effect of" the unwanted same matching level are considered numeric if anyone
control break with and without the special handling is declared numeric. Or, an alphanumeric field may be
(using indicator 15). considered numeric for matching or sequence checking
by defining it again with a different field name and
designating it as numeric. The matching level is then
MATCHING FIELDS used with the redefined field.

Columns Values Meanings • Decimal positions are ignored when numeric fields are
being matched. Also, a numeric field with leading zeros
matches a field having the same value and suppressed
61-62 Blanks No matching is to be per- leading zeros (i.e., 0123 equals ~123).
formed on this input field.
MI-M9 Matching level assigned to • Signs are ignored when numeric fields are matched.
Thus, a negative number can match a positive number.
this input field
Columns 61 and 62 are used for two purposes: • Multiple matching fields are in an AND relationship.
That is, matches must occur in all matching fields
specified for a record before MR turns on.
• Sequence checking of a single input, update, or
combined file, or

8-10 96768710 A
100 PROJECT A SUBTOTAL

02 00652 40.0 320.00


02 r0321 3.5 28.00
02 56781 32.0 .256.00
604.00 SUBTOTAL
604.00 TOTAL

110 PROJECT B
01 10321 36.5 365.00
01 45098 35.0 350.00
715.00 SUBTOTAL
02 45098 5.0 40.00
40.00 SUBTOTAL
755.00 TOTAL
1359.00 GRAND TOTAL

OUTPUT SHOWING UNWANTED CONTROL BREAK

100 PROJECT A
02 00652 40.0 320.00
02 10321 3.5 28.00
02 56781 32.0 256.00
604.00 SLinOTAL
604.00 TOTAL
100 PROJECT B
01 10321 36.5 365.00
01 45098 35.0 350.00
715.00 SUBTOTAL
02 45098 5.0 40.00
40.00 SU3TOTAL
755.00 TOTAL
1359.00 CRAN>TOTAL
OUTPUT Wt-£RE UNWANTED CONTROL BREAK IS SUlPRESSED

~OLDATA RPG INPUT SPECIFICATIONS Pr."ted .... U.s.A.

CORrQRt\1l0N

I==- 10.18
PunchIng
Instruclion I::~ I I I I I I I I~~E~Num_ P.~O,_
I 2 75 78 77 78 79 80

~~Iionl I I I I I I

~ Record Identification .Codes


I 3 Field Location Field

- ~ I 2 3 Indicators

f:~ j
~
~
Is
I
Line
~
...
Filename
1=0 Z
1i- ~ l'alidon
ge
t ~
l'alidon
g~~
t l'oIIIiDI'I tl~
~I--
From To
)
Field Name
!
j~
......
r~
j Plus ~ or
z"o
E
~ -fo; 'Rr-" E j
~8 j ~ S6 ~ 6 j§ ; g
!S ... G: ~ J iB I
Blink

o
4 5 6 7 8
0
'ii~
9 10 II 12 13 U III I. 17 18 1920 21

AA
:n :n 24 2S 28 27 21 211 30 31 3233 34 3$ 38 37 38 3940 41'" 4344 . . . . 47 48 49 50 51 52 S3 54 SS 56 S7 58 MfIO 61 62 8314 6566

e1
.7. 6970 lIn7374

I
0 1 ~A ~p wlR .1k:l j
o 2 01 1.2 tic. PIJ U~ L2
o 3 0 1 l5 IJ5 PIN A1/'JIE
o 4 rl as 20 1 f.
o 5 01 i2 '10 PIN ()~ L2
o 6 r"'Il ~ I:, ~A riA QJtD LI.:J.
o 7 :::::1 ? lLc ~A IkT~e
o B "'1 11 ~S F'M PtJ~
o
I 0
9 ~1

1
-
l' 1.9 1U AS

Figure 8-5. Specifying Around Unwanted Control Breaks (Sheet 1 of 2)

96768710 A 8-11
CONTRPL DATA RPG CALCULATION SPECIFICATIONS Printed In U.S.A.
CORrO~TlON
Program 1 2 75 76 77 78 79 80

Programmer Date page~o'_ :~;~:Cltion IIIIIII

~
C Indicators Result Field
Resutting
Indic.tors
cr Arithmetic

&
ez
«
At At Factor 1 Operation Fletor 2 :1 ~ 'Minus' Zero
Plus Comments
Line ~ Name length ofl 1>211Compa ..

e ~ ~~
<2'1-2

.f ~j z
1)
J u :: Lookupl Factor 2lis
~~ High low Equal
3 4 5 6 8 • 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25. 211 :n 28 29 30 31 32 33 34 35 36 31 38 39 40 41 42 43 44 4S 46 47 48 leg &0 &1 S2 SJ 54 SS 56 57 58 S9 60 61 62 63 64 65 66 61 68 69 70 71 72 13 14
o 1 Ie C :lIt I' !WIN IllS.
o 2 ~C
2C Sf T~IF ,
I' 11S
o Ie c I,., L LI1' I~ ATIE
1J.1IR~ I~~I~
3
~Ic lul~ IllAY
o 4 r.c 21£ IWIItI I~A~ IAt.t11l I~,,,, II I It; II :~11I II ......
II
~rZ
o 5 Ie c
It.! I~I\J :eh' 011 IA!1:lIJ: hall ,"~'1 ~~
o 6 ~c
ILI2 lI~rt IAi1i:t r;l ))7 (J/T ~IA 1)71'7 1(:2
o 7 C
- - - I

RPG OUTPUT SPECIFICATIONS

I=~ I I I I I I I Ic.dbcuo~ I
I 2 75nnn7leD

I=- 10." P"'~of_ =-~UIIIII

0
';".', ,-,,y, .,
. ~:;'~11~;i .
~i
SpKe Skip Output Indicators
.. eo..- ZoroBal.as
so. - x-
,..-.
R_

.~~;; ,.%~:.:
No CR
I--
to Print ,: 'i'~:!
V- 0.-

~i II!
A J

1!
VIS VIS I.
VIS No 2 a K Field Edh
Line Filename End No VIS 3 C L Z - z_
Positon 0 M s.--
J~
No No 4

...~
DI in
AD~
I •I ~
~I
:: Output Constant or Edit Word
E
O[! c I I "AUTO Record
~
.! ~ N 0
3 4 & , 7 • 9 10 11 12 13 14 ~ 18 1 18 ,t 20 21 22 23 24 253 2728 2tJO 31 3:! 33 34 31 31 37 38 be 40 41 42 43 ~~~V48~~~~~MM~~~~~~~~MM.~.mro
I7t n" '"
o I ~o I~IR rLNT 21 ~! lile .-
,.
o 2 ~O 'P II ~J ~ 'I
o 3 11-0 IF at AI~IE lJl4:
o 4 I,. 0
~ 1 21r
0 51,. 0
... -- ~A TC Ia~ 11
o a 0 Ie 1~IJl IIIg .115 -
o 7 ,,",0
I" IA ls 11it1
o 8 11'0
- ~I" PAt ~ 1~le -- - 1-1- - --
o 9 11-0
tl 1 1,1.. IAI I., 1.<
-- - - 1-+-
1 O~ 0 ~IL 1"1' IY- 28
1 " .. 0
1-1- H- I - - -I- II"

_. IS~
--~-
\ .. IllrJ , ;;, IliA I.'
I ...
~
I- 1-.' --I- -1- 1--1-

1 2" 0
1 .1 LI~ -- . - f - - --
3 (0
- TIQIT
I
",~ 121a -._- -- -
I 4 ro al~ ''T 1(211' A I.'
--I- f-!- -f--
t 5 r 0 7 111 tl,4t
1

1 8
610
7,., 0
0
II "
IJ " WI f'\ 218
~1.1
., IRA A)!D trill! rrA IL'
-

Figure 8-5. Specifying Around Unwanted Control Breaks (Sheet 2 of 2)

8-12 96768710 A
• Alphanumeric matching fields are initialized to the • All fields with the same field record relation (i.e.,
lowest collating sequence (or alternate collating related to one record type) should be described on
sequence) value when ascending sequence checking is consecutive specification lines for more efficient use of
specified, or the highest sequence value when descend- core storage.
ing sequence is specified. Numeric matching fields are
initialized to zero. • All portions of a split control field must have the same
field record relation entry, if any, and must be
• Not all files used in a program must have matching described on consecutive specification lines.
fields. Neither must all record types in a file for which
matching has been specified have matching fields. • When used with match or control fields. the field record
relation indicator must be the same as a record
o When packed decimal fields are being matched, the identifying indicator for this file, and the match or
unpacked length; i.e., (2 x packed length) -1, is regarded control fields must be grouped in the specifications
as the length of the match field. according to the field record relation indicator.
• Match fields may not be split. This means that the • When any match value (Ml through M9) is specified
same matching level cannot be used with two fields without field record relation, all match values must be
within a record ~ype. declared once without field record relation. Con-
versely, if any match field in a set of match fields has a
• Field names are ignored in matching record operations. field record relation, all fields in the set should be.
Thus, fields from different record types which have declared with the same relation, using dummy (unref-
been assigned the same matching level may have the erenced) match fields for fields that are not used with
same name. all records.

• Matching is not allowed for chained or demand files. As described under Additional Record Identifications, a
record identifying indicator (01 through 99) can be specified
When a successful match causes MR to turn on, the indicator here for rec~rds in an OR relationship having fields that
is turned on before detail calculations and retains this occupy different positions in the records. In this case, the
setting for one .complete cycle. A record selected by indicator specifies the record for which this field definition
FORCE causes the MR indicator to go off for one complete applies •. Fields with no field record relation are associated
cycle, while the forced record is being processed. with all the record types in the OR relationship.
Record selection through record matching is discussed Control fields and match fields can also be related to
further in section 13. particular records in an OR relationship. Control fields and
match fields without a specified field record relation are
associated with every record type in the OR relationship.
When two control fields have the same control level
FIELD RECORD RELATION indicator or two match fields have the same matching level
indicator, it is valid to assign a field record relationship to
Columns Values Meanings just one of the control or match fields. In this case, the
control or match field definition having the field record
63-64 Blank No particular field-record relation is used when the indicator is on, and the field
relationship definition not having a field record relation is used when the
indicator is off. Indicators Ll through L9, U1 through U8,
01-99 Previously assigned record and MR cannot be specified in columns 63 and 64 for control
identifying indicator and match fields.
LI-L9 Previously assigned control A control level indicator (LI through L9) or the matching
level indicator record indicator (MR) is specified as a field record relation
when the defined field is to be used only when the control
MR Matching record indicator break or matching records occurs. The particular condition
under which the field is accepted is indicated by Ll through
UI-U8 Previously set external indi- L9 or MR, and the field is used only when the specified
cator indicator is on.
HI-H9 Previously used halt indi- When U1 through U8 have been encoded in columns 63 and
cator 64, the normal processing for this field is carried out only
when the specified external indicator has been set on prior
Columns 63 and 64 provide a means of mlnImlzmg the to processing of the object program. If the indicator is off,
number of field definition entries to be written. They also all input processing of the field is bypassed. External
provide a convenient means for selective control of process- indicators are more commonly used to condition entire files
ing. The specification of an indicator in these columns in the file description specifications. An external indicator
means that the field described on this line is used only when is specified in columns 63 and 64 to condition only a field of
that indicator is on. a file - whether or not the file is conditioned externally.

The following general rules apply to this entry: A halt indicator (H1 through H9) is used to relate a field to a
record in an OR relationship where the record has the same
• All fields without a field record relation should be halt indicator coded in columns 19 and 20.
specified before fields with field record relations.

96768710 A 8-13
FIELD INDICATORS • Field indicators are off at the beginning of program
execution and remain off until a field satisfies one of
Columns Values Meanings the conditions. At that time, the appropriate indicator
is turned on.
65-70 Blank Field examination not
required • A single numeric input field can be assigned one, two,
or three field indicators, and the indicators need not be
01-99 Field indicator unique from one another. When the record enters
processing, only the indicator appropriate to the field
H1-H9 Halt indicator contents is turned on; the others are turned off.
Columns 65 through 70 are used to specify-that the contents • If the same indicator is assigned to fields in different
of this field are to be examined when its record has been record types, the status of the indicator renects the
selected for processing. The data contained in the field can record being processed.
be examined for the following conditions:
• When different field indicators are assigned to fields in
• Plus (columns 65 and 66). The field must be numeric. different record types, a field indicator that goes on
The specified indicator is turned on if the contents of stays on until another record of that type is read; i.e., it
the input field are greater than zero. remains on throughout the processing of intervening
records.
• Minus (columns 67 and 68). The field must be numeric.
The specified indicator is turned on if the contents of • When a single field indicator is assigned to several
the input field are less than zero. fields in a record type, the status of the indicator
always reflects the contents of the field defined last in
• Zero or blank' (columns 69 and 70). The specified the specifications.
indicator is turned on if this numeric field contains
zeros or this alphanumeric field contains blanks. An all • The status of field indicators can be altered by SETON
blank numeric field will also cause the specified and SETOF calculation operations.
indicator to turn onj however, an alphanumeric field
containing zeros does not cause the indicator to go on. Halt indicators are typically used as field indicators when a
plus, minus, zero, or blank field is an error. Unless a halt
Field indicators are defined in the input specifiS!ations; indicator is set off during calculations, program execution is
indicators are used in calculation and output specifications. halted at the end of the current cycle. Recovery procedures
are outlined in appendix B.
The following facts about field indicators should influence
their proper usage.

8-14 96768710 A
CALCULATION SPECIFICATIONS - FORM C 9

y§.WJiij·PSW,§*WS_,,,bH' ( * AM.iSiitM,,,,M"';,MiWPP t', W54f±±W5

Calculation specifications tell RPG II which run-time


operations to perform. General rules for these specifica-
• Columns 7 through 17 control when the operation is to
be performed.
tions are as follows:

• Each operation is entered on a single line of the coding


• The kind of operation and the data for which the
operation is performed are defined in columns 18
form. Generally, operations are entered in the order through 53.
they are to be executed.

• Detail operations are specified first, followed by total • Columns 54 through 59 specify the tests to be
performed on the results of the calculation.
operations, and finally, lines of subroutines.
The Calculation Specifications sheet is shown in figure 9-1.
Each calculation specification line can be divided into three
parts.

CONTR.OL DATA RPG CALCULATION SPECIFICATIONS Prinled in U.S.A.

@2> CORrO~TlON
1 2 15 16 11 18 19 80
Program

Programmer Dale
Page [ J J o , _ :~;~'~cation I IIIIII

i---
e ~
~
Indicators Result Field
Resulting
Indicators
Arithmetic

~~
At At Factor 1 Operation Factor 2 l:
....
Plus IMinusl Zero
Compare
Comments
line > ..J Name Length :5- 1>211<211=2
.... "0
E~ ~ Lookup(Faclor 21is
~8 ~ ~ '0
z l: H,yh Low Equal
3 4 5 6 7 9 10 11 12 13 14 15 IG 11 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3S J6 37 38 39 40 41 42 43 44 45 46 47 48 49 60 61 53 54 55 50 57 58 59 60 61 62 63 64 65 66 61 68 69 70 71 72 73 7.

0 ) C
0 2 C
o 3 C
o 4 C 14"'+-+-+-+-~~CAI CULA TlONS TO BE PERFORMED ~-+-+-I-...j....-j~
o 5 C

o 6 C
~:...!--l~...w-l--W.....l-~I--l-i---+-+-I-+-I--l--+-+-+-l-I--++-l~-t-+-+-+-+-l-l-I-+-ll-+--H--+-+-+-+-l-I-+-IRESUL T .- ~--+-+--+-+-+-+-I-+--+--4--+-+++4
o 1 C INDICATORS
o a c
0 19 C

1 0 C i !
1 1 C ! I 1 I
I i
-! I
1 2 C i
I
1 3 C

1 4 C

1 5 C

1 6 C
1--1-1-
1 7 C

1 8 C

1 9 C

2 0 C

C
C

C
C

C
lL IL OL 69 89 L9 99 S9 >9 C9 19 19 09 6S as LS 9<; SS K CS lS IS OS 6. 80 LO 90 SO .0 Co lO 10 006C 8C LC 9C SC tC CC lC IC or. 6l 8Z LZ 9l Sl OZ Cl lZ IZ Ol 61 81 LI 91 SI 01 CI II II 01 6 8 L 9 S to C Z I

Figure 9-1. Calculation Specifications Sheet

96768710 A 9-1
CONTROL LEVEL When LR is set on by a SETON operation code, Ll through
L9 are not affected. (LR cannot be set off.) When LR is on,
Columns Values Meanings the job ends after all total operations have been performed.
7-8 Blank Calculation operation is not An SR in columns 7 and 8 identifies the line as part of a
part of subroutine and is subroutine. Subroutines can be entered from either a detail
performed at detail time. or a total calculation sequence. Individual operations within
the subroutine may be conditioned by any valid indicators,
LO-L9 Calculation operation is per- including LO through L9, in columns 9 through 17. Sub-
formed at total time when routine lines must be specified last on the calculation
this indicator is on (LO is sheet(s).
always on).
LR Calculation operation is per-
formed when the last record INDICATORS
has been processed or when
LR has been set on. Any entries in columns 9 through 17 specify the additional
conditions that must be met after those in columns 7 and 8
SR Calculation operation is part are satisfied. These conditions are specified in the form of
of a subroutine. indicators that must be on and/or off.
AN,OR Indicators listed on the Columns Values Meanings
current line are in an AND
or OR relationship with indi- 9-17 Blank Columns 7 and 8 list the
cators on the preceding only conditions. If 7 and 8
line(s). are blank, do the operation
for every record read.
Calculation specification lines are presented to the compiler
in the above order, with the exception that AN/OR lines are 01-99 Resulting indicators or
specified with their associated lines. More information is record identification indi-
given about AN/OR lines under Indicators. cators defined elsewhere in
the program
Calculation operations are performed at either deUlil time
or total time. Blanks in columns 7 and 8 indicate perform- LI-L9 Previously assigned control
ance at detail time. LO and control level indicators Ll level indicators
through L9 deSignate calculations to be performed at total
time. As described under Control Level, section 8, control LR Last record indicator
level indicators are set by control breaks. A change in the
control field at any level causes the indicator associated MR Matching record indicator
with that level and all lower control levels to turn on.
However, a lower level indicator is not turned on when: HI-H9 Previously assigned halt
indicators
• The higher level indicator is set by a SETON operation,
or UI-U8 Previously assigned external
indicators
• The higher level indicator is set on as a result of being
used as a record identifying indicator. OA-OG, Previously assigned overflow
OV indicators .
When a control level indicator is specified in columns 7 and
8, the operation is performed only when the indicator is on. Indicators are set or cleared according to input conditions or
When a control break occurs, all operations conditioned by pre~ious calculations. Up to three indicators may be
control level indicators are done before those that are not specified (one each in columns 10 and 11, 13 and 14, and 16
conditioned. and 17); if two or more are specified, they are considered to
be in an AND relationship. If the desired indicator state is
The LO indicator is always on and is used for calculations off, encode an N in the preceding column (column 9, 12, or
that are to be done at total ti me whether or not a control 15).
break has occurred.
Indicators are used in the following ways in columns 9
In one program cycle, all operations conditioned by control through 17:
level indicators in columns 7 and 8 are done at total time.
When control level indicators are specified in columns 9 • Use any record identifying indicator to condition an
through 17 of a line having blanks in columns 7 and 8, the operation that is to be done only for a certain type of
operation is performed at detail time immediately following record.
the control break.
• Use any previously defined field indicator to condition
The last record indicator, LR, is set on after the last input an operation that .is to be done only when a field has a
record has been read and processed. Control level indi- specified status.
cators Ll through L9 are also turned on at the same time.

9-2 96768710 A
o Use any resulting indicator specified in columns 54 through L9, LR, or SR in columns 7 and 8. Other lines of the
throug~ 59 of the Calculations Specifications sheet to group contain AN or OR in columns 7 and 8, as appropriate.
condition operations according to the results of previous The last line of an AN/OR group lists the operation,
operations. operand(s), and resulting indicator(s) to be used when all of
the conditions are met. The preceding lines should not
o When an input data error causes a halt indicator to go specify operations, operands, or resulting indicators.
on, program execution is not stopped until the end of
the cycle, after calculations have been performed. Halt The indicators on each individual line of the AN/OR group
indicators are commonly used in these columns to are in an AND relationship with one another. It is not
bypass operations on erroneous data. Conversely, halt necessary to have three indicators on each AN/OR line, but
indicators can be specified here to condition operations each line should contain at least one indicator.
to be performed only when an error occurs.
AN/OR lines give flexibility for cORditioning. If more than
o The matching record indicator is specified to condition three indicators must be on or off for a particular operation,
operations to be done only when matching records have AN lines allow a virtually unlimited number of indicators.
been found. OR lines allow -alternate conditions. When there are
combinations of AN and OR lines, AN has the higher binding
• An external incticator previously assigned on the File power.
Description Specifications' sheet is used to condition
operations to be done only when a certain input file is
available.
FACTOR 1 AND FACTOR 2
• The last record indicator is specified in these columns
only when LR is set on duri~ calculations to simulate Many RPG II calculation operations require the specification
end-of-file conditions. LR should be specified in of factors: factor 1 or factor 2 or both or neither,
columns 7 and 8 instead for operations to be performed depending upon the particular operation. Information about
at true end-of-file. the calculation operations and their factors can be found
under Operation, and a summary of the specification of
operation codes is contained in appendix D.
NOTE
Columns Values
When LR is used as a resulting indicator
(columns 54 through 59), NLR should be 18-27 Factor 1 and Factor 2 columns may
specified in columns 9 through 17 of the and contain the following entries:
same line in order to avoid, the clearing of 33-42
LR in the true end-of-file situation. • Field name
• Alphanumeric or numeric literal
• When a control level indicator is specified in columns 9 • Array element name, or name of
through 17 and columns 7 and 8 are blank, the operation table, array, or subroutine
is performed on only the first record of a new control • Date field name (UDATE, UMONTH,
group at detail calculations time. ' UDA Y, UYEAR)
• Previously assigned overflow indicators are used to • Special name (PAGE, PAGEl,
condition operations to be done when overflow occurs. PAGE2)

Points to remember when encoding columns 7 through 17 • Label for a TAG, BEGSR, or ENDSR
operation (Factor 1 column only).
are: Label for a GOTO or EXSR operation
(Factor 2 column only)
• When columns 7 and 8 contain a control level indicator
and columns 9 through 17 specify MR, the matching • Filename for a CHAIN, DEBUG,
record description applies to the last record processed - DSPLY, READ, SETLL, or FORCE
not the record causi~ the control break. MR will not operation (Factor 2 column only)
reflect the current record until all the total operations
specified for the control break have been performed. Entries are left-justified in the two fields.

• A control level indicator in columns 7 and 8 designates


a total calculation. A control level entry in columns 9
through 17 specifies a detail operation to be performed LITERALS
after the control break. The organization of the RPG II
program cycle causes total op.erations for a control Literals are self-defining data - either numeric or alpha-
break to be executed before detail operations are numeric.
performed on the record causing the control break.

Numeric
AN/OR LINES
A numeric literal is a combination of digits (0 through 9), an
Up to three indicators may be specified on each AN/OR line. (optional) decimal point, and an (optional) arithmetic sign
The first line of an AN/OR group contains blanks, LO

96768710 A 9-3'
(example: -12.3). Numeric literals must have the following SPECIAL NAMES
characteristics:
The special names are the three page counter names, PAGE,
• Not exceed 10 positions PAGEl, and PAGE2, discussed under Field Name in
section 8. The page counters can be incremented explicitly
• Not contain embedded blanks in the calculation specifications or implicitly in the output
specifications.
• Be left-justified
• Have the sign, if encoded, in the leftmost column (18 or
33)i if unsigned, the literal is assumed to be positive LABELS
• Not be enclosed in apostrophes Rules for establishing Factor 1 labels (used with TAG,
BEGSR, and ENDSR) and Factor 2 labels (used with GOTO
The decimal point, if encoded, may appear anywhere in the and EXSR) are discussed with those operations.
literal. When a decimal point is not encoded, it is assumed
to follow the rightmost digit (i.e., the literal is integer).
FILENAMES
Alphanumeric Any valid RPG n filename can be used as Factor 2 for
CHAIN, DEBUG, DSPLY, READ, SETLL, and FORCE opera-
An alphanumeric literal is a combination of any alpha- tion codes, subject to the specific requirements of each
numeric characters enclosed in apostrophes (exam- operation.
ples: 'DON' 'T', '-12.3'). Alphanumeric literals must adhere
to the following rules:
• The literal must not exceed eight characters plus two OPERATION
apostrophes.
Columns Values
• The literal may contain any alphanumeric characters,
including blanks. 28-32 Operation code listed in table 9-1
• The literal must be left-justified. The operation code is the mnemonic for the operation to be
performed with Factor 1, Factor 2, and the Result Field.
• An apostrophe within the literal is encoded by entering Operation codes are left-justified.
two consecutive apostrophes.
Generally, operations are performed in the order specified in
the calculation sheets. All operations conditioned by control
level indicators in columns 7 and 8 must follow those that
NAMES AND ELEMENTS are not conditioned by control level indicators. All
operations that are part of a subroutine (SR in columns 7 and
Table and array names were described briefly in section 6 8) must be listed after all other calculations in a program,
and are discussed more fully in section 12. A subroutine
name, a table or array name, or an array element name
must:
ARITHMETIC OPERATIONS
• Be,'left-justified
The fields and literals used in arithmetic operations must be
. ' Start with an alphabetic character numeric. Factor 1, Factor 2, and the Result Field may all
be the same field or three different fields or any combina-
• Not exceed six characters tion thereof. None of the fields specified as Factor 1,
Factor 2, or Result Field may exceed 15 digits. Decimal
• Not be the same as any field name points are aligned by RPG n before the operation is
performed. If the result exceeds 15 characters, characters
• Not include special characters or embedded blanks may be dropped from either or both ends, depending upon
the location of the decimal point. The results of all
arithmetic operations are signed. Any data placed in the
Result Field replaces any data that was previously there,
DATE FIELD NAMES and the previous contents are lost. Factor 1 and 2 fields are
not altered by the operations unless one or both of the
The date field names (UDATE, UMONTH, UDAY, and names are the same as the Result Field name.
UYEAR) refer to the current date that the host computer
supplies to the object program. These values cannot be The arithmetic operation codes and their factors are shown
changed by calculation operations, so they must not be in table 9-2.
specified as Result Fields. They may be used as Factor 1
and Factor 2, for example, if one wants to calculate the For the operations ADD, Z-ADD, Z-SUB, MULT, DIY, and
next month's billing date based upon the current date. SQRT, whole arrays may be specified in the factor and

9-4 96768710 A
TABLE 9-1. OPERATIONS FOR CALCULATION TABLE 9-2. ARITHMETIC OPERATION CODES
SPECIFICATIONS AND FACTORS

Class Code Operation Factor 1 Operation Factor 2 Result Field


Arithmetic ADD Add Required ADD Required
Z-ADD Zero and add Required
SUB Subtract Blanks Z-ADD Required Required
Z-SUB Zero and subtract Required SUB Required
Multiply Required
MULT
DIV Divide Blanks Z-SUB Required Required
MVR Move remainder Required MULT Required
Square root Required
SQRT
XFOOT Crossfoot - sum elements Required DIV Required Required
of array Blanks MVR Blanks Required
Move MOVE Move Blanks SQRT Required Required
MOVEL Move left Blanks XFOOT Required
Move array Required
MOVEA

Move zone MHHZO Move high to high zone


MHLZO Move high to low zone
MLLZO Move low to low zone result fields. In this case, corresponding elements are used
MLHZO Move low to high zone to effect element-by-element operations (i.e., element 1
from the factor arrays is operated on to produce element 1
Compare and COMP Compare of the result array. This is followed by the use of element 2,
testing TESTZ Test zone etc.).

Bit BITON Set bit on


BITOF Set bit off
TESTB Test bit Add (ADD)

Setting SETON Set indicator on Factor 2 is added to Factor 1. The sum is placed in the
indicators SETOF Set indicator off Result Field.

Branching GOTO Go to
TAG Provide a branching
label Zero and Add (A-ADD)
Lookup LOKUP Table or ·array lookup . Factor 2 is added to a field of zeros, and the sum is placed
in the Result Field.
Subroutine BEGSR Begin an RPG n subroutine
ENDSR End an RPG n subroutine
EXSR Execute an RPG n sub-
routine Subtract (SUB)
EXIT Exit to external subroutine
RLABL Define label for external Factor 2 is subtracted from Factor 1. The difference is
subroutine placed in the Result Field.

Input/Output EXCPT Force output record


FORCE Force record to be read NOTE
DSPLY Print and/or accept data at
console device When Factor 1 and Factor 2 have the
READ Read from demand file same name, the Result Field is effectively
CHAIN Retrieve defined record set to zero.
SETLL Set lower limits

Debug DEBUG Aid in finding programming


errors Zero and Subtract (Z-SUB)
Time TIME Get time-of-day Factor 2 is subtracted from a field of zeros, and the
difference is placed in the Result Field. This operation can
be used to change the sign of a field, when F.actor 2 and
Result Field have the same name.

96768710 A 9-5
Multiply (MU L T) A whole array can be used in a SQRT operation if both
Factor 2 and the Result Field have array names. In this
Factor 1 is multiplied by Factor 2. The product is placed in case the square root of every element in the Factor 2 array
the Result Field. Be sure the specified Result Field is large is caiculated, and the results are stored in the corresponding
enough to hold the product. element positions of the Result Field array.
The following statements apply to the SQRT operation:
Divide (DIV) • The root is automatically half-adjusted in the Result
Field.
Factor 1 (dividend) is divided by Factor 2 (divisor). The
quotient is placed in the Result Field. • The length of the Result Field must be greater than or
equal to the decimal positions entry for the field.
If Factor 1 contains zero, the quotient is zero. Factor 2
cannot contain zero. If it does, program execution halts • Factor 2 cannot contain a negative number. If it does,
program execution is halted immediately; recovery is
immediately. If the operator elects to continue elCecutio~, outlined in appendix B.
the quotient and remainder are set to zero, as shown In
appendix B. • Resulting indicators are not allowed on the SQRT
specifications line.
Any remainder resulting from a divide operation is lost
.unless the next operation code is MVR. If the next operation
is Move Remainder, half adjust (round) should not be
specified for the divide operation. Crossfoot (XFOOT)
This operation is used with arrays having numeric elements.
Move Remainder (MVR) The elements of the array named as Factor 2 are added
together, and the sum is placed in the single-element Result
Field. If the Result Field name is an element of the
This operation moves the remainder from the immediately Factor 2 array, the sum reflects the value of the element
preceding divide operation to Result Field. Move Remainder before storing of the result took place.
should not be used following a divide operation for arrays. A
Move Remainder operation should be conditioned ,by the Half adjust and resulting indicators can be specified with the
same indicators, if any, that conditioned the divide opera- XFOOT operation code.
tion. Half adjust cannot be specified for the Move
Remainder operation. The maximum length of the remain-
der is 15 digits, including decimal positions. The number of
significant decimal positions in the remainder is the greater MOVE OPERATIONS
of:
Move operations move part or all of the data in the Factor 2
• The number of decimal positions in Factor 1 of the field to the Result Field. The contents of Factor 2 are not
preceding divide operation changed. Move operations must not have Factor 1 specifica-
tions, and there must be no resulting indicators.
• The sum of the decimal positions in Factor 2 and Result
Field of the preceding divide operation The form of the data may be changed from alphanumeric to
numeric and vice versa. This is accomplished by moving an
The maximum number of whole number positions the alphanumeric field to a numeric field or a numeric field to
remainder has is equal to the whole number positions in an alphanumeric field. When an alphanumeric field is moved
Factor 2 of the preceding divide operation. to a numeric field, blanks are converted to zeros. Zeros are
not converted to blanks when a numeric field is moved to an
alphanumeric field, however.
Square Root (SQRT) Decimal positions are ignored when numeric fields are
moved. Thus, if the numeric data 1.23 is moved to a field
The square root of the contents of Factor 2 is placed under having one decimal position, the result is 12.3.
Result Field.
As with other arithmetic operations, Factor 2 and the Result
Field are numeric fields that can be up to 15 digits long, and Move (MOVE)
each field can have up to nine decimal positions. The
correspondence between Factor 2 and Result Field lengths is Characters of the data field or literal specified in Factor 2,
as follows: starting with the rightmost character, are moved to the
rightmost positions of the Result Field.
• For every digit left of the decimal place in the Result
Field, there should be two digits left of the decimal If the Result Field length is shorter than the length of the
place in Factor 2. Factor 2 field the excess leftmost characters of the
Factor 2 field ~r liter8J. are not moved. If the Result Field
• For every digit to the right of the decimal place in the is longer than the Factor 2 field, all available characters are
Result Field, there should be two digits right of the moved, and excess characters of the Result Field are not
decimal place in Factor 2.

9-6 96768710 A
changed. A numeric Result Field assumes the sign Factor 2 and Result Field Same Length
associated with Factor 2. Factor 2 Result Field
+
When data is moved into an indexed array, data is moved
Numeric
~ Before MOVEL
~ Numeric
(2 decimal (I decimal
into only one element of the array. This is true even if the positions) ,0,0,1*2,3 ! After MOVEL ,0,0, I ,2;,.j I position)
field being moved is larger than the array element.
Numeric Before MOVEL Z 0 WIE Alphanumeric
(2 decimal
Move Left (MOVEL) positions) After MOVEL

This operation is similar to MOVE, except that characters A Iphanumer ic ~ Before MOVEL Numeric
are moved from the leftmost position of the Factor 2 data (I decimal
field to the leftmost character position(s) of the Result ~ After MOVEL position)
Field.
If a numeric Result Field is the same length as the Factor 2 Alphanumeric ~ Before MOVEL ,l,O,W",E, Alphanumeric
field, it assumes the sign associated with Factor 2. If a
numeric Result Field is longer than Factor 2, the Factor 2 ~ After MOVEL
sign is lost, and the excess rightmost Result Field characters
remain intact, including the sign position. When the Result
Field is shorter than Factor 2, the sign of the Factor 2 field Factor 2 Longer Than Result Field
becomes the sign of the Result Field.
Factor 2 Hesult Field
Examples of the MOVEL operation are shown in figure 9-2.
+
Numeric ,0,0,0,0,0*1 12, Before MOVEL 4 1S,6,7 8, Numeric
A
(2 decimal (I decimal
position ,0,0 10,0,0*1 12, After MOVEL ,0,0,0,0*° 1 position)
Move Array (MOVEA)
With MOVEA, characters of Factor 2, starting with the Before MOVEL ~ Alphanumeric
leftmost character, are moved to the leftmost positions of (2 decimal
the Result Field. positions) ~.1 After MOVEL

Arrays and fields specified with MOVEA must be alpha- +


Alphonumeric J'~IWIO,M,E,NI Before MOVEL .!iilifu?~ Numeric
numeric, and Factor 2 and the Result Field must not
(I decimal
reference the same array.
,3,~,WIOIMIE,N, After MOVEL ,3,OI6,6}j 1 positions)

The number of characters moved is equal to the length of


the shorter field (Factor 2 or the Result Field). If the Alphanumeric 131~,W,O,M,E,N Before MOVEL A Iphanumer ic
Factor 2 field is longer than the Result Field, the excess
rightmost characters· of Factor 2 are not moved; when ,31~,W,O,M,E,N, After MOVEL
Factor 2 is shorter than the Result Field, the rightmost
characters of the Result Field are unchanged. Factor 2 Shorter Than Result Field
Factor 2 Result Field
MOVEA makes possible the following field movements:
+
Numeric Before MOVEL ~!I,5&J~ Numeric
• Several contiguous array elements can be moved to a
(2 decimal
single field.
positions) After MOVEL

• A single field can be moved into contiguous elements of


an array. Numeric
~ Before MOVEL O,~,Z,OIW,I,E, Alphanumeric
(2 decimal
• Contiguous elements of one array can be moved into
contiguous elements of a second array.
postions)
~ After MOVEL ,Q,Q,12 ,LIE

+
A Iphanumer ic 13,~,M,E,N, Before MOVEL ,2 ,3,4,5,6 ,7,1;8, Numeric
Character movement starts with the· first character of a
field or unindexed array. When an array is indexed, (I decimal
+
movement starts with the first character of the referenced ~ After MOVEL ,110,41515,7;,.8, post ion)
array element. Character movement continues until:
A Iphanumer ic ,3,IS,M ,E,N, After MOVEL ~~WJg, Alphanumeric
• The last array element has been moved or filled, or
11,~,M,E,N, After MOVEL
• The last character of the field specified as Factor 2 or
the Result Field has been moved or filled (this situation
can result in the partial movement or filling of an array
element). Figure 9-2. Examples of MOVEL Operations

96768710 A 9-7
MOVE ZONE OPERATIONS Move-High-to-Low Zone (MHLZO)
The four "move zone operations are used to move only the The zone of the leftmost character of the Factor 2 field is
zone portion of a character. Using a minus sign moved to the rightmost zone position of the Result Field.
character (-) in a move zone, operation does not result in a The Factor 2 field must be alphanumeric, but the Result
negative Result Field: the minus sign has an internal Field may be either alphanumeric or numeric.
representation of X'60', while an X'D' zone designates a
negative character. Moving one of the characters J through
R, however, can produce a negative Result Field, as these
characters have hexadecimal representations of X'Dl' Move-Low-to-Low Zone (MLLZO)
through X'D9'.
The zone of the rightmost character of the Factor 2 field is
The four move zone operations are listed below and in moved to the leftmost zone position of the Result Field.
table 9-3. In general, the word high involves alphanumeric The Factor 2 field and the Result Field may be either
fields only, while the word low can be used with alphanumeric or numeric.
alphanumeric and numeric fields. •

Move-Low-to-High Zone (MLHAO)


Move-High-to-Hlgtl Zone (MHHZO)
The zone of the rightmost character of the Factor 2 field is
, The zone of the leftmost character of the Factor 2 field is mov~d to the leftmost zone position of the Result Field.
moved to the leftmost zone pOSition of the Result Field. The Factor 2 field may be either alphanumeric or numeric,
Both fields must be alphanumeric. but the Result Field must be alphanumeric.
TABLE 9-3. MOVE ZONE OPERATIONS
COMPARE AND TESTING OPERATIONS
Allowable
Operation Field Function The compare (COMP) and test zone (TESTZ) operations test
Formats fields for certain conditions. The results of the tests are
shown in resulting indicatdrs; contents of the specified fields
MLLZO are not changed by the operations.
Factor 2 Alphanumeric
Result Field Alphanumeric
Compare (COMP)
Factor 2 Alphanumeric
Result Field Numeric Zone of rightmost byte The operation COMP compares the literal or the contents of
of factor 2 is moved to the field in Factor 1 against the literal or contents of the
Factor 2 Numeric zon~ of rightmost byte field in Factor 2. The Factor 1 and Factor 2 fields must
Result Field Alphanumeric of result field. have identical formats: both numeric or both alphanumeric.
An entire array cannot be specified as either factor. The
Factor 2 Numeric Result Field must be left blank.
Result Field Numeric
At least one resulting indicator (columns 54 through 59)
MHLZO must be specified. Depending upon the results of the
comparison, the appropriate indicator is 'turned on as
Factor 2 Alphanumeric Zone of leftmost byte follows:
Result Field Numeric of factor 2 is moved to
High - Factor 1 is greater than Factor 2.
Factor 2 Alphanumeric zone of rightmost byte
Result Field Alphanumeric of result field. Low - Factor 1 is less than Factor 2.
Equal - Factor 1 equals Factor 2.
MLHZO
A single indicator may be specified in two resulting
Factor 2 Alphanumeric Zone of rightmost byte indicator positions but should not be specified in all three
Result Field Alphanumeric of factor 2 is moved to resulting indicator positions.
zone of leftmost byte
Factor 2 Numeric of result field. Fields and literals are automatically aligned by RPG II
Result Field Alphanumeric before the comparison. Alphanumeric fields are aligned to
their leftmost characters, and numeric fields are aligned by
MHHZO decimal points.
Factor 2 Alphanumeric Zone of leftmost byte of The maximum length of numeric fields is 15 digits. When
Result Field Alphanumeric factor 2 is moved to zone one field is shorter than the other, the shorter field is
of leftmost byte of result padded with zeros until the lengths are equal.
fie~d.

9-8 96768710 A
The maximum length of alphanumeric fields is 256 All data fields are initialized by RPG II at the beginning of a
characters. When one field is shorter than the other, the job:
shorter field is padded with blanks on the right until the
lengths are equal. • Alphanumeric fields are initialized to blanks.
When an alternate collating sequence is supplied, 'the • Numeric fields are initialized to zeros with a positive
alphanumeric comparison is based upon that; otherwise, the sign.
alphanumeric comparison is according to the collating
sequence shown in appendix D. If a field must be initialized to binary zero (hexa-
decimal X'OO') for bit operations, the initialization must be
specified in the RPG II source program.
Test Zone (TESTZ)

This operation tests the zone of the leftmost character in Set Bit On (BI TON)
the Result Field. The Result Field must be alphanumeric.
The resulting indicators (columns 54 through 59) are set The BITON operation causes bits specified in Factor 2 to be
according to the following characters appearing in the set equal to one in the corresponding Result Field bit
leftmost position of the Result Field column: positions. That is, the inclusive OR of Factor 2 and the
Result Field are placed into the Result Field.
High - & (ampersand) or A through I
I Low - (bracket), - (minus sign), or J through R
Equal - Any other character Set Bit Off (BITOF)

Factor 1 and Factor 2 should be left blank for this operation. The BITOF operation causes bits specified in Factor 2 to be
cleared to zero in the corresponding Result Field bit
An alternate collating sequence does not apply to the TESTZ positions. The Result Field is 1\ NDed with the complement
operation. of Factor 2. .

BIT OPERATIONS Test Bit (TESTB)

The bit operations allow users to set (BITON), clear (BITOF), Bits specified in Factor 2 of a TESTS operation cause
and test (TESTB) bits that can be used for conditioning corresponding bit positions in the Result Field specification
opera tions. to be tested for an on or off condition and resulting
indicators to be set accordingly. (The Result Field is ANDed
The Result Field specification must be a one-character with Factor 2.)
alphanumeric field or element in a table or array~
At least one indicator must be specified in the resulting
The Factor 2 specification can have two formats: indicators field. A user may specify up to three, but a single
indicator may not be specified in more than two positions.
• Bit numbers (0 through 7) can be specified. The Resulting indicators are set according to the following
numbers specify which bits are to be set on, set off, or conditions:
tested. Up to eight bits can be specified in any order.
Bits of the one-character Result Field are numbered 0 • Columns 54-55 - An indicator specified in these
through 7 from left to right. Bits specified in Factor 2 columns is set if each Result Field bit specified by the
are enclosed in apostrophes. When Factor 2 has a value Factor 2 entry is off, with the exception of the anomaly
of 0, the leftmost bit of the Result Field is to be set or listed with columns 58 and 59.
tested. An entry of 7456 causes bits 4 through 7 (the
rightmost four bits) to be set or tested. • Columns 56-57 - An indicator specified in these
columns is set if the Result Field bits specified by the
• Factor 2 can also be a one-character field or element in Factor 2 entry are in a mixed condition (some on, some
an array or table. In this case, the contents of the off) .. If the Factor 2 entry causes only one bit to be
Factor 2 specification (that is, those bits that are equal tested, an indicator specified here is never set by the
to one) indicate the bits to be set or tested. TESTS operation.

No matter which format is used for Factor 2, unspeciOed bit • Columns 58-59 - An indicator specified in these
positions cause the corresponding Result Field bits to be columns is set if each Result Field bit specified by the
ignored. Factor 2 entry is on.

Bit operations can be conditioned by entries in columns 7


through 17. If Field Length is specified, the value must be NOTE
one. Factor I, Decimal Positions, and Half Adjust columns
must be blank for bit operations. Resulting Indicators If Factor 2 is a field that is all zeros,
(columns 54 through 59) are blank for BITON and BITOF, but the indicator in columns 58 and 59 is
must have at least one entry for TESTB operations. turned on.

96768710 C 9-9
SETTING INDICATORS • Some operations should be performed for some, but not
all, record types.
RPG II provides two operation codes that are used to turn
indicators on or off. Both may be conditioned by entries in
columns 7 through 17.
Go To (GOTO)
Here are some points to remember when using SETON and
SETOF: If the conditions specified in columns 7 through 17 are met,
control is transferred to the point in the program specified
• The following indicators may not be turned on by a by the name in Factor 2. (See Tag section below.) Both
SETON operation: 1P, MR, LO, and U1 through U8. forward and backward referencing is allowed. Be careful
when transferring into a subroutine (SR in columns 7 and 8)
• The following indicators may not be turned off by a that a transfer is made out of the subroutine before the
SETOF operation: 1P, MR, LR, LO, and U1 through U8. ENDSR operation is encountered, since there is no progr'am
point available for the return.
• When LR is set on by a SETON operation conditioned by
a control level indicator (columns 7 and 8), processing When transferring from Detail calculation (blanks in
stops after all total output operations are completed. If columns 7 and 8) to Total calculation (LO through L9 in
'.he SETON is not conditioned by a control level columns 7 and 8), the RPG loop is altered. This may cause
indicator, processing stops after the next total output considerable confusion but may also be used to good
sequence is completed. advantage when used properly.

• If one or more halt indicators (HI through H9) are When conditions are not specified in columns 7 through 17
turned on and not turned off before detail output for the GOTO operation, the transfer always occurs.
operations are completed, processing stops at that time.
Recovery from this type of halt is outlined in Factor 1 and Result Field must be blank for a GOTO
appendix B. operation.

• Using SETON to set on a control level indicator (L1


through L9) does not automatically cause lower level
indicators to go on. Tag (TAG)

• Indicators L1 through L9 and the record identifying The TAG operation defines names to which a GOTO
indicators are always turned off after detail output operation may transfer control. The name goes in Factor 1
time, regardless of the manner in which these indicators and may be one to six chluacters long. The first character
went on. must be alphabetic and placed in column 18. No special
characters or embedded blanks may be used. The same label
• Whenever a new record enters processing, the reco['d may not be used for more than one TAG operation code, but
identifying indicators and field indicators are set to more than one GOTO is allowed to transfer control to a
reflect conditions on the new record. Previous settings single TAG.
of the indicators are lost.
Columns 9 through 17 must be blank for a TAG operation
code, but a control level indicator can be specified in
columns 7 and 8 to signal that the branches will occur at
Set On (SETON) total time.

This operation turns on the indicator(s) specified in


columns 54 and 55, 56 and 57, and 58 and 59.
LOOKUP OPERATIONS

RPG II provides a table lookup operation, encoded LOKUP,


Set Off (SETOF) to be used for searching through a table or an array to find a
specific element.
This operation turns off the indicator(s) specified in
columns 54 and 55, 56 and 57, and 58 and 59.

Lookup (LOKU P)

BRANCHING OPERATIONS This operation code causes a search for a particular table or
array element to be executed. Factor 1 specifies the search
Calculation operations are ordinarily performed in the order argument (data for which a match is to be found in the table
in which they are entered on specifications lines. Opera- or array), and Factor 2 specifies the name of the internally
tions listed in this section, however, can alter this sequence stored argument table or array to be searched. RPG II
for the following sample reasons: begins all table searches with the first element and stops
searching when conditions have been satisfied. Array
• Some operations should be skipped as a result of certain searches begin with the index specified in Factor 2; if none
conditions. is given, the search begins with the first element. At least
one indicator, but not three, must be designated in
• Operations defined on preceding specifications lines columns 54 through 59 to specify the type of search.
should be repeated as a result of certain conditions.

9-10 96768710 A
The search argument (Factor 1) may be: When a table name is specified as the search argument in
Factor 1 of a LOKUP operation, RPG II uses the current
• An alphanumeric or numeric constant value in the holding area as the search argument.
• A field name When a table name which has been Factor 2 in a successful
search is specified as the Result Field of a later calculation
• A table name operation, the holding area and the corresponding table
element receive the result of the operation. Object
• An array element name programs can alter table elements in this manner.
As described below, when a table is named as Factor 1, the
table element last selected by a LO.KUP operation is the
search argument. Factor 1 and Factor 2 must have equal LOKUP with Two Tables
lengths and be of the same type (numeric or alphanumeric),
but decimal positions of the two items .are ignored. Related tables can be specified as Factor 2 and the Result
Field of a LOKUP operation. -In this type of operation,
The type of search is specified by entries in the resulting Factor 1 designates the search argument, and Factor 2
indicators field (columns 54 through 59). Before the search, specifies the table that is actually searched. When a search
indicators specified there are turned off. Indicators are is successful, two items are moved to holding areas: the
turned on only when the conditions are met. Possible Factor 2 item' resulting from the search and the corres-
conditions are: ponding item from the related table. Both holding area
values remain available according to the rules outlined for a
High (columns 54 and 55) - The search is terminated and single-table search. When the related tables do not contain
this indicator turned on when the smallest (and first) the same number of entries, the shorter number of elements
entry greater than Factor 1 is found. determines the maximum number of· items searched.
Trailing elements in the longer table are ignored.
Low (columns 56 and 57) - The search is terminated and
.this indicator turned on when the largest (and last)
entry less than Factor 1 is found.
LOKUP with Arrays
Equal (columns 58 and 59) - The search is terminated and
this indicator turned on when the first entry equal to When a LOKUP operation is performed with an array named
Factor 1 is found. ' as Factor 2, the Result Field must be blank. Searching an
array is similar to searching a table except that RPG II does
Combin~~ions of High and Equal and Low and Equal may be not move an array element to a holding area if the search is
specified wi~h Equal given precedence. That is, if an Equal successful. However, RPG II does set appropriate resulting
cannot be found, the nearest higher or nearest lower entry is indicators after a successful array search.
selected. High and Low may not be specified
simultaneously. When Factor 2 is an unindexed array, the search begins at
the first element of the array.
Algebraic comparisons are made for numeric quantities.
Alphanumeric quantities are compared according to the When Factor 2 is an array name and index, the search begins
collating sequence specified in appendix D. An alternate with the element specified by the index. The Factor 2
collating sequence does not apply to LOKUP. format in this case is
Tables and arrays to be searched by LOKUP must have an [ array name], [ index]
entry in column 45 (Sequence) of form E unless the search is
for an equal condition only. where index can be a numeric field name or a numeric
literal (with no decimal positions).
LOKUP operations may be conditioned· by entries in
columns 7 through 17. When index is a field name, a successful search causes
RPG II to place the element number in the field designated
as index. The array element can then be referenced in later
calculation and output operations, using the array and index
LOKUP with One Table names.
If a single-table search is successful, RPG II retrieves the When index is a field name and the search is unsuccessful,
table value and stores it in a holding area set aside RPG II places a 1 in the index field unless the low indicator
specifically for that table. Previous contents of the holding and a starting index greater than 1 are specified. In this
area (results of previous LOKUP operations) are destroyed. case, the starting index is decremented by 1.
If the search is unsuccessful, the contents of the holding
area are not altered. When index is a literal, only the indicators tell if the search
conditions are satisfied. That is, RPG II does not change the
References to a table name in later non-LOKUP operations value of the literal or otherwise identify the array element
actually refer to the table item in the holding area. Thus, satisfying the search.
later operations should be conditioned by the indicator that
signals a successful search. If a literal or field index is zero or greater than the number
of elements in the array, the following results.

96768710 A 9-11
• With a literal index, the compiler detects the error and added to the related table element of TABCUR. When the
causes compilation to cease. value at ACTNO does not match any element of TABACN,
indicator 11 is used to condition a branch to a TAG named
• With a field index, the' error is not detected until run- NOMTCH.
time, and program execution is halted. If execution is
continued (according to appendix B), the field index is At lines 110 through 140, there is a LOKUP of an array
given a value of one. named ARRAY in which the purpose of the search is to find
the array element that is nearest to but higher in value than
the data item stored at ARG. A successful search causes
indicator 20 to turn on and a branch to the TAG named
Examples of LOKUP operations NEXT to be taken. (Action taken for an unsuccessful search
is not shown in the example.) Notice that this LOKUP
LOKUP operations with tables and arrays are illustrated in indicates the presence or absence of the specified element
figure 9-3. At lines 010 through 040, a value stored at in the array but does not show the element's location in the
ACTNO is used to search the table TABACN, which has a array or make the element available for future calculations.
related table, TABCUR. When the value at ACTNO matches
an element of TABACN, the data item found at CHRGE is Lines 210 through 250 show approximately the same LOKUP
operation indicator 20 is turned on when the first

CONT1\.OL DATA RPG CALCULATION SPECIFICATIONS Printed in U.S.A.

CORrQR('T10N
1 2 75 76 77 78 79 80
Program

Programmer Date
page~OI_ ~;~:~f:'lion I IIIIII
R.. ulling
C ~
Indicators Result Field
Indicators

~
l
Arithmetic
"----:
!
Jd Factor 1 Operation Feetor 2 %
~
Plus IMioual Zero Comments

...E ...;;:: i
!l Compare
line
,. Name length
t>21t<21'-2
~ lookuplFaclor 2115
~8 I :I J ! High l _ Equal
3 4 5 6 1 • 10 II 12 13 14 15 16 17 I. 19 20 21 22 23 24 25 211 27 28 29 JO 31 31 33 34 3!1 36 31 38 39 40 41 42 43 .4 45 46 47 48 49 50 &1 53 54 55 56 &1 58 59 ~ 61 62 63 64 65 titi 6/ 68 tiy 70 71 n
-
73 74
o 1 oe
'" '"IU
I-
lia I<U PT A6 IA~W I.,. A Be ulA ~j. P.o A~ TA 17le viE: ~u APt NI1
o 2 ~e~ 8~ ~A N~
,-
o 3 ~C tJ (,;~ .,'r/J Ill!. '0A Ell. A~IR
o 4 itooe iI.- I.. 1.IIlfll~ AJ)~ 1111 ~~ ~IA ~A 1~1l! lilA uP ~"Ir 81~ W~~ L-"
o 5 ,,"e <;
o 6 Ie e I( I

o 7 re C
o 8 oe
o 9 ce AIA~ ILa KU lilA AA AY tc?l.l
I

t 0

1 1
:C e
~e~
1111,. ~Ia rr~ IN l: ,,11'
I , I
IBIA lAW CH "HlEN
Hr ~It Ell. IEL Ern ~~T
1 2 I,.. eli ! Flcz u~::z:
1 3 ~e

1 4 be I)
1 5 Ire 1\
1 6 ,e }
7 ,.e
1
~- AT> ~11 X. --f- fie.
8 ,-,e
ILIGI KL Ill~ ~p. AY
I
1
AIAA X 211'
1 9 Ce
INI~c IGla 7~ 1,:12:1",
2 0 "e 1~la vie RA ~IAY 1)1 IlIla Lit> l5~
121 ~e IAIIl 1~11 ITIA c
rzl2 I,. e i
12~ I,. e
ti-~
~ I
1.'I1':l Ie e -- D +. -.
Ic/S /e e .1\
lL It Ot 69 89 L9 99 S9 t9 [9 Z9 19 09 6S ~ L9 9<; SS .... [9 ZS IS O'i 6> 8> Lt 9> S. . . [> Z> I> 0> 6t 8t L[ 9£ S[ t[ [[ Z[ I[ or. 6Z 8Z LZ 9Z SZ >z [Z ZZ IZ OZ 61 81 1I 91 SI >1 [I ZI "01 6 8 L 9 S > [ Z I

Figure 9-3. Examples of LOKUP Operations

9-12 96768710 A
element higher in value than ARG is found. In this case, operation lines, and the subroutines may be specified in any
however, ARRAY is searched one element at a time, and an order at the end of Calculation Specifications. A subroutine
element satisfying the search is available through an index may not be contained within another subroutine; that is,
field named X. The index field is initialized to one (to point each pair of BEGSR and ENDSR lines must be coded without
to the first element of the array) at line 210. If the desired intervening BEGSR/ENDSR lines. One subroutine may call
element is found, X contains the index value of the element, another subroutine, however.
and at line 240 the value of the element itself is moved to a
location named HOLD for future reference. If the desired In other words, a subroutine may contain an EXSR
element is not found, X contains the value 1 at the statement. A subroutine may call itself or may call a
conclusion of the LOKUP, and a branch to FIN is taken. subroutine that calls it.
In any of the examples shown in figure 9-3, the search A subroutine may contain a GOTO operation code, which
argument specified as Factor 1 in a LOKUP operation could branches either to a point within the subroutine or to any
have been a literal, rather than a constant, value. other point in the program. Program flow should make
sense - the program should not be allowed to flow into an
ENDSR operation if a corresponding EXSR has not been
performed for the same subroutine.
SUBROUTINE OPERATIONS
A subroutine is a routine that is part of a main routine. A
routine is a series of program steps that is executed over Begin Subroutine (BEGSR)
and over. An RPG II program is a main routine because the
instructions are done over and over again (the program The BEGSR operation defines the entry point of an RPG II
cycle). A subroutine is a series of instructions that may be subroutine and is the first physical statement of the
performed several times within a single program cycle. subroutine. The left-justified name of the subroutine is
defined in Factor 1. Columns 7 and 8 must contain SRi all
The purpose of a subroutine is to save lines of coding and the other columns, except 60 through 74 (Comments), must be
core memory space required for the object program. Instead blank.
of coding the same sequence of steps every time they are
needed, the user will only need to code the group of steps Every subroutine must have a unique name. The name may
once and can then refer to the group at every point in the have one to six alphabetic or numeric characters, the first
program where it is needed. When the subroutine is of which must be alphabetic. Embedded blanks are not
contained in the main program, the series of steps is called allowed in the name.
an internal subroutine.
It may be that several main programs can use the same
subroutine. Here again, the subroutine need be coded only End Subroutine (ENDSR)
once. References to the subroutine from programs that do
not contain the subroutine are references to an external An ENDSR operation is the last physical statement of an
subroutine. RPG II subroutine and causes an automatic branch back to
the calling program. The Factor 1 field may contain a name
All subroutine operation codes are written in specification referenced by GOTO operations within the subroutine.
lines following all detail and total calculation lines. Lines of Columns 7 and 8 must contain SR.
a subroutine (except AN or OR lines) are identified by SR in
columns 7 and 8.
The first line of the subroutine must have a BEGSR Execute Internal Subroutine (EXSR)
operation code, and the last line must have an ENDSR
operation code. The EXSR operation causes a transfer of control to an
internal subroutine written in the RPG II language as a part
Even though the subroutine is entered last on Calculation of the same program. EXSR may appear anywhere in the
Specifications, performance of the subroutine may occur at program. After the subroutine has been performed, control
any point in the calculations portion of the program cycle. returns to the next specification following the EXSR
operation.
All valfd RPG II operations may be performed within the
subroutine. Operations within the subroutine may be The name of the subroutine is left-justified in Factor 2.
conditioned by any valid indicators in columns 9 through 17. This name must be identical to the Factor 1 specification
Individual operations within a subroutine cannot be condi- for a BEGSR operation code.
tioned by control level indicators in columns 7 and 8, since
those columns contain SR. However, execution of an entire The EXSR operation code may be conditioned by any
subroutine can be conditioned by control level indicators in indicators; this means that the subroutine is executed only if
columns 7 and 8 of the referencing EXSR operation code. all the conditions are met.
Fields used in a subroutine may be defined either inside or
outside the subroutine. In either case, a field may be used
by both the main routine and the subroutine, and the name Exit-to-External Subroutine (EXIT or EXITF>
and characteristics of the field are identical in both usages.
The EXIT operation transfers control to an external sub-
An RPG II program may contain more than one subroutine. routine suppUed by the user. EXITF is equivalent to EXIT
Each such subroutine is delimited by the BEGSR and ENDSR but is used to exit to a FORTRAN subroutine (see

96768710 A 9-13
appendix G). The name of the subroutine is left-justified in Force (FORCE)
factor 2. The EXIT operation can be conditioned by entries
in columns 7 through 17. The resulting indicators field must The FORCE operation overrides normal record selection and
be blank. allows the user to select the file that will supply input for
the next program cycle. The forced file can be a primary or
The EXIT operation code may be conditioned by any secondary input, update, or combined file. Factor 2 names
indicators; this means that the external subroutine is the file from which a record is to be forced.
executed only if all the conditions are met.
The FORCE operation can be conditioned by columns 7
Assembly language coding usage of external subroutines is through 17, but all other columns except 60 through 74
described in appendix G. (Comments) must be blank. FORCE should not be specified
at total calculations time.
Define-Label-for-External Subroutine (RLABL) If a FORCE operation is executed, the next program cycle
will process the next available record from the forced file.
RLBABL defines a parameter that may be referenced by an If several FORCE operations are executed in one calcula-
external subroutine. The parameter may be a file hame, tions cycle, all but the last operation are ignored. The
field name, table, array, indicator, constant, or literal. effect of a FORCE lasts only one cycle.

The RLABL calculation specification must contain RLABL In multi-file processing, RPG II selects the first record to be
in columns 28 through 32 and the parameter left-adjusted in processed in the normal fashion, but thereafter records can
Result Field Name (columns 43 through 48). Field length in be forced in an abnormal sequence. At end-of-file on a
columns 49 through 51 and decimal positions in column 52 forced file, normal record selection resumes.
are optional. All other columns must be blank.
The RLABL specifications must immediately follow the
EXIT specification, which refers to the parameters. Indica- Display (DSPLY)
tors are referenced by coding INxx in Result Field Name
where xx is the indicator code. For example, Matching Through a DSPL Y operation, either or both of the following
Record Indicator" is coded INMR. can occur:

• Up to 125 characters are printed from storage onto the


PROGRAMMED I/O CONTROL console device without a halt in program execution.
• Up to 125 characters are printed from storage onto the
In the RPG II program logic outlined in appendix F, the console device. The program then halts, allowing the
normal sequence of events in a program cycle is: contents of the displayed item to be altered from the
console.
1. Read a record.
2. Perform calculations. With the first usage, the item to be displayed can be a field,
a table element (holding area element), an array element, or
3. Output a record. a literal. The item is specified as Factor 1 with the DSPLY
operation code.
Deviation from this pattern is possible via six operation
codes that allow input or output at calculations time: For the second usage, the item to be displa,ed (and perhaps
altered) can be a field, a table element, or an array element.
• EXCPT (exception) A literal can be specified but cannot be altered during
• FORCE (force) program execution. The item is specified as the Result
Field with the DSPLY operation code.
• DSPLY (display)
• READ (read) Factor 2 of the DSPL Y operation line designates the file on
which Factor 1 and/or the Result Field is displayed. A
• CHAIN (chain) display file is described completely on form F; the" file needs
• SETLL (set lower limit) no record descriptions. A single DSPL Y operation may have
specifications in both Factor 1 and the Result Field. In this
case, contents of both Factor 1 and the Result Field are
displayed. Program execution halts. The Result Field," but
Exception (EXCPT) not Factor 1, can be changed.

The EXCPT operation allows exception records to be written A DSPL Y operation may be conditioned by indicators in
at calculations time. EXCPT is primarily used to produce a columns 7 through 17.
variable number of similar or identical records (either detail
or total) in a single program cycle. One usage would be to The rules for entering data during program execution are:
write out the contents of a table in a program cycle.
• Leading" zeros need not be supplied for numeric data;
An EXCPT operation may be conditioned by entries in RPG II automatically right-justifies numeric data after
columns 7 through 17. All other columns except 60 through all characters have been keyed.
74 (Comments) must be blank. The exception output records • A trailing minus sign is keyed for negative numeric
are indicated by an E in column 15 of the Output Specifica- data. Field length need not take the trailing minus sign
tions sheet. Exception records may not be specified for a into consideration.
combined file.

9-14 96768710 A
o Alphanumeric fields are automatically left-justified Chain (CHAI N)
after all characters have been keyed.
o Typing a single space causes a numeric field to be The CHAIN operation is used for two purposes.
cleared to zeros and an alphanumeric field to be set to
blanks. • Random processing of an indexed, sequential, or direct
disk file
• If no characters are entered and the space bar is not
pressed, the Result Field item is not changed. • Loading (creating) a direct disk file
Specific information on the entering of characters and The operation requires Factor 1 and Factor 2 entries, but
clearing the halt is provided in appendix B. columns 43 through 53 and columns 56 through 59 must be
blank. A CHAIN operation may be conditioned by entries in
columns 7 through 17. A chained file may be conditioned by
an external indicator (Ul through U8). .
Read (READ)
An indicator should be specified in columns 54 and 55 of the
The READ operation causes RPG II to read and process a CHAIN operation. This indicator is set on when a record is
record from a demand file during the calculations cycle. not found; output cannot occur to a chained file when the
Unlike a record read by a FORCE operation, RPG II reads specified record is not found unless the operation was
the record immediately, not at the start of the next program intended for file addition. If columns 54 and 55 are blank
cycle. The READ operation is similar to the CHAIN and the record is not found, program execution halts.
operation, except that the READ file is processed
sequentially and the CHAIN file is processed randomly. When RPG II processes chained files, more than one record
identifying indicator may be on at the same time in a single
A demand file is described on forms F and I, and the same program cycle. This would happen if the program is chaining
filename is entered as Factor 2 of the READ operation. to one or more files during the same RPG II cycle. When
Columns 7 through 17 of the READ operation may contain chaining to the same file more than once during a cycle,
entries. All other columns should be left blank except for an only the last record processed is updated during output time
indicator specification in columns 58 and 59 and comments unless an exception output operation is associated with each
in columns 60 through 74. An indicator specified in chain operation.
columns 58 and 59 is turned on when end-of-file is reached
on the demand file and is turned on thereafter every time a
read from the demand file is attempted. Specification of an NOTE
indicator in columns 58 and 59 is desirable, because other-
wise the object program halts when the demand file is at If the same physical file is designated
end-of-file and every time thereafter that an attempt is INPUT and UPDATE in the same program,
made to read from the file. successive chains to the same record may
yield the old data after update, because
A demand file's record identifying indicator remains on the chained records are taken from the
throughout a program cycle after a record has been read input buffer instead of the disk.
from the file. This is also true for multiple reads from one
or more demand files in a single cycle.
When chaining to a file having packed record keys, the
A demand file is designated by a D in column 16 of form F. Factor 1 entry must have a packed length equal. to the key
Demand file records may be accessed only through READ field length in the chained file. A packed key field is
operations•. Control levels, matching records, and look- limited to eight bytes.
ahead fields may not be specified for demand files.
Furthermore, numeric sequence checking must not be
requested for the file, and the MR indicator cannot be
specified in columns 63 and 64 (Field Record Relation) of Random I nput Processing
the input sheet.
The entry in Factor 1 of the CHAIN operation identifies the
When a demand file is conditioned by an external indicator record to be retrieved. The value is either a numeric
(Ul through U8) that is not on, no records are read from the relative record number (for sequential and direct files) or a
file, and the end-of-file indicator (columns 58 and 59) is not record key (for indexed files). The relative record number
set on. or key can be contained in a field specified for that purpose.
The entry in Factor 2 identifies the (chained) file. This file
Demand files are input, update, or combined files that are must be described on forms F and I.
accessed by the following methods: .

• Sequential or direct disk files are processed


consecutively. Direct Output File Load
• Indexed disk files are processed sequentially by key or When. a direct file is created (loaded), the file is described as
within limits. a chained output file on forms F and O. Factor 1 names a
• Card, tape, or console files are processed sequentially. relative record number, and Factor 2 names the file.

~ 96768710 A 9-15
Relative· record numbers define the record position of each DEBUG OPERATION
record in the file. A relative record number can be all or
part of a field in an input record, or it may be generated by The DEBUG operation can assist in isolating programming
the RPG n program. errors in the object program. Whenever a DEBUG operation
is executed, one or more records are written to an output
When a direct file load i~ to occur, RPG IT clears the entire file.
area reserved for the file to blanks. As a record is being
output, the relative record number is used ,to chain to the
disk record to which the output occurs. Records not
specified in the direct file load remain blanks. Debug (DEBUG)
A direct file load is very different ,from record addition to The DEBUG operation may be placed at any place or several
sequential or indexed files. In the latter cases, a data places in the calculation operations. Whenever the opera-
record is added to the first available position at the end of tion is executed, one or more records are written to an
the file. Also, in the case of an indexed file, the record key output file. The first record always lists the indicators that
and disk address are added to the file index. With a direct are currently on at the time of execution of the DEBUG
disk file, each record has -a previously allocated position; operation. Following records show the contents of anyone
each record is chained to its proper physical position at the field. ,
time it is loaded. '
'A DEBUG operation is executed only if requested through
Once the direct file has been created, the file can be a 1 in column 15 of the control card specifications (form H).
modified in other RPG IT program executions by defining the When that column is blank, RPG II diagnoses each occur-
file as an update file processed consecutively or by the rence of a DEBUG operation with a warning. Both the
CHAIN operation. DEBUG operation and the error message are shown on the
source program listing.
It may b~ that duplicate record numbers will be entered as
Factor 1. These record numbers are called synonyms. This On the DEBUG statement, Factor 1 is optional. It may
could occur if a loaded record is composed of portions of contain a literal or field name to identify the particUlar
several other records. However. only the last data loaded DEBUG output. The literal or the value of the field named
for one record number appears in the created file. Two here is merely written in the first DEBUG output record. A
methods are available for the satisfactory processing of Factor 2 entry is required and names the output file to
synonyms: which DEBUG recor~ are written. All DEBUG statements
in a program must refer to a single output file. The optional
• Define the file as a chained output file in order to clear Result Field may name a field, a table or array element, or
the file to blanks in the first job. , Then run one or more an entire array whose contents are to be written in the
subsequent jobs using the update feature to read second DEBUG output record. Any valid indicators may be
relative record locations, checking for synonyms, while specified in columns 7 through 17. Columns 49 through 59 of
loading the file. the DEBUG operation must be blank.
• Define the file as a chained output file, clearing the file Becalise of additional processing considerations, it is
to blanks, and load all recor~ not having synonyms in a undesirable to name a direct or indexed file as the DEBUG
first job. Then run a subsequent job using the update output file.
feature to select synonym records and load them into
the file. The first DEBUG record is automatically produced when the
operation is executed and is a list of all the indicators that
are currently on in the object program. The format of the
first record is:
Set Lower Limits (SETLL)
Record Information
The SETLL operation allows the lower limits (for indexed POSItiOns
demand files being processed within limits) to be set during
program execution. 2-7 DEBUG-
Factor 1 contains a field name or literal that specifies the 8 Blank
value of the lower limit being set. Factor 2 designates the
name of the file for which the lower limit is set. The length 9-16 Constant specified as Factor 1 or
of the field or literal must equal the length of the key for statement number of the DEBUG
the file named as Factor 2. operation code in the program.
If the file is accessed before a lower limit is set by SETLL, 17 Blank
the record with the lowest key in the file is read.
18-31 INDICATORS ON-
When end-of-file is reached on the demand file, additional
records may still be read from the file through the issuance 32-end Names of all indicators that are
of another SETLL operation. In other words, the object of record on, separated by blanks or the
program'is not limited to one SETLL operation for a demand word NONE
file. However, if processing of the file continues after an
end-of-file condition has been reached, the end-of-file If the indicator list does not fit in one record, the list is
indicator specified with the READ command is not turned continued in the next record, starting at position 2.
off by RPG IT.

9-16 96768710 A
RPG II writes additional records to the output file if a • A list of indicators currently on
Result Field is specified for the DEBUG operation. The
format of these records is: • The contents of the entire array, ITMARY
Record Information When a match is not found, the MOVE operation is bypassed.
POsITIOns When a match is found, DEBUG output is not produced, and
the MOVE"operation is executed.
2-12 , FIELD VALUE or
TABLE VALUE or
ARRAY VALUE Get Time-of-Day (TIME)
13-14 Blank Column Value
15-end Contents of the Result Field 43-48 Name of field, table, array, or element to
of record speCification (up to 256 char- receive time
acters per item)
The TIME operation allows the current time of day to be
The record is continued starting in position 2 of the next read from the computer system during program execution.
record, if required. These additional records adhere to the The Result Field specifies the field, table, array, or array
following rules: element into which the time is to be stored. Time-of-day is
maintained as a six-digit value in the form hhmmss (hours,
• Decimal points are not produced. minutes, and seconds).

• A minus sign is appended to a negative item. Factor 1 and factor 2 must be blank.

• Array elements are written in order, separated by


blanks •
.J
·RESULTFIELD
• An array element is not split between physical records Columns Values
if the element size is less than the size of the physical
record. 43-48 Name of field, table, array, or array
element.
An example of coding with the DEBUG operation is shown in
figure 9-4. A search is made of ITMARY for an element This entry names a field, table, array, or array element used
matching ITMNO. If a match is not found, the following by the operation code specified. Generally, this field
records are written to DBGOUT (assuming form H contains a receives the result of the operation specified in columns 28
one in column 15). through 32. Other usages are described with the operation
codes.
• A list of indicators currently on
The name must conform to the rules for naming fields,
• The word ITMNO and the value of that field tables, and arrays. The name may be previously defi~ed in

CONTRPL DATA RPG CALCULATION SPECIFICATIONS Printed In U.S.A.

CORPO~TlON
12 757677787980
Program

Programmer Date
Page ~ 01_ ~:~;:'cation I IIIIII
Resulting
C
t---
Indicators Result Field Indicators
Arithmetic

~
At At Factor 1 Operation Factor 2
0
;:;
0
Plus IMinus! Zero
Compare
Comments
Name Length ~
line ~ 1>211<211-2
E
j ~ 15
z
15
z ~
u LookuplFactor 21is
High Low Equal
3 4 5 6 9 10 It 12 13 14 15 16 17 lB 19 20 21 22 23 24 25 26 27 2B 79 30 31 32 33 34 35 36 37 3B 39 40 41 42 43 44 4S 46 47 48 495051 52 54 55 55 57 5B 59 60 61 62 63 64 65 66 61 68 ti9 70 71 12 73 74

o 1 ~C ! i!- A~ lil.:l r~)C


o 2 QC
1:1 i NNk'l! LIJ 1<..11 IPI T~ A~ Y I~~J( 99
o 3
CC IfVqq I I 7irl I~ a: I bE 8U [(:it: 18J: %LE 2., 1,ft",11)
o 4
CC ItJ~ q ! b'l: 8Ui~ 1l!8 f:ll L.IS ~T ~A It..Y
o 5 c:;C qq ~~J1~_ :r.:T Jt1A K'« IZIJ IS!A vE
Ii
I
o 6 C : I I i
- I i I I I I I

Figure 9-4. Example of DEBUG Operations

96768710 A 9-17
the extension specifications. input specifications. or exceed the field length. The number may, however, be
elsewhere in the calculation specifications. larger or smaller than the number of decimal positions that
actually result from the operation. When the result of an
Otherwise. the Result Field name together with entries in operation produces fewer decimal positions than specified
columns 49 through 52 define the Result Field for further here. RPG II pads the low-order positions with zeros. If the
references. The new field may be either numeric or specified number of decimal positions is smaller than the
alphanumeric. A field used in arithmetic operations or number that results from the operation. the .rightmost digits
numeric compare. or a field edited or zero suppressed in are dropped (i.e., the result is not rounded).
output specifications must be numeric. A numeric field is
initialized to zeros by RPG II, and an alphanumeric field is
initialized to blanks. HALF ADJUST
When the name has already been defined. entries in Values Meanings
columns 49 through 52, if any, must agree with the previou.c;
definition. 53 Blank a. Not an arithmetic oper-
ation, or
FIELD LENGTH b. Do not half-adjust.

Columns Values Meanings H Half-adjust the result.

49-51 Blanks Field is defined elsewhere An H in this colUmn speCifies that the result of an
arithmetic operation is to be half-adjusted (rounded). Half-
1-256 Result Field length adjusting is accomplished by adding a 5 to the position
immediately to the right of the last decimal position
The length of the Result Field may be entered in columns 49 speCified for this field.
through 51, right-justified. Leading zeros may be omitted.
When these columns contain an entry, the form of the data The addition is performed on the absolute value of the
and its length after the operation has been performed must number to be stored. The correct sign is replaced before the
be considered. When the field is not long enough to contain rounded result is s~ored. All positions to the right of the
a result. the most significant digits to the left of the decimal positions speCified for the field are then dropped.
decimal point are lost. (The least significant digits ,to the
right of the decimal point may also be lost.) Unpacked Half-adjust must not be speCified with an MVR operation,
lengths are specified here for numeric fields. and the nor may it be specified for a DIV operation followed by an
maximum length allowed is 15 digits. Alphanumeric fields MVR operation.
may be up to 256 characters long.
If the Result Field has been described in previous input or RESULTING INDICATORS
calculation specifications. any entry here must agree with
the previous definition. If the Result Field contains a" table Columns Values Meanings
or array name, an entry in these columns is optional. but if 54-59
specified, must agree with the length described in the Blanks No entry
Extension Specifications.
10-99 Numeric indicators

DECIMAL POSITIONS HI-H9 Halt indicators

Meanmgs LI-L9 Control level iridicators

52 Blank a. Field is defined else- LR Last record indicator


where. or
OA-OG. Overflow indicators
b. Alphanumeric field OV
0-9 Number of d~cimal positions
in a numeric Result Field Indicators specified in these columns serve four purposes:

This entry specifies the number of positions to the right of • To describe the value of. a Result Field after an
the decimal point in a numeric Result Field. No entry is arithmetic operation
made for alphanumeric fields. A zero is entered in
column 52 if the numeric Result Field contains an integer. • To indicate the outcome of a CHAIN. LOKUP, COMP.
TESTB, or TESTZ operation
An entry in column 52 requires an entry in columns 49
through 51 (Field Length). • To specify indicators for SETON and SETOF operations

A Result Field may not have more than nine decimal • '1'0 signal encl-of-file for the READ operation code
positions, and the number of decimal poSitions must never

9-18 96768710 A
The specific uses of this field have been defined with the Line 010 If halt indicator H2 is on, indicators H2 and L1
various operation codes, with one exception: When are set off.
arithmetic operations are performed, the results are tested
and indicators are turned on as follows: Line 020 Bits 0 through 3 of the flag word named
FLAGS are set off.
• An indicator specified in columns 54 and 55 is turned on
if the result is positive. Line 030 This is a comments line (designated by the
asterisk in column 7).
• An indicator specified in columns 56 and 57 is turned on
if the result is negative. Line 040 If the matching record (MR) indicator is on,
bit 0 in word FLAGS is set on.
• An indicator specified in columns 58 and 59 is turned on
if the result is zero Line 050 The value found at MINMUM becomes the
lower limit to be used for processing the
A resulting indicator is typically used to condition following indexed demand file, RFILE, within limits.
calculation or output operations.
Line 060 Control is transferred to the subroutine named
SUB.
NOTE
Line 070 The flag word FLAGS is interrogated. If both
When LR is used as a resulting indicator, bit 0 and bit 1 of the word are on, indicator 19
NLR should be used to condition the same is set on.
operation (columns 9 through 17) to avoid
setting off a valid LR indication. Line 080 If this is detail time in the cycle but control
level indicator Ll is not on and indicator 19 is ~
on, then the zone portion of the rightmost byte
If a single resulting indicator is specified on more than one of ARG 1 is moved to the zone portion of the
calculations line, its condition reflects the result of the rightmost byte or ARG2.
most recently executed operation. Thus, it is usually good
practice to assign unique indicators as field indicators Line 090 If indicator 19 is on, the contents of FACTI
and/or resulting indicators in one program. are divided by the contents of F ACT2, and the
result replaces FACT!.
All halt indicators (HI through H9) are off at the beginning
of program execution. If more than one halt indicator is on Line 100 The divide operation at line 090 is immediately
when the program halts at the end of detail output, each followed by an operation to move the
halt indicator must be responded to separately. This is remainder produced by the divide to a word
because it may be desirable to continue program execution called REM. REM is defined on this line to be
under certain error conditions but terminate execution under six bytes long with room for two digits to the
others. By assigning unique halt indicators to various error right of the decimal point. The remainder is
conditions, the nature of an error condition can be readily rounded, if appropriate, before being stored.
identified. Notice that the MVR operation uses the same
conditioning indicator (19) that the DIV
operation used.

COMMENTS Line 120 In this operation, characters found at FIRST


are moved, left-justified, into a newly-defined
Columns Values field, NAME, which is 16 alphanumeric
characters long.
60-74 Any characters
Line 130 If a level 1 control break has occurred, bit 3 of
These columns are not interpreted by the RPG II compiler the word FLAGS is set on.
but are printed on the source program listing.
Line 140 When a level 1 control break has occurred, the
last record (LR) indicator is on, the matching
record (MR) indicator is not on, and control is
CALCULATION SPECIFICATIONS transferred to label TAG.
EXAMPLES
Line 150 When a level 1 control break has occurred, a
Highlights of some of the principles discussed in this section two-digit numeric integer field is initialized to
are illustrated in figure 9-5 and are discussed below. 99.

96768710 C 9-19
Line 170 Defines the label TAG, to which control was Line 210 If H2 is on at this point, bit 1 of the word
transferred at line 140 FLAGS is set on.
Line 130 When a level 1 control break has occurred, the Line 220 Also if indicator H2 is on, control is
alphanumeric literal TOTAL is moved to a transferred to SEXIT.
field named CONST.
Line 240 SEXIT defines the label of the last instruction
Line 190 This entry names the beginning of a and the exit of the subroutine.
subroutine. Lines up through 240 are con-
tained in the subroutine which is named SUB.

Line 200 A record is read from the demand file named


RFILE. If the end of the file has been
reached, halt indicator H2 is set.

&J E::\ CONTRPL DATA RPG CALCU LATION SPECI FICATIONS


\::I r:!I CORPORftTION
1 7 ,It, lfi 1/ 78 79 8()

p""Ql~"'_ ~'I:~::::':""" I," C.= ~IT~_~


c ..J
In<ltcators

r-- ~~ I Ani"Alld Factor 1 Factor '2 ] :r PI,., fMI"u,/ /' ,,,

J ~ : 1-r---r-+--r--r-+--r---r-1
Z... CII!I1II,tI"

L,,.,
Length ~ .~ 1 7h < 2 , 7

~j~~ ~! ~ ! ~ ~ ~",',:,""~fo:: '0; ,~:,,;


l
J 4 OJ h 7 H 9 10 l' 12 lJj'4 15 II.j",a 19 20 2122 2J 24 2~ 7fl]"l :' 31 J4 J'l :Jb 37 3R 3'J 404147 ,1j .14 .1' .1, ., 'iJ .1' <:"6 ',1 ',I' "j f,O 1,1 I,;:> h' 1,4 I,' ',t, 0, I " "

. ~-. f---

f-.i---L f---

. :'2l~
f----f---,~ ~-
"
.1'«.
t-~ 1----.--

-f- f-----
f----i-
t-f--- i
I
,1 l
l I J
j
I
1
j ••.••.
i (-j--j' ... j --+ ..

·-f-

• • • t ~ • .. ~ • • ._- ..

1------1-- • ~A~.-r. ~'r.0f ,A, L. rP.P. _


-f..- ,
11,2
-I
,

1--1--

f-I-- • t
--I-- . ~ .
E,tJ.1>_ S,v~,R..fP,u""~':".'.
I

Figure 9-5. Calculation Specifications Examples

9-20 96768710 A
OUTPUT SPECIFICATIONS - FORM 0 10

1'!.j" R49i·;·, Aj·",.,m;g;"WiIii#¥' W< 'It' I'WWU'W!W2 9tv' ,.,

Output specifications are provided for files designated as FILENAME


output, update, or combined files in the File Description
Specifications (form F). Output specifications also apply to Columns Values Meanings
input files into which records are added (I in column 15 and
A in column 66 of form F). 7-14 Blanks This is not the first line of
description of this output
Form 0 logically subdivides into two general categories: file.

• Record description entries (columns 7 through 31) Valid This is the first line of
describing records or lines of print RPG II description of this output
filename file, and this is the name of
• Field description entries (columns 23 through 70) that the file.
indicate the fields and constants comprising a record or
line The filename entered in columns 7 through 14 must be
identical to a filename listed on the File Description
The indicators portion of the form may condition output of a Specifications sheet. The name is left-justified in these
field or an entire record. These logical subdivisions are columns.
shown in figure 10-1.
The filename needs to be specified only once on the Output
Field descriptions are entered on lines im mediately Specifications sheet, but it must be entered on the first
following the associated record description. descriptive line of the file. All subsequent record and field
description lines up to a different filename pertain to this
All output fields are initialized to blanks before each cycle. file. .

~~
CONTRPL DATA RPG OUTPUT SPECIFICATIONS
CORf'O~1l0N
1 2 75167718111110
Progr....
Progr........ , OliO
P.[Oo,_ =:'tionU I I I I I

-0
_ ~ Spoc:e Skip Output Indicators Zoro Bilinees - X· Remove
Commos NoSi~ CR

~~ 1 I t:1tId Name ,,1£:11.-.._---.-.... Yes


1o Prinl
Yes A J
PlusSi~
V·olle

'--
line Filename ~! ~~ .IJ :(~ And And
I~ II:
End
Posilon
Yes
No
No
No
Yes
No
B
C
o
K
l
M
Field Edit
Z'ZetO
Suppress
~!
E
~
~
l-
I- .,;

o R'A 0"0
'A~~
j ! ~ j I 'AUTO ~ ~ ~:'~
wG
in

i Constant or Edit Word

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 XI 24 25 26 27 28 21 30 31 :r.t 33 34 35 3S 37 38 ]!I 40 41 42 43 . . 45 46 47 48 49 SO 51 52 53 54 ~5 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 11 72 73 74

o 1 0
.- ~ -. . r-r- -- -+-+-+-+-i-+-i
o 2 0
o 3 0
o 4 0
_.+-+-+-I-f---+-I-J-+-+--+--t RE CORD ~f--+....+-+-+-~--I-lf--+....+-+-+-l-+-+ - .. +-+- . t --t -+-1+-IH·-+-+-I-I--+--H-I
o 5 0 CONDITlO'J NG ..-1-1--
-·I-+-++--IH--l--H-~-.J-4-+-+-+-+--I-+-~-+-+--H-+-+-lI-I--+- -. - ---- - -. - -- . 1- . - - - ,--
o 6 0
- '--r- --
o 7 0
.- - - - ._-- -+-lH--+-H
o
o
8

9
0
0
-J- -- -l -------1- -+-If-+.--f--4

_. - -- - . -. -+-+-+-+-t-+-+-l
1 0 0
- -.
11 0 I I·
1 2

1 3
0
0
~r i- ---I

1 4 0
- - - - - r - - ._--'-. -,- - --I--+-+-+-1f-++-+-+ ------- . --- - - -.-.- - --'--+--+--!-'+-+-+4-+--+--+-+-+-+-lI--+~
1 5 0
1 6 0
17 0
1 8 0
1-t+~-+-t-iH--I-+-IH-+' _.- - ·-I-+-++-1-++-+--+-+-+....j~4-~-++-J-..+-+-+- +--+--f-+-+-+-I-+--+--I-+-. +-+-++-f-+-4-+-I-+-+--H-+-+-+-+--Ir-f-+-+--I
1 9 0

Figure 10-1. Output Specifications Sheet

10-1
96768710 A
AND/OR RELATIONSHIPS beginning of program execution. Subsequently. heading lines
are usually printed as a result of overflow processing and
Columil!; Values Meanings skipping to a new page.
14-16 Blanks Field description line Detail records are closely connected to input data as they
are ordinarily produced after each input record has been
AND Record description line. processed.
Output indicators on this
line are in an AND rela- Total records are usually output after control breaks have
tionship with those on the occurred and total calculations have been performed and at
previous line. end-of-job, when the LR indicator is on. Total records
commonly contain the results of calculations on several
14-15 OR Record description line. input records. Unpredictable output may occur when total
Output indicators on this records are specified for primary or secondary update files.
line are in an OR rela-
tionship with those on the Exception records are output when directed by the
previous line. calculation operation EXCPT. Exception output cannot be
specified for a combined file. Furthermore, exception
Form 0 allows up to three indicators per line for condition- output conditioned by control level indicators should not be
ing record output. These indicators are in an AND specified for primary or secondary update files, as the
relationship. If more than three indicators are required to results of the output may be unpredictable.
condition a record, an AND in columns 14 through 16 of the
next line allows the specification of three more indicators. It is a customary programming procedure to prepare form 0
Then the condition of all indicators in an AND relationship lines for each file in the following order: all heading
must be satisfied before the output operation can be done. records, followed by all detail records, followed by all total
records, followed by exception recor¢;. This order is not
An OR in columns 14 and 15 of the next line allows the user mandatory, however.
to specify· up to three alternate output indicators for a
record. As an example, the user may want to eject a printer
page and print a report heading line (record) at the time of a
control break (L2, for example) and when the last record has ADDA RECORD
been read and is being processed. Thus, the user can request
the page eject and the printing of the report heading when Columns Values Meanings
L2 OR LR is on. Simply specifying L2 OR LR, however, can
yield duplicate page ejects and report headings when LR is 16-18 Blanks a. Field description line,
on. This is avoided by encoding L2 and NLR (not last record) or
on one line and LR on the other. b. This record is not being
added.
Spacing and skipping specifications need not be specified on
an OR line unless alternate spacing and skipping are desired. ADD Add this record to this disk
file.
When spacing and skipping are not specified on an OR line,
any space and skip specifications on the previous line are This entry allows records to be added to existing inpu.t,
used. update, and output files. The designated file must contain
an A specification in column 66 of the File Description
AND/OR lines cannot be used to condition fields of a record. Specifications sheet.
The ADD entry must be on the first form 0 line describing
the record to be added.
TYPE •
Column Values Meanings
15 Blank Field description line
STACKER SELECT/FETCH
OVERFLOW
H Heading record Column Values Meanings
D Detail record 16 Blank a. Use standard overflow
routine for this printer
T Total record file, or
E Exception record b. Use the predetermined
stacker on this card
The specification in column 15 determines when a record device, or
should be output. c. This card device does
not have multiple
Heading records usually contain constant information such stackers, or
as report and column headings as well as page numbers.
Conditioning heading records with the first page (lP) d. This is neither a printer
indicator is a common way to produce the records at the nor a card file.

10-2 96768710 A
Column Values Meanings When fetch overflow has not been specified, all detail and
total lines conditioned for output in the cycle are printed. If
16 1-4 Designates one of four any of those lines is printed on or below the overflow line,
stackers in which to place all such lines are printed before output lines conditioned by
cards after they have been the overflow indicator are printed. If the overflow area is
processed. Standard not large enough to hold all of these lines, unattractive
CYBER 18 devices do not output results. Use of the fetch overflow feature ensures
provide for more than one overflow processing before the end of the page. Overflow
stacker. indicator usage is summarized in table 10-I.
F Fetch overflow (printer files Fetch overflow must be designated for each line in an OR
only) relationship if the overflow routine is to be fetched for each
record in the relationship.
Column 16 may be used for two entirely different purposes:
Partial specifications for fetching overflow are shown in
o To specify a stacker into which certain cards are to go figure 10-2. Lines 030, 050, and 060 can fetch overflow.
after processing This happens only when indicators OV and L5 and both set.
Should overflow be fetched, the OV indicator is reset after
o To request that the overflow routine be used at this the forms advance at line 010 is executed.
point for a printer file
At the time that the record specified at line 030 is to be
produced, indicators OV and L5 and interrogated. If they
are both on, the forms are advanced (per line 010), the
STACKER SELECT heading record specified at line 010 is written, and the
records specified at lines 030 through 070 are then written
Through column 16 one may indicate that certain. cards are on the new page. If overflow has not been sensed before the
to fall into the designated stacker. When a stacker is not printing of line 030 but is set on by the printing of that line,
selected in column 16, all records of the file fall into the overflow is fetched at the time of execution of line 050. If
stacker designated in appendix B. line 050 fetches overflow, the forms are advanced, the
heading record is produced, and records corresponding to
Only output and combined files may be stacker-selected lines .050 through 070 are written on the new page. (Notice
through the output specifications. When the program is to that if line 050 fetches overflow, line 060 does not, as
perform output on a combined file, any stacker selection indicator OV is reset at the time the heading record is
should be made in the output specifications rather than the printed.)
input specifications. However, form 0 stacker selection
overrides form I stacker selection.
When stacker selection is based upon matching records, the OVERFLOW PRINTING WITH
selection should be indicated for detail time (D in EXCPTOPERATION CODE
column 15), as it is only at this time that the MR indicator
reflects the matching status of the record about to be sent An overflow indicator cannot condition ail exception line,
to a stacker. but it may condition fields within an exception line. The use
of the EXCPT operation code with exception lines (E in
A stacker select entry may be made on an OR line but not column 15) causes exception lines to be printed during
an AND line. When column 16 is blank on an OR line, the calculations time rather than output time. If the overflow
record falls into the predetermined stacker; unlike spacing line is sensed when an exception line is printed, an assigned
and skipping options, the OR line does not assume the overflow indicator is turned on, as expected, but overflow
stacker selection indicated for the preceding line. processing does not occur until another exception line
specifying fetch overflow and having satisfied conditions is
ready to be printed.
FETCH OVERFLOW The actual overflow output lines must be type H, D, or T.
The use of fetch overflow causes the H, D, or T overflow
Fetch overflow may be specified for any total, detail, or output lines to be printed if the overflow indicator is on.
exception record that is not conditioned by an overflow The overflow output lines are produced prior to the printing
indicator. An F in column 16 can cause overflow lines to be of the line on which fetch overflow is specified. Overflow
printed and the forms to advance before the printing of may also be forced by issuance of a SETON of the
detail and total lines appropriate for the cycle is completed. appropriate overflow indicator prior to the EXCPT operation
Overflow can be fetched only if all the conditions specified code, provided fetch overflow has been specified.
in columns 23 through 31 are met and overflow has been
sensed.
FORMS CONTROL-SPACE/SKI P
NOTE
Through the space/skip feature, RPG II offers relative and
Forms advance is not automatic when absolute forms control to the user. If columns 17 through 22
overflow is fetched. Forms advance takes are blank, Single spacing occurs automatically after each
place only by explicit request (probably on line is printed.
the first heading line for a new page).

96768710 A 10-3
TABLE 10-1. OVERFLOW INDICATOR USAGE

Conditions. Effect at Overflow Time

This file does not bavean assigned 1. The following lines are printed in the overfiow area.
overflow indicator.
• Any detail lines to be printed as a part of the current detail output.
• Any total lines to be printed as a part of the current total output.
2. The form is automatically advanced to the top of the next page.
This file has an assi~ed overflow 1. The overflow indicator is turned on.
indicator, but the indicator is not used
to condition any output lines. 2. Detail and total printing. continues in the overflow area.
3. The overflow indicator is turned off at the top of the next page.
This file has an assigned overflow 1. The overflow indicator is turned on.
indicator used to condition at least
one output line. 2. The following lines are printed in the overflow area.

• Any detail lines to be printed as a part of the curtent detail output.


• Any total lines to be printed as a part of the current total output.
• . Any total lines conditioned by the overflow indicator.
• Any header or detail lines conditioned by the overfiow indicator.
3. The overflow indicator is turned off after all lines conditioned by the
indicator have been printed and top of form has been reached.
4. Regular detail cycles resume.
This file has an assigned overflow 1. The overfiow indicator has been turned on.
indicator, tlte overflow line has been
passed, and the overflow routine has 2. Total lines conditioned by the overfiow indicator are printed.
been fetched.
3. Any header or detail lines conditioned by the overfiow indicator are
printed.
4. The line that fetched overflow is printed. t
5. Remaining detail and total lines are printed.

tThe overfiow indicator is turned off after top of form has been requested.

Columns 17 and 18 allow up to three lines of spacing, before 3. The line is printed
and/or after a print line, relative to adjacent lines.
Columns 19 through 22 allow absolute spacing to a particular 4. Skip after
line on a page, before and/or after a line is printed. If both
spacing and skipping are specified on the same line, the skip 5. Space after
always precedes the space. Thus, if columns 17 through 22
all contain entries, spacing, skipping, and printing is Different spacing and skipping may be specified for lines in
executed in the following order: an OR relationship. When columns 17 through 22 of an OR
line are blank, spacing and skipping are performed according
1. Skip before to the entries on the line preceding the OR line.
, .
2. Space before

10-4 96768710 A
CONTRPL DATA RPG OUTPUT SPECIFICATIONS
CORPORf.T10N
1 2 75 78 77 78 711 110
Progrlm

Progrlmmer 01"
PI9I~OI_ =-;:'Clti~U IIIII

-
o _ ~r'pac­ Skip Output Indicators

e~~~~--+---.---,---; ~~~ 1I'•[. i~r---~~


..Jo.,

-
,?, Commn Zero Balances
to Print
NoSi", CR - X • Remove

V •
Plus Sign
0.,_
J

~! ~ !01:(:;
Ves Ves 1 A

line Filename
~
l
And A.lnd iflJ IE:
End
Politon
Yes
No
No
No
Yes
No
2
3
4
B
C
0
K
L
M
Z •
Fi_ld Edil
Zero
Suppress
"

.... Vi !. in a:
r;'Oro I :; 0 0 (; 8 5 Oulpul ::J Constant or Edit Word
ORO>
~ND
~ z Z Z ·AUTO ~ ~
we
Record
~
3 • S 6 7 8 9 10 11 12 13 .. 15 16 17 18 ,. 20 21 22 :13 2' 2S 26 27 28 11 30 31 :n 33 34 J5 38 37 38 ~ '0 .. '2 '3 44 '5 06 '7 08 '9 so 51 S2 S3 so 55 56 S7 58 59 60 61 62 63 60 65 66 67 68 69 70 71 72 n 74

- r--t-. - f-- . r-~-I- -+-+-+-t-t-t'-1

4,...
--+-+-+--rlt-t--t'j-,-t-t_++4-=!ll;::.~+.-t-t-+-ir -+--t-t-Ht-t--r-t-rl"lll--- r- - r~t-I-
o 0
-+---If--t-+-t

: : :~ : rl-+-H~F':-1H~A-i~H+--t-t--=-I~t-l~-t-t--i--++-+-+-t-Ht-HH---'-t-t- -- -- - f-- 1- - -1-r-- - - - f--


-0 1--7 ~ ~_~- _ t-~~ f.- - -- ~ f-IJ_ -~t-I-- ,-. t- r- -~--+-if-+--+-+--+"+- f- - -- - --- . - -- - --

1
I.l. - ,- I- - -
1-
o 8
ft ft
~O
~
" I' ~ I"~ .~+-+-+-+-++--I-+--+-t-t---+-t_- I~I : t~ _-_ _ t- _-_, -~t-~ -t- _
r- t-H--r- _- '-~t-r-
Figure 10-2. Specifications of Fetch Overflow Feature

SPACE FORMS CONTROL Columns Values Meanings


Columns Values Meanings 19-20 01-99 Lines 1-99
21-22
17, 18 Blank a. This is not a printer or AO-A9 Lines 100-109
console file, or
b. Default to single space BO-B2 Lines 110-112
after line is printed.
Columns 19 and 20 sI1ecify the skipping before and
columns 21 and 22 the skipping after a line is ,printed. The
o No spacing
~eading zero must be supplied for lines 1 through 9.
1 Single spacing
The codes designate the forms location of the next line to be
2 Double spacing printed. When the skip is to a lower line number, the forms
are advanced. No action occurs when the forms are already
3 Triple spacing positioned at the specified line.
If the destination of a skip is beyond the overflow line but
Column 17 specifies the spacing before a line is printed, and
column 18 specIfies the' spacing after -a line is printed. If before top of form, an overflow indicator assigned to the
the destination of a space operation is· a line in the overflow file is set on and remains on until forms advance occurs.
area, the overflow indicator, if assigned, turns on and The destination line of a skip operation must not be beyond
remains on until the top of a new page is reached. the form length defined on the Line Counter sheet.
Because of the mechanism of a console device, the default The skip feature is useful in moving form stock more than
of a single space after printing is actually a carriage return the number of lines possible through spacing or when the
that occurs before the line is printed. Thus, a space number of lines to the destination line varies. The skip
specification of blank, zero, or one always 'yields a single function is also useful for positioning subtotal, total, and
space before printing at the console device. heading lines, and is the most common way to reach a top of
form.

SKIP FORMS CONTROL


Columns Values Meanings OUTPUT INDICATORS
19-20 Blanks a. This is not a printer or Columns Values
21-22 console file, or Any RPG II indicators
23-31
b. Skipping is not
requested.

96768710 A 10-5
Output indicator entries are used to condition output of Columns Values
entire records and/or fields of records. Any of the
indicators associated with RPG n may be specified. 32-37 UDATE, UDAY, UMONTH. or
Numerical indicators (01 through 99), control level indi- UYEAR
cators (LI through L9), halt indicators (HI through H9), and
external indicators (U1 through U8) require previous specifi- c. The name of a table. array. or
cation in the RPG n program. When an overflow indicator array element
(OA through OG or OV) is used to condition a record and/or
field, that indicator must have been previously assigned to Entries in columns 32 through 37 identify each field to be
the same file in the file description specifications. included in the output record or print line last .;pecified.
The columns are left blank on a record description line or if
An indicator that conditions a re("ord is entered on the this line specifies in columns 45 through 70 a constant to be
pertinent record description line; similarly, an indicator that' output. When an entry is made in columns 32 through 37.
conditions a field is entered on the pertinent field columns 7 through 22 of the same line must be blank.
description line.
Entries in these columns may be listed in any order oil the
The indicator codes are entered in columns 24 and 25, 27 and sheet. as the order in which they appear in the output record
28, and 30 and 31; the codes in a single line are in an AND is determined by entries in columns 40 through 43. They are
relationship. If output is to occur when the indicator is off, usually listed sequentially. however, for easy reference. If
enter an N in the preceding column (column 23, 26, or 29). later fields overlap the first fields. overlapped data from the
It is a poor programming practice to specify only negative first fields is lost. Entries in these columns are left-
indicators on a line, but if a heading or detail record is justified.
conditioned in such a manner, the record is output at the
beginning of the program cycle, when IP lines are written.
Overflow indicators may not be used to condition exception FIELD NAMES
records (E in column 15). Overflow indicators may condition
fields of exception records, however. A specified field, table. array, or array element name must
be previously defined as a field of an input record in
Records conditioned by overflow indicators are produced columns 53 through 58 of the input specifications or as a
only when overflow has been sensed for the file. An result field of an operation in columns 43 through 48 of the
overflow indicator may have an OR relationship with ,the IP calculation specifications.
indicator if identical heading records go on every page of
the file. The lP indicator, however, may be specified only According to the internal representation of numeric data. a
fo~ heading and detail records. negative number shows a letter as the rightmost digit unless
the field is edited (see Edit Codes).
When a control level indicator (Ll through L9) conditions a
total record without an overflow indicator, the record is
written only after the last record in the control group has
been processed. A detail record conditioned by a control PAGE, PAGEl, PAGE2
level indicator but not an overflow indicator is produced
only after the first record of the new control group has been RPG II automatically numbers print file pages if PAGE.
processed. When columns 23 through 31 contain both a PAGEl, or PAGE2 is entered in columns 32 through 37. The
control level indicator and an overflow indicator, the record three page counters, PAGE, PAGEl, and PAGE2, are
is produced only when overflow has been sensed and the provided for use with three different output files. The same
control break has occurred. name should not be used with two different output files.
All records conditioned by the last record indicator (LR) are . When a page counter is named in these columns without
produced last. being defined elsewhere in the program. the page number is
taken from a four-digit numeric counter with no decimal
positions; RPG II increments the counter by one before using
NOTE it on each page.
Only one record is written to an update or On the other hand, a page field may be defined in the input
combined file per cycle. Unpredictable or calculation specifications and be up to 15 positions long.
results may occur if multiple records are Zero decimal positions are still required for a program-
designated for an update or combined tile defined page counter.
in a single cycle.
When a page counter is output, leading zeros are suppressed
automatically, and a sign is not shown with the low-order
digit unless an edit word or edit code is specified for the
FIELD NAME counter. Page numbering starts with' page one unless
otherwise specified, and RPG II automatically increments a
Columns Values page counter by one every time the counter is output; this is
true for page counters that are defined internally and page
32-37 a. Any previously defined field counters that are defined in the program.
name
b. The special words PAGE, A page counter may be reset to zero during program
PAGEl, PAGE2, *PLACE, execution in several ways. One way is to specify Blank

10-6 96768710 A
After (column 39) in the same line in which the page counter coding produces the output record shown in figure 10-4.
is referenced. Another way is to use an output indicator to When several fields are being repeated, the *PLACE feature
condition the' page counter field. An output indicator does is a very convenient device for saving lines of coding.
not truly condition output of the page counter, as a counter
is output any time its associated record is output. When the These rules should be followed when using *PLACE:
output indicator is on, however, the specified page counter
is reset to zero and incremented by one before the record is o *PLACE is entered on the line immediately following
printed. Other ways to change the value of a page counter the last field specification to be repeated.
during program execution are to use the Z-ADD and MOVE
operation codes in the caiculation specifications with the o *PLACE entries may be made on successive lines
desired reset value entered as a numeric literal in Factor 2
and the appropriate page counter in the Result Field. o An *PLACE specification causes all prior field specifi-
cations for the record to be repeated.
o The end position specified for *PLACE should be at
*PLACE least twice the previously named end position for the
record (not including previous *PLACE specifications),
*PLACE is a special RPG II word allowing fields to occupy but not greater than 256. If this is not done, over-
more than one position in an output record without being lapping of fields results, with the *PLACE fields
respecified. When RPG II encounters *PLACE, all fields overlapping prior characters. The specified end position
previously specified for the record are repeated in the same must not be lower than the preceding end position
relative positions, ending at the character position named in specification.
columns 40 through 43 of the *PLACE line. A set of fields
may be produced in a _single record more than twice by the • The starting (leftmost) character position for an
use of multiple *PLACE lines. An example of using the *PLACE move is always position one of the record.
*PLACE feature is shown in figure 10-3. Either method of

CO~OLDATA RPG OUTPUT SPECIFICATIONS


CORrO~nON

I::. ., IDote
Punchi,.
1..lnICtion
I::~ I I I III I I Card EIIcVo Number

..
~
0
~~
~ Skip Output Indicators
~?~i::ti~;,:/0'":f l£l .... Comma Zero Balances
to Print
NoSi", eR

A
- X· R_I
Plus Sign
~:!
I'>' [;:;~I~"
't.' '1
Ii II :
y.
•..~. "'~,J}."-. Yes Yes 1 J Dill
I;:. .....
Line Filename
F!
::( AL 1 .':; II
~
End
Positon
YIS
No
No
No
Yes
No
2
3
4
B
C
0
K
L
M
Field Edit
Z • Zero
Supprea ';

!
~
E
~ ~D
I I;
::
« i .i I ·AUTO
~-
~~
in
Output
Roterd
IE
:l
~
Constant or Edit Word "

~ ~;ro
3 4 5 6 7 8 9 10 11 12 13 14 t5 16 n 18 II 20 21 22 :13 24 25 215 27 28 2830 31 ~ 33 34 a 38 37 38. 40 41 42 43 44 45 40 47 48 49 50 51 52 53 54 55 5& 57 58 59 60 61 62 63 64 65 66 67 68 69 70 7t 'It n,.
o 1 ~o
--
o 2
~°lt ~1 " F1 'I "': ~' t 'LA ~~ ~~7t ~Lth..
o 3 ,...,0

o 4 QO pI~ .'IlftJT I .1 cll


o 5 QO
-- f-- IFIL .IlIA It!
o 6 00 I~IL :))18 l11~ ~-
o ,...0 ~ILll ~~r-
7

o 8 ",0
. 11= I L Jj 121~ --- -r-:-:. - --
o 9 ~O - i- ---I- IrL IZ:'A 1.= Ie
1 0 ~o
--- 1--- - ~ .. - I':L IlB 31~ --f-- -- . - - -f-- .-- --,- ~--
11 to ..
1 2 Ie 0 -I- - - -
bo~ ...t{. ..tJ ~ )L ~C~ ~~. D, l "'~
I 3
_. -- I - -
I 4 Ir-o
--- 1-1-
1 5 ~O ipl~ lAh' tJ: 1 t"1.i
1 6 DO II i llll Il
1 7 ~O Ft 1)i3 lt2
i 8 ~O
~if ILA Clf ~I'I
bo , :Q '~II:
1 9

2 0 0
oil'
l.!I'" .... 1..
6'
-
Figure 10-3. Example of Coding with the *PLACE Feature

96768710 A 10-7
RECORD
POSITION It
t.FLDA
.1 .121
FLOO"" FLDA
181
-+-
241 301 361
FLOO +FLDA ..... FLOO-.(
TABLE 10-2. EDIT CODES
Category Code Meaning
0307 SUppress positive sign. Insert two
One X
blanks in front of each array
element.
Figure 10':'4. Exam~le of *PLACE Output
y Edit date field according to
inverted print specification
DATE FIELD (column 21 of form H):

The special words UDATE, ,UMONTH, UDAY, and UYEAR- Blank - mm/ddtyy
refer to the runtime-supplied current date. A reference to i> ;..dd/mm/yy
UDATE yields a six-character numeric date field in one of I - dd.mm.yy
the formats: J - dd.mm.yy

• Domestic: mmddyy Suppress first digit of date if zero.

.• Foreign (including United Kingdom): ddmmyy Z Suppress zero balance and suppress
sign.
The format desired is specified in column 21 of form H,
Control Card Specifi,cations. When a UDATE field is edited, Two 1 Print with commas, print zero
the eight-character. result is one of the following: balance, suppress sign.

• Domestic: mm/dd/yy 2 Print with commas, suppress zero


, balance, suppress sign.
• United Kingdom:'. dd/mm/yy
3 Print wltJlout commas, print zero
• Foreign: dd.mm.yy balance, suppress sign.

UMONTH refers to the two-character mm, UDAY to dd, and 4 Print without commas, suppress
UYEAR to yy. zero balance, suppress sign.

None of these special words may be specified in the result A Print with commas, print zero
field of a calculation operation. Any of the words, however, balance, print sign as CR.
may be used as Factor 1 or Factor 2 of a calculation
operation. B Print with commas, suppress zero
balance, print sign as CR.
C Print without commas, print zero
EDIT CODES balance, print sign as CR.

Column Values Meanings D Print without commas, suppress


zero balance, print sign as CR.
38 Blank a. Alphanumeric field, or
J Print with commas, print zero
. b. Field editing . not b~ance, print sign as -•
desired.
K Print with commas, suppress zero
1-4, See table 10-2. balance, print sign as -•.
A-D,
J-M, L Print without commas, print zero
X-Z balance, print sign as -.
An entry is made in column 38 to edit numeric fields in the M Print without commas, suppress
following ways: ' zero balance, print sign as-.
• To suppress leading zeros
• To omit signs from low-order digits of fields
o To punctuate fields without setting up edit words There are two categories of edit codes. The first category
(consisting of codes X, Y, and Z) generates punctuation only
An entry should not be made in column 38 for alphanumeric for a date field with code Y and prohibits entries in
fields or when an edit word is entered in columns 45 through columns 45 through 47. All of the other edit codes belong to
70. Some edit codes allow the entry of edit eode 'modifiers the second category, causing punctuation of the output field
in columns 45 through 47; however. with decimal points/commas and the affixing of negative

10-8 96768710 A
balance indicators, and allowing entries in columns 45 Characters added to a field through edit codes should be
through 47. The function of each edit code is listed in taken into consideration in determining the ending record
table 10-2 •. position of an output field. The effect of each edit code on
numeric data is shown in table 10-3. (Data in the figure is
six digits long and is aligned in the low order position to
NOTE show edited field expansion.) Another illustration of the
effects of entries in column 21 of form H is found in
A positive sign is suppressed when table 4-1.
any edit code is specified.
The use of edit code modifiers with edit codes of the second
category was mentioned above. Specifically, there are two
When an edit code is used to punctuate. a whole array, two allowable edit code modifiers:
high-order blanks are provided with each array element.
• To replace leading zeros by asterisks, enter '*' in
An edit code can be specified only for. unpacked numeric columns 45 through 47 of the line containing the edit
data. When an edit code is not specified for a negative code. This type of replacement is termed an asterisk
field, a non-numeric character is produced in the low-order fill.
position of the field.
• To ge"nerate a dollar sign immediately before the first
Edit codes are used in conjunction with entries in column 21 digit of the field, enter '$' in columns 45 through 47 of
(Inverted Print) of the Control Card Specifications sheet. the line containing the edit code. This type of editing is
All edit codes suppress leading zeros, except when a J is referred to as a floating dollar sign.
specified in column 21 of form H. In that one case, a zero is
supplied to the left of the decimal comma for zero and
fractional balances.

TABLE 10-3. EDIT CODE USAGE

Zero Balance -
Negative Two Decimal Positions
Positive Positive Negative Zero
Edit Number - Number - Number"- Number - Balance -
Entry in Column 21 of
Code Two Decimal No Decimal Two Decimal No Decimal No Decimal
Positions Form H
Positions Positions Positions Positions
blank, D I J

Blank 123456 123456 00012L 00012L 000000 000000 000000 000000

1 1,234.56 123,456 1.23 123 .00 ,00 0,00 0

2 1,234.56 123,456 1.23 123

3 1234.56 123456 1.23 123 .00"' ,00 0,00 0

4 1234.56 123456 1-.23 123

A 1,234.56lSlS 123,456lSlS 1. 23CR 123CR .00 ,00 0,00 0

B 1,234.56lSlS 123,456lSlS 1.23CR 123CR

C 1234.56lSlS 123456lSlS 1.23CR 123CR .00 ,00 0,00 0

D 1234. 56lSlS 123456lSlS 1. 23CR 123CR

J 1,234.56lS 123,456lS 1.23- 123- .00 ,00 0,00 0

K 1,234.56lS 123,456lS 1.23- 123-

L 1234.56lS 123456lS 1.23- 123- .00 ,00 0,00 0

M 1234.56lS 123456lS 1.23- 123-

X 123456 123456 00012L 00012L 000000 000000 000000 000000


y 12/34/56 12/34/56 0/01/23 0/01/23 0/00/00 0.00.00 0.00.00 0/00/00

Z 123456 123456 123 123

96768710 A 10-9
It is also possible to have 0. dollar sign precede the asterisk When the field name is *PLACE, columns 40 through 43
fill. In this case the field has a fixed dollar sign. A fixed indicate the rightmost character position to which the move
dollar sign is requested in this manner: occurs.
• Encode a dollar sign constant in the record position
immediately preceding the edited field.
PACKED OR BINARY FIELD
• Enter ,*, in columns 45 through 47 of the line containing
the field name and the edit code. . Column Values Meanings
44 Blank a. Record description line,
or
BLANK AFTER b. Unpacked numeric or
Column Values Meanings alphanumeric format
field
39 Blank a. Record description line,
or P Packed decimal format field
b. Do not chaQge this out- B Binary format field
put field.
Column 44 indicates whether a numeric field is to be output
B Reset this field to zeros or in packed decimal or binary format. Packed and binary
blanks after output. fields should not be printed; however, it is quite appropriat&
to produce a packed or hinary field on disk, tape, or cards in
The entry of B in column 39 causes the source field to be order to conserve space on the exJernal medium. When
reset to blanks (if alphanumeric) or zeros (if numeric) after column 44 is blank, the data is output in unpacked format.
the field has been placed in the output record. Blank after
is a convenient means for resetting control break When format conversion is requested via column 44, four or
accumulators after they are output at total time. fewer bytes are converted to two binary data bytes; five to
nine unpacked data bytes become four binary bytes. Further.
Blank after cannot be specified for a date field nftme (for discussion of unpacked, packed, and binary formats can be
example, UDATE), a look-ahead field, or a constant. found in section 6.
When blank after is requested for a table name, both the
holding area item and the equivalent table item are reset.
CONSTANT OR EDIT WORD
Care must be taken in specifying blank after for a field that
is produced in more than one record. The blank after should Columns 45 through 70 are used for three purposes:
be designated· in the last record in which the field is output
to avoid premature clearing of the field. 1. To define a constant to be placed in the output record
2. To indicate a modification to the edit function coded in
column 38
END POSITION IN OUTPUT RECORD 3. To specify an edit word that formats the output field.
Columns Values Meanings
40-43 Blank Record description line CONSTANTS
1-9999 Low"';order character posi- An alphanumeric constant may be defined by encoding an
tion of this field in the apostrophe in .column 45 followed by up to 24 alphanumeric
output record characters (including blanks) and terminated by another
apostrophe. An apostrophe within the constant is encoded
'rhe entry in columns 40 through 43 specifies the rightmost by entering two consecutive apostrophes. For example, the
or least significant position of ·the designated field in the constant DON'T is encoded 'DON' 'T' in columns 45 through
output record. The entry is numeric,· right-justified, and 52. Since a constant is actually a source field for the output
leading zeros may be omitted. The end position must not record, columns 32 through 37 (field name) must be left
exceed the record length. blank in the same line.
If punctuation or other characters are added to the field When a constant exceeding 24 characters "is required, subsets
through editing, the effective field length is increased. Be of the constant are entered on successive lines, as if they
sure to allow sufficient room in the record for the source were independent. For each line of the constant, an
field and any additional characters; output results are appropriate entry must be made in columns 40 through 43
unpredictable if edited fields overlap. . (End Position in Output Record).
If the field name is PAGE, PAGEl, or PAGE2, the entry in
columns 40 through 43 indicate the low-order position of the
page number in the output record.

10-10 96768710 A
EDIT CODE MODIFIERS • The first (highest position) zero or asterisk in the edit
word stops zero suppression. Subsequent zeros and
As described above, the two edit code modifiers, * and $, asterisks are treated as constant symbols and are
are entered with enclosing apostrophes in columns 45 interspersed where they occur with respect to the
through 47 for use in conjunction with the Edit Code in source field.
column 38. An entry of '*' shows that all leading zeros of
the numeric field are replaced by the asterisk character • A floating dollar sign is provided if the dollar sign is
(asterisk fill). '$' indicates that a dollar sign is placed just encoded immediately preceding the zero suppression
preceding the high-order nonzero digit of the numeric output code (zero or asterisk).
field (floating dollar sign).
• A fixed dollar sign is provided if the dollar sign is
Asterisk fill and the floating dollar sign are com monly used encoded in column 46; i.e., the first character in the
for check protection. body of the edit word.

• Any editing characters other than a fixed dollar sign are


replaced by blanks (or asterisks if asterisk fill is used) if
EDIT WORDS they appear to the left of the most significant digit of
the output field. If zero suppression is not specified by
The edit codes in column 38 plus dollar signs and asterisks an asterisk or zero, all constant editing characters in
provide normal editing of typical numeric fields. An edit the body of the edit word to the left of the most
word, however, allows more unusual or complex editing of a significant digit are suppressed by blanks.
numeric field. An edit word is like a mask or framework
that allows insertion of characters from the source field
named in columns 32 through 37. Through an edit word the
• The sign of a negative field can be shown by a minus
sign or the characters CR. These edit characters are
operator may directly specify inclusion of decimal points, replaced by blanks in the output field if the source field
com mas, zero suppression, negative balance indica tors, is positive.
dollar signs, asterisks, and even whole words between one
digit and the next. • Asterisks or other characters in the edit word to the
right of the characters C R or a minus sign always
The following rules apply to using edit words: appear in the output field.

• Edit words are used only with unpacked numeric source


fields. Columns 32 through 37 name the field.
o The source field length must exactly match the number
of replaceable characters in the edit word, with these
exceptions:
• Columns 38 (Edit Code) and 44 (Packed or Binary Field)
must be blank on the line containing the edit word. - An extra space must be left in the edit word for the
floating dollar sign. This ensures an output record
• Columns 40 through 43 (End Position in Output Record) position for the dollar sign in the event that the output
must contain an entry. field is full.

• An edit word must be enclosed in apostrophes, with the - An extra space may be left in the edit word if the first
leading apostrophe entered in column 45. Edit words character in the edit word (column 46) is a zero. In
are li mited to 24 characters. this case, the source field is not zero suppressed, but
all other specified editing is performed.
• Any printable character is valid in the edit word, but
certain characters in certain positions have the • If a minus sign or the characters C R are used to denote
meanings listed in the lines below. a negative field, the character position(s) used by these
designations must be taken into consideration when
• A blank in the edit word causes the digit from the entering the end position of the field in the field
corresponding position of the source field named in description line.
columns 32 through 37 to be placed in the output field.
Thus, the leftmost blank receives the leftmost Examples of edit words and the output they produce are n
character, and so on. The num ber of replaceable given in table 10--4. U
characters in the edit word must be equal to the length
of the field to be edited. OUTPUT SPECIFICATIONS
• An ampersand (&) in the edit word generates a blank in EXAMPLES
that position of the output field. Various examples of Output Specifications examples are
shown in figure 10-5. The examples are discussed below.
• A zero in the edit word causes leading zero suppression.
The position containing the zero is the last (rightmost)
digit position subject to suppression. LINES 010 THROUGH 190

• An asterisk in the edit word causes zero suppression and Two heading records are to be printed if indicator lP or OA
replacement of suppressed zeros by asterisks. The is on; that is, the two records are to be printed on the first
position containing the asterisk is the last (rightmost) page (lP) and all overflow pages (OA). There is a skip to the
digit position subject to suppression and replacement. sixth line of H new page before the heading records are

10-11
96768710 C

I-'
<:)
I
I-'
t-:I

TABLE 10-4. EDIT WORD EXAMPLE

EXAM- SOURCE
PLE ~5 ~( 60 70 DATA OUTPUT DATA
NO.

t , ~I&t I , I I I" 101 1.1 I 1l1-1~IT 1,s11~~ILI' I 123lJ-5f)7 R9n- .)~12,3lJ-5,f)7R.90 - ~GTAL

2 oonOOOO12J- 1. 2J-
I I I I,. I 11, I I 1.1 I 1-1'1 I I I I I I I
J 1I I 1 I I I I I I I I 1I 1 I I I I I nnOn1JC; h 7 R OnOO1J5 h 7R
4- ooon1.35 fi 7R oOOOtJ5fi78
I I I I I I I I I I I I I I I I I I I I
5 I I I I I I I I I I I I I I I I II I I 00001J5f)78 00OO1.J5f)78
f) , I I, I I ,I I 01-1 I IgC~IJI 1 I I I I I 0000000008 .08 CR

7 I lid
, 1.1
, 10 I-I~IAIV t,4l/lll.4~ LIEI'1 I I 0000000000 o AVAILABLE
8 1 1,.. JIJ ill l . I • I I I-~I' I I *
9
,,. JI I 1'1
I I ..
'
I I,\ I 1I10J -I I ~""'... ". ~,I
1I I I I
I I 1I I
oonooooooJ
00087f)C;4J2-
.".;o.oJ
(987,f)54,J2CR**
to , II I I'..
/
I 1,.. 1 101.1 I III I I I I I I I I
0000000004 .? .04

~ 000olJ-RJ72f) *****4,8J7.2f)
1.1. I I JI
I
I
I" . 1.1 I Igl-I'1 1 I I 1 1I I
12 0000000000
11I I I I 1'1 I I I I I 1 I 1I I I I
1J I I I I 1'1 I I I I I I I 0000432123 4321.23
I I I I I I I I
14 I 1I 1 I I I 1'1 I I I I I I I I I I 1I 00onlJ-32101- hJ21.01

&Ie IRI&ttSILJrBI 17 1~711 I I I


15 I oooo45(i7 R9+ 456789 SUB TOT
1J I I I I
1(1 ,
I I I I I I liatctRl&ISIVIBI IT ~LTL It L 1 nor,n4Sh7[)q- 45f)789 en SUB TOT

t£l-I~J8,.ISJl)JBI IT fJl71 / , sus


17 I on(;oh5f)78O- 4Sf)789 - TOT
I I I
1R , I 11
I I I
I
I I I I'LTldlT~ICIRL I 1 I I I I I
nooohS/)7RQ hs6789

19 I
I I I 1 I I I~tTlfrr~CtRIJ I I I I I 1 nco04C;f)7 R9- 456789 TC,L' Crl
20 , 1 J 1 I I I 1&1&1G1.4I1IM'1 I I I I I I nnnOL;.~h7p'9 !IS(,7 R r: \~AII<
~
en
21
I 1-~ld'1I..41L.11 L 1 I 1 I On()04Sh7G9 ,nnGaL- 5(.7 P9
~
~'C'":'l~I
'ifJ'()1
, fill I I I I ,
en
00 I
~

LL~1:J!Jr~lrL41b
I-'
22
'LLLLL onnc :. c:,f,7 P q- !~ :(.789 - r:'cn~1A.I
o l
(')
- I I I
/

co
0')
~
0')
00
~ TABLE 10-4. EDIT WORD EXAMPLE (Contd)
~
o
()

EXAM- SOURCE
PLE ~5 ~C 60 70 DATA OUTPUT DATA
NO.

23 I~ I I I I I I 1~1-4lruITfAll 'I I I I I OOO04Sh789+ "J 4Sh789 TOTAl·


I
24 I 1 I 1 1ilJc: 1 I~'C,~,/I , I I 1I I I I 0000 4 56789- )4Sh789 CR
25 I I I 45 h78 90123- :)4567890123 CR
I I '#It] I I&IC,RI'I I I I I J 11 I
2f)
'Iii I I I I 10 I 1c~ICIRIJ,ITll2J'1 T 1.4 L.I'I I I I 0000000000 'I 00 TOTAL

27 , I I I I I I 101', , , 1 I 1 1 J 1111 I 00004'5(;789- 456789


28 I 101 I I I 11 J 'I I I I I I I I I I I 1I ooo04S67R9 0004St17R9
29 I ~ I I J 1 1 JI I I I I I I I 1 I I I I 1 0000456789- ~:'0004 Sfi789

30 • ~I I I I I 1 I' J I I I I I I 1 11 1 1I 3h5 h 7R9012 3 4 5t17R901.2


31 , I 11 I , I ~1/1 I I I I I I I I I I I I 0000456789+ *'*<**456789
32 I I 1 I" I L~
, IOJ I .. I I 1~ITlOIT IA ~ 1'1 I I I· 00000000 5 :~O. 05 TOTAL
33 I I 1,.. 1 1,.. 1 1 1.1 I ~k:IR~I-lr 0$1 TIf1-IL I' I 0000456789 4,St17.89 -TCTAL

34 I
I I., I 1,.. 1 1 1.1 I 18,ICIRI~I&IT tilT iii IL. I 'I 0000456789- 4.,S67.89 cn TOTAL

35 I I I,\ I ~II I .U'._.~ / .... ~, I 000045h789 "*****4,567.89 ***


1.1
, J • ~""""'V'I"I I I I I I
36 0000002345 :i;, 023.45 SOH
I I I I .. ~OI,... 1 1 I. I I 1-ISI~IJlI' I I I I I
37 '~I&I I' 1\ I I I ,.. I 101. I I ClfO' I I I I 11 123 4 !:)h7890- : 12,3 4 S,fi78.90CR
38 I 1... 1 I 1.1 I I [.oJ 1 I 1-IBLHILI2"c: ,.,J°JQl'l I t23 ll 5h7890- 1. ,234,567, 890-DAL FrJHD
, I' I'
39 I 1,,1 I I ,I 101 1-IBL4ILI~IF IWlRIDI'I 1 OOOOO()0000 o BAL F:..iED
I", 1 I
V I'
'-~O OOOOOOOOOt1 ;':.Oh
, 1 I I"
., 1 1
,..1 fglOI .. 1 1 1'1 I I J 11 J I I
41 987(; Sl~321 0-
I I I I, lW ttOI .. I I I-I IJ I I 11 1 1 I ·.:98,765,432.1.0-
LJ·2 I
I)OO12345 h7- .,,: 1. 2 , .3 11 5. h 7C H
I I " I 111
,
'11101 • 1 I ICIAI'I 1 I I I I I
II3 I 1.',11 O()OOll~h78q It, 5h7~c'LI k,{S7RCi:.:. r,':~
I hi
. I !DIm Ill! J..9!,fISI I ClEWIrIS1'
..... I
o
~
I
44 1'\1 1 lotd~ iaJ81SI I ICl8Nlns "J I I I 0(,('000 ,..,.
V
: ;n-'
i~.i·.. 1. ")

""


.....
o
.....I
"'" TABLE 10-4. EDIT WORD EXAMPLE (Contd)

EXAM- SOURCE
PLE ~5 ~( 60 70 DATA OUTPUT DATA
NO.

45 I 1.,•. 1 IfJ 'Drill II. IAI~SI


I
1 ICIBNrTI5 19z9,CIRI'1 I 000000 ODOLLARSOO
46 I la J I- I-I I 1. 23 4 5h7R 12-34-5678
I 1'1 I I I I I I J I I I I
47 I Ql IUI~ l~ 1 I ~ I/INI51. \&'ldl','ICIl. ~lCIk1/ I 0042 OHRS.42MINS. O'CLOCK

1I I I I I I I I 1 1111 1 11 I 1I
111 1 1I I I I 1 I 111 1 11111
1I I I I I 1I 11 I I I 1 I 11111
I I I I 1I 11 1I I I I I I 1J I I I
1I I I I I I I I I 11 I I I I , , I I

111 I I I 11 I 1I I I 1 I I I I I I
I I I I 1I I I I 1 I I I I I I I I I I
J 11 1 I I I I I I I I 1I I I 1 1I ,

jll I I I I I I I I 11 I I 11111
I I I I I I I I I I I I I I I I I I I I
III 1 I 1 I I I I I I I I I I I I I 1
111 I I I 1I 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 j I I I I I I I I I I I I I I I I I I

I I I 1 , I I I I 1 ILl L 1 I I 1I I
I I I 1 1I I 1 I 1 I I I I I l I I I I
I I I I I I I I I I I , I , , I I I I I
to
m
-::J
m
00
-.J
JJ 1 I I I I I I I I I I I I I I I I I
.....
o I I I I I I J I 11I I I I I I , I I I
()
printed. Notice that the skip/space specifications are not Two types of total records are shown. The record described
repeated on the OR lines, in lines 140 through 160 is printed at total time when
indicator L1 is on. The record consists of a subtotal of the
Lines 030 through 060 show what is actually printed in the amounts and an appended asterisk. The subtotal is reset to
first heading record: the constant SALES REPORT, the zero after the record is printed.
date, the constant PAGE, and the page number. A Z edit
code is used to zero-suppress the page number. A Y edit The grand total record described in lines 170 through 190 is
code inserts slash punctuation in the date. The column produced only once: in the last total output time.
headings SALE and AMOUNT are printed in the second
heading record (lines 070 through 100). The absence of a Note that all heading records for the file are described first,
skip specification indicates that the second record is to be followed by all detail records, followed by all total records.
printed on the same page as the first heading record.

Only one detail record format is shown. The record is


produced whenever indicator 10 is on. However, the record LINES 200 AND 210
contains an ITEM entry only when indicator L1 is also on
(ordinarily when a level 1 control break occurs). When L1 is A record is to be added to the disk file, DSKFIL, if
not on, the field AMOUNT is the only field in the record. indicator 77 is on at detail time. The record consists of a
single 80-character alphanumeric or unpacked deci mal
numeric field named NEW REC.

CONTRPL DATA RPG OUTPUT SPECIFICATIONS


CORPORf.TION
1 2 75 76 77 78 79 60

P'CjI!~Of_ ~:;~f:lI,on 0 IIIII

-
o -"
lr Space

~~I-r;-~--~--'---'---~
Skip Output Indicators

.e -
Line Filename ! ~ j ~
~ ~ ol! ~
I- Vi
~ro~ j ;; Constant or Edit Word
~~t- 4 ~ Z ·AUTO

il !
AND
3 .. 5 6 1 8 9 1011 1:7 13 1415 16 17181920 11 n 23 ]4 ]~ 16 27 28 19 JO 31 n.13 34 ~ 36 37 J8 b9 4041 4243 44 4~ 464148 49 ~O ~1 ~2 SJ 54 ~5 ~5 57 58 59 60 616] 6J 6465 fi6 67 6R b'3 7() 7t 12 73 14

: ;~:I~IRn-~!:rIL I"~ I~~l~ I-tl~--'- f- - ~ I-I--i-I-I- I- -jl ~ ! I !~! j I!j 1ii if!I~~t f l~.j., I j ;.1 -1--1-

1)",- - I - ~ f-r-- ~~ t ~~ r- :l" ~~ ~jJ --f~I I-~-f- I-UIl: ATE Y~I-.-- I- \ 1


12141- j,sr [E t
Rl"lrIGlRlt' i
tj H t ~ ~t t I " ~
~ f- ~ - ~I'Lt-t
I
f I-- j f! -
a 3 C 0 II 1---1-

::- ~ Q () I-~ I 1 t Ij~ f


I-- -1- - 1-1-

j:
I-
4'7 1 I-

Ii
I t J t [ j j j + ,

j' , -I-r---I-
a 5 I'" 0
a
f-C- "'" -

:!-~c 0
6"" 0

- -
f
I
I
-
t

~
f-
- .- -
-

~
-

Iz
f-j--
-I-,
-f- 1
j -

P
f--
c--
~-
PAGE
- I-
12.
I-
-

I~
2
i-
~ I!
II

f
PIA

j )
I,:
l....
j
IJ'
I

j it:
I
,I
j

j 1 I
!

I
l
:
I'
! t • t
, . :
!!
I I

I
I
f t,
1

I
j ,'I

I 1 t
i
t r t
! ; '- . i 1':
! I tit
-+---1--+--+-l

-f---

--'----
~~ ~Ih
t t I,
a 8 Jr, 0
~ 9~ 0 I- --f- H*r--j-
1

--. - -- lu-'
II r

t
1
I I 1
!
'f j i -- --i

1t1~
1- i- t j ,tt

-;--;;-~o -- f- . 1-1 e-1--f-1- -~-- b!~ :tA"'IAjL; I,ll 1,1 \ J: I : , ; \ it + it -,---


-

llPO
~~- r- - .12- -.1 1- ~--
~C
- -- - - j II - j M.'~;tJ NiT:
' ' i ! ii, I I
Itt!
I
t ! 1, I ~j, +. ! -+ -+-
• I'I
~;I,:(; 1 -. .1- i '1:1-reM _, ! t l.u - 'Ti j--t t T' . T-~, I
t+1 ;-:- - - - -
-- - ~ r
I- j t + +

~ ; ~'o f--
l - ~~ .-- j -12 1~ - !r I' !! t i ' j r ~ t~ i I -: j
!! j
!

11"1 ----h - ~j-- t - ,~~ A.~.1 __ c- ~f-- If -, II


- 1 ~----i+--~-~-~j t t-~+--.--
I~
i

~~~~H- -- ~'-+-- rr ~-lllj --' - ls'IL.erraI1l~rp: 12lfl- I ! I r--J. r- I-t- ~- +- ~' ' 1--1-1--1-
.

1 6 0 0 I~ ~1 'I-.. '
1 7 P0 for I; c--I- - -I-:LI~I- - -I- - ~ +-
11 8 !~ 00 _I-- _, I- I- _~ ~ __ ,_ ~ _ _~ ~ I-- rT'ar JIl. ,~ --+IZ-+4:-t·-t--t--f--+-+-+,~- - l-
9 lL '".-- ~. 1-;:: ~~ I- I ~~ I f

2 a Ie 0 1D1-sll<i FlIll tDlA 1I In 7 1'7 +-+-+-++-+-+-- f-f-


o
I-+-+-+-l--+-+-I--+-+-+-l-++--~ ~-+--+-+--+-,- 1-1- '--
o I
I

Figure 10-5. Output Specifications Examples

10-15 I
96768710 C
OTHER RPG II INPUT FORMS 11

Section 4 references alternate collating sequences and file TABLE 11-1. PLAYGROUND EQUIVALENTS
translation tables. File translation applies to input, output,
update, and combined files where the external character set Letter of Hexadeci mal Number Hexadecimal
(used on the input/output device) differs from the internal Code Word Equivalent Equivalent
character set (used inside the computer). With file
translation, RPG II translates the input characters before P D7 0 FO
using the data and the output characters before they are
written out. L 03 1 FI

An alternate collating sequence may be defined to vary the A Cl 2 F2


collating hierarchy of the internal characters on an external
medium. Y E8 3 F3

Specifications of file translation tables and alternate G C7 4 F4


collating sequences are submitted to the RPG II compiler
with the source program. Preprinted forms are not provided R 09 5 F5
for file translation tables and alternate collating sequences.
However, this section describes these specifications as other 0 D6 6 F6
RPG II input forms.
U E4 7 F7
Proper placement of alternate collating sequence and/or file
translation specifications in the RPG II source program is N D5 8 F8
shown in figures 2-1 and 12-3.
D C4 9 F9

NOTE: Translation characters are specified in


FILE TRANSLATION TABLES internal code (table D-5).
The internal character set used by this RPG II system is
listed in appendix D. If a file referenced in a source
program is produced by or will be used by another computer
system, character translation of the entire file may be
called for. POSITIONS 1-8

Another application of file translation occurs when, for The characters *FILES~b indicate that all input, output,
security reasons, certain information in a file needs to be update, and combined files referenced in the program are to
encoded into an unidentifiable character set on the external undergo translation. (For update and combined files, botll
medium.. As an example, a program may process an input the input and output processing of the files include
file containing confidential wholesale prices paired. with translation.)
retail prices. File translation could apply to the wholesale
price field so that only selected store personnel would be A left-justified filename indicates that this individual input,
able to identify the store's price markup. Substituting a output, update, or combined file is to be translated (in both
code word containing 10 distinct alphabetic characters (for the input and output phases, if this is an update or combined
example, PLAYGROUND) for the digits of wholesale prices file). More than one individual file may be translated when
would produce the desired encoding. Using the code word translation records are entered for each filename.
PLAYGROUND, the letter P represents the number zero, L
represents one, and so on. A wholesale price of APP.UN in
the input file would translate to 200.78, that ls, two hundred
dollars and seventy-eight cents. Typically, the code word is POSITIONS 9-10
a combination of letters that is easily remembered by store
personnel. Ten distinct letters are required to represent the Enter the hexadecimal equivalent of the external character.
ten digits 0 through 9. Hexadecimal equivalents of each This is the internal code corresponding to the character on
letter in the word PLAYGROUND are listed along with the the external medium.
hexadecimal equivalents of the numbers 0 through 9 in
table 11-1.
To indicate that there are files to be translated, enter an F POSITIONS 11-12
in column 43 of the Control Card Specifications sheet. File
translation table records must also be used to specify the Enter the hexadecimal equivalent of the internal character.
exact nature of the translation. The format of each file This is the form the <;!haracter is to have during internal
translation record is as follows. processing.

96768710 A 11-1
POSITIONS 13-16, 17-20,21-24 There are several ways to alter the normal collating
sequence. One character may be inserted between two
Each set of four positio.ns up to the end of the record other characters; a character may be completely removed
specifies successive pairs of two-digit hexadecimal repre- from the sequence; or the positions of two characters may
sentations - first external, then internal. be exchanged. A common application for an alternate
collating sequence is to give the same hierarchy to zeros and
The rules for including file translation tables with the source blanks. An alteration of this kind causes an equal
program are as follows: comparison for fields containing 00256 and M256.
• The file translation records immediately follow the
RPG II source program specifications lines. The first NOTE
translation record is preceded by a single record with
the characters **~ in positions 1 through 3. Other 00256 should remain equal to 00256 and
positions in the **~ record may be used for comments. }f>256 should remain equal to }f>256.
•. The order of characters in the translation records is not
significant except that the pairing of character repre- In this application, only a single entry needs to be made in a
sentations is mandatory. single ~ternate collating sequence record.
• All records for a single file must have identical entries Character insertion in a collating sequence, however,
in columns 1 through 8. requires more than one entry. The number of entries
required depends on the number of characters affected by
• All translation table records for one file must be kept the insertion. Thus, if the character zero is to occupy a
together. collating hierarchy higher than nine, but all other
hierarchies are to remain intact, ten entries are required in
• A file translation record is terminated by a blank the collating sequence records.
character or end-of-record.
The following sections describe the format for each
The file translation record for using PLAYGROUND as the alternate collating sequence record.
code n~me for all files referenced in the program would be:
Column Entry
--- POSITIONS 1-8
1-8 *FILES}f>
9-12 D7FO Enter ALTSEQ~~ to indicate that this is an alternate
collating sequence record.
13-16 D3Fl
17-20 CIF2
21-24 E8F3 POSITIONS 9-10
25-28 C7F4 Enter the two-character hexadecimal representation of the
29-32 D9F5 first character whose hierarchy is being defined.
'33-36 D6F6
37-40 E4F7
POSITIONS 11-12
41-44 D5F8
45-48 C4F9 Enter the two-character hexadecimal representation of the
first character whose hierarchy is being used.
Only the letters in the. example have been specified for
translation. All other characters are processed in the
normal manner. File translation is important to the
example, as the characters in the code word PLAYGROUND POSITIONS 13-16, 17-20,21-24, •••
would be nonsense in arithmetic calculations.
These positions are used in the same way as positions 9
through 12. Enter as many pairs of characters as the record
can contain.
ALTERt~ATE COLLATlt~G
SEQUENCES As many records as are necessary to define the alternate
coUatIng sequence may be used; each rec.ord must conform
A collating sequence defines the relationship between one to the above format.
. character and every other character used in a program. The
normal (default) collating sequence of characters is defined The following are the rules for including an alternate
in appendix D. collating sequence with the source program:
When column 26 of the Control Card Specifications sheet • Alternate collating sequence records follow the RPG II
contains an S, alternate collating sequence records must be source program specifications lines and file translation
supplied to the compiler. records, if any. The first alternate collating sequence

11-2 96768710 A
record is immediately preceded by a single record with Record 2
the characters •• ~ in positions 1 through 3. Other
positions in the •• ~ record 'may be used for comments. Entry
• The order of characters in a record is not significant, 1-8 ALTSEQ~~
but the pairing of characters is mandatory. 9-12 F6F5
(6 takes 5's position)
• Positions 1 through 8 of 'continuation records contain
ALTSEQ~~. . 13-16 F7F6
(7 takes 6's position)
• An alternate collating sequence recofd is terminated by 17-20 F8F7
a blank character or end of record. (8 takes 7's position)
The alternate collating sequence record for assigning the 21-24 F9F8
space character to the same hierarchy as zero is: (9 takes 8's position)
25-28 FOF9
Column Entry (0 takes 9's position)
1-8 ALTSEQ~l$
Two records were used to illustrate using more than one
record. It is valid to enter all pairs of characters on one
9-12 40FO record. When the hierarchy of a nonprintable character is
(Blank takes the O's position.) being used by a printable character, it is not necessary to
assign another hierarchy to the nonprintable character. For
To cause zero to come after nine in the hierarchy, use: example, if a character were being inserted so that the
character 9 assumed the hierarchy of the (nonprintable)
Record 1 character represented by FA, it would not be necessary to
Entry include the pair FAFB, and so on.
Column
It is valid to include the two cases described above in the
1-8 ALTSEQ~~
same compilation.
9-12 F1FO
(1 takes O's position) Alternate collating sequences apply to matching fields,
13-16 F2-F1 sequence checking of files, and the COMP operation code.
(2 takes l's position) An alternate collating sequence is ignored in numeric
comparisons, look-up operations, and control levels.
17-20 F3F2
(3 takes 2's position)
21-24 F4F3
(4 takes 3's position)
25-28 F5F4
(5 takes 4's position)

96768710 A 11-3
USE OF TABLES AND ARRAYS IN 12
RPG II PROGRAMMI NG

The specification of tables and arrays was described in • Pre-execution time table or array - A pre-execution
section 6. This section describes the formation and usage of time table or array is loaded with the object program
tables and arrays. just prior to the actual execution of the RPG II object
program; that is, before the first input file is read. A
Tables are systematically arranged sets of information that pre-execution time table or array may be modified by
are more limited in scope than files. RPG II treats tables in the object program and output at program termination.
much the same way that clerks do in manual systems. A
document (or record) provides a piece of known information • Execution time table or array - An execution time table
such as an employee's identification number. The clerk (or or array is read or created during the input or
RPG II) uses that figure to obtain another piece of informa- calculations phase of an object program cycle but
tion from a table by search or lookup. Employee number cannot be output at program termination by RPG II. (It
may be used to look up the corresponding tax withholding can, however, be output by the object program.)
rate in a table of rates listed by employee number.
• Related tables and arrays - Related tables and arrays
Tables are also used simply to provide verification of a piece are tables and arrays that are used together. The items
of data. For example, a table of employee numbers may be in each table or array are called corresponding entries;
used to validate an input employee number. each item in the second table or array gives additional
information about its corresponding item in the first
Table elements may be extracted and used in calculation table or array. Related tables and arrays may be
operations. RPG II allows table updating, where entries may specified separately or in alternating format. Where all
be changed during processing. For example, a new items in one table or array must have the same
withholding rate may be substituted in the withholding rate characteristics (element length, etc.), related tables
table wh~n an employee changes his W2 form. and arrays need not have identical characteristics, nor
must they contain the same number of elements if they
Arrays are also systematically arranged sets of information are specified separately. When a search of related
that may be searched for a uniquely identified data item. tables is successful, corresponding items of the two
Unlike tables, an array element may be referenced by tables are brought to the holding areas. A successful
position number (its array index). Another difference is that search of related indexed arrays causes the index field
an unindexed reference to an array name is a reference to to point to the corresponding items in the related
the entire set of data; a reference to a table name is a arrays.
reference to the table item currently in the table's holding
area. An array element or an entire array may be used as an • Short tables and arrays - A short table or array contains
operand in a calculation operation. some null elements. For nonsequential (neither ascend-
ing or descending) tables and arrays, null elements equal
The advantages of using a table or array format instead of zero if numeric, or blanks if alphanumeric. A short
other file formats are that a table or array is compact and table or array may be created when all significant table
may be completely contained in computer memory during or array items are not available when building the tabl~
runtime for random accessing, and that table and array or array, and the other significant items are to be added
entries may be used repeatedly during the course of later. A short table or array must have at least one
processing by an RPG II. object program. non-null element.
Table names begin with the characters TAB; array names do o Full table or array - Every element ofa full table or
not. Both types. of names follow the rules for naming fields. array contains significant data.
Each element in a single table or array has the same length,
format (numeric or alphanumeric), and number of decimal An example of using related tables is illustrated in
positions. figure 12-1. A medical billing file (1) is sequenced by
procedure code within record type within account number.
Following is a review of some definitions r~lated to tables There is a type 1 record for each patient and a variable
and arrays. number of type 2 records. The type 1 record shows a
patient's name, address, and account number. Each type 2
• Compilation time table or array - A compilation time record gives a treatment code, the date the treatment was
table or array is compiled with the source program and administered, and the patient's account number. Treatment
becomes a permanent part of the object program. This codes and associated treatment prices are maintained in
type of table or array can be permanently changed only related tables (2). The treatment code from the type 2
through recompilation of the source program with the record is used as a search argument for treatment price
revised table or array, but the table or array may be from the price table (3). The prices extracted from that
output at end of job, if requested on form E, any time table are summed, and the patient is billed for the total.
the object program is executed. Two methods for specifying the related tables are shown in
figure 12-2.

96768710 A 12-1
TREATMENT TREATMENT
G) CODE PRICE
SEARCH
ARGUMENT~ 2 800
IS 19 ~
19 2100

38 750
2 200
39
2
2
··
· ··· ··
·
99 1700

RECORD TYPE
o RELA TED TABLES

...._ _ _ _ _• TREATMENf CODE


......_ - - - - - - . TREATMENT DATA
' -_ _ _ _- - - - - . ACCOUNT NUMBER

/ 00201 NAME ADDRESS I

RECORD TYPE
--. ACCOUNT NUMBER

o MEDICAL BILLING FILE

0308
Figure 12-1. A Use for Related Tables

FORMI NG TABLES must not be confused with the table or array name described
AND ARRAYS earlier in this section. Table and array files may be assigned
to the same device and even have the same filename if they
Tables and arrays may be formed inside or outside the are read from the same device. Table and array files are
computer. Elements formed on the outside may be entered read in the order the tables and arrays are specified on
through any input device. Any computer program, including form E.
an RPG II program, may also form them, and they· may be
output to any sequential file medium. Tables and arrays
have the same format and structure rules whether they are
formed inside or outside the computer. The complete set of COMPI LATION TIME
entries comprising a table or array is considered a sequen-
tially organized file, although the entries need not be in When tables and arrays are loaded at compilation time or
sequence within a table or array. pre-execution time, the entire table or array is loaded
before the first input record is read by the object program.
A table or array file must have a unique name consistent
with the file naming rules listed in section 1. The filename

96768710 A
12-2
• • • 99

TREATMENT
CODE
TABLE

.01700

TREATMENT
PRICE
TABLE

DEFINED SEPARATEL Y

TREATMENT
CODE AND PRICE
TABLE

TABLES DEFINED WITH ALTERNATING FORMAT

Figure 12-2. Two Methods for Defining Related Tables

Compilation time. tables and arrays are compiled along with • Compilation time tables and arrays must have entries in
the source program, come from the same input stream as columns 33 through 35 (Number of Entries Per Record)
the source program, and, thus, do not have a From Filename and must not have entries in columns 11 through 18
column entry on the Extension Specifications sheet. Here (From Filename) on the Extension Specification sheet.
are the rules for entering a compilation time table or array,
• Numeric tables and arrays must be in unpacked decimal
• The table or array must be on the same device that
holds the source program and must follow the RPG II
format.

source program, file translation tables, and alternate The proper placement of compilation time tables and arrays
collating sequence records, if any. in the compiler input stream is illustrated in figure 12-3. In
this example, the user has a file translation table, alternate
• Each distinct table or array must be· preceded by a
record having **kS in positions 1, 2, and 3. As this
collating sequence records, and two of his own compilation
time arrays, ARRX and ARRY. The file translation table
record is a delimiter, the first element of a table or and alternate collating sequence records are optional and
array record must not contain those characters in the because of that are illustrated with broken lines. If either a
first three positions. file translation table or an alternate collating sequence, but
not both, is included, it must precede the user's tables and
• The last compilation time table or array is followed by arrays. If both are included, the file translation table must
I a record reading /*~in positions 1,2, and 3. precede the alternate collating sequence, as shown in the
illustration.
• The tables and arrays must be loaded in the same order
as described on the Extension Specification sheet.

96768710 C 12-3
NOTE: ~= BLANK

0310
Figure 12-3. Placement of Compilation Time Tables and Arrays

PRE-EXECUTION TIME EXECUTION TIME

Pre-execution tables and arrays are not part of the source Execution time table and array files are read by the object
program. They are used by the program like any other data program and can only be described as any other input file on
file. They differ from execution time tables and arrays, form I. The definition on form I specifies whether the file
however, because they are loaded by RPG II prior to has a single record or many records, and whether or not the
execution of the object program. elements are contiguous in a record. If the unindexed array
name appears as the field name on form I, then the array is
Here are the rules for loading pre-execution time tables and contained in one record and the elements are contiguous. If
arrays: the elements are not contiguous, each element must be
specified on its own form I line, with the appropriate field
• A record containing 1* in positions 1 and 2 must follow positions specified.
each pre-execution time table or array.
Such a table or array may not be used until every element
• Pre-execution time tables and arrays must be arranged that is required for program execution is in core. Calcula-
in the same order they are described in the extension tion and output operations, therefore, may have to be
speci fications. suspended for several program cycles until the object
program has read all of the records from the file.
• A pre-execution time table or array must have entries
in columns 11 through 18 (From Filename) and 33 The extension and input specifications required to fill an
through 35 (Number of Entries Per Record) of the execution time array from contiguous elements of a single
Extension Specifications, and may have entries in input record are shown in figure 12-4. Using the same
columns 43 and 55 (Packed or Binary Field), if appro-
priate.

12-4 96768710 C
RPG
g~ CONTRPL DATA
CORrQRt\TlON
EXTENSION AND LINE COUNTER SPECIFICATIONS Printed in U.S.A.

1 2 75 76 71 78 79 BO
Progr....

Progrernmer Date
P.~Of_ :::r:.tion I IIIIII
Extension Specifications

E Record Sequence of 1he Chaining File

Number of 1M Q\aInIng Field


Number
of Number I!!- Table or
:1 ~ ~
~ length
Table or
Una
!
ToFllllfllme
ATriy Name ....
EntrIeo of
Entri.. of ATrayName of Comments

:i I E
(AI_ting
From Filename Record P.-Table Entry
Format)
Entry a:
::r I
! or Array
~~j ~ j

RPG INPUT SPECIFICATIONS PrInted In U.S.A.

1 2 75 76 77 78 79 BO

Data
PIIJI~Of_ =~;:tionl IIIIII
Record Identification Codes

~
I Field Location
~ j~.---I
Field
Indicators

~ :~ J
Line Filename
i ! - f:~
. -; e. -, "
~l
Position _
~e~
!! Posilloll _ ~
~e~
Position -
~e~~::r
!
I
a; II: From To
j Field Name
] ~~
I r~ c!
i Zero
Plus MiIM or

r-~""~8
~.!!.I-z
~
a:
~ S~ ~S6 ~sa.;;~ J a ~d ~
811nk

3 4 5 6 7 8 9 10 II 12 13 ,~ 1~ ~ 17 18 19 20 21 :n 23 24 25 28 27 28 28 30 31 32 33 34 35 38 37 38 39 40 41 ~2 43 44 41 . . 47 48 49 50 51 52 53 54 55 56 57 58 &9 60 61 62 113 64 65 66 .7 • 89 70 7t n 73 74

o 1 it" :I1~IQIt:ITII E lcii

Figure 12-4. Input Specifications for Contiguous Array Elements

extension specifications, input specifications for array ele- of form E must be blank for execution time tables and
ments separated by one character are shown in figure 12-5. arrays; that is, the table or array cannot be output at end of
Finally, using the same extension specifications, input job by RPG ll.
specifications for the array when the elements are separated
by one-character index values for the array are shown in An example of building an array during the calculations
figure 12-6. phase of execution is shown in figure 12-7. The array is to
contain the square roots of the numeric values found in two
Execution time tables and arrays are not checked for input records of different types. The first input record has
sequence, but column 45 of form E (Sequence) must contain the character A in position 80. The second input record has
an A or D code if high or low LOKUP is specified for the any character except A, including blank. in position 80.
table or array.
If the execution time table or array is in packed decimal or
binary format, an appropriate entry must be specified in USI NG TABLES AND ARRAYS
column 43 of form I. The length specified for tables and
arrays 1n these formats reflects the packed or binary length This section further investigates how to use the specified
of an element, in numbers of bytes. Columns 19 through 26 . tables and arrays.

96768710 A 12-5
CJ 1:\ CONTRPL DATA RPG INPUT SPECIFICATIONS Ptlnt~ In U.S.A
\:I ~ CORfO~110N
Program 1 2 75 76 77 78 79 80

Date P.ge~Of_ ::~:~f:alion IIIIIII

~
I
Line
!
I-

!
Filename

o~ . . JI i
l Z

~
.~
~
2'.

r~
a:
I'IIIitIon
1

~e
~
Record Identification Codes

Sl .
" . f'oIidool
2

~j ~ II~
~
PosItion
3

i~
~) a:
xi~
~U)~
Field Location

From To
,
I
Field Name
~
~
]
J
0

..ji j
f:f
~ll ~
~
I
II:

II
Field
Indicators

Plus iMi_
Zero
or
Blank

3 4 5 e 7 8
f;:~~
t 10 11 12 13 14 ~e I. n " 1920 ~1 22 22 24 25:1e 27 . 2 t 30 31 3233 34F-383738 3940 41 Ie 43 44 48 48 47 48 49 50 51 52 53 54 55 56 57 58 !Q6O 61 62 6384 6566 8781 6970 7172 7374
o 1 Ie: 1 IAIQ 11= IT II Ie AI~ ~1.1
o 2 leI
II It; IA!RI~ 1.1
o I"
3 1 8 li'3 IA Rtr ~
o 4 Ie 1 lis 1:2lc I~/~ y 3
-0 5 01
1212 121 ~l y"I~
o 6 ~I I~ (j l':ill.! IAR Iyl"'~
o 7 ~I
B~ 'Ij A/'<: ~I"I'
o 8 Ie 1 ~r.- 4~ AR rrl ..J~
o 9 ~I
ISle 5) IA~ r~'"' ra
1 0 1 I'
- - -
Figure 12-5. Input Specifications for Scattered Array Elements

CONTRPL DATA RPG INPUT SPECIFICATIONS P',"led In U.S.A.

CORfO~110N
1 2 75 76 77 78 79 80
<:.rd Electro Number

D.te
P.ge~Of_ :::~f~calion IIIIIII

~
I
Line
~
l-

...~
Filename

- 'i-
0
!"

',1.
..

ii i
.1
~
2'.
;r.~
j
II:
~'
1

~e
~S
Record Identification Codes

"

l
I'I:IIIdooI
2

i~ 1
PosItion
3

-
j~ ~J
~) a:
Ii! • iii
ii:
~
Field Location

From To
,
1
~
Field Name
~

3
J
15
~ :3ioS
~~
f:~ J
~ll ...
I
II:

j
Field'
Indicators

Plus Minus or
Blank
Zero

Ai i n
3 4 5 e 7 8 9 10 11 12 13 14 ''1. ,. 1920 ~1 22 23 24 25 :Ie 27 21 2t 30 31 3233 343131137311 3940 414:1 43 44 48 48 47 48 49 50 51 52 53 54 55 56 57 58 6960 61 62 6384 65 ~ ~7 ea 6970 7t 72 73 74

o 1 ~I I,; ~A 01
o 2 ~I
~ tLr 1"l11
o 3 1£)1 ~ 11 l4A ~ . crl1
o 4 I,. 1 lao 1I~
o 5 Ie 1 111tJ ~~ Y. t:I~
o 6 I" 1 ~ bts 1,1I~
o 7 Ie :I ~.~ 1~l:J. IA F! Y I:I~
o 8 Ie 1 ~2 2t Ilr~ .
o 9 It 1 12~ Iple IA~~ l.llij
1 0 01 ~A 12A Ir~
11 Ie 1 ~ [35 tAR ~ I, ~~
LJlf :I'
1 2 Ie 1
~ ~~
!, .

I
1 3 ~I F r,j ~IJ( VI_ l:t/'
1 4
bI I
1-:: ~I:: llllJ
1 5 Ie 1
r;"
I
.''.
N ~~ 1A1~ rl, I7rJ
I
1 6 Ie 1 I ~ ~ Isle I'rF
1 7 11"1 t, , ", . I··'
lSl1 lsi' IAI~ rl . I:r~
1 8 1 I> . F ,

- ". I.e ,--

Figure 12-6. Input Specifications for Array Elements and Indexes

12-6 96768710 A
~DATA RPG EXTENSION AND LINE COUNTER SPECIFICATIONS
g5) CORrO nON
Printed In U.S.A.

I::~ I I I I I I I I
7578n7871lBO
' 2
[QJ!) :::'ticx11 I I I I I I
Pro.,.I111 Punching Clrd Electro Number

I'Jopnmer IDa~ Instruction


Pegt of_

Extension Specifications

E Record Sequence of the Chlining File


Nu....
NumbIr of 1M 0wInIne Field of Number 1- Table or
... l~ ~
lAngth Length
Table or Entriel of knyName Comments
To Filename Entries of of
Array Name
~1i
Entry IA/hnwtIng Entry C
Reoord Per Table
From Filename or Array
~~1
~I ~
~ J

CONTR..Ol DATA RPG INPUT SPECIFICATIONS • PrU\led In U.S.A.

CORr(jRi\TION I 2 75 76 77 78 79 SO

Date
PIgI~OI_ ::~-;:li,",1 IIIIII
Record Identification Codes
I ~ , Field Location Field
Indicators
r-- ~ 2 3

.[:
j
~
~
0

:2~
I
~
Line

...~
Filename
1. Z
1j-
'SIS
::0 ~ I"INitlon t
g e 1i
Poeidon - !! PosItion t j~ From To
Field Name
] ~~
i:~
j Plus iMlnul
Zero
or

~
.
rei 'R~
t;; ~ro
if j ~ S~ ~~~ i§ 1iII J
• :J
iii
6 til ii: i ) ~6 il
l! Blank

3 • 5 6 1 8 9 10 11 12 13 14 15 l' 1118 1920 21222324 25 25 21 2121 30 31 3233 343531131311 3940 41 it2 43 44 46 • • 7 .a 49 50 51 ~ 53 54 55 56 51 58 fil60 61 62 5364 65 66 81. 69 10 11121374

o I """I AI~ 11='1,- 'L If IAA h'i IEk: Il'.~


o 2 11"1 I ~ I~ 'ciA
o 3 InI ~ 1.11~ ~IB
o 4 Ie I lS 1~ll rC
o 5 l~ I . 2f IQ~ C·r.
o 6
0 1 fq 13~ O.E
o 7 Ie I 3 1- 4Z OF
o 8 Ie I IAA r.2 lc<r-. "In 11
o 9 Ie I 1 ~OG
, 0
Ie I R i1l~ clu
I I hI 1 c; 2.1 I1II
I 2 ~I
22 2~ elJ
I 3
01 121tf 35 CJK
I 4 • I
. . ~ I

Figure 12-7. Building an Execution Time Array Through Calculations (Sheet 1 of 2)

~768710 A 12-7
CO~OLDATA CALCULATION SPECIFICATIONS Printed In U.S.A.
RPG
CORl'OR(\11ON
1 2 75 76 77 78 79 80
Program

Programmer Date
P.ge~Of_ ~~~;~f:.tion IIIIIII
Resulting

I---
C Indicators Result Field Indicators
Arithmetic

Operation Plus IMinusl Z.ro


Factor 1 Factor 2 Comments
Compare
~ Name Length
Line ~ 1>211<211'2
E lookuplFJctor 2)is
& i i j Hi!Jh Low Equal
3 4 5 G g 10 11 12 13 1. IS 16 17 18 19 20 21 22 23 24 2S 26 27 28 29 30 31 32 J3 34 35 J6 37 J8 J9 40 '1 '2 43 44 45 4~ " 4R 49 50 61 r,4 55 56 57 58 59 60 61 62 6:.1 64 6~ bb 61 (iH ti~J 70 71 17 73 74

: I
ri'J,. . "S~I ~ ,. !A A R f l1'
-- ! ~~~
o 2 ,. C I : i
: : I
: I ! I
,;
I
i
; i ,,
i !
o 7,..,C Ill! ~'1~1 IF lQiR' It. i i ! i i
o 8n C 02 I~ r.,~'-rl Ie ~lA ,'1, I
: I I I I j, !
,
: I i :

! ! I I I ! I

I I ! i
j
:

t1lalri~1L ~Ir :
L

1,
2 0 C ! !
, I I

Figure 12-7. Building an Execution Time Array Through Calculations (Sheet 2 of 2)

SEARCHING TABLES AND ARRAYS number of meaningful entries in a table or, array may be
altered. By the selection of proper search arguments and
Tables and arrays may be searched using the LOKUP crit~ria, the null entries in a short table or array may be
operation code described in section 9. The LOKUP opera- ignored during processing.
tion is the key to a table, since it is this operation that
brings a table item to the table's holding area for subsequent The simplest way to add elements to a short table or array is
use in the object program. to include the new entries on the input records before
execution of the object program. Entries may be added
When LOKUP is used to search an array, an array element during execution, however, through calculation operations or
satisfying the search is not brought to a holding area but, via input records. An example of adding elements to related
rather, the relative position of the element within the array alphanumeric tables is shown in figure 12-8.
is stored in a designated index field. The indexed array
name· may then be used in later calculation and output Any type of table or array may be temporarily modified
operations •. during execution of the object program. This is done by
using the table or array name in the Result Field of an
arithmetic or move operation. This type of modification
lasts through the duration of the job only; the next time the
MODIFYING TABLE AND program is executed, the table or array has its original
ARRAY ELEMENTS contents. Modifications are permanent ol!ly if the table or
array is output as modified and the new records are used the
When elements of a table or array are being deleted next time the job is run, or if the table or array input
(replaced by zeros or blanks) or changed, or when elements records are manually altered before the next execution of
are being added to a short table or array, the number of the object program.
entries in the ta~le or array is not altered; this number is
fixed on the Extension Specifications sheet. Rather, the

12-8 96768710 A
&J 1:\ CONTIPL DATA RPG CALCULATION SPECIFICATIONS Prlnled In U.S.A.

'::I r::I OORrO~nON


1 2 75 76 77 78 79 SO
Progrlm

Progrlmmer Dlle
P.ge~Of_ :~:~ulionl I II I I I
Resulting
C Indicators [' Result Field
Indicalors

- ~
0 Plus ~-Zero
.., %
Arithmetic
IMinUll
Z
Jd Jd Factor 1 Operation Faetor2 Comments
'8 -=!
Compare
Line ~ <t Name Length
1>211<211-2
Q.
I- r£
en , ~i lookuplFaclor 2)is
~ r:i
.....
S
Z j j ~~
High LDw Equal
3 4 5 6 8 II 10 tl '2 13 14 15 t6 t7 18 19 20 21 22 2J 24 25 26 27 28 29 30 31 32 33 34 35 36 37 311 39 40 ., .2 43 .. 45 46 41 48 49 50 51 52 S3 54.55 5& 51 5859 60 61 62 63 64 65 66 61 6S tiy 70 11 12 73 74
o
o
1 ,.,c
2 rlclt
ell rtr,. 1.:0 ~I< t PT :A~~ .,.~ 81v '1" LIQ Ira /, rrlc -
1«;;; ," r,. , ,
~rl ~M l~rA'r
o 3 "'c
rl.1 I'll ~Ia fUe }!IE 'I'll r)lv 1A B~
o 4 Cc ,..,1.1 I','l mQ ~\Je 'II t. 'lJT lliill "lIA 131 ~
o 5 c
" ~ ~

Figure 12-8. Adding Elements to Short Related Tables

An example of altering a table of pay rates is shown in array are references to the whole array, the name may be
figure 12-9. The table has to be modified to renect an six characters long. When an index is used with the array,
across-the-board 3 per cent cost-of-living increase. The pay however, the name may be no more. than four characters
rate table is related to a table of employee numbers, and long.
table items are extracted via the input employee number.
Notice that the 'new rates are rounded by a Half Adjust An index may be a numeric field with zero decimal positions
entry in 'column 53. or an integer literal. When used together, the array name
and index are separated by a comma. But the space
allocated to the array name, comma, and index is six
positions in the input and output specifications and in the
USING ARRAYS Result Field of the Calculation Specifications sheet. (Ten
positions are allocated to Factor 1 and Factor 2 entries.)
An array name may be used in input, output, and calculation This is why an array name is limited to four characters if it
specifications. When an index is specified with the array is used with an index.
name, the elements are referenced individually. A refer-
ence to the array name without an index is a reference to The index to an array may not be zero, negative, or greater
the entire array. than the number of declared entries in the array.
The maximum .length an array name may have depends uPon The following operation codes may reference an array name
the way the name is to be used. If all references to the (with or without an index): ADD, Z-ADD, SUB, Z-SUB,

CONTl!..OL DATA RPG CALCULATION SPECIFICATIONS Prinled in U.S.A.

CORrO~nON
Program

Programmer Da'.
Page rn
1 2

of _ :~:~':ation I
75 76 77 78 79 SO

IIIIII
Resulting
C ~
Indicators Result Field
Indicators

1
Arithmetic
~
~ c:
.g X Plus IMinusl Zero
U Jd Factor 1 Operation Factor 2 Comments

Line
It
,. .....t Name Length ~ ! Compare

~i lookup(Factor 2)i.
I- "0 1>211<211=2
EE j 2 'li
3 4 5 6
.f8 I..10 J 13 14 11 ~i
0% High Low Equal
15 16 17 '8 19 20 21 22 23 24 25 25 27 28 29 30 31 32 33 34 35 36 31 311 39 40 4' .2 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 tiy 70 71 12 73 7'
7
o 1 pC I, . ~m ,II.. -.Ia I.. aII( II. 1FT 118 l4J~ -rA
~" lt17 ~!6 &ltl1 aJ...D ';IA ~c
dr I. 013 I(Ia 11/.7'1 vleLL IA:/i
o lrtc '71 6!A IAl tr6
A
2 ...... ~ rl liN l'l~ fli/ rtll. '11
:'
o 3 c '. "

Figure 12-9. Modifying a Table During Calculation

96'168110 A lZ-9
MULT, DIV, SQRT, MOVE, MOVEL, MLLZO, MLHZO, Any type of table or array may be output through output
MHLZO, MHHZO, MOVEA, DEBUG, XFOOT, and LOKUP. specifications. In these specifications, a table element and
Factor 1 and Factor 2 may not be an array name unless the an indexed array element are treated like any other field
Result Field is also an array name, except wnen the specification. Blank-after codes may be used. Columns 40
operation code is LOKUP or XFOOT. through 43 of form 0 must contain the record position where
the last field of the table or array is to end.
The following operations never reference a whole array but
may reference an array element with an index: COMP, When an unindexed array name is specified as a field name
DSPLY, TESTZ, TESTB, BITQN, BITOF, and MVR. on form 0, the value specified as the end position in the
output record is the position of the rightmost character of
The following rules apply to using an un indexed array name the last element in the array. Any editing specified for the
in calculations: array applies to each element in the array. Elements,
therefore, must be individually specified as indexed ele-
• When Factor 1, Factor 2, and the Result Field specifi- ments if uniform editing cannot be used.
cations are all unindexed array names, the operation is
done using the first element of each array, then the When an edit code (column 38 of form 0) is specified for an
second element of each array, and so on until the unindexed array, two blanks are automatically inserted to
shortest array is exhausted. If the ResUlt Field array is the left of every element of the array. When an edit word is
longer than at least one of the factors, unreferenced specified, blanks are not automatically inserted betwe"3n
Result Field elements are not altered. ' elements. Edit words must contain explicit requests for
blanks wherever they are desired.
• When one of the factors is a field or constant and the
other factor and the Result Field are unindexed arrays,
the operation is done once for each element in the
shorter array. The field or constant is used in each EXAMPLE OF USING AN ARRAY
operation, and unreferenced Result Field array ele-
ments are not changed. This example illustrates the use of arrays on the Output
Specifications sheet and how arrays can reduce the number
• When the ,operation does not use a Factor 1 entry (for of coding lines required in a program. In this program, three
e,xample, Z-ADD), the Factor 2 entry is a field or levels of totals are maintained and output when appropriate
constant, and the Result Field is an unindexed array, control breaks occur.
the operation is performed once for each array element
using the same field or constant in each operation. The A conventional method of accumulating the totals is shown
exception is the MOVEA operation, which moves the in figure 12-10. The fields FDA, FOB, FDC, and FDD are
field into the array disregarding array element bound- aqded (as they are read from input records) to the first level
aries. totals, eLlA, CL1B, CL1C, and CL1D, respectively. At a
level 1 control break, the level 1 subtotals are added to
• Resulting indicators cannot be used due to the multiple subtotals CL2A, CL2B, CL2C, and CL2D, respectively. At a
operations being performed. The exceptions are the level 2 control break, totals CL3A, CL3B, CL3C, and CL3D
LOOKUP and XFOOT operations, where there is a are updated. Total lines are output as control breaks occur,
single result. and totals are cleared to zeros after being output. Since
CL1A through CL1D, CL2A through CL2D, and CL3A
• In arithm~tic operations, arrays must be numeric. Half through CL3D are first defined as Result Fields on form C,
adjusting may be specified with these operation codes. the fields have automatically been initialized to zeros by
RPG II. They do not, therefore, require initial clearing by
the source program.
TABLE AND ARRAY OUTPUT Figure 12-11 shows the same functions being performed with
arrays. The execution time arrays TOT1, TOT2, and TOT3
Tables and arrays may be output in two ways. One way is to are defined for accumulation of the various totals. The
have RPG II write out the table or array just before end-of- output produced by figures 12-10 and 12-11 is identical.
job. This is done by entering the desired output filename in Figure 12-11, however, eliminates most of the repetitious
columns 19 through 26 of the Extension Specifications sheet coding lines of figure 12-10. Since the array elements are
describing the table or array. The table or array is written defined on form E in figure 12-11, the definitions are not
out in its input format and includes any modifications made repeated on form C. Whereas in figure 12-10 the levell, 2,
during execution of the object program. If the output file is and 3 fields are defined with lengths of five, six, and seven
a printer file, a skip to top-of-form should be requested characters, respectively, each element of each array is
following the last output line of any file that is also going to defined as eight characters, for equal spacing on the output
the same printer. This type of output may be requested for line. An RPG II supplies two blanks in front of each array
any table or array except an execution time table or array. element. The equal spacing occurs in figure 12~10 only as a
result of individual end position specifications for each field.

12-10 9~76871~ A
CONTRPL DATA RPG CALCULATION SPECIFICATIONS Prinled in U.S.A.

CORrQPJ'TION
1 2 75 76 77 78 79 80
Program
Programmer Oal.
P.ge~OI_ ~~~;~;:'Iion I IIIIII
Resulting
Indicators Result Field Indicators.
Arithmetic
o - I-::P::-lus""TIM:7."in-u,TIZ:-"er-io
Factor 1 Operation Factor 2 . Comments
;; Compare
Name length ~ ;"""",>-i2r:;;1'~<2T!I''''''''_~2
~ Lookup(Factor 21i5
o High Low Equal
3 4 5 6 7 8 !I 10 II 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 2a 29 30 31 32 33 34 35 36 37 J8 39 40 41 42 43 44 45 46 47 4a 49 50 51 5' 54 55 56 57 sa 59 6061 62 6364 65 bb 61 6H bY 70 71 12 73 74

o ,0 c l110 fall J/J. ~lL .iIA


IAllllD C,L11~ I
o 3 CC lilll I
'A"1lb l:l.lb
(l_
o 5 C C L1 flILI:1 A flLi2 A "it ;}iA
(l1l.l! B AI Ill: £!IL213 "il 218
A'l:lll
o 80 CIL1 I~L~11 {tl~il I
o 90 eli? fJlL fJ, 1 '12

1 'ICc I" ~iL12 I I I !


, 2 hell? f1ll3l: '12 I I
1 3 C i j i i I
I I i I I I I I

CONTRPL DATA RPG OUTPUT SPECIFICATIONS


CORJ'OPJ'TlON
1 2 7576777879110

page~Of_ ==:~lionU
Program
Programmer Oal.
IIIII

~
0 ... "> Commas
Zero Balances
to Print
No Sign CR - X' Remove
Plus Sign
,- Ves Ves I A J V = 0.1.
Ves No 2 B K Field Edil
Line Filename No Ves 3 C L Z • Zero
No No 4 0 M Suppress

Constant or Edit Word

1 6 0
I I I I I I I
I I

Figure 12-10. Accumulating Totals Without Arrays

96768710 A 12-11
CONTROL DATA RPG EXTENSION AND LINE COUNTER SPECIFICATIONS
Printed In U.S.A.
CORPOR(\T10N
Program 12 757877787980

Programmer Dot. Page lQli] of _ ::~:'tiCM11 IIIIII


Extension Specifications

-
E Record Sequence of thl Chaining File

Number of the Chaining Field


Number
of Number
.~ 0 Table or
~
Table or Entries of LongIh Length
Line
8-
~
To Filename .
Array Name Per Entries of
l~ Array Name
(AII.notlng
of Comments

j
Entry Entry
From Filename
Record Per Tabl.
~ ~ ~ Forrut)
a:
::J
! or Arrav
~~i ~
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2!5 2!5 27 28 29 30 31 32 333435 36 37 38 39 40 41 42 4344 45 46 47 48 49 50 51 52 53 54 5556 57 58 59 50 61 62 63 64 55 66 67 66 69 70 71 72 73 74
0 1 Ie E tro 1"""1'.1 Lf f' ~
o 2 J" E
rl~ /1;, liJ lli 2
o 3 hE
~
r7~ trL-3 1'1 Iz
o 4 E
.. c r

Printed In U,S.A,
CONTRPL DATA RPG CALCULATION SPECIFICATIONS
CORrQR(\110N
I 2 75 76 77 7B 79 BO

~ 01_ ~~~:~;:alion I IIIIII


Program
Page
Programmer Dale

Resulling
C ~
Indicators Result Field
Indicators
0_
1
~ Arithmetic

=0
-'0:
At Factor 1 Operation Factor 2 g Plu. IMinu.' Zero
Comments
~3~
Compare
Line ~ 0 a:
Name Length
~ 1 > 2f1 < 2T 1 • 2
§ E ~ .- ! LoakuplFaclor 2);.
.f! 85:1. i 1)
z % High Low Equal
3 4 5 6 7 8 9 10 11 12 13 14 IS 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 41 48 49 50 51 53 54 55 56 57 58 59 60 61 62 6:3 64 65 ti6 61 6H ti~ 70 71 12 73 74

o 1 Ie e ~kj 1J:lll!A A .b't ITa17r.1 .1 rrm ·rl.tl rt I : I i I


o 2 ~., e !1~ I~!tl~ MDt rra ITlt 1"12 !T~ ri-1j' c2 I I
i i I I
o 3 Ir: e 1Jf'l 11= b'~ IA!.bb 17'11171.1 ~ Tid ·rt:1f ~ I l i I
:1ia ,rk:' J.I
I
o 4 be l1~ ItllD 11-111::'-1: i r7rD Tl:1 .'" lJ I : ! I
0 5b eLi rTlli! 1'l1 IA ".]) -1- ~Q\ Tr2
11
iT~'T:l! ! : I I i
0 6~ c L7 rr~ rT~2 ~;'I:>1) i ~11a TI~
,- ~! i I I ! 1 :I
o 7 e
,
Iii i i i iii I
-- - I I : ! ' I I I I I I I
I

CONTR..OL DATA RPG OUTPUT SPECIFICATIONS


CORrQR(\110N
1 2 75711777879110
Progrom

Programmer O.t.
page~OI_ ::::',iCM1U IIIII

~
0 -s:
~~poce Skip Output Indicators ,,,,.:. .... , .
'> Commas
Zero B.lanc..
10 Print
NoS.gn CR - X" Remove
Plus Sign

i~ J :
FIeldNIrM Ii
'1
v.. Ves 1 A J V" Date

ill End
V.. No 2 B K Field Edit
Z " Zero
i~ .z:t
Line Filename No Ves 3 C L
AL a: Po.ilon No No 4 0 M Suppress
!
l-
... ell
f;; fo~
! li !! in a:
::J
~~
Oulpul
E ~
0
z ~ ~ Constant or Edit Word
~ ~~I-
"AUTO Record
~
AND
3 4 5 6 7 8 9 10 II 12 13 14 5 16 11 18 1.20 21 22 :1324 25 26 27 28 2930 31 32 33 34 35 36 37 38~ 40 41 42 43 44 45 46 41 48 .9 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 66 69 70 71 n 73 74

~~I+ c-~ c-
I,. olp IMr iI.l ~T Illl
0 1
-~ J11~ --,-i- f- - f--t- - ~- - -.--. ---_. - f-- - rf-- .
0 21r 0
n-rz· Tit r III ILjlr c-

.tt .::-
c-
- ~- I-f- - -- --1;-1-- . f- f- --
0 31r 0 11 111i' IJ .?

--t lll+ ~ C~~l~ ·,tn


o 4 I,.. 0 17 fa hill J IR 141~ I I
f-. --
0 51r- 0
T 1112 i-~~ I~ f- -·-tJ---- -
1}-- -t-t-t -t- t1W2
-i- f--
0 sic 0 TI~ ,kJ ~- r -~ rf- I; ! Iii
---++- ~-+
0 7 0
- 1-- - - I--f- f-- ~- 1-- t if-: - -t11 - - -I'
r---j--1
-f --. -i--t -j ~ 1
-f-l-i-- I--f- I--~
I
I--~f- "- --I- - -+ t·- f- - f- f--. t-- --- ' r - -- I -r -++-li- -+ I
i
-- I t-I "'-1
I --, -1- I--f- I--~

Figure 12-11. Accumulating Totals With Arrays

12-12 96768710 A
RPG II FILE ·PROCESSING 13

MbAA ··1! ¥Wi.W;" btiMWS¥M"WMWW.·W.a'. &(.1-.. 6

The various file structures and modes of processing available employee address input file is secondary. The application
in RPG II were described briefly in section 5. This section determines primary and secondary designations. In a billing
discusses in detail the subject of record selection and the program, sales transactions are accumulated for each
significance of file structures to the modes of processing. customer record. In this case, the customer file is
designated a secondary file, ensuring that individual sales
transaction records (from the primary file) have already
SEQUENTIAL FILE PROCESSING been read and accumulated before the next customer record
is read.
All records in files with sequential organization are written
to the storage medium with no intervening logical gaps; one In the following discussion of primary and secondary input
logical record follows the next. Frequently, the records of a files,it is important to keep in mind the fact that RPG II
sequentially organized file are logically in sequence. For first reads an input record into a core area known as a read
RPG II, logical sequence implies keys in the file that are in area and then moves the record to another core area known
ascending or descending order. RPG II can process ordered as a process area. A control break is detected while the
and unordered sequentially organized files. An RPG II record causing the control break is still in the read area.
object program can create an ordered file if the input data RPG II performs all appropriate control break processing
is in the correct sequence. Alternately, a sort program can before moving that record to the process area.
put existing sequential files in order.
All files on any medium can be created in sequential order MATCHING RECORDS
by RPG II. Disk files may be created with indexed
organization to permit random processing later. Other Interrelated multiple input files are processed through the
sequential disk files' may be processed nonsequentially as matching record feature of RPG II. The matching field
well through the use of a record address file of tags (known entries in columns 61 and 62 of· the Input Specifications
as an ADDROUT file), which is prepared by a sort program. sheet determine when records of a secondary file are to be
processed. The following rules apply to matching field
RPG II object programs process records of sequential files as entries:
they appear from the beginning of the file. A sequential file
may be processed to end-of-file, or processing may stop o Up to nine matching field entries (Ml through M9) may
before end-of-file is reached (see End-of-File, section 5). be specified for a record.
As an example of the latter condition, consider a file of
employee addresses that is referenced when mailing labels o The locations of matching fields in a record must be the
for the management newsletter are prepared. When the same for all records of that type.
address corresponding to the highest management employee
number has been extracted, there is no further use for the • The locations of matching fields in different record
address file in this program, although the end of the address types may be different •
. file mayor may not have been reached.
• Not all of the record types in a single file must have
An indexed file may be processed from beginning to end of matching field specifications.
the index or within index limits supplied by a record address
file. In the above example, a record address file could • Records may be matched by one field, many fields, or in
supply the lowest and highest management employee their entirety.
numbers. .
• Records of two or more files being matched must have
When there is only one input file, that file is the primary file the same number of matching field specifications.
(P in column 16 of form F). The entire file is processed
beginning with the first record and continuing until the end o The combined length of the matching fields for one
of file has been reached. record must equal the combined length of the matching
fields of any record with which it is being matched.
With multiple input files, one is primary and the other(s) are
secondary •. If there is no relationship between the process- o The combined length of matching fields within a record
ing of the files, RPG II processes the primary file to its end must not exceed 256 characters.
before it processes the secondary file(s). In this case, two or
more secondary files are processed in the order of their o When matching fields are specified for a single input
form F descriptions. file, the effect is sequence checking of the file.
When a record matching relationship exists among multiple Notice that matching fields may be specified for a file even
files, the file that controls processing is primary and the if not all record types of the file are to enter into the
others are secondary. In the management newsletter matching. Matching field entries are not made for records
example, the employee number input file is primary and the that are not to be matched.

96768710 A 13-1
RPG II turns on the matching record indicator (MR) when a· result is shown as a merger of the two files. Record
match occurs'. between records of the primary file and' selection is performed according to the two-digit numeric
secondary file(s). The indicator may be used to condition field values shown.
calculation and output functions. The indicator remains on
during the complete processing of the selected record and is Record types not having matching field specifications are
turned off by RPG II after all calculations and output indicated with no match values. The MR indicator is on
specified for the record have been executed. during processing of the shaded records. The files shown are
in ascending sequence of the match fields; the record
If there is no match between records of the primary file and selection would be inverted if the files were in descending
secondary file(s), the MR indicator is not turned on, and the sequence. Notice that for both files, or neither, an E must
off condition may be used to condition calculations for have been entered in column 17 of form F (end of file) since
.unmatched records or selection of unmatched records for processing of the secondary file continues after the end of
output. the primary file has been reached.
If there is more than one matching field entry for a record,
the codes M1 through M9 must be assigned to the fields in LOOK-AHEAD FI ELDS
the order of increasing significance of the match. If a
matching field in any record is defined as numeric, all fields Look-ahead extends the matching record capability by
at that same Mn level are treated as numeric fields in the allowing fields in the read area to be used before the record
match. If all fields at a given level are defined as has been selected for processing. Look-ahead cannot be
alphanumeric, the fields are compared logically. specified for chained or demand files, as records in these
I During the matching of records of primary and secondary
files are not held in a read area before processing.
files, four situations can occur: Figure 13-2 illustrates the read and process areas as record
selection in figure 13-1 is taking place. In picture 1, the
• There is a matching primary record. first record of each file has been read. In picture 2, the
secondary record with a matching field value of 16 has been
• There is a matching secondary record. selected for processing. Records selected for processing and
records available for look-ahead are charted by picture
• There is an unmatched primary record. number in table 13-1.
• There is an unmatched secondary record. Look-ahead can be specified for update and combined files,
but it applies to the current record of the file only. A copy
Given these four possible situations, here are the rules for of the current update or combined file record remains in the
the order of processing: read area until the end of cycle; thus, the next record is not
available for look-ahead until the next cycle.
• Recor~s having, no designated matching fields are
processed before records having matching field If the secondary file in figure 13-1 were an update file, the
specifications, regardless of file. read and process areas would take the configurations shown
in figure 13-3. Records selected for processing and records
• When records match, the primary file record is available for look-ahead are shown in table 13-2.
processed first.
An application for look-ahead fields is shown in figure 13-4.
• Matching records of additional secondary files are The job reads records from two files: a primary update file
processed in the order of specification of the files on named PRIMARY and a secondary input file named
form F. SECONDARY. Changes for some items in the primary file
are contained in the secondary file. Thus, if a record from
o When records with matching field specifications do not the primary file matches one from the secondary file, the
rna tch, the record first in sequence according to the information in character positions 1 through 8 of the
matching field value is processed first, regardless of secondary file record is placed in positions 15 through 22 of
file. the primary file record. When matching does not occur and
a secondary record is being processed, the erroneous record
Record selection based on matching fields of one primary is printed out. (A primary record without a matching
file and one secondary file is illustrated in figure 13-1. The secondary record is not an error condition and is written to
the update file as is.)

13-2 96768710 B
MERGED FILE

S 42
PRIMARY NO-MATCH SECONDARY
FILE FILE

NOTE: MR INDICATOR IS ON DURING PROCESSING OF THE SHADED RECORDS.


03U

Figure 13-1. Record Selection Based on Matching Fields

96768710 A 13-3
(521
rP NO MATCH (5 NO MATCH
(P30
'5 NO MATCH

(P2) (52)
-
r-~------- --- ~---

lr~ ___ ~] l'~ ___ ~lJ


READ
AREA

I I PROCESS
I
L
I
_ _ _ _ _ _ _ _ _ _ _ _ _ _ ....J
AREA

~PNOMATCH (521
(PJO . ( 5 NO MATCH
I'"P21 '521
-
"--
(P2) (53)

-- ---
~p~ 5 NO MATCH

~-- -
(J - - --
READ
AREA

l6
I"

I
L_ - - - - - - - r (J
--
PR0CE55
AREA

Figure 13-2. Read and Process Areas for Reeorci9 in Figure 13-1 (Sheet 1 of 2)

IH 96768710 A
PNOMATa-t
(521
'SNOMATa-t

(54)
-

rr ---J --
l
- -1'Z~ -~J READ
AREA

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

J
NOMATCH

:
L ____________ _ r PROCESS
AREA

I~~
ISI6

_.______________(~SI~)_

(PNOMATCH (521
~P30 1'5 NO MATCH

- --

n;;l--- J-TZI- - --]


CPJ) (54)

READ
~.

1---- - -- -----

:
L ____ - - r l

IS NO MATa-t
reJ
PROCESS
~

~ 16 PROCESSED
RECORDS

(51) -
oau

Figure 13-2. Read and Process Areas for Records in Figure 13-1 (Sheet 2 of 2)

96'168'110 A 13-5
TABLE 13-1. RECORDS AVAILABLE FOB LOOK-AHEAD

Picture Record Being Processed Records Available

2 81 PI and S2
3
.. 82
PI
PI and 83
P2 and 83

fU21
NO MATCH (UNO MATCH
(Ull
UNO MATCH

(U2)
--
r---
21
--- - -- --- -.--
:r
~-~
(J ria READ
AREA

t I PROCESS
AREA
t I
L _ _ _ _ _ _ _ _ _ _ _ _ .J

r U21
(U NO MATCH
rPNOMATCH
(PJO fUll
;,p 21 "UNO MATCH

(P2)
- (02)
-

READ
AREA

I
PROCESS
I AREA
_0--1
Figure 13-3. Look-Ahead With Update Files (~heet 1 of 2)

13-6 96768710 A
LPNOMATCH (U21
(PJO (UNO MATCH
/P21 , U21

- -
(P2)
- (U3)
--

:r z' - - -.- -.. - (J - -:;;;M;;; - - -(U-Z)-: READ


AREA

L _ ____ - ___ ---- ___ -I


I ~U~N~O~M~A~T~C~H~--------- I
PROCESS
I I AREA

L ________ ~U2~ ___ .J


U 16 I PROCESSED

I
________________(~U~I)
RECORD

(U21
~UNO MATCH

(P3) (U4)
-
- - -,

~IJ
READ
AREA

I PROCESS
I AREA

__ J
IUNOMATCH
U 16 PROCESSED
RECORDS

(Un

0313
Figure 13-3. Look-Ahead With Update Files (Sheet 2 of 2)

96168110 A 13-1
TABLE 13-2. RECORDS AVAILABLE FOR LOOK-AHEAD WITH UPDATE FILE

Picture Record Being Processed Records Available

2 UI PI and Ul·
3 U2 PI and U2
4 PI P2 and U3

r.J 1:\ CONTRPL DATA RPG CONTROL CARD AND FI LE DESCRIPTION SPECI FICATIONS
\::I ~ CORrO~110N
12 7578777871180
Card EllC1ro Number
"~Of_ =ca~onl IIIIII
PUnching
Instruction

Control Card Specifications


~
H II ModtI20

r--- I !
• Number
~
.r
a22-
&1 j ~ i
II l "r j a~ i]g w!2 11
I "-1
IiJi
Une
!
~
Sin to
Compil.
11 SIze to
E_
I ~ Ii
Of Pr,nt
POSItions ~
I
Address
toSuort iA~cl!!1
~!i~
!'

11 .
]1 ~i ~ f ~ ~
Refer to the spocific Sysam R.ferent!lt LibrlfY m ...ual fo, actull entries.

3 4
!
& • .7 8
II !,
Ii! ... w
a a
c!o
II 10 11 121314 1& II 17 18 1920 21
II :n n 242S
<i:
12il
~6!~!~
N

5 j!: ]! II !& l:~


27 28 29 30 3132 3334 3138 3738 3940 4142 4344 48 48 4748 41&0 ~~MM"M~M~~~~M~~M~M.ronnn~

01,j H IJ It I II III I I I I I I I I I I I I II I I I I I I I I

File Description Specification


file Type Mode of Procnsing File Additionl\JnordeNCl
F FiltDni...tion LAngtII of Key FiMd Of EX1In1 Exlt ~ofT""
f--

Filename
IEndfll file
Sequence
of " - d ~,iMd
P'=,d'~rt"..sT~
Type of ,lie o.vIce
Symbolic i Nemeof
Label Exit
for DAM for CylindIr o..tIow
t~.. mt., of [I<l4nU

Une
FIIe"- ClrgInIzMlon
Of~AnI ~
oJ
iii
Device
! StonIgt Index
T. .

~
0verfI~ j Condition

Ii w~1
..
! Block "'-d :It !5 KeyFiIId .. Contin..tion U_
U1~

~
~ t: SUnIng!
~
Lqtfl LAngtII
:J. ~g ~.: I( Option Entry ~
3 4 & • 7 8 9 10" 12 13 14 11 I. 1718 1.2021222 :M 211 211 27 282930 313:l 3334 38383731 39 40 41 42 43 44 411 411 47 48 49 &0 &1 ~ 113 M &5 M 87 M!!4I eo 1182 e:t . . . M~ ~. 10 71 n '13 ,.

o 2 hF PI. Tht
A~'" liP 11= ~~ ~Ic V;z: 51(
nl ...
o 3 "F ,~E=: ~'(JJ AltD 11.'( 3.~c :~ Biro 113 ( :- I-'-I~

o .. (}F PP. TN "1'f!.A. Ql I~ 13~ t~~ fA 7.~ IT It;: Jt


o5 F
-- ~

Figure 13-4. An Application tor Look-Ahead Fields (Sheet 1 ot 2)

13-8 96768710 A
CONTR..OL DATA RPG INPUT SPECIFICATIONS
COR]'OR{\TION
1 2 7~ 76 17 78 19 80
Program Card Electro Number
page~ot_ P'O<J,.m
IdentLflcatlon
DJJII]- I

Programmer Date

Record Identification Codes


I Field Location
Field

- §
0
0

"
"
Indicators

"0 ~ ~ -c ~
Filename " ;;; F Icld Name 0;

~
~ ~ "0
~.;:

]
0 ll'fo
Q.
Position Posjtion From To "'", PIU!i MInus or
~ g C
-5 ~
"
"0 Bl,mlo:.
¥ ~ ~ 0;
0 .3 ::.U u:
7 8 9 10 11 12 13 14 16 16 17 18 19 70 21 12 23 24 2S 215 27 28 29 30 31 );,1 33 34 3~ 36 31 Ja 39 40 41 "2 43 .... 46 46 47 4F1 4') ~o Sl 52 ~J 'l~ S~ ')1, ':Jl 'J8 59 60 tJl G2 63 64 fl~ bti 67 68 b9 f(l 71 72 73 ,.

-I-l Jtj- i-
~
-L~
i
~~ lj~ ~ PLRiJ: fIllAiR ~ Ix J: ~~ --- --- f- - -- --
1
- I - -~ 1-- --
!
+

~_l_+- --t
I
01 2 ,0 I -f-f-:!q - -+-lB -~lr,f,mtl - - -- --
~?~ ~i
I ~-

-f'"'- -~ -~ Et- -~- 1


! -- --- - f- --- '4~ V1JAI'1CiHL -c-
--f , - t II
1-- ---
0141 0 I SI, c'owlD ~ Y'H'f 012 -,- ---+- --
t
---
r- -I- -- --- - - 1---
t-+-~
- - c-~ t t -:r~~M21- - -
<-

J_
0!5icI~_I! I'
-+- -
o i61C I I'
~~ ~-10 I
I 1
-+-+ -tot
--;-ti-+l
-t t: z. --
-1

--1
I

- -- -~
-
-i --
,--

f-
-
- -- f-1
I
: r
--
-'--T

11 _MAj"TiC (t 1 -- r{L --
:1..;4
--

-- £,
_J+-
rr-
~~
=+
! 1 I
1
~~-~~ - i -1-+ + ~-- - -- -- -t-- - - -- j t • --- --- --
Ol8X;I 'II1~ T
-i ~- ---j - • t t
1
-+-
+- --\-~+ - - -t- --- - - -t-"~ ---+ 1 8-N.~nZ"-r.M -r --
=HE
c-- . -- --
T ---
-~ f- -f- 1-- -+

: . ~ I I
09: I
--r--+-- - +-+-. .• - -I --- -
• - ..... : I I
--:- ---I - - -- T -i - -C--- c-, .. - 1 t ! I t -~ --- t
-+-

CONTRPL DATA RPG OUTPUT SPECIFICATIONS


COR]'O~TION
1 2 75 76 77 78 79 80
I P,ogfim
~1 ~~:;~f:",on UIIIII
I Dalt
Page ,4 _

I---
o ----~---

X "- Remove
Plus Sign
Y ;:. Date
Field Edit

SUPPfPSS

Figure 13-4. An Application for Look-Ahead Fields (Sheet 2 of 2)

96768710 A 13-9
INDEXED FILE PROCESSING he could examine just those delinquent accounts by supplying
the customer names through the CHAIN operation code.
Indexed files may be created (loaded) by RPG II on disk as
output files. During the file creation, RPG II accumulates An ADDROUT file is a special type of record address file
the record keys to form an index to the file. Once the file created by sort programs. The indexed file is sorted by
has been loaded, records of the file may be accessed by some field(s) in the records, and the ADDROUT file or
other RPG II programs on a random basis. RPG II might be binary relative record numbers is produced according to the
given the record key of a single desired record and use this sorting sequence. The key fields of the sort would ordinarily
key to find the index that points to the right record. The not be the same key fields that determine the order of the
record then may be used as a source of input information, or index for the file.
the record may be simply changed and returned to its
previous position in the disk file. When the sequential by key or the random method is being
I The various methods of processing an indexed file provide
used to access records of an indexed file, an entry of A in
column 66 of form F (File Addition/Unordered Output) per-
great operational flexibility to the RPG II user, as keys to mits the addition of new records to a pre-existing file. New
the indexed fi Ie, provided by record address files, can be records are added to the end of the data file and new index
changed each ti me the object program is executed. Con- information is added to the end of the index portion of the
sider a depart ment store billing program which is to be run file. Then at the end of object program execution, RPG II
once a week. In order to bill customers on a monthly basis, reorganizes the entire index into ascending key sequence.
it would be convenient to index the customer file alphabeti- File addition is performed more efficiently if the new
cally by na me and to process approxi rna tely one quarter of records are presented in ascending key sequence.
the file each week. The processing limits could then have
thc following configuration:
DIRECT FILE PROCESSING
Record Address File
Direct access files are sequentially organized disk files that
Lower Upper also may be processed randomly. Records of a direct file
level level are assigned specific record positions on disk. Regardless of
the order in which the records are put in the file, they
1st week AARDAL GYLLENSWAN always occupy specific disk addresses. A rela ti ve record
2nd week number identifies the relative position of a record within the
HAACK NYSTROM
file.
3rd week OAKLEY TYSON
A direct file is created in RPG II through the CHAIN
4th week UhBELE ZWELLING

Two other methods of processing an indexed file are:


operation code. The user supplies relative record numbers
for the records to be loaded. Before the file is loaded, the
entire disk area is cleared to blanks. Record posi lions
I
remain blank and reserved for records not available at the
• Random processing with the record key supplied in
time of file creation.
a CHAIN operation

• Processing by ADDROUT file


"
Records are retrieved f rom direct
" f"lIes through ADD ROUT I
files or with the CHAIN operation.
Processing an indexed file with specific keys using the
Because a direct file is not organized according to a known
CHAIN operation code allows even greater selectivity than
key sequence, sequential processing of the file by key or
processing within limits. Further, while processing within
limits is not possible.
limits reduces the number of records to be handled, it still
requires sequential processing within the limits. With
Records may be added to a pre-existing direct file through
CHAIN, the order of processing may be completely nonse-
an entry of A in column 66 of form F and by the execution
(l'lential. This mode of processing allows retrieval of
of CHAIN operation codes, or through the declaration of the
specific unordered information in an indexed file.
file as an update file processed consecutively. When CHAIN
is used, new records replace the gaps. In the latter case,
As an example, suppose that certain customers in the
new records are added to the end of the direct file.
department store billing file had very delinquent payment
records. If the store manager had threatened legal action if
a payment were not received by a certain date, on that date

13-10 96768710 C
GLOSSARY A

l'> - The character frequently used throughout this manual to Collating Sequence - Any logical sequence used to put items
denote a blank character of data into order
Access Method - A way of moving data between main Combined File - A card file that both input and output
storage and input/output devices operations are performed on. All cards in the file are
·read, but not all cards are punched, interpreted and/or
Alphabetic Characters - The 26 alphabetic EBCDIC charac- stacker· selected.
ters and the three EBCDIC charact~rs i, $, and @'
Compilation Time - The time during which the RPG n
Alphanumeric Characters - Any of the 256 EBCDIC compiler accepts source program specifications,
characters produces program and diagnostic listings, and generates
the object program
Alphanumeric Fields - All fields for which a decimal
positions specification has not been made in the Compile - To prepare a machine language program from a
appropriate column of the specifications forms. Alpha- computer program written in another programming
numeric fields contain alphabetic. numeric. or special language through use of the overall logic structure of
characters the program or by generating more than one machine
instruction for each symbolic statement, or both. as
American National Standard Labels - Magnetic tape labels well as performing. the function of an assembler
conforming to conventions established by the American
National Standards Institute; also called ASCII label Console - The computer part used for communication
between the operator or maintenance personnel and the
Application Program - A program written for or by a user computer
Array Element Name - An array name followed by a comma Control Card - A punched card that contains input data or
and an index. The indexed array name designates a parameters for initializing or modifying a program
specific element in an array.
Control Field - A group of record bytes used in determining
Ascn - American Standard Code for Information Inter- sequence in sorting or merging records
change. The 128-character external code set used in
this RPG II compiler . Conversion - The process of changing from one method of
data processing to another or from one data processing
ASCII Label- See American National Standard Label. system to another; also the processor of changing from
one form of representation to another; e.g•• to change
Assemble - To prepare a machine language program from a from decimal representation to binary representation.
symbolic language program by the substitution of
absolute operation codes for symbolic operation codes Data File - A collection of related data records organized in
and .absolute or relocatable addresses for symbolic a certain manner. For example, a payroll file or an
addresses inventory file
Batch Processing - The technique of executing a set of Deblock - To make the first and each subsequent logical
computer programs such that each is completed before record of a block available for processing, one record at
the next program of the set is started a time
Blocking - Two or more records combined into one block Debug - To detect. locate, and remove mistakes from a
routine or malfunctions from a computer; also called
Blocking Factor - The number of logical records combined troubleshooting
into ·one block or physical record . .
Default Value - The choice the system makes among exclu-
Buffer - A temporarily reserved area of storage for use in sive alternatives when no explicit choice is specified by
performing an input/output operation and into which the user
data is read or from which data is written; also called
I/O area Detail Time - The part of execution time during which
operations that occur every cycle are executed
Byte - Eight data bits; one character
Direct Access Storage Device - A device in which the
COBOL - Stands for Common Business-Oriented Language; a access time is effectively independent of the location
business data processing language of the data
Collate - Combining items from two or more ordered sets
into one set having a specified order not necessarily the
same as any of the original sets; contrast with merge

96768710 A A-I
Direct Organ.ization - A file organization containing, for Internal Subroutine - A subroutine coded in the RPG n
purposes of storage and retrieval, a relationship language that is part of this RPG n source program
between the contents of the records and their positions
in the file. Contrast with indexed organization and Interpret - To print on cards or to translate
sequential organization
Interrupt - To stop a process so that is can be resumed
Disk - A disk storage device
1/0 - See input/output
Disk Pack - A removable direct access storage volume
containing magnetic disks on which data is stored. Disk I/O Area - Same as buffer
packs are mounted on a disk storaye drive.
ITOS - The Interactive Terminal-Oriented System for
Dump - To copy all or part of the contents of a storage, CYBER 18-20 computers
usually from an internal storage into ·an external
storage; to process the contents or the data resulting JCL - Job control language
from the process
Job - A specific group of tasks called out as a unit of work
EBCDIC - Extended Binary Code Decimal Interchange for a computer; a job usually includes all necessary
Code. The 256-character internal code used in this computer programs, linkages, files, and instructions to
RPG n compiler the operating system. Also a collection of related
problem programs identified in the job stream by a JOB
Execute - To carry out an instruction or group of statement. A job consists of one or more job steps.
instructions, as in a program
Job Control Language - A programming language used to
Execution Time - The time during which object program code job control statements. Abbreviated as JCL
cycles are being executed
Job Control Statement - A statement in a job or job step
External Subroutine - A referenced subroutine that is not that is used to identify the job or describe its
part of this RPG n source program requirements to the operating system
File - A group of related records treated as a unit Job Step - Work associated with one processing program or
one cataloged procedure and related data
File Maintenance - To keep a file up to date by adding,
changing, or deleting data Job Stream - The sequence of operation control statements
and data submitted to an operating system on an input
Fixed-Length Record - A record having the same length as ·unit activated for this purpose by the operator
all other records with which it is logically or physically
connected. Contrast with variable-length record K - 1024 bytes or words used in referring to storage
capacity
Hexadecimal - Pertaining to a number system with a base
of 16; valid digits range from 0 through F, where F Key - One or more characters within an item of data used
represents the highest units position (15) to identify it or control its use
Index - .An ordered list of the contents of a file or Label - An identification record for a tape or disk file
document, containing keys or reference notations for
identification or location of those contents. Also, a Language - A group of representations, conventions, and
table used to locate the records of an indexed file rules used to convey information
Indexed Organization - A file organization containing Language Translator - A general term for any compiler,
records arranged in logical sequence by key. Indexes to assembler, or other routine that accepts statements in
these keys permit random processing of individual one language and produces equivalent statements in
records. Contrast with direct organization and another
sequential organization
Library - A set of procedures, programs, routines, etc., on
Input/Output - About either input or output, or both, a a direct access storage device. Also see source library
general term for equipment used to communicate with a and object library
computer (commonly called I/O), data involved in I/O
communication, or media carrying the data for Load - (1) To enter data or programs into storage (2) Same
input/output as (1) using the loader
Installation - A particular computing system, considering Loader - See relocatable binary loader
the work it does and the people who manage it, operate
it, apply it to problems, service it, and use the results it Main Storage - A computer's general purpose storage.
produc~s Contrast with auxiliary storage

A-2 96768710 A
Merge - To combine items from two or more similarly Pre-Execution Time - The time during which the object
ordered sets into one set that is arranged in the same program is entering execution: after the object
order (contrast with collate) or a program or routine program has been loaded into core memory and just
that performs this function before the first program cycle is executed
MFCM - Multi-Function Card Machine. Same as IBM 2560 Priority - A rank assigned to a job that determines its
Multi-Function Card Machine precedence in receiving system resources
MFCU - Multi-Function Card Unit. Same as IBM 5424 Program Library - A group of available computer programs
Multi-Function Card Unit and routines
MSOS - The Mass Storage Operating System for CYBER 18 Prompting - A function that assists a user by requesting
systems him to' supply information necessary to continue
processing
Multiprogramming - The concurrent execution of two or
more programs by a computer Queue - A waiting line or list formed by items in a system
waiting for service (e.g., jobs to be performed), or to
Nonstandard labels - Labels that do not conform to arrange in, or form, a queue
American National Standard or IBM Standard label
conventions Random Processing - The treatment of data with respect
to its location in external storage, and in an arbitrary
Numeric Fields - All fields having a decimal positions sequence governed by the input against which it is to be
specification in the appropriate columns of the specifi- processed. Contrast with consecutive processing and
cations forms sequential processing
Object Code- Output from a compiler or assembler that is Record - A group of related items of data that are treated
an executable machine code or is suitable for processing as a unit (e.g., one line of an invoice may form a record;
to produce an executable machine code a complete set of such records may form a file)
Object Program - A fully compiled or assembled program Record Key - The field or fields that uniquely identify a
ready to be loaded into the computer. Contrast with record in an indexed file
source program
Relocatable Binary Loader - A program that prepares the
Offline - Equipment or devices not under control of the output of language translators for execution. It
CPU combines separately produced object modules, resolves
symbolic cross references among them, and produces
Online - Equipment or devices under control of the CPU; a executable code (a load module).
user's ability to ineract with a computer
Reproduce - To prepare a duplicate of stored information,
Operating System - Software that controls the execution especially for punched cards
of computer programs and that may provide scheduling,
debugging, input/output control, accounting, compila- Routine - A set of coded instructions arranged in proper
tion, storage assignment, data management, and related sequence to direct the computer to perform a desired
services operation or series of operations
Operator Message - A message from the operating system RPG n - Report Program Generator. A business-oriented
or a user program directing the operator to perform a data processing language
specific function (i.e., mounting a disk pack or inform-
ing him of specific conditions within the system, such as Scratch File - A disk file that is created and deleted in the
an error condition) same job step. Contrast with permanent file and
temporary file
Pack - Compressing data in a storage medium by taking
advantage of known characteristics of the data so that Sector - A 96-word directly-addressable part of a disk
the original data can be recovered (i.e., to compress storage device
data in a storage medium by making use of bit or byte
locations that would otherwise go unused). See disk Seek - To position the access mechanism of a direct access
pack . device at a specified location
Partition - A subdivision of main storage. Sequence - Items arranged according to a specified set of
rules. In sorting, a collection of records whose control
Permanent File - A disk file that is normally created for fields are in ascending or descending order according to
continuing use. Contrast with scratch file and the collating sequence.
temporary file

96768710 A A-3
Sequential organization - A file organization in which System Generation - The process of tailoring the system to
records are arranged in a physical sequence, but not suit a user's requirements and of including the desired
necessarily in logical s'equence. Contrast with direct program products .
organization and index.ed organization
Total Time - The part of execution time occurring after a
Sequential Processing - A method of treating data with control break in which operations for the prior control
respect to its location in external storage in a sequence group are processed
governed by the logical order of the data in the file.
Contrast with consecutive processing and random . Unit Record Devices - Card readers, card punches, and
processing printers
Source Program - A computer program that is written in Utility Program - A program designed to perform an
source language. Contrast with object program everyday task, such as copying data from one storage
", device to another
Source Statement - A statement written in symbols of a
programming language Variable-Length Record - A record having a length
independent of the length of other records with which it
Special Characters - The 217 EBCDIC characters· not is lOgically or physically connected. Contrast with
defined as alphabetic or numeric fixed-length record. Also, a file in which the records
are not uniform in length
Spooling - Reading and writing input and output streams on
disk concurrently with job execution in a format Volume - That portion of a single unit of storage that is
convenient for later processing or output operations accessible to a single read/write mechanism, such as a
disk pack. Also, a recording medium that is mounted
Storage - A device into which data can be entered and held and demounted as a unit; e.g., a reel of magnetic tape
and from which it can be retrieved at a later time; or a disk pack
also, any device that can store data
Storage Protection - An arrangement for preventing access
to storage for either reading, writing, or both. Also
called memory protection

A-4 96'168'110 A
DEVIATIONS FROM IBM SYSTEM/3 RPG II B

This product is designed to be nearly compatible with IBM TABLE B-1. DIFFERENCES BETWEEN SYSTEM/3
System/3 Model 10 RPG II. Some of the differences are due AND MSOS OPTIONS
to requirements of the operating environment; other changes
represent system improvements. Feature System/3 MSOS
Implementation Implementation
Those IBM System/3 Model 10 RPG II features that are
omitted are: Number of files al- Maximum of 20 Unlimited
lowed in one source
program
• A Telecommunications Specifications sheet is not
supported. Number of demand Maximum of 15 Unlimited
and/or chained files
• The P (punched card) option is not provided for Object allowed in one source
Output on the Control Card Specifications sheet. program
Name specified for Name must be Any name is
• A specification for Core Size to Execute is not Label Exit SUBRxx or allowed
supported on the Control Card Specifications sheet. SRyzzz
• An Inquiry specification on the Control Card Specifi- Number of tables and Maximum of 63 Unlimited
cations sheet is not supported. arrays in one source and only 60 may
program be compile time
• A PWlch MFCU Zeros specification is not supported for Number of spread Maximum of 128 Unlimited
the Control Card Specifications sheet. .
card specification
lines
• The Nonprint Characters specification on the Control
Card Specifications sheet is not supported. Device used with Device must be Any sequen-
spread cards card reader tial input de-
• ·PRINT as a special word in the output specifications is
not provided.
Format of trailer Must be un- May be un-
.
vice is valid

fields on spread packed decimal packed deci-


Some features not applicable to current hardware cards mal, packed
configurations are supported. This implementation provides decimal, or
for the future addition of such features. An example of this binary
is input/output stacker select. The compiler does not
diagnose such a feature and defaults the specification to a Number of AND/OR· Maximum of 20 Unlimited
logical alternative. lines allowed on Input
Specifications sheet
Other differences from System/3 RPG II signify the easing
of restrictions. These features are listed in table B-1. In Number of char- Maximum of 144 Maximum of 256
this table, the term unlimited means that the feature is acters in control
limited only by the available computer memory. fields
Number of char- Maximum of 144 Maximum of 256
acters in matchmg
fields
Number of AND/OR Maximum of '1 Unlimited
lines on Calculation
Specifications sheet
Number of AND/OR Maximum of 20 Unlimited
lines on Output Spe-
cifications sheet
Number of digits 3 to 6 1 to 15
allowed with -Y edit
code

96'168'110 A 8-1
SUMMARY OF RPG II SPECIFICATIONS C

.!~

This appendix is provided as a brief summary of sections 3 CONTROL CARD


through 10. It is intended as a quick reference for SPECIFICATIONS - FORM H
programmers who are acquainted with RPG II.
Column 15 (DEBUG)
On any form, columns for which spe.cifications are not listed
are to be left blank. Blank DEBUG operation not used

1 DEBUG operation is used


COMMON ENTRIES Column 21 (Inverted Print)
RPG II specifications forms should be ordered in ascending Blank Domestic format
numeric sequence based on columns 1 through 5. Pages
should be arranged in the following order and numbered Foreign format
accordingly:
J Foreign format (leading zero remains
1. Control Card Specifications (Form H) for zero bala,nce)

2. File description Specifications (Form F) D United Kingdom format

3. Extension Specifications (Form E) Column 26 (Alternate Collating Sequence)


4. Line Counter Specifications (Form L) Blank Normal collating sequence used

5. Input Specifications (Form I) S Alternate collating sequence is sup-


plied at end of source program.
6. Calculation Specifications (Form C)
Column 41 (IP Forms Positioning)
7. Output Specifications (Form 0)
Blank First 1P line to be printed only once.
Columns 1-2 (Page)
1 First IP . line may be printed repeat-
Numeric page number edly to allow forms positioning.
Columns 3-5 (Line) Column 43 (File Translation)

Numeric line number within page Blank File translation not needed
Column 6 (Form Type) F Input, output, update. or combined
files need translation (translation
Enter an H, F, E, L, I, C, or 0 to indicate the tables at end of source program).
specifications form type.
Column 48 (Shared I/O)
Column 7 (comments)
Blank Each disk file uses a separate
An asterisk in this position indicates that the entire line input/output area
is commentary.
1 All disk files share a single
Columns 75-80 (Program Identification) input/output area.

Enter any valid characters into these columns of form H Column 74 (Segmented Running)
to identify the object program. If these columns are
left blank. the name RPGOBJ is assigned to the Blank The program is to be produced as a
program. Columns 75 through 80 on all other specifica- single entity.
tions lines may contain any entries.
1 The object program is to be seg-
mented to conserve memory space.

96768710 A C-l
FILE DESCRIPTION Column 19 (File Format)
SPECI·FICATIONS - FORM F
F Fixed length records
Columns 7-14 (Filename)
V Variable length records (EBCDIC tape
Enter a unique name for each file. The filename may files only)
be from one to eight characters long. must begin in
column 7. and must be a valid RPG II filename. D Variable length records (ASCII tape
files only)
Column 15 (File Type)
Columns 20-23 (Block Length)
I Input
Blank Block length equals record length.
0 Output
U Update 1-9999 Multiple of record length (tape and
disk only) or record length (any
C Combined device)
D Display
Columns 24-27 (Record Length)
Column 16 (File Designation)
1-9999 Number of characters per record
Blank Display file or output file other than
chained output file 18-9999 Maximum number of characters per
tape record
P Primary
Column 28 (Mode of Processing)
S Secondary
Blank a. Not a disk file
C Chained b. Sequential by key
R Record Address c. Consecutive
T Table or Array L Sequential within limits
a. Random by relative record num-
D Demand ber
Column 17 (End-of-File) b. Random by key
c. By ADDROUT rile
Blank . Program can end before end of this
file is reached. d. Direct file load (random load)
E Program termination not possible This column applies only to disk files.
before end of file on this file.
Columns 29-30 (Length of Key Field or Record Address
If column 17 is blank or E for all files. every record of Field)
every input. update. and combined file is processed
before the program terminates. An E in this column Blank Sequential or direct file or chained
requires an I. U. or C in column 15. and a p. S. or R in input file accessed by relative record
column 16. 'number
Column 18 (Sequence) 1-29 Length of indexed filets record key
(entry made for indexed file or record
Blank Sequence checking not requested address file containing limits)
A Records are to be checked for 3 Length of ADD ROUT file record
ascending sequence.
Column 31 (Record Address Type)
D Records are to be checked for
descending sequence. Blank Sequential or direct file
An entry is required here when matching fields are A Indexed file. alphanumeric key
used. Column 18 applies to update and combined files
and all input files except table. array. chained. demand. P Indexed file. packed key
and record address files.
ADDROUT file, or processed by
ADDROUT file

C-2 96768710 A
This column applies to disk files specified as input, Columns 60-65 (Buffer Offset Length)
update, or chained output files.
Blank Not a continuation line having
Column 32 (File Organization or AdditionalI/O Area) BUFOFF as the Continuation Lines
Option
Blank Sequential or direct file; use one
input/output area for the file 0-99 Length of the block prefix in an
ASCII tape input file that specifies
I Indexed organization BUFOFF
T ADDROUTfile Columns 54-59 (Name of Label Exit)
1-9 Sequential or direct file; use two Blank No special device named in col-
input/output areas for the file umns 40 through 46; no label exit is
required.
Columns 33-34 (Overflow Indicator)
'.
Valid RPG n Name of user-supplied external sub-
Blank No overflow indicator is used. nam.e routine that performs input/output
operations for this special device.
OA-OG,OV Overflow indicator used to condition
records in the file Column 66 (File Addition/Unordered Output)
Columns 35-38 (Key Field Starting Location) Blank No file addition or unordered output
for this file
Blank Not an indexed file
A New records are added to this pre-
1-9999 Indexed file; record position in which existing file.
the key field begins
U Records are to be loaded into this
Column 39 (Extension Code) new indexed file in unordered
sequence.
Blank There are no file extension or line
counter specifications for this file. This position applies to sequential and indexed disk
files.
E The file described on this line is a
table file, array file, or record Columns 68-69 (Number of Extents)
address file further described in
extension specifications. Blank Single volume file
L The file described on this line is a 1-50 Number of volumes in the file
printer file further described in line
counter specific~tions. Column 70 (Tape Rewind)
Columns 40-46 (Device) Blank Rewind information is specified at
run time.
Enter a device code from appendix D for the
input/output unit used by the file specified in columns 7 R Rewind this tape at end of file.
through 14.
U Unload this tape at end of file.
Column 53 (Continuation Line)
N Leave this tape at end of file
Blank This is not a continuation line.
Column 70 applies only to magnetic tape files.
'. K This is a continuation record.
Columns 71-72 (File Condition)
Columns 54-59 (Continuation Lines Option)
Blank File is to be processed uncondition-
Blank This is not a continuation line. ally.
ASCII ASCII tape file specified Ul-U8 File is conditioned by the specified
external indicator.
BUFOFF ASCII tape input file contains a block
prefix. These positions apply to output files and primary and
.secondary input, update, and combined files, excepting
Table or Name of table or array to be refer- table and array input files. A' record address file may
array name enced by a user-supplied external be conditioned by an external indicator if its associated
subroutine. Name cannot be ASCII or primary or secondary file is conditioned either by the
BUFOFF. same indicator or by no indicator.

96768710 A C-3
EXTENSION SPECIFICATIONS- 1-15 Number of characters in nonbinary
FORM E numeric table or array entry
Columns 11-18 (From Filename) 1-9 Number of characters in binary table
or array entry
Blank a. Compilation time table or array
. if columns 33 through 35 contain For packed or binary tables and arrays, enter the
an entry number of bytes of storage required to represent the
b. Execution time table or array if data in unpacked form~t.
columns 33 through 35 are blank Column 43 (Packed or Binary Field)
Filename a. Pre-execution time table or , Blank a. Record address file
array file
b. Compilation time table or array
b. Record ac;ldress file named on
form F c. Pre-execution or execution time
table or array with alphanumeric
Columns 19-26,(To Filename) or unpacked numeric format
Blank This table or array is not output at P Pre-execution or execution time
end of execution. table or array with packed numeric
format
Filename a. The output file to which the
compilation or pre-execution 8 Pre-execution or execution time
ti me table or array is to be table or'array with binary format
written at job termination
Column 44 (Decimal Positions)
b. The name of the file for which
the from file name record Blank a. Record address file
addreSs file controls record
selection b. Alphanumeric table or array
Columns 27-32 (Table or Array Name) 0-9 Number of positions to the right of
the decimal point in this numeric
Enter the name of a table or array used in the program. table or array (zero if entries are
Table names start with the three characters TAB; array integers)
names must not start with TAB. If alternating tables or
arrays are specified on this line, enter here the name of Column 45 (Sequence)
the table or array to which the first element of the '
input record(s) belongs. Leave these columns blank if Blank a. Record address file
this line describes a record address file. b. Table or array entries are un-
ordered.
Columns 33-35 (Number of Entries Per Record)
A Entries have ascending sequence.
Blank Record address file or execution time
table or array D Entries have descending sequence.
1-999 Number of entries per record in a
compilation time or pre-e¥ecution This position describes the sequence of data in a table
ti me table or array file or array. Column 45 must contain a nonblank entry if
high or low look-up is to be used.
Columns 36-39 (Number of Entries Per Table or Array)
Columns 46-57 (Alternate Table or Array)
Blank Record addreSs file
These positions, corresponding in definitions to col-
1-9999 Maximum number of entries in this umns 27 through 45, describe a table or array that is in
table or array alternating format with the table or array named in
columns 27 through 32.
Columns 40-42 (Length of Entry)
Columns 58-74 (Comments)
Blank Record address file
An entry in these columns is assumed by ttie compiler to
1-256 Number of characters in alpha- be entirely commentary.
numeric table or array entry

C-4 96768710 A
LINE COUNTER 1 Positions 15 and 16 contain numeric
SPECIFICATIONS - FORM L characters; only one record of this
type is present in each sequenced
Columns 7-14 (Filename) group.
Enter the name of a printer file for which you wish to N Positions 15 and 16 contain numeric
specify a form size and overflow line. characters; one or more records of
this type may be present in the
Columns 15-17 (Line Number - Number of Lines Per Page) sequenced group.
12-112 Number of lines available for printing Column 18 (Option)
on the printer form
Blank a. Columns 15 and 16 contain
Columns 18-19 (Form Length) alphabetic characters or blanks.
FL FL indicates that the previous entry b. Columns 15 and 16 are numeric.
and this record type is required
is the form length. in the sequence.
Columns 20-22 (Line Number - Overflow Line)
o Columns 15 and 16 are numeric, and
1-112 this record type is optional in each
Number of the overflow line sequenced group.
Columns 23-24 (Overflow Line) Columns 19-20 (Record Identifying Indicator, Look-Ahead
OL OL indicates that the previous entry Fields. or Spread Cards)
is the overflow line number. Blank a. Field description line
b. No distinction need be made be-
tween this record type and the
INPUT SPECIFICATIONS - preceding record type.
FORM I
01-99 Record identifying indicator
Entries must be made on this form for every input. update.
and combined file used in the program. LI-L9 Control level indicator used as a
record identifying indicator' when
Columns 7-14 (Filename) record type rather than control field
signals start of a new control group.
Blank a. Field description line
LR Last record indicator
b. This line uses the previously
listed filename. H1-H9 Halt indicator used as a record ident-
Valid RPG II ifying indicator when checking for a
The name of the input. update. or record type that causes an error
filename combined file associated with this
input specification condition

Columns 15-16 (Sequence) ** Look-ahead fields


TR Spread card
Blank a. Field description line
b. AND or OR line Columns 21-:41 (Record Identification Codes)
01-99 Check for special sequence of record This field is divided into three identical sub fields:
types. The order of these numbers
determines the sequence. • Columns 21 through 27
Any two Record type sequence is not to be • Columns 28 through 34
alphabetic checked. An alphabetic entry is
characters required for a chained file. • Columns 35 through 41
Within a file. record types with an alphabetic sequence An AND relationship exists between the subfields.
entry must be described before record types with a
numeric sequence entry. Columns 21-24 (Position)
Column 17 (Number) ,Blank A record identification code is not
specified.
Blank Columns 15 and 16 contain alphabetic
characters or blanks.

96768710 A C-5
1-9999 Character position of the record Columns 44-51 (Field Location)
identification code
Enter two one- to four-digit numbers to identify the
Column 25 (Not) beginning of a field (From Column) and the end of a
field (To Column) in the input record. These entries are
Blank Either columns 21 through 24 are identical for a one-position field.
blank or the character (or zone or
digit) must be present to identify the Column 52 (Decimal Positions)
record.
Blank Alphanumeric field
The character, zone, or digit must
not be present in the position being 0-9 The number of decimal positions in
described. the numeric field named in posi-
tions 53 through 58 (zero for integers)
Column 26 (C/Z/D)
Columns 53-58 (Field Name)
Blank Record identification code not
needed These positions name the field specified in columns 43
through 52. The following entries may be made here:
C Full character comparison
o A valid RPG II field name
Z Zone comparison
o The name of an array or array element
D Digit comparison
o The special words PAGE, PAGEl, or PAGE2.
Column 27 (Record 'Identification Character)
Columns 59-60 (Control L~veI)
Blank or The alphabetic, numeric, or special
any character that identifies the record. Blank The field being described is not a
alphanumeric Blank is a valid record identification control field.
character character.
L1-L9 The level of the control field being
Additional record identification codes are specified as described
above in columns 28 through 34 and 35 through 41, as
needed. If more than three codes are needed to identify These columns must be blank for chained or demand
a record, enter AND in columns 14 through 16 of the files.
next line and enter additional codes. Enter OR in
columns 14 and 15 of the next line if an OR relationship Columns 61-62 (Matching Fields)
exists between the codes.
Blank No matching is to be performed on
Column 42 (Stacker Select) this input field.
Blank a. Input device is not a card reader M1-M9 Matching level assigned to this input
field
b. Cards automatically fall into pri-
mary stacker. Columns 63-64 (Field Record Relation)
c. This card device does not have
multiple stackers. Blank No particular field-record relation-
ship
1-4 Stacker into which this record type is
stacked 01-99 Record identifying indicator assigned
to a record type
This column applies only to input and combined files
assigned to card readers. L1-L9 Previously assigned control level indi-
cator
Column 43 (Packed or Binary Field)
MR "Matching record indicator
Blank a. Record description line
U1-U8 Previously assigned external indicator
b. Unpacked decimal or alpha-
numeric format field H1-H9 Previously assigne<l halt indicator
P Packed decimal format field
B Binary format field

C-6 96768710 A
The following general rules apply to this entry: columns 9 through 17 that are in an AND or OR
relationship with those on the first line by entering
• All fields without· field record relation should be AND or OR in columns 7 and 8.
specified before fields with field record relation.
Columns 18-27 (Factor 1) and Columns 33-42 (Factor 2)
• All fields with the same field record relation entry
should be entered on consecutive lines. Factor 1 and Factor 2 may contain the following en-
tries:
• All parts of a· split control field must have the
same field record relation entry and must be • Previously defined field name
described on consecutive specification lines.
• Alphanumeric or numeric literal
Columns 65-70 (Field Indicators)
• Array element name, or name of a table, array, or
Blank Field examination is not required. subroutine
01-99 Field indicator • Date field name (UDATE, UMONTH, UDAY,
UYEAR)
H1-H9 Halt indicator (when checking for an
error condition in the field data) • Special name (PAGE, PAGEl, or PAGE2)
When indicators are specified in these positions, RPG II • Label for a TAG, BEGSR, or ENDSR operation
makes appropriate settings when the field is input. (factor 1 only) or a label for a GOTO or EXSR
When the field is numeric, indicators are specified for operation (factor 2 only)
positive, negative, and zero conditions in columns 65
and 66, 67 and 68, and 69 and 70, respectively. One, • Filename (first six characters) for a CHAIN,
two, or three indicators may be specified, but only the DEBUG~ DSPLY, READ, SETLL, or FORCE opera-
indicator that reflects the result of the test is set on; tion (factor 2 only)
other specified indicators are set off. An alphanumeric
field may only be tested for all blanks (columns 69 Columns 28-32 (Operation)
through 70).
Enter an operation code (appendix D), left-justified.
Columns 43-48 (Result Field)
CALCULATION SPECIFICATIONS-
FORMC Enter the name of the field, table, array, or array
element that holds the result of the operation specified
Columns 7-8 (Control Level) in positions 28 through 32. If the field named in Result
Field has not been previously defined in extension,
Blank Operation done at detail time input, or preceding calculation specifications, it should
be defined now by entries in positions 49 through 52 of
LO Calculation is performed at total this line.
time (LO is always on).
Columns 49-51 (Field Length)
J... 1-L9 Calculation operation is done at total
time when the appropriate control Blank Result field is defined elsewhere.
break occurs or the specified indi-
cator is set on. 1-256 Result field length (right-justified)
J...R Calculation operation is done after The maximum length of a numeric field is 15 digits; the
the last record has been processed or maximum length of an alphanumeric field is 256
aft~r LR has been set on. characters.
SR Calculation operation is part of a Column 52 (Decimal Positions)
subroutine. .
Blank Result field designated elsewhere or
Calculation specifications must be ordered by the alphanumeric result field
sequence listed above. AN or OR may be entered in
these positions to indicate that indicators (columns 9- 0-9 Number of decimal places in a
17) on the line are in an AND or OR relationship with numeric res1Jlt field
indicators on the preceding line.
Column 53 (Half Adjust)
Columns 9-17 (Indicators)
Blank Do not half adjust the result field.
Enter one, two, or three indicators. Any RPG n
indicators except IP and LO can be used. Columns 9, H Half adjust the result field.
12, and 15 may contain blank or N. An AND
relationship exists between indicators on a line. Addi- Half adjusting may be specified only with arithmetic
tional lines may be used containing indicators in operations.

96768710 A C-7
Columns 54-59 (Resulting Indicators) OUTPUT SPECIFICATIONS-
FORM 0
Enter any of the following indicators: 01 through 99,' H1
through H9, L1 through L9, LR, OA through 00, and Columns 7-14 (Filename)
OV. Columns 54 and 59 are used:
Enter a valid RPG n filename for each output, update,
• To test the value of the result field after an and combined file used by the program. Each filename
arithmetic operation. Enter up to three indicators need be specified only once, on the first line describing
to test for a positive result (columns 54 and 55), a that file.
negative result (columns 56 and 57), or a result of
zero (columns 58 and 59). Columns 14-16 (And/Or Relationships)

• To check the outcome of a CHAIN, LOKUP, Enter AND in positions 14 through 16 or OR in


COMP, TESTB, or TESTZ operation. positions 14 and 15 if output records are in an AND or
OR relationship.
With the CHAIN operation, an indicator specified
in columns 54 and 55 is set on if the record is not Column 15 (Type)
found. With the LOKUP operation, up to three
indicators are specified to indicate that factor 2 is Blank Field description
high (columns 54 and 55), low (columns 56 and 57),
or equal (columns 58 and 59). For the COMP H Heading record description
operation, up to three indicators are specified to
indicate that factor 1 is greater than (columns 54 D Detail record description
and 55), ~ess than (columns 56 and 57), or equal to
(columns 58 and 59) factor 2. T Total record description

With the TESTB operation, resulting indicators have the E Exception record description
following meanings:
Columns 16-18 (Add a Record)
• Positions 54 and 55: An indicator in these positions
is turned on if each bit specified in factor 2 is off Enter ADD in these columns if the record is to be added
in the result field. to an input: update, or output disk file. An A must also
be encoded in position 66 of the File Description
• Positions 56 and 57: An indicator in these positions Specifications sheet for the file to which a record is
is turned on if two or more bits were tested and of added. .
mixed status (some bits on and some bits off).
Column 16 (Stacker Select/Fetch Overflow)
• Positions 58 and 59: An indicator in these positions
is turned on if each bit specified in factor 2 is on in Blank a. Use standard overflow routine
the Result Field. for this printer file •.
b. Use the predetermined stacker
With the TESTZ operation, resulting indicators reflect on this card device. .
the zone of the leftmost character in the result field, as
follows: c. This card device does not have
multiple stackers.
• Positions 54 and 55: Turned on by the zone portion
of the characters &: and A through I.
d. This is neither a printer nor a
card file.
• Positions 56 and 57: Turned on by the zone portion e. Field description line
of the characters (right bracket), - (minus sign or
hyphen), and J through R 1-4 Indicates the stacker in which to
place records
• Positions 58-59: Turned on by the zone portion of
any other chars-cter F Fetch overflow (printer files only)'

• To specify up to three indicators to SETON or Only combined or output files may be stacker selected
SETOF. on form O. Output stacker selection overrides a
specification for input stacker selection.
• To indicate end-of-file for the READ operation
code. An indicator specified in columns 58 and 59 Columns 17-22 (Space/Skip)
is set on if an end-of-file condition is reached
through a READ operation. Once end-of-file is If these columns are blank, single spacing occurs after
reached, a halt occurs after each read operation if each line is printed. Spacing and skipping are not
no indicator is entered. allowed on the printer keyboard.

Columns 60-74 (Comments) Columns 17-18 (Space)

The compiler treates entries in these columns as Enter a number (0 through 3) to specify how many lines
comments and produces them with the program listing. to skip before (column 17) and after (column 18) a line
is printed.

C-8 96768710 A
Columns 19-22 (Skip) B Field is reset to blanks (if alpha-
numeric); or zeros (if numeric) after
Blank No skipping being output.
01-99 Lines 1-99 This column must be blank for look-ahead and update
.fields. If Field Name is a table name, the last table
AO-A9 Lines 100-109 element retrieved is reset.
BO-B2 Lines 110-112 Columns 40-43 (End Position in Output Record)
Enter one of the two-character specifications listed Positions 40 through 43 indicate the location in the
above to indicate where the current line will be printed. output record of the field or constant being written out.
All lines between are bypassed. A skip before printing Enter the number of the position occupied by the
is specified in columns 19 and 20, a skip after in rightmost character of the output field. The End
columns 21 and 22. If the skip line number is less than Position entry must not be greater than the record
the current line number, a skip to a new page occurs. length.
Columns 23-31 (Output Indicators) Column 44 (Packed or Binary Field)
Enter one to three indicators to condition the output Blank a. Record description line
record. Any RPG n indicators may be specified. An N
may be entered in columns 23, 26, and 29 to indicate b. Field has unpacked numeric or
negative conditioning. An AND relationship exists alphanumeric format.
between indicators on a line. Additional lines of
indicators in an AND or OR relationship may be used by P Field has packed numeric format. .
entering AND in columns 14 through 16 or OR in
columns 14 and 15 of each additional line. B Field has binary format.

Columns 32-37 (Field Name) Packed and binary fields may be written to tape or disk
but should not be printed. Position 44 must be blank
Enter one of the following to name every field written with ·PLACE fields.
out:
Columns 45-70 (Constant or Edit Word)
• Any previously defined field name
Constant
• The special words PAGE, PAGEl, PAGE2,
*PLACE, UDATE, UDAY, UMONTH, and UYEAR • Field Name (positions 32 through 37) must be
blank.
• A previously defined table name, array name, or
array element • A constant is enclosed in apostrophes. Enter
the leading apostrophe in position 45.
These positions must be blank if a constant is entered
on positions 45 through 70 of the line. If an entry is • An apostrophe is represented in a constant by
made in the Field Name column, positions 7 through 22 two apostrophes.
must be blank.
• Up to 24 characters of constant information
Column 38 (Edit Codes) may be placed in one line~ Additional lines
may be used, but each line must be treated as
Enter an edit code to accomplish: a separate line of constants. The end position
of each line must appear in positions 40
• Suppression of leading zeros for a numeric field through 43.

• Omission of a sign from the low-order position of a Edit Word


numeric field
Enter any edit word to specify editing of numeric
• Punctuation of a numeric field without having to fields. Edit words must be enclosed by apos-
generate an edit word trophes. Constants are allowed within edit words.
Edit words are not used with edit codes. However,
A table summarizing the edit codes that can be entered when edit codes 1 through 4, A through D, and J
in column 38 is found in appendix D. through M are used, positions 45 through 47 may
contain '*' (to denote asterisk fill) or '$' (to denote
Column 39 (Blank After) a floating dollar sign). .

Blank a. Record description line


b. Field is not reset after being
written out.

96768710 A C-9
RPG II REFERENCE TABLES D

TABLE D-1. OPERATION CODES

Operation
Type of Code Factor 2 Result Half Resulting
Operation Function of Operation (Columns Indicators Faetor 1 Field Adjust Indicators
28-32)

Add Faetor 2 to Faetor 1. ADD 0 R R R 0 0

Clear Result Field and add Z-ADD 0 B R R 0 0


Faetor 2.
Subtract Factor 2 from SUB 0 R R R 0 0
Factor 1.
Clear Result Field and sub- Z-SUB 0 B R R 0 0
tract Faetor 2.
Arithmetic
Operations
Multiply Factor 1 by Faetor 2. MULT 0 R R R 0
I
I
0

Divide Factor 1 by Faetor 2. DIV 0 R R R 0 0

Move remainder of preeeding MVR 0 B B R B 0


division to Result Field.
Sum elements of an array and XFOOT 0 B R R 0 0
put sum in Result Field.
Derive the square root of SQRT 0 B R R B 0
Factor 2.
Move Faetor 2 into Result MOVE 0 B R R B 0
Field, right-justified.
Move Move Factor 2 into Result MOVEL 0 B R R B B
Operations Field, left-justified.
Move Faetor 2 array into MOVEA 0 B R R B B
Result Field, left-justified.
Move low zone of Factor 2 MLLZO 0 B R R B B
to low zone of Result Field.
Move high zone of Factor 2 MHHZO 0 B R R B B
to high zone of Result Field.
Move Zone
Operations Move low zone of Factor 2 MLHZO 0 B R R B B
to high zone of Result Field.
Move high zone of Factor 2 MHLZO 0 B R R B B
to low zone of Result Field.
Compare Factor 1 to Factor 2. COMP 0 R R B B R
Compare
and Zone Identify the zone in the left- TESTZ 0 B B R B R
Testing most position of the Result
Operations Field.

0= Optional
R = Required
B = Blank

96768710 A D-1
TABLE D-1. OPERATION CODES (Continued)

Operation
Type of Code
Operation Function of. Operation (Columns Indicators Factor 1 Factor 2 Result
Field
Half Resulting
Adjust Indicators
28-32)

Set on specified bits. BITON 0 B R R B B


Binary
Field Set off specified bits. BITOF 0 B R R B B
Operations
Test specified bits. TESTB· 0 B R R B R
Set one, two, or three SETON 0 B B B B R
Setting specific indicators on·.
Indicators
Set one, two, or three SETOF 0 B B B B R
specific indicators off.
Branch to another RPG n GOTO 0 B R B B B
calculation specification
Branching line.
within
RPGn Identify the name in Factor 1 TAG B R B B B B
as a destination label to
which GOTO may branch.
Table lookup. J~OKUP 0 R R 0 B R
Lookup
Operations
Array lookup. LOKUP 0 R R B B B
Beginning of the subroutine. BEGSR B R B B B B
Internal End of the subroutine. t ENDSR B 0 B B B B
Subroutines
Call to execute the subrou- EXSR 0 B R B B B
tine.
Call to execute the subrou- EXIT 0 B R B B B
External tine.
Subroutines
Define argument for exter- RLABL B B B R B B
nal subroutine.
Forcing record to be read FORCE 0 B R B B B
next
Forcing output printing EXCPT 0 B B B B B
A field is printed on the con- DSPLY 0 0 R 0 B B
sole device and/or data is
entered via the console de-
vice into a field.
Program A record is read from a READ 0 B R B B 0
Control demand file.
A record is read from or CHAIN 0 R R B B 0
written to a disk file.
Sets lower limits for in- SETLL 0 R R B B B
dexed files being processed
within limits
Debug Aid in finding programming DEBUG 0 0 R 0 B B
Function errors
0= Optional
R = Required t Columns 7 and 8 must have an SR entry for alllnternal subroutine lines.
B = Blank

D-2 96768710 A
TABLE D-l. OPERATION CODES (Contd)

Operation
Type of Code Result Half Resulting
Operation Function of Operation (Columns Indicators Factor 1 Factor 2 Field Adjust Indicators
28-32)
Debug Aid in finding programming DEBUG 0 0 R 0 B B
Function errors
Time Get time of day TIME 0 B B R B B
0= Optional
R = Required
B = Blank

TABLE D-2. SUMMARY OF PROGRAM INDICATORS

Indicator Where Where Turned On Turned Off Notes


Defined Used
Field Input Calculation Spec i- By Blank or Zero (or Before this field Turning these indica-
Indicators Specifications fications sheet, Indi- Plus or Minus) in status is to be tested tors on or off can
01-99 sheet cators column. specified field the next time also be accomplished
Output Specifica- by using the SETON
tions sheet, Output and SETOF operation
Indicators column codes.
HI-H9 Input Calculation Specifi- Whenever the Internally, at the Turning these indicators
Specifications cations sheet, Indi- specified field end of the detail on or off can also be
sheet cators column; status or record cycle accomplished by using
Output Specifica- identification the SETUP and SETOF
tions sheet, Output condition is satisfied operation codes.
Indicators column
LR Internal Calculation Specifi- After the last At the beginning of Turning these indicators
cations sheet, record of the last object program exe- on can also be accom-
Control Level input file has been cution plished by using SETON
column; Output processed operation codes. All
Specifications sheet, control level indicators
Output Indicators (LI-L9) are also turned
column on when LR is turned
on internally.
LO Internal Calculation Specifi- At the beginning Never turned off Cannot be SETON or
cations sheet, Con- of object program by RPG II SETOF.
trol Level column; execution
Output Specifica-'
cations sheet, Output
Indicators column
Control level Input Calculation Speci- When the value in a At the end of the Turning these indica-
indicators Specifications fications sheet, control field changes. following detail tors on or off can also
Ll-L9 sheet Control Level or All lower level indi- cycle be accomplished by
Indicators column; cators are also using the SETON and
Output Specifica- turned on. SETOF operation codes.
tions sheet, Output
Indicators column
MR Internal Calculation Spec i- When the matching When all total
fications sheet, fields of a secondary calculations and
Indicators column; file match the output are completed
Output Specifica- matching fields of for the last record
tions sheet, Output the primary file of the matching
Indicators column group

lP Internal Output Specifica- At the beginning of Before the first


tions sheet, Output object program detail record is
Indicators column execution read

96768710 A D-3
TABLE D-2. SUMMARY OF PROGRAM INDICATORS (Contd)

Indicator Where Where Turned On Turned Off


Defined Used Notes

Resulting Calculation Calcula tion Speci- For 01-99, the next Turning these indicators
Indicators Specifications fications sheet, time the sarrie indi- on or off can also be
01-99 or sheet Indicators column; cator is a resulting accomplished by using
HI-H9 Output Specifica- indicator and the the SETON and SETOF
tion sheet, Output specified condition operation codes. Indi-
Indicators column is not met. cators 01-99 and HI-H9
With By a positive (or are the com monly used
arithmetic negative or zero) resulting indicators.
operations balance in field However, LI-L9, LR,
Plus and previously defined
Minus indicators (OA-OG and
Zero OV) are also acceptable
to the compiler.
With COMP For HI-H9, intern-
High If Factor 1 > ally, at the end of
Factor 2; the detail cycle
Low If Factor 1 <
Factor 2;
Equal If Factor 1 =
Factor 2
WithOLOKUP
High If table>
Factor 1;
Low If table <
Factor 1;
Equal If table =
Factor 1
With TESTZ If a C zone or & is
High present; if a D zone
or minus sign is pres-
Low ent; if a C or D zone
is not present
Equal •
With CHAIN Bya no record found
(random condition
processing)
Columns 54-55
With READ By end-of-file on the
Columns 58-59 demand file
OA-OG,OV File Calcula~ion Speci- When the destination At the end of the Turning these indicators
Description fications sheet, of a space, skip, or detail cycle on or off can also be
Specifica tions Indicators column; print operation falls accomplished by using
sheet Output Specifica- within the overflow the SETON and SETOF
tion sheet, Output area operation codes.
Indicators column
Record Input Calculation Speci- When the specified Before the next Turning these indicators
Identifying Specifica tions fication sheet, record has been read record is read dur- on or off can also be
Indicator sheet Indicators column; and before total cal- ing the next cycle. accomplished by using
01-99 Output Specifica- culations ar~ exe- the SETON and SETOF
tion sheet, Output cuted operation codes.
Indicators column

D-4 96768710 A
TABLE D-3. VALID INDICATORS

File Output
Description Input Form Calculations Form Form
Form

File Field Control Condi- Condi-


Indicators Overflow Condi- Record ID Control Record Field Level tioning Resulting tioning
Indicator tioning Indicator Level Relation ~ndicator Indicator Iridicator Indicator Indicator
(Columns (Columns (Columns (Columns (COlU~ns (Columns (Columns (Columns (Columns (Columns
33-34) 71-72) 19-20) 59-60) 63-64) 65-70) 7-8) 9-17) 54-59) 23-31)

01-99 X X X X X X
H1-H9 X X X X X X
1P X2
MR X3 X X
OA-OG.OV X X X X4
LO X X
L1-L9 X X X3 X X X X
LR X X X X X
U1-U8 X5 X X X

X =Indicator valid in these columns


1. Invalid for look-ahead fields
2. Valid only for heading and detail lines
3. Invalid for match field or control field specification
4. Cannot condition an exception record. but may condition fields of an exception record
5. Invalid for table input files

'---

D-5
96768710 A
TABLE D-4. EDIT CODES

Sign-for Zero Balancel Zero


Edit Commas Decimal Negative Value
Point Domestic or Suppress
Code Foreign (I) Foreign (J)
No Sign CR - United Kingdom
1 Yes Yes x .00 or 0 ,00 or 0 0,00 or 0 Yes
2 Yes Yes x Blanks Blanks Blanks Yes
3 No Yes x .00 or 0 ,00 or 0 0,00 or 0 Yes
4 No Yes x Blanks Blanks Blanks Yes
A Yes Yes x .00 or 0 ,00 or 0 0,00 or 0 Yes
B Yes Yes x Blanks Blanks Blanks Yes
C No Yes x .00 or 0 ,00 or 0 0,00 or 0 Yes
D No Yes x Blanks Blanks Blanks Yes
J Yes Yes x .00 or 0 ,00 or 0 0,00 or 0 Yes
K Yes Yes x Blanks Blanks Blanks Yes
L No Yes x .00 or 0 ,00 or 0 0,00 or 0 Yes
M No Yes x Blanks Blanks Blanks Yes
X2 No No No
Y No No Yes 3
Z No No Yes
1. Zero balances for foreign formats are written in two ways, depending upon the entry of I or J in column 21 of the Con-
trol Card Specifications sheet.
2. The only editing performed with the X code is the insertion of two blank characters in front of each element of an
array.
3. The leftmost zero only is suppressed. The source field can be up to 15 digits. Slash characters are inserted between
every two characters. If the length of the field is an odd number of characters, a single digit follows the rightmost
slash. For example, source fields having three, four, and five digits have the following edited patterns:
nnln
nnlnn
nnlnnln

D-6 96768710 A
TABLE D-5. NORMAL COLLATING SEQUENCE AND HEXADECIMAL
EQUIVALENTS OF CHARACTERS
Collating
Sequence Character I Hexadecimal
Equivalent
Collating
Sequence Character Hexadecimal
Equivalent
1 Blank 40 33 F C6
2
3
•. 4A
4B
34
35
G
H-
C7
C8
4 4C 36 I C9
5 ( 4D 37 DO
6 + 4E 38 J D1
7 4F 39 K D2
8 &: 50 40 L D3
9 5A 41 M D4
10 $- 5B 42 N 05
11 • 5C 43 0 06
12 ) 5D 44 P D7
13 ; .. 5£ 45 Q D8
14 5F 46 R 09
15 - (minus) 60 47 S E2
16 I 61 48 T £3
17 • 6B 49 U E4
18 % 6C 50 V E5
19
20
- (underscore) 6D
6E
51
52
W
X
E6
E7
21 ? 6F 53 Y E8
22 : 7A 54 Z E9
23 It 7B 55 0 FO
24 @ 7C 56 1 F1
25 , 7D 57 2 F2
26 = 7E 58 3 F3
27 " 7F 59 4 F4
28 A Cl 60 5 F5
"- 29 B C2 61 6 F6
30 C C3 62 7 F7
31 D C4 63 8 F8
32 E C5 64 9 F9

96768110 A D-7
TABLE D-6. PRINTABLE CHARACTERS GROUPED TABLE D-6. PRINTABLE CHARACTERS GROUPED
BY EQUAL ZONES BY EQUAL ZONES (Contd)

Group Character Group Character

•. blank
0
1 < 1
( 2
+ 3
I 8
4
5
I 6
$ 7
2 •) 8
9
;
~

I
• (comma) TABLE D-7. PRINTABLE CHARACTERS GROUPED
96 BY EQUAL DIGITS
3
- (underscore)
> Group Character
?
blank
: &
I 1 - (minus)
@ }
4 , (apostrophe) o(zero)
=
" I
2 A
& J
A 1
B
C B
D K
5 3
E S
F 2
G
H C
I 4 L
T
- (minus) 3
}
J D
K 5 M
L U
6 M 4
N
0 E
P N
6
Q V
R 5

S F
T 7 o (letter 0)
U W
V 6
7 W
X G
Y 8 P
Z X
7

D-8 96768710 A
TABLE D-7. PRINTABLE CHARACTERS GROUPED
BY EQUAL DIGITS (Contd)

Group Character

H
Q
9 y
8

I
10 R
Z
9

t
11 I
:

12 $
• (comma)

<

13 %

@

(
)
14 _ (wtderscore)
• (apostrophe)
+
15 ;
>
=

....,I
16 !
n

96768710 A D-9
The 1963 American Standard Code for Information Interchange (ASCD) is used by MSOS. ASCD code uses
eight- bits: bit 8, which is always zero, is omitted in the table below. Bits "1 through 4 contain the low-order four
bits of code for the character in that row. Bits 5 through 7 contain the high-order three bits of the code for the
character in that column. The code is given in ascending sequence.

TABLE D-8. ASCD CHARACTER SET

ASCII Bit Hexadecimal


Symbol Configur.ation Number Meaning

NULL 000 0000 0 Null/idle


SOM 000 0001 1 Start of message
BOA 000 0010 2 End of address
BOM 000 0011 3 End of message
BOT 000 0100 4 End of transmission
WRU 000 0101 5 Who are you
RU 000 0110 6 Are you
BELL 000 0111 7 Audible signal
PE 000 1000 8 Format effector
O
HT/SK 000 1001 9 Horizontal tab skip (punched card)
LF 000 1010 A Line feed
V 000 1011 8 Vertical tabulation
TA8
PF 000 1100 C Form feed
CR 000 1101 D Carriage return
80 000 1110 B Shift out
81 000 1111 P Shift in
DC 001 0000 10 Device control/data link escape
O
DC 001 0001 11
1
DC 001 0010 12 Device controls
2
DC 001 0011 13
3
DC (STOP) 001 0100 14 Device control/stop
4
ERR 001 0101 15 Error
SYNC 001 0110 16 Synchronous idle
LEM 001 0111 17 Logical end of media
80 001 1000 18
Sl 001 1001 19
82 001 1010 1A
S3 001 1011 18
Information separators
84 001 1100 1C
8 001 1101 ID
5
86 001 1110 IE
87 0()1 1111 IF

D-I0 96768710 A
TABLE D-8. ASCII CHARACTER SET (Contd)

8-Bit 171x-l 171x-2 6-Bit 8-Bit 171x-l 172x-2 6-Bit


026 029 Ext. BCD TTY TTY 026 029
ASCII TTY TTY ASCII Ext. BCD
Punches Punches Array Array PuncMs Punches
Codes Array Array Mag Tape Codes Mag Tape

20 16 Space Space No Punch No Punch 20 40 @ @ 0-8-7 8-4 37


8 16
21 11-8-2 12-8-7 52 41 A A 12-1 12-1 61
n 8-7 8-7 17 42 B B 12-2 12-2 62
22 "
23 /I 1# 12-8-7 8-3 77 43 C C 12-3 12-3 63
24 $ $ 11-8-3 11-8-3 53 44 0 0 12-4 12-4 64
25 % % 0-8-5 0-8-4 35 45 E E 12-5 12-5 65
26 &: &: 8-2 12 00 (35) 46 F F 12-6 12-6 66
27
, , 8-4 8-5 14 47 G G 12-7 12-7 67
28 ( ( 0-8-4 12-8-5 34 48 H H 12-8 12-8 70
29 ) ) 12-8-4 11-8-5 74 49 I I 12-9 .12-9 71
2A • • 11-8-4 11-8-4 54 4A J J 11-1 11-1 41
2B + + 12 12-8-6 60 4B K K 11-2 11-2 42
2C , , 0-8-3 0-8-3 33 4C L L 11-3 11-3 43
20 - - 11 11 40 40 M M 11-4 11-4 44
2E 12-8-3 12-8-3 73 4E N N 11-5 11-5 45
2F / / 0-1 0-1 21 4F 0 0 11-6 11-6 46
30 0 0 0 0 12 50 P P 11-7 11-7 47
31 1 1 1 1 01 51 Q Q 11-8 11-8 50
32 2 2 2 2 02 52 R R 11-9 11-9 51
33 3 3 3 3 03 53 S S 0-2 0-2 22
34 4 4 4 4 04 54 T T 0-3 0-3 23
35 5 5 5 5 05 55 U U 0-4 0-4 24
36 6 6 6 6 06 56 V V 0-5 0-5 25
37 7 7 7 7 07 57 W W 0-6 0-6 26
38 8 8 8 8 10 58 X X 0-7 0-7 27
39 9 9 9 9 11 59 Y Y 0-8 0-8 30
3A : : 8-5 8-2 15 5A Z Z 0-9 0-9 31
3B ; ; 11-8-6 11-8-6 56 5B 12-8-5 12-8-2 75
3C 12-8-6 12-8-4 76 5C 0-8-2 0-8-2 36
3D = = 8-3 8-6 13 50 11-8-5 11-8-2 55
3E 8-6 0-8-6 16 5E 11-8-7 11-8-7 57
3F ? ? 12-8-2 0-8-7 72 5F 0-8-6 0-8-5 32
Refer to note 2.
Refer to note 4.
1. The 171x-2 teletypewriter (TTY) array is the ASCII 68, 64 character subset. This array is the same as used on the 171x-3
devices which receive from a 1774.
2. To operate in 026 punched card mode, ASCII 63 options are selected. To operate in 029 punched card mode, ASCII 68
options are selected. These options are assembly-time options for each driver affected.
3. The CDC Standard 1.10.003 is supported by an assembly option. For CDC ASCII mode of operation, the card punches
12-8-2 and 12-0 are stored internally as 78. The card punches 11-8-2 and 11-0 are stored internally as 70. For line
printer operations, the internal codes 78 and 7 D are converted to 58 and 5D to allow printing the hardware compatible
graphic characters [(left bracket) and] (right bracket).
4. 8ince 173x magnetic tape controllers do not provide any code conversion, BCD code 00 is illegal and causes a noise rec-
ord or BCD code 35 is substituted for the illegal 00 code to prevent tape errors.
On tape write operations the ASCII codes 25 (%) and 26 (&:) are written as 8CD 35 ,
16 16 8
On tape read operations the BCD code 35 is always translated to an ASCII $25 (%).
8

96768710 A D-ll
TABLE 0-9. DEVICE CODES, RECORD LENGTHS, ANO BLOCK LENGTHS

Device Logical Maximum Maximum


Mnemonic Unit Record Length Block Length

I DISK 8 8191 9999

CRT77 4 80 80

TAPEO 6 8191 9999

TAPE1 16 8191 9999

TAPE2 17 8191 9999

PRINT84 12 131 1:31

READOI 10 80 80

MFCMl 10 80 80

MFCM2 10 80 80

OISK40 8 8191 9999

I OISK45 8 8191 9999

MFCUI 10 80 80

MFCU2 10 80 80

PRINTER 12 131 131

I PRINTR2 12 131

80
131

80
CONSOLE 4

I TAPE 6 8191 9999

READER 10 80 80

READ42 10 80 80

PUNCH 11 80 80

8191 9999

I
SPECIAL

BLANK t 8191 9999

t In batch mode the standard input/output unit is used. In terminal mode the user terminal is
employed.

0-12 96768710 C
TABLE 0-10. ASCII TO EBCDIC TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE
CODING SHEET (CYBER 18 GRAPHICS)

Replaced Replaced
CYBER 18 ASCII By/Takes CYBER 18 ASCII By/Takes
Code Graphic Entry Place of Code Graphic Entry Place of

00000000 Null 00 00111000 8 38 F8


00000001 SOM 01 00111001 9 39 F9
00000010 STX 92 00111010 : 3A 7A
00000011 ETX 03 00111011 ; 3B 5E
00000100 EOT 04 00111100 < 3C 4C
00000101 ENQ 05 00111101 = 3D 7E
00000110 ACK 06 00111110 > 3E 6E
00000111 BEL 07 00111111 ? 3F 6F
00001000 BS 08 01000000 @ 40 ·7C
00001001 HT 09 01000001 A 41 C1
00001010 LF OA 01000010 B 42 C2
00001011 VT OB 01000011 C 43 C3
00001100 FF OC 01000100 0 44 C4
00001101 CR 00 01000101 E 45 C5
00001110 SO OE 01000110 F 46 C6
00001111 SI OF 01000111 G 47 C7
00010000 OLE 10 01001000 H 48 C8
00010001 OC1 11 01001001 I 49 C9
00010010 OC2 12 01001010 J 4A 01
00010011 OC3 13 01001011 K 4B 02
00010100 OC4 14 01001100 L 4C 03
00010101 ANK 15 01001101 M 40 04
00010110 SYN 16 01001110 N 4E 05
00010111 ETB 17 01001111 0 4F 06
00011000 CAN 18 01010000 P 50 07
00011001 EM 19 01010001 Q 51 08
00011010 SUB 1A 01010010 R 52 09
00011011 ESC 1B 01010011 S 53 E2
00011100 FS 1C 01010100 T 54 E3
00011101 GS 10 01010101 U 55 E4
00011110 RS IE 01010110 V 56 E5
00011111 US IF 01010111 W 57 E6
00100000 Blank 20 40 01011000 X 58 E7
00100001 ! 21 5A 01011001 Y 59 E8
00100010 "# 22 7F 01011010 Z 5A E9
00100011 23 7B 01011011 [ ~ 5B 4A
00100100
00100101
$
%
24
25
5B
6C
01011100
01011101
",
]
5C
50
5F
27
00100110 & 26 50 01011110 5E 4F
00100111
, 27 70 01011111
A
-.... 5F 60
00101000 ( 28 40 01100000 60 20
00101001 ) 29 50 01100001 a 61 2F
00101010 * 2A 5C 01100010 b 62
00101011 + 2B 4E 01100011 c 63
00101100 t 2C 6B 01100100 d 64
00101101 - 20 60 01100101 e 65
00101110 2E 4B 01100110 f 66
00101111 / 2F 61 01100111 g 67
00110000 0 30 FO 01101000 h 68
00110001 1 31 F1 01101001 i 69
00110010 2 32 F2 01101010 j 6A
00110011 3 33 F3 01101011 k 6B 2C
00110100 4 34 F4 01101100 I 6C 25
00110101 5 35 F5 01101101 m 60 3B
00110110 6 36 F6 01101110 n 6E 3E
00110111 7 37 F7 01101111 0
I
6F 3F

NOTE: Blank entries indicate that the code is not changed.

96768710 A 0-13
TABLE D-10. ASCD TO EBCDIC TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE
CODING SHEET (CYBER 18 GRAPHICS) (Contd)

Replaced Replaced
CYBER 18 ASCD By/Takes CYBER 18 ASCD By/Takes
Code Graphic Entry Place of Code Graphic Entry Place of

01110000 p 70 10101001 A9
01110001 q 71 10101010 AA
01110010 r 72 10101011 AB
01110011 s 73 10101100 AC
01110100 t 74 10101101 AD
01110101 u 75 10101110 AE
01110110 v 7'6 10101111 AF
01110111 w 77 10110000 BO
01111000 x 78 10110001 B1
01111001 Y 79 10110010 B2
01111010
01111011
01111100
..-z
:
7A
7B
7C
3A
CO
20
10110011
10110100
10110101
B3
B4
B5
01111101 -&- 7D DO. 10110110 B6
01111110 ,... 7E 3D 10110111 B7
01111111 Delete 7F 22 10111000 B8
10000000 80 10111001 B9
10000001 81 10111010 BA
10000010 82 10111011 BB
10000011 83 10111100 BC
10000100 84 10111101 BD
10000101 85 10111110 BE
10000110 86 10111111 BF
10000111 87 11000000 CO 23
10001000 88 11000001 C1 41
10001001 89 11000010 C2 42
10001010 8A 11000011 C3 43
10001011 8B 11000100 C4 44
10001100 8C 11000101 C5 45
10001101 8D 11000110 C6 46
10001110 8E 11000111 C7 47
10001111 8F 11001000 C8 48
10010000 90 11001001 C9 49
10010001 91 11001010 CA
10010010 92 11001011 CB
10010011 93 11001100 CC
10010100 94 11001101 CD
10010101 95 11001110 CE
10010110 . 96 11001111 CF
10010111 97 11010000 DO 29
10011000 98 11010001 D1 24
10011001 99 11010010 D2 2E
10011010 9A 11010011 D3 3C
- 10011011 9B 11010100 D4 28
10011100 9C 11010101 D5 2B
10011101 9D 11010110 D6 2A
10011110 9E 11010111 D7 26
10011111 9F 11011000 D8 51
10100000 AO 11011001 D9 52
10100001 Al 11011010 DA
10100010 A2 11011011 DB
10100011 A3 11011100 DC
10100100 A4 11011101 DD
10100101 A5 11011110 DE
10100110 A6 11011111 DF
10100111 A7 11100000 EO
10101000 A8 11100001 E1

NOTE: Blank entries indicate that the code is not changed.

D-14 96768710 A
TABLE 0-10. ASCII TO EBCDIC TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE
CODING SHEET (CYBER 18 GRAPHICS) (Contd)

Replaced Replaced
CYBER 18 A.SCII By/Takes CYBER 18 ASCII By/Takes
Code Graphic Entry Place of Code Graphic Entry Place of

11100010 E2 53 11110001 Fl 31
11100011 E3 54 11110010 F2 32
11100100 E4 55 11110011 F3 33
11100101 E5 56 11110100 F4 34
11100110 E6 57 11110101 F5 35
11100111 E7 58 11101110 F6 36
11101000 E8 59 11110111 F7 37
11101001 E9 21 11111000 F8 38
11101010 EA 11111001 F9 39
11101011 EB 11111010 FA
11101100 EC 11111011 FB
11101101 ED 11111100 FC
11t'01110 EE 11111101 FC
11101111 EF 11111110 FE
11110000 FO 30 11111111 FF

NOTE: Blank entries indicate that the code is not changed.

TABLE 0-11. EBCDIC TO ASCII TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE
CODING SHEET (SYSTEM/3 GRAPHICS)

System/3
Replaced
By/Takes System/3 I Replaced
By/Takes
Place of Graphic Entry ~'-~e of
Code Graphic Entry Code

IB
-
00000000 00 00011011
00000001 01 00011100 lC
00000010 02 00011101 10
00000011 03 00011110 IE
00000100 04 00011111 IF
00000101 05 00100000 20 7C
00000110 06 00100001 21 E9
00000111 07 00iOOOl0 22 7F
00001000 08 00100011 23 CO
00001001 09 00100100 24 01
00001010 OA 00100101 25 6C
00001011 OB 00100110 26 07
00001100 OC 00100111 27 50
00001101 00 00101000 28 04
00001110 OE 00101001 29 00
00001111 OF 00101010 2A 06
00010000 10 00101011 2B 05
00010001 11 00101100 2C 6B
00010010 12 00101101 20 60
00010011 13 00101110 2E 02
00010100 14 00101111 2F 61
00010101 15 00110000 30 FO
00010110 16 00110001 31 Fl
00010111 17 00110010 32 F2
00011000 18 00110011 33 F3
00011001 19 00110100 34 F4
00011010 lA 09110101 35 F5

NOTE: Blank entries indicate that the code is not changed.

96768710 A 0-15
TABLE D-11. EBCDIC TO ASCII TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE
CODING SHEET (SYSTEM/3 GRAPHICS) (Contd)

Replaced Replaced
System/3 By/Takes System/3 By/Takes
Code Graphic Entry Place of Code Graphic Entry Place of

00110110 36 F6 01101101 - 6D 5F
00110111 37 F7 01101110 > 6E 3E
00111000 38 F8 01101111 ? 6F 3F
00111001 39 F9 01110000 70
00111010 3A 7A 01110001 71
00111011 3B 6D 01110010 72
00111100 3C D3 01110011 73
00111101 3D 7E 01110100 74
00111110 3E 6E 01110101 75
00111111 3F 6F 01110110 76
01000000 Blank 40 20 01110111 77
01000001 41 C1 01111000 78
01000010 42 C2 01111001 79
01000011 43 C3 01111010 : 7A 3A
01000100 44 C4 01111011 It 7B 23
01000101 45 C5 01111100 @ 7C 40
01000110 46 C6 01111101
, 7D 27
01000111 47 C7 01111110 = 7E 3D
01001000 48 C8 01111111 " 7F 22
01001001 49 C9 10000000 80 80
01001010 ¢ 4A 5B 10000000 81
01001011 4B 2E 10000010 82
01001100 < 4C 3C 10000011 83
01001101 ( 4D 28 10000100 84
01001110 + 4E 2B 10000101 85
01001111 I 4F 5E 10000110 86
01010000 & 50 26 1000'0111 87
01010001 -, 51 D8 10001000 88
01010010 52 D9 10001001 89
01010011 53 E2 10001010 8A
01010100 54 E3 10001011 8B
0101b101 55 E4 10001100 8C
01010110 56 E5 10001101 8D
01010111 57 E6 10001110 8E
01011000 58 E7 10001111 8F
01011001 59 E8 10010000 90
01011010 ! 5A 21 10010001 91
01011011 $ 5B 24 10010010 92
01011100 5C 2A 10010011 93
01011101 ) 5D 29 10010100 94
01011110 ; 5E 3B 10010101 95
01011111 5F 5C 10010110 96
01100000 60 2D 10010111 97
01100001 / 61 2F 10011000 98
01100010 62 10011001 99
01100011 63 10011010 9A
Oi100100 64 10011011 9B
01100101 65 10011100 ' 9C
01100110 66 10011101 9D
01100111 67 10011110 9E
01101000 68 10011111 9F
01101001 69 10100000 AO
01101010 6A 10100001 Al
01101011 6B 2C 10100010 A2
01101100 96 6C 25 10100011 A3

NOTE: Blank entries indicate that the code is not changed.

D-16 96768710 A
TABLE D-11. EBCDIC TO ASCII TRANSLATION TABLE AND ALTERNATE COLLATING SEQUENCE
CODING SHEET (SYSTEM/3 GRAPHICS) (Contd)

Replaced Replaced
System/3 By/Takes System/3 By/Takes
Code Graphic Entry Place of Code Graphic Entry Place of

10100100 A4 11010010 K D2 4B
10100101 A5 11010011 L D3 4C
10100110 A6 11010100 M D4 4D
10100111 A7 11010101 N D5 4E
10101000 A8 11010110 0 D6 4F
10101001 A9 11010111 P D7 50
10101010 AA 11011000 Q D8 51
10101011 AB 11011001 R D9 52
10101100 AC 11011010 DA
10101101 AD 11011011 DB
10101110 AE 11011100 DC
10101111 AF 11011101 DD
10110000 BO 11011110 DE
10110001 B1 11011111 DF
10110010 B2 11100000 EO
10110011 B3 11100001 E1
10110100 B4 11100010 S E2 53
10110101 B5 11100011 T E3 54
10110110 B6 11100100 U E4 55
10110111 B7 11100101 V E5 56
101i1000 B8 11100110 W E6 57
10111001 B9 11100111 X E7 58
10111010 BA 11101000 y E8 59
10111011 BB 11101001 Z E9 5A
10111100 BC 11101010 EA
10111101 BD 11101011 EB
10111110 BE 11101100 EC
10111111 BF 11101101 ED
11000000 -e- CO 7B 11101110 EE
11000001 A C1 41 11101111 EF
11000010 B C2 42 11110000 0 FO 30
11000011 C C3 43 11110001 1 F1 31
11000100 D C4 44 11110010 2 F2 32
11000101 E C5 45 11110011 3 F3 33
11000110 F C6 46 11110100 4 F4 34
11000111 G C7 47 11110101 5 F5 35
11001000 H C8 48 11110110 6 F6 36
11001001 I C9 49 11110111 7 F7 37
11001010 CA C 11111000 8 F8 38
11001011 CB 11111001 9 F9 39
11001100 CC 11111010 FA
11001101 CD 11111011 FB
11001110 CE 11111100 FC
11001110 CF 11111101 FD
11010000 {-e- DO 7D 11111110 FE
11010001 J D1 4A 11111111 FF

NOTE: Blank entries indicate that the code is not changed.

96768710 A D-17
RPG II ERROR MESSAGES E

COMPILATION ERRORS Where:

These messages are output during compilation of RPG II nnnn is the compilation error number.
source programs with the source listing. The error message
follows the source statement that contained the error and is x is the specifications form type H, F, E, L, I,
of the form: C, 0, or A. (A is for arrays.)

******** ERROR nnnnx Error numbers of 0100 and above are not recoverable and
object code is not generated. Error numbers are grouped by
form type in tables E-1 through E-5.
TABLE E-1. CONTROL CARD SPECIFICATION ERRORS

Error
Message Error Definition Action
Number
f - - - - - - - ---"'1'- - ~-

0001H Illegal entry in columns 7-14 Entry must be blank. No special action taken

0002H Illegal Debug entry in column 15 Entry must be blank. Blank assu m ed

0003H Illegal entry in columns 16-20 Entry must be blank. No special action taken

0004H Illegal Inverted Print entry in Entry must be D, I, J, or blank. Blank assu m ed
column 21

0005H Illegal entry in columns 22-25 Entry must be blank. No special action taken

0006H Illegal Alternate Collating Entry must be S or blank. S (alternate collating set)
Sequence ~ntry in column 26 assumed

0007H Illegal entry in columns 27-39 Entry must be blank. No special action taken

0008H Illegal Sign Handling entry in Entry must be blank. Blank assu med
column 40

0009H Illegal 1 P Forms Position Entry Entry must be 1 or blank. 1 (forms positioning) assumed
in column 41 I

0010H Illegal Indicator Setting entry Entry must be blank. Blank assumed
in column 42 -

OOllH Illegal File Translation entry Entry must be F or blank. F (file translation) assumed
in column 43

0012H Illegal entry in columns 44-49 Entry must be blank. No special action taken

0013H megal Formatted Dump entry Entry must be blank. Blank assumed
in column 50

0014H Illegal internal code entry in Entry must be E or blank. Blank assumed
column 51

0015H Illegal entry in columns 52-73 Entry must be blank. No special action taken

0016H Illegal Segmented Running entry Entry must be 1 or blank. Blank assu med
in· column 74

0017H This entry in column 52 is Entry must be 1 or 6. Blank assumed


invalid

0018H Invalid entry in column 49 Entry must be blank. Blank assumed

0019H Invalid entry in column 48 Entry must be blank or 1. Blank assumed

I 0020H Invalid entry in column 52 . Entry must be blank for Blank assumed
this configuration

96768710 C E-l
TABLE E-1. CONTROL CARD SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number

0100H Abnormal end-of-file reached Compiler exited

0101H Illegal Form Type entry in Entry must be H or F. Source line (record) bypassed;
column 6 processing continues with
next line.

0102H Invalid Form Type entry of H Header card encountered more Previous data ignored; pro-
in column 6 than once. cessing continues with new
data.

0103H Illegal JCB string

0001F Illegal File Type entry in Entry must be D, C, U, 0, or I. I assumed


column 15

0002F Illegal File Designation entry Entry must be D, T, R, C, S, Blank assu med
in column 16 P, or blank.

0003F Illegal Sequence entry in Entry must be A, D, or blank. Blank assumed


column 18

0004F Not used

0005F Illegal Extension Code entry Entry must be E, L, or blank. Blank assumed
in column 39

0006F Illegal Filename entry in Invalid character encountered Character accepted as part
columns 7-14 in name or name included on of file name
embedded blank

0007F Illegal File Format entry in Entry must be F, V, or D. F assumed


column 19

0008F Invalid File Designation Entry encountered more than Secondary file assumed
entry of P in column 16 once; primary file already
defined

0100F Abnormal end-of-file reached /* or ** encountered Compiler exited

0101F Illegal Form Type entry in Entry must be F, E, L, or I. Source line bypassed; pro-
column 6 cessing continues with next
line.

0102F Logical unit number in columns Entry is not a numeric value Blank entry assumed
50-52 is invalid. less than 256.

0103F Illegal Filename entry in Blank entry A blank filename assumed


columns 7-14

0104F Invalid Filename entry in Filename encountered more No special action taken
columns 7-14 than once

0105F Illegal Record Length entry in Entry must be a numeric entry Record length of one
columns 24-27 greater than zero assumed

0106F Illegal Record Address Type Entry must be A, P, I, or blank. Blank assumed
entry in column 31

0107F Illegal End of File entry in Entry must be E or blank. Blank assumed
column 17

E-2 96768710 A
TABLE E-l. CONTROL CARD SPECIFICATIO'N ERRORS (Contd)

Error
Message Error Definition Action
Number
0109F Illegal Block Length entry Entry must be a valid numeric Blank assumed
in columns 20-23 entry or blank.
OllOF Illegal Mode of Processing Entry must be L t R t or blank. Blank assumed
entry in column 28
OlllF Illegal Length of Key Field Entry must be a valid numeric Blank assumed
or Record Address Field entry or blank.
entry in columns 29-30
01l2F Illegal Type of File Organiza- Entry must.be It T t 1-9 t or Blank assumed
tion entry in column 32 blank.
01l3F Illegal Overflow Indicator in Entry must be OA-OG t OV t OA assumed
columns 33-34 or blanks.
01l4F Illegal Key Field Starting Entry must be a valid numeric Blank assumed
Location entry in columns entry or blank.
35-38
01l5F Illegal Device entry in Entry must be a valid device No device assigned to file
columns 40-46 name.

01l6F Illegal Symbolic Device entry Entry must be a blank. Blank assumed
in columns 47-52
01l7F Illegal Labels entry in Entry must be blank. Blank assumed
column 53
01l8F Illegal File Condition entry in Entry must be U1-U8 or blank. ·U1 assumed
columns 71-72
01l9F Illegal entry in column 67 Entry must be blank. Blank assumed
0120F K entry in column 53 invalid Continuation line requires an K assumed; line processed
wi th entry of blanks in entry of K. as a continuation line.
columns 7-52
0121F Illegal Option entry in columns Entry must be a valid option Source line bypassed; pro-
54-59 of a continuation line name (ASCU t BUFOFF t EBCDIC t cessing continues with next
or table/array name). line.

0122F Illegal File Addition/Unordered Entry must be At U, or blank. Blank assumed


entry in column 66
0123F Illegal Tape Rewind entry in Entry must be R t U, N, or Blank assumed
column 70 blank.

0124F Entry in columns 60-65 in- Entry must be numeric. Zero assumed
valid with Option entry of
BUFOFF in columns 54-59
0125F Invalid Sequence entry in Different entry encountered Previous entry used
column 18 previously

0126F No File Designation entry of No primary input file specified. No special action taken
P in column 16 encountered
0127F File Type entry of I, Ut or C Only output and display files No special action taken
in column 15 invalid with File do not require file designation.
Designation entry of blank in
column 16

96768710 A E-3
TABLE E-l. CONTROL CARD SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
0128F File Type entry of 0 or D in Only input t update t or com- No special action taken
column 15 invalid with File bined files can be demand
Designation entry of D in files.
column 16.
0129F File Type entrY'of 0 or D in Only input t update t or com- No special action taken
column 15 invalid with File bined files can be table/array
Designation entry of T in files.
column 16.
0130F File Type entry of 0, U, C, or Only ~nput files can be record No special action taken
D in column 15 invalid with address files.
File Designation entry of R
in column 16.
0131F File Type entry of C or D in Only input, output or update No special action taken
column 15 invalid with File files can be chained files.
Designation entry of C in
column 16.
0132F File Type entry of 0 or D in Only input, update, or com- No special action taken
column 15 invalid with File bined files can be secondary
Designation entry of S in files.
column 16
0133F File Type entry of 0 or D in Only input, update, or com- No special action taken
column 15 invalid with File bined files can be primary
Designation entry of P in files.
column 16
0135F File Type entry of 0 or D in Only input, update or com- No special action taken
column 15 invalid with End of bined files permit end-of-file
File entry of E in column 17 designation.
0136F File Designation entry of C, Only record address, primary, No special action taken
T, D, or blank in column 16 or secondary files permit end-
invalid with End of File entry of-file designation.
of E in column 17
0137F File Type entry of 0 or D in Only input t update, or com- No special action taken
column 15 invalid with bined files permit sequence
Sequence entry of A or D in specification.
column 18
0140F Block Length entry in columns Block Length must be record No special action taken
20-23 invalid with File Format length or a multiple for fixed
entry of F in column 19 and length records.
Record Length entry in
columns 24-27
0141F Block Length entry in columns Block Length must be at least No special action taken
20-23 invalid with File Format eight bytes larger than record
entry of V in column 19 and length for variable length
Record Length entry in records.
columns 24-27
0144F Record Address Type entry ADDROUT file organization No special action taken
of A, P, or blank in column 31 requires an I in column 31.
invalid with File Organization
entry of T in column 32

E-4 96768710 A
TABLE E-l. CONTROL CARD SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
0145F Mode of Processing entry of ADDROUT file organization No special action taken
R or L in column 28 invalid cannot be processed randomly
with File Organization entry or within limits.
of T in column 32
0146F Record Address Type Entry of Record address type processing No special action taken
A or P in column 31 invalid illegal for sequential file
with File Organization entry
of 1-9 or blank in column 32
0147F Mode of Processing entry of Limit processing. illegal for No special action taken
L in column 28 invalid with sequential or direct file
Type of File Organization
entry of 1-9 or blank in
column 32
0149F Record Address Type entry of Indexed sequential file must No special action taken
blank in column 31 invalid have alphanumeric or packed
with File Organization entry ~eys.
of I in column 32
0151F Record Address Type entry Direct files must be retrieved No special action taken
of A or P in column 31 invalid by key or identification.
with direct file access (R in
column 28 and blank or 1-9 in
column 32)
0152F Invalid Length of Key Field Columns 29-30 entry illegal No special action taken
·• or Record AddresS Field with a non-record address file
entry in columns 29-30 that does not use keys
0153F When device is not a printer, Overflow indicator can only be No special action taken
Extension Code entry of E or defined for a line counter file.
blank in column 39 invalid
with Overflow Indicator entry
of OA-OG or OV in columns
33-34
0154F Invalid Key Field Starting Location specification illegal No special action taken
Location entry in columns with non-record address files
35-38 not using keys
0155F File Format entry of V or D, in Table files must be fixed No special action taken
column 19 invalid with File format.
Designation entry of T in
column 16
0156F Display File (column 15) ille- Display files must ·use a con- N0 special action taken
gal with device specified in sole or similar device.
columns 40-46
0157F Combined,File (column 15) . Combined files must use a card No special action taken
illegal with device specified reader/punch device.
in columns 40-46
0158F Update File (column 15) ille- Update file must use a disk No special action taken
gal with device specified in device.
columns 40-46
0159F Output File (column 15) ille- Output files must use a device No special action taken
gal with device specified in capable of output.
columns 40-46

96768710 A E-5
TABLE E-l. CONTROL CARD SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number

0160F Input File (column 15) illegal Input files must use a device No special action taken
with device specified in capable of input.
columns 40-46
0161F For device specified (columns For device specified, column No special action taken
40-46), file must be sequential 31 must be blank.
(column 31).
0162F For device specified (columns Entry in column 19 must be No special action taken
40-46), records must be fixed F for device specified.
length (column 19).
0163F For device speCified (columns Number of extents must be Blank number of extents
40-46), multivolume files (col- blank for device specified. assumed
umns 68-69) not allowed
0164F Block Length (columns 20-23) Block length must be less than Maximum device length
'exceeds maximum record or equal to maximum device assumed
length for device specified in length.
columns 40-46.
0165F Record Length (columns 24-27) Record length must be less Maximum device length
exceeds maximum record than or equal to maximum de- assumed
length for device specified in vice length.
columns 40-46.
0170F Core Index Entry in columns Core index legal only with in- No special action taken
60-65 invalid with File Organi- dexed sequential files pro-
zation entry of T, 1-9, or blank cessed randomly.
in column 32 and with Mode of
Processing entry 'of L or biank
in column 28
0171F File Addition entry of A in col- File addition legal only with No special action taken
umn 66 invalid with File Type input, output, and update files
entry of C or D in column 15
0173F Device entry in columns 40-46 Tape rewind can only be speci- No' special action taken
invalid with Tape Rewind fied with tape files.
entry in column 70
0174F megal Filename entry in First character in column 7 No special action taken
columns 7-14 cannot be numeric or· blank.
0178F megal number of extents entry Entry must be numeric or Blanks assumed
in columns 68-69 blank.
0179F megal entry in columns'73-74 Entry must be blank. No special action taken
0180F File Condition entry of U1-U8 File conditioning indicator, No special action taken
in columns 71-72 invalid with illegal with display file
File Type entry of D in column
15
0181F Extension Code entry of E in Extension specifications not No special action taken
column 39 invalid with File allowed with display file
Designation of D in column 16
0182F Extension Code entry of E in Extension specifications not No special action taken
column 39 invalid with Device allowed with console file
entry of CONSOLE in columns
40-46

E-6 96768710 A
TABLE E-l. CONTROL CARD SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number

0183F Extension Code entry of E in Extension specifications not No special action taken
column 39 invalid with File allowed with indexed file
Organization entry of I in
column 32

0184F Extension Code entry of L in Line counter specifications not No special action taken
column 39 invalid with Device allowed with specified device
entry in columns 40-46

0185F Sequence entry of A or D in Sequence specification illegal No special action taken


column 18 invalid with File with demand or table file
Designation entry of T, C, R,
or D in column 16

0186F File specification line with D-format file requires BUFOFF No special action taken
File Format entry of D in continuation specification.
column 19 not followed by
continuation line with Option
entry of BUFOFF in columns
54-59

0187F File Format entry of F or V BUFOFF legal only with D- No special action taken
in column 19 invalid with type records
Option entry of BUFOFF in
columns 54-59

0188F Invalid Storage Index Entry Entry was not a valid numeric Blank assumed (no core index)
entry in columns 60-65 entry or blank.

0189F Chained file (C in column 16) No special action taken


must be processed randomly
(R in column 28)
,---- .- -' ".'" .,--
... ~-- .... ~-.-- ---
0190F Key starting position greater No special action taken
than record length

0191F Additional I/O areas are Column 32 must be I, T, or No special action taken
not allowed within shared I/O blank when shared I/O is
specified.

0192F Multivolume files may not be Columns 68-69 must be blank No special action taken
used with shared I/O or 01 when shared I/O is used.
-
0913F Randomly processed primary No special action taken
file must be processed by
ADDROUT I

96768710 C E-7
TABLE E-2. EXTENSION SPECIFICATION ERRORS

Error
:vJessage Error Definition Action
Number

0001E Chaining entries in columns


7-10 must be blank.

0002E From Filename entry in No special action taken


columns 11-18 encountered
on file specifications; how-
ever, file specification did not
contain an Extension Code
entry of E in column 39.

0003E File speci fica t ion processed No special action taken


with an Extension Code of E
in column 39. This requires
extension specifications; how-
ever, no extension specifica-
tion records with a Form Type
entry of E in column 6 are
encountered for the file. File
name follows.

0100E Abnormal end-of-file reached Compiler exited.

OlDIE Illegal Form Type entry in Card out of sequence Source line bypassed; pro-
column 6 cessing continues with next
line.

0102E Illegal Table or Array Name Blank entry Zero length name assumed;
entry in columns 27-32 processing continues.

0103E Illegal Length of Entry in Entry must be 1-256 for Length of 1 assumed.
columns 40-42 alpha, 1-15 for numeric,
1-14 binary.

0104E Illegal Packed/Binary entry Entry must be P, B, L, R, or Blank assumed


in column 43. blank

0105E Illegal Decimal Positions Entry must be 0-9 or blank. Zero assu m ed
entry in column 44

0106E Illegal Sequence (A/D) entry Entry must be A, D, or blank. Blank assumed.
in column 45

0107E Illegal Length of Entry entry Entry must be 1-256. Length of 1 assu m ed
in columns 52-54

0108E Illegal Packed/Binary entry Entry must be P, B, L, R, or Blank assumed


in column 55 blank.

0109E Illegal Decimal Positions entry Entry must be 0-9 or blank. Zero assumed
in column 56

0110E Illegal Sequence (A/D) entry Entry must be A, D, or blnnk. Blank assumed
in column 57

E-8 96768710 A
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
01llE megal Number of Entries per Entry must be 1-999 or blank. 1 assumed
Record entry in columns 33-35
O1l2E megal Number of Entries per Entry must be 1-9999. 1 assumed
Table or Array entry in
columns 36-39
O1l3E Invalid To Filename entry in Filename did not appear on Since no valid information is
columns 19-26 file specifications. available for processing file
name, multiple related errors
can occur due to lack of infor-
mation.
O1l4E Invalid From Filename entry Filename did not appear on Since no valid information is
in columns 11-18 file specifications. available for processing file
name, multiple related errors
can occur due to lack of infor-
mation.
O1l5E megal Table or Array Name Name contains invalid char- Name used as it exists up to
entry in columns 27-32 acter, embedded blanks, or first blank
numeric first character.
01l6E megal Table or Array Name Name contains invalid char- Name used as it exists up to
entry in columns 46-51 acter, embedded blanks, or first blank
numeric first character.
01l7E megal Number of the Chaining Entry must be CI-C9. Cl assumed
Field entry in columns 9-10
01l8E megal To Filename entry in Name contains invalid char- File name used as it exists up
columns 19-26 acters or embedded blanks. to first blank
01l9E megal From Filename entry in Name contains invalid char- File name used as it exists up
columns 11-18 acters or embedded blanks. to first blank
0123E Invalid or missing To Filename. No special action taken
entry of a chaining file in col-
umns 19-26
0124E Invalid or missing To Filename No special action taken
entry of a record address file
in columns 19-26
0125E Invalid or missing From File- No special action taken.
name entry of a record address
file in columns 11-18
0126E Invalid Table or Array Name Name encountered previously No special action taken
entry in columns 27-32 or
46-51
0127E megal Length of Entry entry Entry length must be equal to No special action taken
in columns 40-42 or 52-54 or less than record length of
entry.

96768710 A E-9.'
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
0128E Number of Entries per Record Entry must be 1-999. 1 assumed
entry of blanks in columns
33-35 invalid with entry in
From Filename in columns
11-18
0129E Number of Entries per Record Number of entries per record No special action taken
entry in columns 33-35 invalid cannot be greater than num-
with Number of Entries per ber of entries per table/array.
Table/Array entry in columns
36-39
0130E Decimal Positions entry in Decimal position cannot be Zero decimal position assumed
column 44 or 56 invalid with greater than length of entry.
Length of Entry entry in
columns 40-42 or "52-54
0131E megal Table or Array Name Name contains a blank as No further processing of line
entry in columns 27-32 first character.
0132E Packed/Binary entry of P, B, No special action taken
L, or R in column 43 invalid
with non-initialized tables/
arrays
0133E Packed/Binary entry of P, No special action taken
B, L, or R in column 55
invalid with non-initialized
tables/arrays
0134E Length of Entry entry in Primary table/array record No special action taken
columns 40-42 invalid with size cannot exceed from-
From Filename entry in file record size.
columns 11-18
0135E Length of Entry entry in Alternate table/array record No special action taken
columns 52-54 invalid with size cannot exceed from-
From Filename entry in file record size.
columns 11-18
0136E Length of Entry entry in Primary table/array record No special action taken
columns 40-42 invalid with size cannot exceed to-file
To Filename entry in record size.
columns 19-26
0137E Length of Entry in columns Alternate table/array record No special action taken
52-54 invalid with To File- size cannot exceed to-file
name entry in columns 19:-26 record size.
0138E megal Table or Array Name Name contains a blank as first No further processing of line
entry in columns 46-51 character.
0139E megal P=Packed/B=Binary Tables/arrays loaded at com- Data assumed to be unpacked;
entry of P or B in column 43 pile time cannot be in binary additional error can occur
or column 55 or packed format. when data is input.

E-10 96768710 A
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number

0140E To Filename in columns 19-26 No special action taken


is specified for table or array
output but is not an output
file (0 in column 15 of file
specifica tions).
0141E From Filename in columns
11-18 is specified for table
or array input but is not a
table file (T in column 16 of
file specifications).
0142E From Filename in columns No special action taken
11-18 is not a record address
file (R in column 16 of file
specifications).
0143E To Filename in columns 19-26 No special action taken
is not an input or update file
(I or U in column 15 of file
specifications).
0001L File Description Specifications
for Filename in columns 7-14
did not request line control
specifications (L in column 39).
0002L Columns 18-19 did not contain
FL (assumed ok).
0003L Columns 23-24 did not contain
OL (assumed ok).
0004L File description specification
for Filename in columns 7-14
requested line counter specifi-
cation (L in column 39), but
none were present.
0100L Abnormal end-of-file reached.
0101L megal form type entry in
column G (not I or L).
0102L Filename in columns 7-14 not
previously defined on File
Description Specifications.
Or03L Number of lines per page entry
(columns 15-17) did not contain
a valid numeric entry greater
than 12 (60 assumed).
0104L Overflow line number entry
(columns 20-22) did not con-
tain a valid nonzero numeric
entry (40 assumed).

96768710 A E-U
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number

0011 megal Sequence entry in Alphabetic Sequence entry No special action taken
columns 15-16 encountered; however, numer-
ic Sequence entry encountered
previously for same file
00021 megal alphabetic Sequence Both characters in alphabetic No special action taken
entry in columns 15-16
. sequence must be alphabetic •
00031 Number entry in column 17 Both must be blank with alpha- No special action taken
or Option entry in column 18 betic Sequence.
invalid with alphabetic Sequence
entry in columns 15-16
00041 megal Number entry in Entry must be 1 or N. N assumed
column 17
00051 megal Option entry in Entry must be a or blank. a assumed
column 18
00061 megal Sequence entry in First numeric Sequence entry No special action taken
columns 15-16 must be 01.
00071 Invalid Sequence entry in Numeric Sequence entry out No special action taken
columns 15-16 of sequence

00081 Both record identification and Both properly processed


field description specifications
encountered on same input
specification line
00091 megal Stacker Select entry in Blank assumed
column 42
00101 megal sterling sign position Sterling sign position specifi- No special action taken
entry in columns 71-74 cation not allowed
00111 megal packed/binary entry in Entry must be P, B, L, R, or Blank assumed
column 43 blank.
00121 megal Field Location entry in When a key field is defined, a K assumed in both
columns 44-51 K must be entered in both
From and To entries.
00131 megal Decimal Positions entry Entry must be 0-9. Zero assumed
in column 52
00151 megal entry in columns 17-18 Entry must be blank on And/Or No special action taken
line.

00161 megal entry in columns 19-20 Entry must be blank on And Record identification indicator
line. entry ignored

00171 megal entry in column 16 Entry must be blank on Or line. No special action taken

00181 megal entry in columns 7-42 Entry must be blank. No special action taken
of field description entry

00191 megal Sequence entry in Entry contains· invalid charac- No special action taken
columns 15-16 terse

E-12 96768710 A
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number

00201 Illegal Stacker Select entry Entry must be blank on And No special action taken
in column 42 line.

00211 Illegal Field Location entry in Trailer field overlaps header No special action taken
columns 44-51 field of spread card.

00221 Invalid Record Identifying Blank entry No indicator assumed


Indicator entry in columns
19-20

00231 Unexpected end-of-file Compiler exited through C


reached specifica tion processor.

00241 Invalid Field Name entry in Entry encountered previously Alpha assumed for this line
columns 53-58 as numeric only

I 00251 Column 15-16 contains 'OR' If OR line, 'OR' should be in No special action taken;
14-15 treated as 'NS'

01001 Illegal Record Identifying No special action taken


Indicator entry in columns
19-20

01011 Illegal Form Type entry in Card out of order. Source line bypassed; pro-
column 6 cessing continues with next
line.
01021 No header fields specified for' No special action taken
trailer fields

01031 Illegal entry in columns 17-18 Entry must be blank on look- No special action taken
and 21-74 ahead field definition line.

01041 Sequence entry of numeric or Sequencing not allowed with No special action taken
blank in columns 15-16 invalid look-ahead files
with look ahead fields (**)
entry in columns 19-20

01051 megal Filename entry in Name contains invalid char- Name used as it exists up to
columns 7-14 acters or embedded blanks first blank
01061 illegal Filename entry in Blank entry or blank charac- Since no valid file can be
columns 7-14 ter in entry related to the following
input specifications, multiple
diagnostic errors can occur.
01071 illegal From entry in columns 1 assumed
44-47

01081 Illegal To entry in columns From entry assumed


48-51

01091 Illegal To entry in columns To entry must be equal to or To assumed equal to From.
48-51 greater than from entry in
columns 44-47.

01101 Illegal To entry in columns To entry must be less than or Record size assumed
48-51 equal to record size.

01111 Illegal Field Location entry in Packed numeric field exceeds No special action taken
columns 44-51 length of 8.

96768710 C E-13
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number

01121 Illegal Field Location entry in Binary input field must have No special action taken
columns 44-51 length of either 2 or 4.

01131 Illegal Field Location entry in Alpha field exceeds length of No special action taken
columns 44-51 256.

01141 Illegal Field Location entry in Unpacked numeric field No special action taken
columns 44-51 exceeds length of 15.

01161 Invalid Field name entry in Entry encountered previously No special action taken
columns 53-58 as alpha

01171 Illegal Field Name entry in Name contains a comma with Comma ignored; name pro-
columns 53-58 no index. cessed as non-indexed

01181 Blank Field Name entry in Since neither entry is present,


columns 53-58 invalid with compiler is unable to determine
blank Sequence entry in whether line is a record identi-
columns 15-16. (Blank first char- fication or a field description.
acter in field name causes com- Additional diagnostic messages
piler to assume blank name can occur.
entry.)

01.201 Packed/Binary entry in column No special action taken


43 invalid with a non-numeric
field

01211 Invalid Filename entry in columns Filename encountered pre- No special action taken
7-14 viously on input specifications.

01221 Illegal Field Name entry in Name contains invalid char- Field name used as it exists up
columns 53-58 acters or embedded blanks. to first blank

01231 illegal Field Name entry in First character of field name No special action taken
columns 53-58 cannot be numeric.

01241 Invalid Field Name entry in Record address or table file No special action taken
columns 53-58 cannot be defined on input
specifications.

01251 Field Name entry in columns No special action taken


53-58 encountered previously
with different length

01261 Field Name entry in columns No special action taken


53-58 encountered previously
with different decimal posi-
tions entry in column 52

01271 Field Name entry in columns No special action taken


53-58 encountered previously
but was not an array

E-14 96768710 A
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number

00221 Invalid Record Identifying Indi- Blank entry No indicator assumed


cator entry in columns 19-20

01291 Valid Field Name entry of an No special action taken


array name in columns 53-58;
however t array name not
encountered on Extension Speci-
fications

01301 Invalid Field Name entry in Table illegal as input field No special action taken
columns 53-58

01311 Invalid Field Name entry in Reserved word other than No special action taken
columns 53-58 PAGE illegal for input

01321 megal Control Level entry Entry must be L1-L9 or blank Blank assumed
in columns 59-60

01331 megal Matching Fields entry Entry must be M1-M9 or blank Blank assumed
in columns 61-62
01341 megal Field Record Relation Indicator LO assumed
entry in columns 63-64

01351 megal Plus Field Indicator in Indicator LO assumed


columns 65-66

01361 megal Minus Field Indicator Indicator LO assumed


entry in columns 67-68

01371 megal Zero Field Indicator Indicator LO assumed


entry in columns 69-70

01381 Invalid Control Level entry Control fields invalid with No special action taken
of L1-L9 in columns 59-60 chained files

01391 Invalid Control Level entry Control fields invalid with de- N0 special action taken
of L1-L9 in columns 59-60 mand fields

01401 Invalid Control Level entry Control files invalid with No special action taken
of L1-L9 in columns 59-60 binary fields

01411 . Invalid Control Level entry Control fields invalid with No special action taken
of LI-L9 in columns 59-60 look-ahead files

01421 Invalid Control Level entry Control fields invalid with No special action taken
of L1-L9 in columns 59-60 trailer fields

01431 Invalid Matching Fields entry Matching fields invalid with No special action taken
of M1-M9 in columns 61-62 chained files

01441 Invalid Matching Fields entry Matching fields invalid with No special action taken
of M1-M9 in columns 61-62 demand files

01451 Invalid Matching Fields entry Matching fields invalid with No special action taken
of M1-M9 in columns 61-62 binary fields

01461 Invalid Matching Fields entry Matching fields invalid with No special action taken
of M1-M9 in columns .61-62 look-ahead fields

96768710 A E-15
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number
01471 Invalid Matching Fields entry Matching fields invalid with No special action taken
of M1-M9 in columns 61-62 trailer fields
01481 Invalid Matching Fields entry Matching fields invalid with No special action taken
of M1-M9 in columns 61-62 nonindexed arrays
01531 megal entry in columns 7-18 Entry must be blank on trailer No special action taken
and 21-74 definition line
01541 Invalid Filename entry in Name not defined on file spec- First file name defined on file
columns 7-14 ifications specification assumed. Addi-
tional diagnostic errors can
occur.
01551 Invalid Filename entry in File must be input, update, or No special action taken
columns 7-14 combined
01561 Look-ahead fields (**) entry No special action taken
in columns 19-20 invalid with
AND or OR specifications
01571 First input specification line No special action taken
of record identification can-
not be AND or OR.
01581 megal Not entry in columns Entry must be N or blank. No special action taken
25, 32, or 39.
01591 megal C/Z/D entry in Entry must be C, Z, or D. No special action taken
columns 26, 33, or 40.
01601 megal Position entry in Entry must be 1-9999 or blank. No special action taken
columns 21-24 or 35-38
01611 megal Field Name entry of Invalid characters in numeric
an array index in columns index processed
53-58
01621 Control Level indicator L1 No special action taken
entered for different field -
types in a preceding record
identification group
01631 Control Level indicator L2 No special action taken
entered for different field
types in a preceding record
identification group
01641 Control Level indicator L3 No special action taken
entered for different field
types in a preceding record
identification group
01651 Control Level indicator L4 No special action taken
entered for different field
types in a preceding record
identification group
01661 Control Level indicator L5 No special action taken
entered for different field
types in a preceding record
identification group

E-16 96768710 A
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number

01671 Control Level indicator L6 No special action taken


entered for different field
types in a preceding record
identification grou~
01681 Control Level indicator L7 No special action taken
entered for different field
types in a preceding· record
identification group
01691 Control Level indicator L8 No special action taken
entered for different field
types in a preceding record
identification group
01701 Control Level indicator L9 No special action taken
entered for different field
types in a preceding record
identification group

01711 Matching Field indicator Ml No special action taken


defined more than once in a
preceding record identifica-
tion group

01721 Matching Field indicator M2 No special action taken


defined more than once in a
preceding record identifica-
tion group

01731 Matching Field indicator M3 No special action taken


defined more than once in a
preceding record identifica-
tion group
01741 Matching ·Field indicator M4 No special action taken
defined more than once in a
preceding record identifica-
tion group
01751 Matching Field indicator M5 No special action taken
defined more than once in a
preceding record identifica-
tion group
01761 Matching Field indicator M6 No special action taken
defined more than once in a
preceding record identifica-
tion group

01771 Matching Field indicator M7 No special action taken


defined more than once in a
preceding record identifica-
tion group

01781 Matching Field indicator M8 No special action taken


defined more than once in a
preceding record identifica-
tion group

01791 Matching Field indicator M9 No special action taken


defined more than once in a
preceding record identifica-
tion group

96768710 A E-17
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
01801 Matching Field indicator M1 No special action taken
entered for different field
types in a preceding record
identification group
01811 Matching Field indicator M2 No special action taken
entered for different field
types in a preceding record
identification group
01821 Matching Field indicator M3 No special action taken
entered for different field
types in a preceding record
identification group
01831 Matching Field indicator M4 No special action taken
entered for different field
types in a preceding record
identification group
01841 Matching Field indicator M5 No special action taken
entered for different field
types in a preceding record
identification group
01851 Matching Field indicator M6 No special action taken
entered for different field
types in a preceding record
identification group
01861 Matching Field indicator M7 No special action taken
entered for different field
types in a preceding record
identification group
~1871 Matching Field indicator M8 No special action taken
entered for different field
types in a preceding record
identification group
01881 Matching Field indicator M9 No special action taken
entered for different field
types in a preceding record
identification group
01891 Invalid Field Indicators entry Plus and Minus indicators No special action taken
in columns 65-68 illegal with alpha field
01901 Invalid look-ahead fields (**) Look-ahead previously speci- No special action taken
entry in columns 19-20 fied and active.
01911 No valid input specifications No special action taken
present .
01921 illegal Position entry in col- Entry must be less than or No special action taken
umns 21-24, 28-31, or 35-38. equal to record length.
01931 Invalid look-ahead fields (**) Look-ahead 6nly valid with No special action taken
entry in columns 19-20 primary or secondary file.
01951 illegal Field Name entry in Table/array indexes must- be No special action taken
columns 53-58 numeric.

E-18 96768710 A
TABLE E-2. EXTENSION SPECIFICATION ERRORS (Contd)

Error
Message Error Definition Action
Number
01961 Decimal Positions entry in Decimal position cannot be No special action taken
column 52 invalid with Field greater than field length.
Length entry in columns 44-51
01971 megal Field Name entry in Array index has value of zero. No special action taken
columns 53-58
01981 Invalid Field Record Relation Field record relation indicator No special action taken
entry in columns 63-64 must be equal to record ident-
ification indicator when spec-
ified with matching or control
fields.
01991 Invalid Field Length entry in Field length is zero. No special action taken
columns 44-51
02001 Length of array defined on No special action taken
input specifications greater
than length defined on exten-
sion specifications
02011 megal Field Name entry in An array index cannot be a No special action taken
columns 53-58 table or array name.

02021 megal Field Name entry in An array index can have no No special action taken
columns 53-58 decimal positions.

02031 megal Field location entry in A nonindexed array must define No special action taken
columns 44-51 a length that is devisible by
the length of elements in the
array.
02041 megal trailer specified in Trailer already present for No special action taken
columns 19-20 this file.

TABLE E-3. CALCULATION SPECIFICATION ERRORS

Error
Message Error Definition Action
Number
0001C megal Factor 1 entry in Label name exceeds six char- No special action taken
columns 18-27 or Factor 2 acters.
entry in columns 33-42
0002C megal Operation entry of . DEBUG not specified on header Source line bypassed processing
DEBUG in columns 28-32. line continues.

0003C Invalid Field Length entry in Entry must be 1-256 with Blank assumed
columns 49-51 maximum of 15 for numeric
and 256 for alpha.

0004C megal Field Length entry in Entry must be 1-256 or blank. Blank assumed
columns 49-51

0005C Indicators entry in columns Conditioning indicators illegal Indicator entries in columns
9\-17 invalid with Operation with specified operation code 9-17 ignored.
entry in columns 28-32 .

0006C megal Control Level Indica- Entry must be LO, Ll, L9 or LO assumed
tors entry in columns 7-8 LR.

96768710 A E-19
TABLE E-3. CALCULATION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
0007C megal Operation entry in Only BEGSR operation code No special action taken
columns 28-32 can be specified following a
line with ENDSR operation
code.
0008C Abnormal end-of-file reached Compiler exited normally.
0100C megal Factor 1 entry in Entry must be blank for speci- Factor 1 assumed blank
columns 18-27 fied operation code.
0101C megal Factor 1 entry of a No special action taken
numeric field in columns 18-27
0102C megal Factor 1 entry of an No special action taken
alphabetic field in columns
18-27
0103C megal Factor 1 entry in No special action taken.
columns 18-27 If entry is blank, numeric
field assumed.
0104C megal Operation entry in Source line bypassed; pro-
columns 28-32 cessing continues with next
line.
0105C megal Factor 1 entry in Label previously defined No special action taken
columns 18-27
0106C megal Factor 1 entry in Invalid label entry No special action taken
columns 18-27
0107C megal Con"trol Level entry in Entry must be AN or OR due No special action taken
columns 7-8 to no Operation entry in col-
umns 28-32 of preceding line.
0108C megal Factor 2 entry in Entry must be blank for speci- No special action taken
columns 33-42 fied operation code.
0109C megal Factor 2 entry of a No special action taken
numeric field in columns 33-42
OllOC megal Factor 2 entry of an No special action taken
alpha field in columns 33-42
01llC megal Factor 2 entry in No special action taken. If
columns 33-42 entry is blank, numeric field
assumed.
O1l3C megal Factor 2 entry in Invalid label entry No special action taken
columns 33-42
O1l4C megal Factor 2 entry in File name not defined in file Factor 2 assumed blank
columns 33-42 specifications or blank entry
O1l5C Factor 2 must be same type No special action taken
as Factor 1 for specified
operation code
O1l6C megal Result Field entry in Entry must be blank for spec- Result field assumed blank
columns 43-48 ified operation code.
O1l7C megal Result Field entry of a No special action taken
numeric field in columns 43-48

E-20 96768710 A
TABLE E-3. CALCULATION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
OU8C megal Result Field entry of an No special action taken
alpha field in columns 43-48
OU9C megal Result Field entry in No special action taken
columns 43-48
0120C megal Form Type entry in Card out of sequence Source line bypassed; pro-
column 6 cessing continues with next
line
012lC me gal Half-Adjust (H) entry Invalid entry for s~ecified Half-adjust entry ignored
in column 53 operation code
0122C megal Half-Adjust (H) entry Entry must be H or blank. Blank assumed
in column 53
0123C megal Resulting Indicators Entry must be blank for speci- No special action taken
entry in columns 54-59 fied operation code.
0124C megal Resulting Indicators At least one resulting indicator No special action taken
entry in columns 54-59 required for specified opera-
tion code
0125C megal Resulting Indicators LO assumed
entry in columns 54-55
0126C megal Resulting Indicators LO assumed
entry in columns 56-57
0127C megal Resulting Indicators LO assumed'
entry in columns 58-59
0128C megal Control Level entry in Total line cannot be entered No special action taken
,
columns 7-8 following a last record line.
0129C Detail specifications must No special action taken
proceed total specifications
0130C megal Control Level entry in Total line cannot be entered No special action taken
columns 1-8 following a subroutine line.
013lC megal Control Level entry in No special action,taken
columns 7-8
0132C megal Not entry in column 9 No special action taken
0133C megal Not entry in column 12 No special action taken
0134C megal Not entry in column 15 No special action taken
0135C megal Indicator entry in No special action taken
columns 10-11
0136C megal Indicator entry in No special action taken
columns 13-14
0137C megal Indicator entry in No special action taken
columns 16-17
0138C megal Factor 1 entry in No closing apostrophe on No special action taken
columns 18-27 or Factor 2 literal entry
entry in columns 33-42

96768710 A E-21
TABLE E-3. CALCULATION SPECIFICATION ERRORS (Contd)
"Error
Message Error Definition Action
Number
0139C megal Operation Code entry ENDSR operation code invalid No special action taken
in columns 28-32 outside of a subroutine
0140C megal Operation Code entry BEGSR operation code speci- No special action taken
in columns 28-32 fied prior to termination of
preceding subroutine
0141C megal Result Field entry in Entry previously specified with No special action taken
columns 43-48 diUerent length
0142C megal Result Field entry in Entry previously specified with No special action taken
columns 43-48 different decimal pOsitions
0143C megal Result Field entry in Entry previously specified as No special action taken
columns 43-48 alphabetic
0144C megal Result Field entry in Entry cannot be a numeric Name processed with first
columns 43-48 literal character numeric
0145C megal Result Field entry in Entry cannot be an alphabetic Name processed with opening
columns 43-48 literal apostrophe in literal included
in alphabetic name
0146C megal Result Field entry in Entry previously specified as No further validity tests made
columns 43-48 numeric on field
0147C Invalid Decimal Positions entry Entry illegal with alphabetic
in columns 52 field
0148C megal Factor 2 entry in Bit numbers specified incor- Invalid bit numbers ignored
columns 33-42 rectly
0149C megal Factor 2 entry in Output file for DEBUG opera- No special action taken
columns 33-42 tion must be at least 80 bytes
in length
0150C megal Factor 2 entry in File name for DEBUG opera- No special action taken
columns 33-42 tion code must be an output
file.
0151C megal Factor 2 entry in File name for DSPL Y opera- No special action taken
columns 33-42 tion code must be a display
file.
0152C The following label name was No special action taken
referenced and not defined.
0153C megal Factor 2 entry in Filename contains invalid File name used as it exists up
columns 33-42 characters or embedded to first blank
blanks.
0154C megal Factor 1 or Factor 2 Alphabetic literal contains No special action taken
entry characters following closing
apostrophe.
0155C megal Factor 1 or Factor 2 Alphabetic literal has length No special action taken
entry ot zero.
0156C megal Factor 2 entry in " Bit number literal contains No special action taken
columns 33-42 characters following closing
apostrophe.

E-22 96768710 A
TABLE E-3. CALCULATION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
0157C megal Decimal Positions entry Entry must be 0-9 or blank. Zero assumed
in column 52
0158C megal Operation entry in DIV operation code must be No special action taken
columns 28-32 entered prior to specification
of MVR operation code.
0159C No ENDSR operation code No special action taken
entered for previous subroutine
0160C megal Resulting Indicators LOKUP operation code cannot No special action taken
entry in columns 54-59 have both Plus and Minus indi-
cators specified in columns
54-57.
0161C megal Factor 1 or Factor 2 More than one decimal point Leftmost decimal point used
entry in numeric literal.
0162C megal Factor 1 entry in Label name previously defined No special action taken
columns 18-27
0163C megal Factor 1 or Factor 2 Label name contains invalid Label name used as it exists up
entry characters or embedded to first blank
blanks.
0164C megal Factor 1 or Factor 2 Operation code requires a label No special action taken
entry of blanks name.
0165C megal Resulting Indicators High/Low indicators must not No special action taken
entry in columns 54-57 be specified with LOKUP oper-
ation on non-sequenced tablet
array.
0166C megal Factor 1 or Factor 2 Factor 1 and factor 2 of No special action taken
entry LOKUP operation must have
equal length fields specified.
0167C megal Factor 1 or Factor 2 Table/array indexes must be No special action taken
entry numeric.

0168C megal Factor 1 or Factor 2 Field name contains more than Name used with first six char-
entry. six characters. acters
0169C megal operation entry in FORCE operation illegal with No special action taken
columns 28-32 output or display files
0170C Operation entry of READ in High/Low indicators not No special action taken
columns 28-32 invalid with allowed with READ operation
High/Low resulting indicators
entry in columns 54-57.
0171C Operation entry of READ in Equal indicator HO not No special action taken
columns 28-32 invalid with allowed with READ operation
equal Resulting Indicators
entry of HO in columns 58-59.
0172C Decimal Positions entry in Decimal position cannot be No special action taken
columns 52 invalid with Field greater than field length
Length entry in columns 49-51
0173C megal Factor 1, Factor 2, or Name contains blank as the No further processing of line
Result Field entry first character

96768710 A E-23
TABLE E-3. CALCULATION SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
0174C illegal Operation entry in FORCE cannot be specified No special action taken
columns 28-32 on total or last record speci-
fication.
0175C illegal Operation entry in BEGSR can only be specified No special action taken
columns 28-32 on subroutine specification.
0176C illegal Factor 1, Factor 2, or Array index is zero. No special action taken
Result Field entry
0177C Entries in columns 18-59 Line assumed to be first line
invalid with no Operation of AND/OR related indicators
entry in columns 28-32
0178C megal Factor 2 entry in Entry is not a one-byte alpha No special action taken
columns 33-42 field.
0179C megal Result Field entry in Entry is not a one-byte alpha No special action taken
columns 43-48 field.
0180C Factor 2 entry of Result Field Factor 2 or Result Field must No special action taken
entry invalid with Operation contain an array or an array
entry of MOVEA in columns element with MOVEA opera-
28-32 tion.
0181C megal Factor 1 entry in Field length of Factor 1 is No special action taken
columns 18-27 greater than record length.
0182C Factor 1 entry or Result Field DSPL Y operation requires No special action taken
entry invalid with Operation Factor 1 or Result Field.
entry of DSPL Y in columns
28-32
0183C megal Result Field entry in Field length of Result Field is No special action taken
columns 43-48 greater than record length.
0184C megal Factor 1, Factor 2, or An index is entered for a field No special action taken
Result field entry that is not defined as an array.
0185C megal Factor 1, Factor 2, or An array index cannot be a No special action taken
Result Field entry table or array name.
0186C megal Factor 1, Factor 2, or An array index cannot be a No special action taken
Result Field entry ULABL field.
0187C megal Factor 1, Factor 2, or An array index can have no No special action taken
Result Field entry decimal positions.
0188C megal Result Field entry in Entry must be a table name. No special action taken
columns 43-48
0189C Last record calculation speci-
fication must precede SR
specifications.
0190C Detail specifications must
precede LR specifications.
~

0191C Detail specifications must


precede SR specifications.
0192C RLABL operation must follow
either an EXIT operation or
another RLABL operation.
0193C Result field has been pre-
viously defined differently.
E-24 96768710 A
TABLE E-4. OUTPUT FORMAT SPECIFICATION ERRORS
Error
Message Error Definition Action
Number

00010 megal Packed/Binary Output Entry must be blank for alpha- No special action taken
entry in column 44 betic field.
00020 megal Packed/Binary Output Entry must be blank for alpha- No special action taken
entry in column 44 betic constant.
00030 megal blank after entry in Entry must be blank for alpha- No special action taken
column 39 betic constant.
00040 megal Space and Skip entries Entry must be blank on No special action taken
entry in column 17-22 . And/Or line.
00050 megal Space Before entry in Blank assumed
column 17
00060 megal Space After entry in Blank assumed
column 18
00070 megal Skip Before entry in Blank assumed
columns 19-20
00080 megal Skip After entry in Blank assumed
columns 21-22
00090 megal Not entry in column Blank assumed
23
00100 megal indicator entry in Blank assumed
columns 24-25
00110 megal Not entry in column 26 Blank assumed
00120 megal indicator entry in Blank assumed
columns 27-28
00130 megal Not entry in column 29 Blank assumed
00140 megal indicator entry in Blank assumed
columns 30-31
00150 megal Constants or Edit Words Constant must not contain No special action taken
entry in columns 45-70 less digit positions than field
to be edited.
00160 megal Packed/Binary Output No special action taken
entry iri column 44

00170 megal entry in columns 71-74 Entry must be blank. No special action taken

00180 Invalid Field Name entry of Data repeated in original No special action taken
*PLACE in columns 32-37 position
01000 megal Form Type entry in Entry must be O. Source line bypassed, pro-
column 6 cessing continues with next
line

01010 megal Filename entry in Blank entry or blank first Since no valid file can be re-
columns 7-14 character in entry lated to the following output
specifications, multiple diag-
nostic errors can occur.
01020 megal Type entry in column 15 D assumed

96768710 A E-25
TABLE E-4. OUTPUT FORMAT SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number
01030 Invalid or missing End Position No special action taken
in Output Record entry in
columns 40-43
01040 megal Filename entry in Name not defined on file speci- Since no valid file can be
columns 7-14 fications related to the following output
specifications, multiple diag-
nostic errors can occur.
01050 megal And/Or entry in Preceding line must be record No special action taken
columns 14-16 selection.
01060 megal Field Name entry in Field name must be previously Field name assumed blank;
columns 32-37 defined in program. line processed as constant
output.
01070 megal Field Name entry in Index name must be pre- No special action taken
columns 32-37 viously defined.
01080 megal Field Name entry in Numeric index contains non- Non-numeric character assumed
columns 32-37 numeric character. to be zero
01090 megal Constants or Edit Words No terminal apostrophe in No special action taken
entry in columns 45-70 constant or edit word
01100 megal End Position in Output Entry cannot be greater than No special action taken
Record entry in columns 40-43 record length.
01110 megal End Position in Output Entry cannot be less than field No special action taken
Record entry in columns 40-43 length.
01120 megal Field Name entry in *PRINT not available No special action taken
columns 32-37
01130 Field Name entry in columns Only numeric fields can be No special action taken
32-37 invalid with an Edit edited.
Codes entry in column 38 or
with an Edit Words entry in
columns 45-70
01140 Packed/Binary Output entry No special action taken
in column 44 invalid with
edited fields
01150 megal Filename entry in Name must be output, update, No special action taken
columns 7-14 or combined file.
01160 megal Field Name entry ih Name contains invalid char- Name used as it exists up to
columns 32-37 acters or embedded blanks. first blank
01170 megal Constants or Edit Words No opening apostrophe in No special action taken
entry in columns 45-70 column 45
01180 megal Constants or Edit Words Constant contains characters No special action taken
entry in columns 45-70 following closing apostrophe.
01190 megal Constants or Edit Words Constant has l~ngthof zero. No special action taken
entry in columns 45-70
01200 megal Filename entry in Name contains invalid char- Name used as it exists up to
columns 7-14 . acters or embedded blanks. first blank

E-26 96768710 A
TABLE E-4. OUTPUT FORMAT SPECIFICATION ERRORS (Contd)
Error
Message Error Definition Action
Number

01210 megal Skip entries in columns Entry must be blank for an Add No special action taken
19-22 file.
01220 Invalid Indexed Sequential Add Add must be defined on file No special action taken
entry in columns 16-18 specifications in column 66
when Add specified on output
specifica tions

01230 megal entry in columns 32-74 Must be blank on record ident- No special action taken
ification line
01240 megal Output Indicator entry Overflow indicator specified No special action taken
in columns 23-31 that was not defined on file
. specifications

01260 Constants or Edit Words entry No special action taken


of dollar sign ($) or asterisk (*)
in columns 45-70 invalid with
Edit Codes entry of X, Y, or Z
in column 38
01270 Invalid Field Name entry of No valid fields exist to place. No special action taken
*PLACE in columns 32-37

01280 megal Blank After entry in No special action taken


column 39

01290 Invalid Edit Codes entry in No special action taken


column 38

01300 Constants or Edit Words entry Edit constant illegal with edit No special action taken
in columns 45-70 invalid with code
Edit Codes entry in column 38
01310 Output Indicators entry of 1P 1P indicator not allowed to No special action taken
in columns 23-31 invalid with condition total output
Type entry of T in column 15

01320 megal End Position in Output Field length must not be No special action taken
Record entry in columns 40-43 larger than nine for binary
output.
01330 megal Field Name entry in Table/array indexes must be No special action taken
columns 32-37 numeric.
01340 Output Indicators entry of Overflow indicator not allowed No special action taken
OA-OG or OV in columns to condition exception line
23-31 invalid with Type entry
of E in column 15
01360 megal Field Name entry in Array index in columns 34-37 No special action taken
columns 32-37 is zero
01370 megal Field Name entry in An index is specified in col- No special action taken
columns 32-37 umns 34-37 for a field that is
not defined as an array.
01380 megal Field Name entry in An array index cannot be a No special action taken
columns 32-37 table or array name.
01390 megal Field Name entry in An array index cannot be a No special action taken
columns 32-37 ULABL field.

96768710 A E-27
TABLE E-4. OUTPUT FORMAT SPECIFICATION ERRORS (Contd)
,
Error
Message Error Definition Action
Number

01400 megal Field Name entry in An array index can have no No special action taken
columns 32-37 decimal positions.
01410 megal Stacker Select/Fetch Fetch overflow not allowed No special action taken
Overflow entry of F in column for exception output
16
01420 ADD must be specified ADD is assumed in columns
(columns 16-18) for an output 16-18.
and add file.

TABLE E-5. COMPILE TIME ARRAY ERRORS


Error
Message Error Definition Action
Number
0001A Short table/array loaded at Less than the maximum num- Remaining table/array elements
compile time ber of elements read into filled with blanks if alphabetic,
table/array zeros if numeric and not in
ascending sequence, and nines (9)
if numeric and in ascending
sequence.
0002A megal entry in columns 1-2 of Should be end-of-file (/*) line End-of-file line assumed
record
0100A Table/array entries loaded at First line assumed to be **~;
compile time not preceded by processing begins with second
**~ line source line.
OlOlA File name encountered on file Since no valid file information
translation entries that was can be related to bad file name,
not defined on file specifica- additional random errors can
tions occur. Assumed file informa-
tion can vary between pro-
grams.
0102A megal file name entry on file File names not specified in File names following the error
translation records valid form are bypassed; file names
entered correctly prior to the
error are processed.
0103A File translation entries not Line processed as first file
preceded by **t6 line translation line
0104A Alternate collating sequence Line assumed to be **~ line;
entries not preceded by **t6 processing begins with next
line. line.
0105A megal entry in columns 1-6 of Line does not begin with Line assumed to begin with
alternate collating sequence ALTSEQ. ALTSEQ; therefore, first
record eight columns not processed
as data

E-28 96768710 A
TABLE E-5. COMPILE TIME ARRAY ERRORS (Contd)

Error
Message Error Definition Action
Number

Ol07A Mode definition (alphabetic No special action taken


or numeric) not encountered
for following field

Ol08A Length definition not encoun- No further processing of field


tered for following field

0109A Invalid character in hexa- No special action taken -


decimal data

OllOA megal table/array entry Alphanumeric field out of No special action taken
sequence

OlllA megal table/array entry Non-numeric character in Character assumed to be zero


numeric input field

01l2A megal table/array entry Numeric field out of No special action taken
sequence

RUN-TIME ERRORS 0107R HALT INDICATOR H7 IS ON


These messages are output during execution of RPG II object 0108R HALT INDICATOR H8 IS ON
programs when an abnormal situation occurs. No operator
intervention is possible to respond to the message. The Ol09R HALT INDICATOR H9 IS ON
I message is output to the MSOS console device and is of the
form: OllOR NO PRIMARY
OPENED
OR SECONDARY FILES ARE
RPG nnnx ffffffff text
0111R SQUARE ROOT OF NEGATIVE NUMBER
Where: nnn is the run-time error message number.
O1l2R NOT USED
x is the designator. It is D for messages
output by the data manager; otherwise it O1l3R DIVISION BY ZERO
is R.
O1l4R ARRAY INDEX OUT OF RANGE
ffffffff is the file name, or blank if not applicable.
O1l5R INPUT TABLE OR ARRAY OUT OF SEQUENCE
text is the message text.
O1l6R NO TABLE OR ARRAY DATA IN FILE
The following is a list of run-time error messages.
O1l7R TOO MUCH DATA FOR TABLE OR ARRAY
OlOlR HALT INDICATOR Hl IS ON
O1l8R SUBROUTINE RETURN STACK IS FULL
Ol02R HALT INDICATOR H2 IS ON
01l9R SUBROUTINE RETURN WITHOUT PREVIOUS
Ol03R HALT INDICATOR H3 IS ON EXSR
Ol04R HALT INDICATOR H4 IS ON 0120R END-OF-FILE FOR DEMAND FILE
Ol05R HALT INDICATOR H5 IS ON 0121R RECORD NOT FOUND, KEY NOT IN INDEX FILE
Ol06R HALT INDICATOR H6 IS ON 0122R RELATIVE RECORD NUMBER OUT OF RANGE

96768710 B E-29
0123R RECORD IS OUT OF SEQUENCE 0153R Not used

0124R FILE OUT OF MATCHING RECORD SEQUENCE 0154R Not used

0125R UNIDENTIFIED RECORD IN FILE 0155R ERROR IN PARAMETER(S) PASSED TO SUB-


ROUTINE SUBRFL
0126R TOO MUCH DATA FOR RECORD
0156R ERROR IN PARAMETER(S) PASSED TO SUB-
0127R Not used ROUTINE SUBRAJ

0128R Not used 0157R ERROR IN PARAMETER(S) PASSED TO SUB-


ROUTINE SUBRMV
0129R Not used
0158R ERROR IN PARAMETER(S) PASSED TO SUB-
0130R ATTEMPT TO OUTPUT TO FULL FILE ROUTINE SUBRIN

0131R DIRECT ACCESS RECORD NO. OUT OF RANGE 0159R ERROR IN PARAMETER(S) PASSED TO SUB-
ROUTINE SUBRED
0132R ATTEMPT TO UPDATE FILE BEFORE INPUT
0160R Not used
0133R RECORD NOT FOUND WITH SPECIFIED KEY

0134R DUPLICATE KEY FOR OUTPUT TO FILE DATA MANAGER ERRORS


0135R DEVICE ERROR These messages are similar to the run-time error messages
and are also output during execution of RPG IT object
0136R FILE IS NOT PRESENT programs when an abnormal situation is detected by data
management. The message is output to the MSOS console
0137R FILE DOES NOT CORRESPOND TO DMPT device and is of the form described for run-time errors.
DESCRIPTION
The following is a list of data manager error messages.
0138R SETLL NOT VALID FOR THIS FILE TYPE
0010 FILE IS ALREADY OPENED
0139R Not used
0020 TRIED TO PROCESS FILE IN WRONG MODE
0140R UNABLE TO CONTINUE DUE TO PREVIOUS
ERROR 0030 SPECIFIED RECORD LENGTH IS INCORRECT

0141R Not used 0040 FILE NOT DEFINED IN DffiECTORY

0142R Not used 0050 AN ADD FILE FOR SEQ PROC MUST BE DEF AS
OUTPUT
0143R Not used
0060 ADD/LOAD SEQUENTIALLY NOT FOR DffiECT
0144R Not used DEF FILE

0145R Not used 0070 FILE DEFINITION IS WRONG FOR SEQ. PROC.

0146R Not used 0080 RECORD LENGTH NOT COMPATIBLE WITH THE
DIRECTORY
0147R Not used
0090 FILE MGR DID NOT HANDLE DIR REQ STATUS
0148R Not used $$$$
0149R Not used 0100 TRIED TO ACCESS AN UNOPENED FILE

0150R ALL HALT INDICATORS HAVE BEEN DISPLAYED 0110 READ 09 FOUND FILE TO BE NON UNIT-
RECORD DEFINED
0151R FIRST LINE WILL BE PRINTED TWICE FOR
FORMS ALIGN 0120 RECORD ######## WAS SHORT-PADDED WITH
BLANKS
0152R Not used

• E-30 96768710 B
013D READ 12 FOUND FILE DEFINED AS A NON-DISK 03'1D READ13 FOUND FILE DEFI AS A NON DISK-
FILE DIRECT FILE

014D RECORD ######ft# WAS TOO LONG - RECORD 038D WRIT21 FOUND FILE DEFI AS A NON DISK-
TRUNCATED . DIRECT FILE

015D WRIT17 FND FILE DEFI AS A NON UNIT- 039D UPDT2'1 FOUND FILE DEFI AS A NON DISK-
RECORD FILE DIRECT FILE

016D WRIT20 FND FILE DEFI AS A NON DISK-SEQ 040D CLOS39 FOUND FILE DEFI AS A NON DISK-
FILE DIRECT FILE

017D UPDT26 FND FILE DEFI AS A NON DISK-SEQ 041D RECORD NUMBER #####ftftft OUT OF RANGE
FILE
042D DOUBLE BUFFERING NOT ALLOWED FOR
018D MULTIPLE UPDATES W/O READ .IN BETWEEN INDEX FILE
INVALID
043D INDEX PROC. IS ALLOWED ONLY FOR
019D ADDT30 FOUND FILE DEFINED AS A NON DISK- INDEXED-DEF FILES
SEQ FILE
044D KEY LENGTH/POSITION NOT COMPATIBLE WITH
020D CLOS35 FOUND FILE DEF AS A NON UNIT-REC DIRECTORY
FILE
045D OPEN05 WAS CALLED FOR NON-RANDOM
021D CLOS38 FOUND FILE DEFINED AS A NON DISK- PROCESSING
SEQ FILE
046D READ15 FOUND FILE DEFINED AS A NON INDEX
0220 MASS STORAGE ERROR FILE

023D FILE MGR DID NOT HANDLE FILE REQUEST 04'10 WRIT23 FOUND FILE DEFINED AS A NON INDEX
$$$$$ FILE

024D END OF TAPE ENCOUNTERED 048D ADDT32 FOUND FILE DEFINED AS A NON INDEX
FILE
025D INPUT DEVICE FAILURE
049D CLOS41 FOUND FILE DEFINED AS A NON INDEX
026D OUTPUT DEVICE FAILURE FILE

02'1D SHARED BUFFERS NOT ALLOWED FOR TAPE 0500 UPDT29 FOUND FILE DEFINED AS A NON INDEX
FILES FILE

028D BLOCK SIZE MUST BE INTEGER MULTIPLE OF 051D THE KEY IN RECORD #ftft##### MODIFIED BY
REC SIZE UPDATE

029D READll FOUND FILE NOT DEFINED AS TAPE 052D CLOS40 FOUND FILE DEFINED AS -A NON INDEX
FILE .
030D WRIT19 FOUND FILE NOT DEFINED AS TAPE
0530 READ 19 FOUND FILE DEFINED AS A NON
031D CLOS3'1 FOUND FILE NOT DEFINED AS TAPE INDEX FILE

032D DATA OVERFLOW - NO MORE TAPE VOLUMES 054D WRIT22 FOUND FILE DEFINED AS A NON INDEX
DECLARED FILE

033D ADDING RECORDS IS NOT ALLOWED IN DIRECT 055D UPDT28 FOUND FILE DEFINED AS A NON INDEX
PROC. FILE

034D OUTPUT FILE FOR DIRECT PROC MUST BE DEF 056D ADDT31 FOUND FILE DEFINED AS A NON INDEX
DIR FILE

035D DIRECT PROC. ON INDEXED FILE ALLOWED 05'1D SETL33 FOUND FILE DEFINED AS A NON INDEX
ONLY FOR INP SEQ FILE

036D FILE DEFINITION IS WRONG FOR DIRECT PROC. 058D RECORD ft###ft### OUT OF ORDER

96'168'110 B E-31·
0590 SETL33 SET LOWER LIMIT NOT ALLOWED FOR 0820 CLOS36 FOUND FILE DEF "AS NON SPECIAL DEV
ADD "FILES FILE

060D KEY OF RECORD ######## ALREADY EXISTS 0830 WRIT18 FOUND FILE DEF AS NON SPECIAL
DEV FILE
0610 SEQ. PROC. FOR INDEX-DEFINED FILE ONLY
FOR INPUT 0840 Not used
062D UNABLE TO SORT THE KEYS 0850 Not used

063D SLCT34 CALL STACKER SELECT IS NOT 0860 Not used


SUPPORTED
0870 Not used
" 0640 ERROR CODE IN BUFFER IS WRONG FOR TAPE
0880 Not used
065D NO VOL1 LABEL ON SL TAPE
0890· Not used
066D WRONG DATA SET NAME
0900 Not used
0,670 TAPE VOLUMES MOUNTED IN WRONG ORDER
0910 Not used
068D TAPE FILE NOT DEFINED BY MOUNT UTILITY
0920 Not used
0690 WRONG VOLUME SERIAL NUMBER
0930 Not used
0700 INVALID EXPIRATION DATE
094D Not used
071D FILE MANAGER ERROR IN READING MOUNT
FILE 0950 Not used

072D UNEXPffiED DATE SET 0960 Not used


0730 Not used 0970 Not used

0740 COMBINED FILES ARE NOT-SUPPORTED 0980 Not used

0750 OPEN02 FOUND FILE DEF AS NON SPECIAL DEV 0990 ERROR AT LOCATION = $$$$$
FILE
1000 Not used
076D WRONG BUFFER SIZE CANNOT BE USED FOR
FIXED BLK
MAGNETIC TAPE UTI LITY ERRORS
" 0770 BLOCKING IS IMPOSSIBLE FOR SHARED
BUFFERS Tables E-6 through E-10 list the four types of plagnetic tape
utility processor . (MTUP) error messages: action,
078D ERROR RETURN FROM SPEC DEV DRIVER, descriptive, critical, serious, and warning error messages.
STATUS = $$$$$ See the Magnetic Tape Utility Processor Reference Manual
for further information.
0790 READ 10 FOUND FILE DEF AS NON SPECIAL
DEV FILE
MOUNT UTILITY ERRORS
0800 UPDT25 FOUND FILE DEF AS NON SPECIAL DEV
FILE MOUNT utility error messages are shown in table E-11.

081D RECORD 1#1#1### WAS TOO LONG"- RECORD


IGNORED

• E-32 96768710 B
TABLE E-6. MAGNETIC TAPE UTILITY ACTION MESSAGES
Error Message Definition Action
*INVALID PARM= The characters within quotes are invalid Enter corrected parameter.
"XXX •••" and may be corrected.
*RETYPE PARM:
-
10 ERRORS Verify function has located 10 consecutive Type carriage return to termi-
*CONTINUE: records that contain errors. nate or type one character
followed by carriage return to
continue.
*MOUNT ,OUTPUT, Type carriage return, which
SCRATCH: implies tape is ready, or type
any other character followed
by a carriage return, to termi-
nate the initialize function.
*VOLSER=nnnnnn:
VOL NOT Label processing: Output volume header Carriage return implies do not
EXPIRED USE: records are checked against the system use. U implies use, ignoring
date. expiration date.
*DATA SET NAME: Label processing: Output volumes require a DSN='XXXXX'
data set name if not available from input.
VOLSER=nnnnnn Informative tape file just opened with the None
specified volume serial number.

TABLE E-7. MAGNETIC TAPE UTILITY DESCRIPTIVE ERROR MESSAGES


Error Message Definition Action
FILES(S) NOT A required file is not open and the spec i- Open file and reenter function.
OPEN fied function cannot be executed.
*INVALID OPEN OR The file being opened or closed is already Open or close the proper file.
CLOSE in that state.
*FUNCTION NOT An attempted function is not available in Use another function, if
AVAILABLE the system. The function is not invalid; possible.
rather, the system was configured without
the requested module.
*PARM NOT A parameter is not available in the system. Use another parameter, if
AVAILABLE The parameter is not invalid; rather, the possible.
system was configured without the re-
quested module.
*INCORRECT The volume mounted does not contain a Mount correct volume and type
VOL MOUNT: volume label or the header label sequence a carriage return.
is incorrect; i.e., the wrong volume of a
multiple volume file is mounted.

96768710 A E-33
TABLE E-8. MAGNETIC TAPE UTILITY CRITICAL ERRORS
Error Code Definition Action
****COOO**** Data buffer linkage has been destroyed. Reload utility.
Cause: I/O malfunction, CPU malfunction.

TABLE E-9. MAGNETIC TAPE UTILITY SERIOUS ERRORS


Error Code Definition Action
****SOOO**** Available memory has been filled. Free memory by closing a file.
****SOOl**** Attempt to close file already closed. Close proper file.
****S002**** 1. Read end-of-file Retry the function.
2. Attempt to write on file not opened
for write.
3. I/O error; i.e •. , parity, read or write
error, lost data, or alarm.
****S003**** Variable length block does not match Close all files. Open input as
actual length read, or variable read length undefined and dump records to
is greater than specified block size. locate the erroneous record.
File cannot be processed as
variable length.
****S004**** Blocking has been requested and specified Reopen file with proper param-
block size is smaller than specified record eters.
size.
****S005**** Variable size error detected prior to Attempt to re-execute function
write after closing and reopening all
files. Possible hardware mal-
function.
****S006**** Fixed block error detected prior to write. Close file and reopen with
Record length is not specified. proper record size or dump file
to locate erroneous records.
****S007**** Labeled file sequence number in error. Mount proper volume and re-
(File is not opened.) open.
****S008**** Labeled file EOF1 trailer label contains This file cannot be processed
invalid information which does not corres- with standard labels.
pond to header label 1.
****S009**** Labeled file is missing EOF trailer labels. File cannot be processed as
labeled.
****S010**** End-of-tape senSed on output file Close the file with EOV and re-
(unlabeled) open after mounting new tape.
Re-enter function to complete
processing.
****SOl1**** A double file mark has been sensed on an Close input file and mount next
input file. Processing is terminated. volume. Re-enter function to
complete processing.
****S012**** Invalid date Re-enter date function with
proper date.

E-34 96768710 A
TABLE E-9. MAGNETIC TAPE UTILITY SERIOUS ERRORS (Contd)
Error Code Definition Action
****S013**** Labeled volume sequence number incorrect. Mount proper volume and re-
(Occurs after OPEN file is not opened.) open file.
****S014**** ZERO LENGTH block specified in OPEN Reopen. specifying proper
FILE is not opened. block length.
****S015**** Block or record length specified is not a Reopen. specifying even block
multiple of two. FILE. is not opened. and record length. If either
block or record length is odd.
the data cannot be processed
by the system.

TABLE E-10. MAGNETIC TAPE UTILITY WARNING MESSAGES


Error Code Definition Action
xxxWOOOxxx Blocking not specified but block size and Open file with proper param-
record size have been specified differently eters. or continue statement.
in OPEN.
xxxWO 01xxx File count specified as zero Re-enter function with proper
parameters or continue state-
ment.
xxxW002xxx Record count speCified as zero Re-enter function with proper
parameters or continue state-
ment.
xxxW003xxx Input and output record lengths have been Re-enter function with proper
specified differently for COPY. parameters or continue state-
ment.

TABLE E-1!. MOUNT UTILITY ERROR MESSAGES

Error Message Definition Error Message Definition

XXXXXXXX The information for this tape INPUT ERROR. There was some failure of the
MOUNTED volume has been written to CONTINUE? logical input device prevent-
the Mount file. It does not ing the reading of Mount
imply that all the informa- information. Remaining data
tion was written. as there will be flushed and the pro-
may have been other errors. gram terminated.
It shows that as much as
possible was written. FILE NAME The F parameter was not
MISSING supplied.
UNRECOGNIZED Self-explanatory - A param- .
eter beginning with an ille- FILE MANAGER For some reasons. the Mount
PARMS file could not be written.
gal letter was supplied. The ERROR
parameter itself will be high-
lighted by a question mark (?) CODE NOTA C parameter must be CA or
printed underneath it on the ORE CEo
console.

96768710 A E-35
TABLE E-l1. MOUNT UTILITY ERROR MESSAGES (Contd)

Error Message Definition Error Message Definition

MISSING A parameter, such as F, C, PARAMETER TOO F was more than 8 characters


PARAMETER V, D, or E was supplied with- LONG long, D was more than 17
out any data. characters long, or V was
more than 6 characters long.
EXPIRATION DATE Must be five characters long.
WRONG LENGTH

CATALOG UTILITY ERRORS *RBDPCH* ****ERROR****


*T NOT FOUND IN LGO FILE
CATALOG utility error messages are as follows: BINARY OUTPUT ERROR
NAM BLOCK MISSING
*CATLOG* ***ERROR ***/ DUPLICATE ENTRY POINTS
*CATLOG* READY TO INSTALL/ ENT/EXT TABLE OVERFLOW
MASS STORAGE I/O ERROR/ PROGRAM NOT FOUND IN LIB
REQUIRED PROGRAM NOT FOUND/ RBDPCH*OUTPUTCOMPLETED
LIBRARY PROGRAM NOT VALID/ EI0 UNPATCHED EXTERNAL
PROGRAM ON LGO NOT VALID/
TOO MANY PROGRAMS ON LGO/
LAST LGO PROGRAM HAS NO XFR/ SWITCH UTILITY ERRORS
INVALID CONTROL STATEMENT/
SWITCH utility error messages are as follows:

BINARY PUNCH UTILITY ERRORS Message Meaning

Binary punch utility (RBDPCH) error messages are as follows: x. is the status of RPG
ekternal indicator U
i
*RBDPCH* O/P UNLINKED RBD PROG AND =
for i 1 to 8.
SUBPROGS x· = 0 if U. is OFF
x~ = 1 of U. is ON
1 1

INVALID SWITCH ENTRY *SWITCH xxxxxxxx


statement was invalid.

E-36 96768710 A
RPG II OBJECT PROGRAM F
LOGI C (DETAILED)

WG.a¥'Mf.f¢§4'r>' ,4'(Wti 'i dtii' •

For each input record processed, an RPG n object program The specific steps taken during each cycle are shown in the
performs the same general sequence of operations. This following flowchart (figure F-l). Total time occurs at
sequence of steps is called the program cycle. Within each steps 18 and 19; detail time is shown in steps 25 and 3. A
cycle there are two periods of time in which calculations are program cycle begins at step 3 and continues through step
performed and output records are produced. At total time, 25. The remainder of this appendix is a description of the
all total calculation operations (operations conditioned by RPG n object program logic referencing numbers in the
control level indicators in columns 7 and 8 of form C) and flowchart (figure F-l).
total output (records conditioned by co~trollevel indicators)
are done. Calculation and output operations not conditioned
by control level indicators are performed at detail time.

OPEN ALL FILES.


LOAD PRE-EXECUTION
TIME TABLES AND
ARRAYS.

PERFORM HEADING, DETAIL, AND


FETCHED OVERFLOW OUTPUT.
TURN ON OVERFLOW INDICATOR IF
OVERFLOW LINE HAS BEEN REACHED.

SET OFF OVERFLOW INDICATORS IF


PERFORMED LAST CYCLE; LEAVE
ON IF FE TCHED DURING PREVIOUS
DET AIL CALCULATIONS OR CURRENT
DET AIL OUTPUT.

SET OFF RECORI)


IDENTIFYING INDI-
CATORS, IP, LI-L9,
ANDHI-H9.

Figure F-l. Program Cycle (Sheet 1 of 4)

96768710 A F-l
YES

READ FROM FILE JUST PROCESSED.


FIRST TIME t-ERE, READ OIlE RECORD NO
FROM EACH FILE EXCEPT CHAIN AND
DEMAND.
IDENTIFY (0Nl.. Y) RECORDS WITH LOOK-
At-EAD FIELDS.

29
SI:LECT RECORD BY HIGt-EST
PRIORITY MATCHING FIELD
CONTENT.
YES

SET ON APPROPRIATE
CONTROL LEVEL INDICATORS.

Figure F-l. Program Cycle (Sheet 2 of 4)

F-2 96768710 A
YES .--________..., 1- &

18

PERFORM TOTAL CALCULATIONS AND ANY


REQUESTED EXCPT, CHAIN, DSPLY, AND
READ.
GIVE RESULTING INDICA TORS APPROPRIATE
SETTINGS.
TURN ON OVERFLOW INDICA TOR IF OVERFLOW
AREA REACH ED THROUGH EXCEPTION OUT-
PUT.
PERFORM FETCHOVERFLOW IF REQUIRED
BY EXCEPTION OUTPUT.

19
PERFORM TOTAL OUTPUT.
SET ON OVERFLOW INDICA TOR
I F OVERFLOW AREA HAS. BEEN
REACHED.
FETCH OVERFLOW IF REQUESTED.

Figure F-l. Program Cycle (Sheet 3 of 4)

96768710 A F-3
24
TURN FELD INDICATORS ON OR OFF.
MAKE DATA FROM LAST RECORD
SELECTED AVAII.:ABLE.
READ FROM LOOK-AHEAD FILES.

25

PERFORM DETAIL CALCULATIONS AND


ANY REQUESTED EXCPT, CHAIN, DSPLY,
READ, AND FORCE.
GIVE RESULTING INDICATORS APPROPRIATE
SETTINGS.
TURN ON OVERFLOW INDICA TOR IF OVER-
FLOW AREA REACHED THROUGH EXCEPT-
ION OUTPUT.
PERFORM FETCH OVERFLOW IF REQUIRED
BY EXCEPTION OUTPUT.

Figure F-l. Program Cycle (Sheet 4 of 4)

1. All data files referenced in the object program are 5. Each halt indicator is tested in turn. If they are all
opened; that is, they are made ready for use by the off or if each remaining halt indicator is off,
program. All pre-execution time tables and arrays control goes to step 6.
are loaded into computer memory.
5A. An overflow indicator was on. The operator selects
2. All output records conditioned by the first page one of three options: continue, controlled cancel,
UP) indicator are produced. These records are or immediate cancel. These options are described
written only once per object program execution in appendix B.
and, thus, do not fall within the prOgram cycle.
5B. If the operator selects continue, control returns to
3. The program cycle begins. All heading and detail step 5 where the remaining halt indicators are
records whose conditions are satisfied are written tested. If the operator elects to cancel, the
out. This output includes records conditioned by an program is terminated at step 32.
overflow indicator if the overflow routine has been
fetched. If the overflow line was reached or if 6. All record identifying indicators. and indicators lP,
overflow was fetched during this step, the perti- Ll through L9, and HI through H9 are turned off.
nent overflow indicator is turned on.
7. The LR indicator is tested. If it is on, a branch to
4. If the overflow line was reached during the most step 26 is taken.
recent step 25, the overflow indicator is turned on•.
Otherwise, if the indicator did not go on during 8. The program reads the next record from the file
step 3, the indicator is turned off. that provided the previously processed record. File

F-4 967687l0A
translation occurs at this point, if necessary.. If 19. All total output that is not conditioned by overflow
this is the first execution of step 8, one record is indicators is produced. A specified overflow
read from each input file except forced files and indicator goes on if the overflow line was reached
demand files. If this is not the first execution of during this total output phase. If LR is on, output
step 8 and the file has look-ahead fields, the next records conditioned by the LR indicator are written
record of the file is identified only. out after all other total output records have been
produced. File translation is performed on total
9. The program tests to see if the record just read output records, if requested. Overflow is fetched,
was an end-of-file record. If the end of the file has if required.
been reached, a branch to step 11 is executed.
20. If LR is on, execution of the object program is
10. When the file was not at end-of-file, the program concluded at step 35.
tests the sequence of the input record according to
form I. If the record is in proper sequence, control 21. When LR is not on, the program tests the status of
goes to step 11. Control also goes to step 11 if this the overflow indicators. If all overflow indicators
is a nonsequential input record but the program was are off, overflow output is not called for, and
able to identify the record. control goes to step 23.
lOA. A halt occurs. When execution is resumed, control 22. At this point, all output operations conditioned by
goes to step 31. positive (on) overflow indicators whose other condi-
tions are also met are performed. File translation
11. A test is made to see if end-of-job conditions have is performed on overflow output, if requested.
been met. The test is successful if all files for
which an E was specified in column 17 of form F 23. The MR indicator is turned on if this program has
are at end-of-file, and in this case a branch to multiple input files and the record about to enter
step 26 is taken. processing is a matching record. Otherwise, MR is
turned off.
12. If the program has multiple input files, the record
just read may not be the record selected for 24. Data from the record selected for processing and
processing in the current cycle. Record selection from specified look-ahead fields is made available
will occur at step 27. for the next cycle. Field indicators are turned on
or off, as appropriate.
13. With a single input file, the record read will indeed
be the record selected for processing in this cycle; 25. All detail calculations (operations not conditioned
but if sequence checking through matching fields by control level indicators in columns 7 and 8) are
has been specified for the file, that checking takes performed. Any required file translation is done
place first at step 30. for exception output, chain, and read operations.
Overflow is fetched if it is required by exception
14. A record has been selected for processing during output. If exception output causes the overflow
this cycle, and the appropriate record identifying line to be reached, the appropriate overflow indi-
indicator is turned on. Data from the record is not cator is turned on. Control returns to step 3,
made available, however, until step 24. where the next cycle is commenced.
15. If the record contains control fields, a test for a 26. Control comes here when all files for which an E
control break is made. This is accomplished by was specified in column 17 of form F are at end-of-
seeing if the current control fields are not equal to file. The last record indicator (LR) and all control
the previously processed control fields. If a control level indicators (L1-L9) are turned on, and process-
break has not occurred, or if the record does not ing continues at step 18.
have control fields, a branch to step 17 is taken.
27. If a file has been forced, the next record in that
16. When a control break has occurred, the pertinent file is, by definition, the next input record to enter.
control level indicator and all lower level control processing. The record is selected, and a branch to
level indicators are turned on. step 14 is taken.
17. If this is the first program cycle or first control 28. If a file has not been forced, and a record with no
break, total calculations and output are bypassed matching fields is found in a normal and active
by a branch to step 20. input file, that record is selected for processing.
Control goes to step 14.
18. All total calculations (conditioned by control level
indicators in columns 7 and 8) are performed. If 29. When matching fields are specified, the normal file
LR is on, operations conditioned by LR are per- with the highest priority matching fields content is
formed after all other total calculations have been selected. When two or more files have equal
performed. Any required file translation is done matching fields of the highest priority, the record
for exception output, chain, and read operations. from the highest priority file is selected for
Overflow is fetched if it is required by exception processing. (The primary file is always the highest
output. If exception output causes the overflow priority file; the order of priority of secondary files
line to be reached, the appropriate overflow is determined by the order in which those files are
indicator is turned on. listed on form ·F.)

96768710 A F-5
30. The matching fields content of the selected record 33. With a controlled cancel, all calculation operations
is compared to the matching fields content of the conditioned by the LR indicator are performed.
previously selected record. lC the records are in
proper sequence (or equal), control returns to 34. All output operations conditioned by the LR indi-
step 14. cator are performed.
30A. The program halts. The operator's options are to 35. All tables and arrays for which a To Filename was
bypass the out-of-sequence record, by reading the specified on form E are written out. File transla-
next record from the same file, or to cancel the tion is applied to these tables and arrays, if
job. The operator's decision is queried at step 31. requested.
31. This step tests the operator's decision to either 36. All files used by the program are closed; for
bypass an erroneous record or cancel the job. In example, any output record still residing in a core
the case of a bypass, control returns to step 4. buffer is written out.
32. If the operator has chosen an immediate cancella- 37. Program execution is ended.
tion, the job is terminated at this point.

F-6 96768710 A
USE OF EXTERNAL SUBROUTINES G

Control may be passed to an assembly language subroutine The user subroutine may be coded to handle a variable
by an EXIT operation or to a FORTRAN language subroutine format of parameter lists or may expect a fixed number and
by an EXITF operation in a calculation specification. form of parameters. In the later case the parameter list
Parameters referenced in the subroutine must be specified should be checked to verify that the correct structure was
by RLABL operations that immediately follow the EXIT coded in the RPG II source program.
operation. A parameter may be a field, table or array, file,
indicator, or a literal. The format of these specification
statements is given in section 9.
SUBROUTINES TO SUPPORT USER
ASSEMBLY LANGUAGE ROUTINES
ENTRY
The following subroutines are used to support user assembly
Control is passed to the user subroutine with an RTJ language routines:
instruction. The entry point must therefore be an ADC 0
instruction for the return address. R9MVB Move Bytes
Upon entry the A-register contains a pointer to the Entry: A-Register = Byte count
parameter list. The parameter list contains one entry for
each RLABL statement that followed the EXIT statement in Q-Register = Source byte address
the RPG II source program. The list is terminated by a word I-Register =Destination byte address
with all bits on.
RTJ R9MVB Subroutine call
The effective calling sequence is: ADC R9BASE Source offset
LDA = XADR A register = Address of parameter ADC R9BASE Destination offset
list
R9MIB Move Bytes Immediate
RTJ SUB Call to user subroutine, entry name
SUB Entry: A-Register = Byte count
Q-Register =Immediate constant
I-Register =Destination byte address
PARAMETER LIST FORMAT RTJ R9MIB Subroutine call
For a file, field, or table/array name in an RLABL ADC R9BASE Destination offset
statement, the parameter list contains the associated R9LBY Load Byte"
file/field description table entry number (FDT). For an
indicator the list contains the indicator number with bit 15 Entry: Q-Register =Byte address
also set on. The list is terminated by a word with all bits set
on. RTJ R9LBY Subroutin~ call
o ADC R9BASE Source offset
15 14
Exit: A-Register = Byte (bits 7-0)
ADR x Entry I
x Entry 2 R9SBY Store Byte
x Entry 3 Entry: A-Register = Byte to store (bits 7-0)
~ 4
Q-Register = Byte address
RTJ R9SBY Subroutine call

F F
Entry n
F F
Note: If X=O, entry is a file/field description table (FOT)
J R9FLDL
ADC R9BASE Source offset
Get Field Length and Address

number Entry: A-Register =File/field description table (FDT)


If X=O, entry is an indicator number number (bits 0-7)
0317 RTJ R9FLDL Subroutine call

96768710 A G-1
Exit: A-Register = Attribute bits DATA FORMATS
Bit 15 =Numeric field
14 =Table FILES
13 =Array
12 =Ascending sequence if table or array
11 =Descending sequence if table or array Information regarding files is contained in the data
10 = File management parameter table. This table (DMPT) consists of
9 =UMONTH, UDAY, UYEAR, or UDATE a prefix of 4 to 14 words plus the table itself. The prefix is
field addressed as negative offsets from the pointer output from
8 = Any form of page field R9FLDL.
7-0 = Byte length minos 1 (alphabetic field)
7-4 =Decimal position (numeric field)
3-0 =Digit count (numeric field)
FIELDS/TABLES/ARRA YS
Q-Register = Length
Alphabetic field = Byte length minus 1 The byte address output from R9FLDL is relative to
Numeric field =Digit count R9BASE. To get the absolute address, the byte address must
I-Register =Address be shifted right 1 and added to R9BASE. If the unit's
File =Absolute address of DMPT position of the byte address is on, the first byte of the field
Field =Byte address relating to R YBASE is the rig~t. byte of the ~irst word: The first byte is the high
order posItion of the field. This address manipulation is
R9TSTN Test Indicator performed by the R9LBY and R9SBY routines.

Entry: A-Register: Indicator number (bits 7-0) The table byte addre~ is that of the last looked up entry;
the array byte address IS that of the first array entry.
RTJ R9TSTN
Exit: A-Register: 0 =Indicator on Numeric fields are in packed decimal format with one
1 =Indicator off decimal digit per byte. A sign byte is allowed to the right of
the low order digit; D is minus, F is plus.
R9CRIN Clear Indicator
Entry: A-Register: Indicator number (bits 7-0)
INDICATORS
RTJ R9CRIN Subroutine call
Numbers 1 through 99 are used for indicators 01 through 99.
R9SETN Set Indicator
Entry: A-Register: Indicator number (bits 7-0)
RTJ R9SETN Subroutine call

G-2 96768710 A
CODI NG OF SAMPLE RPG II PROGRAMS H

This appendix contains two sample RPG II programs. The INPUT SPECIFICATIONS
first example is described in considerable detail as an
introduction to RPG II program solutions. Records in the file READER are identified by an X in
column 80. Indicator 01 is set on when this type of record is
being processed.
EXAMPLE 1 Active records in the inventory file, INVTR Y, are identified
by an I in character position 1. Indicator 02 is on during
Example 1 demonstrates the retrieval and updating of processing of this type of record. Any other type of record
recorm in an indexed sequential file using the CHAIN in the same file turns on indicator 77.
operation code. The context is an inventory report problem
in which a part number field from an input card is used to
chain to the indexed sequential disk file. The card record
also contains fields that specify how many of a particular CALCULATION SPECIFICATIONS
part were received, issued, and returned in the transaction
period. The card record is identified by an X character in At line 010, the PARTNO field is chained to the file
column 80. INVTR Y. The CHAIN is conditioned by the presence of a
valid input card, designated by indicator 01. If the CHAIN
The master inventory record for the part contained in the fails to yield the desired record, indicator 88 is set on.
disk file contains an alphanumeric description of the part as Otherwise, indicator 02 is on in the next detail cycle.
well as the number of parts on hand and the minimum
number of the particular part that is acceptable for the When indicator 02 is on, all the fields needed to perform the
inventory•. inventory calculations are present, and those calculations
are performed in lines 020 through 050. The field WORK
Calculations are performed to determine the new on-hand receives the result of the calculations.
balance for the part number. That field of the disk file
record is updated, and a report describing inventory activity At line 060, the test is made to determine if more parts
for the month is printed. need to be ordered. Indicator 11 is turned on if the balance
is equal to the order point, and indicator 10 goes on if the
If, during the chaining process, an unidentified part number part definitely needs to be ordered.
appears at the card reader, that part number is printed in
the report with the comment NOT FOUND. A master
record that does not contain the record identification code I
in the first character position corresponds to a deleted part OUTPUT SPECIFICATIONS
number and is identified as such in the same printed report.
Heading lines for the file PRINT are produced if either the
A new balance that is less than or equal to the minimum first page (IP) indicator or the overflow (OA) indicator is on.
acceptable balance for a part number is denoted with the Updated page numbers are printed at the top of each page.
comment ORDER or WARNING, respectively, in the report.
The detail record described in lines 170 through 270 is
The following pages contain illustrations of the input, printed only if both indicators 01 and 02 are on. The
update, and output files involved in the program (figure H-l) individual comment fields ORDER and WARNING are
and the five pages of RPG II coding (figure H-2) required to conditioned additionally by the indicators 10 and 11,
solve the problem. respectively.
Lines 280 through 310 describe the exception line, which is
printed for either an unidentified part number or an inactive
FILE DESCRIPTION SPECIFICATIONS master record.
READER is the name of the primary input file assigned to Lines 320 and 330 provide the updating of the master file.
the card reader. This file must be processed to end-of-file. Update occurs only if both indicators 01 and 02 are on,
showing that both a primary and secondary record were
INVTR Y is the chained update file. The file has fixed length received for the part number and that the calculations were
records that are 40 characters long. The key field is six performed. Other fields of the master file record are not
characters long and begins in record position 34. The file is listed on the Output Specifications form,. as they are not
processed randomly. changed.
The output file is named PRINT and has overflow indicator
OA associated with it.

H-l
96768710 A
PARTNO RECD ISSUED RTRND X

READER FILE

DESCR IMINMUM IONHAND IPARTNOI


INVTRY FILE

INVENTORY 07/04n6 PAGE


PART PART MINIMUM PREVIOUS NEW
NUMBER DESCRIPTION BALANCE BALANCE RECEIVED ISSUED RETURNED BALANCE

220260 ITEM I 50 55 5 50 WARNING


220261 ITEM 2 1,000 1,006 100 30 1,076
220264 ITEM 3 750 600 100 25 50 725 ORDER

267890 NOT FOUND

3 I 1235 DELETED

I ~

0334 PRINT FILE

Figure H -1. Input and Output Formats

96768710 A
H-2
&J t::\ CONTRPL DATA RPG CONTROL CARD AND FILE DESCRIPTION SPECIFICATIONS
\::I ~ CORPORATION

Pr04ramme r Dale I
Control Card Specifications
~Odel

-
H ~
j
E
ir-----,-~r<-.-r~
Model 20

r!~
~

... ~ Number ; ~~ g~c]~ ~~


Sile to a. ~ Size to
_~ ~ ~;S~;II~~S 8 o <!l Reftr to the !>peciflc System Reference LlbtdrY mdnual for actudl e'ltr, .. ~
!
..lIII:

8- ~

UHHliHHHi jII J~
Address
Lme Compile c3 EKecutl
ii ~ ~ !! taSlan
~ r
&
E
g3
g 15
~ ~
g 10 11 12 13 14 15 16 17 18
~I~
202127 7324 ]5 26
I ]I 78 19 )0 313133 )435363738394041474344 4S 4647 4R 49 SO 51 575] 54 55565758 !)g 60616263 rA 65 66 61 68 !)'oj II) /1 17 1"1 14

II I II I II II I I ! IIj III I II j Jj L11 I

File Description Specification


File TVpe Mode of Process I ng

-
F length of Key Field or
of Record Address Field
Extent Exit
for DAM
Nymber of Tracks
for Cylmder Overflow
End of File
Record Addre~s Type Name of Numl,)p.r of EJltpnts
Sequence Symbolic
Filename Type of File Device Label EXit
DeVice Tape
File Format Organization Rewmd
Storage Index
or Additional Area
~
Overflow Indlratof u Condlt'on
r--- 6
Block Record
Key Field § Z Ut~
Length length

~
a: SUrtlng ;
...J Location UJ Opt Ion Entry

10 11 12 13 14 15 1611 18 19 ]021 12 23 24 25 16 27 28 2'930 31 3233 34 35 36 37 38 39 4041424344 45 46 4748495051 52 53 54 Ijlj 56 51 58 59 6061 626364 65 66 67 68 69 70 71 72 73 7.

H-+-+-+--t-l-+-++-H t-++-
-+-++-f·--t-+--+-++-H-t-t+-·~t- -- ~. 1-1-
I
r-l--
+-H-+-++-+--HH-++-+--H-+-++--HH-+-+-+--H-t--+--+-+'H--+-+++-+-H-t-+++-H-I'~r-' - -t 1-1-

RPG INPUT SPECI FICATIONS

t 2 75 16 17 7B 79 BO

IDale
p,gemOf~ ~~~~;~f:'"",, [IX!A 1M IPlI] I
Record Identification Codes

-
I Field Location

Filename
Position Position Position From To
E z e ~
~ 2
~ Z u u

12 13 14 16 16 171819,0 21 12 23 24 2~ '2627 282'93031 1/33 143536 37 3B j<) 40 41 42 4J 44 45 46 41 4H 4CJ <-,0 ~1 52 <,] r,4 ')'J 'JI, ~} ~8 596061 &163646') 66 67 68 fi'1 70 11 12 73 74

1--

If' ---c-
I
11 ~!---I- I- _. ~.- I- - - -

-- r--r
1-1--- I- ,- 1---1- -- ~ -_.. f--i--
I--!-+-
-- -_. ~t~

Figure H-2. Example 1 Coding (Sheet 1 of 3)

96768710 C H-3
r,l E:\ CONT"OL DATA RPG CALCU LATION SPECI FICATIONS
\:=I r:!J CORP0Rt\TION
t',' £J, It (YiP Lt' . I F',tll'l ~~'"
l'"

fl, Pt""" JI)II. 1 p, I


c
~
"I, J, FdLtor '2
L~nllttl -- il-,~-~~
Vi f-....-+-r~+-r--.--4 , .i 1-'--..J..' ...!'l.L:~
:.-.1

'" 1-'~--'---1
" \~i, i" ~I,
.
:': ::: H, .•
i,
',I DC 0..1 p!A!Rtr~N~: , i ; C:HAr,Al[x1,N!v:Tlf<..n : !
,0 C _~:02~.~ H-~ 1 . ~ .L~ 2.-,A1J~1)~lULA.N,b.___ W0f\I'l ,11c
,
Dc
'.~
.02.. v/.CAR.K .. __ 't. . __ ,~])D 816~:P . ~OA.~
:lc _.0.2 . W.(JJ.RK. _,_~ ADl> fl.:r.6!V:1J.; .. Wrpp.,,,,
CC _0.2 'W:(]J.ry,- ,ls~6
t- r,~_5.LLED ., w~,R K
"0 c ._O·21-~ ~;a+1Zi
, :
1\ -~.l C.0M P 'M.I.N.MU.''1_, 1-
ltOL1
c

r,l E:\ CONT"OL DATA RPG OUTPUT SPECIFICATIONS


\:=I r:!J CORP0Rt\TION
1 '} 75 76 77 78 79 eo
~_~--'...L..." I)' I .' .:::Lc....-....:/~----
. . --.-~-----1- PU~Ch,ng r.:::17l
r P''''l"m ~-:-~
I Dale _~.Innructjon p,,!,, ~Ol~ Id.n\'f.ca\,on8~~1J I
o Skip Oulpul I nd,calOrS =-----::> ! Commas 1 If'f(,
.. ··1

F.II ;::. : :
~en'O~l' I

>-- Field Name ~-- T -~_o- ~ lu~ $Iqr


Ddle

F llpnanH'
,",
'"
C),d(HJ 1 .:.
Conc,tdr1! ur E !llf Word
iii
Q:

~I 1 f:: 0 f!p);Ijv:-r.
0,'

o
C- 0
,3.e 0 I~ It
I
i:;,,,I.V·'/:V J

O;4.C 0 I
I--
0.5[. 0

o . h!-, 0
1'-
O,7,C 0 .IH 1 t-
.a[£ I--f-- t
1

;.
1-- l-L

-.--

Figure H-2. Example 1 Coding (Sheet 2 of 3)

H-4 96768710 C
r,ll::\ CONTR,.OL DATA RPG OUTPUT SPECIFICATIONS
\::I ~ CORPOR<\TION
p'09,"mF X p rn PL t.
Programmer Date Pago rn of i
1 2 75 76 77 78 79

~~:;~f:"'On lctx.1f11~, f
110

I:11 I

'J~
I i I I i
! ! !
,
:It.-
j j
f-r
1
: i
I

t t 1
!
·-1·
: I -t~
If'

~flf
-'

I I

j
(+1=
Figure H-2. Example 1 Coding (Sheet 3 of 3)

EXAMPLE 2 Records used to create OFFEXT are read from the card
reader. The file is initialized to blanks. The key field is
In example 2 the CHAIN operation code is used to create contained in positions 1 through 3 of each input record.
(load) a direct disk file. The disk file, OFF EXT , is a file of Other character positions, although loaded to the file, are
telephone extensions in the plant; the file is ordered by not described individually.
extension number, and each record contains the office
number and employee number corresponding to each exten- Figure H-3 shows the RPG II coding sheets required for
sion. OFF EXT is described on the File Extension Specifica- example 2.
tions form as a chained output file.

H-5
CONTRPL DATA RPG CONTROL CARD AND FILE DESCRIPTION SPECI FICATIONS
CORPORATION

_
l·r~~~~~E~ ~~-.~_~=[~0:::~::,~_J-:~:':~h~; -1~1~~1~1_---"----..l11---1---1~I
C"'~~.'~_';N';'~ I
Control Card Specifications

H
r-- ~
o
~

~~
Lin, .£:

~
S,'I'TO
Cump,lt.'
Sill"
Execute
to

~j i;:;,: ;,:, i
~ Numtwf ~
Addres~
to Stdft
;;
I

~
i ]~ ~ ~
I-- (/)
::S
: s~ ~
u... ......
t-'

a::
(1 10 ,~ 121314 IS 16 1/ 181920 (1 n )!;J4}r.., 26 n 31 J7 33 )435 Jh 37 3R 39 40 41 42 43 44 4541; 47 4R 49 ',0 51 '>i f)J Iyl

I
11 ll I
"

o H 1 I iii

File Description Specification

File Tvpe Mode 01 Proce~<'lnq

-
F Length of Key Flell1 or
of Record Address Field
Extent EXIt
for DAM
Numbf'f 01 Tr.teks
tor Cylinder Over'low
End of File
NcHlW 01
Sequerrt> Symboll(
Filename Type of File DeVice Label E XII
DeVice Tape
~lIe Format Organization
or Additional Area
o
Storage Index
~
OVE'rfll'W In(liCdlo; u

Btock Record
;----- g UI US
;~~t~~~td ~ COfl11r1UJlton ltflt.'" r-
Length Length
Location u.J Opl,on Entry
3 4 7 R 9 III 11 121314 15 1611 1819 2021 21 23 24252627 78 29 30 11 321) J.4 35363738)1) 40414243444546 4748 ,Fl ~() ~1 S2 53 ~ ~~ ':>6 57 f:JH ':19 60 6' 61 63 64 65 f)fj 67 6R fig 70 11 U 73 74

t----\·-+-+-+-+-i-t----\- j r- -"--1--
I- i t-. + 1--
I
I- j- 1--+ f---

CONTRPL DATA RPG CALCULATION SPECIFICATIONS


CORPORATION

----lr ,
I
, 1

c IrHJICdturs

- ! I' 1\' ',,,01 ;., (:1)"(1"'11''>


I
L",
N,I'I'l Lenqth - .'11 21'
-i ,I,
I

,=,
I
I
" ll'''\'

rl. I .Cc
C

Figure H-3. Example 3 Coding (Sheet 1 of 2)

H-6 96768710 C
RPG INPUT SPECIFICATIONS Printed .n U.S.A.

12 757677787980

Page ~ Of!l. ::~f~cation I IIIIII


s Record Identification Codes

-
I ::l
~ I 2 3
Field Location Field
Indicators

..!i~ ij
~
c. 0

~ &
!
';"-
OJ ~.;; a:
line Filename Z Field Name
C>
> l ~§
0

~
t 1 a: i ~~ Zero

J I:r
Position Position - !! PosItion From To Plus lMil\U1 or
f- .8
...... I-r- ; &g
c
" e ~ e ~ ~e
g
t; .. -
~ ~ ! Blank
~ j N :;; :!2
zo ()Q ~~6 ~~ QUID:: ~
~6 ~
~~
Q

AN ~
3 4 5 6 7 8 9 10 11 12 13 14 16 1817 18 19 20 21 22 23 24 25 28 27 28 29 30 31 3233 34 35 36 37 36 3940 411-c2 43 44 45 .s 47 48 49 50 51 62 53 54 55 56 57 sa 5850 61 62 8364 65 66 1788 6970 71727374

0 IIr- Ir.:z r" f ILJiT .~~ eli


0 21r I l1 l3lc p!" lalNE
0 3 if-, I .1 18:0 tI>A 71A
o 4 I
~ ~

CONTRPL DATA RPG OUTPUT SPECIFICATIONS


CORPORt-TION
12 7576777879110

Oat.
Page ffi Of!1 ::r:f~Cltion UIIIII

I---
o _ ~ Space
~ ! 1-.-4-....---1---.
Skip Output Indicators
..-,--.1..---1 fietd Name
IA;'::::::::::::==~".~> Commas Zer~oB:,li~~ces No Sign CR - X·
If, ... F==v=es=~';;;';v';;es~=+===F==A9==J=l v •
Remove
~1~tSeSign
~
~
;:; j B
IE End
I....
Ves
No
No
Ves
B
C l Z·
K Field Edit
Zero
Line Filename
~ ~ .; < hr--r_A... nd.....,...""T""+-_ _ _ _-f .. ~
nd.....,.....,.....A... Positon No No 0 M Suppress

! t- ~ .... ' -
ADO

~ ::; ZO ZO ZO
-3'
<3 5
in
Output
a:
::; Constant or Edit Word
E
~..!!..... - ~ ·AUTO ~ ~ Record ~
.f AND
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 12 33 34 3S 36 37 38 l!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

-- -- I- - . ~ -- -++-+-IH-++-f··-'- -. -~I--l-+--f-~
-- ..- -- -. f--. f- . -
I
·+-+-f---f-+-t-++-+-+ -+--'-~-4~

Figure H-3. Example 3 Coding (Sheet 2 of 2)

96768710 A H-7
RPG II UTILITY

Table 1-1 specifies the user of the utilities described in this The utility is called in ITOS console mode in reply to
appendix. Disk type utilities are supplied by UTIL, which is REQUEST = :
described in the nos reference manual.

I TAPE MOUNT UTILITY MOUNT, parameter list

The format of the commands read from the MSOS standard


input device by MOUNT is a string of pllrameters separated
by commas, in any order (see table 1-2). The first letter of
NOTE the parameter signifies its meaning.
This utili ty operates under IrOS only from The last MOUNT command must be followed by /* in inpllt
the master terminal. It does not operate columns 1 and 2.
from other IrOS terminals.
A MOUNT command is required for each tape file in the
RPG II program, including unlabeled tapes.
The tape mount utility (MOUNT) runs under MSOS to define
all tapes that are used by a subsequent RPG II program. An RPG program has seven F state:nents referring to files.
The following is a sample \lOUNT program:
MO U NT builds records into an indexed MSOS file manager
file that is indexed-linked, first-in, first-out. The key *MOUNT
corresponds to the filename on an RPG F statement. Groups FTAPEI
of records with the same keys cOt'respond to volumes within FTAPE2
a multivolume file. The file number of this file manager file FTAPE2
is defined by the INIT utility and is named MOUNTFIL. FTAPE3,B,P
Every time MOUNT is executed, the file is rewritten from FTAPE4,S, V123,DNEW.DATA
the beginning, FTAPE5,S,Vll1111,DMYDATA
FTAPE5,S,V222222,DMYDATA
The utility is called in by the MSOS job processor command: FTAPE6,S,OUT. DATA,V333333
FTAPE7, V345,DUPDATE,E76300
*MOUNT /*

TABLE 1-1. UTILITIES USED WITH RPG

Utility System Comments


I
MOUNT ITOS, console mode Cannot be used except at master terminal in ITOS

CATLOG ITOS, batch mode Cannot be used except at master terminal in IrOS

SWITCH IrOS, terminal mode Note difference in way utility is called

RBDPCH ITOS, batch mode ITOS current does not support punch type hardware

DSORT ITOS, procedure stream mode

UTIL IrOS, terminal mode

EDITOR ITOS, terminal mode

96768710 C I-I
I TABLE 1-2. MOU\lT UTILITY PARAMETERS Where:

First Subfield Definition TAPEl is a non-label tape.


Letter
TAPE2 is a non-label tape on two volumes.
I A Add records to an exist-
ing file. TAPE3 has a nonstandard lahel; therefore the laocl
must be bypassed. Mount 'Nithout a ring.
B Bypass label processing.

C A, B, or E Code of tape: ASCII, BCD


or EBCDIC.

D Name; up to 17 Dataset name on HDRI


characters long label

E Date; in form yyddd Expiration date of file


(yy=year; ddd=day)

F Name; up to eight File name, corresponding


characters to RPG F statement

L Leave tape in position at


close time

N No label processing

P Protect file. Informs


operator to remove
write ring.

R Rewind tape at close


time.

S Standard label pro-


cessing

U Unload tape at close


time.

V Number; up to six Volume serial number of


characters long tape

NOTES:

1. F is compulsory.

2. Defaults are CA (ASCII code), N (no labels), and


R (rewind). The rest are optional.

3. B, N, and S are mutually exclusive.

4. L, U, and R are mutually exclusive.

5. D, E, and V make sense only in conjunction with S.

1-2 96768710 C
TAPE4 is an input file on a standard labeled tape. The ON LIBRARY MASS-STORAGE DEVICE
serial number. of the tape is 000123 and the
data set name is NEW.DATA.
ROOT FILE 0
TAPES is an input file on two volumes with standard
labels. The volume serial number of the first
tape is 111111 and the second 222222. The INITLlALIZA TlON
data set name is MYDATA.
TAPE6 is an output file to be written on an SL tape.
The data user name is OUT.DATA, VOLUME
333333. INPUT FILE I

TAPE7 is an output file to be wpitten on an SL tape. CALCULA TION


The volume serial number is 000345. The data
set name is UPDATE AND EXPIRATION
DATE 76300 (day 300 in year 1976). OUTPUT

CATALOG UTILITY
CLEAN UP FILE 2
NOTE
This utility operates under ITOS only in
batch mode from the master terminal. It CALLING
does not operate from other ITOS PROGRAM PROGRAM
terminals.
Figure 1-1. RPGII Program Link-Edited and
The catalog utility (CATLOG) installs the generated RPG Loaded into Program Library
object program in the MSOS program library under the name
given in the RPG program identification field (columns Step 1 - The RPG II compiler stores the object code on the
75-80 of Common Entries). . scratch mass storage unit beginning at the first scratch
sector. The compiler generates five object modules for each
The RPG object program will be link-edited and installed in RPG program (initialization, input, calculation, output, and
the program library as shown in figure 1-1 and described cleanup). Each object module begins with a NAM block and
below: terminates with an XFR block compatible with the MSOS
LOADER. The CATLOG program takes the relocatable
1. A calling routine with· the entry point the same as the object code generated by the RPG II compiler as input.
RPG program name. The calling routine is stored in
relocatable binary format. Step 2 - The CATLOG program inputs the ROOT and calling
program from the program library, inputs the object
2. A file containing the ROOT and initialization modules, program from scratch mass storage, and outputs the library
named the same as the RPG program name with the last edit load file. The load file is input to the MSOS library
character of the name replaced by O. editor (LIBEDT) to install the RPG object program as three
overlays and a calling program.
3. A file containing the input, calculation, output, external
root, and tables. It will be named the same as the RPG The prototype of the calling program object code is modified
program name with the last character replaced by a 1. to have the declared RPG program name as its entry point
and to use the file names as described.
4. A file containing the cleanup routines, named the same
as the RPG program name with the last character Step 3 - LIBEDT is called to link-edit and load the three
replaced by a 2. files and the calling program into the program library.
Because CATLOG generates three overlays, the amount of The catalog capability requires the use of a read/write
core required to execute a program that had been cataloged sequential access device. Either a magnetic tape or a
is less than for direct execution from the load-and-go file. pseudo tape (in conjunction with the job file handler (JFH»
and the file manager in MSOS satisfy the requirement. The
The cataloging task takes three steps. See figure 1-2 and job control statements vary depending on. which device is
the following description. used.

96768710 A 1-3
IN PROGRAM LIBRARY
ROOT
CALLING PROGRAM
PROTOTYPE
IINST ALLA iioN FILE- -:-
--- - - - - -l

I
ON MSOS
SEQI.£NTIAL DEVICE
PROGRAM
LIBRARY I

r+
ON SCRATCH
INITIALIZA nON
r+.
I
ROOT
INITIALIZATION - rl FILE 0 I
I

B
ROOT INPUT
INPUT ~ *CATALOG ~
I LlBEDT I
*RPG CALCULA TlON CATALOG I
CALCULATION
OUT -.. - I

B
COMPILER f- STEP 3
STEP I OUTPUT
PROGRAM
I ROOT I
T
CLEANUP
STEP 2
I
CLEANUP
I
I I
CALLING CALLING
* RPG *CAT!LOG I PROGRAM PROGRAM
___ J
I
L __ _

0324

Figure 1-2. Flow of Compiling/Cataloging an RPG n Program

The job control statements for magnetic tape are as follows *OPEN,TAPEl,RPG,
(it is assumed that logical unit 6 is a magnetic tape): W,7 3 Open with read/write option
as LU7.
Control *K,P7 4 Make the binary output
Statement Step Comments unit 7.
*JOB,RPG ,CATLOG 1 Job control *RPG 5 Execute the RPG compiler.
*REW,6 2 Rewind the tape (unit 6). -RPG SOURCE-
*K,P6 3 Assign output to the tape. *CATLOG 6 Take the generated object
code from scratch disk. and
*RPG 4 Execute the RPG compiler. create an install file on
unit 7.
-RPG SOURCE-
*CATLOG 6 Take the generated object *V,7,B 7 Install the programs on
code from scratch disk and unit 7 in the library.
create an install file on
unit 6. *RELEAS,TAPEl,
RPG 8 Release the scratch tape
*V,6,B 7 Install the program on ·unit 6 and its space.
in the program library. -END OF FILE- 9 End of job
(Unit 6 has all the control
statements to accomplish
this.)
SWITCH UTILITY
*REW,6 8 Rewind unit 6.
The SWITCH utility is either called from a process stream or
-END OF FILE- 9 End of job it is called from a terminal in response to REQUEST=. In
The job control statements for pseudo tape are a follows (it the process stream case, the utility call has the form:
is assumed that logical unit 7 is a pseudo tape): SWITCH
Control xxxxxxxx
Statement Step Comments
Where: xxxxxxxx is the switch setting ( O=off, 1 = on).
*JOB,RPG,CATLOG 1 Job control
*DEFINE,TAPEl,RPG 2 Define a scratch tape
*

1-4 96768710 A
If called from the terminal in response to the REQUEST= A leading message is printed on the line printer:
option, after SWITCH is requested, the displayed message is
returned to the operator: *** UNLINKED RBD PROGRAM AND SUBPROGRA:',1S
***
ENTER SWITCH VALUES xxxxxxxx
***
The opera tor replies by specifying the position of each
switch with a zero or a one. and is followed by the names of all the programs nnd
subprograms as they are output to the punch unit.

81 NARY PU NCH UTI LI TY A message is printed with the name of the missing entry
point for each external reference that cannot be rna tched by
a corresponding entry point in the program library.
NOTE
Following the last subprogram, an *T is punched and a
This utility is not currently used for ITOS term ination message appears on both the line printer awl
since the lTOS hardware configuration comment device:
does not include punched output
equipment. RBD FILE FINISHED

and control returns to the job processor.


The RPG II object program may be punched from MSOS
load-and-go scratch mass storage by the binary punch See the RTOS reference manual for information on loading
(RBDPCH) routine. the deck into the RTOS System

The object output is compatible with the MSOS and the The following core-resident entry point names normally
RTOS relocatable linking binary loader and optionally appear as missing externals:
includes necessary RPG II runtime routines (copied from the
LOGIA
MSOS program library). "
fa FMPFLG
Input is read from the standard input device and is
terminated by an *T record or an end-of-file. Output is • RPFDIR
always to the standard punch unit ($F A), which may not be
the same as the input unit. Output is terminated with an *T,
• SYSID

if read, or an end-of-file.
II) R9SWCH
fit DAYTO
Relocatable binary output is copied directly from the
scratch unit to the punch unit. External references cause
lit MONTO
the corresponding programs to be copied from the program fa YERTO
library.
Dummy programs (if any) used to equivalence these enti'y
The RBDPCH utility produces a deck of relocatable binary points must be removed from the library prior to executing
programs and subroutines that may then be loaded and linked RBDPCH or deleted from the output.
into an executable program. A tape or pseudo tape or other
MSOS binary output media may be used instead of punched
cards. The prerequisite for using RBDPCH is that the object SORTUTILITY
program(s) must be on disk scratch (LGO file) and must be
terminated by an *T. The runtime routines necessary for
the operation of the program(s) on LGO must be in the A call to the sort utility allows one or more files to be
program library sorted in order by one or more key fields into a single output
file. The sort utility may be called only from a procedure
The MSOS job control statements to punch the object code stream and may not be called fl'om within an RPG II
following compilation are: program. The sort utility has the following capabilities:

*K,Pn It One or more files composed of records of equal length


can be sorted. If more than one file is sorted in a single
*RBDPCH,x
run, the records are merged to form a single sorted
output file.
Where: n is the logical unit used to punch the resulting
binary decks
• The key fields upon which the files are sorted may be of
any length, may overlap, and (if more than one key is
x is a suppression flag. If x is any nonblank
specified) define a hierarchy, that is, a secondary sort
character, the referenced library programs are
within a pri mary, a third order sort within a secondary
not punched. Trailing commas can be omitted
sort, and so forth.
if x is blank.

96768710 C 1-5
It The user may select whether the sorted output file will TEXT EDITOR
contain (1) the full input records (tagalong sort) or (2)
only the portion of the record that remains after the The text editor provides line-by-line (record orienterl)
key fields have been removed (data sort) or (3) only the editing of sequential and direct files that contain only ASCII
rela t iv e record numbers of the input file records text (or blank filled records, in the case of direct files). The
(ADDROUT sort). text editor is used to add or change records in existing file-
manager files or in files previously createri by the text
-- Records may be selectively included in or excluded
editor. Thus the editor is well suited for creating and
from the output file based on whether a single key field
maintaining RPG II source files. The editor can only be used
within the record satisfies logical relations specified by
interactively; all entries are made through the CRT
the user by the relational operators =, t-, <, >, <, and>
terminal. The following types of operations can he
relating the key field to another key field or to a
performed on a file:
constant.
f' Da ta in the input records and the nor mal colla ting
seq uence are assu m ed to be ASCII. However, the user f' Change a single line
may select that EBCDIC code be used instead.
8 Change a specific character string in one or more lines.
For a more complete description of the sort utility, its
The user specifies the old string of characters. the new
operation, and its use, the reader should refer to the ITOS
string that is to replace it. anri the range of lines in
reference manual.
which the change is to be marie.

UTIL • Add a line with a specified line number


UTIL is a file-oriented utility that can be used to control
.. Add one or more lines with automatic line numbers.
equipment to be used, to list files, and to set up, change, ~nd
The text eriitor assigns line numbers in ascending order.
compress, or release files. UTIL can also be used to brmg
disk packs online and to load copy, or dump files.
• Delete a line
The file manacrer utilities operate under the direction of an
executive, UTIL, that is clllled through the ITOS executive.
• Clear all references to the current fi Ie
UTIL reads an individual request processor into main
memory to process each UTIL command. • List records on the CRT tel'minal within a range of
records specified by the user
UTIL operates in one of two modes:
• Resequence the records in the file by assigning new
f' When interactive mode, UTIL processes commands sequence numbers
entered by the operator through the CRT terminal.
• When in procedure stream mode (entered by keying • Set tab stops for use with auto mode line entry
REQ UEST = CARD PRO), UTIL processes commands
encountered in the input stream being read on the
For a more complete description of the text editor, its
device previously assigned by the INPUT= command.
capabilities, operation, and restrictions, the reader should
refer to the ITOS reference manual
For a more complete description of UTIL, its operation, its
use, and the commands. refer to the ITOS reference manual.

• 1-6 96768710 C
TABLE 1-3. CONTROL STATEMENTS FOR SMC2

Statement

9!!!
SMC2 Sorting procedure stream begins

RUN Statement

I D. WKBKSZ.S/N .KEYCNT .FILCNT. D = Disk sorting operation


WKBKSZ = Size of working area required
SIN = Sequence checks. selected or ignored
KEYCNT = Number of search keys
FILCNT = Number of files to be sorted

KEYS Statement

••• C. AID. KEYCOL. KEYCOLS ••.• One sequence of these four parameters per key
C = Character type records
AID = Ascending or descending order
KEYCOL = Relative position of first character of key in
record (starts with 1)
KEYCOLS = Number of characters in keyword

INFILE Statement

D.FILNAM. RECLTH ,BLKSIZ ,SKIPCNT, DOCNT, One INFILE statement per input file
D = Disk type records
FILNAM = File name (eight characters)
RECLTH = Record length (word,,)
BLKSIZ = Block size (1000 words, nomina})
SKIPCNT = Number of records skipped prior to first
record to be sorted
DOC NT = Number of records to process in this file

OUTFILE Statement

D.FILNAM,LUN .BLKSIZ, D = Disk type output file


FILNAM = Output file name (eight characters)
LUN = File manager logical unit
BLKSIZ = Block size

SIN selects or rejects sequence checking of sorting run is aborted. N suppresses


all merged outputs whether inter- sequence checking.
mediate or final (usually sorting is
done in stages and the sorted outputs KEYCNT is the number of keys to be used for the
from groups of records are succes- sorting run. SMC2 will not finish
sively merged into larger and larger processing the KEYS statement until
groups until all of the records are in a the number of keys specified by
single group). S selects sequence KEYCNT has been found and pro-
checking. This should be the normal cessed. If this number is not found,
selection of this parameter. Use of the run is aborted and the fatal error
sequence checking guards against message is delivered. If the input file
errors otherwise undetected during is an indexed file, the key fields do
1/0 transfers. A sequence error is not have to agree with the key fields
treated as a fatal error and the used by the file manager.

96768710 B 1-7
FILGNT is the number of input files to be used RECLTH is the number of words per record.
for the sorting run. SMC2 will RECLTH must be an even divisor of
continue to process INFILE state- WKBKSZ and BLKSIZ. Note that
ments until it has found the total RECLTH must be the same for every
number of IN FILE statements speci- IN FILE statement, and the length
fied by the number in this parameter. equals or exceeds the length of the
If fewer or more INFILE statements largest key (that is, keys must be
are encountered, SMC2 aborts the entirely contained within a single
sorting run. SMC2 processes input record). For a 32K word computer,
files in the same order that they were maximum RECLTH is about
specified by the INFILE statements. 2,000 words.

BLKSIZ is the number of words that SMC2 reads


KEYS STATEMENT during a read request to a file. It
may differ for each INFILE state-
This statement defines' each key to be used. Each key ment, but each BLKSIZ must be a
requires four consecutive parameters. The order of the keys nonzero multiple of RECLTH. At run
in the KEYS statement determines the sorting hierarchy: time, SMC2 checks the length of each
the first key presented is the primary key. Records are first block to be read to verify that the
sorted by this key. Then records are sorted according to the actual BLKSIZ is a nonzero multiple
second key presented. ,Then records are sorted by the third of the specified RECLTH and to
key presented, etc., until records have been sorted by each verify that the actual BLKSIZ does
of the specified keys. not exceed the available memory
storage. Error messages are gener-
The format for each of the n keys used in the sorting process ated if BLKSIZ is improperly desig-
is: nated. Depending on other SMC2
parameters, the maximum BLKSIZ
C,A/D,KEYCOL,KEYCOLS, for a 32K word machine is about
1,000 words. Other parameters,
Where: C indicates that the record to be however, diminish this value.
formatted is a ciIaracter type
record. SKIPCNT is the number of records at the
beginning of the file to be skipped
AID A signifies that ascending collating prior to processing the first record
order is used; for that file. Its value ranges from 0
D signifies that descending collating to 99,999,999.
order is used.
DOCNT is the number of records to be
KEY COL is the character position within the processed in this file. Its value
record for the first character of the ranges from 1 to 99,999,999. DOC NT
key. The first character position of and SKIPCNT together allow the pro-
the record is numbered 1. grammer to select a single contiguous
block of records from a file, to omit
KEYCOLS is the length of the key in characters. records preceding the desired
The ininimum length is a single records, and to omit r~cords follow-
character. ing rhe desired records. If DOCNT
equals E, all records are to be
processed.
INFILE STATEMENT
Each file used in the sorting operation must be defined by its OUTFILE STATEMENT
own IN FILE statement. The order of the IN FILE statements
determines the order in which files are read when the The OUTFILE statement defines the output file. The format
sorting operation' is executed. The format of the IN FILE of the statement is:
statement is:
D,FILNAM,LUN,BLKSIZ.
D,FILNAM,RECLTH,BLKSIZ,SKIPCNT,DOCNT.
Where: D indicates the file is a disk file type
(that is, a file manager file).
Where: FILN AM is an eight-character file name. The
owner name is fixed by the USER ID
which was supplied by the operator FILN AM is the eight-character output file name.
when he logged onto the controlling Its name follows the same rules as
terminal. Volume name is fixed by the FILNAM parameter in the IN FILE
statement.
the fact that the OUTFILE must
occur on the same file where the
input files are stored.
-.

96768710 A
1-8
LUN is the file manager logical unit where RECLTH is inferred from the INFILE statements. RECLTH
the output file is to be defined. This must be an even divisor of BLKSIZ.
unit corresponds to an a.<;signment in
SYSDAT of the file manager logical Example:
units, which are numbered (on a
maximum hardware configuration) Procedure Stream Comments
from 1 through 8. SYSVOL is always
numbered 1. SMC2 converts this SMC2 Procedure call
LU N value to a volume name as a
function of the location where the D,318,S,3,1 WKBKSZ = 6xRCDLTH,
volume is mounted. The operator checking requested, three
must not use a volume designation for keys, one file
LUN. The LUN parameter assures
C,A,1,1,C,A,8,l,C,A,9,2, Ascending order, keys start
at positions I, 8, and 9

D,NEWORDSI1,53,318,O,E, =
RECLTH 53, BLKSIZ
=6x53, no records skipped,
sort all records

D,SNEWORDI1,l,318, Output on SYSVOL (FM


OLKSIZ is defined as in the INFILE statement. LUNI) BLKSIZ = 6xRECLTH

(-9
961681100'
TRACE UTILITY (TRACER) J

The RPG II Trace feature is provided to assist the analyst in At run time the trace must be enabled by first execut ing tile I.
locating programming errors and system problems. It is userl TRACER program and then entering one of the follO'.."ing .
primarily during RPG II application program development. options:
It is not intended as a training aid. There are three types of
trace: ITOS/Terminal Mode

• Trace compiler interpreter o No trace, turn off E option D


ft Trace compiler object code generation Trace at terminal

" Trace object code execution (run time) 2 Full trace at terminal

The trace feature requires that a special control 3 Full trace on printer
specification be included immediately after the
H-specification control card when the RPG II source E Halt on any error condition
program is compiled:
S3 3segment multiuser mode for RPG II
Column 6

Column 8
X

I if object code execution trace required;


S5 5segment multiuser mode for RPG II I
blank if not required. The previous option is assumed (initially zero) unless the
trace utility is called, which allows the option to be entered
Column 10-13 Source statement number (with leading as above. Either the terminal or the printer may be
zeros); starts compiler interpreter trace, specified. The full trace includes output of a mnemonic for
blank if not required each of the calculation section operations actually executed.

Columns 20-23 Source statement number (with leading Indicators are printed wherever a change in status of the
zeros); starts compiler object code indica tor occurs (full trace only). Messages indicate the
genera tion trace, blank if not required start of each portion of the RPG II execution cycle. There
is no trace output during the OPEN or CLOSE RPG II
Column 27-72 Program identification (optional; not used segments.
by trace)
When trace option 1, 2, or 3 is selected, the system will halt
The most common form is for execution time trace only: (enter a tight loop) in SYSMSG if an RPG runtime error
column 6 = X, column 8 = 1, and all other columns are blank. message is reported. This enables the user to request a
Specifying execution time trace adds about 800 words to the dump of main memory. To exit from the halt state (loop),
program main memory size. the user must use the control panel to set the A-register to
zero.

NOTE When trace option E is selected, the system will halt (enter
a tight loop) if any error m,essage is reported from any area
The program must be recompiled and of ITOS (e.g., the utilities, the file manager, RPG II, etc.).
recataloged before execution in normal To exit from the halt state (loop), the user must use the
mode. control panel to set the A-register to zero.

When trace option S3 or S5 is selected, three or five


TRACE OUTPUT FORMAT segment mode of operation (respectively) is initiated. Note
that unless the RPG program to be executed is very large or
The following examples illustrate the trace output format. the operating system has a small user area, the 3-segment
Actual output on a user system may differ slightly. mode of operation is most efficient.

The following example sho~s a typical run time trace


COMPI LER RUN-TIME TRACE output.

This mode is selected if column 8 = 1 on the X specification. Trace Output Normal Output Comments
This mode causes the trace support routine to be included
when the program is cataloged. There is no special output ON IP LO Start of trace
at compile time, but a program cannot be traced at run time DETAIL OUTPUT output, indicators
unless it was compiled with this option selected on the X PRINT RECORD ON IPLOareON
control statement.

96768710 C J-l
Trace Output Normal Output Comments PC - Program counter - if changed hy more than one

-------------------- -----------------page eject--------------- RL - Roll position - contents of roll

TEST AND-LR Header output PF - Program flag - true or false


OFF 1P
INPUT RECORD FROM IN Input from primary BP - Source statement pointer - column number
SELECT RECORD FROM IN file. Indica tor 01 (decimal)
ON 01 (record 10) ON
GET INPUT FIELDS OP - Old pointer - program counter
DETAIL CALCULATION
ADD Values are in hexadecimal (except BP).
ADD operation
CaMP
CaMP - no change
SETON An example of a compiler interpreter trace is shown ill
in indicators
ON 70 figure J1.
SETON 70 set ON
EXCPT
EXePT operation
PRINT RECORD ON OUT
led
EXCPT-01 Exception output COMPI LER OBJECT CODE GENERATION TRACE
DETAIL OUTPUT
PRINT RECORD ON OUT This mode occurs when a source statement line numher is
DETAIL-01 Detail output. entered in columns 20 through 23 of the X specific!1tion. <\
Indica tor 01 line of output is printed for each compiler ohject output
(record ID) OFF operation.

OFF 01
RBD Value
INPUT RECORD FROM IN
SELECT RECORD FROM IN
For output of an RBD value, the first field printed is the
ON 01
object program counter. The second field printed is the
'fOTAL CALCULATION
value output.
TOTAL OUTPUT
PRINT RECORD ON OUT
A denotes an absolute value
TOTAL 01 Total output
R denotes a program relocatable value
GET INPUT FIELDS
DETAIL CALCULATION
B denotes output of the lower byte (bit 0-7)
ADD
COMP
ON 77 Indicator 77 set
B* denotes output of the high byte (bits 15-8)
SETON ON by CaMP
ON LR Indicator LR set * denotes a new origin
SETON ON
SETON - no PC= Program counter in the specified compiler overlay
EXCPT
PRINT RECORD ON OUT change
EXCPT-01 Exception output ENT
DETAIL OUTPUT
For output of an ENT, the first field is the entry point name
PRINT RECORD ON OUT
followed by the second field, which is the defined value
DETAIL-01 Detail output (address).
OFF 01
ON L1 L2 L3 L4 L5 L6 L7 L8 L9 LR caused L1
EXT Reference
TOTAL CALCULATION through L9 to
SETON turn ON
For output of an EXT reference (with an ADC), the first
ON 72 Indicator 72 set
field is the object program counter followed by the second
EXCPT ON at total
field, which is the external name.
TOTAL OUTPUT time
PRINT RECORD ON OUT
TOTAL LR Total output NAM

For output of an NAM, the following is printed:


CaMPI LER I NTERPRETER TRACE
******* SEGMENT NO ***
This mode occurs when a source statement line number is An example of object code generation is shown in figure J-2.
entered in columns 10 through 13 of the X specification.
This mode generates a large amount of printout even though
a line is printed only when one of the following changes:

I J-2 96768710 C
Output Comments
RPG U COMPILER Normal heading and list output
0001 H Source line 1
OOO~ FREAD IPE F 80 80 READER Source line 2
0003 FPRINT 0 F 132 PRINTER Trace begins at line 0003
PC=0194 F RL=3-0008 PF=T BP=OO06 OP=8BCO Interpreter is at 0194 in F-overlay
PC=0196 F RL=4-0000 PF=F Roll position 4 loaded with 0000
PC=0198 F PF=T Program flag changed to TRUE
PC=019B F BP=0007 Source pointer moved to column 7
PC=019C F PF=F
PC=0IA3 F PF=T
PC=0IA5 F RL=5-0000 PF=F Roll-5 loaded with 0000
PC=0IA7 F RL=6-0008 Roll-6 loaded with 0008
PC=0IA8 F RL=5-0000 Roll-6 was unloaded
PC=OIAB F BP=0008 Source pointer moved to column 8
PC=0IA8 F OP=OIAC
PC=OIAB F BP=OO09 Interpreter jumper to OlAB from OlAC
PC=OIA8 F OP=OIAC
PC=OlAB F BP=0010
PC=01A8 F OP=OlAC
PC=OIAB F BP=OOll
PC=01A8 F OP=OIAC
PC=OIAB F BP=OOI2
PC=01A8 F OP=OIAC
PC=OlAB F BP=OOI3
PC=0IA8 F OP=OIAC
PC=OlAB F BP=OOI4
PC=01A8 F OP=OlAC
PC=OlAB F BP=OOI5
PC=OIAC F PF=T End of interpreter loop for columns
PC=OlAE F BP=0007 8 through 15
PC=OlAF F PF=F

Figure J-l. Compiler Interpreter Trace

Output Comments

RPG II COMPILER Normal list output

0001 H S
0002 FINPUT IPE F 80
****** SEGMENT 0 *** PC=018F H Start of object output
R9BASE-- 0000 R PC=0190 H Entry point R9BASE and R9RPGX are at location 0000
R9RPGX--0000 R PC=0191 H
0000 1400 A PC=0194 H Absolute values of 1400 and 0000 were output for locations
0001 0000 A PC=0197 H 0000 and 0001
0002 =R9RPRT PC=0199 H Location 0002 will contain address of R9RPRT which is an
R90NES-- 0003 R PC=0IA3 H external reference. At this point program counter is at
0003 OOFI A PC=0IA4 H location 01A3-01A4 in compiler H overlay.
R9COMA--0004 R PC=0IA3 H
0004 006B A PC=0IA4 H
R9PERD-- 0005 R PC=0IA3 H Entry point (R9PERD) is at location 0005
0005 004B A PC=0IA4 H Location 0005 contains value 004B
R9DOLR-- 0006 R PC=0IA3 H
0006 005B A PC=0IA4 H
R9ZERO-- 0007 R PC=0IA3 H
0007 OOFO A PC=0IA4 H
R9STAR-- 0008 R PC=0IA3 H
0008 005C A PC=0IA4 H

Figure J-2. Object Code Generation

96768710 B J-3 •
INDEX

"' '

Access modes 5-4 Catalog utility E-36; 1-3


Access, sequential 5-5 error messages E-36
ADD operation 9-5 Causing character to be considered equal 4-2; 11-1
ADD a record, form 0 10-2 CHAIN operation 9-15
Adding record to files 5-9; 9-15; 10-1; 13-11 (see also direct file; random processing)
Additional input/output area 4-3; 5-8 Chained file 5-2; 9-15
ADOROUT files 5-2 Changing contents of tables and arrays 5-2
file processing 5-7; 13-11 Characters
sorting 5-9 ASCII 0-10
Alphanumeric EBCDIC 0-7
fields 9-18 Codes
literals 9-4 EBCDIC 0-7
Alternate collating sequence 2-1; 4-2; 11-2 edit 10-8; 0-8
Alternate tables or arrays 6-2,5 operation D-1
ALTSEQ (see alternate collating sequence) record identification 8-6
I Ampersand (&), use in edit word 10-11 Collating sequence 4-2; D-7
AN/OR relationships, form C 9-3 alternate 2-1
AND/OR relationships 8-7 Combined files 5-1
form I 8-3,13 Comments
form 0 10-2 form C 9-19
stacker select form E 6-6
input 8-7 on table input record 11-2
output 10-3 use of asterisk (*) 3-1
Apostrophe (') usage, form 0 10-10 Common entries on specifications sheets 3-1
Arithmetic operations, form C 9-4 COMP operation 9-8
Array files 5-2; 12-2 Compare and testing operations 9-8
Array index 9-11; 12-1 Compilation
Array name 6"-2; 12-9 error messages (diagnostic messages) E-1
Arrays (see tables) of source program 1-1
Arrays, alternate 6-2 Compilation time tables and arrays 2-1
Arrays and tables in· programming 12-1 Compiler B-1
ASCn 5-4,9; 0-12 Compiler program 1-1
Asterisk (*), comment line 3-1 Conditioning files (form F) 5-11
Asterisk fill 10-10,11 Consecutive access 5-6
Consecutive file processing 5-6
Constant, form 0 10-10
Batch mode operation 1-1 (see also literal)
BEGSR operation 9-13 Continuation lines 5-9
Binary format 6-5 Control break
(see also packed or binary fields) definition and general description 1-2; 8-9
Binary punch utility 1-5 unwanted 8-10
Binary relative record number 5-2,7; 13-11 Control card specifications, form H 4-1
(see also ADDROUT files) Control fields 1-2; 8-9
Bit operations 9-9 Control group 1-2; 8-9
BITOF 9-9 (see also control fields; control level)
BITON 9-9 Control level 1-1
TESTB 9-9 form C 9-2
Blank after 10-10 form I 8-9
Block length 5-4 Control level indicator 1-2
Block prefix 5-9 form C 9-2
Branching operations 9-10 form I 8-9
Buffer offset length 5-4,9 form 0 10-6
Buffering, double 5-8 with subroutines 9-2
Conversion of fields
input fields 4-3; 6-4
C/Z/D (character/zone/digit) 8-6 tables and arrays 6-4
Calculation specifications, form C 9-1 CR (negative balance symbol) 10-10
error messages E-19

96768710 B Index-1
Creating a direct file (see direct file) End-of-file
Cycle (see also multifile processing)
detailed object program logic F-1 delimiter. (alternate collating sequence) 11-2
general object program logic 1-1 form F 5-3
with FORCE operation 9-14
ENDSR operation 9-13
Data formats (see packed or binary fields) End position in output record, form 0 10-10
Date field 9-4; 10-8,10 Entry (table or array)
DEBUG length of entry 6-4 .
operation 9-16 number of entries per record 6-2
specifications 4-2 number of entries per table or array 6-3
Decimal positions Error messages E-1
form C 9-18 calculation specifications E-19
form E 6-5 catalog utility E-36
form I 8-8 compile time E-28
with move remainder operation (MVR) 9-6 control card specifications E':'l
with square root operation (SQR T) 9-6 data manager E-30
Decimal data format disk file utility E-31
(see also packed or binary fields) extension specification E-8
packed 6-4 magnetic tape utility E-32
unpacked 6-4 mount utility E-36
Demand file 5-3; 9-15 output specifications E-25
(see also READ operation) RBDPCH utility E-36
Detail lines, form 0 10-2 run-time E-29
Detail operations 1-2; 9-1; 10-2 switch utility E-36
Detail time 9-1; F-1 Error recovery sequences B-1
Device code 5-9; D-12 Exception records, form 0 10-2
Diagnostic messages, RPG II compiler E-1 EXCPT operation code 9-14
Digit overflow printing with EXCPT 10-3
C/Z/D 8-6 Execution
character grouping by digit (table) D-11 halts 4-3; 6-5; 8-2,6,10,14; 9-6,12,15; B-1
Direct file ITOS environment 4-3
adding records 5-9; 13:"'11 object program 1-1
creating (loading) 9-15; 13-11 Execution time tables and arrays 6-1
organization 13-11 EXIT operation 9-13
processing 5-5; 13-11 EXITF operation 9-13
synonym records· 9-16 EXSR operation 9-13
Disk file Extension code, form F 5-8
(see also direct file; indexed file; sequential file) Extension specifications, form E 6-1
block length for 5-4 Extents, number of 5-10
• utility E-31 External character (file translation) 11-1
error messages E-31 External indicators (U1-U8) 5-11; 9-10,15
.Display file 5-2 External file condition 5-11
DIV operation 9-6 External subroutines
Dollar sign ($) definition 9-13
fixed 10-10 use of G-1
floating 10-11
Domestic format 4-2; 10-8
Double buffering 5-8 Factor 1 9-3
DSPLYoperation 9-14 Factor 2 9-3
Dual input/output areas Fetch overflow
form F 5-8 general information 10-3
stacker select with 8-7 form 0 entry 10-2
Duplicate (synonym) records 9-16 Field
alphanumeric 9-18
binary 6-5
EBCDIC characters 5-4; D-7,8,9 control 1-2; 8-9
Edit code key 5-8
effect on inverted print 4-2 length (see field length)
effect on end position 10-10 look-ahead (see look-ahead fields)
form 0 10-8 matching 8-10
summary tables 10-8,9; D-6 numeric (see packed or binary fields)
with arrays 10-9; 12-10 packed 6-4
with edit words 10-10 result 9-17
zero balances 10-9 unpacked 6-4
Edit words 10-10 zeroing 10-10

Index-2 96768710 B
Field indicators 8-14 Forms positioning, 1P 4-3
Field length 5,..7; 6-4; 8-8; 9-18 Forms, specifications 2-1
Field location, form I 8-8 From filename, form E 6-2
Field name 1-2 Full table or array 12-1
form I 8-8 Function of RPG II 1-1
form.. 0 10-6
special word entries 8-8; 10-6
Field record relation 8-13 General object program logic 1-1
File GOTO operation 9-10,13
(see also end of file; multifile processing) Grouping characters by zone and digit (tables) 0-8,9
addition 5-9
ADOROUT 5-2
chained 5-2 Half adjust, form C 9-18
combined 5-1 Halt indicators (H1-H9) 9-10,19
demand 5-3; 9-15 Halt recovery procedures B-1
description specifications, form F 5-1 Header card (control card) 3-1; 4-1
designation, form F 5-2 Header record (spread cards) 8-4
direct (see direct file) Heading lines, form 0 10-2
display 5-2 . Hexadecimal equivalents of characters (table) D-7
indexed (see indexed file) Hold area, table 6-4; 9-11
input 5-1
output 5-1
primary 5-2; 13-1 Identification
record address 5-2; 13-1 of programs 3-2
secondary 5-2; 13-1 of record types 8-6
sequential (see sequential file) Index, array (see array index)
table or arrays 5-2; 12-2 Indexed file
update 5-1 addition of records 5-9; 10-2; 13-11
. File addition AOOROUT processing 5-1; 13-11
differences between direct, sequential, and indexed 5-9 general information 13-10
form F 5-9 key 5-6; 9-15
form 0 10-2 loading 13-10
File condition 5-11 random processing 13-10,11
(see also external indicators) sequential by key processing 5-6; 13-10
File description specifications, form F 5-1 sequential by limits processing 5-6; 13-11
File designation, form F 5-2 unordered loading 5-9; 13-10
File devices 5-9; 0-12 Indicator operations 9-10
File format, form F 5-4 Indicators 1-2
Filenames 1-2 form C 9-2,3,18
form C 9-4 form 0 10"':2,5
form F 5-1 referencing in EXIT and RLABL operations G-1
form I 8-2 setting (SETON; SETOF) 9-10
form L 1';"1 summary tables D-3,5
form 0 10-1 Input/output (I/O) area, additional, form F 5-8
from, form E 6-2 Input/output, program control of 9-14
to, form E 6-2 Input file 5-1 .
File organization, form F 5-8 Input specifications form I 8-1
File processing (see processing methods) Internal character (file translation) 11-1
File translation 11-1 Internal code specification 4-3
form H 4-3 Inverted print, form H 4-2
File type, form F 5-1
First page UP) indicator 1-2; 9-10; 10-2
form H 4-3 Key 5-6
form 0 10-6 (see also indexed files)
Fixed dollar sign 10-10 limits (see also record address files) 5-2
Floating dollar sign 10-11 random processing by 9-15; 13-1
Flowchart, RPG II program logic sequential processing by (indexed file) 5-6; 13-1
detailed F-1 Key field
general 1-3 definition 5-8
FORCE operation 8-13; 9-14 length of, form F 5-1
Foreign format 4-2; 10-8 starting location, form F 5-8
Form length, form L 1-1
Form type 3-1
Forms control space/skip, form 0 10-3 Label exit, name of 5-9
Forms, other input 11-1 Labels, form C 9-4

96168110 A Index-3
Last record (LR) indicator 1-2 Multifile processing 1-2; 5-2; 13-1
Leading zero suppression 4-2 (see also end of file; matching record indicator)
Length of with FORCE operation 8-13
array name 6-2; 12-9 match fields 8-10; 13-1
block, form F 5-4 no match fields 13-2
entry, form E 6-4 normal selection 1-2; 13-1
field with alternate collating sequence 4-2; 11-3
arithmetic operations 9-4,6 with field record relation 8-13
compare operations 9-8 Multiple input file processing 1-2; -13-1
move operations 9-6 (see also multifile processing)
form (number of lines per page), form L 7-1 Multiple input/output areas 5-8
key field, form F 5-7 Multivolume files (see number of extents)
record, form F 5-4 MVR operation 9-6
record address field, form F 5-7
result field, form C 9-18
Level zero (LO) indicator 9-2,10 N (not) 8-6
Line counter specifications, form L 7-1 Name of table or array 6-2
Line number Names; date field 9-4
coding lines 3-1 Name of label exit, form F 5-9
number of lines per page, form L 7-1 Negative balance 10-9
overflow, form L 7-1 Negative numbers 6-4; 9-8; 10-6
Linkage to external subroutines G-1 (see also packed or binary field)
Literals, numeric and alphameric 9-3 Negative square root halt 9-6
Load module B-1 Normal collating sequence 4-2; 11-2; D-9
Loading Number, form I 8-2
direct files 5-2; 9-15 Number of
indexed files 13-17 entries per record, form E 6-2
unordered load 5-9 entries per table or array, form E 6-3
Location of field, forin I 8-8 extents, form F 4-3; 5-10
Logic of RPG II object program Numbering lines on coding sheets 3-1
detailed F-1 Numbering report pages 8-8; 10-6
general 1-1 Numeric literals 9-3
LOKUP operation 9-10
resulting indicators with 9-10
with an array 9-11 OA-OG and OV (overflow) indicators 5-8
with one table 9-11 Object program
with two tables ,9-11 execution 1-1
Look-ahead fields 1-1; 10-10; 13-2 identification 3-2
form I 8-3,4 logic
Lr (last record) indicator 1-2; 9-2,10,18 detailed F-1
LO (zero level) indicator 9-2,10 general 1-1
L1-L9 (control level) indicators 9-2,10 Offset length, buffer, form F 5-9
Operation, form C 9-4
Operation codes D-1
Magnetic tape files arithmetic 9-4
block length for 5-4 bit operations 9-9
continuation records 5-9 branching operations 9-10
rewind 5-10 codes B-1
utility 1-1 compare and testing operations 9-8
Matching fields 8-10; 13-1 debug operation 9-16
(see also multifile processing) lookup operation 9-10
Matching level identifier (M1-M9) 8-10 move operations 9-6
Matching record (MR) indicator 1-2; 8-13; 9-10; 13-2 move zone operations 9-8
Messages, RPG II compiler error E-1 programmed control of input and output 9-14
MHHZO operation 9-8 setting indicators 9-10
MHLZO operation 9-8 subroutine operations 9-13
MLHZO operation 9-8 Operation of RPG II B-1
MLLZO operation 9-8 Option, form I 8-3
Mode of processing, form F 5-4 OR relationship
I MOUNT utility error messages E-35 form C 9-3
MOVE operation 9-6 form I 8-7
MOVEA operation 9-7 form 0 10-2
MOVEL operation 9-7 stacker selection 8-7; 10-3
Move zone operations 9-8
MULT operation 9-6

Index-4 96768710 B
Output Random processing
detail 10-2 by ADDROUT file 5-7; 13-11
exception 10-2 by CHAIN operation code 9-15; 1-3-11
heading 10-2 by key 9-15
table and array 6-2 by relative record number 5-7; 9-15
total 10-2 RBDPCH utility error messages E-36
Output fields 10-6 Read area 8-3; 13-1
repeating (*PLACE) 10-7 READ operation 9-15
Output file (see also demand files)
form F 5-1 Record addition (see adding records to files)
table or array 6-2 Record address file
Output indicators. form 0 10-5 (see also AOOROUT file)
Output specifications. form 0 10-1 definition 5-2
error messages E-24 extension cOde. form F 5-8
Overflow field. form F 5-7
area ·5-8· , format of records 5-6
automatic 7-1; 10-3 processing sequential within limits 5-6; 13-1
fetch 10-3 record address type. form F 5-7
line. form L 7-1 Record address type. form F 5-7
printing (with EXCPToperation) 10-3.6 Record definition lines. form 0 10-1
spacing and skipping 10-5 Record identification character. form I 8-7
steps done after overflow 7-1 Record identification codes. form I 8-6
Overflow indicator. form F 5-8 Record identifying indicator 8-3
(see also overflow) Record length 5-4
Record matching (see multifile processing)
Reference tables D-1
Packed decimal format 6-4 Related tables and arrays 12-1
(see also packed or binary fields) Relative record number 5-7; 13-11
Packed or binary fields (see also CHAIN operation)
form E 6-4 binary 5-2; 13-11
form I 8-7 random processing by 5-7; 9-15
form 0 10-10 Remainder 9-6
PAGE. PAGEl. PAGE2 8-8; 9-4; 10-6 Replaceable characters 10-11
Page numbering 3-1; 8-8; 10-6 Report generation problem H-1
Position. form I 8-6 Result field. form C 9-17
Positioning printer forms 4-3 Resulting indicators. form C 9-8.10.15.18
Pre-execution time tables and arrays 12-4 Rewind. tape 5-10
Primary file, form F . 5-2 RLABL operation 9-14; G-l
(see also matching fields) Rounding numbers in result field (half adjust) 9-18
Printable characters 0-9 RPG II cycle 1-1
Process area 8-3; 13-3 flowchart F-1
Processing methods RPG II names 1-2
consecutive 5-6 RPGOBJ 3-2
direct file load 9-15; 13-11 Run-time error messages E-29
multifile (see multifile processing)
random by ADOROUT file 5-7; 13-11
random by key 9-15 Secondary files 5-2
random by relative record number 5-7; 9-15 Selecting a stacker
sequential by key 5-6 form I 8-7
sequential within limits 5-6 form 0 10-2
single input file 1-1 Sequence
Program collating (see collating sequence)
compilation 1-1 error 3-1; 6-5; 8-2. 10
cycle 1-3; F-1 form E 6-5
identification, form H 3-2 form F 5-3
indicators (summary table) 0;"4 form I 8-2
object "1-1 record type 8-2
sample H-l Sequence group 8-2
source 1-1; 2-1; 11-1 Sequential access 5-5
Program logic Sequential file
detailed" F-1 addition to 5-9
general 1-1 organization 13-1
Programmed control of input and output 9-14 processing 13-1
Punctuation in output field 10-1.8 Sequential processing by key 5-6

96768710 A Index-5
Sequential processing within limits 5-6 sequence 6-5; 12-5
SETLL operation 9-16 short table 12-1
SETOF operation 9-10 TAG operation 9-10
SETON operation 9-10 Tape (see magnetic tape)
Sequence number 3-1 Tape continuation record 5-9
Setting indicators (operations) 9-10 Tape mount utility 1-2
Shared 1/0, form H 4-3 Tape records, block length 5-4
additional I/O area 4-3; 5-8 ,Tape rewind, form F 5-10
Short table or array 6-3; 12-1 TESTB operation 9-9 '
Sign Testing results of calculations (see resulting indicators)
binary format 6-5 TESTZ operation 9-9
packed decimal format 6-4 TIME operation 9-17
unpacked decimal format 6-4 To filename, form E 6-2
Single input file processing 1-1 Total operations 1-2
Skip forms control 10-5 Total output records 10-2
Sort utility 1-5 Total time 9-2; F-1
Source deck arrangement 7-2; 12-4 TR (spread cards) 8-3
Space forms control 10-5
SPECIAL (device entry) 5-9; D-14
TRACER J-1
Trailer records 8-4 •
Special words 9-4 Translation, file 2-1; 11-1
Specifications forms 2-1 Type,formO 10-2
Specifications out of sequence 3-1
Split control fields 8-9
Spread cards UDATE special word 9-4; 10-8
processing 8-4 inverted print format 4-2
specifications 8-3 UDAY special word 9-4; 10-8
SQRT operation 9-6 UMONTH special word 9-4; 10-8
SR entry on form C 9-2 United Kingdom format 4-2; 10-8
Stacker select Unordered load (indexed file) 5-9
form I 8-7 .Unpacked decimal format 6-4
form 0 10-2 Update file (file type entry) 5-1
SUB operation 9-5
Subroutines 9-13; G-1
Summary of RPG II specifications C-1
'UYEAR special word 9-4; 10-8
U1-U8 indicators (see external indicators) •
Suppression of leading zero 10-6
(see also zero balance) Valid RPG n names 1-2
Switch utility 1-4 Volume of a file 5-10
Synonym record 9-16
XFOOT operation 9-6
Tables
(see also LOKUP operation)
adding entries to a short table 12-8 Z (zone) (see record identification codes)
compilation time 12-1 Z-ADD operation 9-5
decimal positions 6-4 Z-SUB operation 9-5
definitions of terms 12-1 Zero balance '
differences between tables and arrays 12-1 effect of edit codes 10-8, 10
execution time 12-1 effect of inverted print 4-2
extension specifications 6-1 Zero suppression 10-10
file 5-2; 12-2 Zeroing fields, blank after 10-6, 10
file designation entry, form F 5-2 Zone
full table 12-1 character grouping by equal zone D-8
length of entry 6-4 move zone operations 9-8
LOKUP operation 9-10; 12-6 test zone operations 9-9
modifying the contents 12-6
naming' 6-2
number' of entries per table 6-3
output 12-4,10
packed or binary format 6-4; 12-5
pre-execution time 12-1
related 12-1
searching (see LOKUP operation)

Index-6 96768710 B
COMMENT SHEET

ftfANUAL TITLE CDC® RPG II Version 2 Reference Manyal

6~7.;;;..68.;...7.;...;;1;;.;;O~_ _ _ _ _ _ _ _ REVISION
PUBLICATION NO. ___9.... _...;;.C_ _ _ _ _ _ _ _ _ _ _ __

NAME: _____________________________________________________________________
FROM

BUSINESS
ADDRESS: ____________________________________________________________________

COMMENTS: This form Is not intended to be used as an order blank. Your evaluation of this manual will be welcomed·
by Control Data Corporation. Any errors, suggested additions or deletions, or general comments may
be made below. Please include page number.
STAPLE STAPLE I

FOLD
-----------J
FiRST CLASS
PER~~ITNO. 3'33

LA JOLLA CA.
BUSINESS REPLY MAIL
NO POSTAGE STAMP NECESSARY IF MAiLED !N U.S.A.

POSTAGE WILL BE PAID BY

CONTROL DATA CORPORATION


. PUBLICATIONS AND GRAPHICS DIVISION
4455 EASTGATE 1'v1ALL
LA JOLLA, CALIFORNIA 92037

---------------~
FOLD

STAPLE
STAPLE
CORPORATE HEADQUARTERS, P.O. BOX 0, MINNEAPOLIS, MINNESOTA 55440 LITHO IN U.S.A.
SALES OFFICES AND SERVICE CENTERS IN MAJOR CITIES THROUGHOUT THE WORLD

<S~
CONTI\OL DATA CO~OR(\TION

You might also like