You are on page 1of 148

Table of Contents:

Chapter I :AS/400 Highlights .................................................................................. 7


Introduction : ................................................................................................................................ 7
Technology-Independent Machine Interface .......................................................................... 7
Operating System OS/400 .......................................................................................................
Single-!e"el Storage ...............................................................................................................
!ogical #artitioning $!#%&' ................................................................................................... (
O)*ects ..................................................................................................................................... (
%S/400 #rocessing +n"ironment ............................................................................................... ,-
.hat is a *o)/ ....................................................................................................................... ,-
0o) 1escription: ..................................................................................................................... ,-
Su)system .............................................................................................................................. ,-
0o) 2ueues ............................................................................................................................. ,-
Output 2ueues ....................................................................................................................... ,-
Type of 0o)s ........................................................................................................................... ,-
%S/400 Security ......................................................................................................................... ,4
Security at o)*ect le"el: .......................................................................................................... ,4
Security 3unctions ................................................................................................................. ,4
Security !e"els ....................................................................................................................... ,5
%pplication 1e"elopment Tools $%1T' .................................................................................... ,7
#rogram 1e"elopment Manager $#1M' ................................................................................ ,7
Source +ntry 6tility $S+6' .................................................................................................... -0
1ata 3ile 6tility $136' .......................................................................................................... -0
Chapter II Libraries ........................................................................................... 22
!i)rary 7ategories ..................................................................................................................... --
!i)rary !ist: .............................................................................................................................. -8
!i)rary commands: .................................................................................................................... -8
!i)rary !ist 7ommands: ............................................................................................................ -8
Chapter III: AS/400 Database ............................................................................ 24
3ile Types: ................................................................................................................................. -4
1ata)ase 3iles: ........................................................................................................................... -4
%ccess paths: .......................................................................................................................... -4
#hysical 3iles: ........................................................................................................................ -5
!ogical 3iles: ......................................................................................................................... -7
Types Of !ogical 3iles ........................................................................................................... -
0oin !ogical 3ile .................................................................................................................... -
9on - 0oin !ogical 3ile: ......................................................................................................... -
3ield &eference 3iles: ................................................................................................................ -(
Importance of using 3ield &eference 3iles ............................................................................ -(
9aming 7on"entions ................................................................................................................. -(
Chapter I: Data Des!ription Spe!ifi!ation "DDS# ........................................... $%
1efining #hysical 3iles .............................................................................................................. 8,
7omponents of 11S .............................................................................................................. 8-
#hysical 3ile :ey;ords ......................................................................................................... 88
3ile !e"el :ey;ords .............................................................................................................. 88
% of %4&
&ecord !e"el :ey;ords ........................................................................................................ 88
3ield !e"el :ey;ords ............................................................................................................ 88
:ey 3ield !e"el :ey ;ords ................................................................................................... 84
1efining !ogical 3iles ............................................................................................................... 85
!ogical file :ey;ords ........................................................................................................... 87
3ile !e"el :ey;ords .............................................................................................................. 87
&ecord !e"el :ey;ords ...................................................................................................... 8
0oin !ogical 3iles ................................................................................................................... 8(
0oin !e"el :ey;ords ..................................................................................................... 40
+<amples of data)ase files in 11S: ........................................................................................... 4,
+<ample of a field reference file: ........................................................................................... 4,
+<ample of a physical file ;ith a ne; record format: ........................................................... 4-
+<ample of a logical file specifying multiple formats and ne; =eys: ................................... 48
+<ample of a logical file specifying a ne; record format: .................................................... 48
+<ample of a *oin logical file: ................................................................................................ 44
11M 3iles ................................................................................................................................. 44
Chapter : SDA an' Displa( )iles ...................................................................... 4*
Screen 1esign %id$S1%': .......................................................................................................... 45
%dding fields. ......................................................................................................................... 4
%dding constants ................................................................................................................... 4
%dding fields from a data)ase file ......................................................................................... 4
Mo"ing> 7opying and Shifting fields ..................................................................................... 4(
1ate and Time =ey;ords. ...................................................................................................... 4(
1isplay 3iles: ......................................................................................................................... 40
Chapter I: +,-/400 ........................................................................................... .7
&#?/400 !anguage 7oncepts .................................................................................................... 47
&#?/400 Specifications ............................................................................................................. 4
@ 7O9T&O! S#+7I3I7%TIO9 ...................................................................................... 4(
3 3I!+ S#+7I3I7%TIO9 ................................................................................................. 4(
+ +AT+9SIO9 S#+7I3I7%TIO9 .................................................................................... 4(
! !I9+ 7O69T+& S#+7I3I7%TIO9 ............................................................................. 4(
I I9#6T S#+7I3I7%TIO9 .............................................................................................. 4(
7 7%!76!%TIO9 S#+7I3I7%TIO9 ............................................................................. 4(
O O6T#6T S#+7I3I7%TIO9 ......................................................................................... 4(
&#?/400 Operation 7odes $O#7O1+S': .................................................................................. 4(
%rithmetic Operations ............................................................................................................ 50
%11 $%dd Statement' ...................................................................................................... 50
B-%11 $Beroise and add' ............................................................................................. 50
S6C $Su)tract statement' .................................................................................................. 5,
B-S6C $Beroise and su)tract' ............................................................................................ 5,
M6!T $Multiply' .............................................................................................................. 5,
1ID $1i"ide' ...................................................................................................................... 5-
MD& $Mo"e remainder' ................................................................................................... 5-
S2&T $SEuare root' .......................................................................................................... 5-
Mo"e Operations: ................................................................................................................... 5-
MOD+ $Mo"e' .................................................................................................................. 5-
2 of %4&
MOD+! $Mo"e left' .......................................................................................................... 58
7ompare Operations .............................................................................................................. 58
I3<< $If condition' ............................................................................................................. 54
1O6<< $1o until' .............................................................................................................. 54
1O.<< $1o ;hile' ............................................................................................................ 54
.@<< $.hen' .................................................................................................................... 55
7OM# $7ompare' .............................................................................................................. 55
1eclarati"e Operations ........................................................................................................... 57
#!IST $ #arameter list' ...................................................................................................... 57
#%&M $#arameter' ........................................................................................................... 57
:3!1 $:ey 3ield' ............................................................................................................. 57
:!IST $:ey list' ................................................................................................................ 57
1+39 $1efinition' ............................................................................................................. 5
T%?$Tag' .......................................................................................................................... 5
InitialiFation Operations ......................................................................................................... 5
7!+%& $7lear' .................................................................................................................. 5
&+S+T $&eset' ................................................................................................................... 5(
String Operations .................................................................................................................. 5(
7%T $7oncatenate T;o 7haracter Strings' ....................................................................... 5(
7@+7: $7hec= 7haracters' .............................................................................................. 70
7@+:& $7hec= &e"erse' .................................................................................................. 70
S7%9 $Scan 7haracter String' .......................................................................................... 7,
A!%T+ $Translate' ............................................................................................................ 7,
S6CST $Su)string' ............................................................................................................ 7-
Su)routine Operations ........................................................................................................... 7-
7%S<< $7ompare and e<ecute su)routine' ........................................................................ 7-
+AS&$+<ecute Su)routine' ............................................................................................... 78
C+?S&$Cegin Su)routine' ................................................................................................ 78
+91S&$+nd Su)routine' ................................................................................................... 78
Indicator Operations ............................................................................................................... 74
S+TO9 $Set on indicator' .................................................................................................. 74
S+TO3 $Set off indicator' .................................................................................................. 74
Structured #rogramming Operations ..................................................................................... 74
O&<< $Or condition' .......................................................................................................... 74
%91<< $%nd condition' .................................................................................................... 74
+!S+ $+lse' ....................................................................................................................... 74
+91 $+nd' ......................................................................................................................... 74
+91yy $+nd 7ondition' .................................................................................................... 74
1O $1o Iteration' ............................................................................................................... 75
S+!+7 $Select' .................................................................................................................. 75
OT@+& $Other' ................................................................................................................ 77
IT+& $Iterate' .................................................................................................................... 77
!+%D+ $!ea"e' ................................................................................................................. 77
3ile Operations ..................................................................................................................... 7
O#+9 $Open 3ile for #rocessing' ...................................................................................... 7
7!OS+ $7lose 3iles' ......................................................................................................... 7
$ of %4&
S+T!! $Set !o;er !imits' ................................................................................................ 7(
S+T?T $Set ?reater Than' ................................................................................................ 0
&+%1 $&ead a &ecord' ..................................................................................................... 0
&+%1+ $&ead +Eual :ey' ................................................................................................ 0
&+%1#$&ead a #re"ious &ecord' .................................................................................... ,
&+1#+ $&ead #rior +Eual' ................................................................................................ ,
7@%I9 $&andom &etrie"al from a 3ile' ........................................................................... -
.&IT+ $7reate 9e; &ecords' .......................................................................................... -
6#1%T $Modify +<isting &ecord' .................................................................................... -
1+!+T $1elete &ecord' .................................................................................................... 8
7alling Operations ................................................................................................................. 8
7%!! $7all a #rogram' ..................................................................................................... 8
#%&M $Identify #arameters' ............................................................................................. 4
#!IST $Identify a #arameter !ist' .................................................................................... 4
Cranching Operations ............................................................................................................ 5
?OTO$?o to' ..................................................................................................................... 5
IT+& $Iterate' ..................................................................................................................... 5
!+%D+ $!ea"e' ................................................................................................................. 5
%rray Operations .................................................................................................................... 5
MOD+% $Mo"e array' ....................................................................................................... 5
A3OOT $%rray Total' ........................................................................................................ 7
!O:6# $!oo=up' .............................................................................................................. 7
SO&T% $Sort array' ...........................................................................................................
1ata %rea Operations .............................................................................................................
7ommitment 7ontrol Operations ...........................................................................................
7OMIT $7ommit' ..............................................................................................................
&O!C: $&oll Cac=' ..........................................................................................................
+<amples 3or 3ile processing: ................................................................................................... (
&#? synta< to process an e<ternally defined #hysical 3ile: ............................................... (
&#? synta< to process a #rogram defined #hysical 3ile: ................................................... (
Chapter II: S/bfiles .......................................................................................... 0%
7omponents of Su)file .............................................................................................................. (,
Su)file 1ata 1escription Specification : ................................................................................. (8
@andling Su)files in &#? #rograms ......................................................................................... (4
Multi page su)files: .................................................................................................................... (4
Su)file !oad Options- #ros and 7ons. ................................................................................... (4
!oad all Su)file: ..................................................................................................................... (4
........................................................................................................................................... (5
+<panding Su)file: ................................................................................................................. (
Single #age Su)file: ............................................................................................................. ,00
3old and 1rop capa)ilities : ..................................................................................................... ,0-
Other interesting Su)file :ey;ords: ................................................................................... ,08
%dditional &ecommended &eading Material ....................................................................... ,08
Chapter III: Arra(s1 Tables an' Data str/!t/res ........................................... %04
%rrays: .................................................................................................................................... ,04
%rray 1escription : .............................................................................................................. ,04
4 of %4&
!oading of an array: ................................................................................................................. ,04
7ompile time array: ............................................................................................................. ,04
#rerun time %rray: ............................................................................................................... ,05
&un time array: .................................................................................................................... ,07
Searching %rrays ...................................................................................................................... ,0(
Searching an %rray ;ithout an Inde< .................................................................................. ,0(
Searching an %rray ;ith an Inde< ....................................................................................... ,,0
Specifying an %rray in 7alculations ........................................................................................ ,,,
Ta)les : ..................................................................................................................................... ,,8
1ata Structures: ....................................................................................................................... ,,8
3ormat of 1ata Structure Su)fields in Storage: ................................................................... ,,8
1ata Structure Statement Specifications: ............................................................................. ,,4
+<amples: ............................................................................................................................. ,,4
Multiple Occurrence 1ata Structure: ................................................................................... ,,5
1ata %reas : .............................................................................................................................. ,,7
Implicitly retrie"ed and ;ritten: ......................................................................................... ,,7
+<plicitly retrie"ed and ;ritten: ...................................................................................... ,,7
1ata Structures 3or +<ception/+rror 7ontrol .......................................................................... ,,(
3ile Information 1ata Structures $I931S': ......................................................................... ,,(
#rogram Status 1ata Structure: ............................................................................................ ,-0
Chapter I2: +L3 an' ,rinter )iles ................................................................... %22
&eport !ayout 6tility $&!6' ................................................................................................... ,--
&eport !ine .......................................................................................................................... ,--
&eport #rototype .................................................................................................................. ,--
#rinter 3ile :ey;ords .......................................................................................................... ,--
#rocessing #rinter 3iles in &#? #rograms: ......................................................................... ,-4
Chapter 2: Intro'/!tion To Control Lang/age ............................................... %2*
7ommand Structure ................................................................................................................. ,-5
#ositional 3orm .................................................................................................................... ,-5
:ey;ord form ...................................................................................................................... ,-7
Coth positional and :ey;ord form ...................................................................................... ,-7
7ommand 7ontinuation ....................................................................................................... ,-
Daria)le naming synta< ....................................................................................................... ,-
7oncatenation ...................................................................................................................... ,-
&elational +<pressions ......................................................................................................... ,-(
!ogical +<pressions ............................................................................................................. ,-(
Su)string e<pressions ........................................................................................................... ,-(
6sing "aria)le in a 7! program ........................................................................................... ,80
6sing files in 7! program ................................................................................................... ,80
3ile Operations ..................................................................................................................... ,80
+rror @andling ..................................................................................................................... ,8,
%ssigning Dalues ................................................................................................................. ,8,
!ogical Operations ............................................................................................................... ,8,
Chapter 2I: 4pen 5/er( )ile 6asi!s ................................................................ %$$
Open data #ath$O1#' : ........................................................................................................... ,88
2&GS+!+7T .......................................................................................................................... ,84
. of %4&
Steps in"ol"ed in a typical O#92&G3 program: .................................................................... ,84
+<ample: ................................................................................................................................ ,84
Chapter 2II: 7essage S/bfiles in +,- ............................................................ %$*
Message Su)files .................................................................................................................... ,85
Steps In"ol"ed : ................................................................................................................... ,85
+<ample : ............................................................................................................................. ,87
Appen'i8 A : +,- 4p!o'es ................................................................................. %42
Appen'i8 6 : AS/400 Data Li9its ....................................................................... %47
Appen'i8 C : +,-/400 +estri!tions .................................................................... %4&
* of %4&
Chapter I :AS/400 Highlights
Introduction :
%S/400 is designed as an entire system >ta=ing into account all the layers that ;ere added to
systems o"er last 80 years as ;e disco"ered one after another ;hile the computer industry
matured. 7urrent mature operating systems ;ere originally )atch processors > many times
patched to accommodate interacti"e and data)ase use ;ith many faster >roomier dri"es. The
user sees these systems today through "arious and complicated interfaces and paths.
On the other hand > %S/400 design engineers created the layers of the onion from the outside in
H the opposite of the design of older machines. 3irst the functions that ;e all ;anted> then user
le"el interfaces that ;ould ma=e that function easy and accessi)le. Then the layers )elo; those
interfaces that ;ould shield us from the intricacies of getting the functionI finally a layered
and Eueued system )eneath the soft;are in hard;are$putting much soft;are function of today
into microcode'. #aths among the layers ;ere made standard and therefore mo"a)le and
changea)le.
Technology-Independent Machine Interface
The %S/400 is a typical in that it is defined )y soft;are> not )y hard;are. In other ;ords> ;hen a
program presents instructions to the machine interface for e<ecution> it Jthin=sJ that the interface
is the %S/400 hard;are. Cut it is notK The instructions> presented to that interface> ha"e to pass
through a layer of microcode )efore they can )e understood )y the hard;are itself. This design
insulates application programs and their users from changing hard;are characteristics through
this comprehensi"e layer of microcode. .hen a different hard;are technology is deployed> ICM
re;rites sections of the microcode to a)sor) the fluctuations in hard;are characteristics. %s a
result> the interface presented to the customer remains the same.
This interface is =no;n as the Technology-Independent Machine Interface $or TIMI'. The
microcode layer is =no;n as the System !icensed Internal 7ode $or S!I7'. The )rilliance of this
design ;as dramatically illustrated ;hen the %S/400 changed its processor technology from
7IS7 $7omple< Instruction Set 7omputing' processors to 54-)it &IS7 $&educed Instruction Set
7omputing' processors in ,((4. .ith any other system> the mo"e from 7IS7 to &IS7 ;ould
in"ol"e recompiling $and possi)ly some re;riting' of programs. +"en then> the programs ;ould
run in 8--)it mode on the ne;er 54-)it hard;are. This is not so ;ith the %S/400> )ecause of
TIMI. 7ustomers ;ere a)le to sa"e programs off their 7IS7 %S/400s> restore them on their ne;
&IS7 %S/400s> and the programs ;ould run. 9ot only did they run> )ut they ;ere fully 54-)it
programs.
7 of %4&
%s soon as they made this transition> customers had 54-)it application programs that ran on a 54-
)it operating system containing a 54-)it relational data)ase that fully e<ploited the 54-)it &IS7
hard;are.
Operating System OS/400
One of the single most dramatic things a)out %S/400 is that its operating system> OS/400> is a
single entity. This section descri)es the meaning of this concept.
Once you )uy an %S/400> you do not ha"e to continue shopping for system soft;are components
)efore it is ready to run your )usiness. %ll of those soft;are components> for relational data)ase>
comprehensi"e security> communications ;ith a )road range of di"erse systems> including
Internet capa)ilities> and many more> are already there.
They are all fully integrated into OS/400 $%S/400 operating system'. Cy Jfully integratedJ> ;e
mean fully tested> too. %ll those components> prereEuisites for running )usiness applications in
the ,((0s> ;or= together and are fully tested together> so that OS/400 operates as a single entity.
%n ordinary machine does not ha"e this approach to its operating system design.
Single-Level Storage
0ust as application programs on an %S/400 are una;are of underlying hard;are characteristics
)ecause of the TIMI. They are also una;are of the characteristics of any storage de"ices on the
%S/400> )ecause of single-le"el storage.
%s ;ith TIMI> the concept of single-le"el storage means that the =no;ledge of the underlying
characteristics of hard;are de"ices $in this case> the hard;are storage de"ices-- main storage and
dis= storage' reside in the S!I7. %ll of the storage is automatically managed )y the system.
#rograms ;or= ;ith o)*ects> and o)*ects are accessed )y name> ne"er )y address. 9o user
inter"ention is e"er needed to ta=e full ad"antage of any storage technologies.
The %S/400Ls address siFe is "ast.
Single-le"el storage ena)les another e<tremely important %S/400 )enefit--o)*ect persistence..
O)*ect persistence means that the o)*ect continues to e<ist in the memory system fore"er. %n
& of %4&
ordinary machine reEuires that information )e stored in a separate file system if the information
is to )e shared or if it is to )e retained for a long time. #ersistence of o)*ects is e<tremely
important for future support of o)*ect-oriented data)ases. O)*ects need to continue to e<ist e"en
after their creator goes a;ay. The %S/400 is uniEuely positioned to e<ploit this characteristic of
o)*ect persistence> ;here ordinary systems use a less-elegant mechanism that reEuires them to
store their persistent o)*ects in a separate file system> ;ith all the attendant performance
implications.
Logical Partitioning (LP!"
%s the performance of an enterprise class ser"er gro;s> so does the reEuirement to di"ide that
performance to run multiple ;or=loads independently. #artitioning enterprise ser"ers has
)ecome commonplace in the mainframe mar=et since its introduction the mid-,(0s. Typically>
separate partitions are used for test releases of applications or to ser"ice multiple )usiness units
or companies from a single ser"er.
!ogical partitions $!#%&' ena)le multiple independent OS/400 instances or partitions in an n-
;ay symmetric multiprocessing. +ach partition reEuires its o;n processor$s'> memory> dis=$s'>
system console> ;ith a 71-&OM and tape dri"e that can )e allocated to each !#%&. .ith
!#%&> you can address multiple system reEuirements in a single machine to achie"e ser"er
consolidation> )usiness unit consolidation> mi<ed production/test en"ironments> integrated
clusters> and more.
O#$ects
%n o)*ect is a container. +"erything the system uses--user and system data structures--is
pac=aged in one of these containers. The o)*ects are encapsulated> ;hich means that you cannot
see inside. Insepara)le from an o)*ect is the list of "alid ;ays in ;hich that o)*ect can )e used.
%ll o)*ects are structured ;ith a common o)*ect header> and a type-dependent functional portion.
Therefore> on the %S/400> instructions can only ;or= on ;hat they are supposed to ;or= on.
Gou cannot ha"e data treated as e<ecuta)le code $so that the processor tries> for e<ample> to
e<ecute someoneLs shoe-siFe'> or e<ecuta)le code treated as data> $)y ha"ing something ;ritten
into the middle of it'. 7ertain instructions apply to all o)*ects> ;hile other instructions ;or= only
on specific types of o)*ects. It is not possi)le to misuse an o)*ect> unli=e the situation that e<ists
other systems ;ithout an o)*ect-)ased approach.
There are t;o important conseEuences of an o)*ect-)ased design. The first is that a system )uilt
around an o)*ect model supports machine independence. This means that technology changes
can )e made in the en"ironment ;ithout affecting application programs. The second
conseEuence is that an o)*ect-)ased design deli"ers a high le"el of system integrity.
Components of an object
9ame H?eneric name
!i)rary- that ;hich contains addressa)ility
to the o)*ect
0 of %4&
Type H attri)ute that defines the purpose of
an o)*ect ;ithin the system. +ach type has
an associated set of commands that is used
to process that o)*ect type.
%ttri)ute-%n additional characteristic of an
o)*ect ;ithin the o)*ect type.
O;ner-9ame of the user ;ho o;ns the
o)*ect.
7reation date /time.
Sa"e date /time.
&estore date /time.
Dolume identifier for sa"e.
3ree storage indication H Indication ;hether
the o)*ect storage ;as freed ;hen the o)*ect
;as sa"ed.
SiFe-9um)er of )ytes allocated to the o)*ect
in au<iliary storage.
Examples of Objects
7M1 7ommand
Casic form of high le"el instruction to the system
1+D1 1e"ice 1escription
%n information set descri)ing the physical and logical attri)utes of a de"ice connected to the
system.
1T%%&% 1ata area : % data store
1T%2 1ata 2ueue
3I!+ 3ile
0OC1 0o) desription
Information descri)ing en"ironment in ;hich a *o) ;ould )e e<ecuted
0OC2 0o) 2ueue
2ueue ;here the *o)s ;ait for e<ecution.
0&9 0ournal:O)*ect ;hich controls storing of application data that needs to )e
reco"ered in case of a system failure.
0&9&7D 0ournal &ecei"er:3ile in ;hich application data that needs to )e reco"ered in case
of a system failure is stored. % *ournal recei"er is al;ays associated ;ith a *ournal.
!IC !i)rary
6ser defined place ;ithin the system ;here any particular group of o)*ects reside.
%0 of %4&
MS?3 Message 3ile
% data)ase file ;here messages are stored.
MS?2 Message 2ueue
2ueues ;here messages ;ait to )e passed or displayed.
O6T2 Output 2ueue
2ueue ;here the system output ;aits to )e "ie;ed printed or transferred
#?M #rogram
%% of %4&
AS/400 Processing Environment
%hat is a $o#&
% *o) is the )asic unit of ;or= on the %S/400.+"ery acti"ity on the %S/400 is done as part of a
*o). +ach *o) is a single > identifia)le seEuence of processing actions that represent a single use
of the system.
Attributes of a job:
Job number:The *o) num)er is a uniEue system generated seEuential num)er
Job Name :0o) name is any user defined name. 3or certain *o)s> the system assigns a *o)
name ;hich is usually the name of the corresponding *o) description.
User Name:6ser name attri)uted ;ith a *o) is the name of the user ;ho initiated the *o).
The com)ined usage of the *o) num)er> *o) name and user name uniEuely identifies a *o) in the
system.
'o# (escription)
% *o) description is a collection of parameters that control the *o) ;hen it is started in the
su)system. The ad"antage of using a *o) description is that once it is defined you can use it
any;here *ust )y referring to the *o) description name ;hene"er you ;ant to start *o).
S*#system
% su)system is single predefined operating en"ironment in ;hich the system coordinates the
;or= flo; and resources. Su)systems are specific user defined *o) partitions of the 7#6 ;here
"arious *o)s may )e e<ecuted. The system is shipped ;ith a set of ICM supplied su)systems
;hich may )e modified if reEuired. One su)system may ha"e more than one *o) acti"e at a time.
'o# +*e*es
0o) 2ueues are streams ;here *o)s ;ait for e<ecution. 0o) Eueues are attached to specific
su)systems. One su)system may ha"e more than one *o)E attached to it.
O*tp*t +*e*es
Output Eueues are streams ;here output from the *o)s ;ait to )e processed. It is a place to hold
the output spooled files created )y *o)s.
Type of 'o#s
Interactive jobs:
%2 of %4&
%n interacti"e *o) starts ;hen the user signs on to the machine and lasts until
user signs off. % *o) is created )y the system to interacti"ely react to the users responses and
thus is called an interacti"e *o).
Batch jobs:
% 0o) is called a )atch *o) ;hen a series of actions su)mitted to a *o) Eueue
for e<ecution in one single *o) stream.
Spooling *o):
% spooling *o) can )e for input or output.In an input spooling *o) >a system
program called a reader transfers *o) from the input de"ice such as a dis=ette or data)ase file.
3or output spooling > the *o) puts the output from a program into a spooled file > later the
spooled file can )e ;ritten to an e<ternal de"ice such as a printer.
Autostart job:
% autostart *o) is al;ays associated ;ith the su)system > and ;hene"er the
su)system is started the autostart *o) is started as ;ell.
%dditional &ecommended &eading Material :
,.S74,-07-0, %S/400 .or= Management ?uide
%$ of %4&
AS/400 Security
The Security is un)reacha)le )ecause it is not a layer added on top of an interface > ;hich > after
)eing unloc=ed pro"ides complete access. &ather> it is a chec= )uilt in e"ery step the system
ta=es for you $once again > ;ith this system you only reEuest ;or= to )e done for you > you do
not actually do it yourself'. It is )uilt into )oth the hard;are and the soft;are and it has to do
;ith function >location> user type and type of use.
On the %S/400 all information is stored in o)*ects. %ccess to that information is through
hard;are instructions that ensure o)*ect integrity . %ny attempt to misuse an o)*ect detected>
causing the system to terminate the instruction and signal an e<ception condition.
Security at obect level:
Object ownership:
%ll o)*ects ha"e o;ners. Initially > the user ;ho creates the o)*ect is the o;ner. @o;e"er>
the o;ner> the Security officer> or a user ;ith O)*ect e<istence rights can transfer o;nership to
another user.
ublic or rivate authorit! over an object:
O)*ect use can )e authoriFed pri"ately or pu)licly. M#ri"ateN means to specific usersI
M#u)licN means to all users.

"oo#in$ at %ecurit! from the object outwar&:
The o;ner of the o)*ect has authority to do all things possi)le to it.
O%!!OC0 authority can )e granted to a user > ;hich gi"es this user M all things
possi)leN authority. 9o; the grantee can further grant authority and re"o=e it as
;ell> e"en from the original o;ner.
O#6C!I7 authority reaches e"ery)ody and can )e granted )y the o;ner at some
command le"el to all system users.
%ecurit! over libraries can be &efine& at these levels:
O+A7!61+ H 6sers 7anNt get it all$only the o;ner and security officer can use it'
O6S+ H % user can 1IS#!%G the content of the li)rary >use commands to find
o)*ects >put the li)rary in !IC list> and sa"e the li)rary.
O%!!- 6sers ha"e all the o)*ect authorities and all the data usage le"el authority on
the contents of this li)rary on the li)rary itself.
Object Authorit!:
O)*ect authority is used to control access to an o)*ect including the a)ility to see an o)*ect
description> control read and ;rite access to an o)*ect> or control an o)*ectLs e<istence.
OOC0M?T : pro"ides the authority to specify the security $grant/re"o=e o)*ect authority'>
mo"e or rename the o)*ect> and add mem)ers to data)ase file.
%4 of %4&
OOC0+AIST: pro"ides the authority to control the o)*ect e<istence and o;nership. The
user ;ith this authority can delete> sa"e> and transfer o;nership of the o)*ect.
OOC0O#& : pro"ides the authority to loo= at the description of an o)*ect and use the
o)*ect as determined )y the data authority that the user has to the o)*ect.
'ata Authorit!:
1ata authority is the authority to access data contained in an o)*ect> for e<ample records in a
data)ase file. This includes the a)ility to "ie;> update> add> or delete records.
O&+%1 :pro"ides the authority to get the contents or an entry in an o)*ect or to run a
program.
O%11 :pro"ides the authority to add entries to an o)*ect.
O6#1 :pro"ides the authority to change the entries in an o)*ect.
O1!T :pro"ides the authority to remo"e entries from an o)*ect.
Co9binations of 4b:e!t an' Data A/thorities
These are =ey;ords> each representing predefined com)ination of o)*ect and data authorities.
They reduce the time reEuired to assign specific authorities to users.
O%!!
allo;s the user to perform all authoriFed operations $o)*ect and data' on the o)*ect.
O7@%9?+
pro"ides OOC0O#& authority and all data authority.
O6S+
pro"ides OOC0O#& authority and data read authority.
O+A7!61+
authority pre"ents the user from accessing the o)*ect e"en if O#6C!I7 is authoriFed.
In addition to these> users can create customiFed com)inations of o)*ect and data authorities
Security ,*nctions
%ettin$ the securit! levels for the s!stem
The system can )e set to "arious security le"els. The system is shipped ;ith a minimum
security le"el> ;hich means that any user can sign on and use any data or programs on the
system. If your system has more than *ust Mminimum security officer controls> ;ho has access to
the system and its data.
%. of %4&
Sec*rity Levels
The %S/400 system allo;s to select the le"el of security needed to use on your system. The
different le"els pro"ide "arying degrees of security> ;hich are as follo;s:
Level 10
The system is not secured. 9o pass;ord is reEuired to signon. 9o resource security is used> so all
users can access and use all system resources.
Level 20
The system has limited security. % pass;ord is reEuired to signon> )ut no resource security is
used. %ll users can access and use all system resources.
Level 30
The system is designed to )e fully secured. % pass;ord is reEuired to signon.&esource security is
used > ;hich means that system resources are a"aila)le to users depending on ;hat o)*ects they
ha"e authority to use and ;hat special authorities they ha"e.
Level 40
The system is designed to )e fully secured> as it is for le"el 80.In addition> the system is
protected from access )y unsupported interfaces.
%* of %4&
Application !evelopment "ools #A!"$
Program (evelopment Manager (P(M"
#rogram 1e"elopment Manager is a complete de"elopment tool ;hich allo;s the programmer to
perform all programming related acti"ities under one single menu dri"en easy to use and
comprehensi"e en"ironment.
(unctions of ')
#1M allo;s the user to ;or= ;ith the li)raries and o)*ects in terms of performing the
follo;ing functions among others.
7reate
7hange
1isplay
1elete
&ename
Mo"e
.or= ;ith mem)ers namely +dit / &ename / 7lear / &emo"e
3ind strings> that is to find a character or string in a source or data file.
1efine 7ommands to perform repetiti"e actions on o)*ects from a list
7all the other %pplication Tools mentioned Celo; :
Source +ntry 6tility $S+6'
Screen 1esign %id $S1%'
1ata 3ile 6tility $136'
&eport !ayout 6tility $&!6'
%7 of %4&
Invo#in$ ')
#rogram 1e"elopment Manager can )e in"o=ed in any one of the follo;ing ;ays :
,. Ta=e option M4N for the programmers menu from the %S/400 main menu.Then ta=e option
M-N for #1M from the programmerNs menu
-. +nter command MST&#1MN from any command entry line
AS/400 Programming Development Manager (PDM)

Select one of the following:

1. Wor with li!rarie"
#. Wor with o!$ect"
%. Wor with mem!er"

&. Wor with '"er()efine) option"









Selection or comman)
***+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

-%*./it -4*Prompt -&*0etrieve -10*1omman) entr2
-1#*1ancel -13*1hange )efa'lt"
(1) 14P506789 6:M 140P. 1&31; #000.

%& of %4&

8. +nter command M.&:!IC#1MP H .or= ;ith !i)raries in #1M H from any command
entry line to ;or= ;ith li)raries
Wor with <i!rarie" ="ing PDM

