Posted: Mon May 30, 2005 8:09 am Post subject: Merge Similar Rows and write to an output file?!?!?!
Hi,
I have a file that looks like below:
Code:
071000100Data Feed to Mainfram003022005-04-072006-04-071
071000100Data Feed to Mainfram003022005-04-072006-04-07 2
071000100Data Feed to Mainfram003022005-04-072006-04-07 3
071000100Data Feed to Mainfram003022005-04-072006-04-07 4
071000100Data Feed to Mainfram003022005-04-072006-04-07 5
The Output Shd look like:
Code:
071000100Data Feed to Mainfram003022005-04-072006-04-0712345
If the first 7 characters followed by the next 2 characters are same then all the rows satisfying the criteria should be merged to one single row. However the values of the last 5 characters should be retained as shown in the output file.
There would be scenario like this also:- The Date value from 45 to 55 might vary. In that case, in the output write the date which is highest among all the rows.
For E.G., If the Second Row has the date like 2007-04-07,then out put should be:
Code:
071000100Data Feed to Mainfram003022005-04-072007-04-0712345
Hope my explanation makes sense. Help me to do this using the SORT utilities
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon May 30, 2005 10:20 am Post subject:
The tricky part here is getting the highest date in the output record because we can't rearrange the records. Below is a DFSORT/ICETOOL job that will do what you asked for.
You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's new UFF format. If you have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:
If you can't get the Dec, 2004 PTF installed, you could do this without UFF by removing the dashes, getting the MAX with ZD and putting the dashes back.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
* Create DFSORT symbol as follows:
* HIGHDATE,'yyyy-mm-dd'
* where yyyy-mm-dd is the highest date in 46-55.
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('HIGHDATE,''',MAX=(46,10,UFF,EDIT=(TTTT-TT-TT)),C'''')
/*
//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
* Splice the last character from records 2, 3, 4 and 5 into
* record 1. Use HIGHDATE with TRAILER1 to get the highest date
* in 46-55.
SPLICE FROM(IN) TO(OUT) ON(1,9,CH) -
WITHEACH WITH(57,1) WITH(58,1) WITH(59,1) WITH(60,1) -
USING(CTL1)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=OUT,REMOVECC,NODETAIL,
TRAILER1=(1,45,HIGHDATE,56,5)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue May 31, 2005 7:31 am Post subject:
Sakreg,
The error messages indicate that you are using syncsort which does not support the SFF (signed free form numeric) and UFF (unsigned free form numeric) data formats. Try this job.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum