Convert EBCDIC data into an alphanumeric character string



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Convert EBCDIC data into an alphanumeric character string

Postby opelosi » Wed Sep 10, 2008 7:42 am

Hi there,

I want to convert some data that is represented in Extended Binary Coded Decimal Interchange Code (EBCDIC) into an alphanumeric character string.

Does any know how to do that?

P.S.: Each character is an 8-bit code in an EBCDIC data represetation.

Thanks.
opelosi
 
Posts: 6
Joined: Wed Sep 10, 2008 7:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Convert EBCDIC data into an alphanumeric character string

 

Re: Convert EBCDIC data into an alphanumeric character string

Postby dick scherrer » Wed Sep 10, 2008 7:48 am

Hello,

You need to clarify what you are asking.

EBCDIC data is already alphanumeric. . .
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: Convert EBCDIC data into an alphanumeric character string

Postby opelosi » Wed Sep 10, 2008 9:37 pm

Well...I have the following data written in a dataset:

D6E240D6D9C7C1D5C9E9C1C4D6D9C5E240C4D6407FC3D6D5C3E4D9E2D6
D4C1C9D5C6D9C1D4C57F40C7D6E2E3C1D9C9C1D440C4C540C1C7D9C1C4C5C3C5D9
D7D6D940E2E4C140D7C1D9E3C9C3C9D7C1C3C1D64B40E2C5D1C1D440C2C5D4
E5C9D5C4D6E240E3D6C4D6E240D8E4C540D7C1D9E3C9C3C9D7C1D4
C4D640C3D6D5C3E4D9E2D640D7C5D3C140D7D9C9D4C5C9D9C140E5C5E9
C540C1D8E4C5D3C5E240D8E4C540D7C1D9E3C9C3C9D7C1D9C1D4
C5D440F2F0F0F74B40C5E2E3C540C1D5D640C1D3C7E4D4C1E240E3C1D9C5C6C1E2
D5D6E5C1E240C6D6D9C1D440C9D5C3D3E4C9C4C1E240D7C1D9C140D4C5D3C8D6D9
C4C5E2C1C6C9C1D940C140E3D6C4D6E24B40C4C5E2C5D1C1D4D6E2
C2D6C140E2D6D9E3C540C4E4D9C1D5E3C540E3D6C4D640D6
C3D6D5C3E4D9E2D64B40C6C1E9C5D4D6E240E5D6E3D6E240D8E4C5
E2C5D1C140D640D4C1C9E240D7D9D6E5C5C9E3D6E2D640D7D6E2E2C9E5C5D34B
7FC2D6C140E2D6D9E3C55A7F40407A605D

If I'm not wrong this data is represented in EBCDIC format.

My quest is to convert this data in a character string that could be readble with the humans eyes.

Thanks,
opelosi
 
Posts: 6
Joined: Wed Sep 10, 2008 7:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Convert EBCDIC data into an alphanumeric character string

Postby dick scherrer » Wed Sep 10, 2008 10:21 pm

Hello,

How was this file created?

Keep in mind that pretty much everything on the mainframe is ebcdic (there are a few rare exceptions).
If I'm not wrong this data is represented in EBCDIC format.
It is ebcdic, but maybe not the way you intended.

Somehow, you have data that is showing each byte as 2 bytes - ie this is the hex construction of each byte. Often someone wants to show the hex values of some data, but it is rare to have the hex in 2-byte form as input. . .

From that input, what do you want for "output"? Keep in mind that your output will only be 1/2 as long as the input.
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: Convert EBCDIC data into an alphanumeric character string

Postby opelosi » Wed Sep 10, 2008 11:41 pm

Hi Dick,

To be honest I haven't got any clue of how the file was created.

The output is a normal message.

At this link: http://publib.boulder.ibm.com/infocente ... a20534.htm I found a table that convert this format.

Per example the first byte is D6. Converting it to binary is 11010110. And the converting it to ASCII is O.
So the firts byte (D6) is equal to character O.

I know I could this byte a byte, but if there is a way to do it automatically would be much easier!!

Thanks,

Orlando
opelosi
 
Posts: 6
Joined: Wed Sep 10, 2008 7:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Convert EBCDIC data into an alphanumeric character string

Postby dick scherrer » Thu Sep 11, 2008 12:11 am

Hi Orlando,

If this was my requirement, i would surely spend a bit of time finding how the file was created. It may have been created on a windows or unix system by someone who did not understand how text data might be transferred from that platform to the mainframe without any gyrations (such as to create this file format).

If i couldn't get the file creation modified to create a proper text file, i would do this with an aray in cobol.

I'm not aware of an automagic sort/utility way to convert that data into "real" characters. The good news is that the cobol work to do this is fairly simple.
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: Convert EBCDIC data into an alphanumeric character string

Postby dick scherrer » Thu Sep 11, 2008 12:17 am

Hi Orlando,

A bit more. . .

If you made a table like this:
01  HEX-TABLE.
      05 filler pic x(32 ) value '000102030405060708090A0B0C0D0E0F'.
      .
      05 filler pic x(32 ) value 'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.
01  HEX-TABLE-R redefines HEX-TABLE.
      05  HEX-ITM occurs 256 times.
           10  HEX-OVER  PIC X.
           10  HEX-UNDER PIC X.
and defined a subscript as a comp field, and looped thru the array adding one to the comp field each iteration, the value in the comp field could be used as the actual result value.

That way there is no need to include the result in the array.
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: Convert EBCDIC data into an alphanumeric character string

Postby opelosi » Thu Sep 11, 2008 1:45 am

Thanks again!! ;)
opelosi
 
Posts: 6
Joined: Wed Sep 10, 2008 7:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Convert EBCDIC data into an alphanumeric character string

Postby hakghen » Thu Sep 11, 2008 8:50 pm

Hello, I'm having the same issue but couldn't figure out how to convert the EBCDIC data representation to ASCII yet... Looking at IBM's website I found out this info (although, or I couldn't use it yet, think I didn't understood very well).:

The TSO/E commands OPUT, OGET, and OCOPY let you convert files between ASCII and EBCDIC.

So... That's it... I'd be glad to find any help, but, anyway, thanks for the attention!

André Luiz
[]'s,

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

Re: Convert EBCDIC data into an alphanumeric character string

Postby dick scherrer » Fri Sep 12, 2008 12:09 am

Hello Andre and welcome to the forums,

FWIW, if files are being transferred between the mainframe and some ascii platform (windows/unix/linux/etc), the file transfer usually handles the ebcdic/ascii conversion automatically. On the mainframe there is very limited use for ascii data. In fact every client i've had that wanted help gettin data to ascii on the mainframe become convinced that they really did not want ascii data on the mainframe.

Orlando's data is neiher "regular ascii" nor "regular ebcdic". Somehow his file has 1-byte values stored n 2 bytes (expanded to their composite hex). I'm still curious how the file was created ;)

What is your requirement to convert data to ascii?
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

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post