Page 1 of 1

Sorting a file using JCL Sort

PostPosted: Mon Oct 22, 2007 9:57 am
by karthick
Hi All,
I have a file which i have to sort using 3 different criteria, first on number(1-15) as A, second on the Y or N(50-51) as D fianlly on date(51-60) as D. I have written a sort card as below. but its not working. can any one help...

SORT FIELDS=(01,15,CH,A,49,01,CH,D,50,10,CH,D) im using PGM=SORT


File layout:

456565750176768 TNYEU STUHUBAU GESMBH Y07.02.2003

Re: Sorting a file using JCL Sort

PostPosted: Mon Oct 22, 2007 3:33 pm
by krisprems
You say,
second on the Y or N(50-51) as D

But you have coded=>
49,01,CH


fianlly on date(51-60) as D

But, your code is=>
50,10,CH,D


And also is the date MM.DD.YYYY or DD.MM.YYYY?

Re: Sorting a file using JCL Sort

PostPosted: Mon Oct 22, 2007 8:54 pm
by Frank Yaeger
Karthick,

Your description of the fields doesn't match the input record example you show, and it's not clear if the date is mm.dd.yyyy or dd.mm.yyyy. In the future, please give examples of your input records and expected output records and explain the rules for getting from input to output.

but its not working


This doesn't tell us anything. Do you mean it's not sorting the records in the way you want it to, or that you received an error message, or what?

In order to sort on a date correctly, you must do it by year, then month, then day.

If your date is in the form mm.dd.yyyy, then this would be the correct DFSORT statement going by your example input record:

   SORT FIELDS=(1,15,CH,A,49,1,CH,D,
     56,4,CH,D,50,5,CH,D)


If your date is in the form dd.mm.yyyy, then this would be the correct DFSORT statement going by your example input record:

   SORT FIELDS=(1,15,CH,A,49,1,CH,D,   
     56,4,CH,D,53,2,CH,D,50,2,CH,D)