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

Unable to interpret a hex value to Decimal coming in a file


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

New User


Joined: 09 Aug 2010
Posts: 33
Location: Chennai

PostPosted: Tue Nov 26, 2024 11:03 pm
Reply with quote

Hi all,
I am receiving a 10 byte hex value (like X'808E640000') in a file. Corresponding layout has a variable, defined as X(5).

Now i am supposed to convert that hex value to a decimal value of 12 bytes (like 552144732160).

How can i achieve this?. Since its a 10 byte, unable to use COMP.
Throw some light on this. I will try at my end.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1049
Location: Richmond, Virginia

PostPosted: Wed Nov 27, 2024 12:46 am
Reply with quote

I don't know if there is a COBOL function for this, but it should be easy enough to write the code to multiply each hex-digit's value by the value of its position and then add them up.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Wed Nov 27, 2024 1:44 am
Reply with quote

Try to use this:

Native binary (COMP-5) items
Back to top
View user's profile Send private message
selvamsrinivasan85

New User


Joined: 09 Aug 2010
Posts: 33
Location: Chennai

PostPosted: Wed Nov 27, 2024 9:57 am
Reply with quote

Hi Phil,
Thanks for the suggestion. Will give a try on that.

Hi Sergeyken,
If I declare as 9(9) comp-5, it occupies 4 bytes only and the last bytes is getting displayed on next variable and if i declare 9(10), it occupies 8 bytes. It looks like COMP and COMP-5 doesn't have any difference here.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Wed Nov 27, 2024 10:26 pm
Reply with quote

selvamsrinivasan85 wrote:
Hi Phil,
Thanks for the suggestion. Will give a try on that.

Hi Sergeyken,
If I declare as 9(9) comp-5, it occupies 4 bytes only and the last bytes is getting displayed on next variable and if i declare 9(10), it occupies 8 bytes. It looks like COMP and COMP-5 doesn't have any difference here.

You MUST declare your intermediate PIC 9(12) COMP-5 field (8 bytes), and populate its lower part with your initial X(5) - via REDEFINE, or any other trick.
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 Help required to reset decimal points... DFSORT/ICETOOL 3
No new posts batch SFTP job using AOPBATCH unable ... All Other Mainframe Topics 7
No new posts how to eliminate null indicator value... DB2 7
No new posts small int to zoned decimal conversion DFSORT/ICETOOL 3
No new posts Format Binary file to EBCDIC JCL & VSAM 4
Search our Forums:

Back to Top