compare two files and write duplicate records to file no dup

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
mainframeman
Member
Posts: 4
Joined: Sat Dec 09, 2006 7:22 am

compare two files and write duplicate records to file no dup

Post by mainframeman » Tue Dec 19, 2006 9:33 pm

I want to be able to compare two files(file A and file B) and write the unique (non-matching) records from file A to an output file (file C) and duplicate records to another file (file D). File D needs to be in a report format. There also has be be another file (File E) that is a exact copy of File B. I know that ICETOOL can do something like this but not sure of the syntax


input:

File A:

AAA1111
BBB2222
CCC333
DDD444

File B:

AAA111
BBB222
EEE555
FFF666
GGG777


OUTPUT FILES:


FILE C:

CCC333
DDD444


File D: Report file (133 bytes long)

I need a header that will print at the top of every page

layout like this: this will be 133 bytes long

company: xxxx page: xxx
Application: xxx date: xx/xx/xx
JOB: xxxx
REPORT: Dropped records due to customer code mismatch


AAA111 (detail records)
BBB222


File E:

AAA111
BBB222
EEE555
FFF666
GGG777

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

Post by Frank Yaeger » Tue Dec 19, 2006 10:33 pm

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your "key" was in positions 1-6, and your input files have RECFM=FB and LRECL=80. You can change the job appropriately if those assumptions are incorrect.

Code: Select all

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//FILEA DD DSN=...  input fileA (FB/80)
//FILEB DD DSN=...  input fileB (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//FILEC DD DSN=...  output fileC (FB/80)
//FILED DD DSN=...  output fileD (FBA/133)
//FILEE DD DSN=...  output fileE (FB/80)
//TOOLIN DD *
COPY FROM(FILEA) TO(T1) USING(CTL1)
COPY FROM(FILEB) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(FILEC) ON(1,6,CH) NODUPS -
  DISCARD(FILED) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:C'A')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:C'B')
  OUTFIL FNAMES=T1
  OUTFIL FNAMES=FILEE,BUILD=(1,80)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=FILEC,INCLUDE=(81,1,CH,EQ,C'A'),
    BUILD=(1,80)
  OUTFIL FNAMES=FILED,INCLUDE=(81,1,CH,EQ,C'A'),
    HEADER2=(8:'company: xxxx',76:'page:  ',PAGE=(M11,LENGTH=3),/,
     8:'Application: xxxx',78:'date:  ',DATE,/,
     8:'JOB:   xxxx',/,
     8:'REPORT:  Dropped records due to customer code mismatch',
     X,/,X),
    BUILD=(1,80,132:X)
/*
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

mainframeman
Member
Posts: 4
Joined: Sat Dec 09, 2006 7:22 am

icetool quesitons

Post by mainframeman » Tue Dec 19, 2006 11:17 pm

Frank,

My input files are:

File A: RECFM=FB and LRECL=150
File B: RECFM=FB and LRECL=13

The key field is 13 bytes long. This is what I will use to match records from the two files


output file:

File C: RECFM=FB and LRECL=150
File D: RECFM=FB and LRECL=150 - Report
File E: RECFM=FB and LRECL=13



Is it possbile to sort these two input files(File A and File B) using ICETOOL and then do the processing?

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

Post by Frank Yaeger » Wed Dec 20, 2006 1:53 am

We just need to change the DFSORT/ICETOOL job a little to handle files with those attributes and the 13-byte key as follows:

Code: Select all

//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//FILEA DD DSN=...  input fileA (FB/150)
//FILEB DD DSN=...  input fileB (FB/13)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//FILEC DD DSN=...  output fileC (FB/150)
//FILED DD DSN=...  output fileD (FB/150)
//FILEE DD DSN=...  output fileE (FB/13)
//TOOLIN DD *
COPY FROM(FILEA) TO(T1) USING(CTL1)
COPY FROM(FILEB) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(FILEC) ON(1,13,CH) NODUPS -
  DISCARD(FILED) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(151:C'A')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(151:C'B')
  OUTFIL FNAMES=T1
  OUTFIL FNAMES=FILEE,BUILD=(1,13)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=FILEC,INCLUDE=(151,1,CH,EQ,C'A'),
    BUILD=(1,150)
  OUTFIL FNAMES=FILED,REMOVECC,INCLUDE=(151,1,CH,EQ,C'A'),
    HEADER2=(8:'company: xxxx',76:'page:  ',PAGE=(M11,LENGTH=3),/,
     8:'Application: xxxx',78:'date:  ',DATE,/,
     8:'JOB:   xxxx',/,
     8:'REPORT:  Dropped records due to customer code mismatch',
     X,/,X),
    BUILD=(1,150)
/*
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

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 11:02 pm

<< Content deleted By Admin >>

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