Master File Attributes

In this section:

How to:

Each Master File that provides access to an IMS data source describes the segments and fields that are available through one IMS PCB.

Note: You do not have to describe every segment from the PCB in the Master File. However, the portion of the hierarchy you describe must be a subtree starting from the root. Any segment or field that you do not describe in the Master File remains invisible to the server.

Reporting costs are largely a function of the volume of data transferred. Therefore, requests issued through the adapter are efficient and cost effective, because only segments referenced in your request are retrieved.

In a Master File, you can describe up to 64 segments across 15 levels. The cumulative length of all fields across all segments cannot exceed 12,000 bytes (an IMS restriction). See How to Specify IMS Field Attributes for additional information about this limit.

Each Master File is stored as a member of a Master File PDS or HFS directory. The member name for a Master File must be the name assigned to that Master File in the Access File record for the corresponding PCB. At run time, the Master File data set is allocated to ddname MASTER.

A Master File consists of file, segment, and field declarations. Rules for declarations are:


Top of page

x
Syntax: How to Identify Master Files for IMS

Each Master File begins with a file declaration that names the file and describes the type of data source"an IMS data source in this case. The file declaration has two attributes, FILENAME and SUFFIX.

FILE[NAME]=name, SUFFIX=IMS [,$]

where:

name

Is any 1- to 8-character name.

IMS

Indicates that the Adapter for IMS is required for data retrieval.


Top of page

x
Syntax: How to Specify IMS Segment Attributes

Each IMS segment described in a Master File requires a segment declaration that consists of at least two attributes, SEGNAME and SEGTYPE. The SEGNAME value is the name of the corresponding IMS segment. The SEGTYPE value identifies the segment characteristics.

SEGNAME=segname, SEGTYPE=segtype [,PARENT=parent] [,$]

where:

segname

Is the 1- to 8-character IMS segment name from the NAME parameter of the SENSEG record in the IMS PCB.

segtype

Is S0 or U. U is used to identify unique segments that are data sensitive. A unique segment has no twins (PTR=NOTWIN in the IMS DBD). While a parent segment can have many types of unique children, it can have at most one instance of each type.

Note: In older releases of the adapter, the SEGTYPE attribute was also used to identify the segment's key type. While those SEGTYPE values are still supported by the adapter, new synonyms created using the Web Console or Data Management Console identify these characteristics using the KEYTYPE attribute in the Access File. For information, see KEYTYPE in IMS.

parent

Is the name of the parent segment from the IMS data source. Its value comes from the PARENT parameter of the SENSEG record in the IMS PCB.


Top of page

x
SEGNAME in IMS

The SEGNAME attribute identifies the IMS segments you can access. The SEGNAME value is the name of the IMS segment from the SENSEG record in the PCB.

The server retrieves segments in top-to-bottom left-to-right sequence as described by the Master File. Therefore, the order of segments in the Master File should be the same as their order in the PCB to maintain the correct hierarchical sequence.


Top of page

x
SEGTYPE in IMS

The SEGTYPE attribute is either S0 or U. U is used to identify unique segments that are data sensitive. A unique segment has no twins (PTR=NOTWIN in the IMS DBD). While a parent segment can have many types of unique children, it can have at most one instance of each type.

Note: In older releases of the adapter, the SEGTYPE attribute was also used to identify the segment key type. While those SEGTYPE values are still supported by the adapter, new synonyms created using the Web Console or Data Management Console identify these characteristics using the KEYTYPE attribute in the Access File. For information, see KEYTYPE in IMS.


Top of page

x
PARENT in IMS

How to:

The PARENT attribute identifies the parent of the segment in the hierarchy. It appears in the PARENT parameter of the SENSEG record in the PCB. The only exception is in the root segment, where the PCB either omits the PARENT parameter or specifies PARENT=0. In the Master File, you can specify the PARENT attribute of the root segment as PARENT= , or you can omit it.



x
Syntax: How to Specify IMS Field Attributes

Each segment consists of one or more fields. The IMS DBD contains FIELD declarations for all sequence (key) and search fields, but other fields are optional.

If the PCB you are describing contains SENFLD records for a segment, the Master File can view only fields explicitly specified in those SENFLD records.

