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

Why we are using this comp usages instead of comp & comp


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

New User


Joined: 19 May 2005
Posts: 15

PostPosted: Sun Jun 19, 2005 11:33 am
Reply with quote

hi friends

i have confused with comp usage .

like comp-4 & comp-5.

why we are using this comp usages instead of comp & comp2

please give me a clear vision about this topic.

vinci
Back to top
View user's profile Send private message
sangiah

New User


Joined: 10 Jun 2005
Posts: 62

PostPosted: Tue Jun 21, 2005 12:13 pm
Reply with quote

The following common COBOL data types:

Binary
Computational (comp)
Comp-1
Comp-2
Comp-3
Packed Decimal
Some compilers have comp-4 and comp-5 data types, usually to emulate a comp type of another system, like an IBM mainframe. There are other COBOL binary data types, such as index and pointer, but they are used internally in the program, and are not found in files, so are not of concern to us. Comp-3 is so common and so uniform across platforms that we have written a separate Tech Talk brief for it. See COBOL Comp-3 Packed Fields.

How the PIC and USAGE affect storage
Which data type a field uses for storage is determined by the "usage is" clause in the field definition. For example,
05 BALANCE-DUE PIC S9(6)V99 USAGE IS COMPUTATIONAL-3.
says to store the field in the computational-3 format. The "usage is" part is optional and generally left off, and "computational" can be abbreviated "COMP", so you will more commonly see this written:
05 BALANCE-DUE PIC S9(6)V99 COMP-3.

The number of bits, bytes, or words that are stored for any given field usually depends on the number of digits given in the COBOL PIC. For binary numbers, 8 bits, or 1 byte, will store unsigned values from 0 to 255 or signed values from -128 to +127. This is enough to store values up to two digits (99), but not up to three digits (999). So a PIC 9 or PIC 99 would require 1 byte, but a PIC 999 would require 2 bytes.

In addition, most compilers have some minimum requirements for comp storage. For example, the smallest unit of storage may be 2 bytes, so even if you specify PIC 9 (only 1 digit), the compiler will reserve two bytes. Also see Synchronization and Alignment below.

Floating point numbers, however, follow standard binary formats and as such their sizes are not determined by a PIC, and no PIC is used in the field definition.

Comp-3 stores two digits per byte, in BCD form.


Data Types
Typical storage for common data types is given below.
Binary
The COBOL standard specifies that this should be a binary data type, but the exact implementation is up to the vendor. Negative numbers are typically in 2's-complement.
Comp (Computational)
Comp (with no suffix) leaves the choice of the data type to the compiler writer. The intent of this data type is to make it the most efficient format on any given machine, which is usually some binary format. Because of this, comp varies greatly between platforms, more than most other types.
Comp-1
Comp-1 is usually a single precision floating point value, stored in 4 bytes. Many vendors follow the IEEE floating point standard, but IBM does not.
Comp-2
Comp-2 is usually a double precision floating point value, stored in 8 bytes. Many vendors follow the IEEE standard, but IBM does not.
Comp-3
Although comp-3 is "vendor specific", the format of comp-3 fields is almost universal across platforms, even on ASCII machines. Comp-3 stores data in a BCD -- binary coded decimal -- format with the sign after the least significant digit. Comp-3 is so common that we have written a separate Tech Talk brief about it. See COBOL Comp-3 Packed Fields.
Packed Decimal
This is the "official" BCD packed format of the COBOL standard. It is implemented as "comp-3". See comp-3, above.

Synchronization and Alignment
This topic is a bit involved for this tutorial, but you should be aware of it. When using binary storage (binary and comp), some compilers on some machines (computers) may require that a numeric field start on some boundary. For example, on a 32 bit machine, it may require that a comp field start on a 32 bit boundary.
If you specify a comp field in the middle of a record, and it doesn't happen to begin on a 32 bit (4 byte) boundary, the compiler will "align" it to a 32 bit boundary to "synchronize" it. What's actually stored in the file is not the same as the PICs on the layout. This is not a very common problem, partly because binary and comp fields are not very common in files, but you should be aware of it.
Back to top
View user's profile Send private message
josephvincentd
Warnings : 1

New User


Joined: 19 May 2005
Posts: 15

PostPosted: Tue Jun 21, 2005 1:53 pm
Reply with quote

hi im really happy with this reply .now i have got the clear vision about
comp usage.really im very happy.thanks a lot my friend.

with thousands of thanks

vincent
Back to top
View user's profile Send private message
ameershaik

New User


Joined: 23 Jun 2005
Posts: 1
Location: bangalore

PostPosted: Thu Jun 23, 2005 9:52 pm
Reply with quote

how to find a total number of members present in a pds.
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Thu Jun 23, 2005 9:56 pm
Reply with quote

Ameershaik, this is not the correct forum but the answer is: Enter in your pds and at the top right you will see "Row 00001 of x"... when x is the total number of members.
Put your question in the correct forum and read the rule before a new post.
Thanks
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 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 Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top