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

Read a Hexdecimal file and convert to decimal


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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
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
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

Moderator Emeritus


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

PostPosted: Fri Oct 02, 2009 2:39 am
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

Moderator Emeritus


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

PostPosted: Fri Oct 02, 2009 2:42 am
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
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: 400
Location: Mumbai

PostPosted: Fri Oct 02, 2009 3:31 am
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
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
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
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
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Oct 02, 2009 11:44 pm
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
Reply with quote

prino,

It worked.. thank you...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Oct 03, 2009 3:13 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top