View previous topic :: View next topic
|
Author |
Message |
getvichu
New User
Joined: 13 Mar 2007 Posts: 3 Location: chennai
|
|
|
|
Hi can i sort a file excluding my header and trailer rec using syncsort |
|
Back to top |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
Yes you can.Please show the i/p and expected o/p foramts with the file details(recfm,lrecl etc..).
Thank you
Krishy |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
How? By using an include or omit.
How do you identify the header and trailer recs?
Have you checked the manual? |
|
Back to top |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
William,
1)Yes thru Include or Omit only.
2)that is the reason asked to show the i/p and o/p.
Thanks
Krishy |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Bill,
But if we want to include header & trailer in o/p file then please suggest the sort card
I/p File:
Code: |
HEDRINF101D342005041300000010
000000000034 10191610022005030119890717FANDERSON
000000000034 21328400022005031019850705FLYONS
000000000034 C1817600022005030119000101FMITCHELL
000000000034 D1965890052005030120031203MBENTON
000000000034 B2529180062005030119940122MGONZALEZ
000000000034 42667570102005030119000101MMATHEW
000000000034 B2868070052005033019951005MSOLORIO
000000000034 C3548350072005030119660930FMACARIO
000000000034 F4078320032005032220050318FWILSON
TRALINF101D34200504130000001000294138 |
O/p should be
Code: |
HEDRINF101D342005041300000010
000000000034 B2529180062005030119940122MGONZALEZ
000000000034 B2868070052005033019951005MSOLORIO
000000000034 C1817600022005030119000101FMITCHELL
000000000034 C3548350072005030119660930FMACARIO
000000000034 D1965890052005030120031203MBENTON
000000000034 F4078320032005032220050318FWILSON
000000000034 10191610022005030119890717FANDERSON
000000000034 21328400022005031019850705FLYONS
000000000034 42667570102005030119000101MMATHEW
TRALINF101D34200504130000001000294138 |
Recfm:FB
Sort fields:(14,10,CH,A) |
|
Back to top |
|
|
getvichu
New User
Joined: 13 Mar 2007 Posts: 3 Location: chennai
|
|
|
|
I VE GIVEN MY INPUT FILE FORMAT
. UM201AAB07031018030185 --HEAD
1200703101803032719321072937379062144211003124000W
1200703101803032719322664690379062144211003124000W
1200703101803032719321276074379062144211003124000W
1200703101803032719320123145379062144211003124000W
1200703101803032719321007479379062144211003124000W
1200703101803032719301658291379062144211003124000W
1200703101803032719320225833379062144211003124000W
.002278171 --TRAIL
LEAVING HEADER AND TRAILER AND THE REST OF THE RECORDS SHOULD BE SORTED IN ASC ORDER STARTING FROM COLUMN 19 TO 29
MY OUTPUT FILE HAS TO BE IN THE SAME FORMAT WITH HEADER AND TRAILER REC
CAN ANYONE HELP ME OUT |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
One way with Syncsort would be to read all of the original file into the sort.
In the control statements use a SORT statement and 3 OUTFIL statements.
Something like:
Code: |
SORT FIELDS=(10,12,BI,A)
OUTFIL FILES=OUT,OMIT=(1,4,CH,EQ,C'HEDR',1,4,CH,EQ,C'TRAL')
OUTFIL FILES=HD,INCLUDE=(1,4,CH,EQ,C'HEDR')
OUTFIL FILES=TR,INCLUDE=(1,4,CH,EQ,C'TRAL')
|
This will require 3 output DD statements
//SORTOUT
//SORTOFHD
//SORTOFTR
Make all 3 with the same dcb info - sortout will need the same space as the input file, the other 2 will need only 1 track. If the file has hundreds of millions of records, this is not a good solution
After the sort step, run an IEBGENER to concatenate the 3 files into one file HD, OUT, TR.
There is probably a more elegant way, but that quickly came to mind.
On a similar note, if (when this file was designed) the file had a "record type" there would be no issue. If the first byte was a 1 for the hdr, 5 for detail records, and 8 for the trailer, the record type could be the high order "key" on any sort and the details would be in order by whatever key was needed for the detail data. |
|
Back to top |
|
|
getvichu
New User
Joined: 13 Mar 2007 Posts: 3 Location: chennai
|
|
|
|
Hi dick
Thanks a lot that was very useful..
but the sort card u mentioned cannot be used becoz the header and trailer rec cant be distinctly seperated with any key value..
1,4,ch,eq'hedr'------> but i don ve a char equal to hedr in my header rec
same for trailer rec too.. trailer rec is just the count of all the detail rec....
Plz help me to solve this |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
No, that literal was for the example posted before your sample data. For yours, you would use the HEAD from this:
Code: |
. UM201AAB07031018030185 --HEAD |
and the TRAIL from this:
On those OUTFIL statements, you would use your "cols", not the ones from my example. You would also change the SORT to be the positions you want to sort on. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Guys, Got this from DFSORT tricks paper-
Code: |
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'HEDR'),OVERLAY=(81:C'0')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'TRAL'),OVERLAY=(81:C'9'))
SORT FIELDS=(81,1,CH,A,19,29,CH,A)
|
Modify as per your requirement
By using a special key of '0' for the header record, '1' for the data records and '9' for the trailer records before the
regular key, we ensure that the header is first and the trailer is last. The '0' special key is unique and will be sorted
first so it's regular key doesn't matter. Likewise, the '9' special key for the trailer is unique and will be sorted last
so it's regular key doesn't matter. However, since all of the data records have the same special key of '1', they will
be sorted between the header and trailer, and the regular key will determine their order. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Agkshirsagar,
Good catch
I like that much better than the OUTFIL method. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I don't think Syncsort has that capability.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Well, bummer. . .
Just did a Syncsort manual search and yup, IFTHEN is not there. . . Neither is OVERLAY.
Here's to the next release. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
It's using DFSORT (ICEMAN).
(Original post said "using Syncsort" which I ignored. Sorry for that.) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
No to worry - we all mis-read one periodically |
|
Back to top |
|
|
|