38
0 output (0) l Update (LJ) l Display (D) l ’ Combined (C) t : 3 \ : , L. ; file designation El!4 VAX RPG II LLlklQflL%4 0 Primary(P) l Secondary (S) l Record-address (R) l Chained (C) l Preexecution-time table or array(T), (A) l Demand (D) l Full procedural (F) CS 323 (H) 123

CS 323 123 - e-book.ram.edue-book.ram.edu/e-book/c/CS323(H)/cs323(h)-6.pdf · CS 323 (H) 123. File Organizations 0 Sequential s Direct ... ZK-4396-85 CS 323(H) 131. 0 tVl%J~~ 19 (record

Embed Size (px)

Citation preview

0 output (0)

l Update (LJ)

l Display (D)

l ’ Combined (C)

t

:3\:,

L.

;

file designation El!4 VAX RPG II LLlklQflL%4

0 P r i m a r y ( P )

l Secondary (S)

l Record-address (R)

l Chained (C)

l Preexecution-time table or array(T), (A)

l Demand (D)

l Full procedural (F)

CS 323 (H) 123

File Organizations

0 Sequential

s Direct

fourth record

Direct File Organization

cell no. ---tr- 1 2 3 4 5 6

recoros ----t 1 2 3 4

t tempty cell ’ empty cell

zrc(-1.463~83

54-55 9109 C-Form ?J:KQd set on ~sb7VdL~QWJ cell 414 (empty cell)

3. Indexed Organization I

CS 323 (H) 125

Index Key Valuekeyn768979Henry Alberts

File Access MethodsFile Designation Organization Access Method

-rrimary Sequential Sequentlall)

Secondary Randomly by ADDROUT hle’

Demand Direct Sequentially

Full-procedural Direct Randomly by relative record number

Indexed Sequentially

Sequentially by key

Sequentially within Ilmits

Randomly by ADDROLiT hle’

Chained Sequential Randomly by relative recordnumber2

Iqdcwd Randomly by key

‘\ou cannot prows de-and or full-prmedural hles ui,y an ADDAOUT hle.

2 You can access the records I” a vq ~mial hle randomly b> reia!,vc word nun;bcr i, the re:ords aiehwd-,er.@h and lhe hk rrsidrs on d,sk.

126 CS 323 (H)

1 1 Sequential Access

sl0 NR!J& 16 (file designation) 9:60-3fhMV.'9~%s"U P, S, D M$O F L~0&38’h input

file ~%0f$U~fl¶9tXY04 primary, secondary, demand Vi30 full-procedural

CS 323 (H) 127

Hode (LR)IKey l e n g t h

T y p e (IOUDC) I I Pecord a d d r e s s t y p e (APIB) Add’n(AU)lDes(PSRCTDF)II IOrganization (IT,i-9) IExpandIIEOF (E) II IlOverflou indicator Continue (K) IIShr(SR)IIlSeq (PD) II III Key location lcpt E n t r y I I I R e w n d

Pi!? IlIlFmt (FV) I I I I I I E x t e n s i o n (EL)11 I III Irime IlIIIBlk Ret I I Ill I IDevice Synb T a p e C a r e I I I IFile

I Illlllen len I I III I I cod? dev l a b e l i n d e x I l l l c c n d‘Fl IllIll I 111111 I I I I I I I I I I

* * * * 1 * - - - i - - - * * - * * * *---xi * *......*-----~I*.X* ,,IP F 60 DISK

ZK *,%I 35

1 Sequential Access by Key

0 fl@l%J6d 16 (file designation) 9:&QJ3tIJ~I%‘% P, S, D PqyQ F b~Q&lL&.&

primary, secondary, demand HfQ full procedural

l Sr@lUJ% 19 (record format) ?t~QXi~¶$hLfh.4 F H”aQ V t~QQfLtTl% record

format

128 CS 323 (H)

@ t?@LW$ 24-27 ‘(record length) Q~~l~U~flal~~la~~~ fixed length record

M~QFl2lW.Jla~~J~WUlJ maximum length record !UTlTt%llQs variable-length reoord

e WWJ$ 29 LbAt 30 (key length) ~~~WdlWJl77J09 key field ¶JU VAX !I!!$ ’

b63Y 2 b$ObaU word LLAZLRY 4 IzObgPd long word aUL!oL& binary formatY

N@l%JJ%! 31 (record address type) iilZ&lJTZ¶+!?U A, P MT0 B L~O&%7 in-

dexed key ~W&-& character (A), packed decimal (P) MT0 binary (B)

‘WlW’% 32 (file organization) Pdkt~~t¶@lb%4 indexed file h~lll3kkh

Idode (LR)IKey length

Type (ION:) II Retard address type (APie) Addtn(AU) 1ID+s(PSRCTDF)II IOrganization (IT,l-9) IExpandI IEOF (E) II IlOverflou indicator Continue (K) IIShr(SR)IliSeq (AD) II III Key location ICpt Entry III Reund

l-611 lllIF,t (FV) II III I Extension (EL)11 I Ill Ic me llIII&llk Ret II III I IDevice Symb Tape Core III liile! llllllrn ien II III I I code dev label index III Icord

“I llllli I II III I .I I I I I Ill II

it It****---1---tt-x#* e---*x * *......*-----**t.t* ,,FI&PlJT I? F 60 3PI 1 DISK

ZK 4395as

! .2 Sequential Access Within Limits

CS 323 (H) 129

Sequential File Access Within Limits

A data

0 data

C data

0 data

E data

F data

/:

file

record-limits file

-E-- firs1 record

- second record

low key

Hode ILR)IKcy l e n g t h

