need to get the count of unmatched records from two files

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
thamodharan
Member
Posts: 21
Joined: Tue Oct 21, 2008 4:45 pm
Location: chennai

need to get the count of unmatched records from two files

Post by thamodharan » Fri Jan 01, 2010 1:16 am

Hi,

I have two input files. Both having same LRECL and having only one field. I need to know whether all the records in file2 is there in the file1. If some records in file2 are missing in file1 then I need those records in Output file Or to get the number of output records in output file.

Please give me a solution JCL for the above need...

Thanks in Advance...

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sat Jan 02, 2010 10:06 pm

Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
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

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Mon Jan 04, 2010 1:22 pm

And please let us know if you are using DFSORT or Syncsort or other. To determine if you're using DFSORT (from IBM) or Syncsort (from Syncsort, Inc), run the PGM=ICEMAN JOB, actually any PGM=SORT or PGM=ICEMAN JOB. Look at the SYSOUT output. If it has ICExxxs messages, you're using DFSORT. If it has WERxxxs messages, you're using Syncsort.

Code: Select all

//S1 EXEC PGM=ICEMAN 
//SYSOUT DD SYSOUT=*    <--- look at messages 
//SORTIN DD * 
//SORTOUT DD DUMMY 
//SYSIN DD * 
  SORT FIELDS=COPY 
/*
Regards,
Anuj

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Mon Jan 04, 2010 3:32 pm

Hi Thamotharan,

You can use EASYTRIEVE to solve this issue. Do let me know, if you need any help
in writing EASYTRIEVE code.
Natarajan
Chennai

User avatar
thamodharan
Member
Posts: 21
Joined: Tue Oct 21, 2008 4:45 pm
Location: chennai

Post by thamodharan » Fri Jan 08, 2010 2:52 am

The example files as follows,

File1 File2
10001 10001
10003 10002
10004 10004
10006 10005

after comparing above two files I should get 10002 and 10005 as output. Or we can get the count (i.e. 2) of file2 record that could not be found in file1.

The requirement is to check whether all the records in file2 are there in file1 or not.
And please let me know if you are using DFSORT or Syncsort or other
We are using DFSORT

Natarajan,

Please help me to write EASYTRIEVE code as I am eager but not known the same.


Thanks.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Jan 08, 2010 3:15 am

Here are two ways to do this with DFSORT. The first job uses JOINKEYS which requires that you have the Nov, 2009 DFSORT PTF installed. The second job uses SELECT and does not require that PTF. I assumed your input files have RECFM=FB and LRECL=80, but the jobs can be changed appropriately for other attributes.

JOINKEYS job

Code: Select all

//JK    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//IN1 DD *
10001
10003
10004
10006
//IN2 DD *
10001
10002
10004
10005
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  JOINKEYS F1=IN1,FIELDS=&#40;1,5,A&#41;,SORTED
  JOINKEYS F2=IN2,FIELDS=&#40;1,5,A&#41;,SORTED
  JOIN UNPAIRED,F2,ONLY
  REFORMAT FIELDS=&#40;F2&#58;1,80&#41;
  OPTION COPY
/*
SELECT job

Code: Select all

//SPL  EXEC  PGM=ICETOOL                                               
//TOOLMSG   DD  SYSOUT=*                                               
//DFSMSG    DD  SYSOUT=*                                               
//IN1 DD *                                                             
10001                                                                  
10003                                                                  
10004                                                                  
10006                                                                  
//IN2 DD *                                                             
10001                                                                  
10002                                                                  
10004                                                                  
10005                                                                  
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=&#40;CYL,&#40;5,5&#41;&#41;,DISP=&#40;MOD,PASS&#41;          
//OUT DD SYSOUT=*                                                      
//TOOLIN DD *                                                          
COPY FROM&#40;IN1&#41; TO&#40;T1&#41; USING&#40;CTL1&#41;                                      
COPY FROM&#40;IN2&#41; TO&#40;T1&#41; USING&#40;CTL2&#41;                                      
SELECT FROM&#40;T1&#41; TO&#40;OUT&#41; ON&#40;1,5,CH&#41; NODUPS USING&#40;CTL3&#41;          
//CTL1CNTL DD *                                      
  INREC OVERLAY=&#40;81&#58;C'1'&#41;                            
//CTL2CNTL DD *                                      
  INREC OVERLAY=&#40;81&#58;C'2'&#41;                            
//CTL3CNTL DD *                                      
  OUTFIL FNAMES=OUT,INCLUDE=&#40;81,1,CH,EQ,C'2'&#41;,       
    BUILD=&#40;1,80&#41;                                     
/*        
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
thamodharan
Member
Posts: 21
Joined: Tue Oct 21, 2008 4:45 pm
Location: chennai

Post by thamodharan » Tue Jan 12, 2010 5:10 pm

The Select Job is working fine for me.

Thanks for your assistance!!!

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