IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

sorting alternate records in the FILE


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
infoman123

New User


Joined: 01 Mar 2005
Posts: 10

PostPosted: Thu Mar 03, 2005 8:40 am
Reply with quote

all,

i need to sort a file's alternate records.Like in a file i need to sort only rec 2 ,rec 4,rec 6 etc.How can we achieve this.
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Thu Mar 03, 2005 4:54 pm
Reply with quote

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.

Bye,
Reddy.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 03, 2005 10:20 pm
Reply with quote

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?
Back to top
View user's profile Send private message
infoman123

New User


Joined: 01 Mar 2005
Posts: 10

PostPosted: Mon Mar 07, 2005 1:29 pm
Reply with quote

my input file is

ABCDEFGH ------REC1
IJKLMNOPQ ------REC2
RSTUVWXY ------REC3
ZABCDEFG ------REC4
HIJKLMNOP ------REC5
QRSTUVWX ------REC6

I need to sort only the rec2 ,rec 4 and rec 6

so the output file will be
IJKLMNOPQ ------REC2
QRSTUVWX ------REC6
ZABCDEFG ------REC4


Regards
Infoman
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Mar 07, 2005 10:54 pm
Reply with quote

Infoman,

Here's a DFSORT/ICETOOL job that will do what you want:

Code:

//S1    EXEC  PGM=ICETOOL                                     
//TOOLMSG  DD  SYSOUT=*                                       
//DFSMSG   DD  SYSOUT=*                                       
//IN DD *                                                     
ABCDEFGH ------REC1                                           
IJKLMNOPQ ------REC2                                           
RSTUVWXY ------REC3                                           
ZABCDEFG ------REC4                                           
HIJKLMNOP ------REC5                                           
QRSTUVWX ------REC6                                           
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)     
//OUT  DD SYSOUT=*                                             
//TOOLIN   DD    *                                             
   COPY FROM(IN) USING(CTL1)                                     
   SORT FROM(T1) TO(OUT) USING(CTL2)                             
/*
//CTL1CNTL DD *                                               
   OUTFIL FNAMES=T1,STARTREC=2,SAMPLE=2   
/*                       
//CTL2CNTL DD *                                               
   SORT FIELDS=(1,8,CH,A)             
/*                           
Back to top
View user's profile Send private message
infoman123

New User


Joined: 01 Mar 2005
Posts: 10

PostPosted: Tue Mar 08, 2005 10:59 am
Reply with quote

Thanx Frank..it worked...

whts the importance of that keyword SAMPLE in this..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 08, 2005 10:45 pm
Reply with quote

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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Sat Apr 09, 2005 3:54 pm
Reply with quote

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                               
/*                                                                   
//*
*************************************************************


Parul.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Apr 09, 2005 8:01 pm
Reply with quote

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.
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Mon Apr 11, 2005 4:35 pm
Reply with quote

Hi,
I am sorry for this. Will try to keep a note of it from next time. But we can try this job for splitting the file as per our requirement.

I apologize for the same.

Parul
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top