Type (IOUDC) I I Record address type (APIE) AddtnlAU)IDes(PSRCTDf)II IOrbanization (IT,l-9) I ExpandI IEOF (E) I I IlOverflou i n d i c a t o r C o n t i n u e (K) IIShr(SR)IllSeq IAD) I I I I I K e y l o c a t i o n topt Entry I I I Rewnd

f i l e llIlfm+” (FV) I I I I I I E x t e n s i o n (EL)ll I III Inave IlIIIBlk Ret I I I I I I IDevice Symb Tape C o r e III lfileI llllllen l e n I I I I I I I code dev l a b e l i n d e x I I I l c o n d

fl llllll I llllll I I I I I III I I

hiPUT**et**---n---*a-s** If---n* *......*-----st*.*e ,,IS F 6OL 3AI i D I S K

ZK-4396-85

CS 323 (H) 131

0 tVl%J~~ 19 (record format) t&a:@ format ?JQ9 record t3eC F 09% V

0 hWl%Jdi~ 24-27 (record length) fhW4~~~lU~l~VQ9 fixed length record W”aO

UUl@l~9~WLl&I record format WdW&J+l!Ufl~~?iQ.! variable length record format

I0 AWB161~ 29 LLA= 30 (key length) hHMflFl~lUUl~YQS key field

FIDXIIZ IP F 60L 3191 1 Dig,:E IDXAlP IDXIl2

132 CS 323 (H)

?llVJ: access file LLlJ9J random bWJ~% relative record number L719~6Qiast'%JU

LjQ%t!?lau F-Form ‘&¶isd

0 WkXJdid 15(file type)1<TEq I V&l U rwloa:~lEha openfile h.&wm:

1109 Input W”aQ&k Update file3

0 tWL%.lbi~ 16 (file designation) Try%33 C H?Q F biQ&l filename fkhl~

!t.W@lLJfi~ 7-14 aeb F-Form $MLflpl chain H?Q full-procedural file

0 tTW.l& 19 (record format) PEZV F YI?Q V t~QQ%JW format 2105 record

0 R@l%.lJ?d 24-27 (record length) ~~~liU1WF1'21U017VQJ fixed length record

H?Q maximum length 2109 variable-length record

0 ~‘GJ~6 28 (mode) TZ$l R L~Q~WQ~99” VAX RPG II YblllT access file bbEl¶J

random IWXll~~~ relative record number

