Tuesday, December 20, 2011

VSAM: Out of sequence problem

Generally when we write records into VSAM through online programs, we don't bother about the key sequence. But batch programs abend if the input records are not in sequence. Any idea why ?


As per my understanding, if a VSAM dataset is accessed in Sequential (or Skip-sequential) mode, THEN the input should be sorted by the Key of the VSAM dataset. Otherwise we will get the error - "OUT OF SEQUENCE". (I guess that is why IDCAMS repro fails).

If the Batch program accesses the dataset in random/dynamic mode, the error won't occur - it is just like the online update. 

I tried this out and verified it :
1. File opened as I-O, access mode DYNAMIC
   - no problem even if input was not in sequence
2. File opened as Output/Extend, access mode sequential
   - ERROR when input was not in sequence

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.