Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

sort on particular order

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: sort on particular order
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

Senior Member


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

PostPosted: Tue Sep 18, 2012 1:39 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 18, 2012 1:52 pm    Post subject: Reply to: sort on particular order
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: 1712
Location: UK

PostPosted: Tue Sep 18, 2012 2:13 pm    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Tue Sep 18, 2012 3:02 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Senior Member


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

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

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

Senior Member


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

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

I've locked another duplicate thread of yours: http://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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 18, 2012 3:45 pm    Post subject: Reply to: sort on particular order
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us