<i"t t2pe . . . . . . . ><6:<

92pe option"; pre"" .nter.
#*1hange %*1op2 ?*Di"pla2 @*0ename
3*Di"pla2 )e"cription &*Save 10*0e"tore 1#*Wor with ...

4pt <i!rar2 92pe 9e/t
( 0:9S5S<6: >P04D(S5S 04:49 S5S9.M <6:0A05
( AS5S >P04D(S5S S5S9.M <6:0A05
( AS5S# >P04D(S5S S5S9.M <6:0A05 -40 1P6BS
( A8<PS5S >P04D(S5S
( A=S0S5S >P04D(S5S S2"tem <i!rar2 for ="er"
( S5S9.M >P04D(S5S .8A S2"tem Software
( C14M# >P04D(S5S 1A(C14M "oftware li!rar2
( AMAM >P04D(S5S MAS.06.S -40 AS/400
( AS5S#&#4 >P04D(S5S
More...
Parameter" or comman)
***+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-%*./it -4*Prompt -?*0efre"h -D*A)) to li"t
-&*0etrieve -10*1omman) entr2 -#%*More option" -#4*More e2"

4. +nter command M.&:OC0#1MP H .or= ;ith o)*ects in #1M H from any command
entry line to ;or= ;ith o)*ects


Wor with 4!$ect" ="ing PDM

<i!rar2 . . . . . 9S9<6: Po"ition to . . . . . . . . ,,,,,,,,,,,,,,,,
Po"ition to t2pe . . . . . ,,,,,,,,,,,,,,,,

92pe option"; pre"" .nter.
#*1hange %*1op2 4*Delete ?*Di"pla2 @*0ename
3*Di"pla2 )e"cription &*Save 10*0e"tore 11*Move ...

4pt 4!$ect 92pe Attri!'te 9e/t
( CMS7D9A0-P >-6<. P-(D9A MD< Me""age Ph2"ica
( 5A:4A:A0-P >-6<. P-(D9A 2a!oa!arfp Ph2"ical fi
( 5A:4A:ACCP >-6<. P-(D9A 1ontain" 5A:4A:A0-P )elete) mo)el )at
( 5A:4A:A00< >-6<. <- MD< A!o 'p)ate (EEA:4A:A)
( 5A:4A:A01< >-6<. <- MD< A!o action rtv (EEA:4/EE181/EEA:4
( 5A:4A:A0#< >-6<. <- MD< A!o action rtv (EEA:4/EEA:4A:A,P)
( 5A:4A:A0%< >-6<. <- MD< A!o action rtv (EEA:4/EE0.-1FD +
( 5A:4A:A04< >-6<. <- MD< A!o 'p)ate (EEA:4/EEA:4A:A)
More...
Parameter" or comman)
***+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-%*./it -4*Prompt -?*0efre"h -D*1reate
-&*0etrieve -10*1omman) entr2 -#%*More option" -#4*More e2"


4. +nter command M.&:MC&#1MP H .or= ;ith mem)ers in #1M H from any command
entry line to ;or= ;ith mem)ers
%0 of %4&
Wor with 4!$ect" ="ing PDM

<i!rar2 . . . . . 9S9<6: Po"ition to . . . . . . . . ,,,,,,,,,,,
Po"ition to t2pe . . . . . ,,,,,,,,,,,,,

92pe option"; pre"" .nter.
#*1hange %*1op2 4*Delete ?*Di"pla2 @*0ename
3*Di"pla2 )e"cription &*Save 10*0e"tore 11*Move ...

4pt 4!$ect 92pe Attri!'te 9e/t
CMS7D9A0-P >-6<. P-(D9A MD< Me""age Ph2"ica
5A:4A:A0-P >-6<. P-(D9A 2a!oa!arfp Ph2"ical fi
5A:4A:ACCP >-6<. P-(D9A 1ontain" 5A:4A:A0-P )elete) mo)el )at
5A:4A:A00< >-6<. <- MD< A!o 'p)ate (EEA:4A:A)
5A:4A:A01< >-6<. <- MD< A!o action rtv (EEA:4/EE181/EEA:4
5A:4A:A0#< >-6<. <- MD< A!o action rtv (EEA:4/EEA:4A:A,P)
5A:4A:A0%< >-6<. <- MD< A!o action rtv (EEA:4/EE0.-1FD +
5A:4A:A04< >-6<. <- MD< A!o 'p)ate (EEA:4/EEA:4A:A)
More...
Parameter" or comman)
***+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-%*./it -4*Prompt -?*0efre"h -D*1reate
-&*0etrieve
#1M is terminated )y pressing +AIT $38' function =ey
So*rce -ntry .tility (S-."
Source +ntry 6tility is a de"elopment tool that allo;s the entry> re"ie; and display of program
source statements and date descriptions specification for "arious specification types.
(unctions of %EU
S+6 function is allo; the user to:
7reate / add ne; mem)ers
&e"ise e<isting mem)ers
Cro;se / 7opy the e<isting mem)ers
S+6 can )e in"o=ed through one of the follo;ing methods:
,. Select option M4N from the programmers menu
-. Select option M-N from the .or= ;ith mem)ers display in #1M to )ro;se through the
source mem)ers
8. Select option M4N from the .or= ;ith mem)ers display in #1M to edit source mem)ers
4. +nter command MST&S+6N from any command entry line.If the command is In"o=ed
;ithout a Eualified mem)er name> a list of all the mem)ers in the file is displayed.
(ata ,ile .tility ((,."
1ata 3ile 6tility $136' is a de"elopment tool that allo;s the entry> re"ision and )ro;se of data
records from the data)ase files.
20 of %4&
(unctions of '(U
136 functions are to allo; for the creation of applications for the manipulation of data records.
These applications can then )e e<ecuted to manipulate data records.
Manipulation of data records includes adding or inserting ne; records and changing> deleting or
displaying e<isting records
%S/400 security allo;s for the restriction of access to the selected files )ound )y the user
Securiry.
%dditional recommended reading Material:
,. S70(-,88-0- S+6 6serNs ?uide and &eference.
-. S70(-,88(-0- #1M 6serNs ?uide and &eference.
8. S70(-,840-0- S1% 6serNs ?uide and &eference.
4. S70(-,4,5-0- &!6 6serNs ?uide and &eference.
4. S74,-(5,4-08 %S/400 2uery / 400 6serNs ?uide.
2% of %4&
Chapter II %&ibraries
% !i)rary is an %S/400 o)*ect that ser"es as a repository for other o)*ects. It is not a parititioned
data set )ut rather an inde< to other o)*ects. The li)rary can ne"er )ecome MfullN as it has no
definite siFe. ?enerally a li)rary can contain any set of o)*ects grouped for a specific purpose.
&ibrary Categories
The li)raries can )e categorised ac ICM supplied li)raries> user-defined li)raries .
IB) %upplie& "ibraries are:
,. 2SGS 7ontains ICM supplied programs and data.This li)rary cannot )e
deleted or renamed. This li)rary is o;ned )y system security officer.
-. 2SGS85 7ontains o)*ects reEuired to run soft;are de"eloped on the
System/85.The soft;are ;ould then )e e<ecuted in MSystem/8
modeN.
8. 2SGS8 7ontains o)*ects reEuired to run soft;are de"eloped on the
System/8. The soft;are ;ould then )e e<ecuted in MSystem/8
modeN
4. 2?#! 7ontains ICM supplied o)*ects for general use. This li)rary is
present in e"ery li)rary list unless e<plicitly remo"ed.
4. 2T+M# 7reated automatically for e"ery *o). The li)rary hold temporary
o)*ects such as ;or= files. This li)rary can )e accessed )y the *o)
that created it. This li)rary ;ould )e deleted ;hen the *o) is
terminated.
5. 2S&D Ser"ice engineer li)rary.
7. 2&7! &eclaim storage li)rary .It is created ;hen a &eclaim Storage
command$&7!ST?' is e<ecuted and ;ould contain o)*ects that
;ere purged )y the command.
. 2&#? &eport #rogram ?enerator li)rary. It contains &#? compiler and the
o)*ects reEuired to enter>edit and compile &#? programs.
22 of %4&
(. 27C! 7OCO!/400 li)rary.It contains 7OCO! compiler and the o)*ects
reEuired to enter> edit and compile 7OCO!/400 programs.

,0. 2IC6 Interacti"e data )ase utilities li)rary.
,,. 2I9S Interacti"e ;or=station support li)rary that contains all ICM supplied
o)*ects that are reEuired to transfer data )et;een %S/400 and #7s.
User*&efine& libraries
These li)raries are created )y users for specific application and uses.6ser-defined
li)rary name may )e use-defined alphanumeric name not more than ,0
characters. !i)rary names may not ha"e em)edded )lan=s and must not )egin
;ith a num)er.
&ibrary &ist:
It is a list of li)raries associated ;ith each *o) ;hich defined the operational
)oundaries of a *o). +ach *o) has a default li)rary list ;hich may )e modified if
reEuired.+ach li)rary list consists of four parts. They are:
%!stem librar! section - This section consists the li)raries containing o)*ects
used )y the system for regular processing functions. The num)er of li)raries in this
section cannot e<ceed ,4.
ro&uct librar! section - This section contains li)raries that are reEuired to
support high le"el languages and utilities other than 2SGS.
7urrent li)rary section H This section contains the Mcurrent li)raryN as identified
)y the *o).
User librar! section H This section contains li)raries reEuired )y system users
and applications such as non-ICM application solutions.The num)er of li)raries
in this section cannot e<ceed -4.
&ibrary commands:
7ommon commands associated ;ith li)raries are:
7&T!IC 7reate li)rary
1S#!IC 1isplay li)rary
1!T!IC 1elete li)rary
&ibrary &ist Commands:
7ommon commands associated ;ith li)rary lists are:
1S#!IC! 1isplay li)rary list
2$ of %4&
%11!IC!+ %dd li)rary list entry
&MD!IC!+ &emo"e li)rary list entry
&#!!IC! &eplace li)rary list
7@?76&!IC 7hange current li)rary
%dditional &ecommended &eading Material
,. ?74,-(0--0, %S/400 System 7oncepts.
Chapter III: AS/400 !atabase
In %S/400> the data )ase is integrated into the operating system and is the licensed internal code
of the %S/400 system. There is no reEuirement to install or maintain a separate data)ase
management product. %ny program that ;ants to store or use data on the %S/400 system uses
integrated data)ase
'ile "ypes:
The different types of files that form %S/400 data)ase ar
24 of %4&
,. 'atabase files are files (including distributed files) whose associated data
is stored permanently in the system.
i+ h!sical files
,. 1ata files
-. Source files
ii+ "o$ical files
-. 'evice files are files that pro"ide access to e<ternally attached de"ices such as displays>
printers> tapes> dis=ettes> and other systems that are attached )y a communications line.
The de"ice files supported are:
H 'ispla! files> ;hich pro"ide access to display de"ices
H rinter files> ;hich descri)e the format of printed output
H ,ape files> ;hich allo; access to data files on tape de"ices
H 'is#ette files> ;hich pro"ide access to data files on dis=ette de"ices
H Inters!stem communications function $OS/400-I73' files> hereafter referred to
as I73 files> ;hich allo; a program on one system to communicate ;ith a
program on the same system or another system
8. %ave files are files that are used to store sa"ed data on dis= $;ithout reEuiring dis=ettes or
tapes'.
4. 'istribute& 'ata )ana$ement files $11M files' are files that allo; access to data files
stored on remote systems.
+ach file type has its o;n set of uniEue characteristics that determines ho; the file can )e used
and ;hat capa)ilities it can pro"ide. The concept of a file> ho;e"er> is the same regardless of
;hat type of file it is. .hen a file is used )y a program> it is referred to )y name> ;hich
identifies )oth the file description and> for some file types> the data itself. This information is
designed to help you understand the common characteristics of all file types so you can use the
files to their full capa)ilities.
!atabase 'iles:
Q The O)*ect type is Ofile
Q It contains description of ho; input data is to )e presented to programs from internal
storage and ho; output data is to )e presented to internal storage from a program
Access paths:
%rri"al SeEuence %ccess #ath :
Q It is )ased on the order in ;hich the records arri"e and are stored in the file
Q SeEuentially> ;here each record is ta=en from the ne<t seEuential physical position in the
file
Q 1irectly )y relati"e record num)er> ;here the record num)er is identified )y its position
from the start of the file
:eyed SeEuence %ccess #ath:
2. of %4&
Q It is )ased on the contents of the =ey fields as defined in 11S
Q This type of access path is updated> ;hene"er records are added or deleted.
Physical 'iles:
Q % description of ho; data is to presented to or recei"ed from a program and ho; data is
actually stored in the data)ase
Q % #hysical file contains one record format and one or more mem)ers
7omponents of a #hysical 3ile
Q O)*ect @eader This contains the regular o)*ect information
Q &ecord 3ormat 1escri)es the format in ;hich the records are stored
Q %ccess #ath 1escri)es the order in ;hich records are to )e retrie"ed
Q 1ata Mem)er 7ontains data
1ata 1escription Specification for a #hysical 3ile:
Q 3ile !e"el entries $optional':
3ile le"el entries gi"e the system information of the entire file including ;hether
the =ey is uniEue
Q &ecord !e"el entries :
?i"e the system information a)out the specific record format in the file
Q 3ield !e"el entries :
The field names and field lengths are specified along ;ith an optional te<t
description for each field
Q :ey 3ield !e"el entries :
The field names used as =ey fields specified
11S :ey;ords:
Q 3ile !e"el : 6niEue> !I3O> 3I3O> 373O> &ef
Q &ecord !e"el : 3ormat> Te<t
Q 3ield !e"el : %lias> &effld> Te<t> +dtcde> 1atfmt> 1atsep> %l;null> 7hec=$%C>
M+> M3'> 7mp/7omp> 7ol@dg> 1ft> &ange> Timfmt> Timsep> Dalues
Q :ey-field !e"el : %)s"al> 1escend> Signed> 6nsigned
7haracteristics of a #hysical 3ile
Q Ma<imum no. of fields that can )e defined in a #3 is 000
Q Ma<imum no. of mem)ers that a single #3 can ha"e is 8->755
Q Ma<imum siFe of a mem)er in a #3 is 8->755 )ytes
Q Ma<imum length of a file name is ,0 characters
Q Ma<imum length of a record format name is ,0 characters
Q Ma<imum length of a field name is ,0 characters
Q Ma<imum num)er of =ey fields in a #3 is -00
Die; of a #hysical 3ile:
3ile !e"el 6niEue
&ecord !e"el & &ecfmt
3ield !e"el 9ame -0
%ge ,0 #
#hone ,0 # 8
:ey-3ield !e"el = 9ame
2* of %4&
&ogical 'iles:
Q !ogical 3ile is an %S/400 o)*ect of type Ofile and attri)ute !3
Q 6sed to arrange data from one or more physicals into different formats and seEuences
Q !ogical file does not contain any data> )ut pro"ides MDI+.SN of the data to satisfy end-
usersN needs
Q % logical file can contain up to 8- record formats and can o)tain data from - to 8-
physical files
7omponents of a !ogical 3ile:
Q O)*ect @eader This contains the regular o)*ect information
Q &ecord 3ormat 1escri)es the format in ;hich the records are stored
Q %ccess #ath 1escri)es the order in ;hich records are to )e retrie"ed
Q 1ata Mem)er 7ontains 1ata
1ata 1escription Specification for a !ogical 3ile:
Q 3ile !e"el entries $optional':
3ile le"el entries gi"e the system information of the entire file including ;hether
the =ey is uniEue
Q &ecord !e"el entries :
?i"e the system information a)out the specific record format in the file
Q 0oin !e"el entries :
?i"e the system information a)out physical files used in 0OI9 !ogical 3ile $9ot
applica)le for 9on-0oin !ogical 3ile'
Q 3ield !e"el entries :
The field names and field lengths are specified along ;ith an optional te<t
description for each field
Q :ey 3ield !e"el entries :
The field names used as =ey fields specified
Q Select / Omit !e"el entries :
?i"e the system information a)out> ;hich records are to )e returned to the
program ;hen processing the file
11S :ey;ords:
Q 3ile !e"el : 6niEue> !I3O> 3I3O> 0dft"al$0!3'
Q &ecord !e"el : 0file $0oin 3ile'> #file $#hysical file'> Te<t
Q 0oin !e"el : 0dupseE> 03ld> 0oin
Q 3ield !e"el : %lias> &effld> +dtcde> 1atfmt> 1atsep>
7hec=$%C> M+> M3'> 7mp/7omp> 7ol@dg> 1ft> &ange> Timfmt> Timsep>
Dalues> 0&ef
Q :ey-field !e"el : %)s"al> 1escend> Signed> 6nsigned
Q Select/Omit !e"el : 7omp> &ange> Dalues> %ll
Die; of a !ogical 3ile:
&ecord !e"el & #3&ecfmt, #3I!+$#3,'
:ey-field !e"el : 7ustR
27 of %4&
"ypes () &ogical 'iles
Q 9on - 0oin !ogical 3iles
Q 0oin !ogical 3iles
*oin &ogical 'ile
Q 0oin logical files are &+%1 only files and may not )e used in 6#1%T+ or 1+!+T+
processing
Q Support only Inner and !eft Outer 0oins. Outer 0oin processing is not supported
Q They may refer - to 8- physical files
Q %ny =ey field specified must )e included in the primary file
Q Select / Omit criteria may )e specified for any field in a 0oin !ogical 3ile
1ata 1escription Specification for 0oin !ogical 3iles:
Q 3ile !e"el entries
Q 0oin !e"el entries
Q &ecord !e"el entries
Q 3ield !e"el entries
Q :ey 3ield !e"el entries
Q Select and Omit 3ield !e"el entries
Die; of a 0oin !ogical 3ile:
& 0oinrcd
03I!+$#3, #3-'
0 0OI9$ , - '
03!1$ +9O +96M '
+num 0&+3$,'
+name 0&+3$,'
1ept 0&+3$-'
: +num
S +num comp ?T ,0,0
Types of 0oin !ogical 3ile:
There are 8 types of !ogical 3iles
-+ Natural Join or Inner Join : .hen this type of a 0!3 is read only the
matching records of )oth the files appear
.+ "eft Outer Join : %ll the records from the primary file appear. Missing
secondary records $records for ;hich no match is found' are filled ;ith default
"alues. This is enforced )y using 013TD%! =ey;ord
8. %elf Join: 0oining a file to itself
+on , *oin &ogical 'ile:
Q % 9on-0oin logical file can either )e a simple logical file ;hich contains only one record
format or a multiple format logical file ;hich contains more than one record format
2& of %4&
Q 9on-0oin logical files can )e used for &+%1> .&IT+ and 6#1%T+ processing
Q 7an *oin a ma<imum of 8- #hysical files
Q
1ata 1escription Specification for 9on-0oin !ogical 3iles:
Q 3ile !e"el entries
Q &ecord !e"el entries
Q 3ield !e"el entries
Q :ey 3ield !e"el entries
Q Select and Omit 3ield !e"el entries
&epeat steps - through 4 for each record format in the file

Die; of a 9on-0oin !ogical 3ile:
&ecord !e"el & #3&ecfmt, #3I!+$#3,'
3ield le"el 7ustR
:ey-field !e"el : 7ustR
&ecord !e"el & #3&ecfmt- #3I!+$#3-'
3ield le"el 7ustR
:ey-field !e"el : 7ustR
'ield -e)erence 'iles:
Q % physical file that contains no data> )ut only description of fields.
Q It is used as a reference for the field descriptions of other files
Importance o) using 'ield -e)erence 'iles
It enforces the naming con"ention
Q &educes programmerNs ;or= load $define once> use often'
Q It defines in one place all data elements used in the application for all users
+aming Conventions
Q The file name> record format name> field name cannot )e more than ,0 characterNs
Q The first character should )e alpha)etic
Q 3ield names should )e uniEue in a record format
Q &ecord format names and mem)er names should )e uniEue in a file
Q 3ile names should )e uniEue in a li)rary
%dditional &ecommended &eading Material
,. S74,-(54(-0- %S/400 1ata)ase ?uide
-. S74,-(54-0- %S/400 1ata Management ?uide
20 of %4&
$0 of %4&
Chapter I.: !ata !escription Speci)ication #!!S$
1ata 1escription Specifications$11S' defines all attri)utes of a file and ;hich are coded
in a system-defined format. These definitions or specifications can )e maintained
e<ternally and independent of programs or other dependent files. These statements are
entered into a system-defined format as a source file ;hich is created or compiled as a file.1ata
records are then ;ritten into or retrie"ed from this file using certain %pplication
1e"elopment Tools or though use-defined application programs.
11S are coded and entered into a system-defined format =no;n as M%N specifications.
+ach file is coded as a separate source mem)er.N%N specifications are used to code the
follo;ing types of files.The positions and entries are uniEue and may differ for the
different files.
#hysical files.
!ogical files
1isplay $or ;or=station' files and
#rinter files
!e)ining Physical 'iles
The 1ata 1escription Specifications$11S' for #hysical 3iles are defined in data
specifications in the follo;ing layout:
ositions Name Entr! Explanation
,-4 SeEuence
num)er
9one This is an optional column and may )e used to
identify> mar= or tag source statements.
5 3orm type M%N 1enotes M%N Specification
7 7omment MON 1enotes a comment line. 7omments may )e entered
)et;eenpositions and 0.
-,5 &eser"ed Clan= This position Is not used for physical files and
must )e )lan=.
,7 Type of 9ame M&N
M M
M:N
&ecord format name.
3ield name.
=ey field name.
,(-- 9ame &ecord name or field name or =ey field name.
-( &eference & 1enotes that a definition and attri)utes of the
named field are to )e referenced from a pre"iously
defined field.
$% of %4&
ositions Name Entr! Explanation
80-84 !ength !ength of the field.
The follo;ing are the "alid lengths for "arious
types of fields.
7haracter , to 8-755 @e<adecimal
, to 8-755
Cinary , to (
9umeric , to 8,
84 1ata Type #
S
C
3
%
@
!
T
B
#ac=ed decimal
Boned decimal
Cinary
3loating point
7haracter
@e<adecimal
1ate
Time
Timestamp.
85-87 1ecimal
position
9um)er of decimal
positions
8 6sage MCN
M M
Coth input and output
1efaults to C
8(-44 !ocation This column is reser"ed and is not used )y physical
files.
44-0 :ey;ords.
Components o) !!S
11S definitions are a serious of statement that are entered as source statements. These
statements may )e entered in to the follo;ing le"els of definitions.
3ile le"el =ey;ords are entered at the file Eualify the named file and are applica)le to all
the record and field definition that follo;.
&ecord format le"el =ey;ords are entered at the record format le"el Eualify the named
record format and are applica)le to all the field definitions contained ;ithin the record
format.
0oin le"el =ey;ords are used to specify parameters that are used to *oin one or more files
in to a single record format. These =ey;ords are "alid only in *oin logical files.
3ield le"el =ey;ords are used to Eualify the named field.
:ey field le"el =ey;ords are used to Eualify the =ey or the access seEuence of a file. 3or
e<ample> 69I26+ can )e specified to pre"ent e<istence of duplicate =ey "alues in a file.
Select/Omit le"el =ey;ords are used to specify rules for the selection of records from a
physical file> these =ey;ords are "alid only in logical files.
Namin$ Conventions
$2 of %4&
The normal rule for naming of files> record formats and fields is a ,0 character alphanumeric
"alue ;hich does not contain em)edded )lan=s and does not start ;ith a numeric "alue.
@o;e"er> some high le"el languages li=e &#?/400 supports only character file and record
format names and 5 character field names.
Physical 'ile /ey0ords
:ey;ords used in physical files are "ided into 4 parts. They are:
3ile le"el :ey;ords
&ecord le"el :ey;ords
3ield le"el :ey;ords
:ey-field le"el :ey;ords
There are in all o"er 84 =ey;ords associated ;ith physical files.These =ey;ords are used to
pro"ide further Eualification to the file> record format> field or =ey field.Some of the more
commonly used =ey;ords are:
'ile &evel /ey0ords
373O 3irst 7hanged 3irst Out
.hen duplicate =ey e<ists in a file this =ey;ord is used to specify that the record that ;as
changed earliest is to )e retrie"ed.
3I3O 3irst In 3irst Out
.hen duplicate =ey e<ists in a file this =ey;ord is used to specify that the record that ;as
;ritten earliest is to )e retrie"ed.
!I3O !ast In 3irst Out
.hen duplicate =ey e<ists in a file this =ey;ord is used to specify that the record that ;as
;ritten most recently is to )e retrie"ed.
&+3 &eference
6sed to indicate the name of another file from ;hich field references ;here"er indicated are
to )e retrie"ed.
69I26+ 6niEue :ey
6sed to indicate that records ;ith duplicate =ey "alues ;ill not )e allo;ed in this file.
-ecord &evel /ey0ords
T+AT Te<t
6sed to assign descripti"e te<t for the record format.
'ield &evel /ey0ords
%!I%S %lias 9ame
6sed to indicate the alias name for the named field.
%!.96!! %llo; 9ull "alue
6sed to indicate that the field may )e ;ritten ;ith 96!! "alue $)lan=s for character fields
and Feroes for numeric fields'
$$ of %4&
7@+7: 7hec= "alues
6sed to pro"ide certain "alidity rules for the named field.The "alues associated ;ith this
=ey;ord are as follo;s:
%C %llo; )lan=s
M+ Mandatory +ntry
M3 Mandatory 3ull
M,0 Modulus ,0 "alidation
M,03 Modulus ,0 "alidation$ICM "ariation'
M,, Modulus ,, "alidation
M,,3 Modulus ,, "alidation$ICM "ariation'
+<ample> 7@+7:$M+'
7M#/7OM# 7ompare Dalue
6sed to pro"ide "alidation to specify that the named field must contain "alue specified in this
parameter. +<ample> 7OM#$O+2 M%N'
7O!@1? 7olumn @eading
6sed to pro"ide descripti"e te<t a)out the named field. This te<t is used ;hen the field is
used in certain application de"elopment tools such as 1ata 3ile 6tility$136' and 2uery. 6p
to three strings of -0 characters each can )e specified.
1%T3MT 1ate 3ormat
6sed to define the format $namely one of either> GG/MM/11 or MM/11/GG or
11/MM/GG' in ;hich date is to )e stored in the named field.
1%TS+# 1ate separator
6sed to identify the character used to separate the elements of a date.
13T 1efault Dalue
6sed to nominate a default "alue ;hen the record is ;ritten.
+1T71+ +dit 7ode
6sed to identify a system-supplied editing rule for the named field. &ules could include Fero
suppression> Fero )alance> sign etc.
&%9?+ &ange
6sed to specify a range of "alues that are allo;ed to )e input in to the named field.
&+33!1 &eferenced 3ield
6sed to reference a field from an earlier referenced file ;hose length and attri)utes are to )e
attached to the named field.
&+33!1$3!1%'
&+33!1$&+73MT0,/3!1%'
&+33!1$&+73MT0,/3!1% 3I!+%'
&+33!1$&+73MT0,/3!1% O!IC!/3I!+%'
&+33!1$&+73MT0,/3!1% !IC%/3I!+%'
T+AT Te<t
6sed to assign descripti"e te<t to the named field to )e used in all future references of the
named field. +<ample> T+AT$M7ustomer codeN'.
TIM3MT Time 3ormat
6sed to define the format in ;hich time is to )e stored in the named field.
TIMS+# Time Separator
$4 of %4&
6sed to identify the character to )e used to separate the elements namely hour>minute and
second of time.
D%!6+S Dalues
6sed to assign one or more "alues that are allo;ed as "alid input in to the named field.
+<ample> D%!6+S$M%N> MCN> M7N> M1N> M+N'.
/ey 'ield &evel /ey 0ords
%CSD%! %)solute Dalue
6sed to indicate that ;hen retrie"ing records from the named file> the sign of the =ey field is
to )e ignored and only the a)solute "alue of the field is to )e used for purposes of ordering
seEuences.
1+S7+91 1escending SeEuence
6sed to specify an ordering seEuencing for the retrie"al of records from the named file.;hen
retrie"ing records from named file> the records ;ould )e seEuenced in the descending order
of the named =ey field.
SI?9+1 Signed
6sed to specify that the sign of the named =ey-field is to )e considered for purposes of
ordering seEuence ;hen retrie"ing records from the named file.
$. of %4&
!e)ining &ogical 'iles
The 1ata 1escription Specifications$11S' for !ogical 3iles are defined in data specification in
the follo;ing.