PrQn~HQQ?7n~n7a~~~P~~Q~~~~~ C-Form n*9-kJs-y”l~l:QPil~~~~~Q

0 Wl%.lJ? 18-27 (factor 1) a:v relative record number 9109 record ~bTlP%Wl?~

Ciummla~aJaaera

CS 323 (H) 133

,direct file FL4NO7A ‘b@lU relative record number LLfiW&Q@ primary file %%I RAN107 !&I:~~

record number 66.l~7 ITEM

FRINI07 IP F DISK_ . _FRAN07A UC FFRAN07B 0 FIRAN107 AA 01II

___DISKPRINTER

1 11 STORE33 130ITEtM

iRAN07A AB 02

;c 50EsCc 50ORAN07A000@RAN0760

IlEtlU CHAIKRAN07AGGTO HANDLR

1 ADD ACCESSSETONEXCPTSCTOF

HANDLR TAGSCTON

02 40REMACCESSVALUE

22 lFN40

0 D OlN40

iSTOREACCESS

0 VALUE

ACCESS40

40

LR

;1 0

22 'STORE PURCHASES'

::27

2.2 Random Access by Key

~~lP~~l~l~~~l~~~~1~~~~~~~ randomly retrieve record 9ln indexed file bWU

fll7X¶$b index key dPZ~%XlU

0 *ati ls(sletype) aq 109% u ~~~~~r~~sJn~~l~~~~~ input%% update

