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

Maximum value of COMP Variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 792
Location: Chennai, India

PostPosted: Mon Jun 21, 2010 12:20 pm
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
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: 2146
Location: At my coffee table

PostPosted: Mon Jun 21, 2010 2:54 pm
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
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: 2146
Location: At my coffee table

PostPosted: Mon Jun 21, 2010 3:29 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jun 21, 2010 3:53 pm
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 21, 2010 5:15 pm
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
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 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