Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
CSV to FB format conversion

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 195
Location: india

PostPosted: Sat Jun 04, 2011 3:30 pm    Post subject: CSV to FB format conversion
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: 6968
Location: porcelain throne

PostPosted: Sat Jun 04, 2011 3:52 pm    Post subject:
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: 195
Location: india

PostPosted: Sun Jun 05, 2011 11:34 am    Post subject:
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: 195
Location: india

PostPosted: Sun Jun 05, 2011 1:00 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sun Jun 05, 2011 3:02 pm    Post subject: Re: CSV to FB format conversion
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Jun 06, 2011 3:48 am    Post subject: Reply to: CSV to FB format conversion
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: 195
Location: india

PostPosted: Mon Jun 06, 2011 8:12 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts FTP data transfer from PC to Mainfram... AJAYREDDY All Other Mainframe Topics 8 Wed Aug 23, 2017 9:59 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us