MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Join the Fields for a pair of records having a matching key

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Mon Aug 30, 2004 5:38 pm    Post subject: Join the Fields for a pair of records having a matching key Reply with quote

Hi
I know this can be done using DFSORT using SPLICE. But just curious whether we can do this using SYNCSORT.
Code:

File A has the following Record
--------------------------------
001 AAAAA
002 CCCCC
003 EEEEE
004 GGGGG


Code:

File B has the following Record
--------------------------------
001 BBBBB
003 DDDDD
004 FFFFF
005 HHHHH

Code:

My Output File is
------------------
001 AAAAA BBBBB
003 EEEEE DDDDD
004 GGGGG FFFFF

Both the File has a Record format of FB and LRECL of 80.
Also the Key is starting at position 1 and has a length of 3.
(In both the files).
Any help on this highly appreciated.
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Aug 30, 2004 8:36 pm    Post subject: Reply with quote

Somu,

If the records are unique in the files then you can follow the approach shown in here

http://www.mvsforums.com/helpboards/viewtopic.php?t=10&highlight=sum

http://www.mvsforums.com/helpboards/viewtopic.php?t=974&highlight=sum

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Tue Aug 31, 2004 8:15 am    Post subject: Reply with quote

Thank You Kolusu.
I have searched these topics before my post. But as you can see it's merging
two files laterally. But my requirement is merging based on a key in these two files.That is only matched records should be merged and unmatched records should be discarded.
Hope I'm clear.
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Tue Aug 31, 2004 8:37 am    Post subject: Reply with quote

Somu,

All you need is an additional omit statement to remove the non matched records. The approach is similar to the merging of the files. Here is a JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SYNCTOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN1      DD *                                             
001 AAAAA                                                   
002 CCCCC                                                   
003 EEEEE                                                   
004 GGGGG                                                   
//IN2      DD *                                             
001 BBBBB                                                   
003 DDDDD                                                   
004 FFFFF                                                   
005 HHHHH                                                   
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//CON      DD DSN=&T1,VOL=REF=*.T1,DISP=(OLD,PASS)         
//         DD DSN=&T2,VOL=REF=*.T2,DISP=(OLD,PASS)         
//OUT      DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *                                           
  COPY FROM(IN1) USING(CTL1)                             
  COPY FROM(IN2) USING(CTL2)                             
  SORT FROM(CON) USING(CTL3)                             
//CTL1CNTL DD *                                           
  OUTFIL FNAMES=T1,                                       
  OUTREC=(01,10,              $ FIRST 10 BYTES AS IS     
          6Z,                 $ PAD 6 BINARY ZEROES       
          17,64)              $ REST OF THE FIELDS       
//CTL2CNTL DD *                                           
  OUTFIL FNAMES=T2,                                       
  OUTREC=(01,4,               $ FIRST 4 BYTES AS IS       
          6Z,                 $ PAD 6 BINARY ZEROES       
          5,5,                $ FIELD TO BE MERGED       
          Z,                  $ PAD 1 BINARY ZERO         
          17,64)              $ REST OF THE FIELDS       
//CTL3CNTL DD *                                           
  OPTION EQUALS                                           
  SORT FIELDS=(1,3,CH,A)      $ SORT ON KEY               
  SUM  FIELDS=(11,4,BI,       $ SUM ON FIELD             
               15,2,BI)       $ SUM ON FIELD             
  OUTFIL FNAMES=OUT,                                     
  OMIT=(05,6,BI,EQ,X'00',OR,  $ OMIT NON MATCHING RECORDS
        11,6,BI,EQ,X'00')                                 
/*                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Tue Aug 31, 2004 9:16 am    Post subject: Reply with quote

Thank You Kolusu
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Tue Aug 31, 2004 3:01 pm    Post subject: Reply with quote

Kolusu,
If my second file (File B in my first post) is having a COMP-3 FIELD as follows,is it possible to achieve the match and merge results.?
Code:

File B has the following Record
--------------------------------
001 BBBBB  6410707.68
003 DDDDD  6410707.68
004 FFFFF  6410707.68
005 HHHHH  6410707.68

Where as the numeric field is defined as PIC S9(12)V9(6) COMP-3
Code:

My Output File is
------------------
001 AAAAA BBBBB 6410707.68
003 EEEEE DDDDD 6410707.68
004 GGGGG FFFFF 6410707.68

_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Tue Aug 31, 2004 3:46 pm    Post subject: Reply with quote

Somuk,

Try the following control cards.

Code:

//CTL1CNTL DD *                                     
  OUTFIL FNAMES=T1,                                 
  OUTREC=(01,10,              $ FIRST 10 BYTES AS IS
          6Z,                 $ PAD 6 BINARY ZEROES 
          10Z,                $ PAD 10 BINARY ZEROES 
          17,54)              $ REST OF THE FIELDS   
//CTL2CNTL DD *                                       
  OUTFIL FNAMES=T2,                                   
  OUTREC=(01,4,               $ FIRST 4 BYTES AS IS   
          6Z,                 $ PAD 6 BINARY ZEROES   
          5,5,                $ FIELD TO BE MERGED   
          Z,                  $ PAD 1 BINARY ZERO   
          12,10,              $ Comp-3 FIELD                   
          17,54)              $ REST OF THE FIELDS   
//CTL3CNTL DD *                                           
  OPTION EQUALS                                           
  SORT FIELDS=(1,3,CH,A)      $ SORT ON KEY               
  SUM  FIELDS=(11,4,BI,       
               15,2,BI,       
               17,8,BI,       
               25,2,BI)       
  OUTFIL FNAMES=OUT,                                     
  OMIT=(05,6,BI,EQ,X'00',OR,  $ OMIT NON MATCHING RECORDS
        11,6,BI,EQ,X'00')                                 
/*                           


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group