View previous topic :: View next topic |
Author |
Message |
John Corbin Beginner
Joined: 23 Jan 2004 Posts: 38 Topics: 21
|
Posted: Mon Oct 18, 2004 12:35 pm Post subject: Formatting non currency values to currency values |
|
|
Using TSO REXX
I have numbers like
1234567
88775433
88990000765
that I want to format like
$12345.67
$887754.33
$889900007.65
Note that I am never sure that the length of the raw data is the same.
Here is what I am trying:
IF LINE114 <> "###########" THEN DO
A = LENGTH(rawdata)
A1 = INSERT(DecimalSymbol,LINE114,1+(A-2))
A2 = DollarSymbol||A1
A3 = LEFT(A2,15)
A4 = "Refund Amount = "||A3
J = J + 1
detail.J = account||startdt||enddt||A4
END
It seems to not work.... I get output like:
$12345.67
$88775.433
$8899000.0765
I can see no real pattern to the way it is working...
Can anyone think of a better way ? |
|
Back to top |
|
|
superk Advanced
Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Mon Oct 18, 2004 12:56 pm Post subject: |
|
|
The INSERT of the decimal point goes at LENGTH - 2:
Code: |
A = Length(rawdata)
A1 = Insert(DecimalSymbol,LINE114,(A-2))
A1 = Insert(DollarSymbol,A1,0)
A1 = Left(A1,15)
|
|
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Mon Oct 18, 2004 1:12 pm Post subject: |
|
|
John_corbin,
Try this
Code: |
/* REXX */
AMTI = '1234567'
NUM1 = LEFT(AMTI,LENGTH(AMTI)-2)
NUM2 = SUBSTR(AMTI,LENGTH(AMTI)-1)
AMTO = "$"||NUM1||"."||NUM2
SAY AMTO
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
John Corbin Beginner
Joined: 23 Jan 2004 Posts: 38 Topics: 21
|
Posted: Tue Oct 19, 2004 8:36 am Post subject: |
|
|
Much thanks to all...
both suggestions worked and I appreciate the help |
|
Back to top |
|
|
|
|