IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Compare File B with File A and eliminate duplicates


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mohanrazz

New User


Joined: 30 Sep 2008
Posts: 30
Location: India

PostPosted: Tue Sep 30, 2008 11:12 am
Reply with quote

Hi,

I have two files :
File B:
--------
Rec3
Rec4
Rec5

FileA:
-------
Rec1
Rec2
Rec3
Rec8

Now I want to generate File C by comparing File A and FileB and eliminating records from File B if they are already present in File A.

So File C output should be:

File C:
------
Rec4
Rec5

Pls help.

Thanks in advance
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Sep 30, 2008 9:33 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80 and your key is in positions 1-4, but the job can be changed appropriately if those assumptions are incorrect.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//FILEB DD *
REC3
REC4
REC5
/*
//FILEA DD *
REC1
REC2
REC3
REC8
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//FILEC DD SYSOUT=*
//TOOLIN DD *
COPY FROM(FILEB) TO(T1) USING(CTL1)
COPY FROM(FILEA) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(FILEC) ON(1,4,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'B')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'A')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=FILEC,INCLUDE=(81,1,CH,EQ,C'B'),
    BUILD=(1,80)
/*
Back to top
View user's profile Send private message
mohanrazz

New User


Joined: 30 Sep 2008
Posts: 30
Location: India

PostPosted: Fri Oct 03, 2008 12:58 pm
Reply with quote

Hi,

As both the files have header records, is it possible to have comparision from 2nd records (where actual data begin) to eliminate duplicate records?

Thanks in advance.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Oct 03, 2008 1:07 pm
Reply with quote

Hi,

are you trying to retain 1 of the header records ?


Gerry
Back to top
View user's profile Send private message
mohanrazz

New User


Joined: 30 Sep 2008
Posts: 30
Location: India

PostPosted: Fri Oct 03, 2008 1:16 pm
Reply with quote

My previous file has data like:

header-1
rec1
rec2
rec3
rec8

current file:

header-1
rec3
rec4
rec5
rec6


after comparision i still want header-1.

i.e. output should be like :

header-1
rec4
rec5
rec6

But above logic is taking header-1 and rec3 as duplicates and removing both.
Back to top
View user's profile Send private message
hchinnam

New User


Joined: 18 Oct 2006
Posts: 73

PostPosted: Fri Oct 03, 2008 1:59 pm
Reply with quote

Is there a specific way to identify your header?
or by default first record will be a header.
Back to top
View user's profile Send private message
hchinnam

New User


Joined: 18 Oct 2006
Posts: 73

PostPosted: Fri Oct 03, 2008 2:42 pm
Reply with quote

I have modified Frank's JCL a bit to consider the first record in FILEB as header. code below,

Code:


//S1   EXEC  PGM=ICETOOL                                         
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//FILEB DD *                                                     
REC3                                                             
REC4                                                             
REC5                                                             
//FILEA DD *                                                     
REC1                                                             
REC2                                                             
REC3                                                             
REC8                                                             
//T1 DD DSN=&&T1,                                                 
//      SPACE=(CYL,(5,5)),DISP=(MOD,PASS)                         
//FILEC DD SYSOUT=*                                               
//TOOLIN DD *                                                     
COPY FROM(FILEB) TO(T1) USING(CTL1)                               
COPY FROM(FILEA) TO(T1) USING(CTL2)                               
SELECT FROM(T1) TO(FILEC) ON(1,4,CH) USING(CTL3) NODUPS           
/*                                                               
//CTL1CNTL DD *                                                   
  INREC OVERLAY=(81:C'B',82:SEQNUM,6,ZD)                         
  OUTFIL FNAMES=T1,INCLUDE=(82,6,ZD,NE,000001),BUILD=(1,81)       
  OUTFIL FNAMES=FILEC,SAVE,BUILD=(1,80)                           
/*                                               
//CTL2CNTL DD *                                   
  INREC OVERLAY=(81:C'A')                         
/*                                               
//CTL3CNTL DD *                                   
  OUTFIL FNAMES=FILEC,INCLUDE=(81,1,CH,EQ,C'B'), 
    BUILD=(1,80)                                 
/*                                               


If you use this JOB make sure your FILEC is empty if exist. Reason for this is I used DISP MOD for this DS
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Fri Oct 03, 2008 10:05 pm
Reply with quote

Mohanrazz,

Assuming the header record has a value in 1-4 that will bring it to the top, you can just make the following change to my job:

Code:

//CTL2CNTL DD *                                 
  OUTFIL FNAMES=T1,OVERLAY=(81:C'A'),STARTREC=2 


If the header record comes out in the wrong order in the output file with this change, let me know.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top