Page 1 of 1

Whats wrong with this DFSORT please

PostPosted: Tue Nov 30, 2010 8:02 pm
by Andyf
I have the following data which
..20101123
....20011113
.*..20501231
.*..20501231
..00737..20011113
..00738..20011113
.æ........@

which I run through DFSORT with parameters

   OPTION COPY                             
   OUTREC IFTHEN=(WHEN=INIT,               
          BUILD=(1,2,PD,M11)),             
      IFTHEN=(WHEN=(1,2,PD,EQ,0),         
          BUILD=(4:3,10)),                 
      IFTHEN=(WHEN=(1,2,PD,EQ,10),         
          BUILD=(4:3,2,PD,M11,5,8)),       
      IFTHEN=(WHEN=(1,2,PD,EQ,15),         
          BUILD=(4:3,2,PD,M11,5,8)),       
      IFTHEN=(WHEN=(1,2,PD,EQ,20),         
          BUILD=(4:3,5,8,2,PD,M11,10,8)), 
      IFTHEN=(WHEN=(1,2,PD,EQ,30),         
          BUILD=(4:3,2,PD,M11,5,10)),     
      IFTHEN=(WHEN=(1,2,PD,EQ,99),         
          BUILD=(4:3,9,PD,M11))           


and get the following output

000 .
010 .
015 .
015 .
020 .
020 .
099 .

which is not the output wanted,

but when I change the sort parameters to the following (which to my mind is the same, but obviously isn't)

  OPTION COPY                                     
  OUTREC IFTHEN=(WHEN=(1,2,PD,EQ,0),             
       BUILD=(1,2,PD,M11,3,10)),               
   IFTHEN=(WHEN=(1,2,PD,EQ,10),                 
       BUILD=(1,2,PD,M11,3,2,PD,M11,5,8)),     
   IFTHEN=(WHEN=(1,2,PD,EQ,15),                 
       BUILD=(1,2,PD,M11,3,2,PD,M11,5,8)),     
   IFTHEN=(WHEN=(1,2,PD,EQ,20),                 
       BUILD=(1,2,PD,M11,3,5,8,2,PD,M11,10,8)),
   IFTHEN=(WHEN=(1,2,PD,EQ,30),                 
       BUILD=(1,2,PD,M11,3,2,PD,M11,5,10)),     
   IFTHEN=(WHEN=(1,2,PD,EQ,99),                 
       BUILD=(1,2,PD,M11,3,9,PD,M11))           


I get the desired output of

00020101123
01000220011113
01500120501231
01500220501231
0200073700120011113
0200073800120011113
09900000000000000007

Question: why the differences, does the IFTHEN=(WHEN=INIT, change the data so that the rest of the IFTHEN commands don't recognise the input, if so can I get around this?

Re: Whats wrong with this DFSORT please

PostPosted: Wed Dec 01, 2010 2:17 am
by Frank Yaeger
Pretty simple. When you use:

   OUTREC IFTHEN=(WHEN=INIT,   
          BUILD=(1,2,PD,M11)), 


you are changing the 2-byte PD value in positions 1-2 to a 3-byte ZD value in positions 1-3.

So after the WHEN=INIT clause, your first record would just have:

000

So the subsequent tests of 1,2,PD,EQ,n will NOT be testing the right value. Instead you'd need to use 1,3,ZD,EQ,n. But you've also lost the rest of the data in the record, so you can't move it. If you want to convert to ZD first, you need to move the rest of the data over to start in position 4. Then you can test for 1,3,ZD,EQ,n and move the data you want from position 4 on.

Re: Whats wrong with this DFSORT please

PostPosted: Wed Dec 01, 2010 2:19 pm
by Andyf
Thank your response, all working now