Text preview for : GC21-7514-2_IntroductionToRPGII_ReportWriting_Jul78.pdf part of IBM GC21-7514-2 IntroductionToRPGII ReportWriting Jul78 IBM system3 GC21-7514-2_IntroductionToRPGII_ReportWriting_Jul78.pdf



Back to : GC21-7514-2_IntroductionT | Home

GC21-7514-2
File No. 53-28




Introduction RPG t l
to
Systems ReportWriting
Third Edition (July 1978)


T h i s r s ;a m a j o r r e v i s i o n o f , a n d o b s o l e t e s , G c 2 1 - 7 s 1 4 - 1 . M a j o r c h a n g e s i n c l u d e
using the latest level specification forms and updating the terminology.

Changr;s are periodically made to the information herein; before using this
publication in connection with the operation of IBM systems, be sure you have
the latest edition and any technical newsletters.

This publication contains examples of data and reports used in daily business
operalions. To illustrate them as completely as possible, the examples include
names;of individuals, companies, brands, and products. All of these names are
fictitious and any similarity to the names and addresses used by an actual
b u s i n e r s se n t e r p r i s e i s e n t i r e l y c o i n c i d e n t a l . U s e t h i s p u b l i c a t i o n o n l y f o r t h e
purpose stated in the Preface.

Publications are not stocked at the address below. Requests for copies of IBM
p u b l i c i a t i o n sa n d t e c h n i c a l i n f o r m a t i o n a b o u t t h e s y s t e m s s h o u l d b e m a d e t o v o u r
local ltsM representative or to the branch office serving your locality.

This publication could contain technical inaccuracies or typographical errors. Use
the Reader's Comment Form at the back of this publication to make commenrs
about this publication. lf the form has been removed, address vour comments to
IBM Corporation, Publications, Department 245, Rochester, Minnesota 5bg01.
IBM may use and distribute any of the information you supply in any way it
believes appropriate without incurring any obligation whatever. you may, of
course, continue to use the the information you suppty.




O CopryrightInternational Business Machines Corporation 1971. 1g7B
Preface



This book is intendedfor personswho want to learnto The second chapter describesthe RPG ll program cycre
write programswhich will produce printed reports using and the RPG ll specifications you must write to do a
the RPG ll language.The book is designedto be used particulartask. The materialin this chapteris arrangeo
by a personwith no previousknowledgeof computers to providea gradualdevelopment concepts,
of
and prrogramming, by a personwho alreadyknows a
or proceeding from the simple to the more complex. Thus,
programminglanguagebut wants to learn about report it is importantto read the materialin sequence.Sample
writing in RPG ll. jobs are used to illustratethe conceptspresented.

After readingthis book, you should not expect to be The third chapter explainsan RPG ll programmer's job
able to write complex RPG ll programs. You will be more fully. lt shows, by means of a samplejob, the
introcluced only a small part of RPG ll. Many
to things a programmermust do from the start of a job to
impoftantfeaturesin RPG ll are not discussedin this its completion.
manual. The RPG ll referencemanualfor your system
containsall of the informationabout RPG ll featureson
your system. You should have gained enough RpG ll Coding Forms
backgroundknowledgeso that you can readilyrearn
more detailedinformation-either from reference Followingis a list of forms used to code and debug
manuals,classes,or IBM personnel-which required
is RPG ll programs. Contactyour local IBM branch office
for writing programsfor your system. to order anv of these materials:

. RPG Control and File Description Specifications,
How This Manual ls Organized G X 2 1- 9 0 9 2

The first chapterdescribes, generalterms, how a
in . RPG Input Specifications,
GX21-9094
system operatesand the things you must do to run a
particular job. The informationpresentedshould answer . BPG Calculation GX21-9093
Specifications,
such questions s:
a
. RPG Output Specifications,
GX21-9090
. Wlhat are the parts of a data processingsystem?
. R P GI n d i c a t o r u m m a r y , X 2 1 - 9 0 9 5
S G
. Wlrat is a program?
. R P GD e b u g g i n g e m p l a t e G X 2 1 - 9 1 2 9
T ,
. W l h a ti s a p r o g r a m m i n ga n g u a g e ?
l
. PrinterSpacing Chart,X2O-1776
. W h a t i s a n R P Gl l p r o g r a m ?
. Record Lavout Form. X21-9088
. How is an RPG ll program run on a system?
. D i s k F i l e L a y o u tC h a r t ,G X 2 1 - 9 1 0 8

