in a file i need to sort only rec 2 ,rec 4,rec 6 etc.
I'm not sure what you mean by this. Please show an example of your input records and what you want the output records to look like. What is the starting position, length and format of your key? What is the RECFM and LRECL of your input file?
SAMPLE is a parameter of DFSORT's OUTFIL statement that lets you "sample" records. The syntax for SAMPLE is SAMPLE=n or SAMPLE=(n,m). The sample consists of the first m records in every nth interval.
n specifies the interval size. The value for n starts at 2 (sample every other record) and can be up to 15 digits.
m specifies the number of records to be processed in each interval. The value for m starts at 1 (process the first record in each interval) and can be up to 15 digits. If m is not specified, 1 is used for m. If m is specified, it must be less than n.
SAMPLE=2 would give you every other record starting with 1 (STARTREC=1 is the default), that is, 1, 3, 5, ...
STARTREC=2,SAMPLE=2 would give you every other record starting with 2, that is, 2, 4, 6, ...
SAMPLE=5,ENDREC=16 would give you every fifth record starting with 1 and ending with 16, that is, 1, 6, 11 and 16
SAMPLE=(1000,2) would give you records 1, 2, 1001, 1002, 2001, 2002, ...
You can access all of the DFSORT books to look up the parameters yourself at:
What you've posted has nothing to do with what infoman123 wants to do. Infoman123 wants to sort alternate records into one output file. Your JCL splits the input file into two output files without sorting the records. Even if you had a SORT FIELDS=(p,m,f,s) statement instead of your SORT FIELDS=COPY statement, it would NOT do what was asked for. The DFSORT job I posted a month ago does what infoman123 wants.
Please read and understand what the poster wants, and test that your solution creates the correct output, before posting.