ositions Name Entr! Explanation
,-4 SeEuence
9um)er
9one This is an optional column and may )e
used to identify mar= or tag source
statements.
5 3orm Type M%N 1enotes M%N specification
7 7omment MON 1enotes a comment line .7omments may
)e entered )et;een positions and 0.
-,5 7onditioning Clan= This position is not used for logical files
and must )e )lan=
,7 Type of 9ame M&N
0
M M
M:N
MSN
MON
&ecord format name
0oin Specification
3ield name
:ey field 9ame
Select 7riteria
Omit 7riteria
, &eser"ed Clan= This position is not used for logical files
and must )e )lan=
,(-- 9ame &ecord name or field name or =ey field
name
-( &eference & 1enotes that a definition and attri)utes of
the named filed are to )e referenced from a
pre"iously defined field.
80-84 !ength !ength of the field the follo;ing are the
"alid lengths for "arious types of fields.
7haracter , to 8-755
@e<adecimal , to 8-775
Cinary , to (
9umeric , to 8,
84 1ata Types #
S
C
3
%
@
!
#ac=ed decimal
Boned decimal
Cinary
3loating point
7haracter
@e<adecimal
1ate
Time
$* of %4&
ositions Name Entr! Explanation
T
B
Timestamp
85-87 1ecimal
#osition
9um)er of decimal positions.
8 6sage MCN Coth input and output
1efault to C
8(-44 !ocation Clan= Thos column is reser"ed and is not used )y
logical files.
44-0 :ey;ords
&ogical )ile /ey0ords

:ey;ords used in logical files are di"ided into four parts> namely >
3ile le"el =ey;ords
&ecord le"el =ey;ords
3ield le"el =ey;ords
:ey-field =ey;ords

There are in all o"er 44 =ey;ords associated ;ith logical files .These =ey;ords are used to
pro"ide further Eualification to the file > record format> field or =ey fields. Some of the more
commonly used =ey;ords are e<plained in the su)seEuent section.
'ile &evel /ey0ords
1G9S!T 1ynamic Select
6sed to instruct that selection of records according to the criteria specified in the file must )e
maintained dynamically as and ;hen records are ;ritten into or retrie"ed from the data)ase
file that is pointed to )y the logical file.
373O 3irst 7hanged 3irst out
.hen duplicate =ey e<ists in a file this =ey;ord is used to specify that the record that ;as
changed earliest is to )e retrie"ed.
3I3O 3irst In 3irst Out
.hen duplicate =ey e<ists in a file this =ey;ord is used to specify that the record that ;as
;ritten earliest is to )e retrie"ed.
!I3O !ast In 3irst Out
.hen duplicate =ey e<ists in a file this =ey;ord is used to specify that the record that ;as
;ritten most recently is to )e retrie"ed.
69I26+ 6niEue :ey
6se to indicate that records ;ith duplicate =ey "alue ;ill not allo;ed in this file.
$7 of %4&
-ecord &evel /ey0ords
#3I!+ #hysical 3ile
6sed to name the physical file that is )eing pointed to )y the named logical file
.This =ey;ord is mandatory for e"ery logical file definition.
T+AT Te<t
6sed to assign descripti"e te<t for the record format.
3ield !e"el :ey;ords
%!I%S %lias 9ame
6sed to indicate the alias name for the named field .
7@+7: 7hec= Dalues
6sed to pro"ide certain "alidity for the named field. The "alue associated ;ith this =ey;ord
are as follo;s:
%C %llo; Clan=s
M+ Mandatory +ntry
M3 Mandatory 3ull
M,0 Modulus ,0 Dalidation
M,03 Modulus ,0 Dalidation$ICM "ariation'
M,, Modulus ,, Dalidation
M,,3 Modulus ,, Dalidation$ICM "ariation'
+<ample>7@+7: $M+'.
7M#/7OM# 7ompare Dalue
6sed to pro"ide "alidation to specify that named field must contain "alue specified in this
parameter.+<ample>7OM#$O+2N%N'
7O@1? 7olumn @eading
6sed to pro"ide descripti"e te<t a)out the named field.This te<t is used ;hen the field is used
in a certain application de"elopment tools such as 1ata 3ile 6tility$136'and 26+&G.6pto
three strings of -0 characters each can )e specified .
1%T3MT 1ate 3ormat
6sed to define the format $namely one of either >GG/MM/11 or MM/11/GG or
11/MM/GG'in ;hich date is to )e stored in the named field.
1%TS+# 1ate Separator
6sed to identify the character used to separate the elements of a date.
+1T71+ +dit 7ode
6sed to identify a system-supplied editing rule for the named field.&ules could include Fero
suppression>Fero )alance >sign>etc.
T+AT Te<t
6sed to assign descripti"e te<t to the named filed to )e used in all future references of the
named filed.+<ample >T+AT$M7ustomer 7odeN'.
TIM3MT Time 3ormat
6sed to define the format in ;hich time is to )e stored in the named field.
TIMS+# Time Separator
6sed to identify the character to )e used to separate the elements namely hour>minute and
second of time.
$& of %4&
D%!6+S Dalues
6sed to assign one or more "alues that are allo;ed as "alid input into the named field.
+<ample>D%!6+S$M%NNCNN7NP1NN+N'.
/e! (iel& "evel /e!wor&s
%CSD%! %)solute Dalue
6sed to indicate that ;hen retrie"ing records from the named file the sign of the =ey-field is
to )e ignored and only the a)solute "alue of the field is to )e used for purpose of ordering
seEuences.
%!! %ll
6sed in con*unction ;ith Select and Omit criteria specification to indicate that all records not
fulfilling the Select or Omit criteria must )e selected or omitted as the case may )e.
1+S7+91 1escending SeEuence
6sed to specify an ordering seEuence for the retrie"al of records from the named file..hen
retrie"ing records from the named file>the records ;ould )e seEuenced in descending order of
the named =ey-field.
SI?9+1 Signed
6sed to specify that the sign of the named =ey-field is to )e considered for purposes of
ordering seEuence ;hen retrie"ing records from the named file.
69SI?9+1 6nsigned
6sed to specify that the sign of the named =ey-field is to )e ignored for purposes of ordering
seEuence ;hen retrie"ing records from the named file.
*oin &ogical 'iles
% *oin logical is a logical file ;hich contains definitions reEuired to *oin t;o or more
different files )ased on certain user-defined *oin conditions.
The first file )eing *oinng is called the M#rimary fileN ;hile the other are called
MSecondary filesN.The primary file and atleast one of the secondary files must )e a
physical file.
.hen accessing a *oin file record> the system internally reads a record from the primary
file and pic=s up the corresponding record from the secondary file )ased on the user-
defined *oin criteria and then presents the com)ined data to the accessing program in one
consolidated record.
If reEuired> ;hen specifying the primary file and secondary file >only certain fields from
either file may )e selected for *oin file record format rather than all the fields from )oth
the files. Cut all the fields indicated in *oin criteria must )e selected .
Special consideration
O Gou cannot change a physical file using a *oin logical file.
O Gou can specify only one record format in *oin logical file.
O 7ommitment control cannot )e used ;ith *oin logical files.
$0 of %4&
*oin &evel /ey0ords
The =ey;ords used in *oin logical files are:
03I!+ 0oin 3ile
Identifies the names of the t;o files )eing *oined.This =ey;ord is specified at the
record le"el.
03!1 0oin 3ield
6sed to name the fields that are to )e used for purposes of *oining the primary file
and secondary file.0oin fileds must ha"e the same attri)utes.This =ey;ord is
specified at the record le"el.
0OI9 0oin
Identifies the names of the t;o files )eing *oined.This =ey;ord is specified at the
*oin le"el.
0&+3 0oin &eference 3ile
Identifies the file from ;hich the named fields is to )e retrie"ed from.This
=ey;ord is specified at the field Hle"el.
40 of %4&
E1amples o) database )iles in !!S)
E1ample o) a )ield re)erence )ile:
This e<ample defines all of the fields used in an application and refers to fields only ;ithin the
field reference file itself. The follo;ing =ey;ords are important in the e<ample:
7O!@1?
+1T71+$B'
&+33!1
&+3S@I3T
T+AT
The follo;ing field reference file $M!?&+3#' descri)es all fields used )y any program in the
application. The other files use the fields in this file.
(i$ure -+ ''% for a (iel& 0eference (ile
00010A>> -<D0.- M<70.-P MA6<6F7 <6S9 -6.<D 0.-.0.F1. -6<.
000#0A (1)0 M<70.-0 9.C9(BMailing <i"t -iel) 0eferenceB)
000%0A A19F=M ? 0 14<8D7(BAcco'ntB BF'm!erB)
00040A .D91D.(G)
000?0A A1995P 1 0 14<8D7(BAcctB B92peB)
000D0A 9.C9(BAcct 92pe 1*:'" #*7vt H
000@0A %*4rg 4*Sch ?*Pvt &*4thB)
00030A FAM. 13 14<8D7(BFameB)
000&0A 0.-S86-9(C)(4)
00100A ADD0 0 (2) (2)0.--<D(FAM.)
00110A 14<8D7(BA))re""B)(3)
001#0A 1695 0 (2) (2)0.--<D(FAM.)
001%0A 14<8D7(B1it2B) (3)
00140A S9A9. # 14<8D7(BStateB)
001?0A G6P ? 0 14<8D7(BG6PB B1o)eB)
001D0A .D91D.(C)
001@0A :A9F=M D 0 14<8D7(B:atchB BF'm!erB)
00130A .D91D.(G)
001&0A 90F95P 1 14<8D7(B9ran"B B92peB)
00#00A 9.C9(B9ran" 92pe A*A)) H
00#10A 1*1hange D*DeleteB)
00##0A CA19FM 0 0.--<D(A19F=M)
00#%0A CA1999P 0 0.--<D(A1995P)
00#40A CFAM. 0 0.--<D(FAM.)
00#?0A CADD0 0 0.--<D(ADD0)
00#D0A C1695 0 0.--<D(1695)
00#@0A CS9A9. 0 0.--<D(S9A9.)
00#30A CG6P 0 0.--<D(G6P)
00#&0A 90FF=M ? 0 14<8D7(B9ran"actionB BF'm!erB)
00%00A .D91D.(G)
00%10A M<7<I1 % 0 14<8D7(B<ocB B1ontrolB)
00%#0A 9.C9(B1ontrol F'm!er ="e) for H
00%%0A recor) locingB)
"e$en&:
4% of %4&
1-2 !i=e all physical files> a field reference file has only one record format. The & in position
,7 specifies that M!?&+3& is the record format name.
1.2 The &s in position -( and &+33!1 in positions 44 through 0 specify that the fields %11&
and 7ITG are to ha"e the same attri)utes as 9%M+.
132 Specifying 7O!@1? for %11& and 7ITG o"errides the 7O!@1? attri)ute for 9%M+>
;hich other;ise ;ould ha"e )een in effect.
142 Specifying &+3S@I3T for 9%M+ ;ill cause the =ey)oard shift specified $A' to )e used
;hen this field $9%M+' is referred to in a display file.
E1ample o) a physical )ile 0ith a ne0 record )ormat:
The &+3 =ey;ord is important in the follo;ing e<ample. This file has one record format. The
names of all fields in the record format are specified. This e<ample uses fields in a reference file
$&+3 =ey;ord' and uses a =eyed-seEuence access path.
The follo;ing physical file $called 76SMST# for customer master physical file' descri)es the
fields physically present in the data)ase.
(i$ure .+ ''% for a h!sical (ile
00010A>
000#0A> SAMP<. P85S61A< -6<.(1=SMS9P)
000%0A>
00040A (1) 0.-(M<70.-P)
000?0A (2) 0 1=SMS9 9.C9(B1'"tomer Ma"ter 0ecor)B)
000D0A A19F=M 0 (3)
000@0A FAM. 0 (3)
00030A ADD0 0 (3)
000&0A 1695 0 (3)
00100A S9A9. 0 (3)
00110A G6P 0 (3)
001#0A (4) S.A018 10 0
001%0A (4) 10D<M9 3 #
00140A (5) I A19F=M
"e$en&:
1-2 %t the file le"el> the &+3 =ey;ord refers the OS/400 program to the physical file M!?&+3#>
;hich is a field reference file for this data)ase.
1.2 %t the record le"el> & in position ,7 specifies that 76SMST is the record format name of the
record in this file. $There can only )e one record format in a physical file.'
132 %t the field le"el> &s in position -( specify that the attri)utes of fields of the same name in
the &+3 file are to )e used as attri)utes of these fields.
142 The fields S+%&7@ and 7&1!MT are not defined in M!?&+3#I therefore> their field
attri)utes are specified here.
152 %t the =ey field le"el> : in position ,7 specifies that %7T96M is the =ey field for the file.
42 of %4&
E1ample o) a logical )ile speci)ying multiple )ormats and ne0 2eys:
The #3I!+ =ey;ord is important in the follo;ing e<ample. The e<ample uses ne; field
specifications and pro"ides t;o record formats. +ach record format pro"ides a different "ie; of
the associated physical file and uses a =ey different from the associated physical file.
(i$ure 3+ ''% for a "o$ical (ile %pecif!in$ New /e!s
00010A>
000#0A> SAMP<. <4761A< -6<.
000%0A
00040A 0 1=SMS91 (1)P-6<.(1=SMS9P)
000?0A A19F=M
000D0A FAM.
000@0A S9A9.
00030A <AS9FAM. 6 (3)SS9(FAM. 3 10)
000&0A (2) I A19F=M
00100A>
00110A 0 1=SMS9# (1)P-6<.(1=SMS9P)
001#0A A19F=M
001%0A FAM.
00140A G6P
001?0A I >F4F.
001D0A (2) I FAM.
"e$en&:
1-2 The t;o record formats $76SMST, and 76SMST-' in this logical file are )ased on the same
physical file $76SMST#'.
1.2 &ecord format 76SMST, has a =ey different from record format 76SMST-> pro"iding the
application program ;ith a different seEuence of the same records.
132 The !%ST9%M+ field is a su)string of the field 9%M+. The usage I in position 8 must )e
specified since this is not a *oin logical file.
E1ample o) a logical )ile speci)ying a ne0 record )ormat:
The 69I26+ =ey;ord is important in the follo;ing e<ample. The e<ample specifies a record
format different from the associated physical file.
The follo;ing logical file $called 76SMST!- for customer master logical file t;o' uses some of
the fields in the physical file 76SMST#. %nother logical file could name all fields> name fields
in other physical files as ;ell> concatenate fields> change the order of fields> rename fields> or
choose different =ey fields. In this logical file> the programmer merely omitted some fields from
the physical file.
(i$ure 4+ ''% for a "o$ical (ile
00010A>
4$ of %4&
000#0A> SAMP<. <4761A< -6<. (1=SMS9<#)
000%0A>
00040A (1)=F6A=.
000?0A 0 1=S0.1 (2)P-6<.(1=SMS9P)
000D0A 9.C9(B<ogical -ile Ma"ter 0ecor)B)
000@0A A19F=M (3)
00030A FAM. (3)
000&0A ADD0 (3)
00100A (4)I A19F=M
"e$en&:
1-2 The 69I26+ =ey;ord specifies that records ;ith duplicate =eys are not allo;ed ;ithin a
mem)er of this logical file.
1.2 The =ey;ord #3I!+ $reEuired for logical files' specifies 76SMST#.
132 The field names do not ha"e & specified in position -( as they ;ould in physical files or in
any de"ice file.
142 %s in 76SMST#> the field %7T96M is treated as a =ey field.
E1ample o) a oin logical )ile:
The follo;ing *oin logical file *oins three physical files $#3,> #3-> and #38' so that an
application program can get name> address> and salary information in one input operation> e"en
though the information is stored in three different physical files. The follo;ing =ey;ords are
important in the e<ample:
03I!+
03!1
0OI9
0&+3
(i$ure 5+ ''% for a Join "o$ical (ile
00010A (1)0 J46F0.1 (2) J-6<.(P-1 P-# P-%)
000#0A J J46F(P-1 P-#)
000%0A (3) J-<D(FAM. FAM.)
00040A J J46F(P-# P-%)
000?0A J-<D(FAM. FAM.)
000D0A (4) FAM. (5) J0.-(1)
000@0A (4) ADD0
00030A (4) P84F.
000&0A (4) SA<A05
A
"e$en&:
1-2 & identifies the record format. There can )e only one record format in a *oin logical file.
1.2 The 03I!+ =ey;ord specifies that #3,> #3-> and #38 are the physical files on ;hich this *oin
logical file is )ased. Cecause it is specified first> #3, is the primary file. There are t;o secondary
files: #3- and #38.
132 0 identifies the *oin specifications. .ith t;o secondary files in this *oin logical file> there
must )e t;o *oin specifications. +ach *oin specification defines ho; a pair of files is to )e *oined>
44 of %4&
as follo;s: 0OI9 is reEuired ;hen more than t;o physical files are )eing *oined> and it identifies
;hich t;o files are )eing *oined in this *oin specification. In the first *oin specification> #3, and
#3- are *oined. In the second *oin specification> #3- and #38 are *oined.
Note:
Secondary files can )e *oined to either the primary file or to another secondary file. In
this e<ample> #3- in the second 0OI9 =ey;ord could )e #3,I there ;ould )e no
difference in the order of records supplied to the program or in performance.
03!1 identifies ;hich fields are used to lin= together records from the
physical files )eing *oined. In the first *oin specification> 9%M+ from #3, lin=s
;ith 9%M+ from #3-. In the second *oin specification> 9%M+ from #3- lin=s
;ith 9%M+ from #38.
142 The field names sho; ;hich fields are presented to the program. %t least one field name is
reEuired.
152 The 0&+3 =ey;ord identifies ;hich physical file to search for the field nameI in this
e<ample> 9%M+ from #3, is used. 9ote the use of the direct file num)er: 0&+3$,' indicates to
use the first file on the 03I!+ =ey;ord> ;hich is #3,.
!!3 'iles
The 11M files is used as a reference file )y %S/400 program to access files
located on any target system in the %S/400 net;or=.
11M files may )e created through t;o methods> either )y the ;or= ;ith 11M
files $.&:11M3' command> then form the list display press 35 to create a
11M file or )y the 7reate 11M file $7&T11M3' command directly on the
source system.
%dditional &ecommended &eading Material
,. S74,-(54(-0- %S/400 : 1ata)ase ?uide
-. S74,-(5-0-0- %S/400:11S &eference
4. of %4&
Chapter .: S!A and !isplay 'iles
Screen !esign Aid#S!A$:
This is a de"elopment tool is to aid in the creation of user interfaces on the %S/400.This tool
allo;s a programmer to JpaintJ screens and menus used )y a program from ;ithin a simple
editor> defining input and output fields and special te<t attri)utes. These screens may then )e
called from an application program> allo;ing the program to ha"e all the features of the %S/400
user interface ;ithout direct programming of the appearance of the interface.
S1% can )e in"o=ed )y either selecting option M(N from #rogrammerNs menu or through typing
the command MST&S1%N from %S/400 command entry line.
%S/400 Screen 1esign %id $S1%'

Select one of the follo;ing:

,. 1esign screens
-. 1esign menus
8. Test display files







Selection or command
SSST

3,S@elp 38S+<it 34S#rompt 3(S&etrie"e 3,-S7ancel
$7' 7O#G&I?@T ICM 7O&#. ,(,> -000.

%creen 'esi$nin$:
The follo;ing function =eys can )e used ;hile designing your image:
(36Exit
4* of %4&
Terminates screen design session.The +<it 1esign Image ;or= screen displays appears ;here
there is a choice to sa"e the ;or= > and return to the .or= ;ith 1isplay records menu.
(46rompt
Sho;s .or= ;ith 3ields display.
(76Con&ition
Sho;s the 7ondition .or= Screen display.
(86%elect a&&itional recor&s
Selects additional records to display on the 1esign image ;or= screen.
(-96'atabase
Sho;s the display for selecting 1ata)ase 3iles display.
(--6Non*&ispla! selecte& fiel&s
Toggle )et;een t;o fields lists that are displayed on the )ottom ro; of the ;or= screen.
(-.6Cancel
Sa"e the current ;or= and return to the .or= ;ith 1isplay records display.
$9ote:%nything that ha"e )een typed since last pressed enter is not processed.'
(-460uler
#lace a "ertical and horiFontal ruler on the 1esign Image ;or= screen to position the cursor.The
ruler does not interfere ;ith the data.#ress 3,4 to remo"e the ruler .1efining fields on the ruler
may cause results that cannot )e predicted.
(-56%ubfile rompt+
This function ;ill ;or= only ;hen a su)file e<ists.#ress 3,4 display prompt on the )ottome ro;
of the 1esign Image ;or= screen that allo;s changing the su)file line$S3!!I9' and su)file
page$S3!#%?' siFes that ;ere in effect for the current record )eing defined.
(-:6rint
#rint the current contents of the 1esign Image ;or= screen.
(-;6,ab
Mo"es the cursor to the attri)ute position of the ne<t field.
(-86Bac# ,ab
Mo"es the cursor to the attri)ute position of the pre"ious field.
(.960everse Ima$e Constants
S;itch the re"erse imaging of constants on and off.This re"erse imaging is temporary and does
not affect the compiled image.
47 of %4&
6se 3-0 to determine the starting and ending points of the constants. 7onstants ;hich ha"e the
underline attri)ute $)ut not the re"erse image and highlight attri)utes' ;ill not )e displayed in
re"erse image. 7onstants that are not currently displayed ;ill )e highlighted and ;ill appear in
re"erse image.
(.-6'ispla! a&&itional recor&s+
1isplays the additional records ;ith the primary record. #ress 3-, again to display only the
primary record. 6se this function =ey to determine ;hich fields on the display )elong to the
primary record. Only the fields of the primary record can )e changed.
Adding )ields4
To add a user defined field> type U follo;ed )y I $input'> O$output'> or C$)oth' for alpha)etic
fields> or follo;ed )y 8$input'> 5$output'> or ($)oth' for numeric fields and press +nter. To add a
floating point field> add a numeric field follo;ed )y + $single-precision' or 1$dou)le-precision'
and press +nter. Indicate the length of a field )y the num)er of characters follo;ing U> or )y the
length specified in )rac=ets after the first characters.
Adding constants
To add a ne; constant or change an e<isting constant
,. Type a constant. % )lan= character ends the constant.
-. Type constants ;ith single Euotation mar=s to define separate constants for each
character string$;ord' that is follo;ed )y a )lan=.
8. Surround a character string ;ith single Euotation mar=s to define single constant.
4. Surround se"eral constants ;ith single Euotation mar=s to redefine them as one
constant.
4. 6se a dou)le Euotation mar= to end one constant and start a ne; constant ;hile
ta=ing up only one position.
Adding )ields )rom a database )ile
The fields selected from the data)ase file appear on the )ottom ro; of the 1esign
Image ;or= screen. Mo"e fields from the )ottom line to your display )y typing V
follo;ed )y the field num)er> in multiple mode> and the column heading position and
pressing +nter. he fields )egin in the position ;here you type V.
4& of %4&
3oving5 Copying and Shi)ting )ields
&eposition fields on the screen )y using their attri)ute position.
$Note: The attri)ute position is the space directly in front of the field. #ress 3,( to go to the
attri)ute position of the pre"ious field. #ress 3, to go to the attri)ute position of the ne<t field.'
7hoose from the from the follo;ing methods and press +nter.
Centerin$ a fiel&
Type %7 in the attri)ute position of the field to mo"e the field to the center of the same ro;.
)ovin$ a fiel& * < 6
Type H in the attri)ute position of the field and type S ;here you ;ant the field to appear.
Cop!in$ a fiel& * < 66
Type H in the attri)ute position of the field and type SS ;here you ;ant a copy of the field to
appear.
)ovin$ a bloc# of fiel&s *< *< 6
Type H in the upper left corner of the )loc= of fields. Type H in the lo;er right corner of the
)loc= of fields so the H is one character )eyond the longest field in the )loc=. Type S ;here you
;ant the group of fields to appear.
Cop!in$ a bloc# of fiel&s *< * <66
Type H in the upper left corner of the )loc= of fields. Type H in the lo;er right corner of the
)loc= of fields so the H is one character )eyond the longest field in the )loc=. Type SS ;here you
;ant the group of fields to appear.
%hiftin$ a fiel& ===< >>>
Type WWW in the position preceding the field $attri)ute position of the fields'> or type TTT after
the field $o"er the ending attri)ute )yte'> to shift the field left or right as far as the signs e<tend.
Gou may type any num)er of T or W> and you can shift more than one field at a time in the ;or=
screen.
!ate and "ime 2ey0ords4
Type O1%T+ or OTIM+ to define special constants on the display ;here the current session date
and system time ;ill )e automatically su)stituted.
User an& s!stem #e!wor&s
40 of %4&
Type O6S+& or OSGS9%M+ to define special constants on the display ;here the user name and
the system name ;ill )e automatically su)stituted.
!isplay 'iles:
The follo;ing types of record formats can )e defined in display files:
Single &ecord 3ormats are normal record formats ;ith a fi<ed num)er of "aria)les and
literals defined in them
Su)file &ecord 3ormats are record formats that define a particular format )ut ;hich
allo;s the processing of multiple records of the same definition.
Su)file 7ontrol &ecord 3ormats are record formats that control the processing of a
related Su)file record format.
'ispla! (ile /e!wor&s
There are o"er ,80 =ey;ords associated ;ith display files. These =ey;ords are used to pro"ide
additional Eualification to the display file at "arious le"els. 1isplay file =ey;ords my )e di"ided
into the follo;ing groups.
(ile "evel =ey;ords> they are used at the file le"els and are common to all the record
formats in that file.
0ecor& "evel =ey;ords> they are used at a particular record le"el and applica)le to all
the constants and fields in the gi"en record format.
(iel& "evel =ey;ords apply to a particular field in a record format.
Some of the more commonly used =ey;ords are detailed )elo;:
(ile "evel /e!wor&s
%!T@+!# %lternate @elp :ey
6sed to assign an alternate command =ey as the help =ey.
%!T#%?+1O.9 %lternate #age 1o;n :ey
6sed to assign an alternate command =ey as the page do;n =ey
.0 of %4&
%!T#%?+6# %lternate #age 6p :ey
6sed to assign an alternate command =ey as the page up =ey
%!.?#@ %llo; ?raphics
6sed to specify that graphic characters could )e generated and displayed in the named display
file. This =ey;ord ho;e"er is "alid only for ;or=stations that support graphic displays such as
the ICM 4-(-.
7%nn 7ommon %ttention :eys
6sed to assign the usage of indicators to )e associated ;ith command =eys.
73nn 7ommon 3unction :eys
6sed to assign the usage of indicators to )e associated ;ith command function =eys.
7ommand 3unction :eys differ from command attention =eys in that the data is transferred
)et;een screens only ;ith the usage of command attention =eys.
7@?I9#31T 7hange input default
1efined at the file le"el so that the field le"el defaults can )e o"erridden ;ith the user specified
attri)utes.
1S#SIB 1isplay siFe
6sed to assign the display siFe of the ;or= station display.
@+!# @elp =ey
6sed to assign an indicator for the @elp =ey so that the program may recogniFe its usage.
@OM+ @ome =ey
6sed to assign an indicator for the @ome =ey so that the program may recogniFe its usage.
MS?!O7 Message !ocation
6sed to identify a line of display ;here the messages may )e displayed.
#&I9T #rint =ey
6sed to ena)le the facility of ta=ing the screen prints and to identify a printer file name into
;hich any screen prints are to )e directed
&+3 &eferenced 3ile
6sed to identify a file from ;hich all the field references are to )e deri"ed from.
&O!!6# &ollup :ey
6sed to specify an indicator that is to )e associated ;ith the &ollup =ey. This indicator can then
)e used to trigger program action for the &ollup function.
&O!!1O.9 &olldo;n :ey
.% of %4&
6sed to specify an indicator that is to )e associated ;ith the &olldo;n =ey. This indicator can
then )e used to trigger program action for the &olldo;n function.
0ecor& "evel /e!wor&s
%!%&M %larm
6sed to specify that the ;or= station alarm is to )e sounded ;hen the named record format is
output
%!.?#@ %llo; ?raphics
6sed to specify that graphic characters could )e generated and displayed in the named display
file. This =ey;ord ho;e"er is "alid only for ;or=stations that support graphic displays such as
the ICM 4-(-.
%SS6M+ %ssume
6sed to indicate that named record format is to )e assumed to )e displayed )y the pre"ious
program> used in association ;ith the :++# =ey;ord in the calling program this
:ey;ord o"erlay the named record format o"er the pre"ious display
C!I9: Clin=
6sed to indicate that named record format is to )lin= ;hen displayed.
7@%9?+ 7hange
6sed to specify an indicator ;hich is to )e set one ;hen any of the input fields in the named
record format is modified )y the ;or= station user.
7@?I9#13T 7hange input default
1efined at the record le"el so that field le"el defaults can )e o"erridden ;ith the user specified
attri)utes.
7S&!O7 7ursor !ocation
6sed to position the cursor in a specified ro;-column position ;hen the screen is displayed.
+&%S+ +rase
This =ey;ord is used to erase a record in a specified ro;-column position ;hen the screen is
displayed.
+&%S+I9# +rase Input
6sed to erase input fields from the named record format )efore the ne<t output operation on the
display file.
+&&MS? +rror Message
.2 of %4&
6sed to specify the te<t to )e displayed as an error message upon occurrence of an error
condition.
+&&MS?I1 +rror Message Id
6sed to identify a message identity from a named message file to )e displayed as a error
Message upon the occurrence of an error condition
@!#7M1:+G @elp 7ommand :ey
6sed to specify an indicator to )e associated ;ith the @elp :ey for the named record format.
@OM+ @ome :ey
6sed to assign an indicator for the @ome =ey so that the program may recogniFe its usage.
:++# :eep 1isplay
6sed to retain the display of the named record format e"en after the termination of the program
so that the ne<t program in the in"ocation stac= may still )e a)le to display the screen. This
=ey;ord to )e used in the display file of the calling program in association ;ith %SS6M+
=ey;ord to )e used in the display file of the called program.
OD+&!%G O"erlay
6sed to retain the display of the format already displayed ;hen the named record format is to )e
displayed.
#&I9T #rint :ey
6sed to identify a printer file name into ;hich any screen prints are to )e directed
#&OT+7T #rotect
6sed to identify that all the input capa)le fields in the named format are to )e input inhi)ited.
#6TOD+& #ut o"er
6sed to indicate that ;hen used in association ;ith OD&1T% or OD&%T& =ey;ords at the
field le"el> only those screen data that ha"e )een changed in an input operation need )e referred
;hen the record format is output again.
(iel& "evel /e!wor&s
%!I%S %lias
6sed to assign an alias name to a field.
7@%9?+ 7hange
6sed to specify an indicator ;hich is to )e set on ;hen any of the input fields in the named
record format is modified )y the ;or= station user.
.$ of %4&
7@?I9#13 7hange input default
1efined at the field le"el so that field defaults can )e o"erridden ;ith the user specified
attri)utes.
7@+7: 7hec=
6sed to specify a set of "alidation rules such as
M+ Mandatory +ntry
M3 Mandatory 3ill
&C &ight *ustified ;ith )lan=s
&B &ight *ustified ;ith Feros
7M#> 7OM# 7ompare
6sed to specify a literal "alue against ;hich any input "alue to the field is "alidated on an input
operation
7O!O& 7olor
6sed to assign a color to a field or constant ;hen it is displayed. %ttri)ute "alues are
?&9 ?reen
.@T .hite
&+1 &ed
T&2 TurEuoise
G!. Gello;s
#9: #in=
C!6 Clue
1%T+ 1ate
6sed to specify that the system date is to )e displayed in the specified position
13T> 13TD%! 1efault "alue
6sed to assign a default "alue to a field to )e displayed during an output operation
1!T7@: 1elete "alidity chec=ing
6sed to specify that any "alidity chec=ing specified in the definition of the referenced field is to
)e ignored for the named field
1!T+1T 1elete +diting
6sed to specify that any editing rules specified in the definition of the referenced field is to )e
ignored for the named field.
1S#%T& 1isplay attri)ute
6sed to nominate a display attri)ute to )e attached to the named field during an output operation.
Dalid "alues are
C! Clin=
.4 of %4&
7S 7olumn separators
@I @igh-light
91 9on H display
#7 #osition 7ursor
#& #rotect
&I &e"erse Image
6! 6nderline
+1T71+ +dit code
6sed to specify an editing rule for numeric "aria)les. +dit codes go"ern such parameters as Fero
)alances> suppression of the leading Feros> commas> negati"e sign and credit )alance. +dit coded
can also )e used to separate dates> month and year components of dates.
+1T.&1 +dit ;ord
6sed to specify the user defined editing rules for )oth alpha)etic and numeric fields.
OD&%T& O"erride attri)utes
6sed in association ;ith the #6TOD& =ey;ord at the record le"el to indicate that only if the
attri)utes of the named "aria)le or literal has changed should data )e sent to the screen in the
ne<t output operation.
&%9?+ &ange
6sed to specify a range of "alues that are "alid input "alues for the named "aria)le
&+33!1 &eferenced field name
6sed to specify the name of a pre"iously defined field from the file indicated as the referenced
file at the file le"el.
SGS9%M+ System name
6sed to indicate that the system name is to )e displayed in the specific ro;-column position at
the ne<t output operation
T+AT Te<t
6sed to attach descripti"e te<t for the named "aria)le to )e used ;hen "ie;ing or printing the
display file field definitions.
TIM+ Time
6sed to indicate that the system is to )e displayed in the specific ro;-column position upon the
ne<t operation to the screen
6S+& 6ser name
6sed to indicate that the ;or= station user name is to )e displayed in the specific ro;-column
position upon the ne<t output operation to the screen.
.. of %4&
D%!6+S Dalid "alues
6sed to specify a set of "alid "alues that can )e allo;ed as input into the named "aria)le during
an output operation.
.* of %4&
Chapter .I: -P6/400
-P6/400 &anguage Concepts
&#? stands for ?0eport ro$ram @eneratorA. &#? a high le"el language ;as originally
designed to )e a semi-automated tool for producing reports. @o;e"er> ;ith the continuous
de"elopmental efforts> currently &#? /400 is fully functional > highly sophisticated structured
language that allo;s for performing a ;ide "ariety of tas=s reEuired in performing hea"y-duty>
high-"olumes transaction processing in commercial applications.
The earliest "ersion of &#? is &#? II .This is fully structured pre set logic cycle that is go"erned
)y certain system-defined rules for processing. This cycle assumes that standard set of
instructions are performed ;hich includes
&eading a file designed to )e a primary file
If end of file> print the end of file totals and control "alues
7hec= for "arious le"el )rea=s and if so do the necessary processing and printing of
control )rea=s and totals
#erform details line processing
The actual processing steps in"ol"ed in the &#? logic cycle is detailed in the follo;ing chart.
&efer to %ppendi< C for &#? cycle charts.
0@ III roce&ural ro$rammin$
&#? III is the ne<t "ersion of &#? that ;as introduced in the ICM System/80.6nli=e &#? II this
"ersion is not a system defined logic cycle )ut rather a fully user controlled application language.
%ll the tas=s that ;ere automatically performed in &#? II has to )e deli)erately performed )y
the user. .hile this might seem a little tedious >the ad"antages and the fle<i)ility pro"ided in the
full user control are commenda)le.
0@B499
&#?/400 is the current "ersion of &#? a"aila)le on the %S/400.&#?/400 is the natural language
on the %S/400.7ertain aspects of the OS/400 lend themsel"es for easy application of &#?/400 as
a language .Cenchmar= tests ha"e pro"ed that 7OCO!/400 application ha"e a performance
degradation of a)out -0X o"er &#?/400 applications.
The follo;ing are the main differences )et;een &#? II and &#?/400.
.7 of %4&
,. &#?/400 allo;s for the use of e<ternally descri)ed files.
-. &#?/400 supports character string operations.
8. &#?/400 supports su) file initialiFation for data structure elements.
4. &#?/400 allo;s indentation of I3-+!S+ and 1O statements in source.
4. &#?/400 allo;s the use of figurati"e named constants.
5. &#?/400 supports e<ception and error handling.
7. &#?/400 is ideal for use of structured programming language.
-P6/400 Speci)ications
&#?/400 program consist of se"en specifications. +ach specification may include one or more
statements. It is not necessary that all these specification )e included in each program.
@o;e"er >the specifications must necessarily follo; the seEuence in ;hich they are listed there
under. The specifications that form a &#?/400 program are:
@ 7ontrol Specification