. P r i n t e r / D i s p l a L a y o u t ,G X 2 1- 9 1 7 4
y
Contents




CHAPTEII 1. BASIC DATA PROCESSINGAND RPG ll Specifications 57
PROGR/\IVI I NG CONCEPTS
M 1 Using the Blank-AfterSpecification 59
Parts of a Data ProcessingSystem I
Job 3 (TRNREG):Using Control LevelIndrcators
to
'l 60
lnput Devices Calculateand Print Totals
Output Devices 1 Job Definition 60
ProcessingUnit 1 Job Reouirements 61
Prc,grams and ProgrammingLanguages 3 Job Specifications bz
Sourcer Programs 3 First Page Indicator 64
Sourcer Programsto Obiect Programs 5 Program Cycle Operations 65
Summary 6 RPG ll Specifications 66
DataProcessing Termsand ProgrammingAids 7 Overflow Indicators 68
Program Cycle Operations 70
CHAPTEIR RPG II PROGRAMMING LANGUAGE .
2. 11 RPG ll Specifications
R P G I I P F I O G R A MC Y C L E 1 1 Using Spacing with Overflow 72
W I I I T I N GS P E C I F I C A T I O N S R I N P U TA N D
FO Using Overflow and 1P Indicators Together 74
O U T P U TO P E R A T I O N S 14 Last Record (LR) Indicator 74
Program Cycle Operations 14 Program Cycle Operations 75
Describing the Files It) RPG ll Specifications 76
File Names 17 Job 4 (TRNREG): Using First Page, Overflow, and
Device Designation 18 Last Record Indicators to Print
File Use 18 Headings and Totals 77
File Dresignation 18 Job Definition 77
Recorrl Size 19 Job Requirements 77
De,scribingInput Records 20 Job Specifications 79
File Names 21 Record ldentifying Indicators 81
Field lVames 22 Program Cycle Operations 82
Field l-ocation 24 RPG ll Specifications 83
Type rcf Data 24 Specifying Record ldentification Codes 85
DescribingOutput Records 25 Specifying Record ldentifying Indicators B6
File Names 26 Specifying Record TyPe Sequence 87
Recor,d Type 27 Job 5 (STOKST): Using Record ldentifying Indicators
Field lltlames 29 to Process Different Record TYPes B9
Field lLocation 29 Job Definition 89
Printed Fleports 30 Job Requirements B9
Spacing 30 Job Specifications 92
Skipping 31 ResultingIndicators 96
Editin$ 33 Program Cycle OPerations 96
Jo'b 1 (TRNREG):Printinga Simple Report Usingthe RPG ll Specifications 9B
f'hree Basic Cycle Operations 36 Using the CompareOperation 99
Job Clefinition 36 Using an ArithmeticOPeration r02
Job Flequirements 37 Job 6 (STOKST):Using Resulting lndicatorsto
'105
Job Sipecifications 38 Test Contents of Result Fields
W R I T I N GS P E C I F I C A T I O N S R
FO Job Definition 105
CALCU |.A'TION OPERATIONS 40 Job Requirements . 105
Program Cycle Operations 40 Job Specifications . 108
42 Field lndicators 11i
Describing fype of Operation
Describing Data to be Used 42 ProgramCycle Operations 111
45 RPG ll Soecifications 112
Describingthe Result Field
Result Field Length 47 Job 7 (AGETB): Using Field Indicators to
Decirral Positions 47 Test Contents of InPut Fields 114
H a l f - l \ d j r . r s t i n g e s u l t s( R o u n d i n g )
R 47 Job Definition 114
49 Job Requirements 114
Job 2 (TRNREG): Doing Simple Calculalions
Job Definition 49 Job Specifications 116
Job llequirements 50 Conditioning Operations by More Than
'18
51 One Indicator 1
Job tipecifications
WRITIN,GSPECIFICATIONSO R I N D I C A T O R S
F 53
Control Level Indicators 54
Program Cycle Operations 56


