Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Built in Function

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Built in Function
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 05, 2009 6:51 am    Post subject: Re: Built in Function
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    Post subject:
Reply with quote

DISPLAY (External-Decimal) to hexadecimal. icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Feb 05, 2009 7:00 am    Post subject:
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: 1239
Location: Richfield, MN, USA

PostPosted: Thu Feb 05, 2009 7:11 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 05, 2009 7:46 am    Post subject: Re: Built in Function
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us