Page 1 of 1

need to convert csv into noncsv

PostPosted: Tue Jun 29, 2010 11:34 am
by richagoyal
hi ,

i have a i/p file that is CSV file i want to convert it into noncsv. i am facing a issue in one of the field.

i/p file :
999,222573,4829.94609700308

expected o/p :
999 222573 4829.94610

field3 = 4829.94609 is a S9(13)V9(5)

My JCl :
IFTHEN=(WHEN=(5,3,CH,EQ,C'999'),
PARSE=(%90=(ENDBEFR=C',',FIXLEN=3),
%91=(ENDBEFR=C',',FIXLEN=17),
%92=(ENDBEFR=C',',FIXLEN=19)),
BUILD=(1,4,%90,%91,SFF,TO=PD,LENGTH=9,
(%92,SFF,ADD,+500000),DIV,+1000000, X
TO=PD,LENGTH=10,1053C' '))

its working fine for the above i/p. but field3 format is not constant it can be
i/p file :
999,587378,10367.7517399912

expected o/p:
999 587378 10367.75174

but we are getting
999 587378 1036.77517

But i am not able to get the desired output as we are appling the standard rule for all format.

Re: need to convert csv into noncsv

PostPosted: Tue Jun 29, 2010 10:02 pm
by skolusu
richagoyal,

What is the purpose of the addition and dividing? Are you rounding the decimal? What is the rule for rounding?

Re: need to convert csv into noncsv

PostPosted: Wed Jun 30, 2010 12:49 am
by skolusu
Richagoyal,


Based on the assumption that you need to round the decimal if the 6th decimal byte is greater than 5 , the following DFSORT control cards will give you the desired results.
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                   
  INREC IFTHEN=(WHEN=(5,3,CH,EQ,C'999'),             
  PARSE=(%00=(ENDBEFR=C',',FIXLEN=3),                 
         %01=(ENDBEFR=C',',FIXLEN=17),               
         %02=(ENDBEFR=C'.',FIXLEN=13),               
         %03=(ENDBEFR=C',',FIXLEN=6)),               
  BUILD=(1,4,%00,%01,SFF,TO=PD,LENGTH=9,             
         %02,JFY=(SHIFT=RIGHT),C'.',%03),HIT=NEXT),   

  IFTHEN=(WHEN=(36,1,ZD,GT,5),                       
  OVERLAY=(34:34,2,ZD,ADD,+1,EDIT=(TT)),HIT=NEXT),   

  IFTHEN=(WHEN=ANY,                                   
  OVERLAY=(17:17,19,SFF,PD,LENGTH=10,1053C' '))       
//*

Re: need to convert csv into noncsv

PostPosted: Wed Jun 30, 2010 5:57 pm
by richagoyal
Thanks Skolusu , the solution worked !