3 3ile Specification

+ +<tension Specification
! !ine counter Specification
I Input Specification
7 7alculation Specification
O Output Specification



1etails of the se"en &#? specifications are as follo;s:
.& of %4&
H C(+"-(& SPECI'ICA"I(+
This is used to pro"ide information a)out program generation and e<ecution .It is included in a
program > 7ontrol specification must )e the first specification in the program. Only one control
specification must )e entered in a program .

' 'I&E SPECI'ICA"I(+
This is used to identify all the files that are reEuired to )e used )y a program. +ach file should )e
defined in a separate specification line. One program can use a ma<imum of 40 files of ;hich
upto files can )e printer files.
E E7"E+SI(+ SPECI'ICA"I(+
This is used )y the program to descri)e all the record address files> ta)les and arrays . %
ma<imum of -00 ta)les and arrays can )e used in a program .
& &I+E C(8+"E- SPECI'ICA"I(+
This is used )y a program to indicate the length of form and the num)er of lines per page for
e"ery program descri)ed printer file..
I I+P8" SPECI'ICA"I(+
This is used )y program to define the "arious types of records ;ithin a file> the seEuence of the
"arious types of records ;ithin a file> the fields ;ithin a record and the data ;ritten ;ithin a
field.
3or program descri)ed files >the input specification define the filed layout of the file.
Input specification is also used to define su)-file> data structure and the data areas.
C CA&C8&A"I(+ SPECI'ICA"I(+
This is used in a program to indicate the operations that are to )e performed on data ;ithin a
program.
( (8"P8" SPECI'ICA"I(+
This is used in a program to define the record the record layout of a program descri)ed output
file .The output specification are optional for e<ternally defined files.
-P6/400 (peration Codes #(PC(!ES$:
&#? Operation codes or Opcodes are commands ;hich allo; the program to perform "arious
calculation and operations. There are in all o"er 0 opcodes used in &#?/400.These opcodes can
)e classified into the follo;ing )road categories. Some of the opcodes may )e listed under more
than one category due to their functionality. The opcode
7lassification are :
%rithmetic Operations
Mo"e Operations
.0 of %4&
7ompare Operations
1eclarati"e Operations
InitialiFation Operations
String Operations
Su)routine Operations
Indicator Operations
Structured #rogramming Operations
3ile Operations
Information Operations
Message Operations
CIT Operations
Test Operations
7alling Operations
Cranching Operations
%rray Operations
1ata%rea Operations
7ommitment 7ontrol Operations
Arithmetic (perations
%rithmetic operations are those )asic operations that are performed on numeric "aria)les to
arri"e at calculated "alues. The follo;ing are the opcodes that relate to arithmetic operations in
&#?/400 .%ll arithmetic operations are "alid only ;hen performed on numeric "aria)les.
A'' 1A&& %tatement2

(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
A))en) A'' A))en) S'm U - B
%dd t;o "aria)les or constants to arri"e at a sum to )e store in a third "aria)le

+<ample:
%11 , &+79O
%11 +@.&: 76&@&S
OD&TM %11 &+?@&S TOT#%G
E*A'' 1Eeroise an& a&&2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
A))en) E*A'' A))en) S'm U - B
InitialiFe a "aria)le to Feros and add a second "aria)le to the first
+<ample:
*0 of %4&
B-%11 3I+!1% 3I+!1C
B-%11 , 3I+!1%
B-%11 OB+&OS 3I+!1%
%UB 1%ubtract statement2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Min'en) SUB S'!trahen) Difference U - B
Su)tract the "alue of one "aria)le from a third "aria)le
+<ample
3I+!1% S6C 3I+!1C 3I+!17
S6C 3I+!1% 3I!+1C
S6C ,0 3I+!1C
,0 S6C 8 3I+!1%
E*%UB 1Eeroise an& subtract2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Min'en) Z-SUB S'!trahen) Difference U - B
InitialiFe a "aria)le to Feros and su)tract a second "aria)le from the first .The result of this
operation ;ould ma=e the "alue of the first "aria)le negati"e. This "aria)le is used to ma=e
the "alue of a "aria)le negati"e.
+<ample:
B-S6C 3I+!1% 3I+!1C
B-S6C , 3I+!1%
B-S6C OB+&OS 3I+!1%
This statement is the same as specifying
B-%11 OB+&OS 3I+!1%
)U", 1)ultipl!2
Multiply t;o "aria)les and store the product in a third "aria)le
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
M'ltiplica
n)
MULT M'ltiplier Pro)'ct U - B
+<ample
3I+!1% M6!T 3I+!1C 3I+!17
4 M6!T 3I+!1% 3I+!1C
3I+!1% M6!T 4 3I+!1C
*% of %4&
8 M6!T 4 3I+!1%
M6!T 3I+!1% 3I+!1C
M6!T OB+&OS 3I+!1C

'IF 1'ivi&e2
1i"ide a "aria)le or constant )y a second "aria)le or constant and store the result in a third
"aria)le.
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Divi)en) DIV Divi"or A'otient U - B
+<ample:
3I+!1% 1ID 3I+!1C 3I+!17
4 1ID 3I+!1% 3I+!1C
3I+!1% 1ID 4 3I+!1C
4 1ID 8 3I+!1%
)F0 1)ove remain&er2
This opcode is "alid only ;hen immediately follo;ing an di"ide $1ID'operation.This
operation stores the remainder from the pre"ious operation is a "aria)le .The result of a
di"ide operation if follo;d immediately )y a mo"e remainder$MD&'operation ;ould )e in
;hole num)ers.
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
MVR

0emain)er U - B
+<ample:
MD& 3I+!1%
%D0, 1%Guare root2
The operation calculates the sEuare root of a "aria)le and stores it in a second "aria)le.
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
SQRT Kal'e 0oot
+<ample
S2&T 3I+!1% 3I+!1C
3ove (perations:
)OFE 1)ove2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
MOVE So'rce 9arget -iel) H ( G:
*2 of %4&
fiel)
Mo"es the contents of a "aria)le or constant into a second "aria)le. This operation is right-
*ustified. @ence if a longer "aria)le is mo"ed into a shorter "aria)le >the left most
characters$and in cases of numeric "aria)les> significant digit ';ould )e truncated.
+<ample:
MOD+ 3I+!1% 3I+!1C
MOD+ M%C71+N 3I+!17
MOD+ M,-844N 3I+!11
MOD+ M,N 3I+!1+
)OFE" 1)ove left2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
MOVE So'rce
fiel)
9arget -iel) H ( G:
Mo"es the contents of a "aria)le or a constant into a second "aria)le .This operation is left-
*ustified .@ence if a longer "aria)le is mo"ed into a shorter "aria)les > the right-most
characters ;ould )e truncated.
+<ample
MOD+! 3I+!1% 3I+!1C
MOD+! M%C71+N 3I+!17
MOD+! ,-844 3I+!11
MOD+! M,N OI9-4
Compare (perations
The compare operations are:
%91<< $%nd'
7OM# $7ompare'
7%C<< $7ompare and Cranch'
7%S<< $7onditionally In"o=e Su)routine'
1O6<< $1o 6ntil'
1O.<< $1o .hile'
I3<< $If'
O&<< $Or'
.@<< $.hen True Then Select'
In the %91<<> 7%C<<> 7%S<<> 1O6<<> 1O.<<> I3<<> O&<<> and .@<< operations>
<< can )e:
xx )eanin$
?T 3actor , is greater than factor -.
!T 3actor , is less than factor -.
+2 3actor , is eEual to factor -.
*$ of %4&
9+ 3actor , is not eEual to factor -.
?+ 3actor , is greater than or eEual to factor -.
!+ 3actor , is less than or eEual to factor -.
Clan=s 6nconditional processing $7%S<< or 7%C<<'.
I(xx 1If con&ition2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) IFxx 1omparan)
7ompare the "alue of one "aria)le or literal against the "alue of second "aria)le or literal to
determine the course of action. The step/s ta=en as a result of this comparison must )e
mar=ed ;ith either an +91 operation or a +91I3 operation.
+<ample:
If 3!1% eEuals 3!1C> the calculation after the I3+2 operation7O is processed. If
3!1% does not eEual 3!1C> the program )ranches to the operation immediately follo;ing
the +91I3.
3!1% I3+2 3!1C I3 +26%!
:
:
:
+91I3
CABxx 1Compare an& branch2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) CABxx 1omparan) <a!el 86 <4 .A
7ompare the "alue of one "aria)le or literal against the "alue of a second "aria)le or literal to
decide to )ranch a;ay to another part of the program logic rather than e<ecute the ne<t
statement follo;ing the compare and )ranch $7%C'operation.
+<ample:
3I+!1% 7%C<< 3I+!1C T%?0,
M%C71+N 7%C<< 3I+!17 T%?0,
3I+!17 7%C<< M%C71+N T%?0,
,0 7%C<< 3I+!11 T%?0,
3I+!11 7%C<< ,0 T%?0,
OI9-4 7%C<< M,N T%?0,
CA%xx 1Compare an& execute subroutine2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) CASxx 1omparan) S'!ro'tine 86 <4 .A
*4 of %4&
Fame
7ompare the "alue of one "aria)le or literal against the "alue of a second "aria)le or literal to
decide to e<ecute a su)routine. 7ontrol then passes to the named su)routine and after
completion of e<ecution of the su)routine control returns to the statement immediately
follo;ing the compare and e<ecute 7%S statement .+"ery 7%S or group of 7%S statement
must )e named ;ith a +91 or +917S operation.
3I+!1% 7%S<< 3I+!1C S6C0,
M%C71+N 7%S<< 3I+!17 S6C0,
3I+!17 7%S<< M%C71+N S6C0,
,0 7%S<< 3I+!11 S6C0,
3I+!11 7%S<< ,0 S6C0,
OI9-4 7%S<< M,N S6C0,
7%S S6C&08
'OUxx 1'o until2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) DOUxx 1omparan)
#erform the operation listed in a 1O loop that is mar=ed ;ith an +91 or an +911O
operation repetiti"ely until the condition specified in then 1O condition is satisfied.The loop
;ould )e performed at least once since the condition is chec=ed only in the +91 or +911O
operation
+<ample:
3I+!1% 1O6<< 3I+!1C
M%C71+N 1O6<< 3I+!17
3I+!17 1O6<< M%C71+N
,0 1O6<< 3I+!11
3I+!11 1O6<< ,0
OI9-4 1O6<< M,N
'OHxx 1'o while2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) DOWxx 1omparan)
#erform the operation listed in a 1O loop that is mar=ed ;ith an +91 or an +911O
operation repetiti"ely ;hile the condition specified in the 1O ststement is satisfied .The loop
;ould not )e performed if on the first instance itself the condition is not satisfied.
+<ample:
3I+!1% 1O.<< 3I+!1C
*. of %4&
M%C71+N 1O.<< 3I+!17
3I+!17 1O.<< M%C71+N
,0 1O.<< 3I+!11
3I+!11 1O.<< ,0
OI9-4 1O.<< M,N
HCxx 1Hhen2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) WHxx 1omparan)
% ;hen condition is used to chec= for and process a group of conditions under a select
group.% select group al;ays starts ;ith a S+!+7 statement and ends ;ith an +91 or an
+91S! ststement.
+<ample:
S+!+7
3I+!1% .@<< 3I+!1C
:
:
+91S!


CO) 1Compare2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
1omparan) COMP 1omparan) 86 <4 .A
7ompare the "alue of a "aria)le or literal against the "alue of a second "aria)le or literal and
appropriately s;itch on one of the resulting indicators.
?CIA indicator is s;itched on i.e the "alue of the indicator )ecomes M,Nif factor one is
greater than factor t;o.
?"OA indicator is s;itched on i.e the "alue of the indicator )ecomes M,Nif factor one is
less than factor t;o.
?EDA indicator is s;itched on i.e the "alue of the indicator )ecomes M,Nif factor one is
eEuals factor t;o.

3I+!1% 7OM# 3I+!1C
M%C71+N 7OM# 3I+!17
3I+!17 7OM# M%C71+N
, 7OM# 3I+!11
3I+!11 7OM# ,
- 7OM# 4
** of %4&
!eclarative (perations
"I%, 1 arameter list2
% parameter list is used to declare one or more "aria)le that are reEuired to )e passY to
another program that is )eing called from ;ithin the named program .% parameter list may
)e declared any;here ;ithin the calculation specification specifications or a program and
need not necessarily )e placed in a logical position.
+efer ;Calling 4perations; for 9ore infor9ation..
A0) 1arameter2
% parameter statement identifies indi"idual "aria)le that form a parameter list. % #%&M
statement must necessarily )e placed immediately follo;ing a #!IST statement or another
#%&M statement. The seEuence in ;hich the #%&M statements are listed ;ould )e the
seEuence in ;hich these "aria)les are passed to the calling program.
+efer to ;Calling 4perations; for 9ore infor9ation..
/("' 1/e! (iel&2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED

KFLD Ie2 fiel)
The :3!1 operation is a declarati"e operation that indicates that a field
is part of a search argument identified )y a :!IST name.
/"I%, 1/e! list2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
<i"t Fame KLIST
The :!IST operation is a declarati"e operation that gi"es a name to a list of :3!1s. This list
can )e used as a search argument to retrie"e records from files that ha"e a composite =ey.
+<ample
:!%C7 :!IST
:3!1 3I!+1%
:3!1 3I!+1C
:3!1 3I!+17
*7 of %4&
'E(N 1'efinition2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
><6I. DEFN 0eference)
fiel)
Define) fiel)
>FAMKA0 DEFN ./ternal
)ata area
6nternal Program
area
1epending on the factor , entry> the declarati"e 1+39 operation can do either of the follo;ing:
1efine a field )ased on the attri)utes $length and decimal positions' of another
field.
1efine a field as a data area.
+<ample:
O!I:+ 1+39 3I+!1% 3I+!1C
O9%MD%& 1+39 3MI91T %&+%0,
,A@1,a$2
% tag statement is used to identify the address of a )ranching operation such as 7%C<< or
?OTO.
T%?0, T%?
Initiali9ation (perations
C"EA0 1Clear2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
>F4I.5 CLEAR Str'ct're
or
Karia!le

The 7!+%& operation sets elements in a structure $record format> data structure> array> or ta)le'
or a "aria)le $field> su)field> or indicator'> to Fero> )lan= or L0L> depending on field type
$numeric> character> or indicator'. It allo;s you to clear structures on a glo)al )asis> as ;ell as
element )y element> during run time.
*& of %4&
3actor , must )e )lan= unless factor - contains a 1IS: record format nameI in ;hich case> it can
contain O9O:+G to indicate that all fields e<cept =ey fields are to )e cleared.
>...1....H....#....H....%....H....4....H....?....H....D....H....@...
6....................................P-rom9oHHD-iel)H<1M1-rPlMnGr...
6>
6> 6n the following e/ample; 1<.A0 "et" all "'!fiel)" in the )ata
6> "tr'ct're DS1 to their )efa'lt"; 18A0 to !lan; F=M to Lero.
I'%- '%
I . 59 NU)
I .9 39 CCA0
>...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<0F01F0#F0%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1>
C C"EA0'%-
0E%E, 10eset2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
>F4I.5 RESET Str'ct're
or
Karia!le

The &+S+T operation sets elements in a structure $record format> data structure> array> or ta)le'>
or a "aria)le $field> su)field> or indicator' to its initial "alue. The initial "alue for a "aria)le is
the "alue the "aria)le had at the end of the OI9IT operation of the program. This "alue can )e
set using data structure initialiFation> or you can use the initialiFation su)routine to assign an
initial "alue to the structure or "aria)le.
String (perations
CA, 1Concatenate ,wo Character %trin$s2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Source string , CA, 1p2 Source string -: num)er
of Clan=s
Target string
The 7%T operation concatenates the character string specified in factor - to the end
of the character string specified in factor , and places it in the result field. If no
factor , is specified> factor - is concatenated to the end of the result field string.
3or e<ample> if you ha"e:
7 L)MI:+))L 7%T L))SMIT@)L:, 9ame
the "alue of the result field after this statement is e<ecuted is: L)MI:+)))SMIT@)L
*0 of %4&
CCEC/ 1Chec# Characters2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
7omparator
string
CCEC/ Case
string:start
!eft-position Z +& 31
The 7@+7: operation "erifies that each character in the )ase string $factor -' is
among the characters indicated in the comparator string $factor ,'.
Derifying )egins at the leftmost character of factor - and continues character )y character> from
left to right.
The operation stops chec=ing ;hen it finds the first incorrect character or ;hen the
end of the )ase string is encountered. If no incorrect characters are found> the
result field is set to Fero.
If the result field is an array> the operation continues chec=ing after the first incorrect
character is found for as many occurrences as there are elements in the array.If there are more
array elements than incorrect characters> all of the remaining elements
are set to Feros.
+<ample
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N
1N :eca'"e factor 1 i" a !lan; 18.1I in)icate" the po"ition
1N of the fir"t non!lan character. 6f S906F7 contain" B!!!theB;
1N F=M will contain the val'e 4.
1N
C ! ! CHECKSTRIN" NUM 2#
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
6..............Fame)con"tantHHHHHHHHH1.........-l)nme......... ....
6N
6N 9he following e/ample chec" that -6.<D contain" onl2 the letter"
6N A to J. A" a re"'lt; A00A5*(1%D000) after the 18.1I operation.
6N 6n)icator &0 t'rn" on.
6N
I !ABCDEF"HI$! C LETTER
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N
C MOVE!1A%BC&! FIELD '
C LETTER CHECKFIELD ARRA( )#
1N
1N 6n the following e/ample; !eca'"e -6.<D contain" onl2 the
1N letter" A to J; A00A5*(000000). 6n)icator &0 t'rn" off.
1N
C MOVE !F"F"F"! FIELD '
C LETTER CHECKFIELD ARRA( )#
CCE/0 1Chec# 0everse2
(actor - Co&e (actor . 0esult (iel& In&icators
70 of %4&
CI "O ED
7omparat
or string
CCE/0 Case
string:start
&ight-position Z +& 31
The 7@+:& operation "erifies that each character in the )ase string $factor -' is
among the characters indicated in the comparator string $factor ,'. Derifying )egins
at the rightmost character of factor - and continues character )y character> from
right to left.
%CAN 1%can Character %trin$2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
7omparator
string:!ength
%CAN Case
string:start
!eft Most
#osition
Z +& 31
The S7%9 operation scans a character string $)ase string' contained in factor - for a
su)string $compare string' contained in factor ,. The scan )egins at a specified
location contained in factor - and continues for the length of the compare string
;hich is specified in factor ,.
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N
1N 9he S1AF operation fin)" the "'!"tring BA:1B "tarting in
1N po"ition % in factor #P % i" place) in the re"'lt fiel).
1N 6n)icator &0 i" "et on !eca'"e the "tring i" fo'n). :eca'"e
1N no "tarting po"ition i" "pecifie); the )efa'lt of 1 i" '"e).
C !ABC! SCAN !*CABCD! RESULT )#
I"A,E 1,ranslate2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
3rom:To I"A,E String:start Target
String
ZZ +& ZZ
7haracters in the source string $factor -' are translated according to the 3rom and
To strings $)oth in factor ,' and put into a recei"er field $result field'. Source char-acters
;ith a match in the 3rom string are translated to corresponding characters in
the To string. A!%T+ starts translating the source at the location specified in factor
- and continues character )y character> from left to right.
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N
1N 9he following tran"late" the !lan in F=M:.0 to B(B. 9he re"'lt
1N in 0.S=<9 will !e B&&&(&&&&B.
1N
C MOVE !)))+))))!NUMBER ,
7% of %4&
C ! !-!-! *LATE NUMBER RESULT ,
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
6..............Fame)con"tantHHHHHHHHH1.........-l)nme.............
6N
6N 6n the following e/ample; all val'e" in S906F7 are tran"late) to
6N 'pperca"e. A" a re"'lt; 0.S=<9*B0P7 D.PB.
6N
I !ABCDEF"HI$KLMNOPQRS- C UP
I !TUVW*(Z!
I !./0123456789:;<=>?@- C LO
I !ABCDxEF!
1N
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
C MOVE GR=" D2=! STRIN" H
C LO-UP *LATESTRIN" RESULT )#
1N
1N 6n the following e/ample all val'e" in the "tring are tran"late)
1N to lowerca"e. A" a re"'lt; 0.S=<9*Brpg )epB.
1N
C MOVE !R=" D2=! STRIN" H
C UP-LO *LATE STRIN" RESULT )#
%UB%, 1%ubstrin$2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
!ength to e<tract %UB%, Case
string:start
Target
string
ZZ+& ZZ
The SUBST operation returns a substring from factor 2, starting at the location speci-fied
in factor 2 for the length specified in factor 1, and places this substring in the
result field. If factor 1 is not specified, the length of the string from the start posi-tion
is used.
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N
1N 9he S=:S9 operation e/tract" the "'!"tring from factor # "tarting
1N at po"ition % for a length of #. 9he val'e B1DB i" place) in the
1N re"'lt fiel) 0.S=<9. 6n)icator &0 i" not "et on !eca'"e no error
1N occ'rre).
C Z-ADD 3 T 2#
C MOVEL!ABCDEF! STRIN" 1#
C 2 SUBSTSTRIN"-T RESULT )#
Subroutine (perations
CA%xx 1Compare an& execute subroutine2
7ompare the "alue of one "aria)le or literal against the "alue of a second "aria)le or literal to
decide to e<ecute a su)routine. 7ontrol then passes to the named su)routine and after completion
of e<ecution of the su)routine> control returns to the statement immediately follo;ing the
compare and e<ecute $7%S' statement. +"ery 7%S or group of 7%S statements must )e mar=ed
;ith an +91 operation of an +917S operation. The M<<N may )e one of the relational operator
!T !ess Than
72 of %4&
!+ !ess than or +Eual to
+2 +Eual to
9+ 9ot +Eual to
?T ?reater Than
?+ ?reater than or +Eual to
See ? Compare operationsA for more information
EI%01Execute %ubroutine2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
E*SR S'!ro'tine
name

+<ecute a named su)routine. 7ontrol passes to the named su)routine and upon completion of the
e<ecution of the su)routine ;hich is indicated ;ith an end su)routine operation $+91S&'
control returns t the statement immediately follo;ing the e<ecute su)routine statement.
BE@%01Be$in %ubroutine2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
S'!ro'tine
name
BE"SR
Cegin e<ecution of a su)routine. This is the first statement in a su)routine and continues till the
end su)routine statement. % second su)routine can )e e<ecuted from a su)routine although a
su)routine cannot )e e<ecuted recursi"ely.
S6C&0, C+?S&
EN'%01En& %ubroutine2
Mar=s the end of a su)routine. %fter the end su)routine statement> control returns the statement
immediately follo;ing the +<ecute su)routine +AS& or the compare and e<ecute su)routine
$7%S<<' statement from ;hich the named su)routine ;as e<ecuted.
+91S&
T%?(( +91S&
7$ of %4&
Indicator (perations
%E,ON 1%et on in&icator2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
SETON O9 O9 O9
Sets on indicator to "alue M,N.
S+TO9 -4
S+TO9 -4 -5 -7
S+TO9 -4 -7
S+TO9 -7
S+TO9 -4 -7
%E,O( 1%et off in&icator2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
SETOF O9 O9 O9
Sets on indicator to "alue M0N.
S+TO3 -4
S+TO3 -4 -5 -7
S+TO3 -4 -7
S+TO3 -7
S+TO3 -4 -7
Structured Programming (perations
The operations I3<<> 1O6<<> 1O.<<> 7%S<< and .@<< ;hich ;ere descri)ed earlier under
compare operations also form part of structured programming operation.
O0xx 1Or con&ition2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
1omparan) ORxx 1omparan)

The O& statement is al;ays used in con*unction ;ith an I3<<> 1O6<< or1O.<< statement to
pro"ide additional Eualification to the first statement. The O& statement ;ould )e e<ecuted only
if the condition specified in the original statement is not satisfied.
74 of %4&
+<ample:
3I+!1% O&<< 3I+!1C
M%C71+N O&<< 3I+!17
3I+!17 O&<< M%C71+N
,0 O&<< 3I+!11
3I+!11 O&<< ,0
OI9-4 O&<< M,N
AN'xx 1An& con&ition2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
1omparan) ANDxx 1omparan)

The %91 condition is al;ays used in con*unction ;ith a n I3<<> 1O6<< or1O.<< statement to
pro"ide additional Eualification to the first statement. The %91 statement is e<ecuted in
con*unction ;ith the first statement> ie.> only if )oth the first statement and the %91 statement
conditions are )oth fulfilled> the conditioned statements are e<ecuted.
+<ample:
3I+!1% %91<< 3I+!1C
M%C71+N %91<< 3I+!17
3I+!17 %91<< M%C71+N
,0 %91<< 3I+!11
3I+!11 %91<< ,0
OI9-4 %91<< M,N
E"%E 1Else2
The else condition is optionally used ;ith a I3<< statement. If the condition specified in the I3<<
statement is not fulfilled> then the else condition ;ould )e chec=ed. The statements till the +91
or +91I3 statement ;ould )e e<ecuted.
EN' 1En&2
The end statement mar=s the end of a group of statements that ;ere e<ecuted )y one of either
I3<<> 1O6<<> or 1O.<< statements.
EN'!! 1En& Con&ition2
The +91yy statement mar=s the end of a specific group of statements that ;ere e<ecuted under
one of the follo;ing. @ere MyyN may )e any one of
7S 7%S<<
7. of %4&
1O 1O
1O6<<
1O.<<
I3 I3<<
S! S+!+7
'O 1'o Iteration2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Starting
val'e
DO <imit val'e 6n)e/
val'e

