Page 1 of 1

Sort using PD key

PostPosted: Mon Dec 15, 2008 4:41 pm
by abhi_bhatt2008
Hi all,

I have a file with fields mentioned below:
01 ws-test.
05 ws-test1 pic 9(4) comp-3.
05 ws-test2 pic 9(4) comp-3.
05 ws-test3 pic 9(4) comp-3.
05 ws-test4 pic 9(4) comp-3.

I want to include all those records that matches:
1) first 2 digits of ws-test1 should be '89'
2) first 1 digit of ws-test4 should be '5'

Is it possible?

Please let me know/

Re: Sort using PD key

PostPosted: Mon Dec 15, 2008 9:35 pm
by Frank Yaeger
A pic 9(4) comp-3 value is a 3-byte PD value that looks like this in hex: X'0ddddC'. So based on what you said, for the ws-test1 field you'd want to check for a value like X'089d' in the first two bytes, and for the ws-test4 value, you'd want to check for a value of X'05' in the first byte. Here's a DFSORT job that will do it:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INCLUDE COND=(1,2,PD0,EQ,X'89',AND,10,1,BI,EQ,X'05')
/*