combining two input files



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

combining two input files

Postby Manju Venkat » Fri Sep 23, 2011 10:58 am

Requirement :
2 input files-File1 (Previous day file), file2(current day file). Need to compare two file if match found should write the file2 record into to the output file. If unmatched, then write the records from file1 and file2 into same output file. Below are the examples mentioned.

example file 1: example file2:
2222   4                                     2222     4                                     
2222   4                                     2222     4
2223   3                                     2222     5 
2223   3                                     2223     3   
2223   3                                     2223     3
2444   7                                     2555     8

output file should be:
2222   4
2222   4
2222   5
2223   3
2223   3
2444   7
2555   8 

Manju.
Manju Venkat
 
Posts: 16
Joined: Tue Mar 15, 2011 9:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: combining two input files

Postby Frank Yaeger » Fri Sep 23, 2011 10:49 pm

Manju,

It appears you are comparing record by record (e.g. file1 record1 to file2 record1, file1 record2 to file2 record2, etc). If so, then 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 for other attributes. Also, I assumed when the records match you want the file1 record and then the file2 record which means the expected output you show is a bit off (see below).

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
2222   4
2222   4
2223   3
2223   3
2223   3
2444   7
//IN2 DD *
2222   4
2222   4
2222   5
2223   3
2223   3
2555   8
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(81,8,A),SORTED
  JOINKEYS F2=IN2,FIELDS=(81,8,A),SORTED
  REFORMAT FIELDS=(F1:1,80,F2:1,80)
  OPTION COPY
  OUTFIL IFOUTLEN=80,
         IFTHEN=(WHEN=(1,80,CH,EQ,81,80,CH),BUILD=(81,80)),
         IFTHEN=(WHEN=(1,80,CH,NE,81,80,CH),
          BUILD=(1,80,/,81,80))
/*
//JNF1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
/*
//JNF2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
/*


SORTOUT would have:

2222   4
2222   4
2223   3
2222   5
2223   3
2223   3
2444   7
2555   8


Note that the third and fourth records here are from file1 and file2, whereas in your output you show it as file2 and file1 even though you show the reverse for the last two records.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post