Page 1 of 1

Copy matching records from 2nd file.

Posted: Tue Jan 27, 2009 9:24 pm
by arrbee
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.

Posted: Wed Jan 28, 2009 1:55 am
by Frank Yaeger
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.

Reply - Here are the details

Posted: Wed Jan 28, 2009 1:52 pm
by arrbee
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.

Posted: Wed Jan 28, 2009 9:05 pm
by Frank Yaeger
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)
/*

Posted: Wed Jan 28, 2009 9:40 pm
by arrbee
Frank, Thanks. I will try it out and let you know.

Posted: Thu Jan 29, 2009 7:28 pm
by arrbee
Frank, Thank you very much. It helped a lot. :D