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
 

 

Get maximum value of 2 different fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
aditya_gorti

New User


Joined: 21 Dec 2005
Posts: 19

PostPosted: Wed Nov 27, 2013 7:36 pm    Post subject: Get maximum value of 2 different fields
Reply with quote

Hi,

I have a file with the following layout

lrecl=22

Input data:

0000000000100000000001
0000000000400000000003
0000000000500000000009
0000000000600000000002

I need the output as:

0000000000100000000001
0000000000400000000002
0000000000500000000003
0000000000600000000009

I need the first 11 to be sorted independently and then the 2 11 bytes independently.

This might be a very silly question.. Can you please help me?

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

dick scherrer

Site Director


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

PostPosted: Wed Nov 27, 2013 8:00 pm    Post subject:
Reply with quote

Hello,

Why is it desirable to swap values between the records?

If you explain just what this is to accomplish, we (i) might be better able to suggest something.
Back to top
View user's profile Send private message
aditya_gorti

New User


Joined: 21 Dec 2005
Posts: 19

PostPosted: Wed Nov 27, 2013 8:04 pm    Post subject: Reply to: Get maximum value of 2 different fields
Reply with quote

The 22 bytes are actually 2 different sets of keys which are combined..
I need to get the max vaue of first key(position 1-11) and also the maximum of 2nd key (position 12-22) to be used further..

I was thinking of icetool to split the keys into separate files and then merging them back.. but was not sure if there was an easier way to do it..
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Wed Nov 27, 2013 8:08 pm    Post subject:
Reply with quote

Add a sequence number before sort -> Step 1
Add a sequence number after sort -> Step 2
Join output of Step 1 & Step 2 based on Sequence number

You would get the desired results
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Nov 27, 2013 9:00 pm    Post subject:
Reply with quote

Hello,

How many pairs of keys will be processed?
Back to top
View user's profile Send private message
aditya_gorti

New User


Joined: 21 Dec 2005
Posts: 19

PostPosted: Wed Nov 27, 2013 9:28 pm    Post subject: Reply to: Get maximum value of 2 different fields
Reply with quote

Only 2 sets of keys. One from the 1st 11 bytes and 1 key from 2nd 11 bytes..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Nov 27, 2013 9:40 pm    Post subject:
Reply with quote

Hello,

Quote:
Only 2 sets of keys.
Your original post shows 4 sets of keys.

How many will there be "for real"?
Back to top
View user's profile Send private message
aditya_gorti

New User


Joined: 21 Dec 2005
Posts: 19

PostPosted: Wed Nov 27, 2013 10:00 pm    Post subject:
Reply with quote

I am sorry.. there would be close to 1.5 million sets of keys..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Nov 27, 2013 10:32 pm    Post subject:
Reply with quote

Hello,

Quote:
I am sorry.. there would be close to 1.5 million sets of keys..
Not to worry icon_smile.gif
Might take a couple of iterations, but we get there icon_wink.gif

If all you want is the 2 highest values (regardless of which "other" value), suggest you consider a tiny bit of Easytrieve or COBOL code.
This code would read each record only once and if the incoming value was greater than the previous "highest value", store it. There would be 2 "highest values - left side and right side.

Only 1 pass of the data and no sorting to find the "winners".
Back to top
View user's profile Send private message
aditya_gorti

New User


Joined: 21 Dec 2005
Posts: 19

PostPosted: Thu Nov 28, 2013 12:27 am    Post subject: Reply to: Get maximum value of 2 different fields
Reply with quote

Yupp probably I will just do it in a cobol program..
Thank you! icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Nov 28, 2013 12:44 am    Post subject:
Reply with quote

use the following DFSORT JCL which will give you the desired results. The trick here is to use the same file twice but treating the keys differently using JNF1 and JNF2

Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//INA      DD *                                         
0000000000100000000001                                 
0000000000400000000003                                 
0000000000500000000009                                 
0000000000600000000002                                 
//INB      DD *                                         
0000000000100000000001                                 
0000000000400000000003                                 
0000000000500000000009                                 
0000000000600000000002                                 
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  JOINKEYS F1=INA,FIELDS=(1,12,A)                       
  JOINKEYS F2=INB,FIELDS=(1,12,A)                       
  REFORMAT FIELDS=(F1:1,12,F2:1,12,?)                   
  JOIN UNPAIRED                                         
  INREC BUILD=(2,11,14,11,X,SEQNUM,8,ZD,RESTART=(25,1))
  SORT FIELDS=(24,8,CH,A),EQUALS                       
  OUTREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(1,11))     
  OUTFIL OMIT=(12,1,CH,EQ,C' '),BUILD=(1,22)           
//*                                                     
//JNF1CNTL DD *                                         
  INREC BUILD=(C'1',1,11)                               
//*                                                     
//JNF2CNTL DD *                                         
  INREC BUILD=(C'2',12,11)                             
//*
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 Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Need Help to Define 36 Input Fields (... satish.ms10 CLIST & REXX 2 Sat May 07, 2016 3:08 pm
No new posts FileAid to compare(logical operations... anand1204 Compuware & Other Tools 3 Wed Apr 06, 2016 2:55 am
No new posts Fields in File-Aid Browse menu screen boyti ko Compuware & Other Tools 5 Mon Apr 04, 2016 4:51 pm
No new posts What is the maximum number of sort wo... Pravina M SYNCSORT 2 Mon Mar 14, 2016 4:51 pm


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