Build Index (for Experienced)


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.

AIX should be empty and it should be related to the base cluster provided in the BLDINDEX.

High-level 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...])}
/*

Detail 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


INFILE(indd) | INDATASET(input-dataset-name)


  • These parameters are used to identify the base cluster or a path that points to the base cluster.

INFILE(indd)

  • Specifies the DDname that identifies the base cluster or a path that points to the base cluster.
  • All the entries (base cluster, alternate index, path) should be in the same catalog.

Short Description: IFILE

INDATASET(input-dataset-name)

  • Specifies the dataset name that identifies the base cluster or a path that points to the base cluster.

Short Description: 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.

OUTFILE(outdd1[ outdd2...])

  • Specifies the DDname that identifies the alternate index or a path that points to the alternate index.

Short Description: OFILE

OUTDATASET(output-dataset-name1[ output-dataset-name2...])

  • Specifies the dataset name that identifies the alternate index or a path that points to the alternate index.

Short Description: ODS

Optional Parameters


EXTERNALSORT | INTERNALSORT


  • Specifies whether the virtual storage is used to sort the key pairs.

EXTERNALSORT

  • Specifies external sort is used to sort the records.
  • Two external-sort work files (ESDS) need to be provided.
  • The predefined DD names for the external sort files are IDCUT1 and IDCUT2.

Short Description: ESORT

INTERNALSORT

  • Specifies access method services used to sort the key pairs within the user-specified virtual storage.
  • If the virtual storage is not sufficient for processing, the BLDINDEX processing ends with an error message.

Short Description: ISORT

SORTCALL | NOSORTCALL


  • These parameters specify whether call DFSORT to sort the alternate index or not.

SORTCALL

  • Specifies DFSORT should use to sort the alternate index.
  • If DFSORT is called, EXTERNALSORT, INTERNALSORT, WORKFILES, CATALOG, IDCUT1, and IDCUT2 are ignored.
  • SORTCALL is the default.

NOSORTCALL

  • Specifies BLDINDEX should use IDCAMS internal sort (or external sort if specified) instead of DFSORT to sort the alternate index.
  • When the IDCAMS internal or external sort is used, SORTMESSAGELEVEL, SORTDEVICETYPE, SORTMESSAGEDD and SORTFILENUMBER parameters are restricted.

SORTDEVICETYPE (device-type)


  • Specifies the DASD device type passed to DFSORT.

Short Description: SORTDVT SDVT

SORTFILENUMBER (number)


  • Specifies the maximum number of work datasets passed to DFSORT.

Short Description: SORTFN SFN

SORTMESSAGEDD (mesg-file-ddname)


  • Specifies the ddname of the DFSORT message dataset.
  • Suppose there is no DD statement for this ddname. In that case, a message dataset with this ddname is allocated dynamically as a SYSOUT=* dataset.

Short Description: SORTMDD SMDD

SORTMESSAGELEVEL ({ALL|CRITICAL|NONE})


  • Specifies the level of DFSORT messages to print to the DFSORT message dataset.

ALL

  • Specifies that all DFSORT messages and control statements are printed to the message dataset.

CRITICAL

  • Specifies that only critical DFSORT messages to print to the message dataset.
  • No DFSORT control statements are printed. Critical is the default.

NONE

  • Specifies no DFSORT messages or control statements to print to the message dataset.

Short Description: SORTML SML

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

CATALOG (catalog-name)


  • Specifies the catalog in which the work files are to be defined.
  • The BLDINDEX command defines and uses the work files for building the index.
  • The work files are deleted when all alternate indexes are built, and the BLDINDEX command no longer needs the work files.

Short Description: CAT

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.