Page 1 of 1

PIC S9(9)V99 COMP-3

PostPosted: Tue Dec 20, 2011 12:46 pm
by Sivaji
Hi,
My copybook field has PIC S9(9)V99 COMP-3. i want to final output to be dislayed like -3136488.00(+ or - should also be displayed). Can someone help with standard format to achieve the same.

Re: COMP-3

PostPosted: Tue Dec 20, 2011 1:53 pm
by NicC
Have you looked in the manual for picture editing symbols?

Re: COMP-3

PostPosted: Tue Dec 20, 2011 2:18 pm
by Sivaji
Is it a standard format to move it to a pic 999999999.99 field and display the value..I just want to know the proper comp-3 move to obtain my result..

Re: COMP-3

PostPosted: Tue Dec 20, 2011 2:31 pm
by NicC
How else do you think it would be done?

Re: COMP-3

PostPosted: Tue Dec 20, 2011 2:35 pm
by BillyBoyo
Well, NicC has given you very good advice. If you want to do it with the 9's like you have, just don't forget to put a leading/trailing sign on (+ or -, experiment). Also see the effect of ZZZZZZZZ9.99- with smaller numbers.

Re: COMP-3

PostPosted: Tue Dec 20, 2011 2:47 pm
by Sivaji
Yeah i know to use the z(9).99-. for this move but i doubt whether it could be the standard format to be used in COBOL. So i asked for various other methods to achieve the same..
Thanks..

Re: COMP-3

PostPosted: Tue Dec 20, 2011 2:55 pm
by BillyBoyo
There is no reall "standard" format. How you format the numbers depends on the requirement. I should think for reporting I've used the Zs about 95% of the time. Other than files going to external systems I've not put physical decimal points in files. For files going to external systems, either the Zs (for CSVs) or 9s (for fixed-format files).

Re: COMP-3

PostPosted: Tue Dec 20, 2011 3:01 pm
by Sivaji
Thank you all guys..

Re: COMP-3

PostPosted: Tue Dec 20, 2011 3:31 pm
by Sivaji
As i want the sign value to be in front i gave it as -Z(9).99. But the thing is that i am getting the values in this format
- 7168.00(spaces after sign field). Which actually i want it as -7168.00.How can i eliminate the spaces after the sign.

Re: COMP-3

PostPosted: Tue Dec 20, 2011 3:56 pm
by BillyBoyo
Replace the Zs by -s, this will cause the - to "float" and it is also going to suppress the leading zeros.