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
 

 

moving 999 to S9(04) BINARY variable

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

Active User


Joined: 19 Mar 2009
Posts: 181
Location: Globe, India

PostPosted: Wed Jul 18, 2012 6:44 pm    Post subject: moving 999 to S9(04) BINARY variable
Reply with quote

Can anybuddy let me know if below move statement is valid if i want to set variable WS-VAR with PIC S9(04) BINARY to 999.

Code:
MOVE 999 TO WS-VAR


Or

do i need to use +999/+0999 like something in MOVE statement OR should i go for SET statement ?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Jul 18, 2012 6:50 pm    Post subject: Reply to: moving 999 to S9(04) BINARY variable
Reply with quote

The compiler is good at it. Try them out. If you want to know beforehand, read the manuals.

It is such a simple-looking question, I've probably missed something :-)

Are you new to Cobol?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8119
Location: East Dubuque, Illinois, USA

PostPosted: Wed Jul 18, 2012 7:18 pm    Post subject:
Reply with quote

Numeric constants do not have to exactly match the variable you're moving them to -- MOVE 999 works just as well as MOVE +0999.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Jul 18, 2012 7:28 pm    Post subject: Reply to: moving 999 to S9(04) BINARY variable
Reply with quote

Maybe the OP needs to read-up on the TRUNC option, providing the binary-halfword field is truly COMP? If it's defined as COMP-5 then the OP won't have to worry about high-order truncation, providing the MOVE is for a value not greater than +32767 (signed) or 65535 (unsigned).

COMP-5 was introduced with OS/390 COBOL 2.1.1, about 10-12 years ago and is upward compatible.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 181
Location: Globe, India

PostPosted: Wed Jul 18, 2012 7:53 pm    Post subject:
Reply with quote

Thanks a lot.. i will definitely dig up into Cobol manual for this COMP and BINARY difference.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Jul 18, 2012 8:38 pm    Post subject: Reply to: moving 999 to S9(04) BINARY variable
Reply with quote

COMP/COMP-4/BINARY definitions are identical and can be affected by the TRUNC option. COMP-5 (known as Native Binary) can be used, providing it's supported by your compiler and will not be affected (ignored) by the TRUNC option. COMP-5 operates similar to TRUNC(BIN) but with less overhead.

What version/release of COBOL are you using?
Back to top
View user's profile Send private message
Jarek.B

New User


Joined: 21 Jun 2012
Posts: 2
Location: UK

PostPosted: Fri Jul 20, 2012 8:58 pm    Post subject:
Reply with quote

Since I'm having my session open I've copied the snippet and given it a try. The mainframe neither exploded nor hurt me in any way icon_wink.gif but displayed this:

Code:

00999


Hope this helps!
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 Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


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