The steps for creating an Alternate Index are as follows:
Step1: Define Alternate Index
DEFINE ALTERNATEINDEX command is used to define an alternate index.
Syntax:
DEFINE ALTERNATEINDEX -
(NAME(alternateindex-name) -
RECORDSIZE(average maximum)) -
FREESPACE(CI-Percentage,CA-Percentage) -
RELATE(vsamfile-name) -
UPGRADE / NOUPGRADE -
KEYS(length offset) -
CISZ(number) -
NONUNIQUEKEY / UNIQUEKEY -
DATA - (NAME(vsamfile-name.data)) -
INDEX - (NAME(vsamfile-name.index))
Here,
DEFINE ALTERNATEINDEX define Alternate Index.
NAME specifies the Alternate Index name.
RELATE specifies the VSAM cluster name for which the alternate index is created.
NONUNIQUEKEY / UNIQUEKEY; NONUNIQUEKEY signifies that duplicate entries may exist for the alternative index, while UNIQUEKEY indicates the alternate index is unique.
UPGRADE / NOUPGRADE; NOUPGRADE specifies that an alternate index shall be unchanged if the base cluster is changed, while UPGRADE specifies that it shall be modified if the base cluster is changed.
Step2: Define Path
Using the Define Path, the alternate index can be related to the base cluster. Defining a path includes specifying its name and the alternative index it is related to.
DEFINE PATH -
NAME(alternateindex-path-name) -
PATHENTRY(alternateindex-name))
Here,
NAME specifies the Alternate Index Path Name
PATHENTRY Specifies Alternate Index Name.
Step3: Building Index
The alternate index is built using the BLDINDEX command. It reads the entire VSAM indexed data set (or base cluster) and extracts essential data to build the alternate index.
BLDINDEX -
INDATASET(vsamcluster-name) -
OUTDATASET(alternateindex-name))
Here,
INDATASET specifies the VSAM Cluster Name
OUTDATASET specifies the Alternate Index Name.