• Aucun résultat trouvé

Documenting Record Layout

When record layouts are documented, your programs are easier to write. Figure 25 shows the layout of a customer master record. A record layout should include the order of the fields in the record, the length of each field, and the name of each f i e l d .

Record Length

Although field lengths within a record may vary, the field lengths for the same fields i n e a c h r e c o r d i n a f i l e s h o u l d b e th e s a m e , a n d a l l r e c o r d s i n a p a r t i c u l a r f i l e m u s t be the same length. Record length is the sum of the field lengths (including reserved s p a c e ) .

I n o u r i n i t i a l e x a m p l e i n t h i s s e c t i o n , t h e s u m o f t h e f i e l d s w a s s e t a t 1 1 6 p o s i t i o n s . However, record length (Figure 25) was established at128, to reserve 12 positions for data that might be needed at a later time.

Key

CODE = Record code

C U S T N O = C u s t o m e r n u m b e r

N A M E = Customer name

AODR = Customer street address

CITST = Citv and state D E L E T E = D e l e t e c o d e

Figure 25. Layout of Customer Master Record ut

o

CUSTNO N A M E A D D R C I T S T o t h e r F i e t d s t

44

Block Length

lnformation about blocks may also be required in your programs. A btock is the n u m b e r o f r e c o r d s t r a n s f e r r e d b e t w e e n a d i s k f i l e a n d t h e p r o c e s s i n g u n i t ( i n p u t ) o r b e t w e e n th e p r o c e s s i n g u n i t a n d a d i s k f i l e ( o u t p u t ) . A l t h o u g h o n l y o n e r e c o r d a t a t i m e i s a v a i l a b l e f o r p r o c e s s i n g b y y o u r p r o g r a m , o n e o r s e v e r a l r e c o r d s m a y b e transferred at one time. When more than one record is transferred, the records are blocked. Transferring blocked records can result in more rapid processing. When onf y one record is transferred at a time, the records are unblocked. Transferring blocks of records can decrease the time required to perform a job, because when r e c o r d s a r e t r a n s f e r r e d o n e a t a t i m e , a c c e s s t i m e i s r e q u i r e d fo r t h e d i s k a c c e s s a r m to locate each record, and when several records are transferred at a time. access time i s u s u a l l y l e s s .

You may want to use unblocked records when a program takes a large amount of s t o r a g e . T o t a l t i m e t o d o t h e j o b m a y i n c e r a s e , b u t y o u r p r o g r a m w i l l f i t i n s t o r a g e .

Block length isa multiple of record length. For example, if your record length i s 6 4 , b l o c k l e n g t h c o u l d b e 2 s 6 ( 6 4 x 4 = 2 5 6 ) . B l o c k l e n g t h in this case is

f o u r t i m e s a s la r g e a s r e c o r d le n g t h . T h e m u l t i p l e 4 i n d i c a t e s t h e n u m b e r o f r e c o r d s you want transferred at one time.

