Mapping ADABAS Structures in the Master File

In this section:

For the Adapter for ADABAS to access ADABAS files, you must describe each ADABAS file you use in a Master and Access File. The logical description of an ADABAS file is stored in a Master File, which describes the field layout.

Standard Master File attributes are generally used to describe ADABAS files, but there are concepts in ADABAS file processing that require special terminology at the field and segment level.

An Access File describes the physical attributes of the ADABAS file, such as the database number, file number, descriptors, and security. See Describing ADABAS Data Sources to FOCUS, for more information about Master and Access Files.

The preferred way to create Master and Access Files is to use the AUTOADBS facility described in The AUTOADBS Facility. For additional information about describing external files to FOCUS, refer to your FOCUS documentation.


Top of page

x
Mapping Repeating Fields

When an ADABAS file contains MU fields or PE groups, the repeating information occurs a variable number of times. The physical record length varies depending on how many times the repeating information actually appears.

In FOCUS, more than one segment is needed to accurately describe an ADABAS file with repeating data. The number of times the fields repeat is expressed in a counter field. Counter fields are discussed in The AUTOADBS Facility.

The OCCURS segment attribute is used by FOCUS to describe MU and PE field types in a FOCUS Master File. Declaring a repeating field in a FOCUS Master File using the OCCURS attribute is discussed in detail in Describing ADABAS Data Sources to FOCUS.

Consider the sample ADABAS file VEHICLES. The FDT for the VEHICLES file is shown below.

*********************************
* FILE     2 (VEHICLES        ) *
*********************************
FIELD DESCRIPTION TABLE
      I      I        I        I              I                        I
LEVEL I NAME I LENGTH I FORMAT I  OPTIONS     I  PARENT OF             I
      I      I        I        I              I                        I
------I------I--------I--------I--------------I------------------------I
      I      I        I        I              I                        I
  1   I  AA  I   15   I    A   I DE,UQ,NU     I                        I
  1   I  AB  I    4   I    F   I FI           I                        I
  1   I  AC  I    8   I    A   I DE           I                        I
  1   I  CD  I        I        I              I                        I
  2   I  AD  I   20   I    A   I DE,NU        I SUPERDE                I
  2   I  AE  I   20   I    A   I NU           I                        I
  2   I  AF  I   10   I    A   I DE,NU        I                        I
  1   I  AG  I    2   I    U   I NU           I SUPERDE                I
  1   I  AH  I    1   I    A   I DE,FI        I                        I
  1   I  AI  I    1   I    A   I FI           I                        I
  1   I  AJ  I    6   I    U   I NU           I SUPERDE                I
  1   I  AK  I        I        I              I                        I
  2   I  AL  I    3   I    A   I NU           I                        I
  2   I  AM  I    4   I    P   I MU,NU        I                        I
      I      I        I        I              I                        I
------------------------------------------------------------------------
SPECIAL DESCRIPTOR TABLE
       I      I        I        I                I                I
 TYPE  I NAME I LENGTH I FORMAT I    OPTIONS     I   STRUCTURE    I
       I      I        I        I                I                I
-------I------I--------I--------I----------------I----------------I
       I      I        I                       I                I
 SUPER I  AN  I    4   I    B   I DE,NU          I AJ (  5 -   6) I
       I      I        I        I                I AJ (  3 -   4) I
 SUPER I  AO  I   22   I    A   I DE,NU          I AG (  1 -   2) I
       I      I        I        I                I AD (  1 -  20) I
       I      I        I        I                I                I
-------------------------------------------------------------------

The MU field, MAINT_COST, is a field in VEHICLES. It is allocated to a new segment, AM0101, required by the adapter, as shown in the Master File for a partial view of the VEHICLES file, illustrating the use of OCCURS=occursname:

$$$ CREATED BY AUTOADBS ON 12/10/97 AT 10.17.27 BY PMSMJB
FILENAME=ADACAR,SUFFIX=ADBSINX,$
$ ADABAS FILE = VEHICLES-FILE                     DICTIONARY = 6
SEGNAME=S01     ,SEGTYPE=S,$
 FIELD= REG_NUM               ,ALIAS= AA      ,A15  ,A15  , INDEX=I,$
 FIELD= CHASSIS_NUM           ,ALIAS= AB      ,I9   ,I4   ,$
 FIELD= PERSONNEL_ID          ,ALIAS= AC      ,A8   ,A8   , INDEX=I,$
 FIELD= CLASS                 ,ALIAS= AH      ,A1   ,A1   , INDEX=I,$
 FIELD= LEASE_PUR             ,ALIAS= AI      ,A1   ,A1   ,$
 FIELD= DATE_ACQ              ,ALIAS= AJ      ,P6   ,Z6   ,$
