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

compare two files


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

New User


Joined: 15 Jul 2010
Posts: 8
Location: chennai

PostPosted: Thu Jul 15, 2010 5:32 pm
Reply with quote

I have two input files which are in sorted order. I have to compare the two input files and generate the two output files.

Note:Account is the key field.

Output1:The output file 1 contain the records from file 2 that matchs the key(account) with file1.

Output2:The output file 2 contain the records from file 2 that does not matchs the key(account) with file1.


File1:
-----
Code:
Account   Amount
---------   ---------
101          50
102          60
103          70
105          80


File2:
-----
Code:
Account   Discount   Desc
---------   ---------    ------
101          30          xxxxxx
101          40          yyyyyy
103          70          zzzzzzz
107          80          aaaaaa
108          22          bbbbbb



Output file1:
Code:
Account   Discount   Desc
---------   ---------    ------
101          30          xxxxxx
101          40          yyyyyy
103          70          zzzzzzz


Output file2:
Code:
Account   Discount   Desc
---------   ---------    ------
107          80          aaaaaa
108          22          bbbbbb



Thanks and Regards,
Gayathiri Devi
icon_redface.gif
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 Jul 15, 2010 10:06 pm
Reply with quote

You can use a DFSORT job like the following to 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=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/80)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,3,A),SORTED
  JOINKEYS F2=IN2,FIELDS=(1,3,A),SORTED
  JOIN UNPAIRED,F2
  REFORMAT FIELDS=(F2:1,80,?)
  OPTION COPY
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'B'),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)
/*
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 Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top