how to match the two files, one sorted and other not

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Parul Singh
Member
Posts: 2
Joined: Fri Feb 13, 2009 11:32 am
Location: noida

how to match the two files, one sorted and other not

Post by Parul Singh » Fri Feb 13, 2009 11:46 am

There are two files. one sorted and other not. Data in files are like

1st file:(not sorted)
---+----1----+----2----+----3----+----4----+----5----+----6----+----7-
LAL116936 *A 02-01-09 12 69.90 24.54 94.44
A101903604 0 01-20-09 01 11.71 0.00 11.71
A102079125 0 02-01-09 03 66.18 0.00 66.18
C101234969 0 02-01-09 12 33.00 0.00 33.00
C101235138 0 02-01-09 12 32.03 0.00 32.03
C101235227 0 02-01-09 12 18.12 0.00 18.12

2nd file: (sorted on these policy no.s)
----+----1
A101762993
A101816689
A101860025
A101903604
A101972621
A102051736

We to match these two reports on the policy no. basis.2nd file contain policy no. only(can be used as key for matching). But 1st contain policy no. along with its some detail. So, we have to create a new file that contain the records of 1st file with added indicator "D" at 14 position (without changing its original format) for those policies which are not present in 2nd file.

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 Feb 13, 2009 8:37 pm

Please show the expected output records for your input example.

What is the RECFM and LRECL of the input files?

In your example, I only see one matching policy number in the two files: A101903604. Is that correct? Is that the example you wanted to show?
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

Parul Singh
Member
Posts: 2
Joined: Fri Feb 13, 2009 11:32 am
Location: noida

Post by Parul Singh » Mon Feb 16, 2009 11:46 am

There are two files. one sorted and other not. Data in files are like

1st file:(not sorted)
---+----1----+----2----+----3----+----4----+----5----+----6----+----7-
LAL116936 *A
A101903604 0
A102079125 0
C101234969 0
C101235138 0
C101235227 0

2nd file: (sorted on these policy no.s)
----+----1
A101762993
A101816689
A101860025
A101903604
A101972621
A102051736

Expected output:
LAL116936 D*A
A101903604 0
A102079125 D 0
C101234969 D 0
C101235138 D 0
C101235227 D 0

We to match these two reports on the policy no. basis.2nd file contain policy no. only(can be used as key for matching). But 1st contain policy no. along with its some detail. So, we have to create a new file that contain the records of 1st file with added indicator "D" at 14 position (without changing its original format) for those policies which are not present in 2nd file.

1st file: (RECFM=FB,LRECL=121,BLKSIZE=12100)
2nd File: (RECFM=FB,LRECL=80,BLKSIZE=800)
output file: (RECFM=FB,LRECL=121,BLKSIZE=12100)

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

Post by Frank Yaeger » Mon Feb 16, 2009 10:15 pm

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed the output records could be in order by the policy number. If the output has to be in the original order, that would require another step.

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/121)
//IN2 DD DSN=...  input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/121)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,10,CH) KEEPNODUPS -
   WITH(14,1) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(14:C'D',122:C'B')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(122:C'V')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(122,1,CH,EQ,C'B'),
    BUILD=(1,121)
/*
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

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