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

Skipping the first and last records in sort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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 Developer


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

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

The Smart DFSORT Trick at:

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:

Use [URL] BBCode for External Links

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
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 Developer


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

PostPosted: Mon Sep 12, 2005 1:31 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
Search our Forums:

Back to Top