Page 1 of 1

Extract selected portion based on certain conditions

PostPosted: Mon Mar 29, 2010 11:22 pm
by dev..
I have a requirement as follows

Input Data
66666 GHFAFSG........
11111 MXTRYRT..........
22222 NNFGHM...........
44444 L....................
33333 ORTHRTHJJ........
66666 R....
77777 S..
11111 T..
33333 G...
55555 W....
88888 R..
11111 D..
66666 S..
77777 A..
33333 B..

I will start extracting weherever i f will ger 11111 and will stop at 33333 ,i.e
My Output will be as follows

11111 MXTRYRT..........
22222 NNFGHM...........
44444 L....................
33333 ORTHRTHJJ........
11111 T..
33333 G...
11111 D..
66666 S..
77777 A..
33333 B..


How can SORT/ICETOOL/FILE-AID BATCH/Any other utlity(Without any program) helps

Re: Extract selected portion based on certain conditions

PostPosted: Tue Mar 30, 2010 4:59 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
66666 GHFAFSG........
11111 MXTRYRT..........
22222 NNFGHM...........
44444 L....................
33333 ORTHRTHJJ........
66666 R....
77777 S..
11111 T..
33333 G...
55555 W....
88888 R..
11111 D..
66666 S..
77777 A..
33333 B..
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'11111'),
    END=(1,5,CH,EQ,C'33333'),PUSH=(81:ID=1))
  OUTFIL INCLUDE=(81,1,CH,NE,C' '),BUILD=(1,80)
/*

Re: Extract selected portion based on certain conditions

PostPosted: Wed Apr 07, 2010 8:11 pm
by dev..
Thanks..it works fine...however in my actual requirement,data will be as follows



....66666 GHFAFSG........
........ 11111 MXTRYRT..........
....22222 NNFGHM...........
......44444 L....................
........33333 ORTHRTHJJ.........
......66666 R....
...77777 S..
.....11111 T..
.......33333 G...
....55555 W....
....88888 R..
......11111 D..
....66666 S..
...77777 A..
.....33333 B..


i.e, that 11111,2222 value may appear in any position within 1 to 80 field(fb)..
Can yor sort card be modified to capture my requirement

Re: Extract selected portion based on certain conditions

PostPosted: Wed Apr 07, 2010 9:37 pm
by Frank Yaeger
Just change the DFSORT control statements to:

  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,80,SS,EQ,C'11111'),             
    END=(1,80,SS,EQ,C'33333'),PUSH=(81:ID=1))                       
  OUTFIL INCLUDE=(81,1,CH,NE,C' '),BUILD=(1,80)