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
 

 

Need help sorting files using 2 keys

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Kijo

New User


Joined: 22 Mar 2007
Posts: 9
Location: Philippines

PostPosted: Tue Oct 09, 2007 4:33 pm    Post subject: Need help sorting files using 2 keys
Reply with quote

Hi,

I need to keep the records from file 1 based on the records on file 2 where no. and amount matches those of file 1 and duplicates should be kept.

File 1:
Code:
00001   50.75  01/01/2007
00001    6.25  01/01/2007
00001    6.25  01/01/2007
00002   10.00  01/02/2007
00003    3.50  01/03/2007
00005    5.00  01/05/2007

File 2:
Code:
00001    6.25
00003    3.50
00004   20.50
00005    6.50

desired OUTPUT:
Code:
00001    6.25  01/01/2007
00001    6.25  01/01/2007
00003    3.50  01/03/2007

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

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Oct 09, 2007 8:37 pm    Post subject:
Reply with quote

You can use a DFSORT/ICETOOL job like this to do what you asked for.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
00001   50.75  01/01/2007
00001    6.25  01/01/2007
00001    6.25  01/01/2007
00002   10.00  01/02/2007
00003    3.50  01/03/2007
00005    5.00  01/05/2007
00006    7.50  01/05/2007
00006    7.50  01/05/2007
/*
//IN2 DD *
00001    6.25
00003    3.50
00004   20.50
00005    6.50
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN   DD    *
COPY FROM(IN2) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,13,CH) WITHALL -
  WITH(1,81) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'BB')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(81,2,CH,EQ,C'VB'),
    BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Wed Oct 10, 2007 12:16 am    Post subject: Reply to: SYNCSORT need help sorting files using 2 keys
Reply with quote

Kijo,

Here is a SyncSort for z/OS 1.2 job stream that should produce your desired output:
Code:

//SORT1  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTJNF1 DD *                                           
00001   50.75  01/01/2007
00001    6.25  01/01/2007
00001    6.25  01/01/2007
00002   10.00  01/02/2007
00003    3.50  01/03/2007
00005    5.00  01/05/2007
//SORTJNF2 DD * 
00001    6.25
00003    3.50
00004   20.50
00005    6.50
//SYSIN    DD *
  JOINKEYS FILES=F1,FIELDS=(1,13,A) 
  JOINKEYS FILES=F2,FIELDS=(1,13,A) 
  REFORMAT FIELDS=(F1:1,25)         
  SORT FIELDS=COPY             
Back to top
View user's profile Send private message
Kijo

New User


Joined: 22 Mar 2007
Posts: 9
Location: Philippines

PostPosted: Wed Oct 10, 2007 8:28 am    Post subject:
Reply with quote

Thank you very much!

I just have a follow up question regarding the syncsort...

how would I use the joinkeys if my input 1 looks like this

00001 01/01/2007 50.75
00001 01/01/2007 6.25
00001 01/01/2007 6.25
00002 01/02/2007 10.00
00003 01/03/2007 3.50
00005 01/05/2007 5.00

Thanks again.
Back to top
View user's profile Send private message
annujp

New User


Joined: 31 Aug 2005
Posts: 39
Location: St Paul,MN

PostPosted: Wed Oct 10, 2007 8:38 pm    Post subject:
Reply with quote

I tried this. I got the same output as the earlier Sort condition.
Be sure to give the same number of keys in F1 and F2. Also make sure that the position of the fields to be compared is correct.
E.g. The amount 3.50 starts from position 7, this should be specified in the F2 fields parameter.


Code:

//SORT1  EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                     
//SORTOUT  DD SYSOUT=*                     
//SORTJNF1 DD *                           
00001 01/01/2007 50.75                     
00001 01/01/2007 6.25                     
00001 01/01/2007 6.25                     
00002 01/02/2007 10.00                     
00003 01/03/2007 3.50                     
00005 01/05/2007 5.00                     
//SORTJNF2 DD *                           
00001 6.25                                 
00003 3.50                                 
00004 20.50                               
00005 6.50                                 
//SYSIN    DD *                           
 JOINKEYS FILES=F1,FIELDS=(1,6,A,18,7,A)   
 JOINKEYS FILES=F2,FIELDS=(1,6,A,7,7,A)   
 REFORMAT FIELDS=(F1:1,25)                 
 SORT FIELDS=COPY
/*               



Please let me know if this helps.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Wed Oct 10, 2007 8:52 pm    Post subject:
Reply with quote

Kijo,

Are you saying that the amount field in File1 is left justified, but that the amount field in File2 is right justified?
Back to top
View user's profile Send private message
Kijo

New User


Joined: 22 Mar 2007
Posts: 9
Location: Philippines

PostPosted: Thu Oct 11, 2007 11:00 am    Post subject:
Reply with quote

Hi,

Its supposed to be right justified but its all good now, the solution you gave me helped me a lot!

Thank you very much. I really appreciate it!
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 Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am


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