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 

Matching two files and updating one file

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


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Aug 09, 2007 5:26 am    Post subject: Matching two files and updating one file Reply with quote

Hi

I have two files
File1: Emloyee number - 8 bytes
Salary - 15 bytes

Employee numbers are unique and it is not is sorted order.
File2: Employee master file with employee details; file length of 316 bytes
Employee number will be starting at 119 with length of 8 bytes
Duplicate employee records might exist.

I want to match File2's Employee number with that of File1's and if match found then keep the Salary from File1 starting at 217 of File2.
So even duplicate employee number exist in File2 each record of such employee should be updated.

I have tried following SPLICE code but it updating only one employee record, not all records with such employee number

Code:

//SORT    EXEC PGM=ICETOOL,
//             COND=(4,LT)
//TOOLMSG  DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//IN1      DD  DSN=NUDMD.PDMF1002.CDMCMCS2.CLONE,
//             DISP=SHR
//IN2      DD  DSN=NUMBD.TMBSDIND.TEST.MIEXTR.G0001V00,
//             DISP=SHR
//TEMP1    DD  DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(9,9)),UNIT=SYSDA
//OUT1     DD  DSN=NUDMD.MADHU.SPLICE3.OUTPUT,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=DEVPOOL,
//             SPACE=(TRK,(1,1),RLSE),
//             DCB=(RECFM=FB,LRECL=316,BLKSIZE=0)//SYSOUT   DD  SYSOUT=*
//SYSABEND DD  SYSOUT=X,HOLD=YES
//TOOLIN   DD  *
 COPY FROM(IN1) TO(TEMP1) USING(CTL1)
 COPY FROM(IN2) TO(TEMP1) USING(CTL2)
 SPLICE FROM(TEMP1) TO(OUT1) ON(119,8,CH) WITHALL-
     WITH(217,15)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,316)
  SORT FIELDS=(119,8,CH,A)
/*
//CTL2CNTL DD *
  INREC BUILD=(119:1,8,217:9,15)
  SORT FIELDS=(119,8,CH,A)
/*


Can anybody please help me achieving this.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Aug 09, 2007 7:10 am    Post subject: Reply with quote

psmadhusudhan,

Try this untested code

Code:

//STEP0100 EXEC PGM=ICETOOL
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//IN1      DD DSN=NUDMD.PDMF1002.CDMCMCS2.CLONE,
//            DISP=SHR
//IN2      DD DSN=NUMBD.TMBSDIND.TEST.MIEXTR.G0001V00,
//            DISP=SHR
//T1       DD DSN=&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD DSN=NUDMD.MADHU.SPLICE3.OUTPUT,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=DEVPOOL,
//            SPACE=(CYL,(1,1),RLSE)
//TOOLIN   DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(IN2) TO(T1) USING(CTL2)
  SPLICE FROM(T1) TO(OUT) ON(119,8,CH) -
    WITH(1,316) WITHALL USING(CTL3)
//CTL1CNTL DD *
  OUTREC BUILD=(119:1,8,
                317:9,15)
//CTL2CNTL DD *
  OUTREC OVERLAY=(317:15X)
//CTL3CNTL DD *
  OPTION EQUALS
  OUTFIL FNAMES=OUT,
  OUTREC=(001,216,
          317,15,
          232,85)
/*


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
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Aug 09, 2007 8:41 am    Post subject: Reply with quote

Thanks Kolusu Smile I am very happy that I am a member of this forum, as many of my doubts are getting clarified by experts. Once again thank u very much.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Thu Aug 09, 2007 10:19 am    Post subject: Reply with quote

For those interested, here's a SyncSort for z/OS 1.2 job that should also produce the desired output:

Code:

//STEP1   EXEC  PGM=SORT
//SORTJNF1 DD DISP=SHR,DSN=NUMBD.TMBSDIND.TEST.MIEXTR.G0001V00
//SORTJNF2 DD DISP=SHR,DSN=NUDMD.PDMF1002.CDMCMCS2.CLONE
//SORTOUT  DD DSN=NUDMD.MADHU.JOIN.OUTPUT,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=DEVPOOL,
//            SPACE=(CYL,(1,1),RLSE)         
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SYSIN    DD *                                               
 JOINKEYS FILE=F2,FIELDS=(1,8,A)                               
 JOINKEYS FILE=F1,FIELDS=(119,8,A)                             
 JOIN UNPAIRED,F1                                             
 REFORMAT FIELDS=(F1:1,316,F2:9,15),FILL=X'FF'                 
 SORT FIELDS=COPY                                             
 OUTREC IFTHEN=(WHEN=(317,1,BI,EQ,X'FF'),                     
        BUILD=(1,316)),                                       
        IFTHEN=(WHEN=(317,1,BI,NE,X'FF'),                     
        BUILD=(1,216,317,15,232,85))                           
 END                                                           

_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
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