Hi,
I want to display +,- sign for amounts field and decimal point and don’t want to suppress leading zeroes . How to declare this output variable? Please advise.
Display +,- sign for amounts field in COBOL.
-
- Registered Member
- Posts: 10
- Joined: Tue Mar 18, 2014 11:16 am
Re: Display +,- sign for amounts field in COBOL.
Hello.
Declare it as "PIC +9(nn)" where "nn" is the length you need. You can also do something like "+999,999,999" if you want the output delimited with commas.
The "9" causes the number to be displayed no matter what. A "Z" is used if you want leading zeros to be suppressed.
The "+" forces both the "+" and "-" symbols to be displayed. If you specify "-", then a negative number will show as "-", but a positive number will only give a space.
Declare it as "PIC +9(nn)" where "nn" is the length you need. You can also do something like "+999,999,999" if you want the output delimited with commas.
The "9" causes the number to be displayed no matter what. A "Z" is used if you want leading zeros to be suppressed.
The "+" forces both the "+" and "-" symbols to be displayed. If you specify "-", then a negative number will show as "-", but a positive number will only give a space.
Re: Display +,- sign for amounts field in COBOL.
...just realised I missed the bit about the decimal point. You do that just by splitting the "PIC +9(nn)" definiton with a decimal point, e.g. "PIC +9(5).99" will give you a seven digit number with two decimal places.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute