Page 1 of 1

Eliminating spaces in Date field

PostPosted: Mon Dec 22, 2008 11:53 am
by dhurai
Hi

I am sorting records based on the first field and also i need sum of third field.At a point of time i got some records in input as follows.


12345 20081210 4500
12345 spaces 1500
12345 20081010 2000


I need a output like this
12345 20081010 8000.

I need to get the non space minimum date and also sum for the last fields.can anyone help me to resolve this?
Thanks in advance..

Re: Eliminating spaces in Date field

PostPosted: Mon Dec 22, 2008 10:40 pm
by Frank Yaeger
Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1    EXEC  PGM=ICEMAN                                       
//SYSOUT    DD  SYSOUT=*                                       
//SORTIN DD *                                                 
12345  20081210  4500                                         
12345            1500                                         
12345  20081010  2000                                         
22345  20081210  4000                                         
22345            1200                                         
22345  20080905  3000                                         
//SORTOUT DD DSN=...  output file (FB/80)                                         
//SYSIN    DD    *                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:8,8)),                   
        IFTHEN=(WHEN=(8,1,CH,EQ,C' '),OVERLAY=(81:8C'9'))     
  SORT FIELDS=(1,5,CH,A)                                       
  OUTFIL REMOVECC,NODETAIL,BUILD=(1,80),                       
    SECTIONS=(1,5,                                             
      TRAILER3=(1,5,                                           
         8:MIN=(81,8,ZD,TO=ZD,LENGTH=8),                       
        17:TOT=(18,4,ZD,M10,LENGTH=5)))                       
/*


SORTOUT would have:

12345  20081010  8000   
22345  20080905  8200