IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

CSV to FB format conversion


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Sat Jun 04, 2011 3:30 pm
Reply with quote

I need to convert the Comma Separated Values format to FB format. The requirement :-

Input file :-

Code:
439991735,11160,1   
479819099,11218,1   
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96



Expected output :-

Code:
011160 439991735 0000000000100
011218 479819099 0000000000100
011408 209043099 0000000000139
012001 016256299 0000000000319
012001 016320799 0000000001096



I have coded the below code :-

Code:
//SYSIN    DD *                                   
  OPTION COPY                                     
  OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),     
                %02=(ENDBEFR=C',',FIXLEN=06),     
                %03=(ENDBEFR=C',',FIXLEN=13)),     
         BUILD=(1:%02,SFF,EDIT=(TTTTTT),           
            08:%01,SFF,EDIT=(TTTTTTTTT),           
            018:%03,SFF,EDIT=(TTTTTTTTTTTTT),     
            80:X)                                 
/*                                                 




I have getting the below output which is not correct icon_sad.gif


Code:
011160 439991735 0000000000001   -- WRONG
011218 479819099 0000000000001   -- WRONG
011408 209043099 0000000000139
012001 016256299 0000000000319
012001 016320799 0000000001096



Please let me know how do i get the expected output.

Thank You,
Rajat
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jun 04, 2011 3:52 pm
Reply with quote

you are going to have to perform some type of inrec overlay to add a '.00' to any record that does not have a '.'.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Sun Jun 05, 2011 11:34 am
Reply with quote

Hello,

Thank's for the suggestion, this would work but please let me know how do i achieve this as the position of '.' is variable, how do i search my third column of the below Input file and then overlay '.00' if '.' is not present at the end.

Input :-

Code:
439991735,11160,1   
479819099,11218,1   
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96


Expected output :-

Code:
439991735,11160,1.00   >> corrected   
479819099,11218,1.00   >> corrected             
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96



Thank You,
Rajat
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Sun Jun 05, 2011 1:00 pm
Reply with quote

Hello,

I just figured out a solution myself as per the initial requirement, i coded below to achieve it.

Code:
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),                     
                %02=(ENDBEFR=C',',FIXLEN=06),                     
                %03=(ENDBEFR=C'.',FIXLEN=11),                     
                %04=(ENDBEFR=C',',FIXLEN=02)),                     
         BUILD=(1:%02,SFF,EDIT=(TTTTTT),                           
            08:%01,SFF,EDIT=(TTTTTTTTT),                           
            018:%03,SFF,EDIT=(TTTTTTTTTTT),29:%04,ZD,EDIT=(TT),   
            80:X)                                                 
/*                                                                 



But would definately like to know how to achieve what dbzTHEdinosauer
mentioned in his above post.

Thank You,
Rajat
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jun 05, 2011 3:02 pm
Reply with quote

rajatbagga wrote:

[...]

Code:

439991735,11160,1   
479819099,11218,1   
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96



Expected output :-

Code:
011160 439991735 0000000000100
011218 479819099 0000000000100
011408 209043099 0000000000139
012001 016256299 0000000000319
012001 016320799 0000000001096



I have coded the below code :-

Code:
//SYSIN    DD *                                   
  OPTION COPY                                     
  OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),     
                %02=(ENDBEFR=C',',FIXLEN=06),     
                %03=(ENDBEFR=C',',FIXLEN=13)),     
         BUILD=(1:%02,SFF,EDIT=(TTTTTT),           
            08:%01,SFF,EDIT=(TTTTTTTTT),           
            018:%03,SFF,EDIT=(TTTTTTTTTTTTT),     
            80:X)                                 
/*                                                 


[...]


Why 9 T's for %1 when you have said FIXLEN=10?

I'm looking at a manual. Searching for "Middle=Quincy" gets you to an example which might help. Application Guide "book" for DFSORT, following link from STICKY at top of forum.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 06, 2011 3:48 am
Reply with quote

Rajat,

The problem you actually have with your field is that it can contain two different types of data. One type is a numeric type, an integer with no decimal places. The other is an alphanumeric representation of a number with two decimal places. Although this can obviously happen on files, and has many millions of times, to my mind there should be something external to this actual piece of data which tells you which is which. Otherwise, you have a self-referential validation/use of the data, which is asking for trouble.

The easiest way for you to get around this is to get your input file changed (corrected) by whoever produced it. However, the very existence of the file like this shows that whoever produced it is either: lazy; lacks technical skills; has no pride in their own work/system. Or some combination thereof.

If the file is external to your group, there should have been some "sign-off" of the format of the data. So, maybe you have already accepted that it is like that. But, worth a try at getting it changed. Might depend on whose manager has the most clout.

I am sure that on Monday you will get solutions for the existing data. It will be worth understanding those solutions in their own right. I'd try first, though, for your actual solution, to get the data changed so that it is consistent.

Also, is there no possibility of any negative values on your file? Possible. Just wondering.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 199
Location: india

PostPosted: Mon Jun 06, 2011 8:12 am
Reply with quote

Quote:
Why 9 T's for %1 when you have said FIXLEN=10?


Thank You Bill, Yes it should be FIXLEN=09, i corrected it.

Quote:
Also, is there no possibility of any negative values on your file?


Nope, the data will not have negative values.

And the CSV file is produced from the process which runs in a UNIX system , i have notified them, but not sure if they can do something
on formating the data in CSV file.

Thank You,
Rajat
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top