Page 1 of 1

Include row after a string

PostPosted: Sun Jul 10, 2011 1:17 am
by xcspg3
How include all lines after a row containing a string?
The row number of the row that contains the string is variable and I can't use "skiprec" and "stopaft".

The input is
aaa
bbb
ccc
ddd
xxx
eee
fff
ggg

The string is 'xxx'

The output should be
eee
fff
ggg

Thanks

max

Re: Include row after a string

PostPosted: Sun Jul 10, 2011 6:18 pm
by enrico-sorichetti
very quick and dirty, Frank or Kolusu might come up with something better

000004 //S1      EXEC PGM=SORT                                                 
000005 //SYSPRINT  DD SYSOUT=*                                                 
000006 //SYSOUT    DD SYSOUT=*                                                 
000007 //SORTIN    DD *                                                       
000008 AAA                                                                     
000009 BBB                                                                     
000010 CCC                                                                     
000011 XXX                                                                     
000012 EEE                                                                     
000013 FFF                                                                     
000014 GGG                                                                     
000015 HHH                                                                     
000016 III                                                                     
000017 //SORTOUT   DD SYSOUT=*,                                               
000018 //             DCB=(RECFM=FB,LRECL=80)                                 
000019 //SYSIN     DD *                                                       
000020   SORT   FIELDS=COPY                                                   
000021   INREC  IFTHEN=(WHEN=GROUP,BEGIN(1,3,CH,EQ,C'XXX'),                   
000022                  PUSH=(81:ID=1))                                       
000023   OUTFIL INCLUDE=(81,1,CH,EQ,C'1',AND,1,3,CH,NE,C'XXX'),BUILD=(1,80)   
000024 //*

Re: Include row after a string

PostPosted: Sun Jul 10, 2011 10:16 pm
by xcspg3
Thanks a lot

max

Re: Include row after a string

PostPosted: Mon Jul 11, 2011 10:32 pm
by Frank Yaeger
Here's an easier way with DFSORT:

//S1 EXEC PGM=SORT                                                 
//SYSOUT DD SYSOUT=*                                               
//SORTIN DD *                                                       
aaa                                                                 
bbb                                                                 
ccc                                                                 
ddd                                                                 
xxx                                                                 
eee                                                                 
fff                                                                 
ggg                                                                 
//SORTOUT DD SYSOUT=*                                               
//SYSIN DD *                                                       
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=GROUP,END=(1,3,CH,EQ,C'xxx'),PUSH=(81:ID=1))   
  OUTFIL OMIT=(81,1,ZD,EQ,1)                                       

Re: Include row after a string

PostPosted: Fri Jul 15, 2011 4:32 pm
by xcspg3
Thanks

max