The 1O operation )egins a group of operations and indicates the num)er of times the group ;ill
)e processed. To indicate the num)er of times the group of operations is to )e processed>
specify an inde< field> a starting "alue> and a limit "alue. %n associated +911O statement
mar=s the end of the group.
+<ample:
1>
1> 9he D4 gro'p can !e proce""e) 10 time". 9he D4 gro'p "top"
1> r'nning when the in)e/ val'e in fiel) C i" greater than
1> the limit val'e (#0) in factor # .
1> 9he "tarting val'e of # i" "pecifie) in factor 1 of the D4
1> operation; an) the incrementing val'e of # i" "pecifie) in
1> factor # of the .FDD4 operation.
1>
1 # D4 #0 C %0 D4 10 96M.S
1 :
1 :
1 :
1 .FDD4 #
%E"EC 1%elect2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
SELEC

The select group conditionally processes one of se"eral alternati"e seEuences of operations. It
consists of:
o % S+!+7 statement
o Bero or more .@<< groups
o %n optional OT@+& group
7* of %4&
o +91S! or +91 statement.
%fter the S+!+7 operation> control passes to the statement follo;ing the first .@<< condition
that is satisfied. %ll statements are then e<ecuted until the ne<t .@<< operation. 7ontrol passes
to the +91S! statement $only one .@<< is e<ecuted'. If no .@<< condition is satisfied and an
OT@+& operation is specified> control passes to the statement follo;ing the OT@+& operation.
If no .@<< condition is satisfied and no OT@+& operation is specified> control transfers to the
statement follo;ing the +91S! operation of the select group.
O,CE0 1Other2
Traps all conditions that ;ere not satisfied ;ithin a S+!+7 group of conditions. This statement
is the eEui"alent of the +!S+ statement in a I3<< condition.
I,E0 1Iterate2
3orci)ly )ranch to the end of a 1O> 1O6<< or a 1O.<< condition )ypassing all other
statements in the 1O group. 7ontrol is thus passed to the ne<t iteration of the 1O processing
loop.
"EAFE 1"eave2
3orce terminate a loop processing> control ;ould then pass to the statement immediately
follo;ing the +91 or +91yy statement is the case may )e.
77 of %4&
'ile (perations
,ile Specification /om#inations)
S=20 F692
N.:2
F692
TE=2
F692
D2@64;.A6<;
F692
F<?:.A
R20<?1
A11?2@@
TE=2
D2C602 R20<?1
A116A6<;
U@2?
C<;A?<9
6np't Mo)e: 4pco)e" can !e performe) : 0.AD; 0.AD.; 0.DP.; 0.ADP; S.9<<; S.979; 18A6F;
(4P.F; 1<4S.)
F I F E K DISK (UC)
6np't Mo)e: 4pco)e" can !e performe) : W069.; 0.AD; 0.DP.; 0.AD.; 0.ADP; S.9<<;
S.979;18A6F; (4P.F; 1<4S.)
F I F E K DISK A (UC)
=p)ate Mo)e : 4pco)e" can !e performe) : 0.AD; 0.AD.; 0.DP.; 0.ADP; S.9<<; S.979;
18A6F;=PDA9; D.<.9( 4P.F; 1<4S.)
F U F E K DISK (UC)
=p)ate Mo)e : 4pco)e" can !e performe) : W069.; =PDA9; D.<.9; 0.AD; 0.AD.; 0.DP.;
0.ADP;S.9<<; S.979; 18A6F; (4P.F; 1<4S.)
F U F E K DISK A (UC)
4'tp't Mo)e: W069.; (4P.F; 1<4S.)
F O K A (UC)
OEN 1Open (ile for rocessin$2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
OEN 3ile 9ame ZZ +& ZZ
Opens a named file. This operation need )e done only for those files that ;ere specified as M6ser
controlN in the file specifications. If M6ser controlN ;as not specified> &#? ta=es care of opening
files upon program in"ocation.
C"O%E 1Close (iles2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
C"O%E 3ile 9ame ZZ +& ZZ
The e<plicit 7!OS+ operation closes one or more files or de"ices and disconnects them from the
program. The file cannot )e used again in the program unless you specify an e<plicit O#+9 for
that file. % 7!OS+ operation to an already closed file does not produce an error.
+<ample:
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
--ilename6P.A-....0len<I1A64vIloc.DeviceH......I./itHH.ntr2HA....=..
-.C1P9F 4 . D6SI =1
--6<.C 6 . D6SI
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
7& of %4&
1N
1N
1 &@F&3 4P.F .C1P9F && &&*F4 S=11.SS
1 &@F&3F&& W069..00.1
1N
1N
1 1<4S.-6<.C
%E,"" 1%et "ower "imits2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Search
argument/O@ID%!/
O!OD%!
%E,"" 3ile 9ame 9& +& +2
The S+T!! operation positions a file at the ne<t record that has a =ey or relati"e
record num)er that is greater than or eEual to the search argument $=ey or relati"e
record num)er' specified in factor ,. The file must )e a full procedural file $identified
)y an 3 in position ,5 of the file description specifications'.
3igurati"e constants can )e used to position the file. In most cases> O!OD%! positions the file so
that the first read retrie"es the record ;ith the lo;est =ey. In most cases> O@ID%! positions
the file so that a &+%1# retrie"es the last record in the file> or a &+%1 recei"es an end-of-file
indication.
&emem)er the follo;ing ;hen using the S+T!! operation:
If the S+T!! operation is not successful $no records found condition'> the file is positioned to
the end of the file.
.hen end of file is reached on a file )eing processed )y S+T!!> another S+T!! can )e issued
to reposition the file.
S+T!! does not cause the system to access a data record. If you are only interested in "erifying
that a =ey actually e<ists> S+T!! ;ith an eEual indicator
$positions 4-4(' is a )etter performing solution than the 7@%I9 operation in most cases. 6nder
special cases of a multiple format logical file ;ith sparse =eys> 7@%I9 can )e a faster solution
than S+T!!.
+<ample:
In this e<ample> the file O&13I! contains order records. The =ey field is the order
num)er $O&1+&' field. There are multiple records for each order. O&13I! loo=s li=e
this in the calculation specifications:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O&1+& %E,"" O&13I! 44
944 @O,O 9OT391
The S+T!! operation positions the file at the first ,[, record. Cecause there are ,0, records>
indicator 44 is set on and the ?OTO operation is
not processed.
70 of %4&
%E,@, 1%et @reater ,han2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Search
argument/O@ID%!/
O!OD%!
%E,@, 3ile 9ame 9& +& ZZ
The S+T?T operation positions a file at the ne<t record ;ith a =ey or relati"e record
num)er that is greater than the =ey or relati"e record num)er specified in factor ,.
The file must )e a full procedural file $identified )y an 3 in position ,5 of the file
description specifications'.
In this e<ample> the file O&13I! contains order records. The =ey field is the order
num)er $O&1+&' field. There are multiple records for each order. O&13I! loo=s li=e
this in the calculation specifications:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O&1+& %E,@, O&13I!
0EA' O&13I! 0
0EA' 10ea& a 0ecor&2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
0EA' 3ile
9ame/&ecord
9ame
1ata structure ZZ+&+O3
The &+%1 operation reads the record> currently pointed to> from a full procedural file
Example:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O!OD%! %E,"" O&13I!
0EA' O&13I! 0
OI90 'OHED M0N
+
+
+
0EA' O&13I! 0
EN''O
0EA'E 10ea& EGual /e!2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Search argument 0EA'E 3ile
9ame/&ecord
9ame
1ata structure ZZ+&+O3
&0 of %4&
The &+%1+ operation retrie"es the ne<t seEuential record from a full procedural file
if the =ey of the record matches the search argument.
+<ample:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O!OD%! %E,"" O&13I!
O&1+& 0EA'E O&13I! 0
OI90 'OHED M0N
+
+
+
O&1+& 0EA'E O&13I! 0
EN''O
0EA'10ea& a revious 0ecor&2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
0EA' 3ile
9ame/&ecord
9ame
1ata structure ZZ+&CO3
The &+%1# operation reads the prior record from a full procedural file
+<ample:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O@ID%! %E,@, O&13I!
0EA' O&13I! 0
OI90 'OHED M0N
+
+
+
0EA' O&13I! 0
EN''O
0E'E 10ea& rior EGual2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Search argument 0E'E 3ile
9ame/&ecord
9ame
1ata structure ZZ+&CO3
The &+1#+ operation retrie"es the ne<t prior seEuential record from a full procedural
file if the =ey of the record matches the search argument. If the =ey of the record
does not match the search argument>
+<ample:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
&% of %4&
O@ID%! %E,@, O&13I!
O&1+& 0E'E O&13I! 0
OI90 'OHED M0N
+
+
+
O&1+& 0E'E O&13I! 0
EN''O
CCAIN 10an&om 0etrieval from a (ile2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Search argument CCAIN 3ile 9ame 1ata structure 9&+& ZZ
The 7@%I9 operation retrie"es a record from a full procedural file
Example:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O&1+& CCAIN O&13I! (0
OI90 I(ED M,N
H0I,E 1Create New 0ecor&s2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
H0I,E 3ile 9ame 1ata structure ZZ+& ZZ
The .&IT+ operation ;rites a ne; record to a file.
+<ample:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
H0I,E O&13I! (,
U'A, 1)o&if! Existin$ 0ecor&2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
U'A, 3ile 9ame 1ata structure ZZ+& ZZ
The 6#1%T operation modifies the last record retrie"ed for processing from an update dis= file
or su)file. 9o other operation should )e performed on the file )et;een the input operation that
retrie"ed the record and the 6#1%T operation.
&emem)er the follo;ing ;hen using the 6#1%T operation:
.hen a record format name is specified in factor -> the current "alues in the program for
the fields in the record definition are used to modify the record.
&2 of %4&
If some )ut not all fields in a record are to )e updated> use the output specifications and
not the 6#1%T operation.
Cefore 6#1%T is issued to a file or record> a "alid input operation ;ith loc= $&+%1>
&+%17> &+%1+> &+%1#> &+1#+> 7@%I9> or primary/secondary file' must )e issued
to the same file or record. If the read operation returns ;ith an error condition or if it ;as
read ;ithout loc=ing> the record is not loc=ed and 6#1%T cannot )e issued. The record
must )e read again ;ith the default of )lan= in position 48 to specify a loc= reEuest.
7onsecuti"e 6#1%T operations to the same file or record are not "alid. Inter"ening
successful read operations must )e issued.
Example:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
O&1+& CCAIN O&13I! (0
OI90 I(ED M0N
+
+
+
U'A, O&13I! (
'E"E, 1'elete 0ecor&2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
Search %rguement 'E"E, 3ile 9ame ZZ+& ZZ
The 1+!+T operation deletes a record from a data)ase file. The file must )e an update file
$identified )y a 6 in position ,4. of the file description specifications' The deleted record can
ne"er )e retrie"ed.
If factor , contains no entry> the 1+!+T operation deletes the current record $the last record
retrie"ed'. The record must ha"e )een loc=ed )y a pre"ious input operation $for e<ample>
7@%I9 or &+%1'.
Example:
N9-9N9.No3 (actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
'E"E, O&13I! (
Calling (perations
CA"" 1Call a ro$ram2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
CA"" #rogram
name
#list name ZZ+& !&
The CALL operation passes control to the program specified in factor 2.
Factor 2 must contain a character entr specifing the name of the program to be
called.
&$ of %4&
A0) 1I&entif! arameters2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
Target field A0) Source
field
#arameter
The result field must contain the name of a field> data structure> or array that is to )e the
parameter. %lso> the result field of a non- O+9T&G #!IST can contain an array element. The
result field can )e numeric or character. The result field cannot contain OI9> OI9<<> OI9><<> a
la)el> a literal> a data-area name> a data-area data structure name> a glo)ally initialiFed data
structure> a data structure ;ith initialiFed su)fields> a data structure ;ith a compile time array as
a su)field> or a ta)le name. In addition> an array element> a data-structure su)field name> the
name of a compile-time array and the name of a program status or file information data structure
OI931S' are not allo;ed in the result field of #%&M specified for an O+9T&G #!IST. % field
name can )e specified only once in an O+9T&G #!IST.
If an array is specified in the result field> the area defined for the array is passed to
the called program. .hen a data structure ;ith multiple occurrences is passed to
the called program> all occurrences of the data structure are passed as a single
field. @o;e"er> if a su)field of a multiple occurrence data structure is specified in
the result field> only the current occurrence of the su)field is passed to the called
program.
+ach parameter field has only one storage locationI it is in the calling program.
The address of the storage location of the result field is passed to the called program on a #%&M
operation. If the called program changes the "alue of a parameter> it changes the data at that
storage location. .hen control returns to the calling program> the "alue of the parameter in the
calling program $that is> the result field' has changed. +"en if the called program ends in error
after it changes the "alue of a parameter> the changed "alue e<ists in the calling program. To
preser"e the information passed to the called program for later use> specify in factor - the name
of the field that contains the information you ;ant to pass to the called program. 3actor - is
copied into the result field> and the storage address of the result field is passed to the called
program.
Cecause the program accesses the parameter fields )y address> not field name>
the calling and called parameters do not ha"e to use the same field names for
fields that are passed. The attri)utes of the corresponding parameter fields in the
calling and called programs should )e the same. If they are not> undesira)le
results may occur.
.hen a 7%!! operation runs> the follo;ing occurs:
,. In the calling program> the contents of the factor - field of a #%&M operation are copied
into the result field $recei"er field' of the same #%&M operation.
-. In the called program> after it recei"es control and after any normal program
initialiFation> the contents of the result field of a #%&M operation are copied into the
factor , field $recei"er field' of the same #%&M operation.
&4 of %4&
8. In the called program> ;hen control is returned to the calling program> the contents of the
factor - field of a #%&M operation are copied into the result field $recei"er field' of the
same #%&M operation. This mo"e does not occur if the called program ends a)normally.
4. 6pon return to the calling program> the contents of the result field of a #%&M operation
in the calling program are copied into the factor , field $recei"er field' of the same
#%&M operation. This mo"e does not occur if the called program ends a)normally or if
an error occurs on the 7%!! operation.
"I%, 1I&entif! a arameter "ist2
(actor - Co&e (actor . 0esult
(iel&
In&icators
CI "O ED
"I%, name "I%,
3actor , must contain the name of the parameter list. If the parameter list is the
entry parameter list of a called program> factor , must contain O+9T&G. Only one
O+9T&G parameter list can occur in a program. % parameter list is ended ;hen an
operation other than #%&M is encountered.
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N
1N 6n the calling program; the 1A<< operation call" P047# an)
1N allow" P047# to acce"" the )ata in the parameter li"t fiel)".
C CALL !PRO"2! PLIST1
1N
1N 6n the "econ) PA0M "tatement; when 1A<< i" proce""e); the
1N content" of factor #; >6F#@; are place) in the re"'lt fiel);
1N :59.. When P047# ret'rn" control; the content" of the re"'lt
1N fiel); :59.; are place) in the factor 1 fiel); >6F%0. Fote
1N that factor 1 an) factor # entrie" on a PA0M are optional.
1N
C PLIST1 PLIST
C PARM AMT 52
C &IN3# PARM &IN2H B(TE 1
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
C CALL !PRO"2!
1N 6n thi" e/ample; the PA0M operation" imme)iatel2 follow a
1N 1A<< operation in"tea) of a P<6S9 operation.
C PARM AMT 52
C &IN3# PARM &IN2H B(TE 1
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH
1N 6n the calle) program; P047#; >.F905 in factor 1 of the
1N P<6S9 "tatement i)entifie" it a" the entr2 parameter li"t.
1N When control tran"fer" to P047#; the content" of the re"'lt
1N fiel)" (-<D1 an) -<D7) of the parameter li"t are place) in
1N the factor 1 fiel)" (-<DA an) -<DD). When the calle) program
1N ret'rn"; the content" of the factor # fiel)" of the parameter
1N li"t (-<D: an) -<D.) are place) in the re"'lt fiel)" (-<D1
1N an) -<D7). All of the fiel)" are )efine) el"ewhere in the
1N program.
C &ENTR( PLIST
C FLDA PARM FLDB FLDC
C FLDD PARM FLDE FLD"
&. of %4&
:ranching (perations
7%C<<> T%? and 7%S<< ;hich are pre"iously descri)ed under compare operations also form a
part of )ranching operations.
@O,O1@o to2
This statement transfers control ;ithin the program to the named statement
I,E0 1Iterate2
3orci)ly )ranch to the end of a 1O> 1O6<<> or 1O.<< condition )ypassing all other statements
in the 1O group. 7ontrol is thus passed to the ne<t iteration of the 1O processing loop.
"EAFE 1"eave2
3orce Terminate a loop processing. 7ontrol ;ould then pass to the statement immediately follo;ing
the +91 of +91yy statement as the case may )e.
Array (perations
)OFEA 1)ove arra!2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
MOVEA So'rce 9arget H ( G:
The MOD+% operation transfers character or numeric "alues from factor - to the result field.
$7ertain restrictions apply ;hen mo"ing numeric "alues.' 3actor - or the result field must
contain an array. 3actor - and the result field cannot specify the same array e"en if the array is
inde<ed.
Gou can use MOD+% ;ith a pac=ed> )inary> Foned> or character array. Gou can:
\ Mo"e se"eral contiguous character array elements to a single character field
\ Mo"e a single character field to se"eral contiguous character array elements
\ Mo"e contiguous array elements to contiguous elements of another array.
Mo"ement of data starts ;ith the first element of an array if the array is not inde<ed or ;ith the
element specified if the array is inde<ed. The mo"ement of data ends ;hen the last array
element is mo"ed or filled.
.hen the result field contains the indicator array> all indicators affected )y the MOD+%
operation are noted in the cross-reference listing.
+<ample:
&* of %4&
MOD+% 3I+!1% %&&%
MOD+% M%C71+N %&&%
MOD+% -4 %&&%
MOD+% 3I+!1% %&&%>A
MOD+% M%C71+N %&&%>A
MOD+% -4 %&&%>A
MOD+% 3I+!1% %&&%>8
MOD+% M%C71+N %&&%>8
MOD+% -4 %&&%>8
MOD+% %&&% 3I+!1%
MOD+% %&&%>A 3I+!1C
MOD+% %&&%>8 3I+!17
MOD+% M,,,,N OI9>-4
MOD+% M0000N OI9>-4
MOD+% M,0,0N OI9>-4
MOD+% O%!!N0N OI9>-4
I(OO, 1Arra! ,otal2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
*FOOT Arra2 name S'm H ( G
Sum of the indi"idual elements of a num)eric array in a named "aria)le.
A3OOT %&&%G 3I+!1%
"O/U 1"oo#up2
Search for a character> named "aria)le or a literal from a specified position in an array
3I+!1% !O:6# %&&%
M%C71+N !O:6# %&&%
-4 !O:6# %&&%
3I+!1% !O:6# %&&%>8
M%C71+N !O:6# %&&%>8
-4 !O:6# %&&%>8
&7 of %4&
3I+!1% !O:6# %&&%>A
M%C71+N !O:6# %&&%>A
-4 !O:6# %&&%>A
#lease refer to MArra!s <,ables an& 'ata %tructuresA section for More information
%O0,A 1%ort arra!2
(actor - Co&e (actor . 0esult (iel& In&icators
CI "O ED
SORTA Arra2 name


Sort an array of ta)le specified in factor - in the seEuence mentioned in the array or ta)le
specification
+<ample:
SO&T% %&&%
!ata Area (perations
#lease refer to MArra!s <,ables an& 'ata %tructuresA section for More information .1ata area
opcodes are discussed in detail.
Commitment Control (perations
CO)I, 1Commit2
Ma=e all data)ase changes since the pre"ious commit or roll)ac= operation.
7OMIT
0O"B/ 10oll Bac#2
6ndelete all data)ase changes since the pre"ious commit or roll)ac= operation
0@B499 In&icator
Indicators are logical s;itches of )inary nature. Indicators may ha"e a "alue of M0N or M,N at any
time.
The 1ifferent =inds of indicators used in &#?/400 are:
O"erflo; indicators H these are used to control of printing headings ;hen s=ipping to ne; pages
in a report. Indicators that may )e used for o"erflo; are
O% to O?> OD
0, to ((
&& of %4&
eecord identifiers H these indicators are used to identify the occurrence of a specific type of
records in program-descri)ed files. Indicators that may )e used are
0, to ((
@, to @(
!, to !(
!&
6, to 6
&T
7ontrol indicators H these indicators are used to condition processing of printing of le"el )rea=s
in &#? logic cycle programs.
&esulting Indicators H these indicators are specified for certain opcodes to identify the normal or
a)normal processing of an op code. These Indicators are also used ;hen chec=ing for end-of-file
conditions etc.
E1amples 'or 'ile processing:
-P6 synta1 to process an e1ternally de)ined Physical 'ile:
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
--ilename6P.A-....0len<I1A64vIloc.DeviceH......I./itHH.ntr2HA....=1.
FSAMPLE IF E K DISK
-N
.ntrie" for Ph2"ical file )efinition:
F692 ;.:2 (0<9 H -14) Q Fame of the Ph2"ical file
F692 TE=2 (0<9B:; 15)( letter 6 )efine" the ph2"ical file a" an inp't file .4ther t2pe" are
=;4;1 an) D
F692 D2@64;.A6<; (0<9B:; 1')- <etter - )efine" the file i" f'll2 proce)'ral file
F692 F<?:.A(0<9B:; 1))- <etter . )enote" the -ile i" e/ternall2 )efine). - )enote" program
)efine)
R20<?1 .11?2@@ AE=2 (C<9B:; 31)- I in)icate" the file i" acce""e) in the e2 val'e or)er; a :lan
entr2 )enote" the file will !e proce""e) in arrival "eM'ence.
D2C602 (C<9B:;@ 4# I 4')-Di" for Ph2"ical or logical file
-P6 synta1 to process a Program de)ined Physical 'ile:
F S=206360.A6<;-
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
--ilename6P.A-....0len<I1A64vIloc.DeviceH......I./itHH.ntr2HA....=1.
FSAMPLE2 IF F 5, K DISK
-N
.ntrie" for Ph2"ical file )efinition:
F692 ;.:2 (0<9 H -14) I Fame of the Ph2"ical file
&0 of %4&
F692 TE=2 (0<9B:; 15)( letter 6 )efine" the ph2"ical file a" an inp't file .4ther t2pe" are
=;4;1 an) D
F692 D2@64;.A6<; (0<9B:; 1')- <etter - )efine" the file i" f'll2 proce)'ral file
F692 F<?:.A(0<9B:; 1))- <etter - )enote" program )efine)

R20<?1 92;4A5(C<9B:; 24 -2H) Q 0ecor) length i" ?3
R20<?1 .11?2@@ AE=2 (C<9B:; 31)- :lan entr2 )enote" the file will !e proce""e) in arrival
"eM'ence.
D2C602 (C<9B:;@ 4# I 4')- Di" for Ph2"ical or logical file
I;=BA S=206360.A6<;@-

>.. 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
6-ilenameSMF40iPo"1F11Po"#F11Po"%F11................................>
6SAMP<.# AA 01
6....................................P-rom9oHHD-iel)H<1M1-rPlMnGr...>
6 % 10 PA09F4
6 11 1D0A95
6 1@ #0 95P.
6 #1 #1 14D.
6 ## #? <41A9F
R20<?1 I12;A6360.A6<; S20A6<; (C<9B:;@ H-42)
F692J?20<?1 N.:2 (C<9B:; H -14) IFame of the inp'tfile )efine)
S2>B2;02 (0<9B:;@ (15-1')- An2 two letter" "ho'l) !e entere).
R20<?1 612;A63E6;4 6;160.A<? (0<9B:; 1) -2#) - A 'niM'e # )igit F'm!er

