IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Movement of Decimal value


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sree Lekshmi

New User


Joined: 24 Dec 2013
Posts: 4
Location: India

PostPosted: Thu Jul 24, 2014 11:14 am
Reply with quote

Hi,

I have written a program in which it reads input data from a file and then updates the table with the values being read. In this Im reading a decimal value and moving to working storage.Please find the declarations below.

Input Record

Code:
05 IN-REC-INT-PREM          PIC  9(7)V9(2).


Working Storage Variable
Code:

05 WS-REC-INIT-PREM-AMT     PIC  9(7)V9(2).   


In one place Im moving the value

MOVE IN-REC-INT-PREM TO WS-REC-INIT-PREM-AMT

I have given display statement for both the values and in SYSOUT Im getting as below.

Code:
IN-REC-INT-PREM: 10.00
WS-REC-INIT-PREM-AMT: 10.00  0


Input Record value is showing correctly but the working storage variable has an additional zero by its side.

I have tried giving "9(9)" and
Code:
"05 WS-REC-INIT-PREM-AMT     PIC  9(7)V9(2) VALUE ZEROS."

but the issue still holds.

Could you please help.

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 24, 2014 12:02 pm
Reply with quote

Please use the Code tags to preserve spacing.

The value you have DISPLAYed for IN-REC-INT-PREM is far from correct for that data-description. If IN-REC-INT-PREM had contained the logical value equivalent to 10,00 it would DISPLAY as

Code:
000001000


The decimal point is implied-only, by the V, it is a numeric definition, so right-justified and left zero-filled.

So your data does not match the PICture of IN-REC-INT-PREM. Either the data is wrong, or the PICture is wrong, and the data will need to be converted before you can use it in WS-REC-INT-PREM.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jul 24, 2014 6:33 pm
Reply with quote

What you have posted is EXACTLY what would happen if the input data were PIC X and you moved it to PIC 9(07)V9(02) -- the data is moved byte by byte (PIC X data is left-justified as your post shows) and the compiler ensures the last byte zone is F? (for unsigned), which changes a space to a zero (X'40' to X'F0').

Also, your post indicates the value is 10.00 -- which is not possible with the PICTURE you provided. The V in a COBOL PICTURE is an IMPLIED decimal point -- which means there is no such thing in the data. If your input were really PIC 9(07)V9(02), the value would have displayed as 000001000, not 10.00.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Thu Jul 24, 2014 8:11 pm
Reply with quote

Please check if ther is any editing onf these fields being done before the display. Or the SYSOUT that you have shown may be of different execution.
Back to top
View user's profile Send private message
Sree Lekshmi

New User


Joined: 24 Dec 2013
Posts: 4
Location: India

PostPosted: Tue Jul 29, 2014 12:16 pm
Reply with quote

Thanks a Lot for your resopnses. icon_biggrin.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jul 29, 2014 7:37 pm
Reply with quote

Did you find out what was wrong?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts String has hex character need to conv... COBOL Programming 3
No new posts How to display the leading zeros of a... DB2 7
Search our Forums:

Back to Top