However, if the PCB does not contain any SENFLD records for a segment, you can describe the entire segment in the Master File. You can get information about sequence and search fields from the DBD. To describe other fields, you may have to refer to an external description of the segment, for example, a COBOL FD.

The Master File need not describe all fields from a segment, but it must include an initial subset of the segment (that is, it must start from the beginning and not contain any gaps).

To describe a field in the Master File, you must specify the primary attributes FIELDNAME, ALIAS, USAGE, and ACTUAL. These attributes are discussed in this topic. Note that the adapter does not support the MISSING attribute.

FIELD[NAME]=field,[ALIAS=]alias,[USAGE=]display,[ACTUAL=]imsformat ,$

where:

field

Is a 1- to 66-character field name. In requests, the field name can be qualified with the Master File and/or segment name. Although the qualifiers and qualification characters do not appear in the Master File, they count toward the 66-character maximum.

alias

Is the alias for a type of field. Possible values are:

imsfield.KEY, the alias for a field that is an IMS key field. Form the alias by appending the suffix KEY to the name of the IMS field.

imsfield.IMS, the alias for a field that is an IMS search field. Form the alias by appending the suffix IMS to the name of the IMS field.

imsfield.HKY, the alias for a field that is the key of the root segment in an HDAM data source. Form the alias by appending the suffix HKY to the name of the IMS field.

display

Is the server display format for the field.

imsformat

Is the server definition of the IMS field format and length (n).

You can omit the ALIAS, USAGE, and ACTUAL keywords from the field declaration if the values are specified in the standard order (FIELD, ALIAS, USAGE, ACTUAL). For example, the following declarations are equivalent:

FIELD = YEAR, ALIAS=, USAGE=A2, ACTUAL=A2,$
FIELD = YEAR, ,A2, A2,$

Top of page

x
FIELD NAME in IMS

Field names can consist of a maximum of 66 alphanumeric characters. IMS field names are acceptable values if they meet the following naming conventions:

Since field names appear as default column titles for reports, select names that are representative of the data.

Note: You can only specify field names in an SQL request. You cannot specify the ALIAS name.


Top of page

x
ALIAS in IMS

The ALIAS value in the Master File distinguishes between fields that are defined in the IMS DBD and fields that are not defined to IMS. The adapter uses this information in constructing DL/I calls to IMS.

If a field name in a WHERE clause is a sequence or search field, the adapter may be able to create an SSA that instructs IMS to apply the screening test and return the appropriate records to the server. If the field is not defined in the DBD, the adapter must retrieve all records sequentially from IMS so that the server can screen them.

Note: In certain cases, the adapter can instruct IMS to screen values based on a secondary index. Segment Redefinition in IMS: The RECTYPE Attribute describes the technique for taking advantage of a secondary index.

The ALIAS value for a field defined in the DBD is composed of:

Except for certain types of control field entries (for example, ORDER and RECTYPE), fields not defined in the DBD should not be assigned ALIAS names. For more information on ORDER and RECTYPE control fields, see Segment Redefinition in IMS: The RECTYPE Attribute.


Top of page

x
USAGE in IMS

The USAGE attribute indicates the display format of the field. An acceptable value must include the field type and length and may contain edit options. The server uses the USAGE format for data display on reports. All standard USAGE formats (A, D, F, I, P) are available.


Top of page

x
ACTUAL in IMS

How to:

The ACTUAL attribute indicates the server representation of IMS field formats.

For fields defined in the DBD (sequence and search fields), use the format specified in the DBD.

Use the following chart as a guide for describing ACTUAL formats of those fields not defined in the DBD:

COBOL Format

COBOL PICTURE

Bytes of Storage

ACTUAL Format

USAGE Format

DISPLAY

X(4)

4

A4

A4

DISPLAY

S99

2

Z2

P3

DISPLAY

9(5)V9

6

Z6.1

P8.1

DISPLAY

99

2

A2

A2

COMP

S9

4

I2

I1

COMP

S9(4)

4

I2

I4

COMP

S9(5)

4

I4

I5

COMP

S9(9)

4

I4

I9

COMP-1

-

4

F4

F6

COMP-2

-

8

D8

D15

COMP-3

9

1

P1

P1

COMP-3

S9V99

2

P2

P5.2

COMP-3

9(4)V9(3)

4

P4

P8.3

FIXED BINARY(7) (COMP-4)

