Using indexing and displacement in CA Gener/OL
search cancel

Using indexing and displacement in CA Gener/OL

book

Article ID: 9576

calendar_today

Updated On:

Products

Gener/OL

Issue/Introduction

How is indexing and displacement handled by CA Gener/OL?



Environment

Release: GOLADA00100-7.1-Gener/OL-Interface to Adabas
Component:

Resolution

Indexing (a way of accessing a one-dimensional array) and Displacement (a method of accessing where the data can be in any position of the record) are implemented in CA Gener/OL through reserved words RWI1 through RWI8. These reserved words are associated with the field through the use of the Index and the Displaced phase. Please review the following examples.

INDEX Working Storage Example:000001 WORK INDEX PREFIX=IN RESIDENCY=Y DESC'Sample             Index'000002 area 1 20 c000003 rec 1 2 c index rwi2000004 fld1 1 1 c index rwi2000005 fld2 2 1 c index rwi2000006 wrk 21 16 c . * work area take 1/2 x records 3000007 * rounded to next power of 2 = 8000008 * 8 records x 2 bytes = 16 bytes000009 * for work area000010 num 37 4 b . * the number of records in the array000011 dir 41 1 c . * sorting direction ascending or descendingDISPLACE Working Storage Example:


       000001 WORK DISPLACE PREFIX=DI RESIDENCY=Y                                 DESC'Sample Displaced'

000002 area 1 20 c000003 rec 1 2 c000004 fld1 1 1 c displaced rwi2000005 fld2 fld1+1 1 c displaced rwi2000006 wrk 21 16 c . * work area take 1/2 x records 3000007 * rounded to next power of 2 = 8000008 * 8 records x 2 bytes = 16 bytes000009 * for work area000010 num 37 4 b . * the number of records in the array000011 dir 41 1 c . * sorting direction ascending or descending



INDEX Program Example:

 

000001 PROGRAM INDEX DESC='Sample Index'000002 handleclear=stdclear,rte=stdfatal000003 * **********************************000004 * * *000005 * * program : index *000006 * * standard program layout *000007 * * date : mm/dd/yy *000008 * * programmer : <programmer> *000009 * * analyst : <analyst>*000010 * * *000011 * *................................*000012 * * *000013 * * this program will show how *000014 * * to access a one-dimensional *000015 * * array *000016 * * *000017 * **********************************000018 * works/records/segments go next *000019 * **********************************000020 work index000021 * **********************************000022 * * *000023 * * initial *000024 * *................................*000025 * * this is the initializing *000026 * * logic routine *000027 * **********************************000028 initial.000029 move '11223344556677889900' to inarea000030 comp rwi2 = 0000031 * **********************************000032 * * *000033 * * mainloop *000034 * *................................*000035 * * this is were the main logic *000036 * * of program resides *000037 * **********************************000038 main.000039 varying rwi1 = 1 to 10000040 print 'INDEX FLD1 ',infld1,' INDEX FLD2 ',infld2000041 comp rwi2 = rwi2 + 2. * INDEX FACTOR000042 endvary000043 endjob000044 * **********************************000045 * * *000046 * * handle labels routines *000047 * *................................*000048 * * this is were the handle logic *000049 * * of program resides *000050 * **********************************000051 stdclear.000052 endjob000053 stdfatal.000054 print rwmsg rwabend000055 endjobDISPLACE Program Example:


       000001 PROGRAM DISPLACE DESC='Sample Displaced'

000002 handleclear=stdclear,rte=stdfatal000003 * **********************************000004 * * *000005 * * program : displace *000006 * * standard program layout *000007 * * date : mm/dd/yy *000008 * * programmer : <programmer> *000009 * * analyst : <analyst> *000010 * * *000011 * *................................*000012 * * *000013 * * this program will show how *000014 * * to access a one-demensional *000015 * * array *000016 * * *000017 * **********************************000018 * works/records/segments go next *000019 * **********************************000020 work displace000021 * **********************************000022 * * *000023 * * initial *000024 * *................................*000025 * * this is the initializing *000026 * * logic routine *000027 * **********************************000028 initial.000029 move '11223344556677889900' to diarea000030 move 2 to rwrow000031 * **********************************000032 * * *000033 * * mainloop *000034 * *................................*000035 * * this is were the main logic *000036 * * of program resides *000037 * **********************************000038 varying rwi1 = 1 to 10000039 comp rwi2 = rwrow * (rwi1-1). * DISPLACED FACTOR IN ARRAY000040 print 'DISPLACED FLD1 ',difld1, +000041 ' DISPLACED FLD2 ',difld2. * CONTINUED LINE000042 endvary000043 endjob000044 * **********************************000045 * * *000046 * * handle labels routines *000047 * *................................*000048 * * this is were the handle logic *000049 * * of program resides *000050 * **********************************000051 stdclear.000052 endjob000053 stdfatal.000054 print rwmsg rwabend000055 endjob

 

Additional Information

See the CA Gener/OL Reference Guide for detailed information regarding using CA Gener/OL