MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Formatting a numeric value

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Mon Jul 19, 2010 7:02 pm    Post subject: Formatting a numeric value Reply with quote

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
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Tue Jul 20, 2010 6:24 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jul 20, 2010 10:42 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Tue Jul 20, 2010 2:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jul 20, 2010 6:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Wed Jul 21, 2010 3:54 am    Post subject: Reply with quote

May be you'd like to post the final solution for the benefit of others.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group