Page 1 of 1

Comma delimited to fixed width space delimited

PostPosted: Mon Aug 09, 2010 3:08 am
by cbrio
Hi,

Can DFSORT reformat a comma delimited file to fixed width space delimited file (where each occurrence of a variable starts in the same position, e.g. ID begins in position 1, last name begins in position 11, first name begins in position 22 and so on?

Input:

231454689,Smith,Mary,02261958
365478965,Harrison,Henry,04191978
365987410,Albertson,Maribel,01232001

Desired result:

231454689bSmithbbbbMarybbb02261958
365478965bHarrisonbbHenrybb12191978
365987410bAlbertsonbMaribelb01232001

(where b=blank)

Thanks.
Cindy

Re: Comma delimited to fixed width space delimited

PostPosted: Mon Aug 09, 2010 9:06 pm
by skolusu
cbrio,

Your input does not match output, especially for the second record. How did the 04191978 transform into 12191978 ? for the last field? Assuming that it is a typo, the following DFSORT JCL will give you the desired results.

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD *                                 
231454689,SMITH,MARY,02261958                   
365478965,HARRISON,HENRY,04191978               
365987410,ALBERTSON,MARIBEL,01232001             
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  SORT FIELDS=COPY                               
  INREC PARSE=(%00=(ENDBEFR=C',',FIXLEN=10),     
               %01=(ENDBEFR=C',',FIXLEN=10),     
               %02=(ENDBEFR=C',',FIXLEN=10),     
               %03=(FIXLEN=10)),                 
        BUILD=(%00,%01,%02,%03)                 
//*


The output from this is

231454689 SMITH     MARY      02261958
365478965 HARRISON  HENRY     04191978
365987410 ALBERTSON MARIBEL   01232001

Re: Comma delimited to fixed width space delimited

PostPosted: Tue Aug 24, 2010 12:41 am
by cbrio
Thank you very much for your help. This is exactly what I was looking for.
Do I correctly assume that the fixlen parameter can be any number I want and does not have to be the same for each field?

Re: Comma delimited to fixed width space delimited

PostPosted: Tue Aug 24, 2010 1:16 am
by Frank Yaeger
Do I correctly assume that the fixlen parameter can be any number I want and does not have to be the same for each field?


Any number you want from 1 to 32752. FIXLEN should be the maximum possible length for each field and can be different for each field.