Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to store 9999999 in 3 bytes space

Status
Not open for further replies.

sreeja1611

Programmer
Sep 3, 2002
7
FR
Hi,
I have the following probelm. We have RM/COBOL 6.6.

01 test.
02 test1 pic 9(5).
02 test1-r redefines test1.
03 test11 pic 9(4) comp-4.
03 test12 pic 9(7) ?????.

what kind of 'comp' I need to use here.

Thanks in Advance
Ravi
 
In Microfocus COBOL (and other dialects that permit 3-byte binary fields), the USAGE would be COMP (-4, -5, or no -) or BINARY.

In dialects that do not permit 3-byte binary fields, you have to get around that limitation. The is the way I did it back in the 60's:
[tt]
03 TEST12 PIC X(3).
. . .
01 4-BYTE-BINARY PIC 9(7) COMP.
01 FILLER REDEFINES 4-BYTE-BINARY.
05 FILLER Pic X(1).
05 3-BYTES Pic X(3).
. . .
MOVE input-data TO 4-BYTE-BINARY.
MOVE 3-BYTES TO TEST12.
[/tt]
 
Ravi,

There is a way in RM/COBOL version 7.

You would code:
Code:
01 test.
   02 test1  pic 9(5).
   02 test1-r redefines test1.
      03 test11 pic 9(4) comp-4.
      03 test12 pic 9(7) comp-4 (3).

You may eliminate the need for the "(3)" in your source code by using the BINARY-ALLOCATION=MF-RM compiler configuration directive.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top