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

moving a s9(09) usage comp to 9(10) variable -urgent


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

New User


Joined: 20 Nov 2005
Posts: 15

PostPosted: Sat Dec 03, 2005 1:23 am
Reply with quote

Hi all,



We have a requirement where we move a s9(09) usage comp variable to 9(10) variable.



The variable declaration are: LS-ITEM-SID PIC S9(09) USAGE COMP.

WS-NUMERIC-SID PIC 9(10) VALUE ZEROES.



The value in LS-ITEM-SID is -2147483507.

Then the following statement is executed:

MOVE LS-ITEM-SID TO WS-NUMERIC-SID



After this statement the value in WS-NUMERIC-SID is 147483507. (Please note that leftmost two is missed).



The same statement is working fine in our client mainframe, but when we run it in our own mainframe the leftmost digit is truncated.

Any idea why this happens?



Thanks in advance.
Senthil Nathan.R
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Dec 03, 2005 3:40 am
Reply with quote

I would say the difference is in the compilers. There are some compilers, or compiler versions that will strictly adhere to the picture edit. You have S9(9), a signed 9 digit number. You are trying to use a 10 digit signed number. This will, with some compilers, truncate the value to -147483507. Then when you move it to a 9(10), an unsigned 10 digit number, the result will be 147483507.

The compile I have will honor any number that will fix into a full word +- 2147483647. Even if the picture is defined as a s9(5) comp.
Back to top
View user's profile Send private message
jon_s_rice

Active User


Joined: 24 Mar 2005
Posts: 102
Location: Douglasville, GA USA

PostPosted: Sun Dec 04, 2005 11:34 pm
Reply with quote

When you compile the program use the TRUNC(BIN) option.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Dec 05, 2005 3:46 am
Reply with quote

Hi Nathan,

What is the actual hex value in LS-ITEM-SID?
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 Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top