Contents v
C H A P T E R3 . T H E P R O G R A M M E R ' S O B
J 121
Deterrnining Job Requirements
the 122
Deterrnine RPG ll Specifications Neededfor the Job 12t
WritetheSpecifications ng
Docunnent Program
the 133
Prepare Compilation
for 134
SpecificationsForm Order 134
CorrtrolSpecifications preparation 13S
Checkingrhe Specifications 13S
Compilethe Source Program 137
Test tlre Prol;ram l4O

GLOSSARY 141

INDEX . 145
Chapter 1. Basic Data Processingand Programming Concepts




PARTS OF A DATA PROCESSINGSYSTEM

Data processingsystemsdiffer widely in appearance,usuallyconsistingof
severalconnectedunits. Regardless their size or shape, however,all data
of
processingsystems have common features.

Data processing systems operateelectronically. They are complex machines
with thousandsof circuitsand wires. Fortunately, you do not have to
understand the purposeof each circuit or wire. To write a programwhich will
producea report, all you need to know are the purposesof the main parts of a
data processingsystem: the input devices,the output devices,and the
processingunit.


lnput Devices

Data you give a system to work with is calledinput. The device used for
getting that data into the system is calledan input device. Severalkinds of
input devicesmay be used; among them are card readers,disks, diskettes.
tapes, and keyboards.For the purposesof this manual,specificinput devices
will not be discussed.Informationabout the input devicesapplicable your
to
system is in the RPG ll referencemanualfor your system.



Output Devices

Data producedby a system is calledoutput. The devicethat producesthe
output is calledan output device. Severalkinds of output devicesmay be
used; among them are card punches,disks. diskettes,tapes, printers,and
displayscreens. For the purposesof this manual,specificoutput deviceswill
not be discussed.Informationabout the output devicesapplicable your to
system is in the RPG ll referencemanualfor your system. Becausethis
manualdeals only with report writing in RPG ll, we will refer only to printed
output.



Processing Unit

The main part of a data processing system is the processingunit. The
processingunit can be divided into three sections-storage,
control,and
arithmetic/logic-according the specialfunction each performs.
to




B a s i c D a t a P r o c e s s i n g n d P r o g r a m m i n gC o n c e p t s
a I
Storage


storage is the system's memory area. This area is divided into many storage
positions which the system uses to electronically store infornration. The actual
number of positions in storage depends upon the size of the storage unit.
Each storage position has an identifying number called an address.


A storage address serves the same purpose as a house address. Information is
sent to and received from these locations. The information can be easilv
retrieved using the address where the information is stored.



Arithmetic / Logic


Calculations (such as add, subtract, multiply, and divide) are performed in the
arithmetic/logic unit. When your instructions tell the system to do an operation
such as add, the information to be added is transferred from storage to the
arithmetic/logic unit. The operation is then performed and the result is sent
back to storage.



Control


The control section is the system's decision maker. lt retrieves instructions
from storage, determines what has to be done, and directs other units or
devices to perform the required operations.
P R O G R A M SA N D P R O G R A M M I N G L A N G U A G E S

Data processing systemsdo only what you tell them. When you give a system
instructions, however,it might seem as though the system requiresmore than
you would need to do the same job. But remember.a data processingsystem
cannot think: it requiresexplicitinstructions, even for those things you would
d o a l m o s tw i t h o u t t h i n k i n g .

When you are to do a job yourself,you need three basic things:

lnformationto work with (input).

telling you how to work with (process)
Instructions the information.

describingthe expectedresults(output).
Additionalinstructions

