Adding Comma Separators

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
FrankTheTank
Participant
Posts: 5
Joined: Wed May 04, 2005 8:00 am

Adding Comma Separators

Post by FrankTheTank »

I currently have a job where I have a decimal value, where it needs the comma separators for the thousands. I need a way of putting those in while in a Char format, since I need to right justify the field with spaces.


Example:

Input from database:

49477404.97

Output to file:

49,477,404.97


Remember that I will be formating this to String for Right Justification, so I need the commas to stick.

Thank you.
ds_is_fun
Premium Member
Premium Member
Posts: 194
Joined: Fri Jan 07, 2005 12:00 pm

Post by ds_is_fun »

First Change the target column to Varchar. What is the length of the datatype ?
Then. let work on it.
FrankTheTank
Participant
Posts: 5
Joined: Wed May 04, 2005 8:00 am

Post by FrankTheTank »

The current length is 16. I figure to be a max of 19 with comma separators.
kris
Participant
Posts: 160
Joined: Tue Dec 09, 2003 2:45 pm
Location: virginia, usa

Re: Adding Comma Separators

Post by kris »

FrankTheTank wrote: Example:

Input from database:

49477404.97

Output to file:

49,477,404.97

Remember that I will be formating this to String for Right Justification, so I need the commas to stick.
Hi Frank,
If your string always has two decimal points (ex: 2345.67, 234567.00). Then this solution will work. Do some test on this.

Code: Select all

FMT(Oconv(Ereplace(yourstring,".",''),"MR2,"),"R#":19)
Hope this will work for you.

Kris~
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Adding Comma Separators

Post by Sunshine2323 »

Hi,

Oconv(49477404.97, "MD2,P")

Ans = 49,477,404.97

You can use Oconv(yourinput, "MD2,P")

Hope this helps :)
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Or simply make it a decimal and give a decimal separator as comma (,) in the target file.
FrankTheTank
Participant
Posts: 5
Joined: Wed May 04, 2005 8:00 am

Post by FrankTheTank »

The Oconv function doesn't seem to work in Parellel jobs, which I am required to use for reasons beyond reason.

Also, I can not just use comma as a decimal seperator at the target file, because I need to keep this field right justified, and that throws it off.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

FrankTheTank,

I tried using the comma as decimal separator and it leaves the value right aligned. Can you please let me know how you obtained a different result.
ravikumarreddy
Participant
Posts: 9
Joined: Tue Apr 05, 2005 4:39 am

Post by ravikumarreddy »

Hi,

FMT(49477404.97, "R2,") ie

FMT(Input, "R2,")

Ans = 49,477,404.97

Hope this helps

:lol:

Ravi
Post Reply