Page 1 of 1

Variables with definition S9V99 COMP-3 and PIC 9(001)V99 ar

PostPosted: Tue Jun 19, 2018 3:34 pm
by arya_starc
When I display the below variable, decimal is not showing in the spool.



003700 01  WS-VARIABLE.                                                          .  
003802     03  WS-A                PIC  S9V99 COMP-3 VALUE 1.99.                 .  
003804     03  WS-B                PIC  9(001)V99.                               .  
 
.


012802     DISPLAY 'WS-A:   'WS-A    
012804     MOVE WS-A TO WS-B        
012806     DISPLAY 'WS-B:   'WS-B    
 



Output is coming as below




********************************************************** Top of Data **************************************************
WS-A:   199                                                                                                              
EE6C7444FFF4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
6201A0001990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 -----------------------------------------------------------------------------------------------------------------------
WS-B:   199                                                                                                              
EE6C7444FFF4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
6202A0001990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 -----------------------------------------------------------------------------------------------------------------------



 


Could anyone tell why this is happen?

Re: Variables with definition S9V99 COMP-3 and PIC 9(001)V9

PostPosted: Tue Jun 19, 2018 4:51 pm
by Robert Sample
You need to go back to whoever taught you COBOL and get a refund because you did not get your money's worth!

The character V in a PICTURE clause means the IMPLIED decimal point occurs at that point. Implied decimal point means COBOL aligns data to that spot, but THERE IS NO DECIMAL POINT. So what you are seeing in the spool is PRECISELY what you should get -- a value with no decimal point. If you want to see a decimal point in your output, move the variable to a PIC 9.99 variable (which is a numeric edited variable).