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 

Combining data from two records to form one

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


Joined: 20 Jun 2003
Posts: 27
Topics: 8
Location: East of the Rock, West of the Hard Place

PostPosted: Tue Aug 26, 2003 8:51 pm    Post subject: Combining data from two records to form one Reply with quote

Suppose I have File A as follows:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----

8131235920645 ABCD03816                                    NRMO     
8131235920645 ABCD03817                                    NRMO     
8131235920645 ABCD03818                                    NRMO     
8131235920645 ABCD03819                                    NRMO     
8134561097010 ABCD01925                                    BIBI4E5   


And File B as follows:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----
8131235920645 ABCD03816    093 03231 03238 00002 16H5 16H5           
8131235920645 ABCD03817    093 03231 03238 00002 16H5 16H5           
8131235920645 ABCD03818    093 03231 03238 00002 16H5 16H5           
8131235920645 ABCD03819    093 03231 03238 00002 16H5 16H5           
8134561097010 ABCD01925    093 03204 03238 00002 0661 0661           


I'd like to combine them to get File C as follows:

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----
8131235920645 ABCD03816    093 03231 03238 00002 16H5 16H5 NRMO     
8131235920645 ABCD03817    093 03231 03238 00002 16H5 16H5 NRMO     
8131235920645 ABCD03818    093 03231 03238 00002 16H5 16H5 NRMO     
8131235920645 ABCD03819    093 03231 03238 00002 16H5 16H5 NRMO     
8134561097010 ABCD01925    093 03204 03238 00002 0661 0661 BIBI4E5     


Can I use Insync or Syncsort or some other util to allow me to combine the records from Files A and B to get records as shown in File C? The key I need to match on in this case is the first 26 characters in Files A and B. I don't have File Aid in my shop, so that is out. Any suggestions would be much appreciated.
Back to top
View user's profile Send private message Send e-mail
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Tue Aug 26, 2003 10:55 pm    Post subject: Reply with quote

Pudah,
This topic has been discussed many times. Search for "Merging records laterally" and you should find some hits posted by kolusu, which is identical to your requirement.

Hope this helps...
Cheers,
Coolman.
________
free drupal themes


Last edited by coolman on Sat Feb 05, 2011 1:26 am; edited 1 time in total
Back to top
View user's profile Send private message
Pudah
Beginner


Joined: 20 Jun 2003
Posts: 27
Topics: 8
Location: East of the Rock, West of the Hard Place

PostPosted: Wed Aug 27, 2003 5:37 am    Post subject: Reply with quote

Thanks coolman. I had tried a search before posting my question but I guess I didn't use the right terminology. I will scan for the phrase you suggested. Thanks for the tip.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Aug 27, 2003 5:42 am    Post subject: Reply with quote

Pudah,


Here is the direct link for the topic

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


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Aug 27, 2003 12:37 pm    Post subject: Reply with quote

For the record, this can be done quite easily with the new SPLICE operator of DFSORT's ICETOOL as follows:

Code:

//S1    EXEC  PGM=ICETOOL                           
//TOOLMSG   DD  SYSOUT=*                           
//DFSMSG    DD  SYSOUT=*                           
//IN DD DSN=&I1,DISP=(OLD,PASS)    input file1                   
//   DD DSN=&I2,DISP=(OLD,PASS)     input file2               
//OUT DD DSN=...   output file                                 
//TOOLIN DD *                                       
  SPLICE FROM(IN) TO(OUT) ON(1,26,CH) WITH(27,33)   
