Page 1 of 1

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

PostPosted: Thu Jan 08, 2015 3:25 pm
by whowillwait4u
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.

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

PostPosted: Thu Jan 08, 2015 3:53 pm
by BillyBoyo
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.

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

PostPosted: Thu Jan 08, 2015 6:39 pm
by whowillwait4u
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