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: 8651
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: 8651
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 Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts Need to find a specific STRING COBOL Programming 11
No new posts SORT - To repeat a string in same col... SYNCSORT 3
No new posts JCL - To repeat a string in same colu... JCL & VSAM 2
Search our Forums:

Back to Top