Merge two files
Moderators: Frank Yaeger, Moderator Group
Merge two files
Hi everybody,
I have two input-files with following records:
File A (LRECL=55, RECFM=FB, KEY (no duplicate, key field start at 1th column an it's 19 bytes ))
Code:
111111111111111111100004078 M2 51791
222222222222222222200004154 M2 67861
333333333333333333300000096 M2 76481
444444444444444433300000024 M2 43321
File B (LRECL=648, KEY (no duplicate, key field start at 14th column an it's 19 bytes (but not in FH or FT))
Code:
000000001FH..........................................
03460000000021111111111111111111000FPK0420100000 000000000000000000000.........
03460000000032222222222222222222000FPK0420100000 000000000000000000000.........
03460000000043333333333333333333000FPK0420100000 000000000000000000000.........
03460000000054444444444444444333000FPK0420100000 000000000000000000000.........
000000006FT..........................................
Now I want to replace in file B (not FH or FT line), column 44(lenght 5), with column 51(lenght 5)of file A.
Code:
000000001FH..........................................
03460000000021111111111111111111000FPK0420151791 000000000000000000000.........
03460000000032222222222222222222000FPK0420167861 000000000000000000000.........
03460000000043333333333333333333000FPK0420176481 000000000000000000000.........
03460000000054444444444444444333000FPK0420143321 000000000000000000000.........
000000006FT..........................................
Thanks for your help!!
I have two input-files with following records:
File A (LRECL=55, RECFM=FB, KEY (no duplicate, key field start at 1th column an it's 19 bytes ))
Code:
111111111111111111100004078 M2 51791
222222222222222222200004154 M2 67861
333333333333333333300000096 M2 76481
444444444444444433300000024 M2 43321
File B (LRECL=648, KEY (no duplicate, key field start at 14th column an it's 19 bytes (but not in FH or FT))
Code:
000000001FH..........................................
03460000000021111111111111111111000FPK0420100000 000000000000000000000.........
03460000000032222222222222222222000FPK0420100000 000000000000000000000.........
03460000000043333333333333333333000FPK0420100000 000000000000000000000.........
03460000000054444444444444444333000FPK0420100000 000000000000000000000.........
000000006FT..........................................
Now I want to replace in file B (not FH or FT line), column 44(lenght 5), with column 51(lenght 5)of file A.
Code:
000000001FH..........................................
03460000000021111111111111111111000FPK0420151791 000000000000000000000.........
03460000000032222222222222222222000FPK0420167861 000000000000000000000.........
03460000000043333333333333333333000FPK0420176481 000000000000000000000.........
03460000000054444444444444444333000FPK0420143321 000000000000000000000.........
000000006FT..........................................
Thanks for your help!!
-
- Member
- Posts: 25
- Joined: Tue Apr 28, 2009 10:53 pm
- Location: USA
- Contact:
meta123,
Here is a SyncSort for z/OS job that will provide the requested output:
PLEASE NOTE: The position and lengths provided in the original post do not match the sample data. This solution is based solely on the sample data. You will need to modify the code to accomodate your actual requirements.
Here is a SyncSort for z/OS job that will provide the requested output:
Code: Select all
//SORT1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTJNF1 DD *
111111111111111111100004078 M2 51791
222222222222222222200004154 M2 67861
333333333333333333300000096 M2 76481
444444444444444433300000024 M2 43321
//SORTJNF2 DD *
000000001FH..........................................
03460000000021111111111111111111000FPK0420100000 000000000000000000000
03460000000032222222222222222222000FPK0420100000 000000000000000000000
03460000000043333333333333333333000FPK0420100000 000000000000000000000
03460000000054444444444444444333000FPK0420100000 000000000000000000000
000000006FT..........................................
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,19,A)
JOINKEYS FILES=F2,FIELDS=(14,19,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:1,43,F1:32,5,F2:49,32)
INREC IFTHEN=(WHEN=(10,2,CH,EQ,C'FH'),OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(10,2,CH,EQ,C'FT'),OVERLAY=(81:C'9')),
IFTHEN=(WHEN=NONE,OVERLAY=(81:C'5'))
SORT FIELDS=(81,1,CH,A),EQUALS
OUTREC BUILD=(1,80)
/*
Whe I execute this code, I've got this error:
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT P
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5
JOINKEYS FILES=F1, FIELDS=(1,19,A)
Č
ICE005A 0 STATEMENT DEFINER ERROR
JOINKEYS FILES=F2, FIELDS=(14,19,A)
Č
ICE005A 0 STATEMENT DEFINER ERROR
May you help me? Thank you!
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT P
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5
JOINKEYS FILES=F1, FIELDS=(1,19,A)
Č
ICE005A 0 STATEMENT DEFINER ERROR
JOINKEYS FILES=F2, FIELDS=(14,19,A)
Č
ICE005A 0 STATEMENT DEFINER ERROR
May you help me? Thank you!
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
meta123,
Here's a DFSORT/ICETOOL job that will do what you asked for:
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/55)
//IN2 DD DSN=... input file2 (FB/648)
//IN2 DD DSN=&&I2,DISP=(OLD,PASS)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/648)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(649,1,CH) ON(14,19,CH) KEEPNODUPS -
WITH(1,43) WITH(49,600) USING(CTL3)
/*
//CTL1CNTL DD *
INREC BUILD=(14:1,19,44:51,5,649:C'1')
/*
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(649:C'1')),
IFTHEN=(WHEN=(10,2,CH,EQ,C'FH'),OVERLAY=(649:C'0')),
IFTHEN=(WHEN=(10,2,CH,EQ,C'FT'),OVERLAY=(649:C'9'))
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,BUILD=(1,648)
/*
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page