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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PIC S9(07) COMP-3 1

Status
Not open for further replies.

claudeb

Programmer
Nov 23, 2000
140
0
0
CA
hi
i have a
05 X PIC S9(07) COMP-3
and would like to redefine it as a
05 X12 redefines X.
10 X-1 PIC S9(02) COMP-3 and
10 X-2 PIC S9(05) COMP-3
what's wrong with that ?
i get an abend ASRA !
thanks for your help
claudeb
 
Claudeb,

I don't know what ASRA is but looks to me like you will have a problem with signs at the very least. If you only accessed X-2 and X-1 (for instance) it would probably be ok but as soon as you try to access X you will find signs in the middle of a numeric packed field. Initialize X-1 and
X-2 and you will get 00 0C 00 00 in X (where 0C is +).

Hope this helps.
Kfmason
 
Claudeb
According to my manual, s9(7) comp-3 requires 4 bytes, while s9(2) comp-3 requites 2 bytes and s9(5) comp-3 requires 3 bytes for a total of 5 bytes. I've always moved a comp-3 field to a non-comp field before redefining.

dlittlesr
 
The problem with the redefines is that the length is not equal but also the redefines does not create two signed fields!

If x contains +1234567 the hexacedimal value will be x'1234567C'. You probably want to get the first two ciphers off from the comp-3 field which is possible, but not with this definition. You can define x-1 as a single byte and put it in front of a valid signed field if that is what you need. So if x-1 has a picture x, you can define something like:

01 TRICK-FIELD.
03 FRONT-OF-COMP-3 PIC X.
03 VALID-SIGN PIC S9 COMP-3 VALUE ZERO.
01 TRICK-NUMBER REDEFINES TRICK-FIELD PIC S9(3) COMP-3.

IF you move x-1 to front-of-comp-3, you can use the numeric field trick-number, but it has a 10 times higher value.

The other and much easier way is of course to move it to a normal numeric field but even then you have some difficulties with the sign. You can define it as a separate sign. The unsigned pic 9(7) field can be redefined for the separate ciphers.

I hope this helps.
 
If you want to manipulate sections of a numeric value using a redefinition, i think you should ditch the comp-3 all together. Also, to evade problems with signs, lose those, too.
A definition like

01 X PIC 9(07).
01 X12 REDEFINES X.
03 X1 PIC 9(02).
03 X2 PIC 9(05).

will provide access to the first two, resp. the last five digits of X seperately.
In spite of it's obvious limitations, you will at least have none of the problems mentioned above.

Good luck !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top