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
 

 

Compare File B with File A and eliminate duplicates

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Compare File B with File A and eliminate duplicates
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 Moderator


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

PostPosted: Tue Sep 30, 2008 9:33 pm    Post subject:
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    Post subject: Reply to: Compare File B with File A and eliminate duplicate
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: 1703
Location: Australia

PostPosted: Fri Oct 03, 2008 1:07 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Oct 03, 2008 10:05 pm    Post subject:
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    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
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
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


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