Page 1 of 1

Representing a decimal with thousand separators

Posted: Wed Sep 29, 2004 3:21 am
by rsrikant
Hi Everyone,

One of the requirement for my job is to represent a decimal number with thousand separators. I have gone through various inbuilt functions available in parallel and not able to find one which can solve this purpose.

For e.g., the decimal 1234567891.23 should be represented as +1,234,567,891.23 in the output.

Has anyone come across this situation? Please give me your inputs on how to achieve this.

Thanks & Regards,
Srikanth

Posted: Wed Sep 29, 2004 4:23 am
by ray.wurlod
You'll probably need a custom operator if you want a "pure" PX solution.

If you're prepared to use BASIC, which slows PX down somewhat, the solution is easy using Oconv.

Code: Select all

If TheNumber < 0 Then "-" Else "+" : TrimF(Oconv(TheNumber,"MCN":@VM:"MD2,"))
The first part of the expression prepends the sign.
The Oconv() function performs two conversions: "MCN" keeps only the numeric characters, while "MD2," expresses the result of that with two decimal places and thousands delimiters.

You have more options if you have NLS enabled, as you can construct a locale that automatically gives you a leading sign, so that you wouldn't need the first part of the above expression.

Posted: Tue Oct 05, 2004 6:17 am
by rsrikant
Thank you for the reply Ray.

The solution you gave is working after using Basic Transformer. In basic transformer i am able to achieve it even by using Fmt function.

But the client is not accepting this solution. He wants pure PX solution.

How to build a custom operator? Do you mean building a custom transform and then using it in the job? Any clues will be helpful.

Thank you again,
Srikanth

Posted: Tue Oct 05, 2004 4:26 pm
by ray.wurlod
I'm reminded of nothing more than the PHB who wanted a document faxed on green paper. :twisted:

My response to the customer would be to ask why a "pure" PX solution is required; doesn't the fact that you can use a BASIC Transformer stage directly from the PX palette mean that you have a "pure" PX solution?

Customisation (including construction of buildops) is an extra charge. See how they react to that.

When you want to know about building custom operators, it's all there in the Parallel Job Developer's Guide. Oh, and you'll need some C skills.