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

Calculating space for COMP variables


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

New User


Joined: 17 Mar 2006
Posts: 4

PostPosted: Sat Apr 22, 2006 11:55 am
Reply with quote

How much space in terms of bytes will the following variables take and how is it calculated?
S9(4) COMP
S9(5) COMP
S9(8) COMP
S9(9) COMP
S9(10) COMP
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Sat Apr 22, 2006 8:17 pm
Reply with quote

Hi,

COMP is a binary storage format . The sign stored in a COMP field will be in the most significant bit. Bit is ON if -ve, off if +ve.

S9(4) COMP - 2 bytes
S9(5) COMP - 2 bytes
S9(8) COMP - 4 bytes
S9(9) COMP - 4 bytes
S9(10) COMP - 5 bytes

Hope this is what you had expected.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 22, 2006 9:08 pm
Reply with quote

Hi,

The best place to find the ans to ques like yours is in the manuals. From the Zos Pgming Reference Manual:

Digits in PICTURE clause
Storage occupied

1 through 4
2 bytes (halfword)

5 through 9
4 bytes (fullword)

10 through 18
8 bytes (doubleword)

Scroll to the top of this page; clk "manuals".
Scroll down to manual selections and clk on your choice.
Back to top
View user's profile Send private message
Pranjal

New User


Joined: 17 Mar 2006
Posts: 4

PostPosted: Sun Apr 23, 2006 12:33 pm
Reply with quote

Thanks for the replies. I must be checking the mauals first.
Back to top
View user's profile Send private message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Tue Apr 25, 2006 3:18 pm
Reply with quote

Hi,

The COMP occupies Int(n/2) 4 bytes and COMP-3 occupies Int((n/2)+1) bytes.
So using this we get the results as :

S9(4) COMP - Int(4/2) = 2 bytes
S9(5) COMP - Int(5/2) = 2 bytes
S9(8) COMP - Int(8/2) = 4 bytes
S9(9) COMP - Int(9/2) = 4 bytes
S9(10) COMP - Int(10/2) =5 bytes

Thanks,
KS
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Apr 26, 2006 6:27 am
Reply with quote

KS,

The info I offered above was cut & pasted from IBM's eCOBOL Language Reference Manual (SC27-1408-01). Where did you get your info?
Back to top
View user's profile Send private message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Thu Apr 27, 2006 4:08 pm
Reply with quote

HI mmwife,

Sorry all , I was wrong on tht..

A binary number with a picture description,
- less than 4 or fewer decimal digits will occupy 2 bytes.
- 5 to 9 decimal digits will occupy 4 bytes.
- 10 to 18 bytes occupies 8 bytes.

Regret the inconvienience caused.

Thanks,
KS
Back to top
View user's profile Send private message
kamran

New User


Joined: 01 May 2005
Posts: 55

PostPosted: Thu Apr 27, 2006 4:48 pm
Reply with quote

Pranjal wrote:
How much space in terms of bytes will the following variables take and how is it calculated?
S9(4) COMP
S9(5) COMP
S9(8) COMP
S9(9) COMP
S9(10) COMP


Hi ,

I have written a rexx routines named copyflds to compute the lenght and offset of each feild in a cobol copy member.
I think you don't need to change it much but you can customize it upon your name conventions.
One of The systax of calling it is:
TSO COPYFLDS dataset-name copy-member-name
which copy-member-name is the name of the cobol copy member name
and dataset-name is the name of the dataset which the copy members is reside in.
please copy both attach files COPYFLDS and COPYPICS into a dataset which is concatenated in your user sysproc ddname .

because I prepared it just for my site, I didn't prepared it any document so if there is any problem using it please put a message here.
Back to top
View user's profile Send private message
kamran

New User


Joined: 01 May 2005
Posts: 55

PostPosted: Thu Apr 27, 2006 4:58 pm
Reply with quote

Sorry I don't know why the mentioned bellow files didn't attached, So I will try it once!.
I think the problem was that I didn't select any extention for the files.
So use the attached files to this one!

Hi ,

I have written a rexx routines named copyflds to compute the lenght and offset of each feild in a cobol copy member.
I think you don't need to change it much but you can customize it upon your name conventions.
One of The systax of calling it is:
TSO COPYFLDS dataset-name copy-member-name
which copy-member-name is the name of the cobol copy member name
and dataset-name is the name of the dataset which the copy members is reside in.
please copy both attach files COPYFLDS and COPYPICS into a dataset which is concatenated in your user sysproc ddname .

because I prepared it just for my site, I didn't prepared it any document so if there is any problem using it please put a message here.[/quote]
Back to top
View user's profile Send private message
new2cobol

New User


Joined: 04 Jan 2006
Posts: 77
Location: Bangalore

PostPosted: Sat Apr 29, 2006 12:49 am
Reply with quote

This should help!!!
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 419
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Sat Apr 29, 2006 2:18 am
Reply with quote

Pranjal,

the official wisdom from IBM

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR30/5.3.17.1?DT=20050714120224
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Merge 2 lines based on Space from a S... DFSORT/ICETOOL 5
No new posts JCL with variables JCL & VSAM 1
Search our Forums:

Back to Top