Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I see two problems here.
1) Since your output file has RECFM=V, I assume your input file also has RECFM=V. So you have to add 4 to the starting position to account for the RDW in positions 1-4. With 3,22, your field actually starts with the 3rd byte of the RDW rather than with the 3rd data byte and all of the 05 records have the same 22 bytes of data.
2) You have 01 for the header record, 05 for the detail records and 09 for the trailer record in the first two data bytes (positions 5-6). If you start sorting with the 3rd data byte, the order of the header, data and trailer records can change. You need to include the 01, 05 and 09 in the SORT.
Given all of that, the correct DFSORT SORT statement would be:
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
Hi Frank,
Thanks alot for your reply....Its working now.
The fact that the files which I am using are varibale files , just slipped out of my mind. But by trail and error method I have tried the sort card as SORT FIELDS=(5,24,CH,A) and its working. Also its sorting only detail records and header trailer records uneffected.
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
Hi Frank,
By using above sort (SORT FIELDS=(7,22,CH,A) )
The header and trailers are also getting changed
So I am using By using above sort (SORT FIELDS=(5,24,CH,A) ) which will sort form first byte. And I will always get header with 01,detail with 05 or 06 ,trailer with 09 so I can sort form first byte.
Can you please suggest how I can avoid this.
Do you want me to omit the first and last record and again to merger the final file after sorting?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Can you please suggest how I can avoid this.
Huh? Why would you want to avoid sorting on the first two bytes when doing so gives you the records in the correct order and not doing so doesn't?
If for some reason you want to sort the detail records only by 7,22 but still keep the header and trailer records in place, you could use DFSORT's new DATASORT function available with z/OS DFSORT PTF UK90013 (July, 2008). Here's the DFSORT/ICETOOL job for that. If you don't have that PTF, ask your System Programmer to install it.