MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

convert ???

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
jacky_ying
Beginner


Joined: 25 Jul 2004
Posts: 46
Topics: 20

PostPosted: Sat Jan 15, 2005 4:08 am    Post subject: convert ??? Reply with quote

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' Laughing
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun Jan 16, 2005 12:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun Jan 16, 2005 2:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
jacky_ying
Beginner


Joined: 25 Jul 2004
Posts: 46
Topics: 20

PostPosted: Sat Jan 22, 2005 8:10 am    Post subject: Reply with quote

Hi,slade:
THANKS FOR YOUR HELP!!! =^_^= Jacky 22/01
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group