Page 1 of 1

Convert EBCDIC Hexcode to EBCDIC Character

Posted: Mon Dec 15, 2014 10:17 am
by major
Is there any way to convert EBCDIC hexadecimal Code to EBCDIC related character in Datastage?

For example : C9 ---> I

Posted: Mon Dec 15, 2014 11:17 am
by chulett
Can you be more specific as to what you are doing? Typically this would be coming from a flat file and the CFF stage would be used and would translate that for you.

Posted: Mon Dec 15, 2014 11:35 am
by major
Thanks Craig for looking into this.

Requirement : I have a column from DB2 which has converted from Timestamp to Hexadecimal (16). The column has again suppressed into char( 8 ) for the target database (ADABAS) which has EBCDIC charset. Whenever i perform insert in datastage, this column has resulted with the truncation of 8 characters only. I need this 16 character HX to be converted into Binary Coded one. Pls suggest if you have any idea on this.

I'm not doing anything with CFF Stage.

Posted: Mon Dec 15, 2014 12:36 pm
by chulett
Thanks for the clarification. I'm not in a position to be able to help with that, have you checked to see if there are any PX functions that might serve here? Or failing that, a Server function you could leverage in a Server Shared Container, perhaps?

Posted: Tue Dec 16, 2014 1:50 am
by ArndW
As Craig has mentioned, going the BASIC transform stage or server container might be your best choice here. The OCONV() function has a number of conversions that do exactly what you are looking for.

Posted: Tue Dec 16, 2014 2:21 am
by chulett
Exactly what I was thinking of... didn't run off and look up any specifics, however.

Posted: Tue Dec 16, 2014 4:31 pm
by major
Thanks Arnd & Craig. I am trying it make simple as per your suggestions.

I have used Basic transformer to translate the Hex to equivalent EBCDIC character. Below are the steps :

ICONV(VAR, 'MX') -- Returns the Decimal value of the Hex code

Char() -- Returns the equivalent Ascii character value

Ascii() -- Returns the EBCDIC character value.

but I am getting weird results in some of the cases, where C9 returns as Ci (hope so meaning capital I) Instead of 'I' and in some other cases, the special characters were translated as '?'.

Even though the proper NLS setting has been made.

Posted: Wed Dec 17, 2014 1:10 am
by ArndW
Since the functions you are using are all single-byte/single-character based ones, the NLS settings shouldn't play a role.

ASCII(ICONV("C9","MX")) should be "I"

Posted: Wed Dec 17, 2014 11:30 am
by major
Thanks Arnd!.

When i tried with "ASCII(ICONV("C9","MX"))" I'm getting some garbage values instead of 'I'.

I tried with ASCII(Char(ICONV(Arg1,"MX")) -- It returns the value as Ci instead of I.

Is there any options to convert this from EBZeeDIC Hex to EBZeeDic Character?

Thanks
Major

Posted: Thu Dec 18, 2014 1:02 am
by ArndW
I'm away from a datastage machine, but you could use the MCX code to convert your hexadecimal representation to decimal:

ASCII(ICONV(OCONV("C9","MCX"))

Posted: Thu Dec 18, 2014 4:31 pm
by major
Arnd : The OConv and IConv resulted the same number. But when i extract the equivalent character for the decimal to ASCII.. I can able to extract it. But from Ascii to EBCIDIC could not retrieve the exact character.