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

SORT in different sequence


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Tue Dec 31, 2013 5:45 pm
Reply with quote

Hi,

I would like to know how to sort a file in different sequence - example below:

Input:-
Code:

01
02
03
04


I would like to have 02 as first record followed by 01,03 and 04.

Expected Output:
Code:

02
01
03
04


Please help. Thanks.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Dec 31, 2013 6:00 pm
Reply with quote

Have a look at the suggestions here, there is more than one.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Dec 31, 2013 8:35 pm
Reply with quote

What is the expected output if your input is like

Code:
03
01
02
04
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Dec 31, 2013 10:50 pm
Reply with quote

the info provided by the TS is inadequate ...
from the scarce set of data seems that TS just wants the collating sequence of 01 and 02 reversed.

I will try to answer again tomorrow
the occurrence of wednesday on the first day of a new year
will certainly make everybody' s psychic powers much stronger
icon_wink.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jan 01, 2014 12:33 pm
Reply with quote

Search for ALTSEQ
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jan 01, 2014 2:57 pm
Reply with quote

Something like this..
Code:

//SYSIN    DD  *
 SORT FIELDS=(1,2,AQ,A)
 ALTSEQ CODE=(F2F1,F1F2)
/*
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Jan 02, 2014 2:29 pm
Reply with quote

Thank you Escapa !
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Jan 02, 2014 5:10 pm
Reply with quote

Bill, Escapa and co, I am facing problems when tried this ALTSEQ solution on below input -

Code:

03
01
02
11
04
12
99
22
21


Output with Escapa's code:-
Code:

02
01
03
04
22
21
12
11
99


Expected Output:-
Code:

02
01
03
04
11
12
21
22
99


Please help.

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jan 02, 2014 5:20 pm
Reply with quote

see here and adjust accordingly ...
www.ibmmainframes.com/viewtopic.php?t=60008&highlight=overlay

probably something like

Code:
   INREC  IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),OVERLAY=(somewhere:C'02')),
         IFTHEN=(WHEN=(1,2,CH,EQ,C'02'),OVERLAY=(somewhere:C'01')),
         IFTHEN=(WHEN=NONE,OVERLAY=(somewhere:1,2)


sort on somewhere
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Jan 02, 2014 5:31 pm
Reply with quote

Or you could do something like

Code:
  INREC  IFTHEN=(WHEN=(1,2,CH,EQ,C'02'),OVERLAY=(81:C'01')),
         IFTHEN=(WHEN=NONE,OVERLAY=(81:C'99')
  SORT FIELDS=(81,2,CH,A,1,2,CH,A)
  OUTREC FIELDS=(1,80)
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 02, 2014 6:21 pm
Reply with quote

Ramsri,

How could we know that other values could contain "2" if you don't show them in your sample data?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 02, 2014 7:04 pm
Reply with quote

Ramsri,

You realize that you have a Long history of not providing proper information.

This wastes a lot of your time as well as the time of those who would help . . . If you look back over some of your topics, you will see that they drag on because the requirement was not properly presented in the first place.

If you will not take the time to properly ask your questions, why should someone "jump in" early - knowing you will probably change the requirement . . . icon_sad.gif

d
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Jan 03, 2014 4:21 pm
Reply with quote

Thank you Bill and Pandora-Box.....
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Jan 03, 2014 8:54 pm
Reply with quote

Quote:
Thank you Bill and Pandora-Box.....


But no thank you to Escapa. Enrico, and especially not to Dick.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Sat Jan 04, 2014 10:21 am
Reply with quote

Thank you all icon_surprised.gif
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top