Merge two files

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
meta123
Member
Posts: 3
Joined: Thu May 07, 2009 12:42 pm

Merge two files

Post by meta123 » Thu May 07, 2009 12:51 pm

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!!

Alissa Margulies
Member
Posts: 25
Joined: Tue Apr 28, 2009 10:53 pm
Location: USA
Contact:

Post by Alissa Margulies » Thu May 07, 2009 7:52 pm

meta123,

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)                                              
/*                                                                  
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.
Alissa Margulies
SyncSort Mainframe Product Services
zos_tech@syncsort.com
201-930-8260

meta123
Member
Posts: 3
Joined: Thu May 07, 2009 12:42 pm

Post by meta123 » Fri May 08, 2009 9:55 am

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!

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri May 08, 2009 3:08 pm

Hi,

You are using DFSORT and not SyncSort; solution provided make use of JOINKEYS which is a SyncSort key-word . . .
Regards,
Anuj

meta123
Member
Posts: 3
Joined: Thu May 07, 2009 12:42 pm

Post by meta123 » Fri May 08, 2009 3:48 pm

Any idea, how to do this with DFSORT? Our admin told me, that we don't have this product (SyncSort).

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri May 08, 2009 5:58 pm

I leave that to Frank or Skolusu, they are much better than me when it comes to DFSORT solutions. Please have patience they will be around soon.

Thanks.

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 May 08, 2009 8:27 pm

meta123,

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

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 10:30 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