Page 1 of 1

Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 4:24 pm
by porwalrox
Hi,
I'm trying to sort a file into two output files using DFSORT but after submitting, It only sorts fields with key2. Both KEY1 & KEY2 files have same data which satisfies the conditions of OUTFIL FNAMES=KEY2OUT but OUTFIL FNAMES=KEY1OUT is not executing.

//U299060A JOB MSGLEVEL=1,CLASS=A,NOTIFY=&SYSUID,REGION=1
//S1 EXEC PGM=SORT                                       
//SYSOUT DD SYSOUT=*                                     
//SORTIN DD DSN=U299060.DFSRTPS.PDS(EXP1INP),DISP=SHR   
//KEY1OUT DD DSN=U299060.DFSRTOUT.PDS(KEY1),DISP=OLD     
//KEY2OUT DD DSN=U299060.DFSRTOUT.PDS(KEY2),DISP=OLD     
//SYSIN DD *                                             
  OPTION COPY                                           
  OUTFIL FNAMES=KEY1OUT,INCLUDE=(3,4,CH,EQ,C'KEY1'),     
  IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),               
  TRLUPD=(18:COUNT=(M11,LENGTH=8),                       
  33:TOT=(8,4,ZD,M11,LENGTH=6)))                         
  OUTFIL FNAMES=KEY2OUT,INCLUDE=(3,4,CH,EQ,C'KEY2'),     
  IFTRAIL=(HD=YES,TRLID=(1,1,CH,EQ,C'T'),               
  TRLUPD=(18:COUNT=(M11,LENGTH=8),                       
  33:TOT=(8,4,ZD,M11,LENGTH=6)))                         
/*     
My Input file is
H 10/12/2010                         
D KEY1 0100                           
D KEY1 0300                           
D KEY2 0200                           
D KEY2 0050                           
D KEY1 0625                           
D KEY1 0300                           
D KEY2 3000                           
T DEPT AXY COUNT=00000007 TOTAL=004575

& output is same in both files KEY1 & KEY2
H 10/12/2010                         
D KEY2 0200                           
D KEY2 0050                           
D KEY2 3000                           
T DEPT AXY COUNT=00000003 TOTAL=003250


Ridiculous unreadable colour-scheme removed.

Re: Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 4:36 pm
by BillyBoyo
You are outputting simultaneously to two different members on the same, presumably,PDS.

Try outputting to something else (sysout, different flat files) and see.

Re: Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 5:30 pm
by porwalrox
Thanks BillyBoyo! But why this is happening? So is it not possible to sort two files within the same PDS? If it is possible, could you please tell me that how can i achieve this?

Re: Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 5:46 pm
by BillyBoyo
It happens because there is an "index" for the PDS, and one updated copy of an index record can get overwritten with another on close.

Re: Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 5:51 pm
by Robert Sample
It is not possible to create (or update) two members of a PDS in a single step of a batch job. Meditate on how a PDS works and you will understand why.

You can use SORT to create two members of a PDS, but you have to execute SORT twice to do so.

Re: Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 6:14 pm
by porwalrox
Got it, Thank you very much Billy & Robert!

Re: Unexpected output using SORT

PostPosted: Fri Oct 05, 2012 8:35 pm
by skolusu
Porwalrox,

You can't use OUTFIL to write to to 2 PDS members in parallel. You can do that with regular sequential data sets or with PDSE members, but NOT with PDS members. So change your JCL to create sequential files or write to a PDSE

Re: Unexpected output using SORT

PostPosted: Sat Oct 06, 2012 2:27 pm
by porwalrox
Thanks Skolusu for your very helpful answer!