Extract Numberics & Chars only from a string

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

Extract Numberics & Chars only from a string

Post by vinaymanchinila »

Hi,
Is there a function or way to extract only numbers and characters from a string. I need to do this so to avoid special characters and line termination characters.
Thanks,
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

to get only numeric value from a string : oconv(string,"MCN")
to get only alphabetic value: oconv(string,"MCA")
to get numeric+special character value from a string : oconv(string,"MC/A")
to get only alphabetic+special character value: oconv(string,"MC/N")


You look for "Masked Character Conversions" in the Datastage help documents, you will get to know more.
Shantanu Choudhary
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

Thanks,
Will try this, I havea field value like MCE90908 which is extracted from Oracle8i and has a line termination at the end which is invisible, so wanted to extract only numerics and characters . What would be the combination to extract numbers AND characters only.
Appreciate your help.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You will need to create a custom routine. There is no intrinsic function for this particular task.
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,
Thanks for the Ocnv idea, have got my issue resolved by first capturing and converting any special characters to "." and then replaceing the "." to ""!

TRIM(Oconv(ToXfm.LONG_SERIAL_NO,"MCP"), ".","")
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Only good if there are no "." characters in your data that you want to keep (decimal points?).
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 »

This filed is serial number so fortunately there are no "." in the number.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
For some strange reason I can't help feeling like the problem might be something like reading a windows source file that still has CRLF line termination instead of LF only as in unix.
if that is the case you can use the CRLF style on the sequential file or make sure when it is transfered to you it converts the Line termination style between different platforms.

if you do this then you won't have a problem.

so I ask does my 6th scense work?

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
vinaymanchinila
Premium Member
Premium Member
Posts: 353
Joined: Wed Apr 06, 2005 8:45 am

Post by vinaymanchinila »

It sure is scary 6th sense! but I donot have hte flat file access as SAP BW Plug in creates the flat file internally. Other way is first create a flat file and do as you say and again load it to BW plug in..Hmm yes that sounds do able.
Will let you know Thanks for the idea.
Post Reply