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 two files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: compare two files
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 Moderator


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

PostPosted: Thu Jul 15, 2010 10:06 pm    Post subject:
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    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 compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 pm
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


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