How to read HEX file and convert it into decimal in REXX.

Ask/Clarify the questions on TSO, CLIST & REXX

Moderators: Veera, Moderator Group

Post Reply
mpawan
Member
Posts: 9
Joined: Mon Jan 18, 2010 2:06 pm
Location: Hyderabad

How to read HEX file and convert it into decimal in REXX.

Post by mpawan » Mon Jan 18, 2010 2:19 pm

Hi,

I have a file in which data is in the Hex format as below.

?..%.?..........?......@...

And when i give a command 'HEX ON' then the data in the file is converted as below.

?..%.?..........?......@...
A00608020002013040000007300
A93C9C3C200C00C953C05C2C4CC

Now i want to read the file in the HEX format and want to bring some data in to some variables.

Eg: Varable A must be equal to 09036C.

Can anyone please help me with that.
Thanks & Regards
M Pawan

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Mon Jan 18, 2010 3:44 pm

lookat 4.3.14 C2X (Character to Hexadecimal)

here is a REXX (or routine) that you can CALL:

Code: Select all

/* REXX  CONVERT PACKED DECIMAL TO NUMBER */   
PARSE ARG PACK_NUM                             
HEX_NUM  = C2X(PACK_NUM)                       
SIGN  = RIGHT(HEX_NUM,1)                   
NUMBER  = LEFT(HEX_NUM,LENGTH(HEX_NUM)-1)     
IF SIGN = 'D' THEN                             
  RETURN '-'| |NUMBER                         
ELSE                                           
  RETURN NUMBER 
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

mpawan
Member
Posts: 9
Joined: Mon Jan 18, 2010 2:06 pm
Location: Hyderabad

Post by mpawan » Mon Jan 18, 2010 4:35 pm

Thanks a lot .. :)

it worked ... but can you explan me the code.
Thanks & Regards
M Pawan

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Mon Jan 18, 2010 4:38 pm

but can you explan me the code.(sic)
no,

use
TRACE ?R
to follow the flow and refer to the manual for info on instructions.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

mpawan
Member
Posts: 9
Joined: Mon Jan 18, 2010 2:06 pm
Location: Hyderabad

Post by mpawan » Mon Jan 18, 2010 4:41 pm

Thanks a lot.
Thanks & Regards
M Pawan

patrickhanagan
Member
Posts: 1
Joined: Tue Nov 02, 2010 12:07 am

REXX CONVERT PACKED DECIMAL routine is great!

Post by patrickhanagan » Tue Nov 02, 2010 1:05 am

hey Dick... your solution works like a champ... thanks very much!
here is a REXX (or routine) that you can CALL:
Code:

/* REXX CONVERT PACKED DECIMAL TO NUMBER */
PARSE ARG PACK_NUM
HEX_NUM = C2X(PACK_NUM)
SIGN = RIGHT(HEX_NUM,1)
NUMBER = LEFT(HEX_NUM,LENGTH(HEX_NUM)-1)
IF SIGN = 'D' THEN
RETURN '-'| |NUMBER
ELSE
RETURN NUMBER

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Tue Nov 02, 2010 3:36 am

actually the routine came from someone else, and can't remember who I stole it from,
but here is a list of Sites that you should visit if you want to add to your tools:

Doug Nadel's site a must see
lionel B dyck's site visit this also
Rexx Examples old but useful
Dave's MVS Freeware - Rexx
and the american programmer has a lot of useful info
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others