MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Merge Similar Rows and write to an output file?!?!?!

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Mon May 30, 2005 8:09 am    Post subject: Merge Similar Rows and write to an output file?!?!?! Reply with quote

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

Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon May 30, 2005 10:20 am    Post subject: Reply with quote

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:

www.ibm.com/servers/storage/support/software/sort/mvs/pdug/

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Tue May 31, 2005 4:14 am    Post subject: Reply with quote

Thanks Frank for your time.

I tried running the JCL, it abended with
S1 - ABEND=S000 U0016 REASON=00000000 188. The SYSOUT has the following Stmt from Syncsort:
Quote:
WER268A OUTFIL STATEMENT : SYNTAX ERROR

I am not very clear in what you explained to use if UFF patch is not applied. Can you make it little more clear how to have the JCL without using UFF.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue May 31, 2005 7:31 am    Post subject: Reply with quote

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.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
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
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE) 
//SYSIN    DD *                                             
  SORT FIELDS=(46,10,CH,A)                                 
  OUTFIL REMOVECC,NODETAIL,                                 
  TRAILER1=('HIGHDATE,''',46,10,C'''')                     
/*                                                         
//STEP0200 EXEC PGM=SYNCTOOL                                 
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                     
//IN       DD *                                             
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
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                             
  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)                           
/*                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Tue May 31, 2005 11:51 pm    Post subject: Reply with quote

Thanks kolusu for your time.

I tried your solution, I got the following error:
Quote:

SYT000I SYNCTOOL RELEASE 1.4C - COPYRIGHT 2002 SYNCSORT INC.
SYT001I INITIAL PROCESSING MODE IS "STOP"

SYT302I SYMNAMES STATEMENTS IN USE
SYT002I "TOOLIN" INTERFACE BEING USED

SPLICE FROM(IN) TO(OUT) ON(1,9,CH) -
WITHEACH WITH(57,1) WITH(58,1) WITH(59,1) WITH(60,1) WITH(61,1) -
USING(CTL1)

SYT005I PERFORM NECESSARY SYMBOL SUBSTITUTION

SPLICE FROM(IN) TO(OUT) ON(1,9,CH) WITHEACH WITH(57,1) WITH(
58,1) WITH(59,1) WITH(60,1) WITH(61,1) USING(CTL1)

SYT048E STATEMENT DOES NOT BEGIN WITH A VALID OPERATOR
SYT030I OPERATION COMPLETED WITH RETURN CODE 12


Does SYT048E imply anything that SPLICE is not supported in my Shop?
SYNCSORT is not recognizing SPLICE??!?!? Any other way of doing this?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jun 01, 2005 8:42 am    Post subject: Reply with quote

Sakreg,

You have an old version of syncsort which does not support the splice operator. The version of synctool which supports splice operator is
Code:

SYNCTOOL RELEASE 1.4D - COPYRIGHT 2003  SYNCSORT INC.


So you are better off coding a pgm

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Thu Jun 02, 2005 2:34 am    Post subject: Reply with quote

That would be the only way I think.

Thanks Guys for all your valuable time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group