View previous topic :: View next topic
|
Author |
Message |
mohanrazz
New User
Joined: 30 Sep 2008 Posts: 30 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
mohanrazz
New User
Joined: 30 Sep 2008 Posts: 30 Location: India
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
are you trying to retain 1 of the header records ?
Gerry |
|
Back to top |
|
|
mohanrazz
New User
Joined: 30 Sep 2008 Posts: 30 Location: India
|
|
|
|
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 |
|
|
hchinnam
New User
Joined: 18 Oct 2006 Posts: 73
|
|
|
|
Is there a specific way to identify your header?
or by default first record will be a header. |
|
Back to top |
|
|
hchinnam
New User
Joined: 18 Oct 2006 Posts: 73
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
|