Character to Number

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Character to Number

Post by rsunny »

Hi ,

Can any one tell me how to convert Character to Decimal Value . For example if i have A , it should convert to 65 . and if i have Aa it should convert to 6597.

Any help is really appreciated

Thanks in advance
leomauer
Premium Member
Premium Member
Posts: 100
Joined: Mon Nov 03, 2003 1:33 pm

Post by leomauer »

Use Seq function for each character in string:
Seq(<strig>[1,1]):Seq(<strig>[2,1]):Seq(<strig>[3,1]) and so on.
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

leomauer wrote:Use Seq function for each character in string:
Seq(<strig>[1,1]):Seq(<strig>[2,1]):Seq(<strig>[3,1]) and so on.
Hi ,

Thanks for your quick reply , but the logic above is for each character and i want for multiple characters. I mean , i dont know the input , the input might be abc for 1 row and sdfge for 2nd , so if that is the case how do i consider . So if i consider the above logic that u said ,after all the characters are converted to decimal do i need to trim all zeroes since "" is converted to zero r8?


thanks in advance
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Right a small routine to cycle through the string and return the decimal value all concatenated.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
leomauer
Premium Member
Premium Member
Posts: 100
Joined: Mon Nov 03, 2003 1:33 pm

Post by leomauer »

I see you are using DataStage Server edition. Then write BASIC routine looping thriugh the string character by character and concatenating the results until you reach the end of the string.
As for trimming zeroes. in the string absence of character is not converted to anything.
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

Hi ,

Thanks all for the reply . As i dont have any experience in writing Routines , Can anyone guide me how to write a routine to solve this issue.

Any help is really appreciated

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

Post by ray.wurlod »

You've been using DataStage for quite a while now (based on your DSXchange profile) and really should be acquiring these skills.

Code: Select all

FUNCTION RSunny(aTheString)

    vLenString = Len(aTheString)
    Ans = ""

    For vChPos = 1 To vLenString
        Ans := Seq(aTheString[vChPos,1])
    Next vChPos

RETURN(Ans)
If you have Unicode data, then use Uniseq() rather than Seq() function.
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