REXX Code - Converting HEX(EBCDIC) to Strings(readable)



IBM's Command List programming language & Restructured Extended Executor

REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby hakghen » Thu Oct 29, 2009 10:43 pm

Hello Friends!

Here I am again taking your time :S

I'm trying to figure out by myself but I'm having a lot of trouble, here's the problem:

I have a member on a dataset (z/OS, V1R6, being accessed via 3270 emulator) that contains this data:

E3C8C9E240E8C5C1D9E240E3D9C1D5E2D3C1E3C9D6D540C5E7C5D9C3C9E2C540E6C9D3D300010003
40D7D9D6E5C9C4C540E8D6E440E6C9E3C840F540D8E4C5E2E3C9D6D5E240C6D6D940D6E400020003
D940E2E8E2E3C5D440E940D9C5D3C1E3C5C440C3D9D6E2E2E6D6D9C44BE6C540E5C5D9E800030003
40D4E4C3C840C8D6D7C540E8D6E440C3C1D540E3D9C1D5E2D3C1E3C540E3C8C540D8E4C500040003
E2E3C9D6D5E240C1D5C440E3C8C1E340E8D6E440E6C9D3D340D2D5D6E640E3C8C540C1D500050003
E2E6C5D9E2407A605D40C7D6D6C440D3E4C3D25A4DF2F640C1C3D9D6E2E25DE6C8C1E34000060003
C9E240E3C8C540F860C2C9E340C3C8C1D9C1C3E3C5D940C5D5C3D6C4C9D5C7404DC3D6C400070003
C540D7C1C7C55D40E4E2C5C440D6D540C9C2D440D4C1C9D5C6D9C1D4C540D6D7C5D9C1E300080003
C9D5C740E2E8E2E3C5D4E240E2E4C3C840C1E240E961D6E26F404DF65D4DF1F140C1C3D900090003
D6E2E25D40D5C1D4C540D6D5C540D6C640E3C8C540C3D6D4D4C1D5C440D3C1D5C7E4C1C700100003
C5E240E2C8C5D3D340E2C3D9C9D7E360E3E8D7C540D7D9D6C3C5E2E2C9D5C740C6D6D94000110003
E3E2D640E4E2C5D9E26F404DF55D4DF540C1C3D9D6E2E25D40E3C8C540D9C1D5C7C540D600120003
C640E5C9D9E3E4C1D340C1C4C4D9C5E2E2C5E240E3C8C1E340E3C8C540D6D7C5D9C1E3C900130003
D5C740E2E8E2E3C5D440C1E2E2C9C7D5E240E3D640C140E4E2C5D940D6D940E2C5D7C1D900140003
C1E3C5D3E840D9E4D5D5C9D5C740D7D9D6C7D9C1D440C9E240C3C1D3D3C5C440C1D5404D00150003
F76BF55D4DF1F440C1C3D9D6E2E25D40C1D540C9D5D7E4E361D6E4E3D7E4E340C4C5E5C900160003
C3C540D6D540C140C3D6D4D7E4E3C5D96B40E4E2C5C440C2E840E3C8C540C3D6D4D7E4E300170003
C5D940D6D7C5D9C1E3D6D94B404DF75D4DF740C4D6E6D55D40E6C8D6E240D9D6D3C540C900180003
E240C9E340E3D640D4D6D5C9E3D6D9405040C3D6D5E3D9D6D340D6D7C5D9C1E3C9D6D54000190003
D6C640E3C8C540D4C1C9D5C6D9C1D4C540C8C1D9C4E6C1D9C540C1D5C440E2D6C6E3E6C100200003
D9C56F404DF66BF85D                                                      00210003


This is the HEX representation of EBCDIC. What I need to do is: write a REXX code that reads this member and then creates a new member, on the same dataset, but with these data that he read all converted to a "String" format, I mean, a format that you can -actually- read and understand the message.

If possible, I would also like to know if there is a native function on the TSO to convert it. I tried the HEX option when editing the member, but no success. I also tried using the OPUT and OGET commands to transfer between OMVS and Datasets, but also failed...

I have a sample code that reads the dataset, but It's a bit difficult to modify, here it is:

/* REXX */                                                             
/*********************************************************************/
/* This EXEC reads a sequential dataset or PDS member and counts the */
/* number of lines it contains                                       */
/*********************************************************************/
trace o                                                               
                                                                       
parse upper arg Dataset .                                             
if (dataset='' | sysdsn(dataset)^='OK') then ,                       
   do                                                                 
      say 'Invalid dataset name entered, terminating'                 
      exit                                                           
   end                                                               
                                                                     
/* Allocate the file */                                                 
address TSO "ALLOC F(IN) DA("dataset") SHR REU"                         
if RC>0 then exit                                                       
                                                                       
/* Read all the records in to array Lines. */                           
"EXECIO * DISKR IN (STEM Lines."                                       
if RC>0 then signal Stop                                               
say Dataset' contains 'lines.0' Lines'                                 
                                                                       
Stop: "EXECIO 0 DISKR IN (FINIS"                                       
address TSO "FREE F(IN)"                                               
exit                                                                   


Well, that's it. Thanks for the attention!
[]'s,

Hakghen
User avatar
hakghen
 
Posts: 59
Joined: Thu Sep 11, 2008 8:15 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

 

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby MrSpock » Thu Oct 29, 2009 11:15 pm

Simple.

Use the X2C (Hexadecimal to Character) function for each line of data, i.e.:

The first line:

record = 'E3C8C9E240E8C5C1D9E240E3D9C1D5E2D3C1E3C9D6D540C5E7C5D9C3C9E2C540E6C9D3D3'
Say X2C(record)

results in

THIS YEARS TRANSLATION EXERCISE WILL
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby hakghen » Fri Oct 30, 2009 6:52 pm

Hi Spock!

Thanks for the help, I managed to understand it, trying here with a bit success... The code is not complete yet, but I'm advancing fast ;)

Thanks again for the help!!
[]'s,

Hakghen
User avatar
hakghen
 
Posts: 59
Joined: Thu Sep 11, 2008 8:15 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby SkIv1989 » Wed Dec 02, 2009 11:32 pm

If possible, I would also like to know if there is a native function on the TSO to convert it.

it very interesting, can anybody tell?
SkIv1989
 
Posts: 2
Joined: Wed Dec 02, 2009 10:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby dick scherrer » Thu Dec 03, 2009 4:14 am

Hello and welcome to the forum,

The link posted by Mr Spock does this. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby SkIv1989 » Thu Dec 03, 2009 9:34 am

Hello dick scherrer,
when i put X2C('F7F2 A2') in command line TSO, i get message what "command X2C not found"
SkIv1989
 
Posts: 2
Joined: Wed Dec 02, 2009 10:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Code - Converting HEX(EBCDIC) to Strings(readable)

Postby dick scherrer » Thu Dec 03, 2009 9:59 am

Hello,

i get message what "command X2C not found
Yes, because it is a tso/rexx command. . .

Put the code** Mr Spock posted in a REXX exec and run it. Post back here if it does not work.

Once you have the sample working, use your data rather than the literal. . .

d

**
record = 'E3C8C9E240E8C5C1D9E240E3D9C1D5E2D3C1E3C9D6D540C5E7C5D9C3C9E2C540E6C9D3D3'
Say X2C(record)
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post