VarChar to Hex

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
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

VarChar to Hex

Post by vinaymanchinila »

Hi,

I need to convert varchar to hex value. There are 2 parts to it, first convert from varchar to hex but take only 2 at a time from the below source column:

SrcCol=56243312....

Required Output value (if we just consider the first 2 i.e. 56)

outputCol=00011100


Did any one come across sucha situation. I look at some Oconv function (radix) but not sure if it takes 2 caharacters at a time.

Thanks,
Thanks,
Vinay
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You would need a BASIC Transformer to use Oconv() or Iconv() in a parallel job. But your output isn't hex - it appears to be binary. Oconv() can do that too. Please specify your exact requirements. Hex can be managed with "MX" or "MX0C" or "MY" conversion, binary with "MB" or "MB0C").
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi Ray,

Sorry for the confusion, yes I need the binary output. I designed it with the basic transformer and got the output, how ever is there away to keep the leading zeros with any options:

56=11100 (Can we get 00011100)

Secondly, do we have any options we can mention in the function so that it takes 2 characters at a time, as the source is like
564286988989.....

thanks a lot.
Thanks,
Vinay
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Vinaymanchinila,
even though I'm not Ray you can right pad your binary to 8 places by using the FMT(In.Column,'8"0"R') conversion. I'm not sure what you are trying to do with the "take 2 characters at a time" part.
sauros73
Premium Member
Premium Member
Posts: 5
Joined: Mon Dec 05, 2005 1:15 pm
Location: Montreal
Contact:

Post by sauros73 »

Are you using the CFF stage in order to create your binary output ? What stage are you using ?
Hugo POISSANT
Data Integration director
CGI
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi ,
I used a basic transformer and Oconv(ToOconv.Src, "MB") function.
Thanks,
Vinay
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Hi,
Now I also have to convert a hex value to binary.

56e2 =0101 0110 ...

Looking to check if we have afunction for that.

Thanks,
Thanks,
Vinay
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

With ICONV/OCONV use the MX format for hexadecimal, MB for binary.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Two characters at a time can be done simply in a server routine with a loop. Be sure to handle exceptions, such as argument not assigned, argument not null, argument contains odd number of digits, argument does not contain decimal numbers. You can invoke the server routine from any expression in your BASIC Transformer stage.

Or you could create parallel routines that you could invoke from a parallel Transformer stage. Or a BuildOp.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply