View previous topic :: View next topic
Author
Message
Pritam Dass New User Joined: 30 Jan 2008Posts: 6 Location: Noida
HI,
I have a file in which first 5 records are header records ( Not the data only headings). From 6th record I have data which needs to be sorted.
My output file should contain first five records as it is copied from input and rest of the records should be sorted in a given order.
Back to top
superk Global Moderator Joined: 26 Apr 2004Posts: 4652 Location: Raleigh, NC, USA
You need to provide the details such as the RECFM and LRECL of the file, and in your case, what fields you want to sort on and their location and format in the file.
Back to top
Pritam Dass New User Joined: 30 Jan 2008Posts: 6 Location: Noida
Thanks Kevin,
I am using SYNCSORT. RECFM=FB, LRECL=133.
SORT fields are (1,5,CH,A,30,14,CH,A,65,8,CH,A).
First Five records should not be considered for this SORT, and just copied in the output file. SORT should start from rec number #6 to EOF.
Currently I am doing it in following steps:
1. copy first 5 recs in temp file...F1.
2. SORT the input to output temp file (skiprec=5)...F2
3. Merge the files F1 and F2 using IEBGENER.
I want to do it in a single step if possible.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Pritamm,
Is there any way to differentiate the header records from the data records? If yes, give us the details.
Back to top
Pritam Dass New User Joined: 30 Jan 2008Posts: 6 Location: Noida
Yes, All data records have date like 20080212 at location 45. Header records do not have date field at location 45.
Back to top
Alissa Margulies SYNCSORT Support Joined: 25 Jul 2007Posts: 496 Location: USA
Quote:
Header records do not have date field at location 45.
In the header records, are there any numerics at position 45?
Back to top
Alissa Margulies SYNCSORT Support Joined: 25 Jul 2007Posts: 496 Location: USA
Pritam Dass wrote:
All data records have date like 20080212 at location 45. Header records do not have date field at location 45.
Assuming all the dates begin with 2, and no header records have a '2' at position 45, try this JCL:
Code:
//SYSIN DD *
INREC IFTHEN=(WHEN=(45,1,CH,NE,C'2'),OVERLAY=(134:C'1')),
IFTHEN=(WHEN=(45,1,CH,EQ,C'2'),OVERLAY=(134:C'2'))
SORT FIELDS=(134,1,CH,A,1,5,CH,A,30,14,CH,A,65,8,CH,A)
OUTREC FIELDS=(1,133)
/*
Back to top
Alissa Margulies SYNCSORT Support Joined: 25 Jul 2007Posts: 496 Location: USA
Depending on what your header records have in the sort control fields, they may get re-ordered in my previous job. If this is the case, let me know and I'll modify the job for you.
Back to top
Amit Banerjee New User Joined: 12 Jan 2008Posts: 14 Location: india
Hi.I think you can use this if u're sure that the first five records are headers
sort card -
SORT FIELDS=(1,5,CH,A,30,14,CH,A,65,8,CH,A)
STARTREC=6
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
Try this untested SORT JCL,
Code:
//*******************************************************
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD I/P FILE (133/FB)
//SORTOUT DD O/P FILE(133/FB)
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(134:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(134,8,ZD,GE,+6),OVERLAY=(134:8C'9'))
SORT FIELDS=(134,8,CH,A,1,5,CH,A,30,14,CH,A,65,8,CH,A)
OUTREC FIELDS=(1,133)
/*
Back to top
Pritam Dass New User Joined: 30 Jan 2008Posts: 6 Location: Noida
Thanks for your response. I used the soultion mentioned by krisprems and it worked .
Back to top
Please enable JavaScript!