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

Comparing 2 files and writing the unique records in output


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

New User


Joined: 29 Mar 2007
Posts: 10
Location: India

PostPosted: Thu May 17, 2007 6:26 pm
Reply with quote

Hi,
I had two files and i need to bringout the Unique records to the output file .
is it possible todo through a jcl or we need to write a cobol program, if yes can anyone pls let me how can we do throgh the JCL.

Input files:
File 1:
123 abc
456 def
786 ghi
910 jkl
110 mno

File2:
123 abc
786 ghi
110 mno

needs the output file:
456 def
910 jkl



thanks

Ravi
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu May 17, 2007 6:32 pm
Reply with quote

Take a look at this

http://ibmmainframes.com/viewtopic.php?t=20069
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: Thu May 17, 2007 8:25 pm
Reply with quote

For the example you show, you can use this DFSORT/ICETOOL job. But if there are other variations (e.g. records in file2 that are not in file1), the job might have to be modified depending on what you want for output. I assumed your input file has RECFM=FB and LRECL=80 and the "key" was in positions 1-7 - again, the job can be modified as appropriate.

Code:

//S1    EXEC  PGM=ICETOOL                     
//TOOLMSG DD SYSOUT=*                         
//DFSMSG  DD SYSOUT=*                         
//CON DD *                                     
123 abc                                       
456 def                                       
786 ghi                                       
910 jkl                                       
110 mno                                       
//  DD *                                       
123 abc                                       
786 ghi                                       
110 mno                                       
//OUT DD SYSOUT=*                             
//TOOLIN   DD    *                             
SELECT FROM(CON) TO(OUT) ON(1,7,CH) NODUPS     
/*                                             


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
maheshlive

New User


Joined: 17 Mar 2005
Posts: 1
Location: Pune, India

PostPosted: Fri May 18, 2007 12:48 pm
Reply with quote

Do a SORT

provide both files in SORTIN DDName, thereby concat them on the fly.

SYSIN, provide the SORT fields and SUM FIELDS = NONE

Should do the job.
Back to top
View user's profile Send private message
mallem_ravi
Warnings : 1

New User


Joined: 29 Mar 2007
Posts: 10
Location: India

PostPosted: Fri May 18, 2007 3:34 pm
Reply with quote

Hi Frank,
It's working for me, Thanks for your help

Regds
Ravi
Back to top
View user's profile Send private message
mallem_ravi
Warnings : 1

New User


Joined: 29 Mar 2007
Posts: 10
Location: India

PostPosted: Fri May 18, 2007 5:29 pm
Reply with quote

Hi,
The above solution is giving the Unique records by comapring both files, I need the Unique records in first input file only and don't want the unique records in 2nd input file, can anyone let me know how can we handle this, pls see the example

Input files:
File 1:
123 abc
456 def
786 ghi
910 jkl
110 mno

File2:
111 mny
123 abc
786 ghi
110 mno
222 xyz


needs the output file:
456 def
910 jkl

and we dont want the unique records in 2nd file(blue)

Thanks
Ravi
Back to top
View user's profile Send private message
mallem_ravi
Warnings : 1

New User


Joined: 29 Mar 2007
Posts: 10
Location: India

PostPosted: Wed May 30, 2007 6:40 pm
Reply with quote

Hi,
I had a requirement, that I had two files and is having identical keys and size, i need to write the output, from the Unique records from 1st file only, can anybody let me know how can we do using icetool/dfsort.

ex:

Input File1:
TXT456LMN
RET678MNO
FKP789LKJ
RTP324IOU
TYU256RYU


Input File2:

MNN456RTE
ERT678OIU
EDS324MKI


Ouput file:
FKP789LKJ
TYU256RYU
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: Wed May 30, 2007 9:26 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input files have RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
TXT456LMN
RET678MNO
FKP789LKJ
RTP324IOU
TYU256RYU
/*
//IN2  DD *
MNN456RTE
ERT678OIU
EDS324MKI
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(T2) ON(4,3,CH) NODUPS
SORT FROM(T2) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'1',82:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'2',82:8X)
/*
//CTL3CNTL DD *
  INCLUDE COND=(81,1,CH,EQ,C'1')
  SORT FIELDS=(82,8,ZD,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
mallem_ravi
Warnings : 1

New User


Joined: 29 Mar 2007
Posts: 10
Location: India

PostPosted: Thu May 31, 2007 10:48 am
Reply with quote

Frank, it's working fine, thanks a lot
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top