IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Question about moving hex to pic x


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
zaphany

New User


Joined: 16 May 2006
Posts: 11

PostPosted: Mon Apr 07, 2008 10:10 pm
Reply with quote

Dear all, I was just wondering if there is a better way to move a hex value to X field, considering the length of the hex value is 512 and which X(256) is expected from it?

Code:

     01  FILLER
    *    WX-INPUT is something like A7F233D6C4
    *    somehow by a routine, it can convert to WX-OUTPUT = X'A7F233D6C4'
          05  WX-INPUT     X(512)
          05  WX-OUTPUT  X(256)


Please help!
[/code]
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Apr 07, 2008 10:22 pm
Reply with quote

Do you mean that you want to convert from a display form of an hex to an actual hex?
From C'A7F233D6C4' which is X'C1F7C6F2F3F3C4F6C3F4' to X'A7F233D6C4' which is C'x2.PD' where the '.' is unprintable......
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Apr 07, 2008 11:50 pm
Reply with quote

Code:

03  WS-PACKED-V9 PIC  9(16)V9 COMP-3.
03  WS-PACKED-X   REDEFINES WS-PACKED-V9
                              PIC  X(09).
03  WS-PACKED      REDEFINES WS-PACKED-V9
                             PIC  9(17)      COMP-3.
03  WS-DISPLAY-V9 PIC  9(16)V9.
03  WS-DISPLAY-X  REDEFINES WS-DISPLAY-V9
                             PIC  X(17).
03  WS-DISPLAY     REDEFINES WS-DISPLAY-V9
                             PIC  9(17).

MOVE 'A7F233D6C4' TO WS-DISPLAY-X (1:10).
MOVE ZERO TO WS-DISPLAY-X (11:).

INSPECT WS-DISPLAY-X CONVERTING 'ABCDEF' TO X'FAFBFCFDFEFF'.

MOVE WS-DISPLAY-V9 TO WS-PACKED-V9.

At this point, WS-PACKED-X = X'A7F233D6C40000000F'

Note that both NUMERIC fields must be unsigned.

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
zaphany

New User


Joined: 16 May 2006
Posts: 11

PostPosted: Tue Apr 08, 2008 12:16 pm
Reply with quote

Thanks a lot.
So due to the limitation of Comp field, I guess my 512 string need to be chopped and run few times to get the result, right? icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 08, 2008 7:45 pm
Reply with quote

Hello,

One easy way to do what you need is to define an array that contains all of the 2-byte values (representing from x'00' to x'FF') and then use the "hex-value" in each "input" byte as the displacement into the array to get the corresponding expanded value.

For example a one would return the 2-byte value F1.
Back to top
View user's profile Send private message
zaphany

New User


Joined: 16 May 2006
Posts: 11

PostPosted: Thu Apr 10, 2008 6:31 am
Reply with quote

Thanks a lot for all your help icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
Search our Forums:

Back to Top