Re: convert packed CHAR to unpacked DIGIT
- From: Joe Zitzelberger <joe_zitzelberger@xxxxxxxxxx>
- Date: Fri, 29 Apr 2005 23:52:57 -0400
In article <1113616966.172135.175650@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"ssb" <mail_ssb@xxxxxxxxx> wrote:
> Hi,
>
> Input record has a field of size 5 bytes containing packed numbers. But
> this field is defined as CHARACTER.
>
> E.g. WS-A PIC X(5) '1212343455'
>
> My task is to display '1212343455' on a report. Obviously, it requires
> converting packed to unpacked numbers.
>
> I tried doing something like this:
>
> MOVE X(5) TO 9(9) COMP-3.
> REDEFINE 9(9) COMP-3 AS 9(10)
>
> Any suggestions/help..? Thanks.
77 I Pic S9(8) comp.
77 X Pic S9(4) comp.
77 Y Pic S9(4) comp.
77 Z Pic S9(4) comp.
77 HEX Pic X(16) value '0123456789abcdef'.
77 WS-A-OUT Pic X(10).
Perform varying I from 1 by 1
until I > length of WS-A
Move 0 to X Y Z
Move WS-A (I:1) to X (2:1)
Divide X by 16 giving Y remainder Z
Move HEX (Y:1) to WS-A-OUT (I*2:1)
Move HEX (Z:1) to WS-A-OUT (I*2+1:1)
End-Perform
Happy hacking --- btw, there is one small gotcha left as an exercise for
the reader...
.
- Follow-Ups:
- Re: convert packed CHAR to unpacked DIGIT
- From: James J. Gavan
- Re: convert packed CHAR to unpacked DIGIT
- References:
- convert packed CHAR to unpacked DIGIT
- From: ssb
- convert packed CHAR to unpacked DIGIT
- Prev by Date: Re: OT - "lie" vs "error"
- Next by Date: Re: CSF and Mainframe
- Previous by thread: Re: convert packed CHAR to unpacked DIGIT
- Next by thread: Re: convert packed CHAR to unpacked DIGIT
- Index(es):
Relevant Pages
|