Can DataStage routines write binary files?
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 33
- Joined: Tue Nov 06, 2007 1:09 pm
Can DataStage routines write binary files?
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
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
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
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 33
- Joined: Tue Nov 06, 2007 1:09 pm
-
- Premium Member
- Posts: 33
- Joined: Tue Nov 06, 2007 1:09 pm
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.
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.