Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Skipping the first and last records in sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Sun Sep 11, 2005 6:41 pm    Post subject: Skipping the first and last records in sort
Reply with quote

hi all

can some one clear my basic doubt. it goes like this.......

i want to sort a sequential file, but skipping the first and last records to be sorted. in my output file these two unsorted records must appear as first and last records itself.........

example: i have 10 records as input. sort records 2 to 9. output file must have 10 records with first record same as the first record in the input file and 10 th record must be last record in input file.....

hope every one reading it got a clear picture of what is required....

thanks in advance....
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sun Sep 11, 2005 8:03 pm    Post subject:
Reply with quote

The Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmtrck.html#a02

shows one way to do this with DFSORT. You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's IFTHEN and OVERLAY functions. Only DFSORT has these functions, so if you don't have DFSORT, you won't be able to use them. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/

If you need more specific help, you'll need to show an example of what the input records look like and what you want the output records to look like, and indicate the position, length and format of the key you want to use and the RECFM and LRECL of the input file.
Back to top
View user's profile Send private message
viveksingal

New User


Joined: 11 Sep 2005
Posts: 10

PostPosted: Sun Sep 11, 2005 8:44 pm    Post subject: Re: sort in jcl
Reply with quote

thanks buddy!!!!!!!!!!

feels good when some one replys so quick.

well we used some other logic to get to the solution.......

//step01 exec pgm=sort
// dd dsn = input file name
// dd dataclas = vlarge
// dd dsn = output file name
// dd sysout = *
// dd *
sort fields = (1,15,ZD,A,1,15,CH,A)
/*

the input dataset consists of records of this kind......

00000000000000000000000
00000wuejwd000026532783
00000hdgsjks000061531633
00000dfjkhdk000083829393
00000dfjkhdk000083829393
99999999999999999999999

this step is working fine now..........

is it correct and need to know whether it will fail under any condition....

thanks...
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Sep 12, 2005 1:31 am    Post subject:
Reply with quote

No, it's not correct and it will fail for many conditions, including the example you show.

Assuming your JCL is correctly specified as follows instead of what you show:

Code:

//STEP01 EXEC PGM=SORT
//SORTIN dd DSN=input file name
//SORTOUT DD DSN=output file name
//SYSOUT DD SYSOUT=*
//SYSIN DD *
   SORT FIELDS=(1,15,ZD,A,1,15,CH,A)
/*


SORTOUT will have:

Code:

00000000000000000000000   
00000dfjkhdk000083829393 
00000dfjkhdk000083829393 
00000wuejwd000026532783   
00000hdgsjks000061531633 
99999999999999999999999   


I assume you're trying to sort the data records on the first 15 characters. But as you can see, the hdg... record appears after the wue... record instead of before it, which is not what you want. Sure, the header record (0 = X'F0') and trailer record (9 = X'F9') will be sorted in the right place, but the rest of the records may or may not be depending on the values in each key field. Here's why:

With 1,15,ZD, the zone is stripped off each byte for sorting purposes, so byte 6 of each record is transformed like this for sorting:

Code:

0 = X'F0' -> 0
w = X'A6' -> 6
h = X'88' -> 8
d = X'84' -> 4
d = X'84' -> 4
9 = X'F9' -> 9


resulting in the following order after sorting:

Code:

0 = X'F0' -> 0
d = X'84' -> 4
d = X'84' -> 4
w = X'A6' -> 6
h = X'88' -> 8
9 = X'F9' -> 9


As you can see the w (6) sorts before the h (8) which is NOT what you want.

The problem with this scheme is that the hex values of the letters are in groups (e.g. 8x, 9x and Ax for the lowercase letters), so you can't just use the last nibble (x) to sort on as ZD does. For example, h = X'88' and w = X'A6' can't be sorted that way.

So unless there's something special about your data that you're not telling me about, that scheme won't work.

I'd suggest you use the method in the Smart DFSORT Trick I gave you the link for. It does work for all cases.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us