Removing Leading Space and Trailing Dot from Numeric Fields

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

Jayanto
Participant
Posts: 41
Joined: Fri Feb 18, 2011 12:37 am
Location: Kolkata

Removing Leading Space and Trailing Dot from Numeric Fields

Post by Jayanto »

Hello All,
I need to remove a leading space and trailing '.' from my source data.
The source is a mainframe file. The source field attributes are --
Native Type : DISPLAY NUMERIC
Length : 3
Scale : 0
Level Number : 3
USAGE : DISPLAY
SQL Type : Decimal
Storage Length : 3
Picture : PIC 93

Now lets say my Input is coming as ' 999.' -->> My desired output is '999'.
The Target Datatype is - Numeric(3).

Please advice on how to move ahead with replacing/removing it.. Tried using the Convert & Trim Functions.. But nothing positive..!!

:(
Regards,
Jayanto
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Output it as a string so you have full control over the formatting.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Jayanto
Participant
Posts: 41
Joined: Fri Feb 18, 2011 12:37 am
Location: Kolkata

Post by Jayanto »

@Chulett -- Thanks.. But what function to use?? :?
Regards,
Jayanto
sudha03_vpr
Participant
Posts: 34
Joined: Tue Feb 26, 2013 9:36 am
Location: Chicago

Post by sudha03_vpr »

Ereplace(MyString, ".", "")

You can probably use the above function to replace "." with nothing.
Jayanto
Participant
Posts: 41
Joined: Fri Feb 18, 2011 12:37 am
Location: Kolkata

Post by Jayanto »

@Sudha01_vpr -- I tried Ereplace(), but it was not working.. It works only with strings..!!
Also, as per my findings in DSXchange-EReplace() works with version 9.1, and pxEReplace() is not advised to be used.. Am working with DataStage 8.7..
Let me try it once with DecimalToString(), but again the datatypes needed to be tweaked..!!
Regards,
Jayanto
sudha03_vpr
Participant
Posts: 34
Joined: Tue Feb 26, 2013 9:36 am
Location: Chicago

Post by sudha03_vpr »

Yes. You can probably use DecimalToString and then get the length of the string and get the substring before . and store it back to Numeric Field.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Jayanto wrote:Thanks.. But what function to use??
DecimalToString. And if you still need to, Convert after that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sudha03_vpr
Participant
Posts: 34
Joined: Tue Feb 26, 2013 9:36 am
Location: Chicago

Post by sudha03_vpr »

Yes. You can probably use DecimalToString and then get the length of the string and get the substring before . and store it back to Numeric Field.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Numeric datatype will have the . when printed to a file. File doesn't have any datatype as such, so you can change the datatype in datastage. Reading program can still read it as decimal.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Assuming that your data is comprised of whole numbers, you can change it to an Integer datatype before the output file (expanding on Priyad's suggestion). Alternatively, you have the option of specifying a format string (C_format or Out_format options) in the column's metadata in the output sequential file stage.

There was a similar thread to this from just a week or two ago...a little bit of searching might have turned it up.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

@Jayanto,
Use simple TRIM function and store the output as Integer.
Thanx and Regards,
ETL User
srinivas.nettalam
Participant
Posts: 134
Joined: Tue Jun 15, 2010 2:10 am
Location: Bangalore

Post by srinivas.nettalam »

Convert('.','',DecimalToString(Col))
N.Srinivas
India.
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

This should also work:-

Code: Select all

Left(DecimalToString(Inputcol),Index(DecimalToString(InputCol),".",1)-1)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or, perhaps simpler:

Code: Select all

Field(DecimalToString(Inputcol),".",1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

In COBOL, display numerics can be treated as a subset of alphanumeric. The key is to make sure you provide "space" for the decimal.

Code: Select all

PIC 9(3) == Char(3)
PIC 9(3)V9(2) == Char(6)
etc.
The sign is usually incorporated in the first (rarely) or last (standard) digit. The EBCDIC character displays instead of the numeric. Ex. unsigned 0 = 0 (x'F0'), positive 0 = } (x'C0'), negative 0 = { (x'D0'). C and D are also the final half-byte in signed packed decimals.
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Post Reply