Copy matching records from 2nd file.

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

Copy matching records from 2nd file.

Post by arrbee » Tue Jan 27, 2009 9:24 pm

Hi,

I have one file that appears as given below. It's RECFM=FB & LRECL=80. The key field here starts at 24th column and it's of 6 bytes.

Code: Select all

----+----1----+----2----+----3----+----4----+----5
000001371044800001000001234564800000FLAGP
000001718271300001000001234571300000FLAGP
000001437971600001000001234581600000FDRAG
000002559231300001000001234591300000FLAGP
000000382411300001000001234501300000FLASP
000001121251300001000001234511300000FLASP
000001219272200001000001234522200000FLASP
000001126681300001000001234531300000FLASP
Another file is as given below. It's RECFM=FB and LRECL=160. The key field starts at 26th column and it's of 6 bytes. There are two records for the key (A & B in position 72nd column).

Code: Select all

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
000    BSS0000000000000001234512009                              FLA000A
000    BSS0000000000000001234512009                              FLA000B
000    BST0000000001000001234562009                              FLS000A
000    BST0000000001000001234562009                              FLS000B
000    BSA0000000001000001234502009                              FLS000A
000    BSA0000000001000001234502009                              FLS000B
000    BSR0000000001000001234522009                              FLT000A
000    BSR0000000001000001234522009                              FLT000B
000    BSP0000000001000001234552009                              FLB000A
000    BSP0000000001000001234552009                              FLB000B
000    BSP0000000001000001234542009                              FLB000A
000    BSP0000000001000001234542009                              FLB000B
I want to match File-A key with it's File-B key and copy 'A' records to one file and 'B' records to another file. All other non-matching records should be copied to third file (including both A & B records).

Please help.

Thanks.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

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 Jan 28, 2009 1:55 am

I want to match File-A key with it's File-B key and copy 'A' records to one file and 'B' records to another file. All other non-matching records should be copied to third file (including both A & B records).
Is File-A the first file (with the key at 24)?

Is File-B the second file (with the key at 26)?

Are you saying
- if File-B has an 'A' record with a matching key in File-A, you want to copy that record to output file1
- if File-B has a 'B' record with a matching key in File-B, you want to copy that record to output file2
- otherwise you want to copy the record to output file3

Please show the records in the three output files you expect for your input example.

Also, give the LRECLs you want for the three output files.
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
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

Reply - Here are the details

Post by arrbee » Wed Jan 28, 2009 1:52 pm

Frank, Thanks for the reply.

Here are the details........

1). File-A is the 1st file and File-B is the 2nd file.
2). All the output files will have RECFM=FB and LRECL=160.
3). The outputs appear as given below:

Output-1:

Code: Select all

000    BSS0000000000000001234512009                              FLA000A 
000    BST0000000001000001234562009                              FLS000A 
000    BSA0000000001000001234502009                              FLS000A 
000    BSR0000000001000001234522009                              FLT000A 
Output-2:

Code: Select all

000    BSS0000000000000001234512009                              FLA000B 
000    BST0000000001000001234562009                              FLS000B 
000    BSA0000000001000001234502009                              FLS000B 
000    BSR0000000001000001234522009                              FLT000B 
Output-3:

Code: Select all

000    BSP0000000001000001234552009                              FLB000A 
000    BSP0000000001000001234552009                              FLB000B 
000    BSP0000000001000001234542009                              FLB000A 
000    BSP0000000001000001234542009                              FLB000B 
Hope, I have explained it clearly. Thanks.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

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 Jan 28, 2009 9:05 pm

You can use a DFSORT/ICETOOL job like the following. I assumed your output could be in sorted order. If you really want the output in the original order, that would require more passes.

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/160)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT1 DD DSN=...  output file1 (FB/160)
//OUT2 DD DSN=...  output file2 (FB/160)
//OUT3 DD DSN=...  output file3 (FB/160)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT1) ON(161,6,CH) KEEPNODUPS KEEPBASE -
  WITHALL WITH(1,160) WITH(167,1) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(161:24,6,167:C'BB')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(161:26,6,167:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT1,
    INCLUDE=(167,2,CH,EQ,C'VB',AND,72,1,CH,EQ,C'A'),
    BUILD=(1,160)
  OUTFIL FNAMES=OUT2,
    INCLUDE=(167,2,CH,EQ,C'VB',AND,72,1,CH,EQ,C'B'),
    BUILD=(1,160)
  OUTFIL FNAMES=OUT3,
    INCLUDE=(167,2,CH,EQ,C'VV'),
    BUILD=(1,160)
/*
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
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

Post by arrbee » Wed Jan 28, 2009 9:40 pm

Frank, Thanks. I will try it out and let you know.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

Post by arrbee » Thu Jan 29, 2009 7:28 pm

Frank, Thank you very much. It helped a lot. :D
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

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