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 to splice two files - Both file has duplicate records.

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

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Thu Jan 03, 2008 8:27 pm    Post subject: Need to splice two files - Both file has duplicate records.
Reply with quote

Hi,

I have the following requirement.

File A:

AA 123
AA 423
BB 111
CC 112
CC 113

File B:

AA 678
AA 666
CC 888
DD 774

Output:

AA 123 678
AA 123 666
AA 423 678
AA 423 666
BB 111
CC 112 888
CC 113 888

The non matched records in file A should be kept. But the non matched records in file B shouldn't be kept. Also the matched records in file A should be spliced as shown in the above ex. The duplicates can appear up to 10 times in both the files.

Is there any way to do this in DFSORT?
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Fri Jan 04, 2008 12:10 am    Post subject: Reply to: Need to splice two files - Both file has duplicate
Reply with quote

The following DFSORT/ICETOOL Job will give you the desired results.

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1      DD *
AA 123
AA 423
BB 111
CC 112
CC 113
//IN2      DD *
AA 678
AA 666
CC 888
DD 774
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=*
//TOOLIN   DD *
  SPLICE FROM(IN1) TO(T1) ON(1,2,CH) KEEPNODUPS  -
  WITHEACH WITH(7,3) WITH(10,3)                  -
  WITH(13,3) WITH(16,3) WITH(19,3) WITH(22,3)    -
  WITH(25,3) WITH(28,3) WITH(31,3) USING(CTL1)

  SPLICE FROM(IN2) TO(T1) ON(1,2,CH) KEEPNODUPS  -
  WITHEACH WITH(73,3) WITH(76,3)                 -
  WITH(79,3) WITH(82,3) WITH(85,3) WITH(88,3)    -
  WITH(91,3) WITH(94,3) WITH(97,3) USING(CTL2)

  SPLICE FROM(T1) TO(T2) ON(1,2,CH) KEEPNODUPS   -
  WITHALL WITH(70,3) WITH(73,3) WITH(76,3)       -
  WITH(79,3) WITH(82,3) WITH(85,3) WITH(88,3)    -
  WITH(91,3) WITH(94,3) WITH(97,3) WITH(101,1)   -
  USING(CTL3)

  COPY FROM(T2) TO(OUT) USING(CTL4)

//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
       OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,2)),HIT=NEXT),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+1),
       BUILD=(01,06,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+2),
          BUILD=(1,3,07:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+3),
          BUILD=(1,3,10:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+4),
          BUILD=(1,3,13:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+5),
          BUILD=(1,3,16:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+6),
          BUILD=(1,3,19:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+7),
          BUILD=(1,3,22:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+8),
          BUILD=(1,3,25:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+9),
          BUILD=(1,3,28:4,3,99:X)),
         IFTHEN=(WHEN=(81,8,ZD,EQ,+10),
          BUILD=(1,3,31:4,3,99:X))
  OUTFIL FNAMES=T1,
  BUILD=(1,99,C'11')

//CTL2CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
       OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,2)),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+1),
       OVERLAY=(70:4,3,27X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+2),
       OVERLAY=(70:03X,73:4,3,24X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+3),
       OVERLAY=(70:06X,76:4,3,21X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+4),
       OVERLAY=(70:09X,79:4,3,18X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+5),
       OVERLAY=(70:12X,82:4,3,15X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+6),
       OVERLAY=(70:15X,85:4,3,12X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+7),
       OVERLAY=(70:18X,88:4,3,09X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+8),
       OVERLAY=(70:21X,91:4,3,06X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+9),
       OVERLAY=(70:24X,94:4,3,03X),HIT=NEXT),
       IFTHEN=(WHEN=(81,8,ZD,EQ,+10),
       OVERLAY=(70:27X,97:4,3))
  OUTFIL FNAMES=T1,
  BUILD=(1,99,C'22')

