Page 1 of 1

how to separate set of records using DFSORT

PostPosted: Wed Nov 11, 2009 3:53 pm
by radhika_engimuri
Hi

I need help in sorting out below input

My Input data looks like

001Haaaa3 --- H in 4th postion is for header
002Daaaa ---- D in 4th position is for detail
003Daaaa
004Hbbbb1
005Dbbbb
006Dbbbb
007Hcccc3
008Dcccc
009Dcccc
010Heeee1
011Deeee
012Deeee


My output should have set of records which has '3' in postion 9

Ex:
001Haaaa3
002Daaaa
003Daaaa
007Hcccc3
008Dcccc
009Dcccc

Thanks in advance,
Radhika

Re: how to separate set of records using DFSORT

PostPosted: Wed Nov 11, 2009 11:13 pm
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 *
001Haaaa3
002Daaaa
003Daaaa
004Hbbbb1
005Dbbbb
006Dbbbb
007Hcccc3
008Dcccc
009Dcccc
010Heeee1
011Deeee
012Deeee
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(4,1,CH,EQ,C'H'),
    PUSH=(81:9,1))
  OUTFIL INCLUDE=(81,1,CH,EQ,C'3'),BUILD=(1,80)
/*