Integrate BASIC file reading with other component

Do you have features you'd like to see in future releases of DataStage, MetaStage, Parameter Manager, Version Control or one of the other tools represented on this forum? Post your ideas here!

Moderators: chulett, rschirm

Post Reply
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Integrate BASIC file reading with other component

Post by PhilHibbs »

You can write a Server Job that is just a BASIC program that reads a binary file and spits out a text file that DataStage can then read with a Sequential File component. The Server Job canvas is blank, and can't hold any other components.

:idea: What I would like is a "BASIC Code" component that contains the code to read a custom file format, but which outputs on a link. The component would hold the output format, which would generate something like an array structure that the BASIC code could write to, with a "send" command to send the completed structure to the output link.

Maybe a matching pair, "BASIC Reader" and "BASIC Writer" would be good.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard! :D

Can you be a bit more detailed with your specification?

The easy solution would be to construct a shared container containing a Sequential File stage and an output link. The Sequential File stage can specify a Filter command; this could (perhaps) achieve your binary-to-text conversion.

Why does it have to be BASIC?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

ray.wurlod wrote:Why does it have to be BASIC?
It doesn't, I'd rather write it in Perl! :wink:
I am suggesting an enhancement (or replacement for) the existing facility to write a Server Job that is entirely implemented in BASIC. The Sequential File component does not appear to be capable of processing a file that does not have line terminators, the only way to process these files is to make a Server Job that reads the file and writes to an output file. What I believe would be a more useful method would be to read the file using BASIC and output it to a link.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

PhilHibbs wrote:The Sequential File component does not appear to be capable of processing a file that does not have line terminators
Sure it can. Set 'Terminators' to 'None' and then ensure your Display metadata is correctly sized.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The project on which I'm currently working uses solely unterminated text files. The line terminator property is on the Stage tab in the Sequential File stage.

Its only requirement is (obviously) that the records are in fixed width format. It's OK that there are multiple record formats (as we have here) but they must all contain the same number of characters. And the total of the display widths in the Columns metadata on the Output link must be the same as this record length. (This is what Craig was alluding to.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

chulett wrote:Sure it can. Set 'Terminators' to 'None' and then ensure your Display metadata is correctly sized.
So have you ever needed to write a "Job Control" procedure that opens a file via a filehandle and writes out to another handle? Can you think of a file type of file that would need this?
Phil Hibbs | Capgemini
Technical Consultant
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, I've done this, but without writing any code, using Sequential File stages in some cases, and using an after job subroutine (ExecSH) to execute a UNIX mv command in other cases (move file once processed).
If you're needing to interact with some other application, you may find the capacity of the Sequential File stage to use named pipes useful.
If you really believe you need to code this please reconsider. If you still want to do it in code, check the BASIC manual for the statements OpenSeq, ReadBlk, WeofSeq, WriteBlk and CloseSeq.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

ray.wurlod wrote:If you really believe you need to code this please reconsider.
No, I'd really rather not! I was told on the course that the Sequential File stage couldn't handle fixed-length binary records, and we did an exercise that read a fixed-length file using file handles. This suggestion is an improvement for that process, but if you're saying it's unnecessary, then that's great!
Phil Hibbs | Capgemini
Technical Consultant
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Phil,

I believe that anytime you feel that something would be useful from a developer standpoint then you should pursue the idea. There is a place on the Ascential eServices site to enter enhancement requests. These requests get prioritized and you never know.... one day they may make it into the toolset. Much of the functionality within the current toolset comes from just these types of ideas.

What's the worst thing Ascential can say.... no and then you're back to where you were, but you tried.

Regards,
Post Reply