The first field that you map for a data set must always be the key field, regardless of where the key field is defined in the VSAM record. In cases where the key is made up of multiple copybook fields, the mapping must follow specific rules. For example, assume that you have a KSDS data set with a 12-byte key field that is broken down in the copybook into an 8-byte and a 4-byte field. The mapping for this file is shown in Figure 1:
--------------------- CICS VT: List of fields for MULTKEY ------- Row 1 of 4
Command ===> ________________________________________________ Scroll ===> CSR_
VSAM file type : KSDS Creator : VID +
Data set length: 00080 Table name: VID_MULTKEY +
Actions: S Display, U Update, I Insert, D Delete
A Field Bytes Start Type DB2 column name Exit Pic Par
- -------- ----- ----- ---- ------------------------------ -------- --- ---
_ GROUPKEY 00012 00001 C +
_ KEYFLD1 00008 00001 C KEY_COL_01 +
_ KEYFLD2 00004 00009 C KEY_COL_02 +
_ VIDF0001 00015 00013 C FIRST_DATA_COL +
The field called GROUPKEY represents the composite key field, starting in position 1 for a length of 12 bytes. Because this field does not map exactly to a single DB2® column, it is designated as unmapped. This means that it is simply a placeholder, and the DB2 column name for this field is blank.
You must select option U for the GROUPKEY field. The following screen is displayed:
----------------------------- CICS VT: Update field ----------------------------
Command ===> ________________________________________________ Scroll ===> CSR_
DIM name : MULTKEY
Creator : VID +
Table : VID_MULTKEY +
Data set length: 00080
Field name . . . . . . : GROUPKEY
Field length . . . ===> 00012 (In bytes)
Field type . . . . ===> C (C,P,U,F,H,B)
Column name . . . ===> .............................. + (Look-up available)
Starting position ===> 00001 ("1" = Beginning of data set)
Picture or FBE . . ===> __________________________ (example HH.XX.SS.NNNNNN)
(or MMDDYY)
(or EXITx=exit name)
Parameters . . . . ===> __________________________ Optional user parameters
Special function . ===> KEY ("KEY", "PTH", "BKY", or blank)
Mapped from table ===> X ("P"=Prim, "X"=Not mapped)
Build order . . . ===> 00001 ("1"=first, "2"=second and so on)
Press: Enter=Update PF3=Exit PF1=Help
Specify KEY in the Special function field and X in the Mapped from table field.
Immediately following the GROUPKEY field in Figure 1 are two copybook fields that are mapped to two DB2 columns KEY_COL_01 and KEY_COL_02. These are the primary key columns of the DB2 table. The first field is called KEYFLD1. The panel shows that it starts at position 1 and has a length of 8 bytes. The second part of the key is called KEYFLD2, which starts at position 9 and has a length of 4 bytes.
Figure 3 shows a file with a 12-byte group key field that starts at position 18 in the VSAM file. The field which is designated as Special Function KEY must always be the first mapped field.
--------------------- CICS VT: List of fields for MULTKE2 ------- Row 1 of 4
Command ===> ________________________________________________ Scroll ===> CSR_
VSAM file type : KSDS Creator : VID +
Data set length: 00080 Table name: VID_MULTKE2 +
Actions: S Display, U Update, I Insert, D Delete
A Field Bytes Start Type DB2 column name Exit Pic Par
- -------- ----- ----- ---- ------------------------------ -------- --- ---
_ OFFSETKY 00012 00018 C +
_ KEYOFF1 00008 00018 C OFFSET_KEY_COL_01 +
_ KEYOFF2 00004 00026 C OFFSET_KEY_COL_02 +
_ VIDF0001 00017 00001 C FIRST_DATA_COL +
The field called VIDF0001 defines the first 17 bytes of the VSAM record and follows the mapping of the key field although it starts at position 18.