Page 1 of 1

SORT the INFILE by hierarchy

PostPosted: Thu Sep 11, 2008 7:52 pm
by ram23bal
hi ,

I have an infile of record length 332. in which byte 330 will have L,T, M, D, A, Z,N,P

I need a output file which will be sorted in the order of N,L,P,T,M,D,A,Z.

Re: SORT the INFILE by hierarchy

PostPosted: Tue Sep 16, 2008 11:23 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  ALTSEQ CODE=(D500,D301,D702,E303,D404,C405,C106,E907)
  SORT FIELDS=(330,1,AQ,A)
/*

Re: SORT the INFILE by hierarchy

PostPosted: Wed Sep 17, 2008 3:03 pm
by ram23bal
MR Frank Yaeger

Can you please explain what you have posted.

Iam unable to get the JCL.

Re: SORT the INFILE by hierarchy

PostPosted: Wed Sep 17, 2008 9:20 pm
by Frank Yaeger
SORT FIELDS=(330,1,AQ,A)

Sorts the byte at position 330 according to the alternate collating sequence indicated by the ALTSEQ statement.

ALTSEQ CODE=(D500,D301,D702,E303,D404,C405,C106,E907)

Sets the alternate collating sequence as follows:

X'D5' (C'N') is collated as X'00'.
X'D3' (C'L') is collated as X'01'.
X'D7' (C'P') is collated as X'02'.
X'E3' (C'T') is collated as X'03'.
X'D4' (C'M') is collated as X'04'.
X'C4' (C'D') is collated as X'05'.
X'C1' (C'A') is collated as X'06'.
X'E9' (C'Z') is collated as X''07'.

So 'N' in position 330 is sorted first, then 'L', and so on.

Thus, the order of the records sorted by position 330 is N,L,P,T,M,D,A,Z.

Re: SORT the INFILE by hierarchy

PostPosted: Fri Sep 19, 2008 8:18 am
by ram23bal
Hey Frank...

Thanks a lot yaar.... It works like a charm.... :D