Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Display without zeroes and sign at proper place.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Tue Nov 29, 2011 4:56 am    Post subject: Display without zeroes and sign at proper place.
Reply with quote

All
I have a below requirement.

I have a variable defined as
WS-WORKING-STORAGE PIC S9(11)V99
SIGN IS LEADING SEPARATE
VALUE ZEROS.

When its zeroes it should be displayed as +0.00
when its +00000000001.23, it should be displayed as +1.23
and when its when its -00000000021.89, it should be displayed as -21.89

What is the function which I can use ?

Thanks for the help.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Nov 29, 2011 5:19 am    Post subject: Reply to: Display without zeroes and sign at proper place.
Reply with quote

Have you tried anything so far yourself? Read up in the manual on the PICTURE clause as it relates to edited numerics and it should provide for whatever format you want the output to be. The "leading sign" shouldn't matter at all in your current picture, the compiler will handle that.

If you don't get it after looking at the manual, let us know what problem you still have.
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Tue Nov 29, 2011 5:27 am    Post subject: Reply to: Display without zeroes and sign at proper place.
Reply with quote

Bill,

Thnx for the reply. I know ZZZZ will serve the purpose but I was not sure about the sign.

I even achieved the result by coding and it was working fine but I would prefer if COBOL does it on its own and not my logic which may affect the performance.

Since you said compiler will handle the sing, let me try with ZZZZ and check. I dont have Mainframe access right now, will try it in couple of hours and let you know.

Thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Nov 29, 2011 5:40 am    Post subject: Reply to: Display without zeroes and sign at proper place.
Reply with quote

The Cobol manuals are a few clicks away with the Manuals link at the top of this page.

The Z's will zero supress. If you want a leading "floating" sign, which you seem to from your example, you can replace the Zs with + or - (- if you only want the sign for negative values, + if you want for all values). I don't know if you want commas for readability, those can be included as well.

Code:
PIC +++,+++.+++.++9.99.
PIC +(11)9.99


Just not that you need one more leading printable character than your picture excluding any other editing, because the sign will take up a position (even if not printed, in the case of a - picture character).

It is well-worth looking at all the editing available through the Cobol picture clause.
Back to top
View user's profile Send private message
Kiran Gadgi
Currently Banned

New User


Joined: 04 Dec 2011
Posts: 3
Location: India

PostPosted: Sun Dec 04, 2011 2:07 pm    Post subject:
Reply with quote

I tried with the above code its working. Follow our Sr words
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Mon Dec 05, 2011 10:52 am    Post subject:
Reply with quote

Thanks Bill, yes it worked although I had to do some modifications but it surely worked fine.

Thanks alot.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts display the sign only if the value is... useit DFSORT/ICETOOL 3 Wed Oct 04, 2017 5:53 pm
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts Hardcoded negative sign value in output scdinesh SYNCSORT 8 Fri Sep 08, 2017 5:28 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us