Page 1 of 1

Convert HEX to EBCDIC

PostPosted: Wed Sep 22, 2010 11:43 am
by graham777
I have a file that contains a mix of EBCDIC text and HEX.
EG. 46000102D0
I am trying to use DFSORT & OUTREC to convert the chars from position 7 to 10 back to EBCDIC.
eg. 460001 }
In essence there is an existing program that unpacks the characters to decipher them.

Note that I can get from the 460001 } value to the 46000102D0 value by using the following:
OUTREC FIELDS=(1:1,6,
7:7,54,HEX,X)

What I cant do is get it back the other way.

Re: Convert HEX to EBCDIC

PostPosted: Wed Sep 22, 2010 10:28 pm
by Frank Yaeger
EBCDIC and HEX are meaningless terms the way you're using them. Maybe you mean character and binary or maybe you mean something else.

I don't know what you mean by "convert the characters from position 7 to 10 back to EBCDIC"?

C'2D0' is X'F2C4F0' ... that is a character representation and a hex representation. Both are EBCDIC.

Show your input field in hex and your expected output field in hex so I can understand the conversion you're actually trying to do.

Re: Convert HEX to EBCDIC

PostPosted: Thu Sep 23, 2010 2:05 am
by graham777
Sorry bout confusion - everything is in essence ebcdic I am really just talking about packing and unpacking as per the following.
I want to go from:
46000102D0
to:
460001 }
0D (hex)
20 (hex)
So chars 02 (position 7 & 8) go to a single char (which may or may not be printable) but is hex x'02'
& chars D0 (position 9 & 10) go to a single char x'D0'

I haven't noted the hex for the first 6 chars (haven't go access to mainframe at moment) but they will just be normal ebcdic characters.

Re: Convert HEX to EBCDIC

PostPosted: Thu Sep 23, 2010 2:50 am
by Frank Yaeger
That isn't really packing and unpacking. It's converting HEX in character representation to equivalent binary. I can't think of an easy way to do that with DFSORT. Maybe somebody else can.

Re: Convert HEX to EBCDIC

PostPosted: Thu Oct 28, 2010 2:50 am
by Frank Yaeger
With z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct, 2010), you can now use DFSORT's new TRAN=UNHEX function to do this kind of thing quite easily like this:

    INREC BUILD=(1,6,7,4,TRAN=UNHEX)


For complete details on the new functions for DFSORT and DFSORT's ICETOOL available with the Oct, 2010 PTF, see:

http://www.ibm.com/support/docview.wss? ... g3T7000242