Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
Hi man,
As I know there is no direct procedure to do this. You do one thing use count variable to count record number. If record number is even write to a seperate file. finally sort newly created file.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
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?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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:
Hi,
Please try to use SORT utility. The first screenshot sort alternate records, and teh 2nd one split every 10th record. PLease let me know if it works.
Code:
*************************************************************
//JOBNAME JOB (Account info),'usernam, SORT ALT',CLASS=B,
// MSGCLASS=R,NOTIFY=&SYSUID
//*
//* SORT A FILE CREATING 2 FILES WITH ALTERNATE RECORDS
//* FROM THE I/P FILE. EVEN RECORDS IN 1 FILE & ODD RECORDS
//* IN THE OTHER.
//*
//SORT1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=UR.FILE.TO.SORT,DISP=SHR
//FILE2 DD DSN=FILE1.SORT,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(15,10),RLSE),UNIT=SYSDA
//FILE3 DD DSN=FILE2.SORT,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(15,10),RLSE),UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=(FILE2,FILE3),SPLIT
/*
//*
*************************************************************
//JOBNAME JOB (account info),'USERNAM, SORT ALT',CLASS=K,
// MSGCLASS=R,NOTIFY=&SYSUID
//*
//* SORT A FILE CREATING 2 FILES WITH ALTERNATE RECORDS
//* FROM THE I/P FILE. 1ST 10 REC IN 1ST FILE, NEXT 10 IN
//* 2ND FILE, NEXT 10 IN 1ST FILE, AND SO ON.
//*
//SORT1 EXEC PROC=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=UR.FILE.NAME,DISP=SHR
//FILE1 DD DSN=FIRST.SORT.FILE,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(15,10),RLSE),UNIT=SYSDA
//FILE2 DD DSN=SCND.SORT.FILE,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(15,10),RLSE),UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=(FILE1,FILE2),SPLITBY=10
/*
//*
*************************************************************
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Parul,
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.