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
 

 

Read a Hexdecimal file and convert to decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Fri Oct 02, 2009 1:03 am    Post subject: Read a Hexdecimal file and convert to decimal
Reply with quote

I'm now in the process of writing the Rexx program to read a file that contains Hex values. I have to get some values and convert them into Decimal. Can anyone suggest how to read only few col in file that is in hex values.

Any suggestions would be really greatfull
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Oct 02, 2009 1:10 am    Post subject: Re: Read a Hexdecimal file and convert to decimal
Reply with quote

GaneshKarunyarajan wrote:
I'm now in the process of writing the Rexx program to read a file that contains Hex values. I have to get some values and convert them into Decimal. Can anyone suggest how to read only few col in file that is in hex values.

Any suggestions would be really greatfull


Would these "hex values" happen to be packed decimal data?
Back to top
View user's profile Send private message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Fri Oct 02, 2009 2:34 am    Post subject:
Reply with quote

This is how the file looks like.
Command ===>
********************************* Top of Data **
...Ã.....INTEGER ....


I will have to read this and convert to a decimal value.
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: Fri Oct 02, 2009 2:39 am    Post subject:
Reply with quote

Hello,

You need to re-post that data as shown using HEX ON. Also, please use the Code tag (which preserves alignment and greatly improves readability.

After properly posting the input, then post the desired output from that input.

There is a Preview feature that will let you see your post as it will appear to the forum (rather than how it appears in the Reply editor).
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: Fri Oct 02, 2009 2:42 am    Post subject:
Reply with quote

Additionally,

There is no such thing as a "hexadecimal file" on the mainframe (or if you prefer, every file is stored in hexadecimal).

There are alphabetic, alphanumeric, and multiple numeric data formats - all have hexadecimal values.
Back to top
View user's profile Send private message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Fri Oct 02, 2009 3:21 am    Post subject:
Reply with quote

Here is the file with hex on. As suggested file with CODE TAG.
Code:
 
Command ===>         
**********************
                     
                     
 ---------------------
...Ã.....INTEGER ....
030601000CDECCCD400004
19163500B9535759004000
 ---------------------
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Fri Oct 02, 2009 3:31 am    Post subject: Reply to: Read a Hexdecimal file and convert to decimal
Reply with quote

Look at the substr() and x2d() functions in Rexx. These will be a start. Then you may want to look at other string handling functions (pos, left, right, and others) as well as other conversion functions (d2x, and others)

You will have to read the whole record and break it up with substr.

When you get more comfortable with Rexx, you will probably want to use the Parse instruction instead of substr() because it is easier to read and more efficient.
Back to top
View user's profile Send private message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Fri Oct 02, 2009 4:03 am    Post subject:
Reply with quote

I will be start with MBabu's suggestion and work on it. Thanks a lot for your help for now.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Oct 02, 2009 4:34 am    Post subject:
Reply with quote

How big is the file?
Back to top
View user's profile Send private message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Fri Oct 02, 2009 9:14 pm    Post subject:
Reply with quote

not a very big file.. 10 - 20 line file
Back to top
View user's profile Send private message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Fri Oct 02, 2009 10:53 pm    Post subject:
Reply with quote

It is a requirement that I'm working on.
I used SUBSTR() function and then used X2D() but
Here is what I'm getting the error.

DD = SUBSTR(LINE,1,2)
a = x2d(DD)

When I run the routine, I'm getting

"Error running HEX2DEC, line 45: Incorrect call to routine "
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Fri Oct 02, 2009 11:44 pm    Post subject:
Reply with quote

a = x2d(c2x(dd))
Back to top
View user's profile Send private message
GaneshKarunyarajan

New User


Joined: 12 Apr 2005
Posts: 13

PostPosted: Sat Oct 03, 2009 1:51 am    Post subject:
Reply with quote

prino,

It worked.. thank you...
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: Sat Oct 03, 2009 3:13 am    Post subject: Reply to: Read a Hexdecimal file and convert to decimal
Reply with quote

Hello,

Several "extra" replies have been deleted.

Ganesh,
Good to hear it is working - thanks for letting us know icon_smile.gif

d
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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