Decimal field suppressing leading and trailing zeros.

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
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Decimal field suppressing leading and trailing zeros.

Post by vijayrc »

Hi,

Working on DS after a while and finding it tough to achieve this result.
I have a source & destination field Decimal 15,2
When the amount field is zero, I should have 0.00
When the amount field is 12cents, I should have 0.12
When the amoutn field is 5dollars, I should have 5.00

In the abvoe scenarios, I 'm getting .00, .12 and 5.00 [only the last one is working]

How do I acheive this in Transformer.
These are my 4 stage variables
[1] StgIncSign:
If Lnk_Ntr_Final.FSSI_INCT_AMT[1,1] = "-" Then "Y" Else "N"
[2] StgIncTot
If StgIncSign = "Y"
Then "-" : Trim(Convert(" -","00",Lnk_Ntr_Final.FSSI_INCT_AMT),"0","L")
Else Trim(Convert(" -","00",Lnk_Ntr_Final.FSSI_INCT_AMT),"0","L")
[3] StgIncTotal
StgIncTot : StgSpace
[4] StgIncCount
Space(StgIncCount) : StgIncTot
Final field derivaiton: Space(StgIncCount) : StgIncTot
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

.00 and .12 are correct. With Decimal data type you can not affect the format (it's actually stored internally in binary format). If you convert it to a string data type of some kind then you can affect the format, as you seem to be trying to do.

You are discarding the sign character ("-"). Do you mean to do so?
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