Convert 1 byte EBCDIC field to its HEX display value

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
HenryWilson
Premium Member
Premium Member
Posts: 2
Joined: Tue Apr 09, 2013 5:47 am

Convert 1 byte EBCDIC field to its HEX display value

Post by HenryWilson »

Hi,

We have a variable blocked ebcdic file which has been successfully transferred without translation as a binary file to the Datastage (unix) box from a mainframe.

We then read the file using CFF stage, and attempt to transform a selected single byte to the display representation of its hex value. We can see the hex representation of the byte contents as x'99' by viewing the data outside Datastage using od -x <filename> . That is the same as the mainframe hex value so we know that no translation has occurred during file transfer.

We use a very simple C program (function) in a transform stage to consume the single byte and write out two bytes using printf %20X.

For example: If a single byte contained x'99' we want to produce characters "99". Equally if x'1A' was presented we would like to see "1A" output.

We can prove that the file contains x'99' in the byte, so we expect x'99' to be presented to the function.

However the function produces "72".

We have checked the offset within the record is correct. So we are reading, and presenting the expected byte.

x'72' is the is the ascii equivalent of ebcdic x'99'. We therefore conclude that the function is being presented with x'72' and not x'99'.

We are presenting the byte to the function as a single byte string. The function reads the contents pointed to by the address, so it should be reading x'99'. However, it appears to be receiving x'72' because that is the value being output.

We are not doing any translation to ascii in the function or anywhere else. We are just using a CFF stage to read the (ebcdic format) file and sending data directly to the transform stage. We want to see "99" output. That is the requirement.

There appears to be a byte translation to ascii occurring somewhere after the initial CFF read and before the transform and we do not understand why. There is nothing else between the two stages !!

Any suggestions will be greatly appreciated.
HenryWilson
Premium Member
Premium Member
Posts: 2
Joined: Tue Apr 09, 2013 5:47 am

Post by HenryWilson »

Solution:
Even though the file is ebcdic, we read it as ascii. This prevents internal translation and when we present a one byte CHAR field to our C program it outputs the hex value as 2 CHAR. e.g. x99 in, "99" out.

For other CHAR fields on the same which we do not required to expose the hex value, we do a field level ebcdic-to-ascii translation on the output link.

Seems a little odd to read an ebcdic file as ascii but this worked for our needs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thank you for posting your solution.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply