How can I create access to multiple records in a coodinated file not keyed to a prior file?
search cancel

How can I create access to multiple records in a coodinated file not keyed to a prior file?

book

Article ID: 31131

calendar_today

Updated On:

Products

Vision:Builder Vision:Inform Vision:Two

Issue/Introduction

Question:

How can I create access to multiple records in a coordinated file not keyed to a prior file?

 

Answer:

The problem is that temporary field coordination will only pull one coordinated record for each occurrence of the driving field.  In the case where we are driven by the master file root, this means exactly one occurrence. 

To circumvent this, we can use an additional dummy cord file with a single record.  The structure of this file is hierarchical where the level two segment will occur a fixed number of times, as many as potentially needed to be retrieved per driver record.  For example, if there could be 160 occurrences of this cord file per master file record, level 2 must be specified to occur 160 times.  Level 2 need only contain the data needed to coordinate to the desired file. If the key is 15 bytes for the sake of this discussion then level 2 would have a single field, 15 bytes which occurs 160 times. Record size is 1 + 160*15) 

The actual data record can have a single character, say A, in the first byte.  The rest of the record is blank, but the record size must match the file definition.  This dummy file is read in a one time request just to get this dummy record/structure into the buffer.  Use temp field coordination where the TF and initial value is also in the one time request. 

The desired file will be read twice for each key.  It will be read the first time using a generic read to get the record and move the key to the dummy structure.  When all occurrences for a given key are found, then the cataloged request is complete. 

The requests can be cataloged and the requests and definitions captured into a Dataview so this is applicable to VISION:Inform as well.

 

File Def for dummy cord file

dummy   FD

dummy   L0         rootkey  01 1 0001C0011

dummy   L0         seg2key 02 2 0001C0160

dummy   L0         sourcef1 02 2 0001C002

dummy   L0         sourcef2 02 2 0001C009

dummy   L0         sourcef3 02 2 0001C005

 

Run Control for LDV and to catalog the requests

RF master            M4OLD

RF dummy           M4CORD7                          dummykey                         T

RF multfile           M4CORD8                                                                           R

RF multfile           M4CORD9                          seg2key                              7

 

ONETIME ER                                                                      1(col 48)

ONETIME AA      read dummy record one time

ONETIME TFdummykey001C         A(init value col 29)

ONETIME PR      7rootkey EQ7rootkey

 

READMULTER

READMULTAA    build generic portion of key 

READMULTTFgenkey  011C

READMULTPR                                  R  Osourcef1                                     Tgenkey

READMULTPR                                  R  Osourcef2                                     Tgenkey 0309C

READMULTAA    clear last - replace blanks into all occurs of level 2

READMULTPR                                  R  C                                                     7seg2key

READMULTAA    attempt match to generic, if fails - bail

READMULTPR    Tgenkey               RE8

READMULTPR    FRSTATUS            EQCKEQL

READMULTPR                                  NS   NEXT REQUEST

READMULTAA    if ok, move to first lev2 seg and go to sub to continue

READMULTPR                                 R   Tgenkey                                       7seg2key

READMULTPR                                 R   8sourcef3                     7sourcef3

READMULTPR                                  GO SUB GETREST

 

                                                                                                         (56)                                               (69)

GETREST ER                                                                    S                                           1

GETREST AA        a sequential read following a direct read

GETREST AA                       keeps the key for comparison

GETREST PR                                      RD8

GETREST PR        FRSTATUS            EQCEGRP

GETREST PR                                      GS   RETURN

GETREST AA        if not end of group, then successful  - replace and continue

GETREST PR                                     R   Tgenkey                                       7seg2key

GETREST PR                                     R   8sourcef3                     7sourcef3

GETREST PR                                      GO REQUEST GETREST

Environment

Release:
Component: V:BLDR