by Scott Lippincott » Wed Jul 28, 2010 9:41 am
First, a PL8 field with valid packed data has 15 digits and a trailing sign nibble. The value is right-justified.
For example:
The number +123451234567890 is stored in 8 bytes as x'123451234567890C'.
The value -95365 is stored in 8 bytes as x'000000000095365D'.
If you wanted an 8 digit number(+12345678), it would require a 5 byte packed field with a capacity of 9 digits x'012345678C' (number of digits in a packed field is always odd, so storing 8 digits in 5 bytes results in a leading zero)
I'm not sure what you mean by "first 2 positions of a PL8 field" This could be interpreted as 2 digits(one byte), or two bytes(with a value of x'9596').
If you meant that you wanted to test the first 2 digits of a 15-digit packed field, you CAN compare the leftmost byte of the field with CLI or CLC instructions.
ZAP CTLNO,=P'950000000000000'
CLC CTLNO(1),CON96
BE . . .
CLI CTLNO,X'96'
BE . . .
CTLNO DS PL8
CON9596 DS 0CL2
CON95 DC X'95' DC PL1'95' is invalid(value exceeds field size); DC P'95' is a 2 byte field with a value of x'095c'
CON96 DC X'96'
If you meant the first two bytes of the packed field. Using the storage defined above:
CLC CON9596,CTLNO (using the CON9596 as the first operand causes the length of the compare to be 2 bytes)
BE . . .
or
CLC CTLNO(2),CON9596 (length must be coded, or the length used would be the length of the first operand 8 bytes)
BE . . .
This all works ONLY if the digits you are testing for in the packed field are in a fixed position, and the pair(s) of digits exist in the same byte(s).