Page 1 of 1

Copying data back and forth between VSAM and Flat files

PostPosted: Tue Oct 05, 2010 5:10 pm
by cvrupesh
Hi All,

I was going through some of the JCL's which include VSAM's in their processing.
I have come across similar situation in many JCL's that 2 similar steps are present one after another when ever VSAM is involved.

The first step looks like copying data from VSAM file to a Flat file and the very next step is copying back data from Flat file to VSAM file.
Can some one throw some light if there any significance behind this?

I can see from comments that Step1 is called Securing(Backup) VSAM file by copying contents to Flat file and Step2 Restoring(Reload) where data is copied from Flat file back to VSAM.

Re: Copying data back and forth between VSAM and Flat files

PostPosted: Tue Oct 05, 2010 6:45 pm
by Robert Sample
If the VSAM file is indexed (KSDS), inserting records can cause splits of the controlinterval and possibly even the controlarea. This can cause inefficient access and excess used space. Unloading the VSAM file, redefining it, and reloading the VSAM file is the only way to recover the space.

Re: Copying data back and forth between VSAM and Flat files

PostPosted: Tue Oct 05, 2010 7:08 pm
by NicC
Also, by reading the backup right away you are ensuring its quality.

Re: Copying data back and forth between VSAM and Flat files

PostPosted: Tue Oct 05, 2010 7:11 pm
by cvrupesh
Exactly, I got the same answer from a System Programmer here also couple of minutes ago that this process will remove CI and CA splits which improves the structure of the index.

One more point he added here is, some programmers code in this way to make the Restart mechanism easy in case of failures.

Re: Copying data back and forth between VSAM and Flat files

PostPosted: Tue Oct 05, 2010 8:19 pm
by ritikasingh
Hi when any processing happens for VSAM file.
you will always see these steps ALWAYS :

Step1: Taking backup in flat file.
Step 2: Sorting the file on the key(if not sorted this will cause and error)
Step3: Copy back(REPRO) the data from flat file to VSAM..

Re: Copying data back and forth between VSAM and Flat files

PostPosted: Tue Oct 05, 2010 8:28 pm
by Robert Sample
ritikasingh, you are not correct. If there are no data changes, an IDCAMS REPRO to a sequential file will already be in key sequence, so there is absolutely no reason to run a sort before the loading back of the data into the VSAM file. There may be other processing going on that requires sorting the data but a straight unload / reload does not.