Each Master File that provides access to an IMS database describes the segments and fields that are available through one IMS PCB.
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 (see IMS Overview and Mapping Concepts). Any segment or field that you do not describe in the Master File remains invisible to FOCUS.
Reporting costs are largely a function of the volume of data transferred. Therefore, requests issued through the Interface 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. Field Attributes, contains additional information about this limit).
For MVS, each Master File is stored as a member of a Master File PDS. The member name for a Master File must be the name assigned to that Master File in the FOCPSB record for the corresponding PCB (see The PCB Record in Required FOCPSB Attributes). At run time, the Master File dataset is allocated to ddname MASTER.
For CMS, each Master File is stored as a file with filetype MASTER. The filename must be the name assigned in the corresponding FOCPSB record.
A Master File consists of file, segment, and field declarations. Rules for declarations are as follows:
The following sections summarize the syntax for each type of declaration and then describe each attribute.
Each Master File begins with a file declaration that names the file and describes the type of data source-an IMS database in this case. The file declaration has two attributes, FILENAME and SUFFIX. The syntax is
FILE[NAME]=filename, SUFFIX=IMS [,$]
where:
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's characteristics.
The syntax is
SEGNAME=segname ,SEGTYPE= segtype [, PARENT=parent] [,$]
where:
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.
FOCUS 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. However, FOCUS retrieves unique segments (only one instance per parent-no twins) prior to any non-unique segments that have the same parent.
The SEGTYPE attribute does the following:
If a segment has a unique key, at least one FIELD record in the DBD must specify NAME=(fieldname,SEQ,U) or NAME=(fieldname,SEQ); similarly, if the segment has a non-unique key, at least one FIELD record in the DBD must specify NAME=(fieldname,SEQ,M). If no FIELD record in the DBD specifies a SEQ attribute, the segment has no key. The key referred to by the SEGTYPE attribute may actually be a secondary index (see Using a Secondary Index).
The characteristics of the segment's key determine the types of SSAs and the number of DL/I calls the Interface must issue to satisfy a retrieval request. To handle keys made up of multiple fields, describe the multiple fields as a group in the Master File (see Group Fields). If you do not specify a key field (.KEY) for a keyed SEGTYPE (for example, S1), a FOC4277 message will result.
The following table lists the valid SEGTYPE values:
SEGTYPE |
Definition |
PROCOPT=K |
NAME=From DBD |
U |
Data sensitive, unique segment |
No |
Not Applicable |
S0 |
Data sensitive, no key |
No |
(name) |
S or S1 |
Data sensitive, non-unique key |
No |
(name,SEQ,M) |
S2 |
Data sensitive, unique key |
No |
(name,SEQ,U) or (name,SEQ) |
SH or SH1 |
Key sensitive, non-unique key |
Yes |
(name,SEQ,M) |
SH2 |
Key sensitive, unique key |
No |
Not Applicable |
The PARENT attribute identifies the segment's parent 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.
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 the COBOL FD description.
The Master File must describe the entire IMS segment. If it does not need access to some of the fields from a segment, it can replace their definitions with filler fields that occupy the same amount of space.
To describe a field in the Master File, you must supply the primary attributes FIELDNAME, ALIAS, USAGE, and ACTUAL, discussed in this section.
The FOCUS for IBM Mainframe Users Manual explains additional attributes, such as TITLE and DESCRIPTION, as well as how to define temporary fields in the Master File.
Note: The Interface does not support the MISSING attribute.
The syntax for a field declaration is
FIELD[NAME]=fieldname,[ALIAS=alias],[USAGE=]display,[ACTUAL=]imsformat,$
where:
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=YR, USAGE=A2, ACTUAL=A2,$
FIELD = YEAR, YR, A2, A2,$
Fieldnames can have up to 66 alphanumeric characters. IMS field names are acceptable values if they meet the following naming conventions:
Since fieldnames appear as default column titles for reports, select names that are representative of the data.
You can use fieldnames, aliases, or a unique truncation of either in requests. For example, consider the following Master File:
FILENAME=MFD1
SEGNAME=SEG1
FIELDNAME=S1, ALIAS=K1.KEY, USAGE=A4, ACTUAL=A4,$
The following statements are all equivalent in a FOCUS request:
PRINT S1
PRINT S
PRINT K1.KEY
PRINT K1
PRINT K
Duplicate fieldnames (the same fieldnames and aliases) within a segment are not permitted. Report requests can qualify duplicate fieldnames from different segments with the name of the Master File and/or segment. That is, using the Master File from the previous example, the following are equivalent:
PRINT SEG1.S1
PRINT MFD1.S1
PRINT MFD1.SEG1.S1
You need this type of qualification if two segments in the Master File or in a join have a field defined with the same fieldname and alias. For more information about field qualifiers, see the FOCUS for IBM Mainframe Users Manual.
Note:
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 Interface uses this information in constructing DL/I calls to IMS.
If a field used in a screening test (IF or WHERE) is a sequence or search field, the Interface may be able to create an SSA that instructs IMS to apply the screening test and return the appropriate records to FOCUS; if the field is not defined in the DBD, the Interface must retrieve all records sequentially from IMS so that FOCUS can screen them.
In certain cases, the Interface can instruct IMS to screen values based on a secondary index. Section Using a Secondary Index, Using a Secondary Index, describes the technique for taking advantage of a secondary index.
The ALIAS value for a field defined in the DBD is composed of the following:
You can assign fields not defined in the DBD any name that complies with FOCUS field naming conventions. Do not include periods or suffix values for such alias names.
In requests, you can reference a field by its fieldname, its alias, or by a unique truncation of either. Note that the IMS fieldname is a unique truncation of the alias value. For example, if the IMS key field is named IMSNAME, then the alias for that field in the Master File is IMSNAME.KEY. A FOCUS request can reference the field by the name IMSNAME (without the .KEY) because this name is a unique truncation of the alias.
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. FOCUS uses the USAGE format for data display on reports. All standard FOCUS USAGE formats (A, D, F, I, P) are available. For additional information about USAGE formats for external files, see the FOCUS for IBM Mainframe Users Manual.
The ACTUAL attribute indicates the FOCUS 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 |
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. For more information, see the FOCUS for IBM Mainframe Users Manual.
The cumulative length of all fields, across all segments, cannot exceed 12K bytes. To determine whether the database you are defining falls within these constraints, issue the following report request:
CHECK FILE filename HOLD
TABLE FILE HOLD
WRITE MAX.LWORD
END
The resulting value must be less than or equal to 3,000.
The following example illustrates the DI21PART Master File that provides access to the DI21PART database.
FILE=DI21PART ,SUFFIX=IMS,$
SEGNAME=PARTROOT ,PARENT=,SEGTYPE=S2,$
FIELD=PARTKEY ,ALIAS=PARTKEY.HKY ,USAGE=A17 ,ACTUAL=A17 ,$
FIELD=SKIP1 ,ALIAS=SKIP1 ,USAGE=A33 ,ACTUAL=A33 ,$
SEGNAME=STANINFO ,PARENT=PARTROOT,SEGTYPE=S2,$
FIELD=STANKEY ,ALIAS=STANKEY.KEY ,USAGE=A2 ,ACTUAL=A2 ,$
FIELD=SKIP2 ,ALIAS=SKIP2 ,USAGE=A83 ,ACTUAL=A83 ,$
SEGNAME=STOKSTAT ,PARENT=PARTROOT,SEGTYPE=S2,$
FIELD=STOCKEY ,ALIAS=STOCKEY.KEY ,USAGE=A16 ,ACTUAL=A16 ,$
FIELD=SKIP3 ,ALIAS=,SKIP3 ,USAGE=A124 ,ACTUAL=A124 ,$
SEGNAME=CYCCOUNT ,PARENT=STOKSTAT,SEGTYPE=S2,$
FIELD=CYCCKEY ,ALIAS=CYCCKEY.KEY ,USAGE=A2 ,ACTUAL=A2 ,$
FIELD=SKIP4 ,ALIAS=SKIP4 ,USAGE=A23 ,ACTUAL=A23 ,$
SEGNAME=BACKORDR ,PARENT=STOKSTAT,SEGTYPE=S2,$
FIELD=BACKEY ,ALIAS=BACKEY.KEY ,USAGE=A10 ,ACTUAL=A10 ,$
FIELD=SKIP5 ,ALIAS=SKIP5 ,USAGE=A65 ,ACTUAL=A65 ,$
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 element's USAGE format is the same type as its ACTUAL format (for example, alphanumeric or packed); the lengths may differ.
The syntax for a GROUP record and its subordinate FIELD records is
GROUP=gname, ALIAS=alias, USAGE=An, ACTUAL=Am,$
FIELD=fld1,al1,use1,act1,$
.
.
.
FIELD=fldn,aln,usen,actn,$
where:
|
|
|
|
|
|
|
|
|
|
The following is an example of a group key definition in the Master File:
GROUP=G1, ALIAS=FILEKEY.KEY, USAGE=A16, ACTUAL=A11 ,$
FIELD=F1,F1,A4,A4,$
FIELD=F2,F2,P6,P3,$
FIELD=F3,F3,I9,I4,$
Note:
You can use the group field or any individual field in a FOCUS query. For example:
WHERE G1 EQ 'ABCD'/245/-20 or
IF G1 GT ABCD/245/-20
IF G1 FROM ABCD/245/-20 TO ABCD/300/50
IF G1 IS ABCD/245F/-20 (field F2 has a non-standard sign, F)
IF G1 IS A$*
IF F1 IS ABCD
IF F1 FROM A TO B
IF F2 IS 245
You must use a slash (/) to separate the individual fields when you reference the group name.
If you reference either the group or the first elementary field from the group in your request, the Interface 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 FOCUS.
However, if you reference an elementary field that is not the first field in the group, FOCUS constructs DL/I calls to retrieve the segments sequentially, and then FOCUS applies the screening test to the returned data.
Chapter 4, Reporting Efficiencies, contains a detailed explanation of screening conditions and SSA generation.
Note: The Interface does not support a group field within a group field. See the FOCUS for IBM Mainframe Users Manual for information on DEFINE fields in the Master File.
Using IMS secondary indexes, you can retrieve records in order of a field other than the key field. (A secondary index is itself a database with its own DBD.) The DBD for a database that uses a secondary index includes an XDFLD statement that assigns a field name to the index.
If a PCB includes the parameter PROCSEQ=indexDBDname, the named index is used as the main entry point into the database.
In prior FOCUS Releases, each Master File could describe only one index and the application programmer had to decide which Master File provided the optimal access path for a request. This technique is still supported, and Release Dependent Interface Features, describes it.
Starting with FOCUS Release 7.0, one Master File and FOCPSB can describe all primary and secondary indexes for a database. Then, given a report request, the Interface can examine all record selection tests to determine the best access path into the database. The Interface can take advantage of this Auto Index Selection feature for the following reasons:
In the Master File, prior to the secondary index definitions, you must describe the entire root segment of the database. Every field listed in the DBD is an IMS sequence field or search field, and each secondary index is based on one or more of these fields. You must assign each secondary index field its appropriate alias, as described in ALIAS in Field Attributes.
Note: IMS allows for system-defined sub-sequence fields to make an index unique. The Master File can completely ignore the presence and length of such fields.
For each secondary index, in the Master File you must perform the following steps:
GROUP=anyname,ALIAS=XDFLDname.SKY
where:
For example, consider the following portion of the DBD for the PATDB01 database:
.
.
.
FIELD NAME=LNAME,BYTES=12,START=56,TYPE=C
FIELD NAME=FNAME,BYTES=12,START=68,TYPE=C
.
.
.
LCHILD NAME=(SEGIX1,PATDBIX1),PTR=INDX
XDFLD NAME=IXNAME,SRCH=(LNAME,FNAME), X
SUBSEQ=/SX1,NULLVAL=BLANK
In the example, the fields that comprise the secondary index are LNAME, FNAME, and an additional sub-sequence system field that makes the index unique and that the Master File can ignore. The GROUP definition for the index in the Master File follows:
GROUP=NAMEIX ,ALIAS=IXNAME.SKY ,USAGE=A24 ,ACTUAL=A24,$
The ALIAS is the index name from the DBD (XDFLD NAME=IXNAME) with the suffix SKY appended. Note that the index definition completely ignores the sub-sequence field.
Assign each subordinate field a new fieldname not previously used in the Master File. Give each subordinate field an alias value identical to the fieldname you assigned it when you previously described it as a sequence or search field. The syntax is
FIELDNAME=fieldname, ALIAS=alias
.
.
.
GROUP=...
FIELD[NAME] = newname, ALIAS = fieldname
where:
The following portion of the PATINFO Master File illustrates the secondary index definition for the example in Step 1:
.
.
.
FIELD=LAST_NAME ,ALIAS=LNAME.IMS ,USAGE=A12 ,ACTUAL=A12,$
FIELD=FIRST_NAME ,ALIAS=FNAME.IMS ,USAGE=A12 ,ACTUAL=A12,$
.
.
.
GROUP=NAMEIX ,ALIAS=IXNAME.SKY ,USAGE=A24, ,ACTUAL=A24,$
FIELD=NAMEL ,ALIAS=LAST_NAME ,USAGE=A12 ,ACTUAL=A12,$
FIELD=NAMEF ,ALIAS=FIRST_NAME ,USAGE=A12 ,ACTUAL=A12,$
The FOCPSB must also reflect the secondary indexes. The IMS PSB includes a PCB for the normal entry point into the database and an additional PCB for entry through each secondary index. Each PCB for a secondary index includes the parameter PROCSEQ=indexDBDname, where indexDBDname comes from the LCHILD NAME parameter in the database DBD.
The FOCPSB must have a one-to-one correspondence with the PSB.
PCB:
PCB TYPE=DB,DBDNAME=PATDB01,PROCOPT=GO,KEYLEN=9
SENSEG NAME=PATINFO,PARENT=0
FOCPSB:
PCBNAME=PATINFO, PCBTYPE=DB,$
The next example illustrates a secondary index PCB and its corresponding FOCPSB entry for the PATDB01 database.
PCB:
PCB TYPE=DB,DBDNAME=PATDB01,PROCOPT=GO,KEYLEN=9,PROCSEQ=PATDBIX1
SENSEG NAME=PATINFO,PARENT=0
FOCPSB:
PCBNAME=IXNAME,PCBTYPE=DB,$
When the Interface generates DL/I calls for retrieval, it examines the record selection tests in the request to determine which PCB offers the most efficient access path to the required data. See Chapter 4, Reporting Efficiencies, for information.
Note: Since the PSB most likely includes only one PCB for each secondary index, each Master File that accesses the same index PCB must contain the same GROUP ALIAS value for the index.
Release Dependent Interface Features, includes a sample DBD, PSB, FOCPSB, and Master File for the PATDB01 database and its three secondary indexes.
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. FOCUS displays 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 FOCUS segments: a base segment describing the unchanging portion, and a child segment describing each redefinition:
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 shown:
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=S2
FIELD=F1,CLID.KEY,A8 ,A8 ,$
FIELD=F2,CLNAME ,A20,A20,$
1. SEGNAME=INFO ,SEGTYPE=S2,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.
Notice that each child segment has a filler for the key field defined in the base segment.
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.
The syntax is
FIELDNAME=RECTYPE, ALIAS= , USAGE=usage, ACTUAL=actual,
ACCEPT = val1 [OR] val2 [ [OR] ...valn] ,$
ACCEPT = val1 to val2 ,$
where:
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'
Refer to the Logical Parent Segment feature in IMS Overview and Mapping Concepts, for more information on RECTYPES.
In an IMS database, segments can have repeating fields or repeating groups of fields. The number of repetitions may have the following attributes:
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 FOCUS. The following chart lists permissible values for the OCCURS attribute:
OCCURS= |
Description |
n |
Is the number of times the field repeats in the segment. |
fieldname |
Is 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. |
When the number of occurrences is fixed, the repeating field can be located between two fields rather than at the end of the segment. In this case, you must define a place-holder field at the repeating field's position in the base segment. Then, in the OCCURS segment, you must indicate the location of the repeating field by supplying the name of the place-holder field with the POSITION attribute.
The syntax for an OCCURS segment is
SEGNAME=occseg,PARENT=imsseg,OCCURS=occurs,$
where:
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 FOCUS retrieval request that references a field in a repeating group, FOCUS, and not IMS, searches and screens the OCCURS segments.
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 identifies to which quarter it applies.
ORDER is an optional counter used to identify the sequence number within a group of repeating fields. You should include it when the order of data is important. The ORDER field does not represent an existing field in the database; it is used only for internal processing.
The ORDER field must be the last field described in the OCCURS segment. The syntax is
FIELDNAME=fieldname, ALIAS=ORDER, USAGE=In, ACTUAL=I4 ,$
where:
Note:
In report requests, you can use the value of the ORDER field. You can also use a DEFINE field in your session or 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:
PRINT TOT.TAXES IF QTR IS 1ST
or
PRINT QTR BALANCE INTEREST
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 shown:
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=S2
FIELD=ACT_NUM ,ALIAS=ACCOUNT.KEY ,A9 ,A9,$
FIELD=TYPE ,ALIAS=TYPE ,A3 ,A3,$
2. SEGNAME=OCC1,PARENT=IMS1,OCCURS=12
FIELD=MM ,ALIAS=MONTH ,A2 ,A2,$
FIELD=AMT ,ALIAS=AMT ,P6.3,P3,$
In the following example, the repeating group is not at the end of the segment, but rather is embedded in the segment before the LNAME field. The COBOL FD for this situation is shown:
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=S2
FIELD=ACT_NUM ,ALIAS=ACCOUNT.KEY ,A9 ,A9 ,$
FIELD=TYPE ,ALIAS=TYPE ,A3 ,A3 ,$
1. FIELD=HOLDIT ,ALIAS= ,A60,A60,$
FIELD=LNAME ,ALIAS=LAST_NAME ,A20,A20,$
2. SEGNAME=OCC1,PARENT=IMS1,OCCURS=12, POSITION=HOLDIT
FIELD=MM ,ALIAS=MONTH ,A2 ,A2,$
FIELD=AMT ,ALIAS=AMT ,P6.3,P3,$
In the next example, the value of the TIMES field is the number of occurrences. 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=S2
FIELD=ACT_NUM ,ALIAS=ACCOUNT.KEY ,A9 ,A9,$
FIELD=TYPE ,ALIAS=TYPE ,A3 ,A3,$
FIELD=TIMES ,ALIAS=TIMES ,P4 ,P2,$
1. SEGNAME=OCC1,PARENT=IMS1, OCCURS=TIMES
FIELD=MM ,ALIAS=MONTH ,A2 ,A2,$
FIELD=AMT ,ALIAS=AMT ,P6.3 ,P3,$
2. FIELD=WHICH ,ALIAS=ORDER ,I4 ,I4,$
WHERE WHICH EQ 3
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 as follows:
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 S9(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=S2
1. FIELD=COUNTFLD ,ALIAS=COUNTER.CNT ,I2 ,I2,$
FIELD=ACT_NUM ,ALIAS=ACCOUNT.KEY ,A9 ,A9,$
FIELD=TYPE ,ALIAS=TYPE ,A3 ,A3,$
2. SEGNAME=OCC1,PARENT=IMS1, OCCURS=VARIABLE
FIELD=MM ,ALIAS=MONTH ,A2 ,A2,$
FIELD=AMT ,ALIAS=AMT ,P6.3 ,P3,$
Information Builders |