/*                                                 


For complete details on SPLICE, see:

http://www.storage.ibm.com/software/sort/mvs/uq90053/online/srtmutol.html#spl
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
patnekar
Beginner


Joined: 27 Jan 2003
Posts: 41
Topics: 16

PostPosted: Fri Aug 29, 2003 8:10 am    Post subject: Reply with quote

Pudah,
This job will do the work for you. It basically puts the data from File 1 ( pos 60-69) into file 2 on matching records. Since I am a novice in SORT, I am sure this job can be written in a better way.

Puru

Code:
//SORT     EXEC PGM=SYNCTOOL                               
//DFSMSG   DD SYSOUT=*                                     
//TOOLMSG  DD SYSOUT=*                                     
//SYSPRINT DD SYSOUT=*                                     
//SYSOUT   DD SYSOUT=*                                     
//IN       DD DSN=YOUR.SECOND.FILE,DISP=SHR         
//          DD DSN=YOUR.FIRST.FILE,DISP=SHR         
//OUT   DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE),
//         DCB=(LRECL=80,RECFM=FB,BLKSIZE=160)             
//TOOLIN   DD *                                           
  SELECT FROM(IN) TO(OUT) ON(1,26,CH) ALLDUPS             
//STEP1    EXEC PGM=SORT                                   
//SYSPRINT DD SYSOUT=*                                     
//SYSPRINT DD SYSOUT=*                                     
//SYSUDUMP DD SYSOUT=*                                     
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=&T1,DISP=SHR,DCB=(LRECL=160,RECFM=FB)               
//SORTOUT  DD DSN=&T2,DISP=(,PASS),SPACE=(TRK,(1,1,),RLSE),           
//         DCB=(LRECL=160,RECFM=FB,BLKSIZE=160)                       
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
//STEP2    EXEC PGM=SORT                                               
//SYSPRINT DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSUDUMP DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=&T2,DISP=SHR                                         
//SORTOUT  DD DSN=YOUR.OUTPUT.FILE,DISP=(NEW,CATLG,DELETE),
//         DCB=(LRECL=80,RECFM=FB)                                     
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  OUTFIL OUTREC=(1:1,59,60:140,10,70:70,11)                           
/*                                                                     
Back to top
View user's profile Send private message Yahoo Messenger
Pudah
Beginner


Joined: 20 Jun 2003
Posts: 27
Topics: 8
Location: East of the Rock, West of the Hard Place

PostPosted: Thu Jan 08, 2004 9:14 pm    Post subject: Reply with quote

Discovered today that I could use the Insync WORKAREA feature to accomplish this task. I first sorted the two files into one with Syncsort so that the matching records would be one after another. I then used that sorted combined file as the input the Insync portion of the job.

Code:
//*********************************************************************
//STEP01   EXEC PGM=SYNCSORT                                           
//SYSOUT    DD SYSOUT=*                                               
//SORTMSG   DD SYSOUT=*                                               
//SORTIN    DD DSN=MYID.TEMPFILB,DISP=SHR                           
//          DD DSN=MYID.TEMPFILA,DISP=SHR                           
//SORTOUT   DD DSN=&&TEMPFILE,                                         
//             DISP=(,PASS),UNIT=DISK,                                 
//             SPACE=(CYL,(1,1),RLSE),                                 
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=9040)                   
//SYSIN     DD *                                                       
 SORT FIELDS=(1,26,CH,A),EQUALS                                       
/*                                                                     
//*********************************************************************
//STEP02   EXEC PGM=INSYNC                                       
//#LOG      DD SYSOUT=*                                           
//#PRINT    DD SYSOUT=*                                           
//#INDD     DD DSN=&&TEMPFILE,DISP=(OLD,DELETE)                   
//#OUTDD    DD DSN=MYID.TEMPFILC,                             
//             DISP=(,CATLG),UNIT=DISK,                           
//             SPACE=(CYL,(1,1),RLSE),                           
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=9040)               
//#PARM     DD *                                                 
 FUNCTION=FIELDMAP                                               
 WORKAREA=80                                                     
 CASE                                                             
   SEARCHDATA=(60,1,NE,C' ')                                     
   MOVE=(1,80,C,C' '),PADCHAR=X'40'        INIT WORKAREA         
   MOVE=(W+1,20,C,60,20,C)                 HOLD ON TO DATA       
 CASE                                                             
   SEARCHDATA=(60,1,EQ,C' ')                                     
   MOVE=(1,80,C,1,80,C),PADCHAR=X'40'                             
   MOVE=(60,20,C,W+1,20,C)                 GRAB DATA FROM WORKAREA
   WRITE=(#OUTDD,1,80)                                           
 ENDCASE
/*     


This seems to work if there are exactly the same number of records on each file.
Back to top
View user's profile Send private message Send e-mail
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