%ddition &ecommended &eading Material:
,. S70(-,,5,-- &#?/400 6serNs ?uide
- S70(-,(-- &#?/400 &eference Manual
8 S70(-,84(-0, S%% %1/7ycle &#?/400 &eference Manual
00 of %4&
Chapter .II: Sub)iles

% su)file is a special type of %S/400 display-file record. It is designed to hold column )ased list
of data and to display that list in a column format. Su) Su)files are used ;hen you ;ant to
display multiple records on the display that ha"e the same record layout.
The t;o ma*or reasons for using su)files are producti"ity and simplicity. % comple< loo=ing
1isplay file can )e totally ;ritten in a matter of minutes and ta=es only fe; lines of code.
Modifying a su)file program is much easier than modifying a non-su)file program> especially
since there is much less program code to handle. The reason su)file programs are easy to ;rite
and maintain is )ecause most of the functionality resides ;ithin the 11S specifications of the
display file.
% su)file may contain a ma<imum of (((( &ecords.
% su)file is of temporary nature and is acti"e only for the duration of one program
e<ecution.
Components o) Sub)ile
Su)file mainly reEuires t;o formats> ".i.F.>
%UB(I"E (O0)A, J%("K+
%UB(I"E CON,0O" (O0)A, J%("C,"K+
Sub)ile )ormat ;S'&< defines the layout of the records in the su)file. The Su)file format is
actually a file that resides in memory. The su)file format descri)es the su)file records> and also
contains data. The 11S =ey;ord to descri)e the su)file format is S3!. The S3! :ey;ord is the
mandatory =ey;ord for any su)file.
Sub)ile control )ormat ;S'&C"&< defines the su)file as a ;hole> such as ho; many records
it can contain> ho; many records to display on a screen and so on. It is also used to display the
su)file> or to clear records out of a su)file. The 11S =ey;ord used to define a su)file control
format is S3!7T!.
There are -- =ey;ords in Su)files ,7 in S3!7T! format V 4 in S3! format.
,he )an&ator! /e!wor&s in subfiles are
%(" J %ubfile 0ecor& (ormatK
%("C," J %ubfile Control (ormatK
%("'% J %ubfile 'ispla!K
%("'%C," J %ubfile 'ispla! ControlK
0% of %4&
%("A@ J %ubfile a$eK
%("%IE J%ubfile %iLe K

Sub)ile /ey0ords
The follo;ing =ey;ords are defined in the su)file control record format and are attri)uted to all
the record for the su)file.
%(" %ubfile 0ecor& (ormat
Identifies the named record format as a su)file record format
%"(C"0 %ubfile clear
6sed to indicate that ;hen the associated indicator is set on the ne<t output operation to the
su)file record format to clear all the record of the su)file.
%("C," %ubfile control recor& format
Identifies the named record format as the su)file control record format
%("'", 'elete subfile
6sed to indicate that ;hen the associated indicator is set on the ne<t output operation to the
su)file record format is to delete the su)file. The su)file ;ould therefore )e inacti"e.
%("'0O %ubfile &rop
6sed to indicate that ;hen the associated command =ey is pressed> the secondary line$s' of a
multiple line of su)file record are to )e displayed. 6pon the first output operation of the su)file>
only the first line of each su)file record ;ould )e displayed.
%("'% 'ispla! subfile
6sed to indicate that ;hen the associated indicator is set on> the su)file is to )e displayed upon
the ne<t output operation.
%("'%C," 'ispla! subfile control
6sed to indicate that the associated indicator is set on> the su)file record format is to )e
displayed upon the ne<t output operation.
%("EN' %ubfile en&
6sed to indicate that ;hen the associated indicator is sent on> the constant MMore]N normally
displayed at the )ottom of the e"ery multi-page su)file is suppressed. This condition is e<ercised
;hen there are no more su)file records to )e displayed.
%("INE InitialiLe subfile
6sed to indicate that ;hen the associated indicator is set on> the ne<t output operation to the
su)file is to initialise all the alphanumeric "aria)le in the su)file record to )lan=s and all the
numeric "aria)le to Feros in e"ery record for the su)file.
%(""IN %ubfile line
6sed to specify the num)er of su)file records that should )e displayed in the line of display
%(")%@ %ubfile messa$e
6sed to associate an error message ;ith an error condition at the su)file control record le"el
%("A@ %ubfile pa$e
6sed to specify the num)er of su)file records to )e displayed in one page of display
%("0C'NB0 %ubfile recor& number
02 of %4&
6sed to associate a "aria)le name ;hich ;ould contain the "alue of a "alid su)file relati"e
record num)er. The page of the su)file containing the record ;hose relati"e record num)er is
present in this "aria)le ;ould )e displayed upon the ne<t output operation to the su)file.
%("0NA %ubfile not active
6sed to specify that the named su)file record format is to )e made inacti"e. .hen used in
association ;ith the initialise su)file $S!3I9B' =ey;ord> this has the effect of deleting the
su)file.
%("0O"FA" %ubfile roll value
6sed to specify the num)er of records that are to )e paged up/do;n ;hen the &oll 6p/&oll
1o;n =eys are used
%("%IE %ubfile siLe
6sed to specify the ma<imum num)er of records that are to displayed in a su)file at a time. The
follo;ing =ey;ord is the only =ey;ord that is applica)le at the su)file record. Thus this
=ey;ord> may )e applica)le or not to indi"idual records in the su)file.
%(" %ubfile recor& format
Identifies the named record format as a su)file record format
%("NI,CC@ %ubfile next chan$e& recor&
%ssociate an indicator ;ith this =ey;ord. This indicator may )e set on/off indi"idually for each
record in the su)file. If this indicator set on> then the modified data tag for the associated su)file
record is set on. In this case> the su)file record can )e pic=ed )y a &+%17 operation ;ithin the
program.
Sub)ile !ata !escription Speci)ication :
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! (isplay ,ile for LO(-LL-S.0,IL-S !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
" #$%$I&'2( )* !#$+,
" -"*+'*+ .E/IT.,
" 0 $FL0E- $FL
" -1$"# 0 2 ) 310EFFL#'0-1$T4-1$"# 526FLI734-1$T,
" -1$89 0 2 ) 1:0EFFL#'0-1$T4-1$89 526FLI734-1$T,
" -1$82 0 2 ) +0EFFL#'0-1$T4-1$82 526FLI734-1$T,
" 0 $FL-TL $FL-TL'$FL0E-,
" 2;E0L"<
" $FL#$%
" $FL#$%-TL
" 1* $FL-L0
" 2* $FLE8#'!920E,
" $FL$I&'**13,
" $FL%"5'**1(,
" 1 2*. =206 $-0EE8 F20 -1$T29E0 E8>1I0<.
" 1 +1$E0
" 1 ??#"TE
" E#T-#E'<,
" 3 (.-1$T 8197E0.
" 3 1@.-1$T29E0 8"9E .
" 3 3(.-1$T29E0 "##0E$$.
" 0 F22TE0
" 2;E0L"<
" 2( +.F+ A E/IT.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -nd of data !!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!
0$ of %4&
Handling Sub)iles in -P6 Programs
'ile !eclarations
The 1isplay file is declared as file in the file specification. 1etails that are
included are
9ame of the display file
Type ;hich is M7N and 1esignation M3N to indicate com)ined 3ully procedural
file
1e"ice definition ;hich is M.O&:ST9N to indicate a display file
In the 7ontinuation specification of the file specification> a "aria)le name is
identified as the su)file relati"e record num)er ;ith the follo;ing &#? reser"ed ;ord
&&9C& :S3I!+ S6C3I!
In the a)o"e e<ample> a su)file record format S6C3I! ;ith a relati"e record num)er
&&9C& is declared.
+<ample:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 0eginning of data !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! -1ample for ,ile specification !
! %hsical File - -1$T !
! #ispla File - $FL-1$ !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
F-1$T IF E 6 #I$6
F$FL-1$ -F E =206$T8
F -218T 6$FILE $FL0E-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -nd of data !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Calculation Speci)ication
.ithin the M7N specification itself> there ;ould not )e any reference in the display
file name.
%ll references ;ould )e to particular record formats only.
Indi"idual record formats may )e returned or read from the screen
If an output operation is done> $that is .&IT+ or related operation' the display is
sent to the screen.
If an input operation is done> $that is> &+%1 or related operation' the display is
read from the screen and the displayed data is made a"aila)le to the program. %t
this point the control passes to the program.
Steps Involved In Sub)ile Programming :
I9ITI%!IB+ - InitialiFe the &&9 to Bero.
7!+%& - Set On the S3! clear indicator> clear S3!7T!> ;rite the
S3!7T! V setoff the Indicator
C6I!1 - !oad the su)file )y reading the #3 V ;riting the Su)file
record
3ormat.
1IS#!%G - Set on the S3!1S#7T! indicator V +A3MT the S3!7T!
#&O7+SS - #rocess 7hanged &ecords 6sing &+%17 or 7@%I9
opcodes
04 of %4&
3ulti page sub)iles:
There are three options for managing a multipage su)file:
,. !oad all Su)file
-. +<panding Su)file $%dding a page at a time.
8. Single page Su)file
Sub)ile &oad (ptions, Pros and Cons4
Subfile Load
Option
Code Issues User Issues
,. !oad all su)file
Simplest code
!imit of ((((
records
6ser has to ;ait until entire file is
loaded.
1ata is only updated ;hen a user ma=es
a change that reEuires reloading the
su)file
7hanges made to the data )y other users
or other programs after the su)file is
loaded ;ill not )e apparent.
-.+<panding su)file
7ode is more
comple<.
!imit of ((((
records.
Crief delay ;hene"er a page is loaded.
#ages added ;hen the #age 1o;n =ey is
pressed are updated at the time they are
added to the su)file. @o;e"er >
su)seEuent changes to the data made )y
other users or #rograms are not
displayed until a user ma=es a change
that reEuires reloading the su)file.
8. Single #age Su)file
Most complicated
7ode .
6se least
memory.
9o SiFe limit.
Crief delay ;hene"er the page up =ey
or #age do;n =ey is pressed.
1ata is al;ays updated at the time of
processing a page up/#age do;n
reEuest.
&oad all Sub)ile:
The first method of loading a su)file is to load all of the records that you ;ant to display into
the su)file at one time. %fter this load is complete you can display the su)file> ;hich gi"es the
users access to all of the su)file records )y allo;ing them to roll )ac=;ards and for;ards. +"ery
record that you ;ant to display must )e loaded into the su)file )efore displaying the su)file.
Sometimes you may only load a fe; records into the su)file> other times you might load
hundreds. Cut for the load-all su)file method> you simply load e"ery record in )efore you display
the su)file.
!oading the su)file is accomplished )y ;riting the su)file records to the su)file format. Once
e"ery record has )een loaded> you can display the su)file )y ;riting the su)file control format.
0. of %4&
The su)file itself handles the roll =eys> and you donNt e"en ha"e to ma=e reference of them in
either the &#? program or the 11S specifications for the display file.
%UB(I"E A@E = %UB(I"E %IEE
O0
%UB(I"E %IEE 6 %UB(I"E A@E M -+
Ph2"ical file 9e"t:
A =F6A=.
A 0 9S90.1
A 14D. %
A FAM. #0
A A7. #P 0
A P84F. 10P 0
A I 14D.

A>>>>>>>>>>>>>>>
A S'!file for <oa) All:
A>>>>>>>>>>>>>>>
A 0 DS-01D S-<
A>RR9S SD #0040#0% 0%1411 09AM6< 0.<(K?01M0 ?@##(WDS
A 14D. 0 4 ? 40.--<D(9S90.1/14D. 09AM6</9.S9)
A FAM. 0 4 ? 1#0.--<D(9S90.1/FAM. 09AM6</9.S9)
A A7. 0 4 ? %%0.--<D(9S90.1/A7. 09AM6</9.S9)
A P84F. 0 4 ? 430.--<D(9S90.1/P84F. 09AM6</9.S9)
A 0 DS-19< S-<19<(DS-01D)
A>RR9S SD #0040#0% 0%4?04 09AM6< 0.<(K?01M0 ?@##(WDS
A S-<S6G(001?)
A S-<PA7(0014)
A 1-0%(0%)
A 1-0?(0?)
A 4K.0<A5
A &0 S-<DSP
A &1 S-<DSP19<
A &% S-<1<0
A &4 S-<.FD(>M40.)
A 1 #&B<oa) All S'!file ./ampleB
A DSPA90(=<)
A # %0B-or Demo P'rpo"e 4nl2B
A DSPA90(:<)
A DSPA90(=<)
A 4 4B1o)eB
A DSPA90(=<)
A 4 1#BFameB
A DSPA90(=<)
A 4 %%BAgeB
A DSPA90(=<)
A 4 43BPhoneB
A DSPA90(=<)

9he following i" the )i"pla2 file for loa) all "'!file".
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> B246;;6;4 <3 1.A. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> ./ample for .CPAFD6F7 S=:-6<. >
> Ph2"ical -ile ( 9.S9 >
> Di"pla2 -ile ( 9.S9DSP
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>
RP" =?<4?.: 3<? 9<.1 .99 @B/3692@
-9.S9 6- . I D6SI
-9.S9DSP 1- . W40IS9F
0* of %4&
- S-<00FIS-6<. DS-01D
1>
1 .CS0 6FGS0
1 .CS0 :<DS0
1 .CS0 DSPS0
1 S.94F <0
1>
1 6FGS0 :.7S0 //1lear "'!file
1 G(ADD>G.04S S-<00F 40
1 S.94F &% 1<0S-<
1 W069.DS-19<
1 S.94- &%
1 .FDS0
1>
1 DSPS0 :.7S0
1 S.94F &0&1 //Di"pla2 "'!file
1 >6F0% D4=.AB1B
1 W069.S-<-90
1 .C-M9DS-19<
1 >6F0% 6-.A B0B
1 >6F0? 6-.A B1B
1 .CS0 :<DS0
1 .FD6-
1 .FD6-
1>
1 .FDD4
1 .FDS0
1>
1 :<DS0 :.7S0 //:'il) S'!file
1 ><4KA< S.9<<9S90.1
1 0.AD 9S90.1 &4
1 >6F&4 D4W.AB0B
1 ADD 1 S-<00F
1 W069.DS-01D
1 0.AD 9S90.1 &4
1 .FDD4
1 .FDS0
>>>>>>>>>>>>>>>>>>>>>>>>>>> E;1 >>>>>>>>>>>>>>>>>>>

07 of %4&
E1panding Sub)ile:
The second method of loading a su)file is to start )y loading a specific num)er of records
into the su)file. Gou can then display the su)file to the user. If the information the user needs is
not currently loaded into the su)file> your program can load more su)file records )ehind those
already loaded. This techniEue is =no;n as an e<panding su)file.
If the user rolls for;ard $&O!! 6#'> then the su)file automatically s;itches the display to
su)file page t;o for you. @ere you ha"e to set the indicator for &O!! 6# =ey;ord in 11S and
handle it in the &#? program. &O!! 1O.9$#age 6p' is automatically ta=en care )y the
system.
One ad"antage of e<panding su)file o"er a load-all-su)file is that the su)file is displayed to the
user in a "ery sta)le amount of time> depending on ho; many records the program loads. .ith
the e<panding su)file> you can di"ide the load process into a fi<ed num)er of records. 3or
instance> suppose you load si< records at a time in an e<panding su)file> It ;ould not matter if
there ;ere a possi)ility of loading 4>000 records into the su)file> your program ;ould only load
si< records )efore it displays the su)file to the user. This method displays the screen to the user
"ery Euic=ly.
%UB(I"E A@E == %UB(I"E %IEE+
The follo;ing is the 11S code for display file $+<panding Su)file'
A> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A> > E*PANDIN" SUBFILES DA9. ( 1%/0?/1&&&. >
A> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A S'!file for ./pan)ing S'!file:
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A 0 DS-01D1 S-<
A 14D. 0 4 ? 40.--<D(9S90.1/14D. 09AM6</9.S9)
A FAM. 0 4 ? 1#0.--<D(9S90.1/FAM. 09AM6</9.S9)
A A7. 0 4 ? %%0.--<D(9S90.1/A7. 09AM6</9.S9)
A P84F. 0 4 ? 430.--<D(9S90.1/P84F. 09AM6</9.S9)
A 0 DS-19<1 S-<19<(DS-01D1)
A>RR9S SD #0040#0% 0%4344 09AM6< 0.<(K?01M0 ?@##(WDS
A SFLSIZ(##15)
A SFLPA"(###')
A 1-0%(0%)
A 1-0?(0?)
A 04<<=P(03)
A 4K.0<A5
A &0 S-<DSP
A &1 S-<DSP19<
A &% S-<1<0
A &4 S-<.FD(>M40.)
A 1 #&B./pan)ing S'!file ./ampleB
A DSPA90(=<)
A # %0B-or Demo P'rpo"e 4nl2B
A DSPA90(:<)
A DSPA90(=<)
A 4 4B1o)eB
A DSPA90(=<)
A 4 1#BFameB
A DSPA90(=<)
A 4 %%BAgeB
0& of %4&
A DSPA90(=<)
A 4 43BPhoneB
A DSPA90(=<)
A>>>>>>>>>>>
A S-<01DF:0
A>>>>>>>>>>>
A 01DF:0 4S 08 S-<01DF:0
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
9he following i" the 0P7 program for ./pan)ing "'!file
>>>>>>>>>>>>>>>> B246;;6;4 <3 1.A.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> ./ample for PA7.(:5(PA7. :=6<D S=:-6<.
> Ph2"ical -ile ( 9.S9
> Di"pla2 -ile ( 9.S9DSP
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> B246;;6;4 <3 1.A. &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
-9.S9 6- . I D6SI
-9.S9DSP 1- . W40IS9F
- S-<00FIS-6<. DS-01D1
1>
1 .CS0 6FGS0
1 .CS0 :<DS0
1 .CS0 DSPS0
1 S.94F <0
1>
1 >6FGS0 :.7S0
1>
1 G(ADD>G.04S S-<00F 40
1 ><4KA< S.9<<9S90.1
1 .FDS0
1>
1 6FGS0 :.7S0
1 S.94F &% 1<0S-<
1 W069.DS-19<1
1 S.94- &%
1 .FDS0
1>
1 DSPS0 :.7S0
1 S.94F &0&1
1 >6F0% D4=.AB1B
1 W069.S-<-90
1 .C-M9DS-19<1
1 >6F0% 6-.A B0B
1 >6F0? 6-.A B1B
1 ><4KA< S.9<<9S90.1
1 .CS0 :<DS0
1 .FD6-
1 >6F03 6-.A B1B //Page Down or 0oll'p
1 .CS0 :<DS0
1 .FD6-
1 .FD6-
1>
1 .FDD4
1 .FDS0
1>
1 :<DS0 :.7S0
1 G(ADD>G.04S 14=F9 40
1 0.AD 9S90.1 &4
1 >6F&4 D4W.AB0B
1> 14=F9 AFD<9D //S-<PA7 * %
1 ADD 1 S-<00F
1 ADD 1 14=F9
1 W069.DS-01D1
1 14=F9 6-.A 1
1 G(ADDS-<00F 01DF:0 // Move 00F to S-<01DF:0
1 .FD6-
1 14=F9 6-.A D
1 <.AK.
1 .FD6-
00 of %4&
1 0.AD 9S90.1 &4
1 .FDD4
1 .FDS0

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>E;1 <3 1.A. >>>>>>>>>>>>>>>>>>>>>>
Single Page Sub)ile:
The third method of loading is =no;n as a single-page load. In this process you only load the
num)er of su)file records that can )e displayed on the screen at one time. If the information the
user needs is not in the su)file> then the e<isting su)file records are discarded> and another page
;orth of su)file records is loaded.If the information the user ;ants to see is not on this page of
su)file records> then you canNt *ust add more records to the su)file li=e you do in an e<panding
su)file method. Gou must first clear the e<isting records out of the su)file. Gou clear a su)file )y
setting on an indicator located in the su)file control format that controls the clear operation. Then
you ;rite the su)file control format> ;hich remo"es all data from the su)file.
This type of su)file is used ;hen there are more than (((( records in a data)ase.
%UB(I"E A@E 6 %UB(I"E %IEE
The follo;ing is the 11S for #age-Cy-#age Cuild su)file
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
A& D6@=9.E F692 3<? LOAD-ALL-SUBFILES
>
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A S'!file Single Page S'!file:
A>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A 0 DS-01D# S-<
A 14D. 0 4 ? 40.--<D(9S90.1/14D. 09AM6</9.S9)
A FAM. 0 4 ? 1#0.--<D(9S90.1/FAM. 09AM6</9.S9)
A A7. 0 4 ? %%0.--<D(9S90.1/A7. 09AM6</9.S9)
A P84F. 0 4 ? 430.--<D(9S90.1/P84F. 09AM6</9.S9)
A 0 DS-19<# S-<19<(DS-01D#)
A S-<S6G(000D)
A S-<PA7(000D)
A 1-0%(0%)
A 1-0?(0?)
A F&4 04<<=P(03)
A 04<<D4WF(0@)
A 4K.0<A5
A &0 S-<DSP
A &1 S-<DSP19<
A &% S-<1<0
A &4 S-<.FD(>M40.)
A 1 #&B./pan)ing S'!file ./ampleB
A DSPA90(=<)
A # %0B-or Demo P'rpo"e 4nl2B
A DSPA90(:<)
A DSPA90(=<)
A 4 4B1o)eB
A DSPA90(=<)
A 4 1#BFameB
A DSPA90(=<)
A 4 %%BAgeB
A DSPA90(=<)
A 4 43BPhoneB
%00 of %4&
A DSPA90(=<)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> E;1 <3 1.A.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
RP" =?<4?.: 3<? P.42-BE-P.42 BB691 SB/3692
>>>>>>>>>>>>>>>> B246;;6;4 <3 1.A.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> ./ample for PA7.(:5(PA7. :=6<D S=:-6<.
> Ph2"ical -ile ( 9.S9
> Di"pla2 -ile ( 9.S9DSP
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-9.S9 6- . I D6SI
-9.S9DSP 1- . W40IS9F
- S-<00FIS-6<. DS-01D#
1>
1> .CS0 6FGS0
1 .CS0 :<DS0
1 .CS0 DSPS0
1 S.94F <0
1>
1 >6FGS0 :.7S0
1>
1 G(ADD>G.04S S-<00F 40
1 ><4KA< S.9<<9S90.1
1 .FDS0
1>
1 6FGS0 :.7S0
1 G(ADD>G.04S S-<00F 40
1 S.94F &% 1<0S-<
1 W069.DS-19<#
1 S.94- &%
1 .FDS0
1>
1 DSPS0 :.7S0
1 S.94F &0&1
1 >6F0% D4=.AB1B
1 W069.S-<-90
1 .C-M9DS-19<#
1>
1 >6F0% 6-.A B0B
1 >6F0? 6-.A B1B
1 ><4KA< S.9<<9S90.1
1 .CS0 :<DS0
1 .FD6-
1>
1 >6F03 6-.A B1B
1 .CS0 :<DS0
1 .FD6-
1>
1 >6F0@ 6-.A B1B
1 .CS0 :<D:S0
1 .FD6-
1 .FD6-
1>
1 .FDD4
- E8#$0
-!
- 7L#$0 7E5$0
- &-"##!&E02$ -218T (*
- E/$0 I8&$0
- 0E"# T$T0E- @(
- !I8@( #2=E>.*.
- -218T "8#LT?
- "## 1 $FL008
- "## 1 -218T
- -218T IFE> 1
- 92;E -2#E F-2#E +
- E8#IF
- =0ITE#$F0-#2
%0% of %4&
- -218T IFE> ?
- LE";E
- E8#IF
- 0E"# T$T0E- @(
- E8##2
- E8#$0
-!!!reposition
- 7L#7$0 7E5$0
- !I8@( IFE> .1.
- !BI;"L $ET5TT$T0E-
- EL$E
- F-2#E $ETLLT$T0E-
- E8#IF
-!!!
- #2 :
- 0E"#%T$T0E- @3
- !I8@3 IFE> .1.
- !L2;"L $ETLLT$T0E-
- LE";E
- E8#IF
- E8##2
-!!!
- &-"##!&E02$ -218T (*
- E/$0 7L#$0
- E8#$0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -nd of data !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'old and !rop capabilities :
The data to )e displayed on a screen freEuently e<ceeds the space a"aila)le to display it. This
is especially true ;hen you design displays ;ith su)files that are usually limited to a single ro;
of 0 characters.
The su)file =ey;ord that initially displays only the first line of the su)file records and reacts
to a function =ey )y s;itching into a multi line format is %("'0O .7on"ersely > The
=ey;ord %("(O"' initially displays the su)file in a multi line format and reacts to a
function =ey )y s;itching to a single line format .
+< :
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! -1ample for ,old and !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
" #$%$I&'2( )* !#$+,
" -"*+'*+ .E/IT.,
" 0 $FL0E- $FL
" -1$"# 0 2 ) 310EFFL#'0-1$T4-1$"# 526FLI734-1$T,
" -1$89 0 2 ) 1:0EFFL#'0-1$T4-1$89 526FLI734-1$T,
" -1$82 0 2 ) +0EFFL#'0-1$T4-1$82 526FLI734-1$T,
" 0 $FL-TL $FL-TL'$FL0E-,
" 2;E0L"<
" $FL#$%
" $FL#$%-TL
" 1* $FL-L0
" 2* $FLE8#'!920E,
S,L(!OP(/,02"
S,LSI3(0004"
S,LP5(0004"
]]..
]]
O 7305 is the function =ey that causes the display file to s;itch from the drop$single line format
' to the fold$multiline format'
%02 of %4&
O Su)file page siFe$ S3!#%?' has )een changed to the num)er of folded records that can )e
displayed.
(ther interesting Sub)ile /ey0ords:
S3!&719C& > S3!MO1+> S3!7S&&&9> S3!&O!D%!
dditional !ecommended !eading Material
,. S7-,-(54-- 1ata Management ?uide
%0$ of %4&
Chapter .III: Arrays5 "ables and !ata structures
Arrays:
%n array may )e defined as an arrangement of computer memory positions in one $or multiple'
dimension ;ith each position ha"ing the same attri)utes.
&#? only supports one dimensional arrays and does not directly support multi dimensional
arrays. @o; e"er they may )e simulated )y defining one or more Multiple Occurrence 1ata
structure
Array !escription :
The 9um)er of elements> siFe of the elements >type and seEuence are specified in the e<tension
specifications:
%ll +<tension Specification instructions must include an E in the column n 5 and immediately
follo; the last 3ile 1escription statement.
,. 7olumns 7-,0 not used.
-. (rom (ilename $columns ,,-,'.&eEuired for #rerun Time arrays. 3ile name> specified
in a 3ile 1escription statement $T in columns ,5' as program-defined $3 in column ,('
must )e entered left-*ustified in this field.
8. ,o (ilename $columns ,(--5'.Optional for #rerun Time arrays. If the array data is to the
end of the program> the name of the output file must )e entered left-*ustified in this field.
4. Arra! Name$columns -7-8-'.#rogrammer Hsupplied array name must )e entered in this
field .If the array is to )e inde<ed > the reEuired comma and inde< name or literal must )e
considered in the array specified in the program.
4. Number of Entries er recor& $columns 88-84'.Specifies ho; many indi"idual array
elements are stored on a record .+ntry is only for 7ompile and #rerun Time arrays.
5. Number of Entries er Arra! $columns 85-8(' specifies ho; many array elements are
stored in the array. &eEuired for all array types.
7. "en$th of Entr! $columns 40-4-'.Specifies the siFe of the array elements. %ll elements
of an array must )e the same siFe. +lements in character arrays may )e defined from , to
-45 )ytes. 9umeric array elements may )e defined from , to 80 )ytes
. BBB"B0$column 48'If the numeric data in a #rerun or &un Time array is stored in
pac=ed decimal format > the letter # must )e specified in this field. If the data is stored in
)inary format> a C must )e specified .If no entry is specified> the numeric array data is
stored as Foned decimal .7ompile Time array data is entered in a Foned decimal
format .%n ! entered in this field indicates that a separate sign stored to the left of the
"alue and an & to the right.
%04 of %4&
(. 'ecimal ositions $column 44' % )lan= in this field indicates that the array is
character .% num)er from 0 to ( defines the array elements as numeric ;ith the indicated
implied decimal positions. The entry cannot )e larger than the !ength of +ntry siFe.
,0. %eGuence $%/1' $column 44' If the array is not in a sorted order> this filed must )e
)lan= .If the data is in an ascending order> an % may )e entered .On the other hand> if the
array data is in a descending order> a 1 may )e specified .If seEuence is specified> an
^early e<itP is pro"ided for an unsuccessful eEual loo=up condition> reducing run times.
,,. Arra! Name$%lternating 3ormat'$columns 45-4,'.%n array name entered in this filed
indicates that t;o or more entries from t;o related array are stored in each stored in each
record> for e<ample >data for an SS9O element follo;ed )y data for a 9%M+ element.
9um)er of entries #er &ecord specifies ho; manyP pairsP are included on a record. Only
"alid for 7ompile and #rerun Time arrays.
,-. 7olumns 4--47.These four fields relate to the attri)ute of the alternating array. &efer to
items 7> > ( and ,0 for an e<planation of these fields.
&oading o) an array:
%rrays can )e classified into three types )y the nature of loading.
,' 7ompile Time array
-' #rerun time array
8' &un time array
Compile time array:
7ompile time arrays data is an integral ^@ard coded ^ part of an &#? #rogram. It must
)e included after a OO control statement entered in column , and - and follo; the last $O'
output statement in the program.
Salient features:
%rray 1ata is permanent.
%rray data is separated from the last output statement in the program )y OO in columns
, and -.
1ata is loaded ;hen the program is created.
+<ample:
%0. of %4&

>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
. M98 D 1# &
. DA5S 1# 1# # 0
$other &#? program statements '
0W----------------------------$last output specification statement'
OO---------------------------------$delimits compile time array from program'
0%96%&G 3+C&6%&G M%&7@ %#&I! M%G 069+ 1ata "alues for an array must
06!G %6?6ST S+#T+MC+& O7TOC+& 9OD+9C+& 1+7+MC+& )e the seme siFe .7ompile time
OO W--------------------------------------------------------------------------------------------------------- %rrays are separated )y O O
8,-8,808,808,8,808,808,
&elated array data must )e entered in the order the arrays are specified in the +<tension form.
9ote: %rray data items must )e siFe of the elements defined in the +<tension form. Smaller numeric data is padded ;ith high-order
Feros and alphanumeric data is padded ;ith lo;-order )lan=s.
+<tension Specification synta< and related data for t;o 7ompile Time arrays.
Prerun time Array:
1ata for #rerun Time arrays is stored e<ternally from the program in a physical file.
.hen processed > the array is created and loaded ;ith the data from the physical file )efore any
other files are processed.
Salient features:
%rray 1ata is stored in physical file
3ile that stores the array data is program defined in the file description space> as input
;ith a T in column ,5 and an + in column 8(.
%rray defined in the +<tension specifications.
MTN 3ile is read )efore any input > calculations or Output is e<ecuted.
+<ample:
3 Specification :
O M'"t !e )efine) a" an inp't ta!le file
> M'"t !e program()efine) .6n)icate" arra2 attri!'te" are )efine) in the ./ten"ion Specification
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
FA05-6<. 69 - 11 .D6SI
+ Specification :
O -ile name )efine) in the -ile De"cription Specification" with a 9 in the col'mn 1D m'"t !e
entere) here
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
. A05-6<. M98 1 1# & DA5S # 0
%0* of %4&
-un time array:
1ata for run time array may )e stored in an e<ternally defined physical file> the data may )e
loaded in the input specifications or loaded )y one or more calculation statements for the arrays
that are defined in the Extension specifications ;ithout a Number of Entries Per Record 3ield
entry.
Salient 3eatures:
1ata !oaded "ia Input specifications:
% physical file e<ternally or program defined stores the array data.
%rray defined in the +<tension Specifications and elements are referenced
in the input specifications.
#rogram is e<ecuted and physical data is read. %s a record is read > the
array is loaded ;ith data . This procedure is follo;ed for each record in
the file.
1ata loaded Dia calculation Specification:
%rray is defined in the +<tension Specifications.
#rogram is e<ecuted and the array is loaded )y instructions in calculation
specifications.
%07 of %4&
Example:
1ata !oaded "ia Input specifications:
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
- ,DA9A-<. 6P . D6SI
#hysical 3ile is e<ternally defined
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
01 . A05 4 3
9um)er of +ntries per record field
is not used for +/n Ti9e
arrays$loaded in nput or !alculation "pecifications'
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
0, ,1%T%3!+&
0- , 3!1, %&G>,
08 , 3!1- %&G>-
04 , 3!18 %&G>8
04 , 3!14 %&G>4
3ield names in the physical file %rray name> comma and element
record format that store the data num)er are entered in the field name
for the Run #ime array are entered columns.
)eginning in column -,.
9ote: The fields in the physical fileNs record do not ha"e to )e contiguous and may )e scattered ;ithin the record
format.
1ata loaded Dia calculation Specification:
%0& of %4&
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
. SA<. ? @ # <oa)e) 4n 6np't
. 949< ? 3 # <oa)e) 4n 1alc
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
1 ADD SA<. 949<


Searching Arrays
The LOU# operation can )e used to search arrays.
Searching an Array 0ithout an Inde1
.hen searching an array ;ithout an inde<> use the status $on or off' of the resulting indicators to
determine ;hether a particular element is present in the array. Searching an array ;ithout an
inde< can )e used for "alidity chec=ing of input data to determine if a field is in a list of array
elements. ?enerally> an eEual LOU# is reEuested.
In factor , in the calculation specifications> specify the search argument $data for
;hich you ;ant to find a match in the array named'. 3actor ,> the search argument>
can )e:
% character or numeric literal
% field name
% data structure name
%n array element
% ta)le name.
The result field cannot )e used.
The search starts at the )eginning of the array and ends at the end of the array or ;hen the
conditions of the loo=up are satisfied. .hene"er an array element is found that satisfies the type
of search )eing made $eEual> high> lo;'> the resulting indicator is set on.
+<ample:
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
--ilename6P.A-....0len<I1A64vIloc.DeviceH......I./itHH.ntr2HA....=1.
FARRFILE IT F 5 EDISK
-N
.....-romfile9ofileHHFameHHF/rF/t!<enPDSArrnam<enPDS1omment"
E ARRFILE DPTNOS 1 5# 5 # DEPT NUMBERS
.N
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHHH
1N 9he <4I=P operation i" proce""e) an); if an element of DP9F4S eM'al
1N to the "earch arg'ment (DP9F=M) i" fo'n); in)icator #O i" "et on.
C DPTNUM LOKUPDPTNOS 2K
1N
1N 4therwi"e; in)icator #O i" not "et on an) the 7494 "tatement
1N con)itione) !2 F#O ca'"e" a !ranch to the :ADF=M 9A7.
%00 of %4&
C N2# "OTO BADNUM
C -
C - C.90B9.A6<;@
C -
C BADNUM TA"
A00-6<.; which contain" )epartment n'm!er"; i" )efine) in the file )e"cription "pec(ification"
a" an inp't file (6 in po"ition 1?) with an arra2 file )e"ignation (9 in po"i(tion
1D). 9he file i" program )e"cri!e) (- in po"ition 1&); an) each recor) i" ?
po"ition" in length (? in po"ition #@). 9he . in po"ition %& in)icate" that the file i"
f'rther )e"cri!e) in the e/ten"ion "pecification".
6n the e/ten"ion "pecification"; A00-6<. i" )efine) a" containing the arra2 DP9F4S.
9he arra2 contain" ?0 entrie" (po"ition" %3 an) %&). .ach entr2 i" ? po"ition" in
length (po"ition 4#) with Lero )ecimal po"ition" (po"ition 44). 4ne )epartment
n'm!er can !e containe) in each recor) (1 in po"ition %?). 8owever; each recor)
)oe" not have to contain an entr2. An2 recor) that )oe" not contain an entr2 i"
fille) with Lero".