B or XL1

4

I4

I7

Note: The USAGE lengths shown are minimum values. You can make them larger and add edit options. You must allow space for all possible digits, a minus sign for negative numbers, and a decimal point in numbers with decimal digits.

The cumulative length of all fields, across all segments, cannot exceed 12K bytes.

The following example illustrates the DI21PART Master File that provides access to the DI21PART data source.

FILE=DI21PART    ,SUFFIX=IMS,$
SEGNAME=PARTROOT ,PARENT=,SEGTYPE=S0,$
  FIELD=PARTKEY  ,ALIAS=PARTKEY.HKY  ,USAGE=A17  ,ACTUAL=A17  ,$
  FIELD=SKIP1    ,ALIAS=             ,USAGE=A33  ,ACTUAL=A33  ,$
SEGNAME=STANINFO ,PARENT=PARTROOT,SEGTYPE=S0,$
  FIELD=STANKEY  ,ALIAS=STANKEY.KEY  ,USAGE=A2   ,ACTUAL=A2   ,$
  FIELD=SKIP2    ,ALIAS=             ,USAGE=A83  ,ACTUAL=A83  ,$
SEGNAME=STOKSTAT ,PARENT=PARTROOT,SEGTYPE=S0,$
  FIELD=STOCKEY  ,ALIAS=STOCKEY.KEY  ,USAGE=A16  ,ACTUAL=A16  ,$
  FIELD=SKIP3    ,ALIAS=             ,USAGE=A124 ,ACTUAL=A124 ,$
SEGNAME=CYCCOUNT ,PARENT=STOKSTAT,SEGTYPE=S0,$
  FIELD=CYCCKEY  ,ALIAS=CYCCKEY.KEY  ,USAGE=A2   ,ACTUAL=A2   ,$
  FIELD=SKIP4    ,ALIAS=             ,USAGE=A23  ,ACTUAL=A23  ,$
SEGNAME=BACKORDR ,PARENT=STOKSTAT,SEGTYPE=S0,$
  FIELD=BACKEY   ,ALIAS=BACKEY.KEY   ,USAGE=A10  ,ACTUAL=A10  ,$
  FIELD=SKIP5    ,ALIAS=             ,USAGE=A65  ,ACTUAL=A65  ,$


x
Syntax: How to Issue a GROUP Field in IMS

IMS fields can consist of multiple elementary fields. In the Master File, you can break the IMS field into component parts using a GROUP field.

The GROUP record in the Master File describes the combined elementary fields. FIELD records immediately following the GROUP record describe the individual elementary fields.

Each element of the group can have a different format. However, retrieval is more efficient if each USAGE format is of the same type (for example, alphanumeric or packed) as its ACTUAL format; the lengths may differ.

GROUP=gname, ALIAS=alias, ELEMENTS=n,$
 FIELD=fld1,,usage1,actual1,$
 .
 .
 .
 FIELD=fldn,,usagen,actualn,$

where:

gname

Is the group name. It can be any name that complies with field naming conventions.

alias

Is the IMS field name from the DBD if the group field is a sequence or search field. Possible values are:

imsfield.KEY is the alias for a field that is an IMS key field. Form the alias by appending the suffix KEY to the name of the IMS field.

imsfield.IMS is the alias for a field that is an IMS search field. Form the alias by appending the suffix IMS to the name of the IMS field.

imsfield.HKY is the alias for a field that is the key of the root segment in an HDAM data source. Form the alias by appending the suffix HKY to the name of the IMS field.

Note: The keyword ALIAS is required.

n

Is the number fields in the group.

fld1,...,fldn

Are field names for the individual elements that compose the group.

usage1,...,usagen

Are USAGE formats for the individual elements. For efficient retrieval, each individual USAGE format must be of the same data type as its corresponding ACTUAL format, but their lengths can differ.

actual1,...,actualn

Are ACTUAL formats for the individual elements. For efficient retrieval, each individual USAGE format must be of the same data type as its corresponding ACTUAL format, but their lengths can differ.



Example: Defining a Group Key

The following is an example of a group key definition in the Master File:

GROUP=G1, ALIAS=FILEKEY.KEY, ELEMENTS=3 ,$
  FIELD=F1,,A4,A4,$
  FIELD=F2,,P6,P3,$
  FIELD=F3,,I9,I4,$