@ R@l%J64 16 (file designation ag3tr C Pq?a F LiO&l filename aUK@lU6d

7-14 PZ.b%.& chain file %?“a0 full-procedural file

l aW& 19 (record format) ~~¶.$lbh4 F HTQ V b&OO%J7U record format

0 RW6d 24-27 (record length) IhMUtlTJl%JUl'YNl9 record 'h~¶J fixed

format record LLKn?‘lLJWla~~J~WlloJ record KhMln~lL8UTf~~ variable-length r&ord

134 CS 323 (H)

ISTORES

:ICEOCERI

:

: 50OREFXT

:

i

CS 323 (H;

AB 02

ITCHK CHAINGROCERSETON

H 22 lPEi40

D OiN40STORECOUNTVALUE

1 11 STORE13 130ITEllU

: ~8%tlT7 10 VALUE

50LR

22 'STORE PURCHASES'

135

2.3 Randum Access by ADDROUT File

ADDROUT fde 0XXh&hJ VAXIVMS Sort/Merge Utility dQL~l%~ qualifier

%I /PROCESS = ADDRESS qualifier b~,,,,d~al~c~alunl~~Q~~ (QlQ~,=MWlU3l~fll3~~

II.4 record hfJftl3~%%J SORT/MERGE Lw”0 sort ~Qap&Lhlil~hllw

Random Access by ADDROUT File

tfield to sort

SORT/MERGE 'Whll3 sort record dl9 7 h.L%%J ~la=al96iilrr~~sslQ~~~~~Q~

record d sort. LL!hh.4 ADDROUT file 4isJllW

An ADDROUT F i l e ’

- address of A

f- address of B

- address of C

- address of D

\ADDROUT file

136 CS 323 (H)

I wWK?JJ% 16 (file designation) ~WJ?llTTt~ P ‘VI?0 S &l%% tilename $a*ltlg

aNaW& 7-14 %?l-kb%b”II%l Primary %?~CI Secondary file

e BGW& 19 (record format) 9ZJ’tv F Mf0 V L~C~CI~¶JW~J record format

8 WWJA? 24-27 (record length) l,~Wl1~~3.J~?-41WLllos fixed length record %*a0

maximum length WI9 variable-length record

e fi@lW% 28 (mode) %+I R b&%~ VAX RPG II ‘l%flla access record bW@J*

CD WAJJ~~ 29 bbflt 30 (key length) L&lSt$lWd%JIJ7~llOJ key field t%~llalOUl?lP~

access indexed file

@ WWJ% 31 (record address type) a%?>:$! I Lw”fl~W’R~W?~~Lbft~~ access file

~Wl&Kl~“u” ADDROUT file

indexed file

CS 323 (H) 137

138 CS 323 (H)

FIDXAl3 IR F 6 611 EDISKFIDXI13 I P F 6OR 311 1 DISKFlDX13A 0 F 80 OF PRINTERi IDXAi3 IDXIi3IIDXIl3 AA 0 2I I 3 KEY

1POF

02

UDATE Y

PAGE

TOWNCOUNTYSTATECENEO .ICEN70 JCEMO JCEN50 JCEN40 JCEN30 J

1 12 TOUN13 14 STATE15 25 CCllNTY26 30 ZIP31 350CEN3036 4OOCEN4041 450CEN5046 500CEN6051 550CEN70 "56 600CEN80

1 049 'NEU C~A~IPSHIRE TOUN~'77

CS 323 (H) 139

2.5 Sequential Access and Random Access by Key

full procedural file ~~Q~~l~%~~~l~lsJ1-dndP-dlM file ~~t%WtX%J random

bb% sequential hiId full procedural file $%L!?U indexed file b~lRlUl~tlPth4 file LL¶JEl

random hJi71~%~ key Lb8d'a%"%ll~~ CHAIN M?B SETLL d.$l..fil~‘a6

nl~~ffJlMh~X%.l indexed-full procedural file au F-Form

0 SmZ.JZ?ti 15 (file type) %fl39”q I %?“a0 U rw”oBiib~flu6dndiaaBPs input file

M”aB update file

@ BGl&.lfi$ 29 btRt 30 (key length) ~~~.~FIFI'~~%J!J~'JYQ~ key field

8 WW.l& 31 (record address type) ass”aC$l A, B PSJO P tdBX$? index key l%l

character (A), packed decimal (P) H”a@l ‘binary (B)

140 CS 323 (H)

iTTY D F 80 TTYFFPFIOI ID F 04 DISt:FFPlrJOi IF V 4iR04AI 1 DIS):FFPFOlA B Y 73 LPRINTERLFPFOlFi 55FL 5OOLIFPFXOiI~FPFJO~I

:Ic READ FPFIOl

EPARTNO CHAINFPFJOl

EXCPTC 98 'BAD' DSPLYTTY

1 4 PbRTNO

i 391 iE"40 43 PRICE c44 47 t#OUNT

98

C 98C LOOPCC NLRC NLR

;FPFOlA H :i;

i H 100

i H 00

: H 01

: E 0100

GOT0 ENDT&GREAD FPFJOlEXCPTGOTO LOOPT A G

1P

1P

1P

1P

PARTN3DESCR

!R

32 'PARTS SIJHtMRi INVENTORY'

11 'PART NO'30 'DESCRIPTION'

30 ‘------”

11 ‘~~~~~~~’

4;

CS 323 (H) 141

0 RWJ& 24-27 (record length) %klpalWJlTllFl~ fvted length record &lfl'JlWJla

~S%WIlOJ record aPana&llQd variable-length records

~aiaoeiisT~*unaugi~~~~~~~~~~~ni~*~i~ output sequential file &hYh OUT60A :

FOUT60A 0 F 24 DISKICUTI24 AAI

;I

:OOUT60A D0

NIPPNPNAK

YHOUSECOLORMIGHTQTY

11 iz13 1 718 2 02 1 2 4

310-4 ‘1’12

:o’2 4

PNPNMEUHOUSECOLORUEIGHTQTY

142 CS 323 (I-U

@ Km%JJ# 19 (record format) ac3tr F H?O V bw”o%v record format

0 NWJ& 24-27 (record length) ~ps’a~$J+l’JlWJl3J~J fixed record length %3~DWJl%J-

til&~J~@llloJ record fhi7bfh-4 variable-length record

B) !3mIJ% 28 (mode) %ps”atIj R &JqE$W&3199” VAX RPG II load direct file

~~iaoeil96~arbnasJ~a~~~l~ diiect file $0 OUT60B ‘b@lfJi variable length record

FDUT60B oc vIOUT AA

: 4 1 10 3 PN PNAME

: 11 13 12 17 UHOUSE COLOR

: 21 18 '24 20 UEIGHT QTY

s COUNT COUNT ADD CHAINDUTCOB 1 COUNT 10 99OOUT60B D NIP 25

iPNPNAi-;E ii

: 4 '3'UWJSE

0 COLOR i:

iUEIGHTQTY 5:

CS 323 (H) 143

0 W%J&i 19 (record format) a<X$l F H% V Lw”ClXIj record format

0 W~aJdi?! 24-27 (record length) !.os"a~~~alaJPJlallQ~ fuced record format 't&XlalaJfJla

!9q@lllEl9 record au variable-length records

0 I@W# 29 blRt 30 (key length) fhHUWlal%JUla~Q9 key field !WlX?!~b~l~%68u

binary format %%Rll 2 &M??J word length LLR:LASI 4 th8l.4n~~llQ~ longword lengthi

0 WR%.J~~ 31, (record address type) %;39”acy’A, P, H?O B lw”E&i indexed key ‘$M

La%& character (A), packed decimal (P) p9!0 binary format data (B)

0 WWJdi~ 32 (file organization)‘%gX$! I b&JQ?ldlb%.4 indexed file

0 RWJdi# 35-38 (key location) ~99"a~nadltt~~JuQs~a~n~~~t~~~~~Q~ key

field

St 3AIDISK

1 DISKFOUTCOAIOU1124I

:I

D

1 3 PN4 10 PNAtiE

11 1 2 UHOUSE13 17 COLOR19 20 YEIGHT21 24 PTY

4 '1'WHOLISECOLOR i:WEIGHTQTY 22:

144 CS 323 (H)

fIl3 Adding Rkcords to Files

1. Adding Records to a Sequential File

Adding Records to the End of a Sequrntial File

CS 323 (H) 145

FLOG 0 f 80 DISK AIINPUT 0 1iLOG 1 80 D A T AD A D D 0 1

0 D A T A 8 021(4w-85

2. Adding Records to a Direct File

Adding’Records to a Direct File

0 S%%J6~ 19 (record format) ~Ik+l F I& V !,&XJQ?ldl record format ~N~LIPI~I

146 CS 323 (H)

3. Adding Records to an Indexed File

CS 323 (H) 147

8 SWJGi 7-14 (file name) ~~~~I$blllOS output

FOUT43A 0 F 24 3AL 1 DISK AIICXIOi AA

hT43b DADD? 24 PN

NIP0 PN 24

ZK406-85

fll‘i Updating Records in Files

III.4 VAX RPG II ~l.U3l~lUl~tl~93bfll~ update records I Pa primary, secondary,

demand, full procedural eS”a0 chained file ~UTl~~ll&Ull~ update record a%4 sequential file

zI.4 ~~l~l~l~sln~~~l~~~~Wl~~~ records ~9~a”nI+tI&ZL%4 fixed format length SYhfU fll3

E P 2update record aI.4 primary Mf0 secondary file U’tb ~tln~"ll~~~i%P6bQ~l~~~~~~~ detail time

148 CS 323 (H)

CS 323 (H) 149

FHASTER UC V EORZlAI 1 DISKITRANSACTI

FASTER 01 1 Ch

:I 02 1 CB

C* Update record type 01C MOVEL'A'

kEYflOVE NAHECHAINHASTEREXCPTSETOF

1 20 NAtiE21 25 NEWW

3 6 4 0 EtiPtl80 8 0 LNGTHl

4 6 5 0 EHPW6 0 6 0 LNGTHZ

tEY 21KEY

c* Update record type 02c* &date record type 02

EE I.EYI.EYtiOVEL'B'tiOVEL’B’

CC;;&;ilASTER;;&;ilASTER

OHASTER EOHASTER E 010 1nn NEWWNEWW0 LNGlHl

FASTER E0 2

NEWU0 LNGTHE

0 1

I,EY 21

25060

0 aQZJJ?d 16 (file designation) acT:v F b~Q&lb%4 full-procedural file

0 [email protected]%! 32 (file organization) 199”aZu I %7b&.4 indexed file

WI3 Deleting Records from Files

bTlllU’l$blCfX deleterecord QQn9ln update, direct, bb8: indexed file 16 6&U@‘l,OU

lllT5lZ delete record X!X!XflQ?J&J?er

0 fll3 retrieve record

FBSTER UC F 50R 4AI 47 DISK AFTTY D F 80 TTYIDELETE

:NASTE?1 4 KEY

C KEY CHAINIIASTER 99C 99 'NOTFOUND'DSPLYTTYOt!ASTER DXL N99NlP

Processing Files with Matching Records

~~lCflkJl~Cl~~ matching field 5I.l primary Ps”aQ secondary file t~QVi7??JNQ¶Jd?~¶J

llQ9 record LbXL~QQ&JlfJh%JllQ~ record dJTCl$?LfQfl'Wfl multiple files

Tl771? matching field ~Ub~l'%~QNlTJP~QlJ'h record dWfiZJ~%CQt$U~7$¶.) (018

XX&.4 ascending MT0 descending)~~~Unl~~lHPb~~lUnl~~Q~~ QlXl~~~~"psfllfJ~lfJfll~

CS323(H) 151

time error

1. Checking Record Sequence for One Record Type

b519tSt~ record sequence b W % A pS?D D (Ascending or Descending) !UtT@l%J&? 181

lIEI9 F-Form Lt~~t?VW@ matching field (M 1 - M 9) kJW&i# 61 kR5 62 lob I-Form aU?lTG

~LTl~$ matching field .3Jlfllldl 1 ~lfJlll~%Ps'iilVlWl M 9 7% field “ikl+$$$l bLkLfl3U

OEPl3’Xl~0¶J matching field L~tl~~l~7J~lfl M 9-M 1

2. Checking Record Sequence for More Than One Record Type

Seqvence (AA-ZZ, 01-93)I Number (I-N)I IOptional/External (OJ)I IlRecord identifyinq indicator

Decimal positionsI Control level

I III I I Hatch fieldI III + Identifying codes + Format I I I Fld ret rel

File I III I I I (PB) IField I I Iname I III I

III III I s

C Cl IField lname I I I FieldZ Zl llocationll I I I indicatrs

I III Pos NDcPas NDcPos NDc IFr To II I I It-0

10 l **It *--- *--- *--- .t*---*---#* * * ⌧ II 1 * ,,.,

IPAYROLL PA 01 80 CCI 1 3 DEPT H2

:6 7 DSTRCT fl3

14 152CONM

:25 27 EHPNUfl Hi

Brl 02 80 cs

I : 3 %T 1:

:13 i72SALARY *25 27 EHPNUH Iii

152 CS 323 (H)

IPAYROLL AA 01 80 CC M-- first

:

record iype

3 72: 27

DEPT DSTRCT !:EIIPNUH til

BB 02 80 CS +- second record typeT i 3 DEPT M2iI

8 9 DSTRCT n3 42 5 2 7 CHPNUtl I41 -

Table Matching Fiefd LengthsRecord hfatching Field FieldType Field Location Length

f!rst DSTRCT 6 to 7 2DEFT 1 to 3 3E M P N U M 25 to 27 3

S <- total

second DSTRCT 8 to 9 2DEPT 1 to 3 3EMPNIJM 25 to 27 3

8 < - total-

Matching fields need not be Fpecified for all the record types in a file

Sequence (AA-ZZ, 01-99)I Humher (I-N)I lOptional/Enternal (OU) Decimal positior;sI IlAecord identifying indicator I Control levelI III I I tiatch f i e l dI I I I + Identifyi-; c o d e s + Format I I Fld ret rel

I.; 1I ;..e I III I I I (PB) [Field I I Inaie Illll C C Cl IField Inane I I I Field

I illlll z Z Zl Ilocationll I I I indicatrsI III Pos NDcPos NDcPos NDc IFr To II IlIt-0

** I *** *--- *--- *--- . **---"---•* * * * ,,*,IFAfzOLL AA 01 80 CSI OR 02 80 cn

CS 323 (H) 153

Sequence (AA-ZZ, 01-99)I Nurbcr ( 1 - N )I IOptionel/External (OU) Decimal positionsI IlRccord identifying indicator I Control level- -I III I I Hatch fieldI I l l t Identifying codes + Format I I I Fld ret rel

File I III I I I (PB) IField I I I.naae lllll c C l IField Inane I I I Field

1:lllll z i Zl l l o c a t i o n l l I I I indicatrsI III Pos NDcPos NDcPos NDc IFr T o I I III+-0

** l *II *--- #--- .*a---t---u* (t * * * It il . . . .

IPAYROLL & A 0 1 8 0 c s

:O R 02 80 cn

I

I

il i KCT E2 5 2 7 E!iPNUtl til1 4 152cotltl 0113 172SALARY 02

If one of the matching fields is in a different record position for eachrecord type, you must assign matching field entries, as shown in thefollowing example:

Sequence (AA-ZZ, 01-99)I Number (1-N)I IOptional/External tbUl Gecimal FssitipnsI IlRecord identifying indicator I Ccntrol l e v e lI III I I Hatch fieldI I I I + Identifying codes + Formst i I I Fld ret rel

F i l e I III I I I (PB) IField I I Iname I Ill I

;C C l IField lname I I I Field

I I III I Z ZI llocationll I I I indicates. I I I I I I P o s N D c P o s NkPos NDc IFr T o I I

** t *It* * - - - * - - - *--- .*i---t---s*IPAYRDLL AA

IO R

:

II

0 1 80 cs0 2 8 0 cn

1 3 ENPNWI tll20 21 DSTRCT M3

6 72conti 0110 12 DEPT n23i5 7 DEPT n202

10 1425ALARY 02ZK-4443-85

1 5 4 CS 323 (H)

0 L&I record TWlbL&Jbl 0nLB”na~elnlacuaa~~~~~a record fh~lJ~@lbhlTlLbl%.l

~~n"il::pn~lM~~lUl2W~l~~n'n~~ L&I record Agndluthula-pn~~iu~~~~~~~ record

&du processing area

JllWh~l..6~~LL~FlWlldl matching field 9117 primary file 44 compare n’El matching

field 1% secondary file Ll%Zfll3hlfl record 811 process

a-

Table Matching Primary and Secondary File FieldValues

, .,

Record Number Primary File Secondary File

l A B

2 C D 2

3 Dl ’ X

4 F Z

Figure E-10 shows the logic f!c& when your program uses ma!ching fieldsto do multifile processing. A keyed list follows the figure.

CS 323 (H) 155

Key to Figure

0

0

0

The f&t record of the primary file is read and the matching field (A)is located.

The first record of the secondary file is read and the matching field (B)is located.The contents of the matching field (A) of the first record in the primaryfile are compared with the contents of the matching iield (5) of thefirst record in the secondary file. A is selected.The second record of the primary file is read and the matching field(C) is located.

0

0

0

0

The contents of the matching field (8) of the first record in thesec-ondary file are compared with the contents of the matching field (C)of the second record in the primary file. B is selected.The second record of the secondary file is read and the matching field(D2) is located.The contents of the matchini field (D2) of the second record in thesecondary file are compared with the contents of the matching field(C) of the second :ecord in the primary file. C is selected.The third record of the primary file is read and the matching field (Dl)is located.

The contents of the matching field (D2) of the second record in thesecondary file are compared with the contents of the matching field(Dl) of the third record in the primary file. Dl is selected.The fourth record of the primary file is read and the matching field (F)is located.

The contents of the matching field (D2) of the second record in thesecondary file are compared with the contents of the matching field(F) of the fourth record in the primary tile. D2 is selected.The third record of the secondary fiIe is read and the matching field(X) is located.The contents of the matching field (F) of the fourth record in theprimary file are compared with the contents of the matching field (X)of the third record in the secondary Me. F is selected. Because theprimary file is now at its end, the remaining records in the secondaryfile (X and Z) are processed in order of appearance.

150 CS 323 (H)

l Ok-Records from the first secondary file without matching fields. OS-Records from the second secondary file with matching fields. 06-Records from the second secondary file without matching fields

FRECI99A IP AF 80 DISKFRECI99B IS F R O DISKFRECIS3C IS DISKFOUTPUT 0 DISKIRECI93AIIiIi,?ECI338.:;

:RECI99C

:

IOOUTPUT D0

i soil 80 Fi0 2 8 0 C2

0 3 8 0 c 3

0 4 80 C4

05 80 c5

06 80 C6

NIP

1 80 TEXT1 2 tlATCH

1 80 TEXT

1 8 0 TEXT1 2 NATCH

1 80 TEXT

1 80 TEXT1 2 HATCH

1 80 TEXT

TEXT 80

CS 323 (H)

Ml

til

Hl

Table lists the contents of the matching fields for all three files:primary, first secondary, and second secondary. Field values with A afterthe value represent values from the primary tile. Field values with B afterthe value represent values from the Srst secondary file. Field values withC after the value represent values from the second secondary file.

.

157

Table Matching Field ValuesRecord Primq First SecondaryNumber File File

Second SecondaryF i l e

1 none

2 “One

3, 20;

4 2OA

5 4 0 A

6 5 0 A

7 n o n e

8 6 0 A

9 SOA

none IOC

208 3oc

308 5oc

300 sot

608 n o n e

n o n e 60C

708 8OC

808 8OC

BOB n o n e

Table lists the steps involved in processing the files in Tablethose indicators that must be set on for the operation to occur.

and

Table Processing Records with Matching FieldsStep Record Type Matching Field Value Indicators for Processing

1 02 n o n e Not MR and 02

2 02

3 04

4 05

5 0 1

6 01

7 03

8 03

9 03

1 0 05

1 1 0 1

12 01

13 02

14 05

none

IOC

20A

2 0 A

20B

308

30B

3 o c

4 0 A

5 0 A

n o n e

sot

Not hfR and 02

Not MR and 04

Not MR and 05

M R a n d 01

M R a n d 01

hlR a n d 03

Not MR and 03

Not MR and 03

Not MR and 05

Not h(R and 01

MR a n d 01

Not MR and 02

M R a n d 05

158 CS 323 (H)

Table Processing Records with Matching Fieldsstep Record Type hIatchinR Field Value Indicators for Processing

15 05 5oc

16. 06 none1 7 0 1 6 0 A

18 0 3 608

19 04 none2 0 0 5 60C

21 0 3 70822 0 1 80A23 0 3 SOB24 0 3 8082 5 0 5 8OC2 6 Ojl 8OC2 7 0 6 none

MR and 05Not MX and 06M R and 0 1

MR and 03Not MR and 04

MJt and 05Not MR and 03MR and 0 1MR and 03MR and 03MR and 0 5MR and 05Not MR and 06

Processing Files with Multiple Keys

The fol!owing program reads one input file with three keys. It uses threedifferent file specifications to gather the three keys. Note that the threefile names use identical fields, and that each file name uses a different keyto pain: to the Same fde. Also note the use of the same fields by a datastructure.

CS 323 (H) 1 5 9

FIDXIOl I P F 2 4FIDXJOl I S FFIDX1’01 I S F ::FIDX03A 0 F 2 4IIDXIOl A AI

I

:IIIDXJOl B B

I

:

IIIDXKOl C C

IFIELDS DS1

:

:IGIDX03A D NIP.0

4AI3AI241

21 DISK1 DISK

11 DISKDISK

IDXIOlIDXIOl

: 1 0 3 PN PNME1 1 1 2 WHDUSE1 3 1 7 COLOR1 8 2 0 WEIGHT2 1 2 4 QTY

: 1: LiE11 12 WHOUSE13 17 COLOR1 8 2 0 WEIGHT2 1 2 4 QTY

1 24 FIELDS

1 3 PN4 10 PNAME

ii 12 WHOUSE1 3 1 7 COLOR18 2 0 WEIGHT2 1 2 4 QTY

FIELDS 24

160 CS 323 (H)