Build Index (for Beginners)


The build index process builds the corresponding alternate index for the existing datasets.

BLDINDEX command is used to build the index for the alternate key. Build index is the last step in creating the alternate index process.

Build index performs the data load operation to the AIX DATA component and indexes to the AIX index component from the base cluster according to the alternate index.

Base cluster should have atleast have one record to build the index.

Detailed syntax -


//JOBNAME  JOB job-card-parameters
//STEP1    EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  BLDINDEX {INFILE(indd)|INDATASET(input-dataset-name)}
  	 {OUTFILE(outdd1[ outdd2...])|
	 OUTDATASET(output-dataset-name1[ output-dataset-name2...])}
  	[{EXTERNALSORT|INTERNALSORT}]
  	[{SORTCALL|NOSORTCALL}]
  	[SORTDEVICETYPE(device-type)]
  	[SORTFILENUMBER(number)]
  	[SORTMESSAGEDD(mesg-file-ddname)]
  	[SORTMESSAGELEVEL({ALL|CRITICAL|NONE})]
  	[WORKFILES(workfile-ddname1[ workfile-ddname2...])
   [CATALOG(catalog-name)]
/*

Parameters


The BLDINDEX command uses to build path, and below are the mandatory and optional parameters.

Mandatory Parameters


Parameters Description
INFILE(indd) | INDATASET(input-dataset-name) These parameters are used to identify the base cluster or a path that points to the base cluster.
Short Description: IFILE | IDS
OUTFILE (outdd1[ outdd2...]) | OUTDATASET(output-dataset-name1[ output-dataset-name2...]) These parameters are used to identify the alternate index or a path that points to the alternate index.
Short Description: OFILE | ODS

Optional Parameters


Parameters Description
EXTERNALSORT | INTERNALSORT Specifies whether the virtual storage is used to sort the key pairs.
Short Description: ESORT | ISORT
SORTCALL | NOSORTCALL These parameters specify whether call DFSORT to sort the alternate index or not.
Short Description: OFILE
Short Description: ODS
WORKFILES (workfile-ddname1[ workfile-ddname2...]) Specifies the DD statements of the work files that BLDINDEX require an external sort of the key-pointer pairs.
Short Description: WFILE

Example -


Requirement - Build index for alternate index on the employee KSDS file.

Input KSDS File - MATEPK.EMPL.KSDS

Input Alternate Index - MATEPK.EMPL.DEPTAIX

Input Path - MATEPK.EMPL.DEPTAIX.PATH

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEPKP JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),            
//             NOTIFY=&SYSUID                                           
//************************************************************          
//* BUILD INDEX                                                         
//************************************************************          
//STEP10   EXEC PGM=IDCAMS                                              
//SYSPRINT DD SYSOUT=*                                                  
//SYSIN    DD *                                                         
  BLDINDEX -                                                            
        INDATASET (MATEPK.EMPL.KSDS) -                                  
        OUTDATASET(MATEPK.EMPL.DEPTAIX) -                               
        NOSORTCALL                                                      
/*                                                                      
//                                                                      
**************************** Bottom of Data ****************************

In the above JCL, MATEPK is the userid and change it as required.

Output -

Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, then BLDINDEX is successful..

********************************* TOP OF DATA **********************************
IDCAMS  SYSTEM SERVICES                                           TIME: 00:16:51
                                                                                
  BLDINDEX -                                                                    
        INDATASET (MATEPK.EMPL.KSDS) -                                          
        OUTDATASET(MATEPK.EMPL.DEPTAIX) -                                       
        NOSORTCALL                                                              
IDC0652I MATEPK.EMPL.DEPTAIX SUCCESSFULLY BUILT                                 
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0                       
                                                                                
IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0               
******************************** BOTTOM OF DATA ********************************

Verify the loaded AIX in 3.4 (Dataset List utility) or any File management tools. AIX keys should load with the combination of the primary keys, as shown below.

Verify AIX Data

Verify the loaded path in 3.4 (Dataset List utility) or any File management tools. The PATH should load with all the keys from the base cluster, and the alternate key should highlight as shown below.

Verify path Data

Explaining Example -

In the above example,

  • INDATASET (MATEPK.EMPL.KSDS) specifies the base cluster (employee KSDS).
  • OUTDATASET(MATEPK.EMPL.DEPTAIX) specifies the alternate index defined earlier.
  • NOSORTCALL specifies no call to DFSORT.