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

Problem in SORT


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

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Fri Dec 26, 2008 7:44 pm
Reply with quote

Hi,

I am facing problem in sorting ine file which has header ,detail and trailer.

I wanr sort form 3rd byte to 24rth byte.
Below is my file

Code:

01AAAA   < ðGT                                       
05U@00002408121809423082003648DR021209635335210892801J
05U@00002408121809423072003648DR021209635335210892801J
05U@00002408121809423062003648DR021209635335210892801J
05U@00002408121809423052003648DR021209635335210892801J
05U@00002408121809423042003648DR021209635335210892801J
05U@00002408121809423032003648DR021209635335210892801J
09   ð


I am using the below sort JCL

Code:

//LBSORT01 EXEC PGM=SORT                                     
//SYSPRINT DD SYSOUT=*                                       
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DISP=SHR,DSN=input dataset   
//SORTOUT  DD DSN=out put dataset           
//            DISP=(NEW,CATLG),                             
//            SPACE=(CYL,(10,10),RLSE),                     
//            DCB=(LRECL=6004,RECFM=V,BLKSIZE=0),           
//            UNIT=SYSDA                                     
//SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(1,1))                   
//SORTWK02 DD UNIT=SYSDA,SPACE=(CYL,(1,1))                   
//SYSIN    DD *                                             
 SORT FIELDS=(3,22,CH,A)                                     
/*     


But the result is same as the input. Means its not sorting .

Please advice.

Regards,
Harsha.
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: Fri Dec 26, 2008 8:54 pm
Reply with quote

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:

Code:

  SORT FIELDS=(5,24,CH,A)
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Sat Dec 27, 2008 4:28 pm
Reply with quote

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.

Thanks again.

Cheers,
Harsha
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Sat Dec 27, 2008 4:34 pm
Reply with quote

Now I have changed my sort to
SORT FIELDS=(7,22,CH,A)

which will acomodate the 4 bytes of RDW.

Thanks,
Harsha
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Sat Dec 27, 2008 4:49 pm
Reply with quote

Hi Frank,

By using above sort (SORT FIELDS=(7,22,CH,A) )

The header and trailers are also getting changed icon_sad.gif

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?

Please advice.

Thanks,
Harsha
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 Dec 27, 2008 9:45 pm
Reply with quote

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.

Code:

//S2   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN   DD DSN=...  input file
//OUT  DD DSN=...  output file
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(7,22,CH,A)
/*


For complete details on DFSORT's new DATASORT function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
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 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top