The GROUP in the example describes an IMS key named FILEKEY that is 11 bytes long and consists of a 4-byte alphanumeric field, a 3-byte packed number, and a 4-byte integer.

The ACTUAL length of the GROUP is 11 (4+3+4).

The USAGE length of the GROUP is 16 (4+8+4) because it counts the packed field as 8.

Since the group components are of mixed data types, you must use individual fields in the WHERE expression of the server query.

WHERE F1 = ABCD
WHERE F1 BETWEEN A AND B
WHERE F2 = 245

If you reference either the group or the first elementary field from the group in your request, the adapter generates qualified SSAs in its DL/I calls for retrieval. Thus, IMS does the screening and returns the segments that pass the screening test back to the server.

However, if you reference an elementary field that is not the first field in the group, the server constructs DL/I calls to retrieve the segments sequentially, and then the server applies the screening test to the returned data.

Note: The adapter does not support a group field within a group field. You may be able to use DEFINE fields in the Master File instead.


Top of page

x
Segment Redefinition in IMS: The RECTYPE Attribute

How to:

An IMS segment can have multiple definitions. For instance, a segment may contain either shipment or order information, depending on the value of one of its fields. If the field that identifies the type of segment is at the same position and has the same format and length in each redefinition, you can use the RECTYPE attribute to define the different segment types in the Master File.

The record type (RECTYPE) field can be part of the key or of the body of the segment. When you issue a request, you do not have to know which segment definition is called for. The server retrieves the appropriate fields and values based on the value in the RECTYPE field.

In the Master File, you describe the one IMS segment with multiple server segments: a base segment describing the unchanging portion, and a child segment describing each redefinition:



Example: Illustrating an IMS DBD With a Redefined Segment

The following example illustrates an IMS DBD with a redefined segment. The CLIENT segment contains client ID, address, and other client information. The INFO segment contains either shipment information or order information, depending on the value in the INFOTYPE field. If INFOTYPE contains the value S, the segment is a shipment segment. If INFOTYPE contains the value O, the segment is an order segment.

The relevant portions of the DBD are:

SEGM NAME=CLIENT,BYTES=(200),PTR=(TWIN),PARENT=0
  FIELD=(CLID,SEQ,U),BYTES=8,START=1,TYPE=C
   .
   .
   .
SEGM NAME=INFO,BYTES=(200),PTR=(TWIN),PARENT=CLIENT
  FIELD=(IKEY,SEQ,U),BYTES=8,START=1,TYPE=C
  FIELD=(INFOTYPE),BYTES=1,START=09,TYPE=C
   .
   .
   .

The corresponding Master File represents the IMS INFO segment with three segments:

    FILE=IMS1,SUFFIX=IMS
     SEGNAME=CLIENT,SEGTYPE=S0
       FIELD=F1,CLID.KEY,A8,A8,$ 
1.   SEGNAME=INFO   ,SEGTYPE=S0,PARENT=CLIENT,$
       FIELD=F3,IKEY.KEY,A8,A8,$
       FIELD=,,          A20,A20,$ 
2.   SEGNAME=SHIP,SEGTYPE=,PARENT=INFO,$
       FIELD=,,          A8,A8,$
       FIELD=RECTYPE,S,  A1,A1,$
       FIELD=SHIPDATE,,  A6,A6,$
        .
        .
        .
       other shipment info 
3.   SEGNAME=ORDER,SEGTYPE=,PARENT=INFO,$
       FIELD=,,         A8,A8,$
       FIELD=RECTYPE,O, A1,A1,$
       FIELD=ORDERDATE,,A6,A6,$
        .
        .
        .
       other order info.

Note:

  1. The base segment is named INFO, like the IMS segment. It contains the key field. The redefined portion is described as a filler field.
  2. The SHIP segment describes the shipment record type. The field that corresponds to the IMS INFOTYPE field has FIELDNAME=RECTYPE and ALIAS=S.
  3. The ORDER segment describes the order record type. The field that corresponds to the IMS INFOTYPE field has FIELDNAME=RECTYPE and ALIAS=O.

Notice that each child segment has a filler for the key field defined in the base segment.



x
Syntax: How to Establish Multiple RECTYPE Values in IMS

