Page 1 of 1

Want to exclude constants from SORT (but keep the data)

PostPosted: Fri Nov 09, 2007 11:02 pm
by D9988
I'm sorting a work file by 2 fields:

//SYSIN DD *
SORT FIELDS=(1,2,CH,A,5,8,CH,A),
FILSZ=E10000

I want to exclude any lines that have '**' in positions 1-2 from being sorted. These lines are currently at the bottom of the work file and I want to keep them there. They currently get included in the sort and moved to the top of the output file.

I tried excluding it with "INCLUDE COND" but that removes the data completely. Is it possible to keep the data, but have the SORT ignore it so that it does not get included in the sort?

Re: Want to exclude constants from SORT (but keep the data)

PostPosted: Sat Nov 10, 2007 2:41 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=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
BB000001
CC000005
AA000004
AA000002
RR000000
RR000005
RR000003
** 3
** 2
** 1
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),
        IFTHEN=(WHEN=(1,2,CH,EQ,C'**'),
          OVERLAY=(81:C'1',82:SEQNUM,8,PD))
  SORT FIELDS=(81,1,CH,A,82,8,PD,A,1,2,CH,A,5,8,CH,A),
    FILSZ=E10000
  OUTREC BUILD=(1,80)
/*


SORTOUT would have:

AA000002
AA000004
BB000001
CC000005
RR000000
RR000003
RR000005
** 3
** 2
** 1

Re: Want to exclude constants from SORT (but keep the data)

PostPosted: Sat Nov 10, 2007 4:50 am
by D9988
Works great, thanks Frank 8-)