Searching an Array 0ith an Inde1
To find out ;hich element satisfies a LOU# search> start the search at a particular element in
the array. To do this type of search> ma=e the entries in the calculation specifications as you
;ould for an array ;ithout an inde<. @o;e"er> in positions 88 through 4-> enter the name of the
array to )e searched> follo;ed )y a comma and a numeric constant or the name of a numeric
field $;ith Fero decimal positions' containing the num)er of the element to )e used. The numeric
constant or numeric field pro"ides the num)er of the element at ;hich the search is to start. This
numeric constant or field is called the inde< )ecause it points to a certain element in the array.
%ll other rules that apply to an array ;ithout an inde< apply to an array ;ith an inde<.
+<ample:
N...1....H....#....H....%....H....4....H....?....H....D....H....@...
--ilename6P.A-....0len<I1A64vIloc.DeviceH......I./itHH.ntr2HA....=1.
FARRFILE IT F 5 EDISK
-N
.....-romfile9ofileHHFameHHF/rF/t!<enPDSArrnam<enPDS1omment"HHHHHHHHH
. A00-6<. DP9F4S 1 ?O ? O DP9DS1 #O D.P9 F4/D.S10P9F
.N
1<OFO1FO#FO%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHHH
1N 9he G(ADD operation !egin" the <4I=P at the fir"t element in DP9F4S.
C Z-ADD1 * 3K SET * FOR LOKUP
1N At the en) of a "'cce""f'l <4I=P; when an element ha" !een fo'n)
1N that contain" an entr2 eM'al to the "earch arg'ment DP9F=M;
1N in)icator #O i" "et on an) the M4K. operation place" the )epartment
1N )e"cription; corre"pon)ing to the )epartment n'm!er; into DP9FAM.
C DPTNUM LOKUPDPTNOSL* 2K
1N 6f an element i" not fo'n) that i" eM'al to the "earch arg'ment;
1N the 7494 operation con)itione) !2 F#O ca'"e" a !ranch to :ADF=M.
C N2# "OTO BADNUM
C MOVE DPTDSCL* DPTNAM 2K
C BADNUM TA"
This e<ample sho;s the same array of department num)ers> !"#$OS> as3igure ,0( on page
8(5. @o;e"er> an alternating array of department descriptions> !"#!S7> is also defined in
positions 45 through 4, of the e<tension specifications. +ach element in !"#!S7 is -0
positions in length $positions 48 and44'. %ny record in !"#$OS that does not contain an entry
is filled ;ith Feros. %ny record in !"#!S7 that does not contain an entry is filled ;ith )lan=s.
%%0 of %4&
Speci)ying an Array in Calculations
%n entire array or indi"idual elements in an array can )e specified in calculation
specifications. Gou can process indi"idual elements li=e fields. &emem)er> if an
array element is to )e used as a result field> the array name ;ith the comma and
inde< cannot e<ceed 5 characters.
To specify an entire array> use only the array name> ;hich can )e used as factor ,>
factor -> or the result field. The follo;ing operations can )e used ;ith an array
name%
A!!
&'A!!
SUB
&'SUB
(UL#
!)*
S+,#
(O*-
(O*-L
(O*-A
(LL&O
(L.&O
(.L&O
(..&O
!-BU/
XFOOT
LOKUP
SORTA
"A,(
!-0$
CL-A,
,-S-#
C.-C
C.-,
SCA9.
Se"eral other operations can )e used ;ith an array element only )ut not ;ith the
array name alone. These operations include )ut are not limited to:
B)#O$
B)#O0
CO("
CAB11
#-S#&
%%% of %4&
#-S#$
#-S#B
(*,
!OU11
!O211
)011
SUBS#
CAT.
.hen specified ;ith an array name ;ithout an inde<> certain operations are repeated for each
element in the array. These are
A!!
&'A!!
SUB
&'SUB
(UL#
!)*
S+,#
(O*-
(O*-L
(LL&O
(L.&O
(.L&O
(..&O
The follo;ing rules apply to these operations ;hen an array name ;ithout an inde< is specified:
.hen factors , and - and the result field are arrays ;ith the same num)er of elements>
the operation uses the first element from e"ery array> then the second element from e"ery
array until all elements in the arrays are processed. If the arrays do not ha"e the same
num)er of entries> the operation ends ;hen the last element of the array ;ith the fe;est
elements has )een processed. .hen factor , is not specified for the A!!3 SUB3 (UL#>
and !)D operations> factor , is assumed to )e the same as the result field.
.hen one of the factors is a field> a literal> or a figurati"e constant and the other factor
and the result field are arrays> the operation is done once for e"ery element in the shorter
array. The same field> literal> or figurati"e constant is used in all of the operations.
The result field must al;ays )e an array.
If an operation code uses factor - only $for e<ample> &'A!!3 &'SUB3 S+,#3 A!!3
SUB3 (UL#> or !)D do not ha"e factor , specified' and the result field is an array> the
operation is done once for e"ery element in the array. The same field or constant is used
in all of the operations.
&esulting indicators $positions 44 through 4(' cannot )e used )ecause of the num)er of
operations )eing processed.
%%2 of %4&
"ables :
There is no physical difference )et;een a ta)le and array. Cut functionally> an array can )e
addressed element )y element ;hile a ta)le can only )e addressed ;holly. %lso one element in a
Ta)le can )e accessed at a time unli=e an array.
!ata Structures:
The &#?/400 program allo;s you to define an area in storage and the layout of the fields> called
su)fields> ;ithin the area. This area in storage is called a data structure. Gou can use a data
structure to:
1i"ide a field into su)fields
7hange the format of a field
?roup noncontiguous data in a contiguous format
1efine an area of storage in more than one format.
1efine multiple occurrences of a set of data

In addition> there are three special data structures> each ;ith a specific purpose:
% data area data structure $identified )y a = in position , of the data structure statement'
% file information data structure $referred to )y the =ey;ord I931S on a file
description specifications continuation line'
% program-status data structure $identified )y an S in position , of the data structure
statement'.

1ata structures can )e program-descri)ed or e<ternally descri)ed.
% program-descri)ed data structure is identified )y a )lan= in position ,7 of the data structure
statement. The su)field specifications for a program-descri)ed data structure must immediately
follo; the data structure statement.
%n e<ternally descri)ed data structure> identified )y an . in position ,7 of the data structure
statement> has su)field descriptions contained in an e<ternally descri)ed file ;ith one record
format. %t compile time> the &#?/400 program uses the e<ternal name to locate and e<tract the
e<ternal description of the data structure su)fields. %n e<ternal su)field name can )e renamed
in the program> and additional su)fields can )e added to an e<ternally descri)ed data structure in
the program.
'ormat o) !ata Structure Sub)ields in Storage:
Su)fields in a data structure are stored in the format specified in position 48 of the data structure
su)field specifications. The possi)le entries for a program-descri)ed data structure are:
Entr! Explanation
Clan= Su)field is in Foned-decimal format or is character data>depending on the entry in position 4-
of the su)field specifications.
%%$ of %4&
# Su)field is in pac=ed-decimal format.
C Su)field is in )inary format.
,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Cecause the su)fields of a data structure are maintained in the format specified> The compiler
generates the necessary con"ersions to process the reEuired function. These con"ersions can
occur at the follo;ing times:
.hen a record is )eing read
%t detail or total calculation time
%t detail or total output time.
!ata Structure Statement Speci)ications:
1ata structure statements are defined on the input specifications and must
follo; all input specifications for records.
The specifications for data structure statements are:

Position -ntry
2 I
6-78 9ame of the data str*ct*re #eing defined: This entry is optional for a
program-descri#ed data str*ct*re; and is re<*ired for an e1ternally
descri#ed data str*ct*re; a file information data str*ct*re (I9,(S"; and a
data area data str*ct*re:
7=-72 0lan>
76



0lan>) Program-descri#ed data str*ct*re:
-) -1ternally descri#ed data str*ct*re: The data str*ct*re s*#field
definitions are retrieved from an e1ternally descri#ed record format:
7?




0lan>) Other than a program stat*s; data area or initiali@ed data
str*ct*re:
I) 5lo#ally initiali@ed data str*ct*re:
S) Program-stat*s data str*ct*re:
.) (ata area data str*ct*re:
74-80 (S
87-=0



0lan>) The data str*ct*re is program descri#ed:
-ntry) This is the name of the file Ahose first record format contains
the field descriptions *sed as the s*#field descriptions for this data
str*ct*re:
=7-4= 0lan>
44-46





0lan>) single occ*rrence data str*ct*re:
nnnn) n*m#er (right-ad$*sted" indicating the n*m#er of occ*rrences
of the data str*ct*re:
9ote) This entry m*st #e #lan> for a data area data str*ct*re; a file
information data str*ct*re; and a program-stat*s data str*ct*re:
%%4 of %4&
4?-B7

Length of data str*ct*re (optional": This entry m*st #eright-ad$*sted:
B8-64 0lan>
E1amples:
D6C612 . 36291 6;A< @B/36291@-
6D"name....F4D"./t(fileHH.............4ccr<enH......................>
6PA09F4 DS
6.............../t(fiel)H............P-rom9oHHD-iel)H...............>
6 1 4 M-7
6 ? 10 D0=7
6 11 1% S90F98
6 14 1D014=F9
6>
Usin$ 'ata %tructure to @roup fiel&s :
>.. 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
6-ilenameSMF40iPo"1F11Po"#F11Po"%F11................................>
690AFSA19FS 01 1 11 # 1#
6....................................P-rom9oHHD-iel)H<1M1-rPlMnGr...>
6 % 10 PA09F4
6 11 1D0A95
6 1@ #0 95P.
6 #1 #1 14D.
6 ## #? <41A9F
6D"name....F4D"./t(fileHH.............4ccr<enH......................>
6P09I.5 DS
6.............../t(fiel)H............P-rom9oHHD-iel)H...............>
6 1 4 <41A9F
6 ? 1# PA09F4
6 1% 1D 95P.
.hen you use a data structure to group fields> fields from non-ad*acent locations on the input
record can )e made to occupy ad*acent internal locations. The area can then )e referred to )y
the data structure name or indi"idual su)field name.
Chan$e the format of the (iel&:
>.. 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
6-ilenameSMF40iPo"1F11Po"#F11Po"%F11................................>
66FP=9 SM 01
6....................................P-rom9oHHD-iel)H<1M1-rPlMnGr...>
6 1 D0DA9.
6 1 # MM
6 % 4 DD
6 ? D 55
6D"name....F4D"./t(fileHH.............4ccr<enH......................>
6 DS
6.............../t(fiel)H............P-rom9oHHD-iel)H...............>
6 1 D 55MMDD
6 1 # 55
6 % 4 MM
6 ? D DD
%%. of %4&
M*ltiple Occ*rrence (ata Str*ct*re)
% multiple-occurrence data structure is a data structure ;hose definition is repeated in a
program to form a series of data structures ;ith identical formats. Gou specify the num)er of
occurrences of a data structure in positions 44 through 47 of the data structure statement.
.hen positions 44 through 47 do not contain an entry> the data structure is not a multiple-
occurrence data structure. %ll occurrences of a data structure ha"e the same attri)utes and can
)e referred to indi"idually. The 41=0 operation code> ;hich can only )e used ;ith a multiple-
occurrence data structure> allo;s you to specify ;hich occurrence of a data structure is used
for su)seEuent operations ;ithin the program.
Note: Multiple occurrences are not allo;ed for a data area> file information> or program-
status data structure.
>.. 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
6>
6> A m'ltiple(occ'rrence )ata "tr'ct're i" '"e) to acc'm'late a
6> "erie" of total" for "pecific co)e"; an) the total" of each of
6> the occ'rrence" of the )ata "tr'ct're are written.
6> 9he program()e"cri!e) )ata "tr'ct're; 949DS; ha" && occ'rrence"
6> (po"ition" 4D an) 4@). 9he length of the )ata "tr'ct're can !e
6> "pecifie) in po"ition" 43 thro'gh ?1.
6>
6D"name....F4D"./t(fileHH.............4ccr<enH......................>
ITOTDS DS ))
6.............../t(fiel)H............P-rom9oHHD-iel)H...............>
6 1 ?09491F9
6 D 1#09491
6 1% #0#949#
6>
>.. 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
1>
1> A n'meric co)e fiel); 14D.; contain" a val'e of 01 tho'gh &&.
1> 9hi" val'e i" )ifferent each time the 41=0 operation i" proce""e).
1> When the 41=0 operation i" proce""e); the 14D. fiel) i" '"e) to
1> "et the c'rrent occ'rrence of 949DS. 6f the 41=0 operation i"
1> "'cce""f'l; the program !ranche" to the ADD09F "'!ro'tine where
1> a recor) co'nt i" ma)e an) inp't val'e" are a))e) to the )ata
1> "tr'ct're "'!fiel)". 6f the 14D. fiel) contain" a val'e other
1> than 01 thro'gh &&; in)icator #? i" "et on an) the program
1> !ranche" to :AD14D.
1>
1<0F01F0#F0%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH>
1 CODE OCUR TOTDS 25
1 #? 7494 :AD14D
1 .CS0 ADD09F ,,,,,,,,,,,,,,,,
1 S T 1alc'lation" T
1 S T,,,,,,,,,,,,,,,,T
1 :AD14D 9A7
1 S ,,,,,,,,,,,,,,,,
1 S T 1alc'lation" T
1 T,,,,,,,,,,,,,,,,T
%%* of %4&
!ata Areas :
1ata areas are o)*ects used to transfer data to one or more programs ;ithin a *o) or )et;een
*o)s. % 1ata area may )e considered as a one-record Storage area .
% 1ata area can )e of ma<imum -4 digits ;ith ma<imum ( decimal positions for O1+7
type and for O7@%& type the ma<imum length is -000 characters.
7reated )y 7&T1T%%&%> Modified )y 7@?1T%%&% and 1isplayed )y
1S#1T%%&%.
1ata areas can )e e<plicitly or implicitly retrie"ed and ;ritten.
Implicitly retrieved and 0ritten:
.hen the data area is defined in an &#?/400 program as a data area data structure> Its
data is implicitly retrie"ed for processing and ;ritten )ac= at the end the of the program.
6>
6D"name....F4D"./t(fileHH.............4ccr<enH......................>
6PA09F4 UDS
6.............../t(fiel)H............P-rom9oHHD-iel)H...............>
6 1 D PA09F:0
6>
E1plicitly retrieved and 0ritten:
The Opcodes and reser"ed ;ords related to the e<plicit processing of data are summariFed as
follo;s :
OpCo&es (unction
I9 +<plicitly retrie"es a data area and optionally allo;s the programmer to
^loc=P it so that it cannot )e updated )y another pgm during the
e<ecution of the controlling program.
O6T +<plicitly updates the data area and unloc=s it
1+39 .hen used ;ith O9%MD%& reser"ed ;ord> It specifies that the 3actor -
entry is a data area.
69!7: &eleases one or all the data areas loc=ed )y the controlling program
0eserve& Hor&s (unction
O!O7: 6sed in 3actor , ;ith opcode I9 to loc= a data area
O9%MD%& 6sed in 3actor , in opcode 1+39 to define a data area
6sed in 3actor - in Opcode I9 to access all data areas specified in the
program


C& D.A. .?2. .@@64;21 A< . F6291-
1<0F01F0#F0%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH>
1 >FAMKA0 DEFN CKINFO CHECKS 1##
1 6F 18.1IS
1>./ample 66
C& RP"J4## C<;A?<9 A< C5.;42 A52 C.9B2 6; D.A. .?2. -
1<0F01F0#F0%-actor1HHH4pc)e-actor#HHH0e"'lt<enD88i<o.M1omment"HHHHHH>
%%7 of %4&
1 >FAMKA0 DEFN CKINFO 1#
1 ><41I 6F 1I6F-4
1 M4K.<1I6F-4 18.1IU 40
1 M4K. 1I6F-4 1IDA9. D0
1 M4K.<18.1IU 1I6F-4
1 M4K. =DA9. 1I6F-4
1 4=9 1I6F-4
1 =F<1I1I6F-4
1>Data area previo'"l2 loce) !2 an 6F i" a'tomaticall2 relea"e) from the loce)
1> "tate after the 4=9 "tatement i" e/ec'te). 6f More than one )ata area i"
1> "'pporte) !2 the program; "pecif2ing =F<1I "tatement with >FAMKA0 in factor #
1> will 'nloc all of them at one time. 4n the other han) ; if onl2 a "elect )ata
1> area i" to !e 'nloce) ;the )ata area name m'"t !e entere) in -actor #.
1>
1 >FAMKA0 =F<1I

%%& of %4&
!ata Structures 'or E1ception/Error Control
Exception errors that cause program e<ecution to cancel are not uncommon in the programming
en"ironment..&outines may )e included in an &#?/400 program to identify and control
e<ception/errors and pre"ent program e<ecution ^%)ortsP.3ile Information 1ata structures and
#rogram Status 1ata Structures are t;o &#?/400 run-time methods to control e<ception/error
processing.
'ile In)ormation !ata Structures #I+'!S$:
% file information 1ata Structure pro"ides e<ception/error information that may ha"e occurred
;hen processing a file during program e<ecution.This type of data structure contains predefined
su)fields that identify:
The name of the file for ;hich the error occurred.
The record processed ;hen the error occurred.
The operation )eing processed ;hen the error occurred.
The status code num)er.
The &#?/400 routine in ;hich the error occurred.
Specifically> =ey;ords including N(I"E< NIN< N)O'E< NOU,< NOCO'E< N%IEE<
N%,A,U%< N0ECO0'> and N0OU,INE pro"ide the pre"iously named information for any file
processed )y the program.
The &#?/400 3ile 1escription and Input Specifications coding to support a 3ile Information
1ata Structure$I931S' is detailed in the )elo; 3igure. 9ote that a 3ile +<ception/+rror
Su)routine $I93S&' is specified on a second continuation statement ;hich accesses the &#?/400
supplied N%%0 routine. .hen an error is detected>control ;ill pass to this su)routine
automatically.
Cased on the error type> programmer supplied statements in the O#SS& routine ;ill determine
the action to )e ta=en $ie end the *o) or ignore error and continue ;ith processing'.
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
FINVPF IP E K DISK KINFDS INFDS1
( KINFSR &PSSR
.
.
.
66F-DS1 DS
6 >-6<. -6<.
6 >4P14D. 14D.
6 >S9A9=S S9A9=S
6 >0.140D 0.140D
6 >04=96F. 04=96F
.
.
%%0 of %4&
.
1 >PSS0 :.7S0
1 S9A9=S 6-.A 01011
1 M4K.<V>7.96FW 0.ADA7 D
1 .C1P9 .004=9
1 .FD6-
1 ENDSRREADA"
The output generated in the O#SS& routine may )e directed to any output de"ice and include
I931S =ey;ord "alues and/or programmer Hsupplied code.Some errors may reEuire that
e<ecution of the program )e cancelled.
6nder those circumstances O7%97! ;ould )e mo"ed to &+%1%? field and the program
;ould end. In any case>I931S e<ception/error control pre"ents the display of system supplied
errors ;hich ;ould utiliFe system resources if a user response ;as not timely.
9ote that the e<ception/error information for the =ey;ords is only generated if the
OST%T6S =ey;ord "alue is greater than 000((.
Program Status !ata Structure:
#rogram Status 1ata Structures > ho;e"er identify e<ceptions/errors that are generated in the
program )y &#?/400 operations and not )y a file.
9ote that any code greater than 000(( is flagged as an e<ception/error.
3our =ey ;ords OST%T6S> O&O6TI9+> O#%&MS> %91 O#&O?&%M are supported )y a
#rogram Status 1ata Structure.
The eight character 0OU,INE #e! wor& contains the name of the 0@B499 routine 1e$:
INI,<N@E,IN<N1+T!> O'E,C< N,O,C< N,O," < NO("< N,E0) < %0 name< p$m name2
in ;hich the e<ception/error occurred. O#%&MS is a three digit numeric =ey;ord that stores the
num)er of parameters passed to the program from a calling program. O#&O?&%M is a ,0-
position character field that stores the name of the program in ;hich the #rogram Status 1ata
Structure is specified.
The )elo; figure details the 3ile 1escription and Input Specification synta< for a #rogram Status
1ata Structure.Instead of the &#?/400 O#SS& routine > a programmer named routine may )e
specified.
>...H... 1 ...H... # ...H... % ...H... 4 ...H... ? ...H... D ...H... @ ..>
-6FKP- 6P . I D6SI I6F-S0 >PSS0
.
.
.
I SDS
6 >-6<. -6<.
6 >4P14D. 14D.
6 >S9A9=S S9A9=S
6 >0.140D 0.140D
%20 of %4&
6 >04=96F. 04=96F
.
.
.
1 >PSS0 :.7S0
1 S9A9=S 6-.A 01011
1 M4K.<V>7.96FW 0.ADA7 D
1 .C1P9 .004=9
1 .FD6-
1 ENDSRREADA"
%2% of %4&
Chapter I7: -&8 and Printer 'iles
-eport &ayout 8tility #-&8$
&!6 is one of the application de"elopment tools used to create and change report prototypes .
&!6 can )e in"o=ed either from the %S/400 command line through typing the command
ST&&!6 or )y selecting option M,(N from the .&:MC&#1M.
-eport &ine
% record that is part of the report prototype for ;hich the user creates data descriptions
specifications.
-eport Prototype
% representation of the image of the report that a user )uilds on a display and the printed report
image> )oth of ;hich loo= li=e the actual listening created )y the application program. The report
prototype> ;hen sa"ed as a 11S source mem)er> can )e used to create a printer file> ;hich in
turn> can )e used )y an application program to create the report.
Printer 'ile /ey0ords
There are in all o"er 44 =ey;ords associated ;ith printer files. These =ey;ords are used to
pro"ide additional Eualification to the printer file at "arious le"els. #rinter file =ey;ords may )e
di"ided into the follo;ing groups:
(ile level =ey;ords that are used at the file le"el and that ;ould )e common to all the
record formats in the file.
0ecor& level =ey;ords that are used at a particular record file le"el and that ;ould )e
apply to all the constants and fields in the gi"en record formats.
(iel& "evel =ey;ords apply to particular field in a record format.
%22 of %4&
Some of the commonly used =ey;ords are detailed )elo;.
(ile "evel /e!wor&s
&+3 &eferenced 3ile
6sed to specify a file that is to )e referenced for all the su)seEuent referenced field
definitions.
S:I#% S=ip %fter
6sed to specify at the file le"el to indicate that ;hene"er a ;rite operation is issued to a
printer file> the printer is to s=ip to a specified line )efore printing the named record format.
S:I#C S=ip Cefore
6sed to specify at the file le"el to indicate that ;hene"er a ;rite operation is issued to a
printer file> the printer is to s=ip to a specified line )efore printing the named record format.
7@&SIB 7haracter SiFe
6sed to specify a character siFe to all "aria)les and constants in the named record format.
7#I 7haracters per Inch
6sed to specify the num)er of characters that are to )e printed in a inch. The "alues specified
must )e "alid for the printer used.
1&%.+& #rinter 1ra;er
6sed to specify the dra;er num)er from ;hich stationery has to )e selected for the printing
of the named record format. This is used in situation ;here mail is printed ;ith company
letter heads> continuation sheets and en"elopes )eing stac=ed in different stac=s of a multi-
dra;er printer.
@I?@!I?@T @ighlight
6sed to specify that all "aria)les and constants of the named record format are to )e
highlighted ;hile )eing printed.
!#I !ine per Inch
6sed to specify the num)er of lines allo;a)le per inch of stationery ;hile printing the named
record format.
0ecor& "evel /e!wor&s
#&T.!TG #rint 2uality
6sed to specify the print Euality to )e used ;hile printing the named record format.
S:I#% S=ip %fter
%2$ of %4&
6sed to specify at the record format le"el to indicate that ;hate"er a ;rite operation is issued
to a record format> the printer is to s=ip to a specified line after printing the named record
format.
S:I#C S=ip Cefore
6sed to specify at the record format le"el to indicate that ;hate"er a ;rite operation is issued
to a record format> the printer is to s=ip to a specified line )efore printing the named record
format.
S#%7+% Space %fter
6sed to specify at the record le"el to indicate that ;hene"er a ;rite operation is issued to a
record format> the printer is to s=ip to a specified num)er of lines after printing the named
record format.
S#%7+C Space Cefore
6sed to specify at the record le"el to indicate that ;hene"er a ;rite operation is issued to a
record format> the printer is to s=ip to a specified num)er of lines )efore printing the named
record format.
T+AT Te<t
6sed to assign descripti"e te<t to )e associated ;ith record format.
(iel& "evel /e!wor&s
&+33!1 &eferenced 3ield 9ame
6sed to specify the name of pre"iously defined field from the file indicator as the referenced
file at the file le"el.
S:I#% S=ip %fter
6sed to specify at the field le"el to indicate that ;hene"er a ;rite operation is issued to a
record format containing the field> the printer is to s=ip to a specified line after printing the
named record format.
S:I#C S=ip Cefore
6sed to specify at the field le"el to indicate that ;hene"er a ;rite operation is issued to a
record format containing the field> the printer is to s=ip to a specified line )efore printing the
named record format.
$NO,E: The use of )oth S:I# =ey;ords is not "alid ;hen specifying line num)ers.'
%24 of %4&
S#%7+% Space %fter
6sed to specify at the record le"el to indicate that ;hene"er a ;rite operation is issued to a
record format> the printer is to s=ip to a specified num)er of line after printing the named
record format.
S#%7+C Space Cefore
6sed to specify at the record le"el to indicate that ;hene"er a ;rite operation is issued to a
record format> the printer is to s=ip to a specified num)er of lines )efore printing the named
record format.
T+AT Te<t
6sed to assign descripti"e te<t to )e associated ;ith record format.
TIM+ Time
6sed to specify that the system time is to )e retrie"ed and printed in the specified position.
Processing Printer 'iles in -P6 Programs:
(ile %pecifications:
In the &#? program the printer file is declared in the (ile specifications ;ith the follo;ing
definitions.
Type of the file is MON for Output.
1e"ice is M#&I9T+&N
In the 0@ calculation specification.
.ithin the calculation specification there ;ould )e no reference to the printer file name. all
references ;ould )e to the record formats defined in the printer file.
To ;rite a particular record format> use one of the follo;ing opcodes.
.&IT+ H for program-descri)ed printer files.
.hen ;riting printer file record formats al;ays ensure that the current print line is less than
the o"erflo; line. %lso ensure )efore ;riting a record format> that the enough num)er of
lines a"aila)le to )e printed in a page.
%dditional &ecommended &eading Material
,. S70(-,4,5-0- &!6 6sers ?uide and &eference.
%2. of %4&
Chapter 7: Introduction "o Control &anguage
7ontrol language is used to string a group of system commands together to perform "ariety of
system functions. Cy stringing together these commands ;e can e<ecute these operations )y
merely in"o=ing a program rather than e<ecute a group of commands indi"idually.
Command Structure
% system command consists of three )asic parts namely> the command name> parameter name
and a parameter "alue. 3or e<ample> in the follo;ing command>
7&T1T%%&% 1T%%&%$!IC%/%&%0,' !+9$,00' TG#+$O7@%&'
The command> 7&T1T%%&% $7reate 1ata %rea' and the parameters ;ith the corresponding
"alues are
1T%%&% !IC%/%&%0,
!+9 ,00
TG#+ O7@%&
.hen this command is e<ecuted> the parameters may )e entered in any one of the follo;ing
forms. #ositional form> only the parameter "alues are entered or =ey;ord form> )oth the
parameter name and the corresponding parameter "alue are entered or )oth #ositional and
=ey;ord form commands are entered.
Positional 'orm
.hen entering commands using only #ositional entries> all the parameters used must )e entered
seEuentially. 3or e<ample> consider the follo;ing command.
%11%0+ %dd autostart *o) entry.
This command uses the three parameters ;hich are
SCS1 Su)system name
0OC 0o) name
0OC1 0o) 1escription name
These three parameters ha"e )een listed here in the seEuence in ;hich the command e<pects
them. Therefore> using the #ositional entry method of entering a command> ;e may e<ecute the
command as follo;s.
%11%0+ %C7 1+3 AGB
;here>
%C7 is ta=en )y the system as )eing the su)system name
1+3 as )eing the *o) name> and
%2* of %4&
AGB as )eing the *o) description name.
Therefore> ;hen using the positional entry method of entering a command> ;e must )e "ery
careful that the seEuence in ;hich ;e enter the parameter "alues is e<actly the same seEuence in
;hich the system e<pects the "alues.
/ey0ord )orm
.hen entering commands using =ey;ord entries> e"ery parameter must )e entered ;ith the
parameter name. 3or e<ample> the add autostart *o) entry command $%11%0+' may )e entered
as >
%11%0+ SCS1$%C7' 0OC$1+3' 0OC1$AGB'
Since the parameters are )eing entered ;ith the parameter name and the parameter "alue> the
seEuence of the parameters may )e changed. The same command ;ould e<ecute *ust the same
e"en if it is entered as
%11%0+ 0OC$1+3' 0OC$AGB' SCS7$%C7'
:oth positional and /ey0ord )orm
7ommands may )e entered using a com)ination of )oth the #ositional form and the =ey;ord
form. 3or e<ample> consider the follo;ing command.
%117M9+ %dd communications entry
This command uses e"en se"en parameters ;hich are>
SCS1 Su)system description
1+D 1e"ice name
&MT!O79%M+ &emote location name
0OC1 0o) description
13T6S& 1efault user
MO1+ Mode
M%A%7T Ma<imum num)er of acti"e *o)s allo;ed
This command may )e entered in the )oth form as follo;s.
%117M9+ %C7 1+3 AGB M%A%7T$-' 13T6S&$2#?M&'
;here>
%C7 is ta=en )y the system as )eing the su)system name
1+3 is )eing the de"ice name
'elimiters
1elimiters are special characters used to separate the "arious components of a 7! statement. The
follo;ing are "alid 7! delimiters.
%27 of %4&
M:N Separates a command la)el from the command name li=e
!%C+!:7&T#3 3I!+$!IC%/3I!+%' &71!+9$4']
MN Separates a command name from the command parameter and also separates the "arious
parameters of a command.
$' %re used to enclose parameter "alues
M/N Separates the parts of a Eualified name li=e !IC%/3I!+% or &+73MT,/3!100,
M.N or M>N 6sed to indicate decimal point.
M N 6sed to enclose string e<pressions> li=e T+AT$M7ustomer Master 3ileN'
/O O/ 6sed to enclose comments in a 7! program li=e /O This is a test li)raryO/
Command Continuation
7ommands may )e continued o"er one line ;ith the use of a M-Mor MUN sign. .hen used> either of
these t;o characters are the last characters in the statement. The follo;ing e<amples illustrate
the use of these characters as ;ell as highlight the difference )et;een these t;o characters.
7&T!IC !IC $T+ST!IC' T+AT$MThis is a test-
li)raryN'
7&T!IC !IC $T+ST!IC' T+AT$MThis is s test U
li)raryN'
.ariable naming synta1
%ll "aria)le ;ithin 7! programs may )e a ma<imum of ,0 characters. Daria)le names may not
include em)edded )lan=s and must al;ays )egin ;ith MVN.The second character must al;ays )e
an alpha)etic character. Dalid e<amples of 7! "aria)le names are:
V3!1%
V3!100,
V%,
Concatenation
Daria)les and constants may )e concatenated or stringed together for "arious reasons using any
of the follo;ing synta<. The "arious methods of concatenation are:
,. O7%T represents as __
O7%T or __ concatenates t;o "aria)les or constants as they are.
-. OC7%T represented as _T
OC7%T or _T ;ould strip out the trailing )lan=s of first string and insert one )lan= space.
)et;een the t;o components )eing concatenated.
8. OT7%T represented as _W
%2& of %4&
OT7%T or _W ;ould strip out the trailing )lan=s of first string> then *oin that ;ith the second
string.
The follo;ing are the e<amples of the "arious types of concatenation discussed a)o"e.
V3!1% is defined as 4% and contains "alue M%C71+N
V3!1C is defined as % and contains "alue M,-84 M
V3!1% O7%T MT+ST0,N M%C71T+ST0, M
V3!1% OC7%T V3!1C M%C71+ ,-84 M
V3!1C OT7%T MT+ST0,N M,-84T+ST0,N

