Page 1 of 1

Need help - SORT

PostPosted: Fri Aug 07, 2009 12:46 pm
by tonu1986
I have an input flat file which has "CODENO" in column 1 to6 and in the next line a corresponding "LEVEL" in column 1 to 5.

Sample entries in PS file is like:

CODENO 1234567
LEVEL A
CODENO 2345906
LEVEL B
CODENO 0987567
LEVEL A

I need to fetch all those "CODENO" for which LEVEL should be "A" in the next line. Is this possible through SORT?
Here the two fields which are to be checked dont exist in the same line.
Please suggest?

Re: Need help - SORT

PostPosted: Fri Aug 07, 2009 7:22 pm
by Bill Dennis
If there are always 2 records AND the records are a fixed length (ex. 80 bytes), you could read the file into a sort and specify LRECL=160 on SORTIN. Now the second record is in positions 81 -160 for comparing.

Re: Need help - SORT

PostPosted: Fri Aug 07, 2009 8:31 pm
by Frank Yaeger
tonu1986,

You can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
CODENO 1234567
LEVEL    A
CODENO 2345906
LEVEL    B
CODENO 0987567
LEVEL    A
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(15:1,14))
  OUTFIL INCLUDE=(10,1,CH,EQ,C'A'),BUILD=(15,14)
/*