$GRMU = CAR_MAINTENANCE       ,ALIAS= AK      ,A11  ,A7   ,$
  FIELD= CURR_CODE            ,ALIAS= AL      ,A3   ,A3   ,$
  FIELD= MAINT_COST_CNT       ,ALIAS= AMC     ,I4   ,I2   ,$
 FIELD= DAT_ACQ_DESC          ,ALIAS= AN      ,A4   ,A4   , INDEX=I,$
 GROUP= MODEL_YEAR_MAKE       ,ALIAS= AO      ,A28  ,A22  , INDEX=I,$
  FIELD=YEAR_S02              ,ALIAS= AG      ,P2   ,Z2   ,$
  FIELD=MAKE_S02              ,ALIAS= AD      ,A20  ,A20  , INDEX=I,$ 
SEGNAME=AM0101  ,SEGTYPE=S,PARENT=S01  ,OCCURS=AMC,$  MAX= 60
 FIELD= MAINT_COST             ,ALIAS= AM      ,P7   ,P4  ,$
 FIELD= AM0101_OCC             ,ALIAS= ORDER   ,I4   ,I2  ,$

In the original segment, the MAINT_COST_CNT (ALIAS=AMC) field contains the total number of occurrences of the MAINT_COST field. The new segment, AM0101, contains the MAINT_COST data field and the newly created AM0101_OCC field. The AM0101_OCC field contains the position of each occurrence.

This example includes the group field called CAR_MAINTENANCE, which contains the MU field, MAINT_COST. AUTOADBS comments out the group field with $GRMU because its length is variable (depending on the number of occurrences of the MU field). FOCUS cannot report on a group with an unknown length. However, the component fields can be referenced for reporting purposes.

Note: The AUTOADBS facility would automatically create the new segment, AM0101, for you. Otherwise, you must create the new segment using the OCCURS segment attribute. See Describing ADABAS Data Sources to FOCUS, for more information about describing multi-value fields with the OCCURS attribute.

The following is the Access File for the VEHICLES file:

 $$$ CREATED BY AUTOADBS ON 12/10/97 AT 10.17.27 BY PMSMJB
$$$ FILENAME=ADACAR,SUFFIX=ADBSINX,$
RELEASE=6,OPEN=YES,$ 
$ ADABAS FILE = VEHICLES-FILE                     DICTIONARY = 6
SEGNAM=S01   ,ACCESS=ADBS,FILENO=002,
              CALLTYPE=RL,SEQFIELD=PERSONNEL_ID,$
 FIELD= DAT_ACQ_DESC                        ,TYPE=NOP,$
 FIELD= MODEL_YEAR_MAKE                     ,TYPE=SPR,$
  FIELD=YEAR_S02                            ,TYPE=   ,NU=YES,$
  FIELD=MAKE_S02                            ,TYPE=DSC,NU=YES,$
SEGNAM=AM0101,ACCESS=MU  ,FILENO=002,$ MAINT_COST

A new segment is created for the MU field. Note that for this new segment, ACCESS=MU.

Here is an example of the counter fields. The AMC field contains the total count of occurrences, the AM field contains the actual data, and the ORDER field contains the position of each occurrence.

     (AMC)          (AM)        (ORDER)
MAINT_COST_CNT   MAINT_COST   AM0101_OCC
--------------   ----------   ----------
             1          520            1
----------------------------------------
             1          210            1
----------------------------------------
             4           44            1
             4          322            2
             4           66            3
             4          188            4
----------------------------------------
             6          324            1
             6         1103            2
             6          566            3
             6          755            4
             6          988            5
             6         1899            6
----------------------------------------
             2          344            1
             2          500            2

In some cases, the ORDER field may describe the months of the year (1-12). If all occurrences for the month of June are needed, for example, you would print data in which the ORDER field is equal to 6 (for June).

Using the preceding sample data, here is an example of how to use the ORDER field; this request always selects the sixth occurrence of maintenance costs:

TABLE FILE VEHICLES
PRINT MAINT_COST 
WHERE AM0101_OCC EQ 6 
END
MAINT_COST
----------
      1899

Using the same data, this request always selects the second occurrence of maintenance costs:

TABLE FILE VEHICLES
PRINT MAINT_COST 
WHERE AM0101_OCC EQ 2 
END
MAINT_COST
----------
       322
      1103
       500

Information Builders