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

Why is length declared as COMP is most cases


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 691
Location: Earth

PostPosted: Fri Jun 01, 2007 11:30 am
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
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: 177
Location: Seattle, WA

PostPosted: Fri Jun 01, 2007 11:34 pm
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: 3156
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 2:17 am
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: 3156
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 2:19 am
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

Moderator Emeritus


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

PostPosted: Sat Jun 02, 2007 2:21 am
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: 3156
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 2:40 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts VB to VB copy - Full length reached SYNCSORT 8
Search our Forums:

Back to Top