Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Comparing 2 files and writing the unique records in output

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Comparing 2 files and writing the unique records in output
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: 8593
Location: Back in jolly old England

PostPosted: Thu May 17, 2007 6:32 pm    Post subject:
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 Moderator


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

PostPosted: Thu May 17, 2007 8:25 pm    Post subject:
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:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
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    Post subject: Re: Comparing 2 files and writing the unique records in outp
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    Post subject:
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    Post subject:
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    Post subject: Unique records from 1st file neds to be write in the output
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 Moderator


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

PostPosted: Wed May 30, 2007 9:26 pm    Post subject:
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    Post subject:
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    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 Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Where is output from PARM ABEXIT (SNA... packerm CA Products 3 Thu Sep 28, 2017 4:06 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us