|
View previous topic :: View next topic
|
| Author |
Message |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| 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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|