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
 

 

Why is length declared as COMP is most cases

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

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Fri Jun 01, 2007 10:00 am    Post subject: Why is length declared as COMP is most cases
Reply with quote

Hi,

Why is length declared as COMP is most cases?

e.g. S9(4) COMP

Why is it not any other member of COMP family? icon_eek.gif
Back to top
View user's profile Send private message

devidas-patil

New User


Joined: 08 Jan 2007
Posts: 54
Location: pune

PostPosted: Fri Jun 01, 2007 10:32 am    Post subject:
Reply with quote

i guess S9(4) comp will take 2 bytes and most of the times for storing length of message in cics, null indicator we use s9(4) comp. thats why. and another thing if we use s9(5) then un-neccesarily it will take 4 byte and is we use usage. alos it help in case of Comp sync that why
please let me know if i a mwrong so that i can update to myself.
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Fri Jun 01, 2007 10:36 am    Post subject:
Reply with quote

My question is why we use COMP in particular for length..
why not COMP1,COMP2 or COMP3?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Jun 01, 2007 11:30 am    Post subject:
Reply with quote

I guess You mean 'length' in
Linkage section when we pass parameters through
OR
length of record in RDW
There is no explanation for this- system is designed to work with binary numbers (COMP) in those cases.
If you meant anything else then please elaborate.
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Fri Jun 01, 2007 11:54 am    Post subject:
Reply with quote

thanks abhijit...

i have one more doubt...

Why do u use COMP for null indicators... is it the same reason.. that system underastands Binary?

If we had used HEX (COMP-3)what would have have been the problem?
b'coz in HEX also we can indicate +ve / -ve values...
or this is also related to system design?

Can u please xplain?
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 147
Location: Columbia, MO

PostPosted: Fri Jun 01, 2007 11:34 pm    Post subject: Re: Why is length declared as COMP is most cases
Reply with quote

If I understand you correctly, you simply want to know why we use COMP fields at all? icon_confused.gif

The simple answer is: to save storage.

Back when mainframes were new, storage was extremely expensive (and programmers were comparativley very cheap). So we developed was to cram as much information into as little space as possible - hence the COMP numeric fields.

That's the short answer. To understand why we use COMP, COMP1, COMP2 and COMP3, you have to look at the differences between them. For example, if I wanted to save space and didn't have to worry about whether the number was positive or negative - in the case of a table index for example - I woud use a COMP field. For other reasons to use the other types of COMP field, check out the programming manuals link at the top of the page.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 2:17 am    Post subject:
Reply with quote

I hate to break this to you, but the COMP or COMP5 & 4?) are all valid binary. COMP1 & 2 are floating point and would never be used. Binary is used for length because the usual application for a length field is addition to an address and that is register math.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 2:19 am    Post subject:
Reply with quote

pingte wrote:
Why do u use COMP for null indicators... is it the same reason.. that system underastands Binary?

If we had used HEX (COMP-3)what would have have been the problem?
b'coz in HEX also we can indicate +ve / -ve values...
or this is also related to system design?
Ok, I'll go look it up, I do need a little better understanding of null indicators.....
Be back shortly.....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jun 02, 2007 2:21 am    Post subject:
Reply with quote

Hello,

COMP fields are used in the situations you mentioned because IBM implemented as such. If you look at assembler code, you will see that many (nearly all) assembler instructions and system control blocks use 1, 2, and 4-byte binary fields as length, displacement, and incremental values. A 1-byte binary field is also a way to store 8 on/off switches in only 1 byte.

Most business code (quantities, rates, values, etc) are usually stored as comp-3 because the assembler business arithmetic instructions and editing require packed-decimal operands.

As s_d mentioned a big reason was to save space.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 2:40 am    Post subject:
Reply with quote

pingte wrote:
Why do u use COMP for null indicators... is it the same reason.. that system underastands Binary?

If we had used HEX (COMP-3)what would have have been the problem?
b'coz in HEX also we can indicate +ve / -ve values...
or this is also related to system design?
OK, they could have used a simple one byte flag, but with the comp they allow for a two way decision, first, if negative, the result is a null (nothing exists in this column) value. Second, if -1 then it's a null, if -2 then it's null (nothing) because of errors.

And a word of advice, HEX and COMP-3 are not synonyms. HEX id eight bit representation for a character while COMP-3 is packed decimal and PD does not encompass all the potential HEX characters.

If you can't grok this, I suggest you open a new thread in the appropriate forum and ask that question.

BTW, what do you mean by "+ve / -ve values"?
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 Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 6 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm


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