View previous topic :: View next topic
|
Author |
Message |
avinash sengar
New User
Joined: 13 May 2010 Posts: 16 Location: hyderabad
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
- 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 |
|
|
avinash sengar
New User
Joined: 13 May 2010 Posts: 16 Location: hyderabad
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
avinash sengar
New User
Joined: 13 May 2010 Posts: 16 Location: hyderabad
|
|
|
|
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 |
|
|
avinash sengar
New User
Joined: 13 May 2010 Posts: 16 Location: hyderabad
|
|
|
|
Hi Anuj Thanks a lot
I Got it..
Thanks
once Again it saves a lot oftime |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Glad you got it. Good Luck! |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|