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

Need to know how to SORT the file


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

New User


Joined: 27 Jul 2005
Posts: 35
Location: Chennai

PostPosted: Wed Nov 29, 2006 7:00 pm
Reply with quote

I have an input file which has 3 fields.It will be in the below format

field1 field2 dield3
1757970 06313 05330
0263753 06316 02301
1747870 06313 06450
1757970 06313 04430
0263753 06313 05049
1757970 06313 06450
0263753 06316 02301



My requirement is

1..i need to group all the similar filed 1 next to one another.
2.Need to sort the file based on descending order of field 2.
3.If records are having same value in field 2 .Then i need to sort those records on desc order of field 3.

So finally my output should be in this format

1747870 06313 06450

1757970 06313 06450
1757970 06313 05330
1757970 06313 04430

0263753 06316 02301
0263753 06316 02301
0263753 06313 05049

Can i do this using a single sort step or should i process in more than one step.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Nov 29, 2006 7:06 pm
Reply with quote

A single step should do it, just name all 3 fields in the sort statement.
Back to top
View user's profile Send private message
Abi

New User


Joined: 27 Jul 2005
Posts: 35
Location: Chennai

PostPosted: Wed Nov 29, 2006 7:19 pm
Reply with quote

But i have the requirment like

1.Need to sort the file based on descending order of field 2.

2.If records are having same value in field 2 .Then i need to sort those records on desc order of field 3.

I TRIED GIVING ALL THIS SORT FIELD

SORT FIELDS = ( 9,5,CH,D,14,5,CH,D,1,7,CH,D)
SORT FIELDS = ( 1,7,CH,D,9,5,CH,D,14,5,CH,D)



BUT THIS DID'NT WORK OUT.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Nov 29, 2006 7:24 pm
Reply with quote

Quote:
SORT FIELDS = ( 1,7,CH,D,9,5,CH,D,14,5,CH,D)


Should work just fine. Why do you say
Quote:
THIS DID'NT WORK OUT
?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Nov 29, 2006 7:45 pm
Reply with quote

Hi ABi,


For

Quote:
1..i need to group all the similar filed 1 next to one another.
2.Need to sort the file based on descending order of field 2.
3.If records are having same value in field 2 .Then i need to sort those records on desc order of field 3.


Code:

SORT FIELDS = ( 1,7,CH,D,9,5,CH,D,14,5,CH,D)



For
Quote:
1.Need to sort the file based on descending order of field 2.

2.If records are having same value in field 2 .Then i need to sort those records on desc order of field 3.

Code:

SORT FIELDS = ( 9,5,CH,D,14,5,CH,D)
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: Wed Nov 29, 2006 9:59 pm
Reply with quote

Abi,

The output you show doesn't make any sense. A column of data can either be sorted ascending or descending. For your first column, ascending order would be 0263753, 1747870, 1757970 and descending order would be 1757970, 1747870, 0263753, but you show 1747870, 1757970, 0263753 which is NOT in ascending or descending order.

Code:

  SORT FIELDS=(1,7,CH,A,9,5,CH,D,14,5,CH,D)


will work fine if you want the first column in ascending order and the second and third columns in descending order.

Code:

  SORT FIELDS=(1,7,CH,D,9,5,CH,D,14,5,CH,D)


will work fine if you want all three columns in descending order.

If neither of those give you what you want, then you need to explain what exactly it is you want.
Back to top
View user's profile Send private message
Abi

New User


Joined: 27 Jul 2005
Posts: 35
Location: Chennai

PostPosted: Fri Dec 01, 2006 11:10 am
Reply with quote

an input file which has 3 fields.It will be in the below format

field1 field2 dield3
1757970 06313 05330
0263753 06316 02301
1747870 06313 06450
1757970 06313 04430
0263753 06313 05049
1757970 06313 06450
0263753 06316 02301


My requirement is


1..i need to group all the similar filed 1 next to one another ( ascending or descending)

2.Need to sort the file based on descending order of field 2 ( highest date shld come first)

3.If records are having same value in field 2 .Then i need to sort those records on desc order of field 3.

Note field 2 & Filed 3 are in Julian date format..before formatting i will be converting those into ordinary date format 20050330
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Dec 01, 2006 3:21 pm
Reply with quote

Sounds like a loop....is an AICA in the making? icon_eek.gif

William Thompson wrote:
Quote:
SORT FIELDS = ( 1,7,CH,D,9,5,CH,D,14,5,CH,D)


Should work just fine. Why do you say
Quote:
THIS DID'NT WORK OUT
?


What is unique about your needs that advice from wizards such as Frank does not satisfy them?
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top