//CTL3CNTL DD *
  OUTFIL FNAMES=T2,
  OUTREC=(1,3,04,03,70,3,100,2,80:X,/,
          1,3,04,03,73,3,100,2,/,
          1,3,04,03,76,3,100,2,/,
          1,3,04,03,79,3,100,2,/,
          1,3,04,03,82,3,100,2,/,
          1,3,04,03,85,3,100,2,/,
          1,3,04,03,88,3,100,2,/,
          1,3,04,03,91,3,100,2,/,
          1,3,04,03,94,3,100,2,/,
          1,3,04,03,97,3,100,2,/,

          1,3,07,03,70,3,100,2,/,
          1,3,07,03,73,3,100,2,/,
          1,3,07,03,76,3,100,2,/,
          1,3,07,03,79,3,100,2,/,
          1,3,07,03,82,3,100,2,/,
          1,3,07,03,85,3,100,2,/,
          1,3,07,03,88,3,100,2,/,
          1,3,07,03,91,3,100,2,/,
          1,3,07,03,94,3,100,2,/,
          1,3,07,03,97,3,100,2,/,

          1,3,10,03,70,3,100,2,/,
          1,3,10,03,73,3,100,2,/,
          1,3,10,03,76,3,100,2,/,
          1,3,10,03,79,3,100,2,/,
          1,3,10,03,82,3,100,2,/,
          1,3,10,03,85,3,100,2,/,
          1,3,10,03,88,3,100,2,/,
          1,3,10,03,91,3,100,2,/,
          1,3,10,03,94,3,100,2,/,
          1,3,10,03,97,3,100,2,/,

          1,3,13,03,70,3,100,2,/,
          1,3,13,03,73,3,100,2,/,
          1,3,13,03,76,3,100,2,/,
          1,3,13,03,79,3,100,2,/,
          1,3,13,03,82,3,100,2,/,
          1,3,13,03,85,3,100,2,/,
          1,3,13,03,88,3,100,2,/,
          1,3,13,03,91,3,100,2,/,
          1,3,13,03,94,3,100,2,/,
          1,3,13,03,97,3,100,2,/,

          1,3,16,03,70,3,100,2,/,
          1,3,16,03,73,3,100,2,/,
          1,3,16,03,76,3,100,2,/,
          1,3,16,03,79,3,100,2,/,
          1,3,16,03,82,3,100,2,/,
          1,3,16,03,85,3,100,2,/,
          1,3,16,03,88,3,100,2,/,
          1,3,16,03,91,3,100,2,/,
          1,3,16,03,94,3,100,2,/,
          1,3,16,03,97,3,100,2,/,

          1,3,19,03,70,3,100,2,/,
          1,3,19,03,73,3,100,2,/,
          1,3,19,03,76,3,100,2,/,
          1,3,19,03,79,3,100,2,/,
          1,3,19,03,82,3,100,2,/,
          1,3,19,03,85,3,100,2,/,
          1,3,19,03,88,3,100,2,/,
          1,3,19,03,91,3,100,2,/,
          1,3,19,03,94,3,100,2,/,
          1,3,19,03,97,3,100,2,/,

          1,3,22,03,70,3,100,2,/,
          1,3,22,03,73,3,100,2,/,
          1,3,22,03,76,3,100,2,/,
          1,3,22,03,79,3,100,2,/,
          1,3,22,03,82,3,100,2,/,
          1,3,22,03,85,3,100,2,/,
          1,3,22,03,88,3,100,2,/,
          1,3,22,03,91,3,100,2,/,
          1,3,22,03,94,3,100,2,/,
          1,3,22,03,97,3,100,2,/,

          1,3,25,03,70,3,100,2,/,
          1,3,25,03,73,3,100,2,/,
          1,3,25,03,76,3,100,2,/,
          1,3,25,03,79,3,100,2,/,
          1,3,25,03,82,3,100,2,/,
          1,3,25,03,85,3,100,2,/,
          1,3,25,03,88,3,100,2,/,
          1,3,25,03,91,3,100,2,/,
          1,3,25,03,94,3,100,2,/,
          1,3,25,03,97,3,100,2,/,

          1,3,28,03,70,3,100,2,/,
          1,3,28,03,73,3,100,2,/,
          1,3,28,03,76,3,100,2,/,
          1,3,28,03,79,3,100,2,/,
          1,3,28,03,82,3,100,2,/,
          1,3,28,03,85,3,100,2,/,
          1,3,28,03,88,3,100,2,/,
          1,3,28,03,91,3,100,2,/,
          1,3,28,03,94,3,100,2,/,
          1,3,28,03,97,3,100,2,/,

          1,3,31,03,70,3,100,2,/,
          1,3,31,03,73,3,100,2,/,
          1,3,31,03,76,3,100,2,/,
          1,3,31,03,79,3,100,2,/,
          1,3,31,03,82,3,100,2,/,
          1,3,31,03,85,3,100,2,/,
          1,3,31,03,88,3,100,2,/,
          1,3,31,03,91,3,100,2,/,
          1,3,31,03,94,3,100,2,/,
          1,3,31,03,97,3,100,2)

//CTL4CNTL DD *
  OMIT COND=(10,2,CH,EQ,C'22',OR,
            (10,2,CH,EQ,C'12',AND,04,03,CH,EQ,C' '),OR,
            (10,2,CH,EQ,C'12',AND,07,03,CH,EQ,C' '),OR,
            (10,2,CH,EQ,C'11',AND,04,06,CH,EQ,C' '))

  INREC IFTHEN=(WHEN=INIT,
         BUILD=(01,03,
                04,03,X,
                07,03,X,
                10,2,X,SEQNUM,8,ZD,RESTART=(10,2)))

  OUTFIL FNAMES=OUT,
  OMIT=(12,2,CH,EQ,C'11',AND,15,8,ZD,GT,1),
  BUILD=(01,10)
/*
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: Fri Nov 20, 2009 6:20 am    Post subject:
Reply with quote

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), you can now use a JOINKEYS application to do this kind of thing, like so:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//IN1 DD *
AA 123
AA 423
BB 111
CC 112
CC 113
//IN2 DD *
AA 678
AA 666
CC 888
DD 774
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  JOINKEYS F1=IN1,FIELDS=(1,2,A),SORTED
  JOINKEYS F2=IN2,FIELDS=(1,2,A),SORTED
  JOIN UNPAIRED,F1
  REFORMAT FIELDS=(F1:1,7,F2:4,3)
  OPTION COPY
/*


For complete details on JOINKEYS and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
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 Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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