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 

insert a row in a file using sort

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


Joined: 09 Nov 2005
Posts: 6
Topics: 3

PostPosted: Mon Oct 09, 2006 10:23 am    Post subject: insert a row in a file using sort Reply with quote

Hi,
how can the below task can be done using sort/icetool?
input data:
aaaa
aaaa
bbbb
bbbb
bbbb
cccc
cccc
cccc
cccc

data tag needs to be included before bbbb row starts and after bbbb row ends.

output data:
aaaa
aaaa
data
bbbb
bbbb
bbbb
data
cccc
cccc
cccc
cccc

I want this to be done without splitting the file data. I want this to be done like read through each row and when bbbb row starts put "data" tag and when it ends put "bbbb" tag without actually splitting data using sort/icetool.

is it possible to do this?
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 Oct 09, 2006 11:19 am    Post subject: Reply with quote

Can we use before the start of the first 'cccc' row, instead of after the end of the last 'bbbb' row, to identify where the second data tag goes?

If not, are there always three bbbb records or can there be a different number of bbbb records? Is it always the second group of records you want the data tags around? I'm looking for more information about the pattern here that we can use.
_________________
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
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Oct 09, 2006 11:55 am    Post subject: Reply with quote

ikumar,

Try this DFSORT/ICETOOL job.

Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                         
AAAA                                                     
AAAA                                                     
BBBB                                                     
BBBB                                                     
BBBB                                                     
CCCC                                                     
CCCC                                                     
CCCC                                                     
CCCC                                                     
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                         
  SORT FROM(IN) USING(CTL1)                             
  COPY FROM(T1) USING(CTL2)                             
//CTL1CNTL DD *                                         
  SORT FIELDS=(1,4,CH,A)                                 
  OUTFIL FNAMES=T1,REMOVECC,                             
  SECTIONS=(1,4,                                         
  HEADER3=(C'DATA',1,4,80:X),                           
  TRAILER3=(C'DATA',1,4,80:X))                           
/*                                                       
//CTL2CNTL DD *                                         
  INREC IFTHEN=(WHEN=(1,8,CH,EQ,C'DATABBBB'),           
       OVERLAY=(5:4X))                                   
  OUTFIL FNAMES=OUT,                                     
  OMIT=(1,4,CH,EQ,C'DATA',AND,5,4,CH,GT,C' ')           
/*                                                       


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
ikumar
Beginner


Joined: 09 Nov 2005
Posts: 6
Topics: 3

PostPosted: Mon Oct 09, 2006 11:23 pm    Post subject: Reply with quote

Hi Kolusu,
I tried your solution but it did not work out for me. It seems, i do not have latest icetool PTFs as it is throwing error at IFTHEN and OVERLAY statements. Is it possible to do without using those statements?

Hi Frank,
I want to have the data tag only before and after bbbb. Any number of bbbb data lines can be present and it may not always be second group.

Thanks,
kumar
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Oct 10, 2006 8:51 am    Post subject: Reply with quote

Quote:

Hi Kolusu,
I tried your solution but it did not work out for me. It seems, i do not have latest icetool PTFs as it is throwing error at IFTHEN and OVERLAY statements. Is it possible to do without using those statements?


ikumar,

You need to post the exact error messages, so that we can help you.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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