ABC character field of length 4, value = 0800 (F0F8F0F0)
and I have to convert it to
XYZ character field of length 2, value = 0800 (0800) (packed)
How is it possible ? How can I do it using any API or any utility, if
I can get the source, that will of great help to me.
Similarly, I have to do the reverse. i.e.,
2-digit character field having value (0800) (packed, not viewable
unless used F22-DSPHEX in debugger to see value )
into 4-digit character field having value (0800)
Note: I cannot use ILE RPG due to certain unavoidable restrictions.
I have tried using the following code
I IDS 4
I 1 4 Hex
I 1 2 Hex1
I B 1 20Binary
C move abc binary (value of abc is f0f8f0f0 , or
0800 - abc is 4-char)
now HEX1 has value 0320 in hexadecimal, which is 800 in decimal.
However, I need this value (0320) to be 800 in a character field of
length-2 . How can I do that ? and vise versa ?
Thanks in advance for your time and favaor
Regards
Ammar Farooq
"Ammar Farooq" <ammar...@yahoo.com> wrote in message
news:1d4eafdf.04011...@posting.google.com...
C MOVE PACK2 XYZ 2
*
* Now XYZ contains x'0800'
*
* Do the reverse:
C Z-ADD0 PACK51
C MOVE XYZ PACK2
C Z-ADDPACK51 ZONE4
* Now ABC contains x'F0F8F0F0'
*
C SETON LR
(This assumes that ABC and XYZ always contain valid decimal digits.)
--Dave
If you truly want to go to length 2, packed unsigned:
Create a packed 5 0 field. (It will be 3 bytes long.)
MOVE char field to this field. Or if on V5R2, use %DEC.
Multiply field by 10.
Use a data structure to get the first 2 bytes of the field.
Sam
"Ammar Farooq" <ammar...@yahoo.com> wrote in message
news:1d4eafdf.04011...@posting.google.com...
You were on the right track before, but you need to use P not B, and a
bit of fixup because of sign half-byte in packed values.
IUNPACK IDS 4
I 1 40ZONED
IBYTE2 IDS 3
I 1 2 PACK
I 1 30PACKED
Using 1234 for example instead of 0800:
C MOVE DATA UNPACK
* UNPACK = ZONE = F1F2F3F4
C Z-ADD ZONE PACKED
* ZONE was F1F2F3F4, PACKED is now 01234F
C MULT 10 PACKED
* PACKED is now 12340F, PACK is 1234
To go the other way,
set PACKED to zero, PACKED=00000F
load your 2-byte value into PACK, PACKED=12340F
divide PACKED by 10 PACKED=01234F
Z-ADD PACKED to ZONED. UNPACK=ZONED=F1F2F3F4