copy a set of lines with a specific 'string'.



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

copy a set of lines with a specific 'string'.

Postby whowillwait4u » Thu Jan 08, 2015 3:25 pm

Hi,

I have a requirement to search a data set for a specific string and if found copy six lines(starting line in which string is present). This string can be anywhere on the line and if found, it is always followed by 5 lines. these lines may/may not contain the string we searched.
Can this be done using DFSORT/ICETOOL?.

Thanks.
whowillwait4u
 
Posts: 15
Joined: Fri Feb 17, 2012 2:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: copy a set of lines with a specific 'string'.

Postby BillyBoyo » Thu Jan 08, 2015 3:53 pm

Yes.

Be careful how you phrase your questions.

You use a field-type of SS for the entire record, and use that in an IFTHEN=(WHEN=GROUP to PUSH a one byte ID (ID=1) onto all the records of the "group" you establish by coding RECORDS=6. Then OUTFIL OMIT when the extended byte is blank (which will be all records except those six).

Again, post your solution to aid others.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: copy a set of lines with a specific 'string'.

Postby whowillwait4u » Thu Jan 08, 2015 6:39 pm

Thank you very much for the idea. It worked for me. Below is the data card i have used. My input file is 80 LRECL and string being searched is 'ABCDEF' in the example.

 SORT FIELDS=COPY                                       
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,80,SS,EQ,C'ABCDEF'),
               RECORDS=6,PUSH=(81:ID=1))               
 OUTFIL BUILD=(1,80),OMIT=(81,1,CH,EQ,C' ')


Code'd
whowillwait4u
 
Posts: 15
Joined: Fri Feb 17, 2012 2:07 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post