View previous topic :: View next topic |
Author |
Message |
jacky_ying Beginner
Joined: 25 Jul 2004 Posts: 46 Topics: 20
|
Posted: Sat Jan 15, 2005 4:08 am Post subject: convert ??? |
|
|
Hi,how to do this in cobol:
wk-aa pic x(5) value X'DBB623BAC1'.
wk-bb pic x(10).
now,I want wk-bb = 'DBB623BAC1' |
|
Back to top |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Sun Jan 16, 2005 12:08 pm Post subject: |
|
|
Hi Jacky,
Here's something that might do what you want. Just move your wk-aa to my
WS-WORK-X5.
The data structure is a bit over-done because I was using it for other purposes as well. Just try it as is and when you get it working you might want to simplify the structure.
Good luck.
Code: |
05 WS-WORK-PACKED PIC 9(009) COMP-3.
05 REDEFINES WS-WORK-PACKED.
10 WS-WORK-X5.
20 WS-WORK-X1 PIC X(001).
20 WS-WORK-X3 PIC X(003).
05 REDEFINES WS-WORK-PACKED.
10 WS-WORK-BIN4 PIC 9(009) COMP.
05 WS-WORK-UNPACKED PIC 9(009).
05 REDEFINES WS-WORK-UNPACKED.
10 WS-WORK-UNPACKED-8 PIC 9(008).
100-CONVERT-HEX-DATA.
*--------------------------------------------------
* CONVERTS HEX DATA FOR DISPLAY PURPOSES
* E.G. X'04FB' => X'F0F4C6C2' OR 04FB CHARACTER
*--------------------------------------------------
MOVE WS-WORK-PACKED TO WS-WORK-UNPACKED
INSPECT WS-WORK-UNPACKED CONVERTING
X'FAFBFCFDFEFF' TO 'ABCDEF'
DISPLAY WS-WORK-UNPACKED-8
.
|
_________________ Regards, Jack.
"A problem well stated is a problem half solved" -- Charles F. Kettering |
|
Back to top |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Sun Jan 16, 2005 2:51 pm Post subject: |
|
|
Oops, I forgot to mention that you'll have to adjust the field lengths to suit your needs. E.g., WS-WORK-PACKED s/b PIC 9(011); WS-WORK-X5 s/b WS-WORK-X6
PIC x(006); etc.
Always alloc one byte more than the length of your subject field because the unpacking process handles the low ord byte differently than the others. _________________ Regards, Jack.
"A problem well stated is a problem half solved" -- Charles F. Kettering |
|
Back to top |
|
|
jacky_ying Beginner
Joined: 25 Jul 2004 Posts: 46 Topics: 20
|
Posted: Sat Jan 22, 2005 8:10 am Post subject: |
|
|
Hi,slade:
THANKS FOR YOUR HELP!!! =^_^= Jacky 22/01 |
|
Back to top |
|
|
|
|