-elational E1pressions
The follo;ing are "alid relational e<pressions allo;ed for use in 7! programs.
,. S O+2 +Eual to
-. T O?T ?reater than
8. W O!T !ess than
4. TS O?+ ?reater than or eEual to
4. WS O!+ !ess than or eEual to
5. -_ O9+ 9ot eEual to
7. -_T O9? 9ot greater than
. -_W O9! 9ot less than
&ogical E1pressions
The follo;ing are "alid logical e<pressions allo;ed for use in 7! programs.
,. V O%91 %nd
-. _ OO& Or
8. -_ O9OT 9ot
Substring e1pressions
#arts of alphanumeric "aria)les may )e e<tracted using the su)string function. % su)string
function may )e used either as XS6CST&I9? or XSST. The su)string specifies the "aria)le
name> the starting position and the num)er of characters to )e e<tracted. 7onsider the follo;ing
%20 of %4&
e<ample ;here V3!1% is defined as % and contains "alue M%C71,-844N.The su)string
e<pression
XS6CST&I9? $V3!1% 4 8'
;ould e<tract 8 characters of the "alue of the "aria)le V3!1% starting from position
4.Therefore> the result of this su)string operation ;ould )e M1,-N.
8sing variable in a C& program
%ll "aria)le in a 7! program must )e declared in the program using the 17! statement. The
format of a 17! statement is as follo;s.
17! D%&$V3!1%' !+9$,0' TG#+$O7@%&'
17! D%&$V3!1C' !+9$5' TG#+$O1+7'
17! D%&$V3!17' !+9$( -' TG#+$O1+7'
% 7! program may not address or use any "aria)le that is not declared in the program.
.hen used> 17! statements must immediately follo; the #?M statement.
8sing )iles in C& program
% 7! program may use a ma<imum of one file of any type. This file is declared to the 7!
program using the 17!3 file. The format of a 17!3 statement is as follo;s:
17!3 3I!+$3I!+%'
The record format parameter &713MT of the declare file command may optionally )e used to
restrict the access of the program to only the named record format$s'.If not mentioned> the
program is allo;ed access to all the record formats in the file.
% 17!3 statement must immediately follo; the 17! statement $if a 17! statement is used' or
the #?M statement and must al;ays precede all other statements ;ithin the 7! program.
%ny "aria)le defined in a file declared in a 7! program need not )e declared ;ithin the 7!
program using 17! statement. These "aria)les can )e addressed ;ithin the 7! program using
the MVN naming con"ention for 7! program "aria)les.
'ile (perations
The follo;ing are the only "alid operations that can )e performed on files in a 7! program.
&7D3 3I!+$3I!+%' &eads a record from the named file
%$0 of %4&
S913 3I!+$3I!+C' .rites a record from the named file
S91&7D3 1+D$O3I!+' &+73MT$O3I!+' 1isplays a record format from the display
file for user input.$This operation is the eEui"alent of an +A3MT operation in a 7! program'
Error Handling
%ll system errors encountered during the e<ecution of a 7! program can )e trapped ;ithin a 7!
program ;ith the use of a MO9MS? statement. The MO9MS? command can )e e<ecuted at
the program le"el or the command le"el. The placement of the MO9MS? command
determines ;hether it is a program le"el or command le"el MO9MS?.
To implement the MO9MS? command at the program le"el > ;e can code the MO9MS?
command immediately after the last 17! Statement or ;hen there are no 17! statements>
Immediately after the #?M statement.
To implement the MO9MS? at the command le"el > ;e can code the MO9MS? immediately
after the command that ;e ;ant to monitor.
.e can monitor messages either specifically or generically.
Assigning .alues
Daria)les can )e assigned "alues H constants> "aria)les or computed H using the change "aria)le
command 7@?D%&. Some e<amples of 7@?D%& command usage are
7@?D%& D%&$V3!1%' D%!6+$M%C71+N'
7@?D%& D%&$V3!1C' D%!6+$MV3!1C U ,'
7@?D%& D%&$OI9:-4 ' D%!6+$M,N'
7@?D%& D%&$V3!17' D%!6+$$V3!1A U V3!1G' O V3!1-'
&ogical (perations
The I3 command can )e used to perform logical operations.
I3 7O91$V3!1% O+2 M%CN' T@+9$?OTO 7M1!C!$O#+9''
+!S+ +A+7$7&T#? 3I!+$!IC%/3I!+%' S&73I!+$!IC%/S&73I!+%'
%n +!S+ statement may optionally )e used ;ith an I3 statement
%dditional &ecommended &eading Material
%$% of %4&
,. S7-,-077-- 7ontrol !anguage: #rogrammerNs ?uide-Dol I and II
-. S74,-00800-0- 7ontrol !anguage: &eference H 8 Dolumes
%$2 of %4&
Chapter 7I: (pen =uery 'ile :asics
O#92&G3 is the "ery po;erful command that allo;s the programmer to select record
dynamically )ased on "ariety of selection criteria $Including field mapping> groupings and the
results of mathematical calculations'.1epending on the selection criteria specified >the
O#92&G3 command may ma=e use of e<isting file access paths to e<tract the desired data> or it
may construct an access path of its o;n.
One crucial point to remem)er ;hen using O#92&G3 is that you must use the S@%&+$OG+S'
file attri)ute for each file opened )y the O#92&G3 command. .hen you specify
S@%&+$OG+S'> su)seEuent opens of the same file ;ill share the original open data path and thus
see the file as presented )y the O#92&G3 process. If O#92&G3 opens a file using the
S@%&+$O9O' attri)ute> the ne<t open of the file ;ill not use the open data path created )y the
O#92&G3 command> )ut instead ;ill perform another full open of the file.
The follo;ing is a list of the ma*or functions supplied )y O#92&G3.
1ynamic record selection
1ynamic =eyed seEuence access path
1ynamic =eyed seEuence access path o"er a *oin
1ynamic *oin
@andling missing records in secondary *oin files
6niEue-=ey processing
Mapped field definitions
?roup processing
3inal total-only processing
Impro"ing performance
Sort seEuence processing
(pen data Path#(!P$ :
Gou ;rite an &#? program to read it in the order in ;hich the records ;ere ;ritten to the file.
This is called arri"al seEuence.
.hen you start the program> the system opens the file and ma=es it a"aila)le to the
#rogram through an open data path. The open data path is> in this case> one that loo=s at the file
in relati"e record num)er $&&9' seEuence.
%$$ of %4&
%n open data path> therefore> is the channel through ;hich an application can access the records
in a file. The same file could )e used )y another &#? program ;hich is coded to read the file
randomly )y =ey. Since the =ey is used> the open data path uses the record =eys - not the &&9Ls.
In this case> therefore> ;e use a =eyed seEuence. 6nder most circumstances> the O1# can )e
thought of as the file itself> although in reality they are t;o entirely different concepts.
!etLs use an e<ample. Suppose a file consists of se"eral records ;ith a field called State7ode. If
someone as=ed you to sort the file so you could sho; only records from 7alifornia and ordered
)y 9ame> you could do this "ery easily in O#92&G3. The O1# ;ould point to only those
records ;hose 7ode S J7%J and order them )y a =ey called 9ame. .e did not ha"e to create a
ne; file ;ith records> simply use the O1# from the physical file and access the records thru 7!.
The O1# contains only pointers to the actual records in the physical file> indicating ;hich
records to retrie"e and in ;hat order. Gou can say that O#92&G3 creates a logical "ie; o"er
the physical file.
=->SE&EC"
2&GS!T is the parameter that determines ;hich records to include in the open data path created
)y O#92&G3. It entails a series of comparisons *oined ;ith %91Ls and O&Ls - the =ind of
comparisons that reads Jthe amount due $contained in %MT16+' is greater than `4000 and the
last payment $!ST#MT' ;as at least ,-0 days old.J 2&GS!T> therefore sounds li=e it should
recei"e a logical e<pression "ery much li=e the I3 commandLs 7O91 parameter:
I3 7O91$V%MT16+ O?T 4000 O%91 V!ST#MT O?+ ,-0'
Gou could try entering something li=e that in O#92&G3Ls 2&GS!T #arameter> remo"ing the
ampersands $V'> )ut it ;onLt ;or=:
O#92&G3 2&GS!T$%MT16+ O?T 4000 O%91 !ST#MT O?+ ,-0'
The reason it doesnLt ;or= is )ecause the 2&GS!T parameter ;onLt accept a logical "alueI it
e<pects a character string. The correct ;ay to code 2&GS!T> therefore is:
O#92&G3 2&GS!T$L%MT16+ O?T 4000 O%91 !ST#MT O?+ ,-0L'
%s you can see> the entire contents of 2&GS!T must )e enclosed in single Euotes )ecause
2&GS!T reEuires a character "alue> and character "alues ;ith em)edded )lan=s must )e
enclosed in single Euotes.
9otice that numeric constants are not enclosed )y t;o apostrophes $Euotation mar=s'.
.hen comparing a field "alue to a 7! "aria)le> use apostrophes as follo;s $only character 7!
"aria)les can )e used':
If doing selection against a character> date> time> or timestamp field> specify:
O#92&G3 3I!+$3I!+%' 2&GS!T$LJL O7%T V7@%& O7%T LJ O+2 3I+!1%L'
%$4 of %4&
or> in re"erse order:
O#92&G3 3I!+$3I!+%' 2&GS!T$L3I+!1% O+2 JL O7%T V7@%& O7%T LJL'
9otice that apostrophes and Euotation mar=s enclose the 7! "aria)les and O7%T operators.
If doing selection against a numeric field> specify:
O#92&G3 3I!+$3I!+%' 2&GS!T$V7@%&96M O7%T L O+2 96ML'
or> in re"erse order:
O#92&G3 3I!+$3I!+%' 2&GS!T$L96M O+2 L O7%T V7@%&96M'I
9otice that apostrophes enclose the field and operator only.
Steps involved in a typical (P+=->' program:
,. Cegin ;ith an O"erride 1ata)ase 3ile $OD&1C3' command> specifying S@%&+$OG+S'. If
necessary> add other o"errides as your application reEuires> such as> o"erriding to a mem)er
other than O3I&ST.
-. Specify the O#92&G3 command ;ith the parameters
8. 7all your &#? program/any @!! #rogram that processes the file. The @!! program should
)e coded as if it ;ere going to process the entire file> ;ithout any pro"isions for record selection
or ordering> since O#92&G3 has already done this *o).
4. 7all the 7lose 3ile $7!O3' command.
4. 7all the 1elete O"erride $1!TOD&' command to remo"e the o"errides created )y step R,.
E1ample:
P7M
D1< KA0(X5.A0) 95P.(>18A0) <.F(#)
09KS5SKA< S5SKA<(A5.A0) 09FKA0(X5.A0)
4K0D:- -6<.(40DMS9) 94-6<.(JAF.<6:/40DMS9) S8A0.(>5.S)
4PFA05- -6<. ((40DMAS9)) A05S<9(V(414D. >F. YDZ) >AFD H
(YW >1A9 X5.A0 >1A9 VZ >.A RSS9(DA9. ? #))W) H
I.5-<D((4K.FD0) (46FAM.)) H
MAP-<D((DA9. VRD6769S(4DA9.)W))
1A<< P7M(40D0P9#) //Proce""ing Program
1<4- 4PF6D(40DMS9)
D<94K0 -6<.(40DMS9)
.FDP7M
%dditional &ecommended &eading Material
,. 1C- 61C for %S/400 1ata)ase #rogramming
%$. of %4&

Chapter 7II: 3essage Sub)iles in -P6
3essage Sub)iles
Message subfiles are special subfiles designed to hold messages. Message
subfiles have some unique properties that make them very useful. They load
themselves automatically from messages on a given program message
queue. Message subfiles also allow users to view the second-level help text
associated with a message, without any additional programming effort.
Message subfiles make it possible to setup a consistent set of information,
warning, or error messages in a message file for a given program or
application, and to display those messages to the user with the greatest of
ease. With ust a little direction from your !"# and $$%, message subfiles
pretty much take care of themselves.
Steps Involved :
Set up a message file $OMS?3' containing the messages you ;ant to use in your
application. Gou can use an e<isting message file or create your o;n. Gou should not
usually modify system-supplied message files> such as 27#3MS?. Message files are
created ;ith the 7&TMS?3 command. 9e; messages can )e added "ia the %11MS?1
command or the .&:MS?3 command.
1efine a message su)file in your display file.
7ode your application program to send program messages to the program message Eueue.
The )est ;ay to accomplish this in &#? is to use the 2M@S91#M $Send #rogram
Message' %#I. Gou can also use the S91#?MMS? command> )ut the )est place to use
that command is in a 7! program.
%fter displaying the message su)file> clear the messages from the program message
Eueue using the 2M@&MD#M $&emo"e #rogram Message' %#I.
&or every call stack entry, which can be an '"M program or an ()*
procedure, there exists a corresponding program message queue with the
same name. ( created my own message file, but you can certainly use the
system-supplied messages and plug in your own text. &or instance, if users
are accustomed to seeing message ($ +"&,-,- from the system-supplied
message file, .+"&M%#, as being something serious, you could still use
that message ($ and substitute your own message. This doesn/t mean you
change the +"&,-,- message in the actual message file. 0ou simply
%$* of %4&
override the message text in your program. (f there are substitution
parameters associated with a specific message, you can also fill in those
parameters using the program message 1"(s. (f message files aren/t your
bag, you can also send text messages to the program message queue and
use no message file at all. )et/s look at some code.
E1ample :
The $$% example, consists of three record formats2 %+!**34, M%#%&),
and M%#+T). &MT4 is the primary screen, and it allows the user to enter
data. 1s you will see in the !"#, this data isn/t going anywhere5 its purpose
is purely to demonstrate how to use a message subfile. M%#%&) is the
message subfile record format, and M%#+T) is the control format for
M%#%&). These formats work much the same way as regular subfile control
and record formats. There are, however, some differences between regular
subfiles and message subfiles.
With regular subfiles, you have to handle the loading and clearing in your
program. Typically, in your !"# program, you will set on the indicator used
to condition the %&)+)! keyword in your $$%, write to the subfile control
format, and set off the indicator to get ready to load and display. With
message subfiles, you don/t explicitly clear the subfile in your program5
rather, you link the subfile to a program message queue and remove
messages from that message queue. This, in essence, clears the subfile.
This same theory holds true for loading the subfile. When displaying subfile
records in a regular subfile, you must first execute some sort of load
routine. This routine usually consists of a $' loop that reads records from a
database file and writes them to the subfile record format. Message subfiles
will have none of that. 6y linking the message subfile to a specific program
message queue and sending messages to that queue, the message subfile
will automatically load itself with records from the program message queue.
Message subfiles require the use of several special $$% keywords, listed
below.
(n the message subfile record format, the following keywords are required2
%(")%@0C' is used to set the starting line on the display for the
message subfile. (n most cases it is set to 78 9the bottom line of the
display:, but you could display more than one message at a time, in
which case you would set this parameter accordingly.
%(")%@/EO controls the message =ey of the first message that is to )e displayed in
the message su)file. +"ery message on a message Eueue has a uniEue message =ey that is
assigned as the message arri"es on the message Eueue. In certain cases> you may ;ish to
maintain old messages on the Eueue and only display messages from a certain point
%$7 of %4&
for;ard in the message su)file. Setting the message =ey allo;s you to control ;hich
messages are displayed.
%("@)D controls ;hich program message Eueue the messages are pulled from. In my
e<ample> it is )eing populated ;ith the name of the program from the program status data
structure in the &#? program or .e can e<plicitly pass the #rogram name. This
techniEue allo;s you to easily copy the message su)file record formats into a ne;
display file> ;ith no changes reEuired to the display file. Of course> the "#M. field
must )e declared .
When in a message subfile, %&)+T), %&)%(;, %&)"1#, %&)$%", %&)*3$,
and %&)$%"+T) behave normally, except that %&)$%" and %&)$%"+T)
must be used without conditioning indicators. 1lso, %&)"1# must be at
least one less than %&)%(; in a message subfile5 they cannot be equal.
Message subfiles are considered load-all subfiles. 3otice also that ( don/t
use the <M'!* parameter on my message subfile. The reason is, using the
<M'!* parameter causes =More...= and =6ottom= to display one line under
the last line on the display. %ince ( am using line 78, which is the last
possible line on the display, ( would get an error if ( tried to use the <M'!*
parameter. The plus sign 9>: works for me, but if you/re dying to use
<M'!* with your message subfiles, try starting on line 7?--
%&)M%#!+$97?:--and keeping %&)"1# as 4. Then you won/t get an error.
)et/s look at the differences in the way %&)(3; keyword behave when it is
in a message subfile.
%&)(3;, in the case of a message subfile, causes the system to
automatically load the subfile with messages from the message queue
specified. This is different from its use with regular subfiles. (n
regular subfiles, %&)(3; loads the subfile with the number of records
indicated by %&)%(; and sets the fields to their default values.
DDS S<B?02-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
A 1-0%(0%)
A 8.<P
A 0 -M91
A 4K.0<A5
A # %B-=<< S10..FB
A -<D1 10 : % %
>
A 0 MS7S-< S-<
> Me""age "'!file recor)
> S-<MS701D control" which line the me""age "'!file "tart" on.
> S-<MS7I.5 control" the me""age e2 of the me""age that i" to
> !e the fir"t one )i"pla2e).
> S-<P7MA control" which program me""age M'e'e me""age" are p'lle) from.
>
A S-<MS701D(#4)
A MS7I.5 S-<MS7I.5
A P7MA S-<P7MA
%$& of %4&
> Me""age "'!file control recor)
> S-<PA7 + S-<S6G to allow the "2"tem to control page 'p an) )own
> in the "'!file. 9he "'!file will !e a'tomaticall2 e/ten)e)
> !a"e) on the n'm!er of entrie" in the program me""age M'e'e.
> S-<DSP an) S-<DSP19< ca'"e the "'!file an) control recor) to !e
> )i"pla2e) when the control format i" thrown
> S-<6FG; in thi" ca"e; ca'"e" the "2"tem to a'tomaticall2 loa)
> the "'!file with me""age" from the me""age M'e'e "pecifie)
> S-<P7MA control" which program me""age M'e'e me""age" are p'lle) from
> S-<.FD with in)icator" that alwa2" eval'ate to 90=.; allow" the
> "2"tem to a'tomaticall2 toggle the SHS "ign that in)icate" if
> there are more recor)" to )i"pla2 in the "'!file.
A 0 MS7S-<1 S-<19<(MS7S-<)
A S-<S6G(000#)
A S-<PA7(0001)
A 4K.0<A5
A S-<DSP
A S-<DSP19<
A S-<6FG
A &3 S-<.FD
A P7MA S-<P7MA
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.n) of Data>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

RP" S<B?02-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
--S# 1- . W40IS9F
>con"tant for the me""age
6 B-6<. <6:0A05 B1 MS71FS
>

> S.FD MS7000% -04M M.SSA7. -6<. CG51%%@ 94 P0470AM M.SSA7. A=.=.
1 M4K.< BMS7000%B MS76D
1 M4K.< BCG51%%@B MS7-
1 M4K. MS71FS MS7D9A D#
1 M4K. B6B MS74P9
1 .CS0 S.FD
>
> S.FD MS70001 -04M M.SSA7. -6<. CG51%%@ 94 P0470AM M.SSA7. A=.=.
1 M4K.< BMS70001B MS76D
1 M4K.< BCG51%%@B MS7-
1 M4K. B6B MS74P9
1 .CS0 S.FD
>
> S.94F S-<.FD 6FD61A940 -40 M.SSA7. S=:-6<.
1 S.94F &3
> W069. M.SSA7. S=:-6<.
1 W069. MS7S-<1
> W069./0.AD 0.7=<A0 S10..F -40MA9
1 .C-M9 -M91
> 1<.A0 98. P0470AM M.SSA7. A=.=.
1 M4K. B1B MS74P9
1 .CS0 S.FD
>
%$0 of %4&
> W069. M.SSA7. S=:-6<.
1 W069. MS7S-<1
> W069./0.AD 0.7=<A0 S10..F -40MA9
1 .C-M9 -M91
1 M4K. B1B >6F<0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1 >6FGS0 :.7S0
> M4K. 98. P0470AM FAM. 94 98. P0470AM M.SSA7. A=.=. -6.<D
1 M4K.< BMS7S-<P7B P7MA
1 M4K. BM B P7MA
1 .FDS0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 986S S=:04=96F. 1A<<S A 1< P0470AM 98A9 S.FDS 98. M.SSA7.
> 94 98. P0470AM M.SSA7. A=.=..
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1 S.FD :.7S0
1 1A<< BS.FDP7MB
1 PA0M MS76D @
1 PA0M MS7- 10
1 PA0M MS7D9A D#
1 PA0M MS74P9 1
1 .FDS0
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.n) of Data>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CL P?<4?.: A< S2;1 M2@@.42@-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
P7M PA0M(XMS76D XMS7- XMS7D9A XMS74P9)
D1< KA0(XMS76D) 95P.(>18A0) <.F(@)
D1< KA0(XMS7-) 95P.(>18A0) <.F(10)
D1< KA0(XMS74P9) 95P.(>18A0) <.F(1)
D1< KA0(XMS7D9A) 95P.(>18A0) <.F(D#)
6- 14FD(XMS74P9 >.A B6B) 98.F(SFDP7MMS7 H
MS76D(XMS76D) MS7-(XMS7-) MS7D9A(XMS7D9A))
6- 14FD(XMS74P9 >.A B1B) 98.F(0MKMS7 P7MA(>P0K H
(>)) 1<.A0(>A<<))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.n) of Data>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
USIN" API@ 6;@A2.1 <3 . CL-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> Sen) me""age "'!ro'tine
>
c "n)m"g !eg"r
c call BAM8SFDPMB
c parm m"g6)
%40 of %4&
c parm m"g<oc
c parm m"g0plDta
c parm m"g0plDta<en
c parm m"g92pe
c parm m"gA'e'e
c parm m"g1allStac
c parm m"gIe2
c parm m"g.rr
c en)"r
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 0emove me""age "'!ro'tine
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
c rmvm"g !eg"r
>
c call BAM80MKPMB
c parm m"gA'e'e
c parm m"g1allStac
c parm m"gIe2
c parm m"g0mv
c parm m"g.rr
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

%4% of %4&
Appendi1 A : -P6 (pcodes
4peration !o'es in +,-/400
Co&es (actor - (actor . 0esult (iel& 0esultin$ In&+
%72 2&?&7O#
#
.O&:ST9
file
- +& -
%11$,/-' %ddend %ddend Sum U - B
%91<< 7omparand 7omparand
C+?S& Su)routine
name
CITO3 Cit num)ers 7haracter field
CITO9 Cit num)ers 7haracter field
7%C<< 7omparand 7omparand !a)el @I !O +2
7%!! #rogram
9ame
#!IST name -- +& !&
7%S<< 7omparand 7omparand Su)routine
9ame
@I !O +2
7%T $p' Source
String ,
Source String
-:9um)er of
Clan=s
Target String
7@%I9$n' Search
argument
3ile name 1ata Structure 9& +& --
7@+7: 7omparator
String
Case String :
start
!eft most
#osition
-- +& 31
7@+7:&$-' 7omparator
String
Case String :
start
&ight most
#osition
-- +& 31
7!+%& O9O:+G Structure or
Daria)le
7!OS+ 3ile 9ame -- +& --
7OMIT Coundary -- +& --
7OM#$,' 7omparand 7omparand @I !O +2
1+C6? Identifier Output file 1e)ug
Information
1+39 O!I:+ &eferenced
field
1efined field
1+39 O9%MD%
&
Internal
program area
+<ternal data
area
1+!+T Search
%rgument
3ile name 9& +& --
1ID $,/-' 1i"idend 1i"isor 2uotient U - B
%42 of %4&
1O Starting
Dalue
!imit Dalue Inde< Dalue
1O6<< 7omparand 7omparand
1O.<< 7omparand 7omparand
1S#!G Message
identifier
Output Eueue &esponse -- +& --
16M# Identifier
+!S+
+91 Increment
Dalue
+917S
+911O Increment
Dalue
+91I3
+91S!
+91S& !a)el &eturn point
+A7#T +A7#T 9ame
Co&es (actor - (actor . 0esult (iel& 0esultin$ In&+
+A3MT &ecord format
name
-- +& --
+AS& Su)routine
name
3+O1 3ile name -- +& --
3O&7+ 3ile name
3&++ #rogram
name
-- +& --
?OTO !a)el
If<< 7omparand 7omparand
I9 O!O7: 1ata area
name
-- +& --
IT+&
:3!1 :ey 3ield
:!IST :!IST name
!+%D+
!O:6# $,'
$%rray'
Search
argument
%rray name @I !O +2
!O:6# $,'
$Ta)le'
Search
argument
Ta)le name Ta)le name @I !O +2
M@@BO Source field Target field
M@!BO Source field Target field
M!@BO Source field Target field
M!!BO Source field Target field
%4$ of %4&
MOD+ $p' Source field Target field U - BC
MOD+% $#' Source Target U - BC
MOD+! Source field Target field U - BC
M6!T $,/-' Multiplicand Multiplier #roduct U - B
MD& &emainder U - B
9+AT #rogram
1e"ice
3ile name - +& -
O776& Occurrence
Dalue
1ata Structure Occurrence
Dalue
- +& -
O#+9 3ile 9ame - +& -
O&<< 7omparand 7omparand
OT@+&
O6T O!O7: 1ata area
name
- +& -
#%&M Target field Source field #arameter
#!IST #!IST name
#OST $8' #rogram
de"ice
3ile name I931S name - +& -
&+%1 $n' 3ile name>
&ecord name
1ata Structure - +& +O3
&+%17 $n' Search
argument
3ile name>
&ecord name
1ata Structure - +& +O3
&+%1+ $n' Search
argument
3ile name>
&ecord name
1ata Structure - +& +O3
&+%1# $n' 3ile name>
&ecord name
1ata Structure - +& CO3
&+1#+ $n' Search
argument
3ile name>
&ecord name
1ata Structure - +& CO3
&+! #rogram
de"ice
3ile name - +& -
&+S+T O9O:+G Structure or
Daria)le
%44 of %4&
Co&es (actor - (actor . 0esult (iel& 0esultin$ In&+
&+T&9
&O!C: - +& -
S7%9 $-' 7omparator
string :
length
Case string :
start
!eft-most
position
- +& 31
S+!+7
S+T?T Search
argument
3ile name 9& +& -
S+T!! Search
argument
3ile name 9& +& +2
S+TO3 $,' O3 O3 O3
S+TO9 $,' O9 O9 O9
S@T19 O9 - -
SO&T% %rray name
S2&T $,/-' Dalue &oot
S6C $,/-' Minuend Su)strhend 1ifference U - B
S6CST $p' !ength to
e<tract
Case string :
start
Target String - +& -
T%? !a)el
T+STC $,' Cit num)ers 7haracter field O3 O9 +2
T+ST9 $,' 7haracter field 96 C9 C!
T+STB $,' 7haracter field
TIM+ 9umeric field
69!7: 1ata area>
record or file
name
- +& -
6#1%T 3ile name 1ata structure - +& -
.@<< 7omparand 7omparand
.&IT+ 3ile name 1ata structure - +& +O3
A3OOT $,/-' %rray name Sum U - B
A!%T+ $#' 3rom :To String :start Target String - +& -
B-%11 %ddend Sum U - B
B-S6C Su)trahend 1ifference U - B
"e$en&:
$,' %t least one resulting indicator reEuired.
$-' % found indicator is reEuired if the result field is not specified.
$8' Gou must specify factor - or the result field. Gou may specify )oth.
$#' #ad the result ;ith )lan=s.
$,/-' @alf ad*ust the result.
$n' 9o loc=.
%4. of %4&
%4* of %4&
Appendi1 : : AS/400 !ata &imits
S/400 (ata limits)
7tes in one record +2,:??
Fields per record ),***
6e fields in one record 120
6esiCe in btes 256
0ecords in one file 16,777,215
7tes in one file 2,1(:,()+,?()
#atabase siCe siCe of disD storage
Logical Files ';ieEs, from one phsical file +,?)?
%hsical files used in one Logical File ';ieE, +2
9aximum files in a F2I8 +2
9aximum field siCe in btes +2,:??
9aximum decimal number @,@@@,@@@,@@@,@@@,@@@,@@@,@@@,@@@,@@@,@
@@
%47 of %4&
Appendi1 C : !P5/400 !estrictions
(unction 0estriction
%9/O& lines $positions 7 and of calculation
specifications'
Ma<imum of 7 per operation.
%rrays and ta)les Ma<imum of -00 per program.
%rray/ta)le input record length for compile time Ma<imum length is 0.
7haracter field length Ma<imum length is -45.
7ontrol fields $position 4( and 50 of input specifica-tions'
length
Ma<imum length is -45.
1ata structure length Ma<imum of ((((.
1ata structure occurrences $num)er of' Ma<imum of (((( per data structure.
+dit .ord Ma<imum length of -4 for literals or ,,4 for named
constants.
+lements in an array/ta)le $positions 85 through 8( of
e<tension specifications'
Ma<imum of (((( per array/ta)le.
3ile Ma<imum of 40 per program.
!e"els of nesting in structured groups Ma<imum of ,00.
!oo=-ahead 7an )e specified only once for a file. 7an )e specified
only for primary and secondary files.
9amed 7onstant Ma<imum length of -45 for character named constant>
4,- for he<adecimal named constant> and 80 digits ;ith (
decimal positions for numeric named constant.
O"erflo; indicator Only , uniEue o"erflo; indicator can )e specified per
printer file.
#arameters Ma<imum of -44
#rimary file $# in position ,5 of file description specifi-
cations'
Ma<imum of , per program.
#rinter file $#&I9T+& in positions 40 through 45 of file
description specifications'
Ma<imum of per program.
#rinting lines per page Minimum of -I ma<imum of ,,-.
#rogram status data structure Only , allo;ed per program.
&ecord address file $& in position ,5 of file description
specifications'
Only , allo;ed per program.
&ecord length for program descri)ed file $positions -4
through -7 of file description specifications'
Ma<imum length is ((((.
Structured groups $see le"els of nesting'
Su)routines Ma<imum of -44 per program.
Ta)les $see arrays'
%ny de"ice record siFe restraints o"erride this "alue.
%4& of %4&

You might also like