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

sort on particular order


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

New User


Joined: 13 May 2010
Posts: 16
Location: hyderabad

PostPosted: Tue Sep 18, 2012 1:35 pm
Reply with quote

I have a flat file that need to be sorted on below order

1.Medicaid ID - ascending order
2. Trasaction_number - ascending order
3.Transaction_type - ascending order(We need to order by 004,024,021,001,030)

can we achieve it by using any sort jcl?
(becoz the order we need for transaction type is not in ascending order)
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Sep 18, 2012 1:39 pm
Reply with quote

Your description seems simple and straight forward, however, you put a question in here -- so possibly something is not adding up correctly at your end. Keeping this in mind, suggest you show us sample input-records and the expected output from them.

Also, tell us what Sort Product are you using. What is the LRECL/RECFM of the input and output files. And what have you tried?
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 Sep 18, 2012 1:52 pm
Reply with quote

I guess it is the third part of they "key" which is not so easy.

Not difficult either.

You need to provide the information Anuj has requested.

Then, just temporarily, you need to extend your records for some extra data for the third key.

That extension you use to put something into which will be in sort order, depending on your values which are not in sort order.

Code:
if value is 91 put 1 in sort key
if value is 17 put 2 in sort key
if value is 10 put 3 in sort key
if value is 13 put 4 in sort key
etc


Note that this is not real code, nor are they the values for the sort key that I'd actually suggest using, just for demonstration :-)
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Tue Sep 18, 2012 2:13 pm
Reply with quote

Quote:
sort jcl
- this will not do what you say you want but it will run the sort program (SYNCSORT for you as you posted in the JCL forum which, for some reason, covers SYNCSORT as well) which, with the correct sort control cards, will do what you want.
Back to top
View user's profile Send private message
avinash sengar

New User


Joined: 13 May 2010
Posts: 16
Location: hyderabad

PostPosted: Tue Sep 18, 2012 2:19 pm
Reply with quote

Hi Anuj and Bill , Thanks for your reply..
Bill you got Right..its a kind of additional order we require.
please suggest me how we can achieve this using DFSORT in jcl

Below is the example of I/P and expected O/P
Medicaid Trans No Trans Type
1234 1 1
1234 1 1
1234 1 4
1234 1 21
1234 1 21
1234 1 24
1234 1 30
1234 1 30
1234 2 1
1234 2 4
5678 1 1
5678 1 24
5678 1 30
5678 1 30
5678 2 30

After Update

Medicaid Trans No Trans Type
1234 1 4
1234 1 24
1234 1 21
1234 1 21
1234 1 1
1234 1 1
1234 1 30
1234 1 30
1234 2 4
1234 2 1
5678 1 24
5678 1 1
5678 1 30
5678 1 30
5678 2 30
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Sep 18, 2012 3:02 pm
Reply with quote

For the sample records, this will work. Bill has given a hint on this, already.

If in the file, you've, positions differ - you may modify it as per the needs.
Code:
//STEP010  EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                       
1234 1 1                             
1234 1 1                             
1234 1 4                             
1234 1 21                             
1234 1 21                             
1234 1 24                             
1234 1 30                             
1234 1 30                             
1234 2 1                             
1234 2 4                             
5678 1 1                             
5678 1 24                             
5678 1 30                             
5678 1 30                             
5678 2 30                             
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                           
  INREC IFTHEN=(WHEN=(8,1,CH,EQ,C'4'),     
               OVERLAY=(81:C'1')),         
        IFTHEN=(WHEN=(8,2,CH,EQ,C'24'),   
               OVERLAY=(81:C'2')),         
        IFTHEN=(WHEN=(8,2,CH,EQ,C'21'),   
               OVERLAY=(81:C'3')),         
        IFTHEN=(WHEN=(8,1,CH,EQ,C'1'),     
               OVERLAY=(81:C'4')),         
        IFTHEN=(WHEN=(8,2,CH,EQ,C'30'),   
               OVERLAY=(81:C'5'))         
                                           
  SORT FIELDS=(1,4,CH,A,6,1,CH,A,81,1,CH,A)
  OUTREC BUILD=(1,80)
//*                                       

SORTOUT:
Code:
1234 1 4
1234 1 24
1234 1 21
1234 1 21
1234 1 1
1234 1 1
1234 1 30
1234 1 30
1234 2 4
1234 2 1
5678 1 24
5678 1 1
5678 1 30
5678 1 30
5678 2 30
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 18, 2012 3:04 pm
Reply with quote

i enjoy reading posts by these type of TS.

they learn nothing from comment to comment.
they insist on describing it their way, each time.

it's obvious why they ask questions on the internet,
nobody sitting within 6 blocks can stand talking to them anymore.
Back to top
View user's profile Send private message
avinash sengar

New User


Joined: 13 May 2010
Posts: 16
Location: hyderabad

PostPosted: Tue Sep 18, 2012 3:19 pm
Reply with quote

Hi Anuj
Thanks a lot for reply
can you give a brief what "OVERLAY=(81:C'1')),"
will do and 81 you have taken as which position.

Thanks
Back to top
View user's profile Send private message
avinash sengar

New User


Joined: 13 May 2010
Posts: 16
Location: hyderabad

PostPosted: Tue Sep 18, 2012 3:41 pm
Reply with quote

Hi Anuj Thanks a lot
I Got it..
Thanks
once Again it saves a lot oftime
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Sep 18, 2012 3:44 pm
Reply with quote

Glad you got it. Good Luck!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Sep 18, 2012 3:44 pm
Reply with quote

I've locked another duplicate thread of yours: ibmmainframes.com/viewtopic.php?t=59506&highlight= I hope you don't want to continue there. Do you?
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 Sep 18, 2012 3:45 pm
Reply with quote

For the "1" and the "4" I'd make the field two bytes long and check for "1 " and "4 ". Otherwise if there is an "11" or "47" around it'd get stuffed in the wrong slot.

OK, your codes may be inclusive. However, when you next copy the working solution for a situation where there either are other values or there is an "overlap", the best time to get it right is now, so you don't have to remember when you do the copy...
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 Help with SORT - I need to validate d... DFSORT/ICETOOL 4
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top