Page 1 of 1

Hex to integer in transfrmer stage

Posted: Wed Feb 16, 2005 1:55 pm
by dsxuserrio
Hello
I have a varchar which has three hexnumbers as input to transformer. I extract each hex number and use them as 3 output fields.

Input : 0000FE00230064


0000FE 0023 0064
fld 1 fld 2 fld 3

Result I need
254 35 100



How can I convert the individual fields to integer values in the transformer??

Thanks for your time and input

Posted: Wed Feb 16, 2005 2:37 pm
by Rboudr2035
Give this a try: ICONV(input[1,6],'MX'):' ':ICONV(input[7,4],'MX'):' ':ICONV(input[11,4],'MX')

Re: Hex to integer in transfrmer stage

Posted: Wed Feb 16, 2005 5:51 pm
by chalasaniamith
this is Radix conversion
MX - converting hexadecimal to decimal

First # : ICONV(input[1,6],'MX')
Second #: ICONV(input[7,4],'MX')
Third #: ICONV(input[11,4],'MX')

use concatenation for all these
ICONV(input[1,6],'MX'):' ':ICONV(input[7,4],'MX'):' ':ICONV(input[11,4],'MX')

Posted: Thu Feb 17, 2005 11:24 am
by dsxuserrio
Hi
I tried that. I am getting the following error message

Link DSLink18, Column DEVICE_CODE: ICONV(DSLink15.DEVICE_CODE,'MX")
Variable 'ICONV' not defined

I am using this in the transformer stage.

Thanks

Posted: Thu Feb 17, 2005 11:57 am
by ArndW
dsxuserrio,

unfortunately the ICONV and OCONV functions only exist in the Server Transform stage :cry: , which is why you are getting this error.

You have a couple of choices in solving this. Easiest in terms of getting up and running is to use a BASIC transform stage in Px. The downside is that you are losing a lot of performance (which is why you are using Px in the first place, right?). But with that stage the ICONV and OCONV functions will work. Your second option is to code a small C program that does this cast() for you; then you can bind it into Px and call it from a transform stage. This is relatively easy and quick to do and will also perform faster in Px than the first solution.

Posted: Tue Feb 22, 2005 2:24 pm
by T42
That was a VERY fun challenge. I love questions like this -- as it help me expand my knowledge of EE.

Here is the answer:

"0x" : [input field].

Yup, you have to append 0x before your number in order for DataStage to recognize it as a Hex number. It will automatically be converted if the output field is defined as an Integer.

Posted: Tue Feb 22, 2005 3:46 pm
by ray.wurlod
Is that actually documented anywhere?

Posted: Tue Feb 22, 2005 4:15 pm
by T42
Nope. But I was reading the Orchestrate document (6.x -- can't find my 7.x copy. :oops: ), did a search for "hex", and noticed that some places goes: Integer = "0000", hexadecimal = "0x000"... blah blah.

So I thought, "Hmm, maybe...", and did the above mentioned solution. Worked. :o

That was fun. :D

Posted: Wed Feb 23, 2005 2:10 pm
by dsxuserrio
T42
Thanks for your suggestion. I tried what you suggested in DS 7.5. It did not work for me.
I prefixed my hex data with 0x.

The data was something like 0x00CF. It had a type varchar.

I tried Integer as output. Also I tried AsInteger function. Both did not work.

Posted: Tue Mar 01, 2005 2:51 pm
by T42
Unfortunately, I am not able to test my solution on 7.5. I did test it on 7.1r2, and it worked.

I did not do anything special (AsInteger() or anything like that) -- just plain straight varchar to integer conversion, doing the conversion with the values you provided. It produced the expected results.

Anyone else here with EE 7.5?

Posted: Fri May 13, 2005 7:54 am
by banactp
The String to Integer conversion does not seem to work in 7.5:

Numeric string expected for input column

is the error message received from the transform. The problem seems to be with the '0x' prefix - I can't even get AsInteger("0x00ab") to work.