Page 1 of 1

Creating Dynamic sort card using sort

PostPosted: Thu Jan 21, 2010 7:17 pm
by Ranjana
Hi,

I have a below requirement,

Need to create a sort card dynamically which should have value from the input file which is created in the previous step.
Sort card should be in the below format,
SORT FIELDS=COPY
'INCLUDE COND=(68,9,CH,EQ,C,'XXXXXXXXX',or,
68,9,CH,EQ,C,'XXXXXXXXX',or,
.
.
.)

Where 'XXXXXXXXX' value should populate from the input file as said earlier. Value is in position 3 of input file.
one important thing is there may be any number of records in the input file.

Eg:

Input file data:
ABC456345645
DER456345875
ANJ926195280
AJU567234768

there can be more than four records or less than four recorrds also there may empty file.

Please let me know how to create dynamic sort card.

Thx in advance:-)

Re: Creating Dynamic sort card using sort

PostPosted: Fri Jan 22, 2010 12:06 am
by Frank Yaeger
Here's a DFSORT job that will do what you asked for. It appears that your 9-byte fields starts in position 4, not position 3 so I used 4. If it's actually position 3, use 3 instead of 4 in the BUILD line.

//S1   EXEC  PGM=SORT
//SYSOUT   DD  SYSOUT=*
//SORTIN DD *
ABC456345645
DER456345875
ANJ926195280
AJU567234768
//SORTOUT DD DSN=&&C1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=('  SORT FIELDS=COPY ',/,
      '  INCLUDE COND=(1,1,BI,NE,1,1,BI,OR,'),
    BUILD=(C'  68,9,CH,EQ,C''',4,9,C''',OR,',80:X),
    TRAILER1=('  1,1,BI,NE,1,1,BI)')
/*
//S2  EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN  DD DSN=&&C1,DISP=(OLD,PASS)


The DFSORT controls statements in &&C1 will be as follows:

  SORT FIELDS=COPY
  INCLUDE COND=(1,1,BI,NE,1,1,BI,OR,
  68,9,CH,EQ,C'456345645',OR,
  68,9,CH,EQ,C'456345875',OR,
  68,9,CH,EQ,C'926195280',OR,
  68,9,CH,EQ,C'567234768',OR,
  1,1,BI,NE,1,1,BI)

Re: Creating Dynamic sort card using sort

PostPosted: Fri Jan 22, 2010 9:53 am
by Ranjana
Thanks a lot :) ..Ill check and let u know

Re: Creating Dynamic sort card using sort

PostPosted: Fri Jan 22, 2010 9:56 am
by Ranjana
Franks,

There is a condition that we should not use program ICETOOL, only SORT.
Is it possible??

Thx,
Ranjana

Re: Creating Dynamic sort card using sort

PostPosted: Fri Jan 22, 2010 10:02 am
by dick scherrer
Hello,

Why is ICETOOL mentioned?

Frank's solution uses PGM=SORT which is the sort which meets the "only SORT condition".

Re: Creating Dynamic sort card using sort

PostPosted: Fri Jan 22, 2010 10:18 am
by Ranjana
Dick,
Thx and u are correct!!

Frank,
It is working perfect.. thanks a lot :)

Ranjana

Re: Creating Dynamic sort card using sort

PostPosted: Fri Jan 22, 2010 10:45 am
by dick scherrer
You're welcome :)

d