Hi,
I have a situation wherein I am reading Ebcidic data from a CFF stage. 1 of the field is defined as FLAG (PIC(X1)) ie it is read as char(1). This field is being sent to a target sequential file and the data type of this field in the sequential file is "binary" which means the output is expected as combination of 0's and 1's. Is there a way to convert the char to binary data. I know about the oconv function in basic transformer but I have to use the parallel transformer.
Regards,
Shilpa
Character data to binary conversion
Moderators: chulett, rschirm, roy
First I'd convert the Char(1) to a number using "Seq(In.Column)". Now it is a simple loop to convert this to a string of 1's and 0's. Which version of DS do you have, i.e. can you loop in transform stages? If not, then you might have to write a simple c++ function to do this.
Alternatively, since you have a text file source, you could do this with sed / awk / perl or the like, these have inbuilt functions to do this.
Alternatively, since you have a text file source, you could do this with sed / awk / perl or the like, these have inbuilt functions to do this.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Then you can loop through the number constructing its binary equivalent into a string which can be written into a text file.
Iteratively divide the remainder by 2 until there is no remainder, using integer arithmetic.
Iteratively divide the remainder by 2 until there is no remainder, using integer arithmetic.
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.
Re: Character data to binary conversion -- resolved
Hi All,
This issue is resolved. I tried Seq(In.Column) and then used a bitexpand function. It worked.
Just a brief: As I mentioned it was an ebcidic file, I was getting "?" for this column and then when I used a Seq function, it gave me the decimal representation of it which was 26 and after using bitexpand, it gave me the binary form of it --- 11010.
Hence, moving this to resolved.
Regards,
Shilpa
This issue is resolved. I tried Seq(In.Column) and then used a bitexpand function. It worked.
Just a brief: As I mentioned it was an ebcidic file, I was getting "?" for this column and then when I used a Seq function, it gave me the decimal representation of it which was 26 and after using bitexpand, it gave me the binary form of it --- 11010.
Hence, moving this to resolved.
Regards,
Shilpa
The "bitexpand" isn't inside DataStage, is it?
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>