If multiple values identify the same record type (for example, S or T for a shipment record), use the ACCEPT attribute to enumerate the list or range of acceptable values. In this case, define the ALIAS value as blank.

FIELDNAME=RECTYPE, ALIAS=, USAGE=usage, ACTUAL=actual,
   ACCEPT=val1 [OR] val2 [[OR] ...valn],$

or

FIELDNAME=RECTYPE, ALIAS=, USAGE=usage, ACTUAL=actual,
   ACCEPT=val1 to val2

where:

val1,val2,valn

Defines a list or range of values that identifies the record type. A list can be continued on more than one line. Enclose values that contain embedded blanks or special characters within single quotation marks.

The following examples illustrate the ACCEPT attribute:

ACCEPT=AAA TO RRR
ACCEPT=136 TO 1029
ACCEPT=RED OR WHITE OR BLUE
ACCEPT=RED WHITE BLUE
ACCEPT=6 OR 11 OR 922 OR 1000
ACCEPT=RED WHITE 'GREEN GREY'

Top of page

x
Repeating Data in IMS Fields: The OCCURS Segment

How to:

In an IMS data source, segments can have repeating fields or repeating groups of fields. The number of repetitions:

In the Master File, you define multiple segments to describe one IMS variable length segment:

The OCCURS segment is a virtual segment (it does not physically exist) that describes the repetitions to the server. Permissible values for the OCCURS attribute are as follows:

OCCURS=

Description

n

The number of times the field repeats in the segment.

fieldname

The name of a field that contains a value indicating the number of times the field repeats in the segment. The repeating field must be at the end of the segment.

VARIABLE

Indicates that the number of repetitions must be computed from the length of the segment. In this case, the segment must contain a counter field as its first field; the counter field alias in the Master File must be IMSname.CNT. The repeating field must be at the end of the segment.

With a fixed number of occurrences, it is possible for the repeating field to be located between other fields in the segment rather than at the end of the segment. In this case, you must define a place-holder field at its position in the base segment. Then, in the OCCURS segment, identify the location of the repeating field by specifying the name of the place-holder field as the POSITION attribute.



x
Syntax: How to Describe Repetitions to the Server With an OCCURS Segment
SEGNAME=occseg, PARENT=imsseg, OCCURS=nfield                  ,$
SEGNAME=occseg, PARENT=imsseg, OCCURS=n [,POSITION=posfield]  ,$
SEGNAME=occseg, PARENT=imsseg, OCCURS=VARIABLE                ,$

where:

occseg

Is the name of the OCCURS segment. It can be any valid segment name.

imsseg

Is the name of the base segment. It must be the IMS segment name.

nfield

Is the name of a field in the parent or non-repeating portion of the segment whose value is the number of times that the group repeats. You must define this field in the Master File whether or not it is a search field defined in the DBD.

n

Is the fixed number of times that the group repeats in the segment. It is an integer value from 1 to 4095.

posfield

Signals that the repeating field is embedded within the base segment rather than occurring at the end, and names a field in the base segment that marks the starting position of the repeating field.

VARIABLE

Indicates that the length of the repeating segment varies and that the number of occurrences can be computed from each segment. In this case, the (base) segment must contain a counter field as its first field; the counter field's alias value must be

IMSname.CNT

where:

IMSname

Is the name of the field in the IMS DBD.

In the IMS DBD, a variable length segment differs from a fixed length segment only in the BYTES parameter. For variable length segments, the BYTES parameter consists of two values: the maximum and minimum number of bytes. IMS cannot search for values among the repetitions within a segment. Therefore, in any request that references a field in a repeating group, the server searches and screens the OCCURS segments, not IMS.



x
Syntax: How to Describe the ORDER Field in IMS

Sometimes the sequence of fields within an OCCURS segment is significant. For example, each instance of the repeating field may represent one quarter of the year, but the segment may not have a field that specifies the quarter to which it applies.

ORDER is an optional counter used to identify the sequence number within a group of repeating fields. Specify it when the order of data is important. The ORDER field does not represent an existing field in the data source; it is used only for internal processing.

The ORDER field must be the last field described in the OCCURS segment.

FIELDNAME=name, ALIAS=ORDER, USAGE=In, ACTUAL=I4 ,$

where:

name

Is any valid field name.

In

Is an integer format.

Note:

