View previous topic :: View next topic |
Author |
Message |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Mon Jul 19, 2010 7:02 pm Post subject: Formatting a numeric value |
|
|
Hi ,
I need help with formatting a numeric value using cobol only.
Input: -123456789.10
Output1 : -$123,456,789.10
Output2 : -123 456 789,10$ (comma from output1 is replaced with blanks and '.' is converted to ',' and dollar sign is moved to end)
Is there an easy way to do output2 using picture clauses or should I use program logic ?
Vijay |
|
Back to top |
|
|
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Tue Jul 20, 2010 6:24 am Post subject: |
|
|
For Output1, you can use eidted-picture-clauses and a direct MOVE should work. Have a look here for examples: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr10/5.3.11.9.1?
for output2 there are couple of ways - have a variable of kind which has a FILLER after every three numerical values and last FILLER with a valuse as "$" - and MOVE the value to this variable and display that. You might also choose reference-modifications. _________________ Regards,
Anuj |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jul 20, 2010 10:42 am Post subject: |
|
|
vijay,
Unless this is a trick question isn't it a simple numeric edit?
Untested code.
Code: |
01 IN-NUM PIC -999999999.99.
01 ED-NUM PIC -$999,999,999.99.
01 SP-NUM PIC -999B999B999.99B.
|
Code: |
MOVE IN-NUM TO ED-NUM
SP-NUM
MOVE ',' TO SP-NUM(13: 1)
MOVE '$' TO SP-NUM(16: 1)
|
Kolusu |
|
Back to top |
|
|
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Tue Jul 20, 2010 2:32 pm Post subject: |
|
|
Thanks Kolusu.
I also do not want any zeroes or spaces after the $ sign and the first digit.Anyways , I used reference modifications and it worked.
Thanks,
Vijay |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jul 20, 2010 6:08 pm Post subject: |
|
|
vijay wrote: | Thanks Kolusu.
I also do not want any zeroes or spaces after the $ sign and the first digit.Anyways , I used reference modifications and it worked.
Thanks,
Vijay |
was it specified in your initial request?
Kolusu |
|
Back to top |
|
|
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Wed Jul 21, 2010 3:54 am Post subject: |
|
|
May be you'd like to post the final solution for the benefit of others. _________________ Regards,
Anuj |
|
Back to top |
|
|
|
|