In data processing terms, input is what you put into the system, processingis
what the system does with the input, and output is the result of processing.
Everyjob you run on a system has these three parts. You write instructions to
describewhat you want the system to do with each part. These instructions
are called a program.

To communicate with the system,you must use the system's language, oneor
that can be translatedinto that language.The system's languageis called
machine language. lt consists of letters, numbers, and symbols that, when
properlyarranged,have a specificmeaningto the system and, when
interpretedby the system, cause it to perform a desiredfunction.

Becausemachinelanguageis so very differentfrom our own language, is it
extremelydifficult to use it to write a program. For this reason,programmtng
languages have been created. A programminglanguageallows the programmer
to use familiarwords and svmbolsto write instructions.

The RPG ll programminglanguageis composedof letters,numbers,and
symbolswhich you put togetherto form an instruction(expressa thought).
When creatinginstructions the RPG ll language,
in you must follow certain
rulesjust as you would when constructing sentencein English.You will learn
a
about these rules in the second part of this manual.

The set of instructionsyou write is calleda sourceprogram- This source
program is translatedby a programcalledthe compiler,resultingin a machine
languageprogram calledthe obiect prograrn. lt is the object programthat you
use to do a job. In fact, you can use it over and over to do the same job.



Source Programs

The instructionsyou write for any program must describethe input, processing,
and output requirements the ,ob. For example,one instructionmight direct
of
the system to read an input record,another might specify the adding of two
numbers,and anothermay tell the system to print a line on the printer'
Becauseall jobs are not the same, you providea different set of instructions
(program) each job.
for




B a s i c D a t a P r o c e s s i n g n d P r o g r a m m i n gC o n c e p t s
a 3
To write the instructions,you fill out RpG ll specificationforms (see Figure ,l).
These forms have been speciallydesignedto help you write instructions
accordingto the rules of RPG ll language.The act of writing instructions on
these forms is called cding; the entries you make on the forms are called
specifications.




OUTPUT SPECIFICATIONS

t , t 6 D t a t 9 8 l t I
-l
P,u!,Jr I IT I ll
- , , " , " ' , , 1" , t I i L l i
'
I
RPG CALCULATION SPECIFICATIONS




"- [L],,_ ll:t:Iil" i' ' J" l ^]'i !]
l' '

R P G C O N T R O L A N D F I L E D E S C R I P T I OS P E C I F I C A T I O N S
N




Specifications

H 5
I


_l
a
,5
n|lit ; Ol ftint
I
SelerIo lhe src irc Syil.m Rete.ence
I
6
a L i b r a r y m a n u a lt o r a c r u a le n r r i e s

E !
z
a a
l 0 l 9
I 8
7 A t
I ! ir; a o
t7 58 59 60 31 626f, & 65 S67 68 69 70 )r i2 73
011




F i l e D e s c r i p t i o n S p e c i fi c a t i o n s


