Compare 2 I/P files and write mismatch record in oneO/P file

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
surindersingh
Member
Posts: 5
Joined: Thu Aug 08, 2013 1:58 pm

Compare 2 I/P files and write mismatch record in oneO/P file

Post by surindersingh » Mon Aug 12, 2013 11:28 am

I have a requirement where i have to compare 2 input files and incase of any mismatch record in any of the two input files i have to write records from both the files into one output file.

In other words, only one output file should contain two rows for each mismatched rows. Row from first file and then a row from second file in case on mismatch.

I know for comparison we can use JOINKEYS and JOIN UNPARED, but not able to achieve the above requirement.

If anyone did same thing before please share with me or provide any inputs which can help to achieve this requirement.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Mon Aug 12, 2013 12:10 pm

This would give you two fixed-length (80) output records from the same input (your REFORMAT record).

Code: Select all

  OUTFIL BUILD=(1,80,/,81,80)
Have a look in the manual for the "/" (the slash operator) on OUTFIL BUILD.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon Aug 12, 2013 11:52 pm

If the 2 files have a mis-match, how will there be 2 records to write into the output?
Have a good one

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Tue Aug 13, 2013 2:03 pm

Please provide bit more clarity on your requirement.

Are the two files having same number of records? and each record from file1 should be compared with the same numbered/positioned record of other file. Say 10th record of file1 should be compared with 10th record of file 2? 11th to 11th and so on....?
Guru:-)

You're never fully dressed without a smile :)

surindersingh
Member
Posts: 5
Joined: Thu Aug 08, 2013 1:58 pm

Post by surindersingh » Wed Aug 14, 2013 1:32 pm

Yes, the two files having same number of records and each record from file1 should be compared with the same numbered/positioned record of other file.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Aug 14, 2013 1:59 pm

In JNF1CNTL and JNF2CNTL generate a sequence number and append/preprend (depending on RECFM). Use the sequence number as the JOINKEYS key.

Pay attention to my previous post, which is accidently relevant.

trushant
Member
Posts: 17
Joined: Thu Sep 12, 2013 5:21 pm

Post by trushant » Thu Sep 12, 2013 6:19 pm

try this for unmatch records

//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(139,18,A,
99,12,A,264,08,A)
JOINKEYS FILES=F2,FIELDS=(1,18,A,
23,12,A,40,08,A)
JOIN UNPAIRED,F2,ONLY
SORT FIELDS=COPY
END
/*

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others