Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need to know how to SORT the file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Need to know how to SORT the file
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: 3158
Location: Tucson AZ

PostPosted: Wed Nov 29, 2006 7:06 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Wed Nov 29, 2006 7:24 pm    Post subject:
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: 1187
Location: Bangalore,India

PostPosted: Wed Nov 29, 2006 7:45 pm    Post subject:
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 Moderator


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

PostPosted: Wed Nov 29, 2006 9:59 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Dec 01, 2006 3:21 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us