The ORDER field must be the last field defined in the OCCURS segment.

In requests, you can use the value of the ORDER field. You can also specify a DEFINE statement in the Master File to translate it to more meaningful values. For example:

DEFINE QTR/A3 = DECODE ORDER(1 '1ST' 2 '2ND' 3 '3RD' 4 '4TH');

A subsequent request could include

SELECT TOT.TAXES WHERE QTR=1

or:

SELECT QTR,BALANCE,INTEREST


Example: Issuing OCCURS=n

In the following example, the IMS segment, IMS1, includes a group (consisting of the two fields MONTH and AMOUNT) that repeats 12 times. The COBOL FD for the segment is:

01  IMS1
    05  ACCOUNT  PIC X(9)
    05  TYPE     PIC XXX
    05  PAYMENT OCCURS 12 TIMES
        10 MONTH PIC 99
        10 AMT   PIC S9(3)V(99)COMP-3

The Master File uses two segments to describe this IMS variable length segment:

1. SEGNAME=IMS1,PARENT=,SEGTYPE=S0
     FIELD=ACT_NUM,ALIAS=ACCOUNT.KEY,A9,A9,$
     FIELD=TYPE,ALIAS=,A3,A3,$ 
2. SEGNAME=OCC1,PARENT=IMS1,OCCURS=12
     FIELD=MM, ALIAS=,A2,A2,$
     FIELD=AMT,ALIAS=,P6.3,P3,$
  1. Segment IMS1 is the base segment. It has the same name as the IMS segment and describes the two non-repeating fields: ACT_NUM and TYPE.
  2. The OCCURS segment, OCC1, identifies IMS1 as its parent. It has no SEGTYPE, and it includes the OCCURS attribute. The two repeating fields are described in this segment.

In the following example, the repeating group is not at the end of the segment. It is embedded in the segment before the LNAME field. The COBOL FD for this situation is:

01  IMS1
    05  ACCOUNT PIC X(9)
    05  TYPE    PIC XXX
    05  PAYMENT OCCURS 12 TIMES
        10 MONTH PIC 99
        10 AMT   PIC S9(3)V(99)COMP-3
    05  LNAME    PIC X(20)

The Master File must include LNAME in the base segment. It must also describe where the repeating fields fit into the base segment by defining a place-holder field before LNAME, equal to the length of the 12 occurrences, and by pointing to the place-holder field with the POSITION attribute:

    SEGNAME=IMS1,PARENT=,SEGTYPE=S0 
     FIELD=ACT_NUM,ALIAS=ACCOUNT.KEY,A9,A9,$
     FIELD=TYPE,ALIAS=,A3,A3,$ 
1.   FIELD=HOLDIT,ALIAS=,A60,A60,$
     FIELD=LNAME,ALIAS=,A20,A20,$ 
2.  SEGNAME=OCC1,PARENT=IMS1,OCCURS=12,POSITION=HOLDIT
     FIELD=MM,ALIAS=,A2,A2,$
     FIELD=AMT,ALIAS=,P6.3,P3,$
  1. The HOLDIT field is the place holder for the repeating group in the base segment (IMS1). Since the repeating group consists of 12 occurrences, each of which is 5 bytes long (A2 and P3, described in segment OCC1), the HOLDIT field is defined as A60.
  2. The attribute POSITION=HOLDIT in the OCCURS segment declaration describes where the repeating group is located in the actual (base) segment.


Example: Issuing OCCURS=fieldname

In the next example, the number of occurrences is specified by the value in the TIMES field. The following COBOL FD describes this situation:

01  IMS1
    05  ACCOUNT PIC X(9)
    05  TYPE    PIC XXX
    05  TIMES   PIC S999  COMP-3 
    05  PAYMENT OCCURS DEPENDING ON TIMES
        10 MONTH PIC 99
        10 AMT   PIC S9(3)V(99)COMP-3

The Master File attribute, OCCURS=TIMES, identifies the TIMES field as containing the number of repetitions. The Master File also defines the optional ORDER field as the last field in the OCCURS segment:

    SEGNAME=IMS1,SEGTYPE=S0
     FIELD=ACT_NUM,ALIAS=ACCOUNT.KEY,A9,A9,$
     FIELD=TYPE,ALIAS=,A3,A3,$
     FIELD=TIMES,ALIAS=,P4,P2,$ 
