VSAM EXPORT

The VSAM EXPORT-IMPORT commands are usually used to take the backup and recovery. The EXPORT option is used to export the dataset or alternate index or catalog. EXPORT-IMPORT can be used with the VSAM dataset (KSDS, ESDS, RRDS, and LDS), Alternate indexes, and the dataset created by EXPORT can have only a sequential organization. EXPORT copies the information required to fully reconstruct the cluster without executing a separate DEFINE. The portable copy of the exported cluster must always be contained in a non-VSAM, sequential dataset.

Using EXPORT/IMPORT for backup and recovery has the following advantages:

  • Key-sequenced data set or variable-length RRDS is reorganized. Using EXPORT for backup results in data reorganization and the recreation of an index for a key-sequenced data set or variable-length RRDS. The data records are rearranged physically in ascending key sequence and free-space quantities are balanced. (Control interval and control area splits can have placed the records physically out of order.) When a key-sequenced data set is reorganized, absolute references using the RBA are no longer valid.
  • Redefinition is easy. Because most catalog information is exported along with the data set, you are not required to define a data set before importing the copy. The IMPORT command deletes the original copy, defines the new object, and copies the data from the exported copy into the newly defined data set.
  • Attributes can be changed or added. When you IMPORT a data set for recovery, you can specify the OBJECTS parameter to show new or changed attributes for the data set. Importing a data set lets you change the name of the data set, the key ranges, the volumes on which the data set is to reside, and the SMS classes. For information about accessing a data set using RLS

VSAM EXPORT Syntax

EXPORT entryname[/password]                                       
       {OUTFILE(ddname)]OUTDATASET(entryname)}                    
	 [ERASE]NOERASE]                                            
	 [INFILE(ddname)]                                           
	 [INHIBITSOURCE]NOINHIBITSOURCE]                            
	 [INHIBITTARGET]NOINHIBITTARGET]                            
	 [PURGE]NOPURGE]                                            
	 [TEMPORARY]PERMANENT] 

The entry name is the name of the object that needs to be exported and OUTFILE provides to which it should be exported.

VSAM IMPORT Syntax

IMPORT {INFILE(ddname)]INDATASET(entryname)}
       {OUTFILE(ddname[/password])]      
	OUTDATASET(entryname[/password])}  
	 [ERASE]NOERASE]            
	 [INTOEMPTY]             
	 [OBJECTS((entryname      
	     [FILE(ddname)]        
	     [(KEYRANGES((lowkey  highkey)]       
	     [(lowkey highkey)...])] 
	     [NEWNAME(newname)]  
	     [ORDERED]UNORDERED] 
	     [VOLUMES(volser[  volser...])])
	   [(entryname...)...])] 
	 [PURGE]NOPURGE]
 [CATALOG(catname[/password])] 

The following usage rules apply to the EXPORT/ or MPORT command:

  • EXPORT or IMPORT must be the first statement in the input stream.
  • All parameters must be in the same statement – no continuation is allowed.
  • Comments are allowed in EXPORT or IMPORT.

Optional parameters for VSAM EXPORT – IMPORT

ParameterDescription
ERASE OR NOERASEUsed to specify whether or not the components of a cluster or alternate index exported need to be erased(Erasing will overwrite it with binary zeroes).

ERASE will overwrite the data component with binary zeroes during the cluster or an alternate index is deleted.

NOERASE will not overwrite the data component with binary zeroes when the cluster or alternate index is deleted.
INHIBITSOURCE OR NOINHIBITSOURCEUsed to specify how the data records in the source data set (ALTERNATE INDEX and CLUSTER) can be accessed after they have been imported to another system. ALTER command is used to change this parameter.

If INHIBITSOURCE is specified then the original data records in the original system cannot be accessed for any operation other than retrieval.

If NOINHIBITSOURCE is specified then the original data records in the original system can be accessed for any kind of operation.
INHIBITTARGET OR NOINHIBITTARGETUsed to specify whether or not the data records copied into the target cluster or alternate index can be accessed for any operation other than retrieval after they have been imported to another system. This specification can be changed through the ALTER command.

If INHIBITTARGET is specified, the target object cannot be accessed for any operation other than retrieval after it has been imported into another system.

If NOINHIBITTARGET is specified, the target object can be accessed for any type of operation after it has been imported into another system.
PURGE OR NOPURGEUsed to specify whether or not the cluster or alternate index to be exported needs to be deleted from the original system regardless of the retention period specified in a TO or FOR parameter during the original definition.

This parameter can be specified only if the object is to be permanently exported, that is, deleted from the original system. Therefore, it does not apply to catalogs that must be exported as TEMPORARY.

If PURGE is specified then the object is deleted even if the retention period has not expired.

If NOPURGE is specified then the object is not deleted unless the retention period has not expired.
TEMPORARY OR PERMANENTUsed to specify whether or not the cluster, alternate index, or catalog to be exported is to be deleted from the original system.

If TEMPORARY is specified then the cluster or alternate index is not deleted from the original system. The object in the original system is marked as TEMPORARY to indicate that another copy exists and that the original copy can be replaced.

If PERMANENT is specified then the cluster or alternate index is deleted from the original system & storage space is freed. If its retention period has not yet expired then PURGE must be specified.

Benefits of EXPORT/IMPORT over REPRO

  • Both data records & catalog information are exported.
  • While restoring exported objects using the IMPORT command, Target cluster deletion and redefinition are not required because the exported object already contains catalog information.
  • Since exported object contains catalog information it can be easily ported to the other (but compatible) system. An exported object has cross-system portability.

VSAM IMPORT EXAMPLE

//VSAMIMPT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,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=XXXXXX.YYYYYY.KSDS.BACKUP,           
//            DISP=SHR                                          
//SYSIN    DD *                                                  
  IMPORT -                                                      
  INFILE(DD1) -                                                     
  OUTDATASET(XXXXXX.YYYYYY.KSDS.CLUSTER)             
/*                                                    

VSAM EXPORT EXAMPLE

//VSAMEXPT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//********************************************************
//* THIS IMPORT AND EXPORT COMMAND USED ONLY FOR VSAMFILE.
//********************************************************
//STEP1    EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//DD1      DD DSN=XXXXXX.YYYYYY.KSDS.BACKUP,   
//            DISP=(NEW,CATLG,DELETE),                          
//            UNIT=SYSDA,                                       
//            DCB=(BLKSIZE=8000)                     
//SYSIN    DD *                                                 
  EXPORT                       -                 
  XXXXXX.YYYYYY.KSDS.CLUSTER   -                     
  OUTFILE(DD1)                 -                      
  TEMPORARY                                           
/*  

VSAM Tutorials

VSAM Define Cluster: Click Here IBM Reference: Click Here

Scroll to Top