This chapter describes a function to define VSAM data sets so that data can be converted and managed for each copybook field.
The following is the workflow of defining VSAM data set by using IDCAMS in TSAM RDB.
Parse a copybook file with the same name as the data set to generate mapped source code.
Link the created source code with the template file (TSAM_@.template).
Compile the complete source file by using the shell script (tsam_compile.sh) to create DSNAME.so.
Call tsrdb_create API defined in DSNAME.so to create a data set table.
The following describes the main features of TSAM RDB.
TSAM RDB divides a record into fields, converts data for each field, and then save the converted data to a table.
The following is the difference between the existing TSAM and TSAM RDB.
Existing TSAM
KEY DAT -------------------- ------------------------------------------------------- 30303031303030303030 3030303130303030303030303034303030303030 ... 30303032303030303030 3030303230303030303030303033303030303030 ... 30303033303030303030 3030303330303030303030303032303030303030 ... 30303034303030303030 3030303430303030303030303031303030303030 ...
TSAM RDB
FLD_KEY FLD_AKEY FLD_DAT ---------- ---------- ------------------------------------------------------- 0001000000 0004000000 ... 0002000000 0003000000 ... 0003000000 0002000000 ... 0004000000 0001000000 ...
Since the existing TSAM saves BLOB data, there is no conversion issue during migration. However, since TSAM RDB verifies data while converting each field data, an issue can occur during migration.
To create AIX, TSAM RDB creates INDEX for the CLUSTER table and does not create a separate table unlike existing TSAM.
The following shows the result of creating AIX in TSAM RDB.
$ idcams define AIX -n SAMPLE.KSDS.AIX -r SAMPLE.KSDS -k 10,10 -l 80,80
COLUMN_NAME TYPE CONSTARINT ------------------- ---------------------------- ------------------------ FLD_KEY NUMBER(10) PRIMARY KEY FLD_AKEY VARCHAR(10) FLD_DAT VARCHAR(60) INDEX_NAME TYPE COLUMN_NAME ---------------------- ------------------------- ------------------------ SAMPLE_KSDS_AIX_INDEX NORMAL FLD_AKEY SAMPLE_KSDS_KEY NORMAL FLD_KEY
The OCCURS field can be created with a single row or multiple rows, depending on the option of IDCAMS.
The following creates the OCCURS field with a simple column.
<SAMPLE.KSDS.cpy>
01 REC. 03 FLD-KEY PIC 9(10). 03 FLD-OCC PIC X(10) OCCURS 5 TIMES. 03 FLD-DAT PIC X(20). : :
$ idcams define CL -n SAMPLE.KSDS -o KS -k 10,0 -l 80,80 -O
COLUMN_NAME TYPE CONSTARINT ------------------- ---------------------------- ------------------------ FLD_KEY NUMBER(10) PRIMARY KEY FLD_OCC VARCHAR(50) FLD_DAT VARCHAR(20) INDEX_NAME TYPE COLUMN_NAME ------------------- ---------------------------- ------------------------ SAMPLE_KSDS_KEY NORMAL FLD_KEY
The following creates the OCCURS field with a detailed column.
<SAMPLE.KSDS.cpy>
01 REC. 03 FLD-KEY PIC 9(10). 03 FLD-OCC PIC X(10) OCCURS 5 TIMES. 03 FLD-DAT PIC X(20). : :
$ idcams define CL -n SAMPLE.KSDS -o KS -k 10,0 -l 80,80
COLUMN_NAME TYPE CONSTARINT ----------------------- ----------------------- ------------------------- FLD_KEY NUMBER(10) PRIMARY KEY FLD_OCC1 VARCHAR(10) FLD_OCC2 VARCHAR(10) FLD_OCC3 VARCHAR(10) FLD_OCC4 VARCHAR(10) FLD_OCC5 VARCHAR(10) FLD_DAT VARCHAR(20) INDEX_NAME TYPE COLUMN_NAME ----------------------- ----------------------- ------------------------- SAMPLE_KSDS_KEY NORMAL FLD_KEY
Basically, columns are created according to the fields defined in the copybook, but VSAM data sets can also be created in the form of a simple column (BULK) to process VB-type records. However, to have a simple column, a copybook that consists of only general fields and fields that redefine these fields must be created.
The following creates a copybook file used to define a VSAM KSDS data set with a simple column (BULK) and defines a data set using the copybook.
<BULK.KSDS.cpy>
01 REC. 03 FLD-DAT PIC 9(80). 03 FLD-BULK PIC X(80) REDEFINES FLD-DAT. : :
$ idcams define CL -n BULK.KSDS -o KS -k 10,0 -l 80,80
COLUMN_NAME TYPE CONSTARINT ----------------------- ------------------------ ------------------------ FLD_DAT VARCHAR(80) BULK_KSDS_COL VARCHAR(10) INDEX_NAME TYPE COLUMN_NAME ----------------------- ------------------------ ------------------------ BULK_KSDS_KEY FUNCTION-BASED NORMAL - EXPRESSION COLUMN -
Character columns are created for redefinition fields regardless of the field type.
Like the existing ESQL TSAM, ISAM is created as VSAM KSDS, not as RDB, and requires a copybook corresponding to the RDB type. However, the name of the copybook file must start with the name of the logic volume, unlike when creating VSAM KSDS.
The following shows a copybook file used to define an ISAM data set in TSAM RDB, and then uses the copybook file to define an ISAM data set by running the dscreate command.
<DEFVOL_SAMPLE.ISAM.cpy>
01 REC. 03 FLD-KEY PIC X(10). 03 FLD-DAT PIC X(70). : :
$ dscreate SAMPLE.ISAM -o IS -k 10 -p 0 -l 80 -v DEFVOL
COLUMN_NAME TYPE CONSTARINT ----------------------------- -------------------- ---------------------- FLD_KEY VARCHAR(10) PRIMARY KEY FLD_DAT VARCHAR(70) INDEX_NAME TYPE COLUMN_NAME ----------------------------- -------------------- ---------------------- DEFVOL_SAMPLE_ISAM_KEY NORMAL FLD_KEY
The following are the steps of defining a VSAM data set.
Create a copybook file with the same name as the data set in the copybook directory. (Example: SAMPLE.KSDS.cpy)
<SAMPLE.KSDS.cpy>
01 REC. 03 FLD-KEY PIC 9(10). 03 FLD-AKEY PIC X(10). 03 FLD-DAT PIC X(60). : :
Define a VSAM data set by using the IDCAMS tool or utility.
$ idcams define CL -n SAMPLE.KSDS -o KS -k 10,0 -l 80,80
Confirm that the data set table and shared object file (Example: SAMPLE.VSAM.so) are created.
COLUMN_NAME TYPE CONSTARINT ------------------------ ----------------------- ------------------------ FLD_KEY NUMBER(10) PRIMARY KEY FLD_AKEY VARCHAR(10) FLD_DAT VARCHAR(60) INDEX_NAME TYPE COLUMN_NAME ------------------------ ----------------------- ------------------------ SAMPLE_KSDS_KEY NORMAL FLD_KEY
The steps of defining AIX are the same as those of defining a data set.
The following defines AIX of a VSAM KSDS data set.
<SAMPLE.KSDS.cpy>
01 REC. 03 FLD-KEY PIC 9(10). 03 FLD-AKEY PIC X(10). 03 FLD-DAT PIC X(60). : :
$ idcams define AIX -n SAMPLE.KSDS.AIX -r SAMPLE.KSDS -k 10,10 -l 80,80
COLUMN_NAME TYPE CONSTARINT ------------------------ ----------------------- ------------------------ FLD_KEY NUMBER(10) PRIMARY KEY FLD_AKEY VARCHAR(10) FLD_DAT VARCHAR(60) INDEX_NAME TYPE COLUMN_NAME ------------------------ ----------------------- ------------------------ SAMPLE_KSDS_AIX_INDEX NORMAL FLD_AKEY SAMPLE_KSDS_KEY NORMAL FLD_KEY