Loading

COMP and COMP-3 equivalent variables in Easytrieve

I suggest you to read Easytrieve variable declaration first to see how to declare variables in Easytrieve. That will give you a better idea about Easytrieve variable.

COMP in Cobol is a Binary variable.

It can be of 2 bytes, 4 bytes or 8 bytes.

COMP variables are always signed. It is also known as BINARY in cobol.

COMP or BINARY Number of Bytes Easytrieve variable
S9(1) COMP.

..

S9(4) COMP.

9(1) COMP.

..

9(4) COMP.

S9(1) BINARY.

S9(4) BINARY.

9(1) BINARY.

..

9(4) BINARY.

2 bytes WS-VAR W 2 B
S9(5) COMP.

..

S9(9) COMP.

9(5) COMP.

..

9(9) COMP.

S9(5) BINARY.

S9(9) BINARY.

9(5) BINARY.

..

9(9) BINARY.

4 bytes WS-VAR W 4 B
S9(10) COMP.

..

S9(18) COMP.

9(10) COMP.

..

9(18) COMP.

S9(10) BINARY.

S9(18) BINARY.

9(10) BINARY.

..

9(18) BINARY.

8 bytes WS-VAR W 8 B

COMP-3 or Packed decimal variables.
P stands for Packed – in Easytrieve variable declaration.
Length specified in Easytrieve always specifies the number of bytes occupied and not number of digits.
For eg,

 WS-VAR S9(3) COMP-3.

will be occupying 2 bytes and the corresponding Easytrieve declaration is

 WS-VAR W 2 P 0 


The zero after P specifies the number of digits after decimal point (implicit).

Another eg,

 WS-VAR S9(5)V99 COMP-3.

will be occupying 4 bytes and the corresponding Easytrieve declaration is

 WS-VAR W 4 P 2


The 2 is for the 2 digits after decimal point, and the 4 still means the total 4 bytes occupied. Note that the 2 is not 2 bytes and just specifies the 2 digits after decimal point.

Read more about Easytrieve variable declaration.

Related Posts




blog comments powered by Disqus

There's 5 Comments So Far

Share your thoughts, leave a comment!