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

String has hex character need to convert it to decimal


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

New User


Joined: 11 Aug 2022
Posts: 2
Location: Netherlands

PostPosted: Thu Aug 11, 2022 11:34 pm
Reply with quote

Hello,

I have a field which is declared as pic x(08) contains character.

01 WS-Date PIC X(08).

Having string value 52B30011 direct string not stored as hexadecimal . I want to convert this into decimal/integer value.

Expected value : 1387462673

Thanks in advance.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2022 12:48 am
Reply with quote

This is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. Once you've worked out the logic you need, if you have problems then you can post what the issue(s) are.

Hint: use reference modification to isolate each character, evaluate its value and multiply that value by the appropriate power of 16 and accumulate those values.
Back to top
View user's profile Send private message
ndilipan

New User


Joined: 11 Aug 2022
Posts: 2
Location: Netherlands

PostPosted: Fri Aug 12, 2022 12:56 am
Reply with quote

Hello Robert,

Thank you so much, I have written that logic multiplying by 16 with power sorry for not posting that in prior. I have posted to check, is there any function we can do it.

Thanks again!! icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2022 2:14 am
Reply with quote

No, there is no function to do what you want. Intrinsic function HEX-TO-CHAR converts a hexadecimal value to a character string, but you already have the character string. And the NUMVAL intrinsic functions don't work on hexadecimal values, just decimal ones.
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 Convert Service Unit to CPU Seconds All Other Mainframe Topics 1
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts ICETOOL to SUM String DFSORT/ICETOOL 1
Search our Forums:

Back to Top