VSAM Tutorial

                                        About Us             Services            Courses            Case Studies             Mainframe Forum            Mainframe Jobs            Contact Us           Mainframe Connectivity


Define VSAM KSDS Cluster:

//IND220KS JOB OZA,OZA,MSGLEVEL=(1,1),                          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//***************************************************           
//* TO DEFINE THE KEY SEQUENCED DATA SET (KSDS)                 
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
  DEFINE CLUSTER(NAME(IND220.INDUS.STUDENT.CLUSTER)   -         
  RECORDSIZE(44,44)    -                                        
  CYLINDERS(3,2)       -                                        
  FREESPACE(10,20)     -                                        
  KEYS(4,0)            -                                        
  CISZ(4096)           -                                        
  INDEXED)             -                                        
  INDEX(NAME(IND220.INDUS.STUDENT.INDEX)) -                     
  DATA(NAME(IND220.INDUS.STUDENT.DATA))                         
/*                                                              
//                                                              


Define VSAM ESDS Cluster:

//IND220ES JOB (123),'INDUS',MSGLEVEL=(1,1),REGION=6M,          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//***************************************************           
//* SAMPLE JCL TO CREATE ENTRY SEQUENCED DATA SET(ESDS)         
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
  DEFINE CLUSTER(NAME(IND220.INDUS.STUDENT.ESDS.CLUSTER)-       
  RECORDSIZE(44,44)-                                            
  CYLINDERS(3,2)-                                               
  CISZ(4096)-                                                   
  NONINDEXED) -                                                 
  DATA(NAME(IND220.INDUS.STUDENT.ESDS.DATA))                    
/*                                                              
//                                                              

 

Define VSAM RRDS Cluster:

//IND220RR JOB OZA,OZA,MSGLEVEL=(1,1),                          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//***************************************************           
//*SAMPLE JCL TO CREATE RRDS                                    
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
  DEFINE CLUSTER(NAME(IND220.INDUS.RRDS.CLUSTER)  -             
  RECORDSIZE(44,44)  -                                          
  CYLINDERS(3,2)  -                                             
  NUMBERED)  -                                                  
  DATA(NAME(IND220.INDUS.RRDS.DATA))                            
/*                                                              
//                                                              


Program to load the records into the ESDS file ...

 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. ESDSWRI.                                           
 AUTHOR. INDUS COMPUTER SERVICES.                               
 INSTALLATION. INDUS, S.R.NAGAR, HYDERABAD, PH:040-66136341.    
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  
      SELECT STU-FILE ASSIGN TO AS-STUDD                        
      ORGANIZATION IS SEQUENTIAL                                
      ACCESS MODE IS SEQUENTIAL.                                
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77  OPTION PIC X(3) VALUE 'YES'.                               
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     PERFORM WRITE-PARA UNTIL OPTION = 'NO'.                    
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN OUTPUT STU-FILE.                                      
 WRITE-PARA.                                                    
     ACCEPT STU-NO.                                             
     ACCEPT STU-NAME.                                           
     ACCEPT STU-ADDR.                                           
     WRITE STU-REC.                                             
     ACCEPT OPTION.                                             
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            

Execution JCL for the ESDS write program

//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=ESDSWRI                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.STUDENT.ESDS.CLUSTER,DISP=SHR    
//SYSIN    DD *                                                 
1111                                                            
VIJAYA                                                          
TANUKU                                                          
YES                                                             
2222                                                            
BHASKAR                                                         
TANUKU                                                          
YES                                                             
3333                                                            
ANDUKURI                                                        
TANUKU                                                          
NO                                                              
/*                                                              
//                                                              


Program to load the records into the KSDS file ...

 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. KSDSWRI.                                           
 AUTHOR. INDUS COMPUTER SERVICES.                               
 INSTALLATION. INDUS, S.R.NAGAR, HYDERABAD, PH:040-66136341.    
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  

      SELECT STU-FILE ASSIGN TO STUDD                           
      ORGANIZATION IS INDEXED                                   
      ACCESS MODE IS SEQUENTIAL                                 
      RECORD KEY IS STU-NO                                      
      FILE STATUS IS WS-STAT.                                   
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77 OPTION PIC X(3) VALUE 'YES'.                                
 77 WS-STAT   PIC X(2) VALUE SPACES.                            
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     PERFORM WRITE-PARA UNTIL OPTION = 'NO'.                    
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN OUTPUT STU-FILE.                                      
 WRITE-PARA.                                                    
     ACCEPT STU-NO.                                             
     ACCEPT STU-NAME.                                           
     ACCEPT STU-ADDR.                                           
     WRITE STU-REC INVALID KEY DISPLAY 'ERROR IN WRITE'.        
*************************************************************   
*  HOW TO USE THE STATUS CODE AND RETURN-CODE REGISTERS     *   
*************************************************************   
     IF WS-STAT = '00'                                          
        DISPLAY 'RECORD INSERTED SUCCESSFULLY'                  
     ELSE                                                       
        DISPLAY 'FILE STATUS CODE IS :' WS-STAT                 
        MOVE '3002' TO RETURN-CODE                              
        DISPLAY RETURN-CODE UPON SYSOUT                         
     END-IF.                                                    
     ACCEPT OPTION.                                             
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            


Execution JCL for the KSDS write program..

//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=KSDSWRI                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.STUDENT.CLUSTER,DISP=SHR         
//SYSIN    DD *                                                 
1111                                                            
VIJAYA                                                          
TANUKU                                                          
YES                                                             
2222                                                            
BHASKAR                                                         
TANUKU                                                          
YES                                                             
3333                                                            
ANDUKURI                                                        
TANUKU                                                          
NO                                                              
/*                                                              
//                                                              


Program to load the records into the RRDS file ...

 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. RRDSWRI.                                           
 AUTHOR. INDUS COMPUTER SERVICES.                               
 INSTALLATION. INDUS, S.R.NAGAR, HYDERABAD, PH:040-66136341.    
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  
      SELECT STU-FILE ASSIGN TO STUDD                           
      ORGANIZATION IS RELATIVE                                  
      ACCESS MODE IS SEQUENTIAL                                 
      FILE STATUS IS WS-STAT.                                   
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77 OPTION PIC X(3) VALUE 'YES'.                                
 77 WS-STAT   PIC X(2) VALUE SPACES.                            
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     PERFORM WRITE-PARA UNTIL OPTION = 'NO'.                    
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN OUTPUT STU-FILE.                                      
 WRITE-PARA.                                                    
     ACCEPT STU-NO.                                             
     ACCEPT STU-NAME.                                           
     ACCEPT STU-ADDR.                                           
     WRITE STU-REC INVALID KEY DISPLAY 'ERROR IN WRITE'.        
*************************************************************   
*  HOW TO USE THE STATUS CODE AND RETURN-CODE REGISTERS     *   
*************************************************************   
     IF WS-STAT = '00'                                          
        DISPLAY 'RECORD INSERTED SUCCESSFULLY'                  
     ELSE                                                       
        DISPLAY 'FILE STATUS CODE IS :' WS-STAT                 
        MOVE '3002' TO RETURN-CODE                              
        DISPLAY RETURN-CODE UPON SYSOUT                         
     END-IF.                                                    
     ACCEPT OPTION.                                             
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            

Execution JCL for the RRDS write program

//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=RRDSWRI                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.RRDS.CLUSTER,DISP=SHR            
//SYSIN    DD *                                                 
1111                                                            
VIJAYA                                                          
TANUKU                                                          
YES                                                             
2222                                                            
BHASKAR                                                         
TANUKU                                                          
YES                                                             
3333                                                            
ANDUKURI                                                        
TANUKU                                                          
NO                                                              
/*                                                              
//                                                              

 

Program to read from KSDS file randomly

 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. RRDSRAW.                                           
 AUTHOR. INDUS COMPUTER SERVICES.                               
 INSTALLATION. INDUS, S.R.NAGAR, HYDERABAD, PH:040-66136341.    
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  
      SELECT STU-FILE ASSIGN TO STUDD                           
      ORGANIZATION IS RELATIVE                                  
      ACCESS MODE IS RANDOM                                     
      RELATIVE KEY IS WS-KEY                                    
      FILE STATUS IS WS-STAT.                                   
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77 OPTION PIC X(3) VALUE 'YES'.                                
 77 WS-STAT   PIC X(2) VALUE SPACES.                            
 77 WS-KEY    PIC 9(4).                                         
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     PERFORM WRITE-PARA UNTIL OPTION = 'NO'.                    
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN OUTPUT STU-FILE.                                      
 WRITE-PARA.                                                    
     DISPLAY 'ENTER THE RELATIVE KEY'.                          
     ACCEPT WS-KEY.                                             
     ACCEPT STU-NO.                                             
     ACCEPT STU-NAME.                                           
     ACCEPT STU-ADDR.                                           
     WRITE STU-REC INVALID KEY DISPLAY 'ERROR IN WRITE'.        
*************************************************************   
*  HOW TO USE THE STATUS CODE AND RETURN-CODE REGISTERS     *   
*************************************************************   
     IF WS-STAT = '00'                                          
        DISPLAY 'RECORD INSERTED SUCCESSFULLY'                  
     ELSE                                                       
        DISPLAY 'FILE STATUS CODE IS :' WS-STAT                 
        MOVE '3002' TO RETURN-CODE                              
        DISPLAY RETURN-CODE UPON SYSOUT                         
     END-IF.                                                    
     ACCEPT OPTION.                                             
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            

Execution JCL

//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=RRDSRAW                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.STUD.RRDS.CLUSTER,DISP=SHR       
//SYSIN    DD *                                                 
0001                                                            
1111                                                            
VIJAYA                                                          
TANUKU                                                          
YES                                                             
0002                                                            
2222                                                            
BHASKAR                                                         
TANUKU                                                          
YES                                                             
0005                                                            
3333                                                            
ANDUKURI                                                        
TANUKU                                                          
NO                                                              
/*                                                              
//                                                              


Program to read the records from KSDS sequentially  ...

 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. KSDSEQR.                                           
 AUTHOR. INDUS COMPUTER SERVIES. S.R.NAGAR, HUDERABAD.          
* INDEXED FILE READING SEQUENTIALLY....                         
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  
      SELECT STU-FILE ASSIGN TO STUDD                           
      ORGANIZATION IS INDEXED                                   
      ACCESS MODE IS SEQUENTIAL                                 
      RECORD KEY IS STU-NO                                      
      FILE STATUS IS WS-STAT.                                   
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77 OPTION PIC X(3) VALUE 'YES'.                                
 77 WS-STAT   PIC X(2) VALUE SPACES.                            
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     PERFORM READ-PARA UNTIL OPTION = 'NO'.                     
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN INPUT STU-FILE.                                       
 READ-PARA.                                                     
     READ STU-FILE                                              
          AT END                                                
             MOVE 'NO' TO OPTION                                
          NOT AT END                                            
             PERFORM DISPLAY-PARA                               
     END-READ.                                                  
     IF WS-STAT = '00'                                          
        DISPLAY 'RECORD READ SUCCESSFUL'                        
     ELSE                                                       
        DISPLAY 'FILE STATUS CODE IS :' WS-STAT                 
        MOVE '3001' TO RETURN-CODE                              
        DISPLAY RETURN-CODE UPON SYSOUT                         
     END-IF.                                                    
 DISPLAY-PARA.                                                  
     DISPLAY STU-REC.                                           
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            

Execution JCL for the KSDS read program

//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=KSDSSER                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSABEND DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.STUDENT.CLUSTER,DISP=SHR         
//                                                              
 

* INDEXED FILE READING RANDOMLY ......


 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. KSDSRAR.                                           
 AUTHOR. INDUS COMPUTER SERVIES. S.R.NAGAR, HUDERABAD.          
* INDEXED FILE READING RANDOMLY ......                          
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  
      SELECT STU-FILE ASSIGN TO STUDD                           
      ORGANIZATION IS INDEXED                                   
      ACCESS MODE IS RANDOM                                     
      RECORD KEY IS STU-NO                                      
      FILE STATUS IS WS-STAT.                                   
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77 OPTION PIC X(3) VALUE 'YES'.                                
 77 WS-STAT   PIC X(2) VALUE SPACES.                            
 77 WS-STU-NO     PIC 9(4) VALUE ZEROS.                         
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     PERFORM READ-PARA UNTIL OPTION = 'NO'.                     
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN INPUT STU-FILE.                                       
 READ-PARA.                                                     
     DISPLAY 'ENTER THE STUDENT NUMBER TO READ'.                
     ACCEPT WS-STU-NO.                                          
     MOVE WS-STU-NO TO STU-NO.                                  
     READ STU-FILE                                              
          INVALID KEY DISPLAY 'ERROR IN READ'                   
          NOT INVALID KEY                                       
              PERFORM DISPLAY-PARA                              
     END-READ.                                                  
     IF WS-STAT = '00'                                          
        DISPLAY 'RECORD READ SUCCESSFUL'                        
     ELSE                                                       
        DISPLAY 'FILE STATUS CODE IS :' WS-STAT                 
        MOVE '3001' TO RETURN-CODE                              
        DISPLAY RETURN-CODE UPON SYSOUT                         
     END-IF.                                                    
     DISPLAY 'DO YOU WANT TO READ MORE RECORDS:'.               
     ACCEPT OPTION.                                             
 DISPLAY-PARA.                                                  
     DISPLAY STU-REC.                                           
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            


Execution JCL


//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=KSDSRAR                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSABEND DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.STUDENT.CLUSTER,DISP=SHR         
//SYSIN    DD *                                                 
1111                                                            
YES                                                             
3333                                                            
NO                                                              
/*                                                              
//                                                              


* INDEXED FILE READING DYNAMICALLY....


 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. KSDSDYR.                                           
 AUTHOR. INDUS COMPUTER SERVIES. S.R.NAGAR, HUDERABAD.          
* INDEXED FILE READING DYNAMICALLY....                          
 ENVIRONMENT DIVISION.                                          
 INPUT-OUTPUT SECTION.                                          
 FILE-CONTROL.                                                  
      SELECT STU-FILE ASSIGN TO STUDD                           
      ORGANIZATION IS INDEXED                                   
      ACCESS MODE IS DYNAMIC                                    
      RECORD KEY IS STU-NO                                      
      FILE STATUS IS WS-STAT.                                   
 DATA DIVISION.                                                 
 FILE SECTION.                                                  
 FD STU-FILE.                                                   
 01 STU-REC.                                                    
     05 STU-NO    PIC 9999.                                     
     05 STU-NAME  PIC X(20).                                    
     05 STU-ADDR  PIC X(20).                                    
 WORKING-STORAGE SECTION.                                       
 77 OPTION PIC X(3) VALUE 'YES'.                                
 77 WS-STAT   PIC X(2) VALUE SPACES.                            
 77 WS-STU-NO     PIC 9(4) VALUE ZEROS.                         
 PROCEDURE DIVISION.                                            
 MAIN-PARA.                                                     
     PERFORM OPEN-PARA.                                         
     DISPLAY 'ENTER THE STUDENT NUMBER TO READ'.                
     ACCEPT WS-STU-NO.                                          
     MOVE WS-STU-NO TO STU-NO.                                  
     START STU-FILE INVALID KEY DISPLAY 'ERROR'.                
     PERFORM READ-PARA UNTIL OPTION = 'NO'.                     
     PERFORM CLOSE-PARA.                                        
     STOP RUN.                                                  
 OPEN-PARA.                                                     
     OPEN INPUT STU-FILE.                                       
 READ-PARA.                                                     
     READ STU-FILE NEXT RECORD                                  
          AT END                                                
             MOVE 'NO' TO OPTION                                
          NOT AT END                                            
              PERFORM DISPLAY-PARA                              
     END-READ.                                                  
     IF WS-STAT = '00'                                          
        DISPLAY 'RECORD READ SUCCESSFUL'                        
     ELSE                                                       
        DISPLAY 'FILE STATUS CODE IS :' WS-STAT                 
        MOVE '3001' TO RETURN-CODE                              
        DISPLAY RETURN-CODE UPON SYSOUT                         
     END-IF.                                                    
 DISPLAY-PARA.                                                  
     DISPLAY STU-REC.                                           
 CLOSE-PARA.                                                    
     CLOSE STU-FILE.                                            

Execution JCL

//IND220VI JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//         NOTIFY=&SYSUID                                       
//STEP1    EXEC PGM=KSDSDYR                                     
//STEPLIB  DD DSN=IND220.INDUS.LOADLIB,DISP=SHR                 
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSABEND DD SYSOUT=*                                          
//STUDD    DD DSN=IND220.INDUS.STUDENT.CLUSTER,DISP=SHR         
//SYSIN    DD *                                                 
1111                                                            
/*                                                              
//                                                              


Define Alternate index

//IND220AX JOB OZA,OZA,MSGLEVEL=(1,1),                          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//***************************************************           
//*SAMPLE JCL TO CREATE ALTERNATE INDEX                         
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
  DEFINE AIX  -                                                 
  (NAME(IND220.INDUS.STUDENT.CLUSTER.ALX) -                     
  RELATE(IND220.INDUS.STUDENT.CLUSTER) -                        
  CISZ(4096) -                                                  
  KEYS(20,4) -                                                  
  NONUNIQUEKEY -                                                
  UPGRADE-                                                      
  RECORDSIZE(29,29)-                                            
  CYLINDERS(3,2)-                                               
  FREESPACE(10,20)-                                             
  )                                                             
/*                                                              
//                                                              


Define path


//IND220PT JOB OZA,OZA,MSGLEVEL=(1,1),                          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//***************************************************           
//*SAMPLE JCL TO DEFINE PATH                                    
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
  DEFINE PATH (NAME(IND220.INDUS.STUDENT.CLUSTER.PATH) -        
               PATHENTRY(IND220.INDUS.STUDENT.CLUSTER.ALX) UPDATE
/*                                                              
//                                                              


Build index command


//IND220BX JOB OZA,OZA,MSGLEVEL=(1,1),                          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//***************************************************           
//*SAMPLE JCL TO BUILD ALTERNATE INDEX                          
//***************************************************           
//STEP     EXEC PGM=IDCAMS                                      
//SYSPRINT DD  SYSOUT=*                                         
//SYSIN    DD  *                                                
  BLDINDEX -                                                    
        INDATASET(IND220.INDUS.STUDENT.CLUSTER) -               
        OUTDATASET(IND220.INDUS.STUDENT.CLUSTER.ALX)            
/*                                                              
//                                                              

 

IDCAMS print command


//IND220PR JOB (123),'INDUS',CLASS=A,MSGCLASS=A,                
//             MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=6M          
//***************************************************           
//*SAMPLE JCL TO PRINT/DISPLAY VSAM DATA                        
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//DDIN     DD DSN=IND220.INDUS.STUDENT.CLUSTER.ALX,DISP=SHR     
//SYSIN    DD *                                                 
  PRINT -                                                       
  INFILE(DDIN) -                                                
  CHAR                                                          
/*                                                              
//                                                              


Reading KSDS fiel using alternate KEY ....

       IDENTIFICATION DIVISION.                                 
       PROGRAM-ID. KSDSAIXR.                                     
       AUTHOR. INDUS COMPUTER SERVICES.                         
       INSTALLATION. INDUS, S.R.NAGAR, HYDERABAD, PH:040-66136341
       ENVIRONMENT DIVISION.                                    
       INPUT-OUTPUT SECTION.                                    
       FILE-CONTROL.                                            
                   SELECT STU-FILE ASSIGN TO STUDMAST           
                   ORGANIZATION IS INDEXED                      
                   ACCESS MODE IS RANDOM                        
                   RECORD KEY IS STU-NO                         
                   ALTERNATE KEY IS STU-NAME WITH DUPLICATES    
                   FILE STATUS IS WS-STATUS.                    
       DATA DIVISION.                                           
       FILE SECTION.                                            
       FD STU-FILE.                                             
       01 STU-REC.                                              
              05 STU-NO PIC 9(4).                               
              05 STU-NAME PIC X(20).                            
              05 STU-ADDR PIC X(20).                            
       WORKING-STORAGE SECTION.                                 
       77 OPTION PIC X(3) VALUE 'YES'.                          
       77 WS-NAME    PIC X(20).                                 
       77 WS-STATUS  PIC XX VALUE SPACES.                       
       PROCEDURE DIVISION.                                      
       MAIN-PARA.                                               
                PERFORM OPEN-PARA.                              
                PERFORM READ-PARA UNTIL OPTION = 'NO'.          
                PERFORM CLOSE-PARA.                             
                STOP RUN.                                       
       OPEN-PARA.                                               
                OPEN INPUT STU-FILE.                            
       READ-PARA.                                               
                 DISPLAY 'ENTER THE NAME TO READ:'.             
                 ACCEPT WS-NAME.                                
                 MOVE WS-NAME TO STU-NAME.                      
                 READ STU-FILE KEY IS STU-NAME                  
                      INVALID KEY DISPLAY 'RECORD NOT FOUND'    
                      NOT INVALID                               
                          PERFORM DISPLAY-PARA                  
                 END-READ.                                      
                 IF WS-STATUS = '00'                            
                    DISPLAY 'SUCCESS'                           
                 ELSE                                           
                    DISPLAY 'WS-STATUS:' WS-STATUS              
                 END-IF.                                        
                 ACCEPT OPTION.                                 
       DISPLAY-PARA.                                            
                 DISPLAY STU-REC.                               
       CLOSE-PARA.                                              
                 CLOSE STU-FILE.                                

Execution JCL to read from the Alternate index Cluster.
Note: With the cluster we need to mention the path instead of
Mentioning the alternate index cluster.
Care should be taken while giving the ddname to path.


//IND220KS JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//             NOTIFY=&SYSUID,REGION=6M                         
//***************************************************           
//STEPOZA  EXEC PGM=AIXREAD                                     
//STEPLIB  DD  DSN=IND220.INDUS.LOADLIB,DISP=SHR                
//SYSPRINT DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//STUDMAST DD  DSN=IND220.INDUS.STUDENT.CLUSTER,DISP=SHR        
//STUDMAS1 DD  DSN=IND220.INDUS.STUDENT.CLUSTER.PATH,DISP=SHR   
//SYSIN    DD  *                                                
BHASKAR                                                         
YES                                                             
ANDUKURI                                                        
NO                                                              
/*                                                              
//                                                              

 

IDCAMS ALTER COMMAND:


//IND220LC JOB (1234),'INDUS',MSGLEVEL=(1,1),REGION=6M          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//*******************************************************       
//*DEMO JCL TO SHOW THE IDCAMS UTILTITY WITH ALTER OPTION       
//*******************************************************       
//STEP10   EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSIN    DD *                                                 
     ALTER IND220.INDUS.CUSTOMER.INDEX  -                       
     NEWNAME(IND220.INDUS.VIJAY.INDEX)                          
/*                                                              
//                                                              

 


//IND220LC JOB (1234),'INDUS',MSGLEVEL=(1,1),REGION=6M          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//*******************************************************       
//*DEMO JCL TO SHOW THE IDCAMS UTILTITY WITH ALTER OPTION       
//*******************************************************       
//STEP10   EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSIN    DD *                                                 
     ALTER IND220.INDUS.VIJAY.DATA  -                           
     ADDVOLUMES(OZAV05) -                                       
     REMOVEVOLUMES(OZAV11)                                      
/*                                                              
//                                                              

 

//IND220LC JOB (1234),'INDUS',MSGLEVEL=(1,1),REGION=6M          
//             CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID                
//**************************************************************
//* ALTER THE FREESPACE PARAMETERS USING THE IDCAMS UTILITY     
//**************************************************************
//STEP10   EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSIN    DD *                                                 
     ALTER IND220.INDUS.VIJAY.DATA  -                           
     FREESPACE(30 30)                                           
/*                                                              
//                                                              

                                                             
       IND220.INDUS.SUTDENT.PSFILE                              
                                                                
=COLS> ----+----1----+----2----+----3----+----4----             
000001 1111AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA             
000002 2222BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB             
000003 3333CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC             
000004 4444DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD             
000005 5555EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE             
000006 6666FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF             
000007 7777GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG             
000008 8888HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH             
000009 9999IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII             
                                                                


IDCAMS REPRO COMMAND:


//IND220EX JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//***************************************************           
//*SAMPLE JCL REPRO/COPY DATA FROM PS TO VSAM KSDS              
//* USING REPOR WE CAN COPY ANY FILE TO ANY FILE                
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSIN    DD  *                                                
  REPRO -                                                       
  INDATASET(IND220.INDUS.SUTDENT.PSFILE) -                      
  OUTDATASET(IND220.INDUS.SUTDENT.KSDS.CLUSTER) -               
  SKIP(3) -                                                     
  COUNT(3)                                                      
/*                                                              
//                                                              

 

//IND220EX JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//***************************************************           
//* SAMPLE JCL REPRO/COPY DATA FROM VSAM KSDS TO PS             
//* USING REPOR WE CAN COPY ANY FILE TO ANY FILE                
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//DD1      DD DSN=IND220.INDUS.SUTDENT.KSDS.CLUSTER,DISP=SHR    
//DD2      DD DSN=IND220.INDUS.SUTDENT.PSFILE.TST1,             
//            DISP=(NEW,CATLG,DELETE),                          
//            SPACE=(TRK,(1,1),RLSE),                           
//            UNIT=SYSDA,                                       
//            DCB=(DSORG=PS,RECFM=FB,LRECL=44,BLKSIZE=440)      
//SYSIN    DD  *                                                
  REPRO -                                                       
  INFILE(DD1) -                                                 
  OUTFILE(DD2) -                                                
  FROMKEY(4444) -                                               
  TOKEY(5555)                                                   
/*                                                              
//                                                              

 

IDCAMS PRINT COMMAND:

//IND220PR JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//             NOTIFY=&SYSUID,REGION=6M                         
//***************************************************           
//* SAMPLE JCL TO PRINT/DISPLAY VSAM DATA                       
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//DDIN     DD DSN=IND220.INDUS.SUTDENT.KSDS.CLUSTER,DISP=SHR    
//SYSIN    DD *                                                 
  PRINT -                                                       
  INFILE(DDIN) -                                                
  CHAR                                                          
/*                                                              
//                                                              

 

//IND220PR JOB (123),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//             NOTIFY=&SYSUID,REGION=6M                         
//***************************************************           
//* SAMPLE JCL TO PRINT/DISPLAY VSAM DATA                       
//***************************************************           
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSIN    DD *                                                 
  PRINT -                                                       
  INDATASET(IND220.INDUS.SUTDENT.KSDS.CLUSTER) -                
  FROMKEY(4444) -                                               
  TOKEY(5555) -                                                 
  HEX                                                           
/*                                                              
//                                                              


IDCAMS LISTCAT COMMAND:

//IND220LC JOB (1123),CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),        
//             NOTIFY=&SYSUID,REGION=6M                         
//***************************************************           
//*DEMO JCL TO SHOW THE IEBGENR UTILTITY                        
//***************************************************           
//STEP10   EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSDUMP  DD SYSOUT=*                                          
//SYSIN    DD *                                                 
     LISTCAT ENTRIES(IND220.INDUS.CUSTOMER.CLUSTER) -           
     VOLUME                                                     
/*                                                              
//                                                              

 

EXPORT COMMAND


//SSS013EX JOB (20,FB3),PARAMESH,CLASS=A,MSGLEVEL=(1,1),TIME=20,
//            NOTIFY=&SYSUID,MSGLEVEL=A,REGION=6M               
//STEP1    EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//DD1      DD DSN=SSS013.PARA2.KSDS.BACKUP,                     
//            DISP=(NEW,CATLG,DELETE),                          
//            UNIT=SYSDA,                                       
//            DCB=(BLKSIZE=8000)                                
//SYSIN    DD *                                                 
  EXPORT -                                                      
  SSS013.PARA2.KSDS.CLUSTER    -                                
  OUTFILE(DD1)                 -                                
  TEMPORARY                    -                                
  INHIBITSOURCE                -                                
  INHIBITTARGET                                                 
/*                                                              
                                                                

IMPORT COMMAND                                                             
                                                                
//SSS013IM JOB (20,FB3),PARAMESH,CLASS=A,MSGCLASS=A,TIME=20,    
//            MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=6M           
//*THIS IMPORT AND EXPORT COMMAND USED ONLY FOR VSAMFILE.       
//STEP1    DD DSN=IDCAMS                                        
//SYSPRINT DD SYSOUT=*                                          
//DD1      DD DSN=SSS013.STU.KSDS.BACKUP,                       
//            DISP=SHR                                          
//SYSIN    DD *                                                 
  IMPORT -                                                      
  INFILE(DD1) -                                                 
  OUTDATASET(SSS013.STU.KSDS.CLUSTER)                           
/*                                                              
//                                                              
                                                                


ALTER COMMND                                                                
                                                                
 //SSS013MO JOB (20,FB3),PARAMESH,CLASS=A,MEGCLASS=A,TIME=20,   
 //            MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=6M          
 //STEP1      EXEC PGM=IDCAMS                                   
 //SYSPRINT DD SYSOUT=*                                         
 //SYSIN    DD *                                                
   ALTER -                                                      
   COBOL.LOAD(PROGRAM1) -                                       
   NEWNAME(COBOL.LOAD(PROGRAM2))                                
 /*                                                             
 //                                                             
                                                                

MODEL COMMANDS                                                                
                                                              
//SSS032MO JOB (20,FB3),PARAMESH,CLASS=A,MEGCLASS=A,TIME=20,    
//            MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=6M           
STEP1      EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSIN    DD *                                                 
  REPRO -                                                       
  INDATASET(SSS013.STU.PS) -                                    
  OUTDATASET(SSS013.STU.KSDS)                                   
  IF LASTCC = 0                                                 
      THEN                                                      
         DELETE (SSS013.STU.PS)                                 
/*                                                              
//                                                               
 www.mainframesguru.com  

Comments