|
|
| Author |
Message |
Roshnii
New User
Joined: 30 Sep 2008 Posts: 27 Location: bangalore
|
|
|
|
Hi,
I have a file with records that i have to sort. But I want to start sorting from the second record. What option should I use? |
|
| Back to top |
|
 |
References
|
|
 |
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1024 Location: Bangalore,India
|
|
|
|
Hello Roshanii,
Is first record conatin any string like header or some string which differntiate it with other records. & Secondly on what key u want to sort the records key length & offset etc
Would you please provide sample i/p & out put for that? |
|
| Back to top |
|
 |
Roshnii
New User
Joined: 30 Sep 2008 Posts: 27 Location: bangalore
|
|
|
|
My input looks like this.
"0" header
1 roshni 100
1 sameer 200
1 pranati 300
1 keerthi 400
1 deepti 500
I have to sort from the second record and want the first record as it is in the output. |
|
| Back to top |
|
 |
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1024 Location: Bangalore,India
|
|
|
|
Hello Roshni i,
Would you provide the sample input as well ? |
|
| Back to top |
|
 |
Roshnii
New User
Joined: 30 Sep 2008 Posts: 27 Location: bangalore
|
|
|
|
My input looks like this
| Code: |
Header record
sandrew bangalore testing
akash development
lisa pune testing
john testing
joan harry
harry
bill
|
And My jcl goes like this
| Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
header record
sandrew bangalore testing
akash development
lisa pune testing
john testing
joan harry
harry
bill
frank george
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(41:1,30)),
IFTHEN=(WHEN=(41,7,CH,NE,C' '),
OVERLAY=(1:C'"',41,7,C'",'),HIT=NEXT),
IFTHEN=(WHEN=(41,7,CH,EQ,C' '),
OVERLAY=(1:C',',9X),HIT=NEXT),
IFTHEN=(WHEN=(49,10,CH,NE,C' '),
OVERLAY=(11:C'"',49,10,C'",'),HIT=NEXT),
IFTHEN=(WHEN=(49,10,CH,EQ,C' '),
OVERLAY=(11:C',',12X),HIT=NEXT),
IFTHEN=(WHEN=(60,11,CH,NE,C' '),
OVERLAY=(24:C'"',60,11,C'",'),HIT=NEXT),
IFTHEN=(WHEN=(60,11,CH,EQ,C' '),
OVERLAY=(24:C',',13X))
OUTREC BUILD=(1,37,SQZ=(SHIFT=LEFT))
/*
|
So my output looks like this
| Code: |
"header","record",
"sandrew","bangalore","testing",
"akash",,"development",
"lisa","pune","testing",
"john",,"testing",
,"joan","harry",
,,"harry",
"bill",,,
,,,
,"frank","george",
|
But I want the first record to be skipped and to appear in the output as it is. How do I skip the first record and apply the sort only from the second record?
So ideally my output should look like this
| Code: |
header record
"sandrew","bangalore","testing",
"akash",,"development",
"lisa","pune","testing",
"john",,"testing",
,"joan","harry",
,,"harry",
"bill",,,
,,,
,"frank","george",
|
|
|
| Back to top |
|
 |
Garry Carroll
Active User
Joined: 08 May 2006 Posts: 192 Location: Dublin, Ireland
|
|
|
|
Google Smart DFSORT Tricks.
Garry. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4684 Location: San Jose, CA
|
|
|
|
Roshnii,
Your description of what you want to do is quite confusing. You say you want to sort starting with the second record, but you're using OPTION COPY so you're NOT sorting, you're copying. What you really want to do is avoid changing the first record.
You were asked if there's something in the header to identify it, but you never answered that question which is an important one. You show 'header' in the header record. Is that string really there? If not, show what the header record actually looks like and indicate if there's something in the header record to identify it, or if it can only be identified as the first record.
What is the RECFM and LRECL of your input file?
What do you want for the RECFM and LRECL of your output file? |
|
| Back to top |
|
 |
Roshnii
New User
Joined: 30 Sep 2008 Posts: 27 Location: bangalore
|
|
|
|
My header looks like this
| Code: |
"0","RECORD","STATION","LEVEL",
|
The "0" is always present in the header. Also it is always the first record of the file. My lrec is 558. And it will remain the same.
So my input file looks like this (before sort)
| Code: |
"0","RECORD","STATION","LEVEL",
1 REC001 10203040506 MEMBER
1 REC002 10203040506 SUB HEADER
|
and after the sort my output should look like this
| Code: |
"0","RECORD","STATION","LEVEL",
"1","REC001","10203040506"," MEMBER",
"1","REC002","10203040506","SUB HEADER",
|
and the header should appear as it is in the output.
But in my case the header is also getting sorted which I do not want. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4684 Location: San Jose, CA
|
|
|
|
Again, you're NOT sorting anything. You're copying!
All you have to do is use another IFTHEN clause to ensure that no changes are made to the record with "0". For example:
| Code: |
INREC IFTHEN=(WHEN=INIT,OVERLAY=(41:1,30)),
IFTHEN=(WHEN=(1,3,CH,EQ,C'"0"'),OVERLAY=(1:1,1)),
IFTHEN=(WHEN=(41,7,CH,NE,C' '),
OVERLAY=(1:C'"',41,7,C'",'),HIT=NEXT),
...
|
The second IFTHEN clause here identifies the "0" record and essentially does a NOP (overlays positions 1 with itself). Since we don't have HIT=NEXT for this clause, none of the other clauses will be executed for the "0" record. |
|
| Back to top |
|
 |
|
|
|