Page 1 of 1

SORT to update a VSAM File

PostPosted: Tue Feb 14, 2012 2:37 pm
by Teja
Hi,

I have a VSAM, KSDS file with the following attributes:
Record Type - FB
Record Length - 300
Key Length - 24
Key Position - 1,24
SHROPTNS(2,3)

I want to update the status of records from 'RS' or 'RB' to 'RC'. Status field position is 60,2.
I am trying to use the below sort with the same file in SORTIN and SORTOUT to do this
//STEP020    EXEC PGM=SORT,PARM=(VSAMIO,RESET)                   
//SYSPRINT   DD SYSOUT=*                                         
//SYSOUT     DD SYSOUT=*                                         
//SORTLIST   DD SYSOUT=*                                         
//SORTIN     DD  DSN=VSAM.FILE,DISP=SHR             
//SORTOUT    DD  DSN=VSAM.FILE,DISP=SHR             
//SYSIN      DD  *                                                 
  RECORD TYPE=F,LENGTH=(300)   
  SORT FIELDS=(1,24,CH,A),EQUALS                                                 
  OUTREC FIELDS=(1,59,                                             
          60,2,CHANGE=(2,C'RS',C'RC',C'RB',C'RC'),NOMATCH=(60,2),   
          62,239)                                                   


But, I am getting the below error while executing.
SYSIN :                                                                       
  RECORD TYPE=F,LENGTH=(300)                                                   
  SORT FIELDS=(1,24,CH,A),EQUALS                                               
  OUTREC FIELDS=(1,59,                                                         
          60,2,CHANGE=(2,C'RS',C'RC',C'RB',C'RC'),NOMATCH=(60,2),             
          62,239)                                                             
WER276B  SYSDIAG= 1238242, 4306914, 4306914, 3685275                           
WER164B  65,540K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,           
WER164B     156K BYTES RESERVE REQUESTED, 27,972K BYTES USED                   
WER146B  24K BYTES OF EMERGENCY SPACE ALLOCATED                               
WER108I  SORTIN   : RECFM=F    ; LRECL=   300; CISIZE =  4096                 
WER073I  SORTIN   : DSNAME=VSAM.FILE                             
WER237I  OUTREC RECORD LENGTH =   300                                         
WER110I  SORTOUT  : RECFM=F    ; LRECL=   300; CISIZE =  4096                 
WER074I  SORTOUT  : DSNAME=VSAM.FILE                             
WER410B  63M BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,         
WER410B     0 BYTES RESERVE REQUESTED, 26,972K BYTES USED                     
WER036B  G=327                                                                 
WER177I  TURNAROUND SORT PERFORMED                                             
 WER255A  VSAM LOGICAL ERROR 08 ON OUTPUT   


Can anyone suggest me what changes i have to make in my sort card.

Re: SORT to update a VSAM File

PostPosted: Tue Feb 14, 2012 2:47 pm
by bodatrinadh
Hi Teja,

If you want to update the dataset, then you should give DISP=MOD not SHR.


Thanks
-3nadh

Re: SORT to update a VSAM File

PostPosted: Tue Feb 14, 2012 2:53 pm
by BillyBoyo
It is not a good idea to use the same input and output datasets from anything, including Sort.

If you want to use the Sort route, I'd suggest VSAM input to PS doing the update of the fields then PS to VSAM. I'd make a backup of the VSAM file before the sort step.

With a program, you could open for "update", read the file in sequence and only "update" those records which need it. Again, backing up the VSAM file before the step.

Crossing in the post, -3nadh, can you suggest what DISP=MOD might mean for a VSAM KSDS? And, from your suggestion, what you think it would mean for a PS?

Re: SORT to update a VSAM File

PostPosted: Tue Feb 14, 2012 4:19 pm
by bodatrinadh
Apologies for wrong information, I didn’t notice SORTIN and SORTOUT are of same file. By seeing error msg “WER255A” I Concluded that error is updating the output DSN which is in share mode.

We can update the dataset by giving DISP=MOD for existing PS file. Coming to VSAM, Very few occasions i handled them.

I want to recall my post and It won’t be happen next time.


Thanks
-3nadh

Re: SORT to update a VSAM File

PostPosted: Tue Feb 14, 2012 4:31 pm
by BillyBoyo
OK. Also note that the DISP=MOD will "update" in a very specific way, in that it will write all the new records after all the existing records on that dataset.

Re: SORT to update a VSAM File

PostPosted: Wed Feb 15, 2012 12:43 pm
by Teja
I am currently using a program which opens the VSAM in I-O mode, read the file in sequence and update the records which have status of 'RS' or 'RB' to 'RC'.

But, I have many files with different record lengths and layouts, but all need similar processing.
So, instead of writing one program for each file, I was trying to update the records with SORT.

Re: SORT to update a VSAM File

PostPosted: Wed Feb 15, 2012 1:16 pm
by BillyBoyo
Well, sort reads an entire input file and writes an entire output file.

Read VSAM, output to sequential from Sort, read seqential and copy to VSAM (can be with Sort). Repeat daily, and for the number of files needed.

Vs

What you have, which is read input file, update three records. Repeat daily and for the number of tiles needed.

End of story.

If you are at all concerned about resources/costs I know which you'll end up doing.