T h e d e s i g n o f S y s t e m / 3 in f l u e n c e s b l o c k l e n g t h . R e c a l l th a t t h e s m a l l e s t d i v i s i o n of a disk is a sector, and it can contain up to 256 characters. The system transfers d a t a i n s e c t o r s , t h a t i s , m u l t i p l e s o f 2 5 6 c h a r a c t e r s . lf y o u r r e c o r d le n g t h i s 1 2 8 . y o u might have a block length of 256, indicating that you want two records transferred 1 1 2 8 x 2 = 2 5 6 ) . O r y o u m i g h t h a v e a b l o c k l e n g t h o f 5 1 2 , i n d i c a t i n g t h a t f o u r records are to be transferred (128 x 4 = SlZl.

F o r e f f i c i e n t b l o c k i n g , y o u s h o u l d c h o o s e a r e c o r d le n g t h th a t i s a m u l t i p l e o f 256 (256 x 2 --

512]. or submultiple of 256. A submultiole is a number that di-v i d e s in t o 2 5 6 a w h o l e n u m b e r o f t i m e s . F o r e x a m p l e , 6 4 i s a s u b m u l t i p l e o f 256 (256 + 64 = 4). See Figure 26 for examples of how record length affects c o m p u t e d b l o c k l e n q t h .

Y o u c a n , h o w e v e r , s p e c i f y a r e c o r d le n g t h th a t i s n o t a m u l t i p l e o r s u b m u l t i p l e o f 2 5 6 . T h e s y s t e m a l l o w s y o u c o m p l e t e fl e x i b i l i t y i n c h o o s i n g a r e c o r d le n g t h to f i t y o u r a p p l i c a t i o n a n d y o u r d i s k s t o r a g e c a p a c i t y . W h e n y o u u s e a r e c o r d l e n g t h w h i c h i s n o t a m u l t i p l e o r s u b m u l t i p l e o f 2 5 6 , n o d i s k s t o r a g e is w a s t e d ; s o m e r e c o r d s w i l l s i m p l y r e s i d e i n m o r e t h a n o n e s e c t o r .

Sector A Sector B

roo

1 0 0

5 6 1 4 4

1 0 0 100 1 2

Record Record 2

Record 3

However, when you specify 10O-character records as shown in the example, the c o m p u t e r r e q u i r e s m o r e m a i n s t o r a g e t o p r o c e s s t h e s e r e c o r d s .

P l a n n i n g D i s k F i t e s 4 5

Record

in Group B can require a larger input/output area than files in Group A.

Group A Files Group B Files

Consecutive Output Consecutive Update Consecutive Input Indexed I nput with Add

Indexed Input without or Update

entries represent the number of bytes of l/O area that RPG ll will use, assuming that the block length you have specified is less than or equal to the values shown in this figure, and that the block length is a multiple of record length. lf the specified block length is greater than the values shown, RPG ll will round the block length so that the computed size is a multiple of 256.

ffofe.' This figure applies to:- 5444 and 5445 files, single l / O a r e a s f o r d a t a o n l y , s i n g l e v o l u m e f i l e s o n l y . Figure 26. Size of Input/Output Area Computed by RPG ll for

Disk Files

46

You recall that the system always transfers data from disk to the computer in increments of sectors. To process record 3, therefore. two sectors must be in main storage, sector A and sector B. The first 56 characters of record 3 reside in sector A; the remaining 44 reside in sector B. Thus, to process 100-character r e c o r d s w i t h a b l o c k le n g t h o f 1 0 0 r e q u i r e s t h a t 5 1 2 c h a r a c t e r s ( t w o sectors) b e a v a i l a b l e i n m a i n s t o r a g e .

A s a n o t h e r e x a m p l e , s u p p o s e y o u s p e c i f i e d 1 0 O - c h a r a c t e r r e c o r d s w i t h a b l o c k length of 400. Four 100-character records can span three sectors. To process your r e c o r d s i n t h i s c a s e r e q u i r e d 7 6 8 c h a r a c t e r s ( t h r e e s e c t o r s ) i n m a i n s t o r a g e .

Sector B Sector C Sector D

I too ''r

l 88

1 0 0

u r l 3 2

1 0 0

R e c o r d 6 R e c o r d 7 R e c o r d 8 R e c o r d 9

T h e b l o c k le n g t h f o r d i s k re c o r d s i s s p e c i f i e d o n a n R P G ll F i l e D e s c r i p t i o n Specifications sheet, and can be from 1 to 9999 bytes for disk files. The block length in a given program does not have to be the same as the block length speci-fied when loading the file. Block length does not affect the way that records are written on disk. but is used to specify the amount of core to be used for the l/O area in the processing program. Block length can be as large or as small as the g i v e n p r o g r a m w i l l a l l o w ; w i t h a l a r g e b l o c k le n g t h , m o r e re c o r d s a r e a v a i l a b l e ( i n core) at a given t i m e th a n if n o b l o c k i n g i s s p e c i f i e d . l n R P G ll . i f b l o c k le n g t h is specified as equal to record length, the compiler will assign an efficient block length, to take advantage of the fact that the l/O area must be a multiple of the sector size (256 bytes).

Blocking can be an advantage if you are likely to process multiple records in the block - sequential processing, for example. However, if you are processing se-quentiaf ly with additions, blocking may have an adverse affect on performance for Models 6 and 10; blocking does not affect performance for Model 15.

When processing randomly, you shouldn't specify a large blocking factor unless you are certain that the system will process more than one record in a block before getting another block.

B l o c k l e n g t h o f 4 0 0

P f a n n i n g D i s k F i l e s 4 7

Shared Input/output Area for Model 6 and Model 10 Disk system - RpG ll or coBoL and 52144 Only

U s u a l l y a p r o g r a m u s e s o n e in p u t / o u t p u t ( l / o ) area f o r e a c h f i l e . H o w e v e r , i f you are using the 5444, and you have a large program that cannot run in the storage a v a i l a b l e , y o u m a y want to use a shared l l o a r e a t o r e d u c e t h e a m o u n t o f s t o r a g e n e e d e d . A s h a r e d l / O a r e a m e a n s t h a t a l l t h e 5 4 4 4 d i s k fi l e s in t h e p r o g r a m s n a r e a s i n g l e l / O a r e a . H o w e v e r , s i n c e a s h a r e d l / O a r e a i n c r e a s e s t h e t i m e r e q u i r e d t o p r o c e s s y o u r p r o g r a m , y o u s h o u l d n o t u s e s h a r e d l / o a r e a s u n l e s s y o u r p r o g r a m i s t o o l a r g e t o f i t i n t o m a i n s t o r a g e . I n c o B o L , t h e s A M E A R E A c l a u s e i s u s e d t o s h a r e a n l / O a r e a . S h a r e d l / O i s n o t a v a i l a b l e o n t h e M o d e l ' l

5 .

T o d e t e r m i n e t h e t o t a l l/ o a r e a n e e d e d w h e n e a c h f i l e h a s i t s o w n l / o a r e a , y o u f i n d t h e b l o c k le n g t h s a s s i g n e d t o e a c h f i l e a n d a d d th e m to g e t h e r . D e t e r m i n i n g t h e b l o c k le n g t h f o r R P G ll i s d i s c u s s e d u n d e r B l o c k L e n g t h e a r l i e r i n t h i s c h a p t e r . For a discussion of this capability in FoRTRAN, see sharing Buffers in the I gM system/3 FoRTRAN lv Reference Manual, SC2g 6g74; for a discussion of this capability in coBoL, see same Area clause in the IBM system/3 subset Ameri-can National Standard COBOL. GC2B 6452.

S h a r e d l / O d o e s n o t a l l o w fo r r e c o r d b l o c k i n g . T o d e t e r m i n e t h e s i z e o f t h e s h a r e d l / O a r e a n e e d e d , y o u f i n d t h e la r g e s t r e c o r d s i z e i n a n y o n e d i s k fi l e u s e d b y t h e p r o g r a m . T h e l/ O a r e a s i z e i s th e n d e t e r m i n e d a s fo l l o w s :

l f t h e r e c o r d s i z e i s 2 5 6 b y t e s , o r a s u b m u l t i p l e o f 2 b 6 , th e l / O a r e a s i z e is 256 bytes.

l f t h e r e c o r d s i z e i s a m u l t i p l e o f 2 5 6 b y t e s , t h e l / O a r e a s i z e i s e q u a l t o t h e record size.

l f t h e r e c o r d s i z e i s n e i t h e r a m u l t i p l e n o r a s u b m u l t i p l e o f 2 5 6 b y t e s , t h e l l O a r e a s i z e i s e q u a l t o t h e r e c o r d s i z e p l u s 2 5 5 b y t e s , r o u n d e d t o t h e n e x r h i g h e r 2 5 6 - b y t e i n c r e m e n t . S h a r e d l / O a r e a s c a n n o t b e s p e c i f i e d i n a p r o g r a m i f t h a t p r o g r a m a l s o s p e c i f i e s a 5 4 4 5 f i l e .

Buffered l/O

F o r c e r t a i n ty p e s o f p r o c e s s i n g ( s u c h a s c o n s e c u t i v e i n p u t o r o u t p u t ) , y o u c a n specify an extra l/O area. When this process, called buffering, is specified, an extra area is reserved so that the records being processed are directed first to one a r e a , th e n t o t h e o t h e r . A l t h o u g h s p e c i f y i n g a n e x t r a l / O a r e a a l l o w s th e p r o c e s s i n g o p e r a t i o n s b e i n g p e r f o r m e d to b e o v e r l a p p e d , e x t r a m a i n s t o r a g e i s r e q u i r e d , w h i c h r e d u c e s t h e a m o u n t o f m a i n s t o r a g e a v a i l a b l e t o t h e p r o g r a m . U s e o f d u a l l / o a r e a s i n a n R P G l l p r o g r a m m a y c a u s e o v e r l a y s t h a t m i g h t n o t o t h e r w i s e h a v e b e e n generated.

Documents relatifs