Can DataStage routines write binary files?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
jonathanhale
Premium Member
Premium Member
Posts: 33
Joined: Tue Nov 06, 2007 1:09 pm

Can DataStage routines write binary files?

Post by jonathanhale »

e.g. is there an OPENBIN (or similiar)

how could the below be converted to write an EBCIDIC file?

OPENSEQ seqFile TO FILE THEN NOBUF FILE
ELSE CREATE FILE THEN NOBUF FILE
ELSE STOP
WRITESEQF Ans TO FILE
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What do you mean by 'binary' in this context? And you don't need to convert anything there, simply send it EBCDIC data to write.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, AFAIK you *should* be able to 'just send it' but honestly never had a need to try. Do you have NLS enabled? :?

Also, what are you using to view the file after it is created?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

If you are in UNIX then dd and other commands can convert from ASCII to EBCIDIC. Just write your normal file out then convert later.
Mamu Kim
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's true... if you are producing this for consumption elsewhere (like a mainframe) then you may be able to write it out as normal ASCII and then have the transfer mechanism do the EBCDIC conversion. May be complicated if you have any packed fields, however.
-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 »

There's no OPENBIN, you just use OPENSEQ as normal but you write blocks of bytes using WRITEBLK rather than writing lines using WRITESEQ. You still need to close the file using 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

AHA! There's the secret. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
jonathanhale
Premium Member
Premium Member
Posts: 33
Joined: Tue Nov 06, 2007 1:09 pm

Post by jonathanhale »

Many thanks to all for the replies. I like Ray's idea best :-). I really don't want the o/s to have to tidy up something that datastage can't do. I'm not back on that site for a few days, but I'll update again after I've tested it.
jonathanhale
Premium Member
Premium Member
Posts: 33
Joined: Tue Nov 06, 2007 1:09 pm

Post by jonathanhale »

Sadly, the WRITEBLK seems to have no effect.

Here the Routine Code (can someone spot a foolish error?):

vFilePath = FilePath
vFileName = FileName
Ans = Ebcdic(FileContent)

*Content of the file
seqFile = vFilePath:'/':vFileName
OPENSEQ seqFile TO FILE THEN NOBUF FILE
ELSE CREATE FILE THEN NOBUF FILE
ELSE STOP
WRITEBLK Ans TO FILE
ELSE STOP

I have tried passing Ebcdic value in the FileContent variable, and passing Ascii in FileContent and then converting (as above). (Because something in the back of my mind said you can only pass Ascii to routines?)

Both approaches result in (what I think is) an Acsii attempt to write the Ebcdic:

%z??z???????????????
%z??z???????????????
%z??z?@?@?

The same output as with WRITESEQF.

The Server Job Folder Stage with no NLS and writing the BLOB as LongVarBinary is the only mechanism I can get to work (produce the Ebcdic output fast enough) in this environment.
Post Reply