tr{il d r.t FI.b a
otiHCttuFLld tu Cdi*Ordl$




Figure l. RPG ll Specificationt Formr



4
To describethe input, processing, and output requirements your job, you
of
supply different informationon each form. For example,you have to describe
what your input data is like and specify the device (such as a disk unit) that
will read it. You also have to describehow the input data is to be processed.
This includesspecifyingwhat type of operations(such as add or subtract)must
be performedupon the data. Finallyyou specify what kind of output you want
(such as a printed report),what informationmust be includedin the output,
and how that informationshould be arranged.

After you have coded the specificationsforms, the next step is to get the
coded informationinto the system. The system cannot read the coded forms,
so you must put the specificationsinto a format that the system can read.
Dependingon your system,you key the specifications onto a diskette,into
punchedcards, or directlyinto the system.



Source Programs to Object Programs

As we said earlier,the system understandsonly machinelanguage. lt cannot
use a coded program (written in a programminglanguagelike RPG ll) directly.
Any programyou write in RPG ll must be translatedinto machinelanguage.
The translatoris a program calleda compiler.The RPG ll Compilerprogram is
a v a i l a b l er o m l B M .
f

The compilertranslates (sourceprogram)into
your RPG ll specifications
machinelanguage (object program).The translatingit does is called
Essentially. compiler performsthree functionsduring
compilation. the
compilation:

It determineswhat machineinstructions are necessary the system to
for
perform the job describedby your RPG ll specifications.

It translates into a machinelanguageprogram.
your RPG ll specifications

It assignsstoragelocationsto program instructionsand data.




B a s i c D a t a P r o c e s s i n g n d P r o g r a m m i n gC o n c e p t s
a 5
Summary

Figure illustrates RpGll data processingconcepts.
2 the




Qj D e t e r m i n e t h e r e q u i r e m e n t so f y o u r j o b .
Define the input and printed output. Also
d e c i d ew h a t p r o c e s s i n g u s t b e d o n e i n
m
order to get the proper results,




(i Writ" the source program by describing your
j o b o n t h e R P G l l s p e c i fi c a t i o n f o r m s .



Figure 2 (Part 1 of 21. Summary of RpG ll Data processingConcepts
Kevboard

O the sourceprogram cards,
on
""t
disk.or diskette.




e T h e s o u r c ep r o g r a m i n p u n c h e d
c a r d s ,d i s k e t t e , o r d i s k i s r e a d
into main storage.




Main Storage

Compiler Program




Compiler program on disk

SourceProgram



@ fftr compiler program, read from
d i s k i n t o m a i n s t o r a g e ,t r a n s l a t e s
t h e s o u r c ep r o g r a m i n t o a n o b j e c t
program.




I Obiect program in
Object program -l punchedcardsor
on disk on diskette.

4\
t 0 , F r o m d i s l , d i s k e t t e , o r c a r d s ,t h e o b -
iect program is read into main storage.
Main Storage

Obiect Program


Input Output
Data files Printedreport




rn" obiect program processesthe
@
d a t a s p e c i f i e db y t h e R P G | | p r o -
g r a m a n d p r o d u c e st h e d e s i r e d r e s u l t .

Figure 2 lPan 2 of 2). Summary of RPG ll Data ProcassingConcepts


B a s i c D a t a P r o c e s s i n g n d P r o g r a m m i n gC o n c e p t s
a
DATA PROCESSING TERMS AND PROGRAMMING AIDS

In the discussion of RpG ll, you wiil find reference to data processrng terms
and programming aids. Figure3 describessome basic programming terms.
Figure4 and Figure 5 are examples of some programming aids.




Field: An area in a record reserved
a n d u s e d f o r a p a r t i c u l a ri t e m o f
information.
Card
File
Record: A group of related fields.


File. A group of related records.
F---l,l,d i l
, : i i i i t
'-:-
'ffir1llrl'
-_-_-4'.1


rl l:rllll
/ | lirlllll
I W
Record


Name City State Zio




Fields Fields



F i l e( P r i n t e d e p o r t )
R


A c c o u n t s R e c e i v a b l eR e g i s t e r

Date Cust Cust Name Invoice Invoice
No No Amount

Record 07111 7560 Attstons 06340 $ 44.32
(A rer:ord 07111 7632 V i t t a s eS h o p 06341 148.39
07/11 8392 Ray's Repair
on a printecl 06342 4.28
reportis
comnronly
called a
l i n e).




Fields
Figure 3. Easic Programming Terms


8
IBM NTERNAIIONAL AUS NFSS MACHINES CORPORATION



P R O P O R T I O N A R E C O R DL A Y O U T F O R I
L
, Ap p l i c a tr , : n rypeor Records EM TRaNSncfroNllEco 8D
If By --
I l E C O R D A I \ , 4A N D R E M A R K
N E


DESCRPTI




t , , , , , , ,
T h e r e c o r d l a y o u t f o r m s h o w s w h a t r e c o r d si n a { i l e l o o k l i k e . T h i s f o r m i s f r l l e d o u t a t
t h e t i m e a f i l e i s d e s i g n e d . l t s h o w sw h a t f r e l d sa r e i n t h c r e c o r d i I r a n d t h e e x a c t l o c a -
t i o n a n d l e n g t ho f e a c h f ) l t m a y a l s o s h o w f i e l d n a m e sa n c le x p l a i n w h a t k i n d o f d a t a
i s i n e a c hf i e l d @ .


T h e r e a r e d i f f e r e n t r e c o r d l a y o u t f o r m s f o r d i s k , B 0 c o l u m n c a r d s , 9 6 c o l u m n c a r d s ,a n d
t a p e . T h e f o r m s h o w n a b o v e i s t h e P r o p o r t i o n a lR e c o r d L a V o u t f o r m .




'1'wonumbertngarrangements,eachinhexadecimalanddecrnralrctalron,areshown
Selectthearrangementandnolalronusedbycheckrngtheappropnateboxtothelelt
ll-he number oI forms per pad may vary slightlV


Figure 4. Record Layout Form




B a s i c D a t a P r o c e s s i n g n d P r o g r a m m i n gC o n c e p t s
a
i
roc. il). i
!+ lold bo.l or doil.d li^.
CHARACTRS P[R INCH.5 LINES PER VERTICAL INCH)




l+ told bc.l or &n.d li..




Figure 5, Printer Spacing Chart
Chapter 2. RPG ll Programming Language




RPG ll Program Cycle

When you do any job, you must do it in a particularorder. The system must
also do its job in a particular order. This logicalorder for the job is suppl.ied
by
t h e R P G l l c o m p i l e ra n d / o r y o u r c o d i n g .

The logic the compilersuppliesis called a program cycle (see Figure6). The
object programgoes through this cycle of operationsevery time a record is
processed.Dependingon your specifications, object program may or may
the
not use a particular
operationin the cycle. However,the program still goes
through the completeprogram cycle every time. Becauseone programcycle is
neededfor each record read, many program cyclesare requiredfor everyjob.




RPG ll Programming anguage 11
L
START

I
{}
Perform heading
operations.
Perform detail
calculations.
Set resulting
andicators,
il Perform detail
output operations.
lf overflow line
has been reached,
set on overflow
indicator.
Move data from record selected at
b e g i n n i n go f c y c l e i n t o p r o c e s s i n g r e a .
a Set off control
level indicators.
Set off record
i d e n t i fy i n g i n d i c a t o r s .


Overflow indicator on? Yes, do
overflow operations and set
overf low i ndicator off .
a
Read a record,

Program
Cycle
'd>
LR indicator on7 Yes,end ot
job has been reached. Last record? Yes,set on
c o n t r o l l e v e la n d L R
indicators nd perform
a

F total calculations.


Perform total output operatlons.
lf overflow line hasbeen reached.
set on overflow indicator.
b,
Set on record i d e n t i f y i n g
indicator.
P"rfo.- tot"t
calculations,
C h a n g ei n c o n t r o l
Set resulting
field? Yes,set
indicators.
on control level
indicators.




Notes:
1 . T h e p r o g r a m c y c l e s h o w n g i v e st h e g e n e r a lo r d e r o f t h e o p e r a t i o n s . T h e r e m a y b e m i n o r v a r i a t i o n s
b e t w e e n t h i s c y c l e a n d t h e d e t a i l e d c y c l e d i s c u s s e dn t h e r e f e r e n c em a n u a l a p p l i c a b l et o y o u r
i
svstem.
2. You do not needto memorizethe program cycle. The cycle is only shown at this time to giveVou
a n i d e a o f t h e c y c l e o f t h e o p e r a t i o n s . T h e o p e r a t i o n sw i l l b e d i s c u s s e d n g r e a t e rd e t a i l l a t e r .
i


Figure 6. Program Cycle




12
It is importantthat you know the order of the operationsin the RpG ll program
cycle. This enablesyou to write specificationsthat will make correct use of the
cycle' By knowing the order in which the operationsin the cycreare
performed,you can organizeyour program in an efficient mannerand
save
yourselfunnecessary coding.

In this chapter,the operationsin the RpG ll program cycle are explaineda few
at a time. You will learn:

. Which operationsare used for a particular
function.

. Which RPG ll specifications
you must write to use the function.




R P G l l P r o g r a m m i n gL a n g u a g e 13
Writing Specifications for Input and Output Operations

One of the simplest jobs you can do on a system is read information from an
input record,such as a card, then put that same informationout, such as in
the form of a printed report. No calculations done.
are


Program Cycle Operations

To do this simple job, the system uses only the three most basic operationsin
the RPG ll program cycle. Figure7 shows these operations.

Notice that two operationsare concernedwith the basic requirements a job:
of
input (reada record)and output (detailoutput). The third operationis the
movementof data insidethe system.
START

I
I

h
D Perform detail
output


v
operataonr,


lVlove data from record selected at
beginning of cycle into processing area.
,...'.

: * i


a
Reada record.


{? Program
Cycle {;}




"#



d
Figure 7. Three Basic Oprations in the RpG ll program Cycle
Data read by an input device must be trarrsferrerJ tl)e $vritern's
tc) processlrlri
unit before it can be used. Moving data is a rnandatoryoprlr;riionrJrrrre
l,..rr
every job. Because this operationis mandatoryand is dorre:
exactlytht: $ariri:
for every job, the compilercan supply instructions do ir.
to

