Page 1 of 1

DFSort Range

PostPosted: Fri Apr 29, 2011 7:05 am
by knobi
hello folks, is this situation can be solved with dfsort ??

Input 80fb :
time
------------
00:10:00.000
00:02:00.000
00:00:02.000


Output:

# of records between 0 and 3   =   0002
# of records between 3 and 5   =   0000
# of records higher than   5   =   0001

Re: DFSort Range

PostPosted: Fri Apr 29, 2011 9:11 pm
by skolusu
Knobi,

You need to provide more details. What is the format of the time? HH:MM:SS:nnn ? Is the range every 2 hours ? or 2 mins or 2 secs? Is the time format 12 hour format or 24 hour format?

What is the position of the time field?

Re: DFSort Range

PostPosted: Fri Apr 29, 2011 10:02 pm
by knobi
Position: input file starts on column 1

Time          => (The format is HH:MM:SS.nnn, but can exceed 24 hours)
------------
00:10:00.300
00:02:00.000
00:00:02.012 
30:00:02.010 
20:00:02.010 
08:10:02.009

Output:
# of records between 0 and 3 Min  =   0000002 recs
# of records between 3 and 5 Min  =   0000000 recs
# of records higher than   5 Min  =   0000004 recs

Re: DFSort Range

PostPosted: Sat Apr 30, 2011 12:04 am
by skolusu
Knobi,

It gets a little trickier to insert a missing range. Inorder to capture the missing range records you need to have a dummy record with the range. Create a 80 byte file with the contents shown for INB ddname. Have the range description in pos 20.

Use the following DFSORT JCL which will give you the desired results

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//INA      DD *                                         
00:10:00.300                                             
00:02:00.000                                             
00:00:02.012                                             
30:00:02.010                                             
20:00:02.010                                             
08:10:02.009 
//INB      DD *                                                   
----+----1----+----2----+----3----+----4----+----5----+----6----+--
                   0 AND 3 MIN                                     
                   3 AND 5 MIN                                     
                   5 AND HIGHER                                   
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  JOINKEYS F1=INA,FIELDS=(20,1,A)                                 
  JOINKEYS F2=INB,FIELDS=(20,1,A)                                 
  JOIN UNPAIRED                                                   
  REFORMAT FIELDS=(F1:20,12,F2:20,12,?)
                           
  INREC IFTHEN=(WHEN=(25,1,CH,EQ,C'B'),OVERLAY=(25:C'1')),         
  IFTHEN=(WHEN=(25,1,CH,EQ,C'2'),OVERLAY=(25:C'0'))               
                                                                   
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                           
  SECTIONS=(13,1,                                                 
  TRAILER3=('# OF RECORDS BETWEEN ',13,12,'  =  ',                 
            TOT=(25,1,ZD,M11,LENGTH=7)))                           
//*                                                               
//JNF1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,8,UFF,M11,LENGTH=6)),           
  IFTHEN=(WHEN=INIT,                                               
  OVERLAY=(08:1,2,ZD,MUL,+3600,ADD,3,2,ZD,MUL,+60,ADD,5,2,ZD,     
              M11,LENGTH=8)),                                     
  IFTHEN=(WHEN=(8,8,ZD,LE,180),OVERLAY=(20:C'0 AND 3 MIN ')),     
  IFTHEN=(WHEN=(8,8,ZD,GT,180,AND,8,8,ZD,LE,300),                 
  OVERLAY=(20:C'3 AND 5 MIN ')),                                   
  IFTHEN=(WHEN=NONE,OVERLAY=(20:C'5 AND HIGHER'))
//*