1.  SEGNAME=OCC1,PARENT=IMS1,OCCURS=TIMES
     FIELD=MM,ALIAS=,A2,A2,$
     FIELD=AMT,ALIAS=,P6.3,P3,$ 
2.   FIELD=WHICH,ALIAS=ORDER,I4,I4,$
  1. The attribute OCCURS=TIMES identifies the value in the TIMES field as the number of instances of the repeating group.
  2. The field named WHICH is the optional ORDER field (ALIAS=ORDER). It is an internal counter defined as the last field in the OCCURS segment. It associates a sequence number with each occurrence of the repeating group. With the ORDER field defined, a request can include a test that selects a specific occurrence. For example:
    WHERE WHICH = 3


Example: Issuing OCCURS=VARIABLE

This example describes a segment in which the number of occurrences must be calculated from the length of the segment. The first field in the segment must be a 2-byte counter field that contains the true length of the segment and is defined to IMS in the DBD. The COBOL FD for this variable length segment is:

01  IMS1
    05  COUNTER PIC 99 COMP
    05  ACCOUNT PIC X(9)
    05  TYPE    PIC XXX
    05  PAYMSCHED OCCURS 1 TO 12 TIMES
        10 MONTH PIC 99
        10 AMT   PIC 59(3)V(99)COMP-3

The Master File must specify OCCURS=VARIABLE and must describe the counter field with the attribute

ALIAS=IMSname.CNT
    SEGNAME=IMS1,SEGTYPE=S0 
1.   FIELD=COUNTFLD,ALIAS=COUNTER.CNT,I2,I2,$
     FIELD=ACT_NUM,ALIAS=ACCOUNT.KEY,A9,A9,$
     FIELD=TYPE,ALIAS=,A3,A3,$ 
2.  SEGNAME=OCC1,PARENT=IMS1,OCCURS=VARIABLE
     FIELD=MM,ALIAS=,A2,A2,$
     FIELD=AMT,ALIAS=,P6.3,P3,$
  1. The 2-byte counter field must be the first field in the base segment. Its alias is formed by appending the suffix CNT to the field name defined in the IMS DBD:
    ALIAS=COUNTER.CNT
  2. In the OCCURS segment definition, the attribute OCCURS=VARIABLE indicates that the first field defined in the Master File contains the segment length and that the number of repetitions must be calculated from this length.


x
Syntax: How to Redefine Fields in IMS Databases

Support is provided for redefining record fields in IMS databases. This allows a field to be described with an alternate layout.

Within the Master File, the redefined field(s) must be described in a separate unique segment (SEGTYPE=U) using the POSITION=fieldname and OCCURS=1 attributes.

SEGNAME=segname,SEGTYPE=U,PARENT=parent,
OCCURS=1,POSITION=position ,$

where:

segname

Is the segment name.

parent

Is the name of the parent segment.

position

Is the field name of the field being redefined.

A one-to-one relationship is established between the parent record and the redefined segment. The following example illustrates redefinition of the IMS structure described in the COBOL file description:

01 ALLFIELDS.
  02 FLD1   PIC X(4).
  02 FLD2   PIC X(4).
  02 RFLD2  PIC 9(5)V99 COMP-3 REDEFINES FLD2.
  02 FLD3   PIC X(8).
FILENAME=REDEF, SUFFIX=IMS,$
  SEGNAME=ONE, SEGTYPE=S0,$
    GROUP=RKEY, ALIAS=KEY  ,USAGE=A4   ,ACTUAL=A4     ,$
      FIELDNAME=FLD1,      ,USAGE=A4   ,ACTUAL=A4     ,$
      FIELDNAME=FLD2,      ,USAGE=A4   ,ACTUAL=A4     ,$
      FIELDNAME=FLD3,      ,USAGE=A8   ,ACTUAL=A8     ,$
    SEGNAME=TWO, SEGTYPE=U, POSITION=FLD2, OCCURS=1, PARENT=ONE ,$
      FIELDNAME=RFLD2,     ,USAGE=P8.2 ,ACTUAL=Z4     ,$

The redefined fields may have any user defined name. ALIAS names for redefined fields are not required.

Use of the unique segment with redefined fields helps avoid problems with multipath reporting.

Note:


iWay Software