Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Parse VB CSV ds to an FB ds with fixed length fields

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

Global Moderator


Joined: 10 May 2007
Posts: 1722
Location: UK

PostPosted: Tue Jul 10, 2012 10:54 pm    Post subject: Parse VB CSV ds to an FB ds with fixed length fields
Reply with quote

OK, I have been looking at this for a month or so, searching fora, manuals and the DFSort Tricks but nothing seemed to fit exactly. Today I eventually got a solution. What I would like to know is: is there a better way (apart from using Rexx which took about 15 minutes to design, code and exceute but I am not allowed to implement)?

The problem: extract various fields from a tab-delimited Excel spreadsheet that has been uploaded to the mainframe.

Input VB, 22 columns tab-delimited.
Output FB, 19 columns of fixed lengths.

It was easy to convert from VB to FB. It was also easy to PARSE out the required columns/fields from that FB dataset creating an FB dataset. But that was 2 passes. There had to be a way to do it in one pass but nothing I found would do both. Plenty of examples abound with PARSE of CSVs etc but none of them seemed to convert the file from VB to FB.

This is my solution (showing 3 columns in and 2 out for ease of reference)
Code:

 INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=09),
                %=(ENDBEFR=C' '),           
              %02=(ENDBEFR=C' ',FIXLEN=11)),
          BUILD=(1,4,                       
                 5:%00,                     
                14:%02)
 OPTION COPY 
 OUTFIL STARTREC=2,VTOF,BUILD=(5,20)


As asked above, could it have been done better?

BTW - the STARTREC=2 is to by-pass the record with column headings. I guess that could have been done in the input phase.
Also, assume x'05' in the ENDBEFR=C' ' phrases.
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jul 11, 2012 12:16 am    Post subject: Re: Parse VB CSV ds to an FB ds with fixed length fields
Reply with quote

Nic Clouston wrote:
The problem: extract various fields from a tab-delimited Excel spreadsheet that has been uploaded to the mainframe.

Input VB, 22 columns tab-delimited.
Output FB, 19 columns of fixed lengths.

It was easy to convert from VB to FB. It was also easy to PARSE out the required columns/fields from that FB dataset creating an FB dataset. But that was 2 passes. There had to be a way to do it in one pass but nothing I found would do both. Plenty of examples abound with PARSE of CSVs etc but none of them seemed to convert the file from VB to FB.


Nic Clouston,

I am not really sure as to why you think you need 2 passes of data. You can do it all in a single pass like shown below.
Code:

//SYSIN    DD *                                                 
  OPTION COPY,SKIPREC=1                                         
  INREC PARSE=(%00=(ENDBEFR=X'05',FIXLEN=09),                   
                  %=(ENDBEFR=X'05'),                             
               %02=(ENDBEFR=X'05',FIXLEN=11),                   
               %03=(ENDBEFR=X'05',FIXLEN=12),                   
               %04=(ENDBEFR=X'05',FIXLEN=13),                   
                  %=(ENDBEFR=X'05'),                             
               %06=(ENDBEFR=X'05',FIXLEN=14),                   
               %07=(ENDBEFR=X'05',FIXLEN=15),                   
               %08=(ENDBEFR=X'05',FIXLEN=16),                   
               %09=(ENDBEFR=X'05',FIXLEN=17),                   
               %10=(ENDBEFR=X'05',FIXLEN=18),                   
               %11=(ENDBEFR=X'05',FIXLEN=19),                   
                  %=(ENDBEFR=X'05'),                             
               %13=(ENDBEFR=X'05',FIXLEN=20),                   
               %14=(ENDBEFR=X'05',FIXLEN=21),                   
               %15=(ENDBEFR=X'05',FIXLEN=22),                   
               %16=(ENDBEFR=X'05',FIXLEN=23),                   
               %17=(ENDBEFR=X'05',FIXLEN=24),                   
               %18=(ENDBEFR=X'05',FIXLEN=25),                   
               %19=(ENDBEFR=X'05',FIXLEN=26),                   
               %20=(ENDBEFR=X'05',FIXLEN=27),                   
               %21=(ENDBEFR=X'05',FIXLEN=28)),                   
   BUILD=(1,4,                                                   
          %00,C'|',%02,C'|',%03,C'|',%04,C'|',%06,C'|',%07,C'|',
          %08,C'|',%09,C'|',%10,C'|',%11,C'|',%13,C'|',%14,C'|',
          %15,C'|',%16,C'|',%17,C'|',%18,C'|',%19,C'|',%20,C'|',
          %21,C'|')                                             
                                                                 
  OUTFIL VTOF,BUILD=(5,379)                                     
//*


If that is not what you need please explain with examples of sample input and output
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1722
Location: UK

PostPosted: Wed Jul 11, 2012 12:48 am    Post subject: Reply to: Parse VB CSV ds to an FB ds with fixed length fiel
Reply with quote

Hi Kolusu

Sorry, I inferred that I had eventually got it down to one pass but did not state it specifically!

But, as you can see, your solution is almost identical to mine - as shown in my post. Only differences are: I do not need the '|' between my output fields and I was using start positions whilst building in the INREC phase - also see my post. The SKIPREC on the OPTION record was the answer to my 'BTW' at the end of my post.

So, 2 things to do tomorrow - remove the STARTREC on OUTFIL and replace by SKIPREC on INREC and remove all those start positions. 3 things - update the documentation for the job for whoever has to run it in the future!

Cheers
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 SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 5 Sat Jan 21, 2017 4:02 am
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us