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

Built in Function


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

New User


Joined: 07 Jan 2009
Posts: 20
Location: Philippines

PostPosted: Thu Feb 05, 2009 6:40 am
Reply with quote

Is there a built in function in cobol that will convert decimal value to hexa decimal?
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: Thu Feb 05, 2009 6:51 am
Reply with quote

When you say "convert decimal" do you need to convert COMP-3 (Packed-Decimal) or DISPLAY (External-Decimal) to hexadecimal?

Regards,
Back to top
View user's profile Send private message
Julie Maquirang

New User


Joined: 07 Jan 2009
Posts: 20
Location: Philippines

PostPosted: Thu Feb 05, 2009 6:55 am
Reply with quote

DISPLAY (External-Decimal) to hexadecimal. icon_smile.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: Thu Feb 05, 2009 7:00 am
Reply with quote

Hello,

If you had 1234 in a pic 9(4) field, what is the pic and value you want in the "hexa decimal" field?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Feb 05, 2009 7:11 am
Reply with quote

Since ALL fields on a mainframe are hexadecimal, you need to be more specific about what you really want.
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: Thu Feb 05, 2009 7:46 am
Reply with quote

AFAIK, there isn't a builtin function.

Give this a try -

Code:

03  WS-NBR PIC 9(08) VALUE 12345678.
03  WS-NBR-X REDEFINES WS-NBR PIC X(08).
03  WS-PACKED PIC 9(16)V9 COMP-3 VALUE ZERO.
03  WS-PACKED-X REDEFINES WS-PACKED PIC X(09).
03  WS-DISPLAY PIC 9(16)V9.
03  WS-DISPLAY-X REDEFINES WS-DISPLAY PIC X(17).

MOVE WS-NBR-X TO WS-PACKED-X (1:8).
MOVE WS-PACKED TO WS-DISPLAY.
INSPECT WS-DISPLAY-X CONVERTING HIGH-VALUE TO 'F'.

At this point, WS-DISPLAY-X (1:16) = 'F1F2F3F4F5F6F7F8'

Regards,
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 Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top