I tried to copy a few records from a VSAM file to another VSAM file using SORT. But the copying didn't happen. I tried the same sort card with output as a sequential dataset and it worked. There is an include condition in the Sort step , but that is not the key . They key is from 2 to 28 which I have specified in SORT FIELDS=(2,28,CH,A)
This doesn't tell us anything. Did you get an error message? If so, which error message?
You didn't give any details, so I can only guess at what happened.
When you specify a VSAM input file and VSAM output file, DFSORT uses TYPE=V by default. That means it adds an RDW temporarily to each input record, so your first data byte starts at position 5 (after the 4-byte RDW) rather than at position 1. Thus, you need to add 4 to each starting position. So the starting position for the key would be 6 instead of 2, and the starting position for your INCLUDE field would be 36 instead of 32.
When you specify a VSAM input file and a sequential output file (without RECFM=x), DFSORT uses TYPE=F by default, so your first data byte starts at position 1 and 2 and 32 are the correct starting positions.
So for VSAM in to VSAM out, you can either let DFSORT use TYPE=V by default, and add 4 to your starting positions, or if appropriate you can specify:
to tell DFSORT to use TYPE=F in which case you don't have to add 4 to your starting positions.
For more information on processing VSAM data sets with DFSORT, see: