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
 

 

Maximum value of COMP Variable

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

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Jun 21, 2010 12:14 pm    Post subject: Maximum value of COMP Variable
Reply with quote

Hi all,


According to theories, and many posts in the forum, an S9(4) COMP variable can hold a maximum value of +/- 32767 i.e. 2 raised to 15.

I wrote a small program to verify it..but it is not giving the desired results...

COBOL Module:
Code:
WORKING-STORAGE SECTION.                             
01 WS-DISP-VAR           PIC S9(05).                 
01 WS-DISP-VAR1          PIC  9(05) VALUE 32766.     
01 WS-NUM-VAR            PIC S9(04) COMP.             
01 WS-NUM-VAR1           PIC S9(04) COMP.             
PROCEDURE DIVISION.                                   
A000-MAINPARA.                                       
     ACCEPT WS-DISP-VAR.                             
     DISPLAY "DISP VARIABLE    : " WS-DISP-VAR.       
     MOVE WS-DISP-VAR TO WS-NUM-VAR.                 
     ADD  1           TO WS-DISP-VAR1.               
     MOVE WS-DISP-VAR1 TO WS-NUM-VAR1.               
     DISPLAY "DISP VARIABLE1   : " WS-DISP-VAR1.     
     DISPLAY "COMP VARIABLE1   : " WS-NUM-VAR.       
     DISPLAY "COMP VARIABLE2   : " WS-NUM-VAR1.       
     STOP RUN.                                       



RUN JCL SYSIN
Code:
//SYSIN    DD *     
3276F               
/*                 


SYSOUT
Code:
DISP VARIABLE    : 3276F   
DISP VARIABLE1   : 32767   
COMP VARIABLE1   : 2766   
COMP VARIABLE2   : 2767   


Please let me know if I missed out on any Compiler option...
I havent given any compiler option while compiling.
Back to top
View user's profile Send private message

Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 788
Location: Chennai, India

PostPosted: Mon Jun 21, 2010 12:20 pm    Post subject:
Reply with quote

Hi,

What is the number in SYSIN. Please show it us in HEX ON.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Jun 21, 2010 12:27 pm    Post subject:
Reply with quote

Its the zoned decimal input--- the number is +32766
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Jun 21, 2010 2:54 pm    Post subject:
Reply with quote

If you would look at the Enterprise COBOL for z/OS V4.2 Programming Guide
under the section about Compiler options
You would have seen the TRUNC option:
TRUNC affects the way that binary data is truncated during moves and arithmetic operations.
Default is: TRUNC(STD)
Abbreviations are: None
TRUNC has no effect on COMP-5 data items; COMP-5 items are handled as if TRUNC(BIN) is in effect regardless of the TRUNC suboption specified.
TRUNC(STD) applies only to USAGE BINARY receiving fields in MOVE statements and arithmetic expressions. When TRUNC(STD) is in effect, the final result of an arithmetic expression, or the sending field in the MOVE statement, is truncated to the number of digits in the PICTURE clause of the BINARY receiving field.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Jun 21, 2010 3:20 pm    Post subject:
Reply with quote

Thanks for the information.

It is working fine now...
But can you provide me some inputs on where and when to use the compiler options...
If possible, please take some random scenario where we need to use some compiler option other than the default one
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Jun 21, 2010 3:29 pm    Post subject:
Reply with quote

Have you looked at the programming guide?
try Specifying compiler options under z/OS...
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: Mon Jun 21, 2010 3:53 pm    Post subject: Reply to: COMP Usage
Reply with quote

If your compiler supports COMP-5 (Native Binary), then the TRUNC option has no effect.

COMP-5 support was introduced with OS390/COBOL 2.2.1.

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jun 21, 2010 5:15 pm    Post subject:
Reply with quote

Quote:
But can you provide me some inputs on where and when to use the compiler options...
If possible, please take some random scenario where we need to use some compiler option other than the default one
Part of the problem here is that IBM allows, during installation of COBOL, for each site to set up their default COBOL options to be different than what is in the manual. This can be done for CICS compiles separately from batch compiles. Unless you contact your site support group, you cannot know absolutely for sure about the default options (other than running a compile, of course).

Additionally, changing the compile options depends largely upon the needs of the program and you should document such deviations very carefully (so the next person to compile your code in 1 month or 7 years -- or whenever -- can get a clean compile). The best recommendation would be to read the compiler options in the COBOL Programming Guide manual (link at the top of the page) and consider when you would need that option changed.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Jun 21, 2010 6:14 pm    Post subject:
Reply with quote

Oh..Thanks for guiding...
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 11 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 Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


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