View previous topic :: View next topic
|
Author |
Message |
reena_preethi
New User
Joined: 14 Jun 2006 Posts: 14
|
|
|
|
hello friends
i having i doubt regarding comp variables.
suppose if i store 7890 in comp3 var how it stores?
how it stores in comp var?
how we write pic class for 7890 in comp 3 & COMP var?
thanks in advance
preethi |
|
Back to top |
|
|
janamott
New User
Joined: 22 Dec 2005 Posts: 4 Location: Edison, NJ
|
|
|
|
A packed or comp-3 field occupies a number of spaces equal to (pic-clause-length / 2) + 1.
Drop any remainder when you divide the pic clause length by 2.
A field defined as PIC 9(4) COMP-3 will occupy only 3 bytes in storage ((4 / 2) + 1 ) = 3.
However, don't define your pic clause as only 3 bytes. It should be long enough for all your unpacked data.
In your example, your pic clause will be
01 WS-FIELDS.
05 TEST-COMP3-SIGNED PIC S9(4) COMP-3.
And your packed data will appear this way
080
79C
If you don't want a sign (c=positive, d=negative), your pic clause will be
05 TEST-COMP3-UNSIGNED PIC 9(4) COMP-3.
And your data will look like this
080
79F
A comp field also needs to have a pic clause long enough for all the field's unpacked data.
In your example, your pic clause can be either of the following
05 TEST-COMP-SIGNED PIC S9(4) COMP.
05 TEST-COMP PIC 9(4) COMP.
And your data will be stored like this
1D
E2 |
|
Back to top |
|
|
reena_preethi
New User
Joined: 14 Jun 2006 Posts: 14
|
|
|
|
thanks a lot janamott
regards
preethi |
|
Back to top |
|
|
|