Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Move s9 to s9 usage comp

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sprikitik

New User


Joined: 29 Jan 2007
Posts: 58
Location: Makati City, Philippines

PostPosted: Sat Aug 20, 2011 11:01 pm    Post subject: Move s9 to s9 usage comp
Reply with quote

HEllo,

WS-TMP-YY-MM PIC S9(06).
WS-TMP-XX-XX PIC S9(04) USAGE COMP.


How do i move WS-TMP-YY-MM to WS-TMP-XX-XX correctly?

Im my program, if WS-TMP-YY-MM is +201103, when moved to WS-TMP-XX-XX, the value of WS-TMP-XX-XX is +4495.

thanks
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Aug 20, 2011 11:08 pm    Post subject:
Reply with quote

How do you expect to move 6 digits to 4 digits??
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sat Aug 20, 2011 11:25 pm    Post subject: Reply to: Move s9 to s9 usage comp
Reply with quote

Indeed, make the COMP field bigger.

You have defined it to hold four digits (maximum value 9999*). You are trying to move six digits to it. It is not going to work.

*You have TRUNC(BIN) as your compiler option. This will utilise all the bits irrespective of the PICTURE (the PICTURE determines the size of the storage, in this case a "half-word", then you have access to all the bits in the half-word, giving you, for a signed field, values in the range +32767 to -32768.

You then move 201103 to this field. This will cause truncation. 201103 in hex is 3118F. Drop the three (a half-word is two bytes, four hex digits). That gives you 118F. 118F in decimal is 4495.

Edit: I said "I suspect you have TRUNC(BIN). Pointless, since I know you have it.
Back to top
View user's profile Send private message
sprikitik

New User


Joined: 29 Jan 2007
Posts: 58
Location: Makati City, Philippines

PostPosted: Sat Aug 20, 2011 11:40 pm    Post subject: Re: Reply to: Move s9 to s9 usage comp
Reply with quote

Bill Woodger wrote:
Indeed, make the COMP field bigger.

You have defined it to hold four digits (maximum value 9999*). You are trying to move six digits to it. It is not going to work.

*I suspect you have TRUNC(BIN) as your compiler option. This will utilise all the bits irrespective of the PICTURE (the PICTURE determines the size of the storage, in this case a "half-word", then you have access to all the bits in the half-word, giving you, for a signed field, values in the range +32767 to -32768.

You then move 201103 to this field. This will cause truncation. 201103 in hex is 3118F. Drop the three (a half-word is two bytes, four hex digits). That gives you 118F. 118F in decimal is 4495.



Thanks for the explanation!
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sun Aug 21, 2011 1:14 am    Post subject:
Reply with quote

No problem.

If you have a chance, compare it with the truncation without TRUNC(BIN).
You'll get a different answer. Scratch here XXXX to see what it is.

Your receiving field should always be at least as big (in digits) as your sending field, unless you deliberately want truncation.

Get used to the hex representation of binary values. Something you'll need for dump-solving, if nothing else.

If you want to see the hex without a dump, redefine your binary field

Code:
01  W-A-BINARY-VALUE-TWO-BYTES COMP PIC S9( 1-4 ) (one to four digits, will occupy the same space)
01  W-DISPLAY-CONTENTS-OF-TWO-BYTE-BINARY
       REDEFINES W-A-BINARY-VALUE-TWO-BYTES PIC XX.

01  W-A-BINARY-VALUE-FOUR-BYTES COMP PIC S9( 5-9 )
01  W-DISPLAY-CONTENTS-OF-FOUR-BYTE-BINARY
       REDEFINES W-A-BINARY-VALUE-FOUR-BYTES PIC X(4).

DISPLAY ">" W-DISPLAY-CONTENTS-OF-TWO-BYTE-BINARY "<"
DISPLAY ">" W-DISPLAY-CONTENTS-OF-FOUR-BYTE-BINARY "<"


Then, when looking at the output, put HEX on. You'll see the hex value in your binary field.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need inputs on Space requirement and... ashek15 IMS DB/DC 0 Sat Apr 01, 2017 8:26 am
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us