When the program is executed,the program cycle is repeateriover anrl orrr,r
All three operationsare used for every record in the input file. The terrn dei.lrl
output,in the cycle operation,means that the sp:ecified orit[)rrtnperationsare
performed for every input record.

It may seem strangethat detail output comes before a record is read. This
occurs,however,so that headingscan be printed on a report. lf a job (such as
this one) does not print headings,no informationis printed during the first
cycle.

To make proper use of these cycle operations, your specificationsmust
describethe recordsin the input file and specify how the output records
should be created. You must also indicatewhat devicesare used in the job.




r l P ( r l l P r , ' , 1 . , , , t r n i nL . a n . l u d g ' j l 5
q
DESCRIBING HE FILES
T

The File Description Specificationsform is used to describeall the files used
by your program. This informationincludesthe name of the file, the device
used with the file, and informationon how the file is to be used. You fill out
the indicatedpositionson the bottom half of the form.




R P G C O N T R O L A N D F I L E D E S C R I P T I OS P E C T F I C A T I O N S
N 6X2t S92. UM/050'
prntedrfUSA




I ' l " - " 1i l l l l l l Il 1 " l._" . " ," * - * ' l
l t5 16 71 18 t9 AA
tuq'd. t TTTI-T_'I
I ; I i t rJFnr,nld'o.l L I i I i l



Control Specifications




F i l e D e s c r i p t i o nS p e c i f i c a t i o n s
Size of records
in the file

l_-r- ,Wt tf Kcy Fidld d Ertsrt xi!
ttrOaM

il ,"i,,"
i l
Il -d Syrnbolc
D.v re
i abel E\rl

$o$gi Indss
r,'",I I I
I t I

ill ls LtrEd,
Kry Fittd
9 UI U8




, l i i l i
$dinl I
E"tsy I
\ I




,i1.
Il
:l:rl:l
r
I
I
l
t l

1
' i. tI'l:ll li l i;;;;
I n p u to r o u t p u
i l l t
i

f
devices used 1
l i ; It , ll l , i ,
I ' i l ' l l :i l '
I
I
i l ,
You must describe,on a separaterine,every file used in your job. Many simple
jobs requireonly one input and one output file. In the first jobs
we discuss,
therefore,we will use only one input and one output file.



File Names

Errery used in a job must be named.The name providesyou and the
file
compilera means of identifyingthe file. During compiration,the compirer
as;sociates file name with other cha4acteristics the file. Thus, you can
the of
refer to that file by name throughoutyour program and the compilerknows
exactly which file you are referring to.

The compiler, however. recognizesfile names only if they conform to these
rules:

A file name must be 1-8 characterslong.

The first characterof a file name must be alphabetic.(The lettersA-Z and
the @, $, and f signs are consideredalphabeticcharacters.) The remaining
characters the name can be either alphabetic numeric.
in or

Blanks must not appear between charactersin the file name.

No two files used in the same programcan have the same name. (Because
some RPG ll compilersuse only the first seven letters of an g-letter file
name, be certain, when using these systems, to make the first seven letters
unique;for example,use TRANSACTand TRANFILE,not TRANFILAand
TRANFILB.)

The file name must begin in position7 on the specifications
form.




Valid filename.
I n v a l i df i l e n a m e . N a m e m u s t s t a r t i n p o s i t i o n 7 .
I n v a l i d f i l e n a m e . A b l a n k m u s t n o t b e u s e d b e t w e e nl e t t e r s .
Valid filename.
Valid filename.
I n v a l i d f i l e n a m e . T h e f i r s t c h a r a c t e ro f t h e n a m e m u s t b e
an alphabetic character.




It is a good practiceto assign meaningfulfile names: Meaningfulnames
indicate something about the file, such as the type of records in the file or the
use of the file. Because file names can be no longerthan eight characters,
abbreviationsmay be necessary. But these too can be meaningful. For
example,the abbreviation CUSTCHGmight be assignedto an input file
consisting of records for all customers having charge accounts.

R P G l l P r o g r a m m i n gL a n g u a g e 17
Device Designation

You must also specify which devicesyour job will use for input and output.
The ones you use, of course,depend upon the system you have, the devices
you have, and your job.

To indicatethe device used for the file you named,enter the RPG ll code
name for that device in positions40-60. The name must begin in positionzt0.

Note: ln the examplesin this manual,you will see shading in the device name
oositionsratherthan actual RPG ll code names for devices. Code names differ
for each system. The RPG ll referencemanualfor your system will tell you the
code names that are applicable.

During compilation,
the compilerassociatesthe file name with the device
name. When you use the same file name in the rest of your program,the
system will know which deviceto use.


File Use

You must also describehow each file and its associateddevice is used in a
program. Filescan be used as either input or output. (Fileswith other uses
will not be discussedin this manual.) lf recordsare read from a file, the file is
an input file. lf a new file is createdduring the job, the new file is an output
file. Printedreports are the only output files discussedin this manual.

You specify file use by placingeither an | (input)or O (output)in position 15:




+ lnputFile
+ O u t p u tF i l e




File Designation

Position16 is used to explainmore about the use of input files. In this manual
we are discussing the use of only one type of input file, the primaryfile. For
this, you place a P in position 16. The designation a file as a primaryfile in
of
an RPG ll program indicatesthat the RPG ll program cycle will supply some of
the program logic. For more informationon primaryfiles, and other types of
input files, see the appropriateRPG ll referencemanual.

IB
Record Size

when describing files, you must specify the rength (in characters) records
of in
the file' Recordlength is enteredin positions 24-27. Enter the length
so the
last digit is in position27:




The record length specificationdoes two things:

It tells the compilerhow much storagespace to set aside for a record (input
or output).

It specifies how many charactersmust be read to get a complete input
record.

Record size for card files is easy to determine. lt is either 8O or 96 depending
upon the size of cards you have. Maybe not all your cards have informationin
all columns,but all columns must be read to get an entire record. Blanksare
placed in storage positions correspondingto unpunched card col.umns.

The size of records(lines)on the printer is also easy to determine. printed
recordsare limited by the size of your printer (the number of print positionsin
a line).

You may, if you wish, specify a record size smallerthan actual printer size. lf
you do this, make certainthat none of the lines to be printed are longerthan
the length you specify;otherwisethe RPG ll compilerwill give you an error
messagewhich requires that the program be corrected and recompiled.

Recordson other files, such as disk, can be any size. The maximum size is
limited only by the capabilityof the device. When you use one of these files
for a job, make sure you enter the correct record size; that is, enter the one
establishedat the time the file was created

Other informationmay b