As we discussed before, defining a VSAM cluster merely allocates a data set. It still has to be loaded with records. This can be done in one of two ways.
As mentioned before, REPRO is an lEBGENER-like utility to copy records from an input data set to an output data set. We will examine this option in detail. In order to use the REPRO command, we need to know the following:
Let us consider the layout of the input data set to be the same as we used before.
The name of the input data set, let us say, is CUSTOMER.TEST.INPUT. The process of loading a data set involves, opening the input file, reading the records one by one, and writing it onto the output file. All these functions are accomplished by the one command REPRO. We will use the input file CUSTOMER.TEST.INPUT to create a KSDS, ESDS and an RRDS by the following names:
Loading a KSDS
Storing data in a VSAM KSDS file, is known as Loading. Initially, to begin with the KSDS File is empty, it doesn’t contain any records. Based on, the Control Interval Size, that you’d have specified, while creating the KSDS File, the MVS Operating System books and reserves empty Control Intervals of that size in the KSDS Cluster. These are yet to be filled up,populated with data-records.
To actually load data-records into a VSAM KSDS file, you use IBM Supplied Utility IDCAMS. Instruct the IDCAMs utility, what’s the task you would like to perform by providing an appropriate control statement(as instream data). The IDCAMS utility picks up the Control Commands, and acts accordingly. So, the control command used to Load Data records in VSAM KSDS File is REPRO Command. In this tutorial, effectively, you are going to REPRO in the data records from a plain Sequential file into a KSDS Dataset.
The following JCL can be used to load records into a KSDS.
Note that the DD statements for the input and output data sets are not present in this JCL. Also, instead of the INFILE and OUTFILE parameters in the REPRO statement, we have used INDATASET and OUTDATASET. In this format, AMS performs a dynamic allocation of the data sets. The important thing to remember is that dynamic allocation can only be done for data sets that are cataloged. It is also possible to use mixed format within the same REPO statement. For example:
Loading an ESDS
When an ESDS is being loaded, the associated file must be opened for SEQUENTIAL OUTPUT. The records are retained in the order in which they are presented.
You can use the KEYTO option to obtain the relative byte address of each record as it is written. You can subsequently use these keys to achieve keyed access to the data set.
A sample JCL for loading into an ESDS is given below:
Loading an RRDS
Loading records into an RRDS is very similar to loading records into a KSDS or ESDS. Records will be loaded into the RRDS beginning with relative record number RRN 1. A sample JCL for loading into an RRDS is given below:
Options of the REPRO Command
The REPRO command copies the contents of one data set to another. The data sets can have either VSAM or sequential organization. Thus the REPRO command can:
This optional parameter is used to merge records into a VSAM file. It can only be used when the target records already have records and is either a KSDS or RRDS. In other words, it cannot be used if the target data set is an ESDS or LDS.REPRO INDATASET(CUSTOMER.TEST.INPUT) OUTDATASET(CUSTOMER.KSDS.CLUSTER) REPLACE
If the target data set is a non-empty KSDS, all records in the source file whose keys do not match the keys of the target data set are added to the target data set; those that match are replaced in the target data set' with the source record; and the records in the target data set that have no counterpart in the source data set are left alone.
If on the other hand, the target data set is a non-empty RRDS, the source data set must be an RRDS too. Records from a non-RRDS source data set cannot be merged with a RRDS target data set because only a
source RRDS will have relative record numbers, which will identify where the source records should be placed in the target data set. REUSE
If we use REUSE in a REPRO command, the records in the target KSDS, ESDS, RRDS or LDS are logically deleted and the records from the source are added as if the target data set were empty. In order to use the REUSE option for REPRO, the target data set should have been defined with the REUSE option. Otherwise, the REPRO command will terminate with an error message.
we use REUSE in a REPRO command, the records in the target KSDS, ESDS, RRDS or LDS are logically deleted and the records from the source are added as if the target data set were empty. In order to use the REUSE option for REPRO, the target data set should have been defined with the REUSE option. Otherwise, the REPRO command will terminate with an error message.
SKIP and COUNT
These options are used to selectively copy records from the source data set to the target data set as opposed to fully copying. An example is given below:
In this case, the first two records of the input file are skipped and the next four records are copied into the output file and the copy is terminated. No more additional records will be read or copied.If SKIP is not coded, the default is SKIP(O) and if COUNT is not coded, the default is to copy records from beginning to end until all the records in the input file are copied.
FROMKEY and TOKEY
If the source data set is a KSDS from which only records that fall within a certain range need be copied, we can use this option. For example
will copy all records with key values ranging from 111111 to 333333. The range can also be generic. For example,
will copy all records in the input file with 11 as the first two bytes of the key through the records having 33 as the first two bytes of the key.
The PRINT command of AMS is used to print VSAM and non-VSAM data sets. It is similar in syntax to a REPRO command and is different from REPRO in that PRINT dumps the contents of the input file to an output printer device as opposed to an output file.
If character format is specified, then the contents of the file are printed in EBCDIC characters. Any non- printable characters will be printed as a period. A maximum of 120 characters will be printed per line.
If hex format is specified, then each character in the data set are printed as 2 hexadecimal digits. A maximum of 120 hex digits is printed on each line or the equivalent of 60 characters.
The dump format is a combination of character and hex formats. Each character is printed as both a character and as the corresponding hex representation. Each print line contains 64 hex digits and the equivalent 32 hex characters. The format of the print command is:
Where INPUT is the DDNAME of the file to be printed. To print in hex format, the keyword HEX must added to the PRINT functional command.
To print in character format the keyword CHAR must be coded and DUMP keyword corresponds to the dump format in printing. A sample JCL is given below:
Selective Printing of VSAM Files
As previously mentioned, the PRINT command is very similar to the REPRO command in its syntax and usage. Just as we can selectively copy records using REPRO, we can selectively print records with PRINT. The options used for this are the same as that for REPRO. These options are given below:
SKIP and COUNT
These options are used to selectively print records from a data set as opposed to printing the full data set. An example is given below:
In this case, the first two records of the input file are skipped and the next four records are printed and the print is terminated. If SKIP is not coded, the default is SKIP(O) and if COUNT is not coded, the default is to print records from beginning to end until all the records in the input file have been printed.
FROMKEY and TOKEY
If the source data set is a KSDS from which only records that fall within a certain range need be printed, we can use this option. For example
will print all records with key values ranging from 111111 to 333333. The range can also be generic. For example,
will print all records in the input file with 11 as the first two bytes of the key through the records having 33 as the first two bytes of the key.
FROMADDRESS and TOADDRESS
These options are similar to FROMKEY and TOKEY in their functioning. The main difference is that this option can be used to print from ah ESDS all records that lie between these two relative byte addresses.
FROMNUMBER and TONUMBER
This option would print the selected records, which lie between the two given relative record numbers (RRN's).
IBM Mainframe Related Interview Questions
|IBM Lotus Notes Interview Questions||IBM-CICS Interview Questions|
|COBOL Interview Questions||Linux Interview Questions|
|IBM-JCL Interview Questions||IBM Mainframe Interview Questions|
|IBM AIX Interview Questions||IBM WAS Administration Interview Questions|
|IBM Lotus Domino Interview Questions||IBM Integration Bus Interview Questions|
|Mainframe DB2 Interview Questions||Unix Production Support Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.