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

Move char to s9(7)v(2) comp-3


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

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Tue Aug 04, 2009 5:27 pm
Reply with quote

this is my requirement....

Code:
WORKING STORAGE

WS-CHAR  PIC X(70)
WS-COMP  PIC S9(7)V9(2)

PROCEDURE DIV.

MOVE WS-CHAR(24:9) TO WS-COMP


but if WS-CHAR(24:9) = 000014000 i am getting WS-COMP value as 001400000

can anyone let me know how to achieve this... thanks in advance...
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: Tue Aug 04, 2009 5:38 pm
Reply with quote

Quote:
can anyone let me know how to achieve this
Yes, there is a link to manuals at the top of the page. Click it, find the COBOL Language Reference manual, and read up on the MOVE statement. Read long enough and you find that your move is working exactly as COBOL rules dictate it should.

Explanation: the implied decimal point on the sending field is after the last character -- so 000014000 is 14,000. This value is aligned to the receiving field decimal point (which is the V) and 2 zeroes are appended for the places after the implied decimal point. And voila the value is 001400000. If this is not what you want, you will need to change your code to achieve your desired goal. Since you didn't say what that goal is, and it is not psychic day today, we cannot tell you what changes are needed.
Back to top
View user's profile Send private message
PrabakarV

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Tue Aug 04, 2009 5:46 pm
Reply with quote

Thanks Bob
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 04, 2009 8:21 pm
Reply with quote

Hello,

Quote:
Thanks Bob
That would be Robert. . .
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Aug 04, 2009 8:29 pm
Reply with quote

Redefine WS-COMP as PIC S9(09), move the 9-Bytes to this redefined field and all will be forgiven.... icon_rolleyes.gif

Your subject indicates moving to COMP-3.

Is this a true statement?

If you ultimately need to populate a COMP-3 field, I would first move the 9-Bytes to an intermediate WS display-numeric 9-Byte field and then move the display-numeric field to the COMP-3 field.

You can't go wrong....
Back to top
View user's profile Send private message
PrabakarV

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Wed Aug 05, 2009 8:18 pm
Reply with quote

I am sorry for the typo. Sorry Robert.

Thanks Bill.
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top