Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert Hexadecimal to Alphanumeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
SanthamoorthyRajamani

New User


Joined: 06 Nov 2008
Posts: 10
Location: Chennai

PostPosted: Tue Jan 20, 2009 12:10 pm    Post subject: Convert Hexadecimal to Alphanumeric
Reply with quote

I have the input file (Flat File) with hexadecimal values, I want to convert into normal alphanumeric values. Is there any option in DFSORT or SYNCSORT or any other utlities.
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Tue Jan 20, 2009 8:15 pm    Post subject:
Reply with quote

Hello,

Please post some sample input data and what you want as output when this input is processed. Your topic will not get many replies as hexadecimal values are normal alphanumeric values.

Mention which sort product is used on your system.

When posting the sample input, also menton the recfm and lrecl of both the input data and the output data.
Back to top
View user's profile Send private message
SanthamoorthyRajamani

New User


Joined: 06 Nov 2008
Posts: 10
Location: Chennai

PostPosted: Wed Jan 21, 2009 4:01 pm    Post subject: Reply to: Convert Hexadecimal to Alphanumeric
Reply with quote

The below are few examples.

Input --> Output
C1D5F0F0F6F5F7F5F640 --> AN0065756
F0F0F0F1F2F0F0F6F0F0 --> 0001200600
C1D5F0F0F6F5F7F5F640 --> AN0065756
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 994
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Jan 21, 2009 4:31 pm    Post subject:
Reply with quote

Yes, we know what hex representations translate to.

You didn't give the RECFM and LRECL of the inputs and outputs, as requested. Nor did you speciify what SORT product you have available.

Is the input LRECL =10 or 20 in your examples? Are both input and output FB?

Garry.
Back to top
View user's profile Send private message
SanthamoorthyRajamani

New User


Joined: 06 Nov 2008
Posts: 10
Location: Chennai

PostPosted: Wed Jan 21, 2009 6:23 pm    Post subject: Reply to: Convert Hexadecimal to Alphanumeric
Reply with quote

Actually my input file record length is 800 fixed block
I want to convert it into record length 400 output flat file.

plz anyone help me. icon_cry.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jan 21, 2009 6:38 pm    Post subject:
Reply with quote

Where does this file get created ?
It may be easier, and more sensible to address this problem at source rather than process a job every day to translate the file into what it should be.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 21, 2009 10:54 pm    Post subject:
Reply with quote

Santhamoorthy R,

Here's a DFSORT job with an E35 exit that does what you asked for.

For C'xy': I convert C'x' to X'x0' and C'y' to X'0y', and add X'x0' and X'0y' together to get X'xy'. (There are, of course, many other ways to do this kind of thing in Assembler.)

Code:

//ASMAM35 EXEC PGM=IEV90,PARM='OBJECT,NODECK'
//SYSPRINT DD  SYSOUT=*
//SYSLIB   DD  DSN=SYS1.MACLIB,DISP=SHR
//SYSUT1   DD  UNIT=SYSDA,SPACE=(1700,(600,100))
//SYSUT2   DD  UNIT=SYSDA,SPACE=(1700,(600,100))
//SYSUT3   DD  UNIT=SYSDA,SPACE=(1700,(600,100))
//SYSLIN   DD  DSN=&&XE35OBJ(E35UNHEX),DISP=(,PASS),
//             UNIT=SYSDA,SPACE=(80,(200,50,1))
//ASM.SYSIN DD  *
E35UNHEX START
* CONVERT A CHARACTER REPRESENTATION OF A HEX VALUE
* (E.G. C'C1F203' TO THE CORRESPONDING HEX VALUE
* (E.G. X'C1F203').
* OUTPUT:  HEX VALUE STARTING IN POSITION 1
*  ABEND 1 IF AN INPUT BYTE IS INVALID (NOT C'0'-C'F')
*
FLDPOS   EQU   1    STARTING POSITION OF FIELD TO UNHEX
FLDLEN   EQU   800  LENGTH OF FIELD TO UNHEX (NUMBER OF CHARS)
*
R1       EQU   1
R2       EQU   2
R3       EQU   3
R4       EQU   4
R5       EQU   5
R6       EQU   6
R7       EQU   7
R8       EQU   8
R9       EQU   9
R10      EQU   10
R11      EQU   11
R12      EQU   12
R13      EQU   13
R14      EQU   14
R15      EQU   15
FLDOFF   EQU   FLDPOS-1   OFFSET OF FIELD TO UNHEX
COUNT    EQU   FLDLEN/2   COUNT FOR LOOP
         STM   R14,R12,12(R13)
         BALR  R12,0
         USING *,R12
         ST    R13,SAVE35+4 SAVE BACKWARD POINTER
         LA    R14,SAVE35   SET FORWARD PT.ER IN CALLER SAVE AREA
         ST    R14,8(R13)
         LR    R13,R14      SET OUR SAVE AREA
         ICM   R2,15,0(R1)  IF EOI,
         BZ    RET8           DO NOT RETURN
         LA    R3,FLDOFF(,R2)  POINT TO FIRST LEFT BYTE IN
*                                INPUT FIELD
         LA    R4,COUNT     GET COUNT FOR LOOP
         LA    R5,OUTRCD    GET START OF OUTPUT BUFFER
UHLOOP   DS    0H
* CONVERT C'XY' TO X'XY'.
         BAL   R10,CVTTOHX  CONVERT LEFT C'X' TO X'0X' IN R8
         LR    R7,R8        COPY R8 TO R7
         SLL   R7,4         GET X'X0' IN R7
         LA    R3,1(,R3)    POINT TO RIGHT BYTE IN INPUT FIELD
         BAL   R10,CVTTOHX  CONVERT RIGHT C'Y' TO X'0Y' IN R8
         ALR   R7,R8        ADD X'X0' AND X'0Y' TO GET X'XY'
         STC   R7,0(,R5)    SAVE X'XY' IN OUTPUT BYTE
         LA    R3,1(,R3)    POINT TO NEXT LEFT BYTE IN INPUT FIELD
         LA    R5,1(,R5)    POINT TO NEXT BYTE IN OUTPUT RECORD
         BCT   R4,UHLOOP    DO NEXT LEFT-RIGHT PAIR
RET0     DS    0H
         LA    R1,OUTRCD    POINT TO OUTPUT BUFFER
         SLR   R15,R15      SET RC=0 (RECORD ALTERED)
         B     GOBACK       RETURN TO DFSORT
RET8     DS    0H
         LA    R15,8        SET RC=8 (DO NOT RETURN)
         B     GOBACK       RETURN TO DFSORT
GOBACK   L     R13,4(,R13)
         L     R14,12(,R13)
         LM    R2,R12,28(R13)
         BR    R14          RETURN
CVTTOHX  DS    0H
* CONVERT C'H' TO X'0H' IN R8
* R3 = POINTER TO LEFT BYTE IN INPUT FIELD
         SLR   R8,R8          GET INPUT
         IC    R8,0(,R3)        BYTE IN R8
         CLI   0(R3),C'0'     IF LOWER THAN C'0',
         BL    CVTCKAF          CHECK FOR C'A'-C'F'
         CLI   0(R3),C'9'     IF HIGHER THAN C'9',
         BH    INVBYTE          BYTE IS INVALID
* C'0'-C'9' (X'F0'-X'F9') -> CONVERT TO X'00'-X'09'
         SH    R8,=H'240'     SUBTRACT X'F0' TO GET X'0H'
         BR    R10            RETURN
CVTCKAF  DS    0H
         CLI   0(R3),C'A'     IF LOWER THAN C'A',
         BL    INVBYTE          BYTE IS INVALID
         CLI   0(R3),C'F'     IF HIGHER THAN C'F',
         BH    INVBYTE          BYTE IS INVALID
* C'A'-C'F' (X'C1'-X'C6') > CONVERT TO X'0A'-X'0F'
         SH    R8,=H'183'     SUBTRACT X'B7' TO GET X'0H'
         BR    R10            RETURN
INVBYTE  DS    0H
         ABEND 1              ABEND 1 = LEFT BYTE NOT VALID
SAVE35   DS    18F
OUTRCD   DS    CL400      BUFFER FOR OUTPUT RECORD
         LTORG
         END
//*
//*   LINK-EDIT E35 EXIT
//*
//LINK35  EXEC PGM=IEWL,PARM='XREF,LET,LIST,NCAL'
//SYSPRINT DD  SYSOUT=*
//OBJ      DD  DSN=&&XE35OBJ,DISP=(OLD,PASS)
//SYSLMOD  DD  DSN=&&LINK,DISP=(,PASS),SPACE=(TRK,(5,5,5)),
// UNIT=SYSDA
//SYSLIN   DD  *
 INCLUDE OBJ(E35UNHEX)
 ENTRY E35UNHEX
 NAME E35UNHEX(R)
//*
//S1   EXEC PGM=ICEMAN
//EXIT     DD  DSN=&&LINK,DISP=(OLD,PASS)
//SYSOUT   DD  SYSOUT=*
//SYSUDUMP DD  SYSOUT=*
//SORTIN   DD  DSN=... input file (FB/800)
//SORTOUT DD DSN=... output file (FB/400)
//SYSIN    DD  *
 OPTION COPY
 RECORD LENGTH=(,,400)   
 MODS E35=(E35UNHEX,1000,EXIT)
//*
Back to top
View user's profile Send private message
SanthamoorthyRajamani

New User


Joined: 06 Nov 2008
Posts: 10
Location: Chennai

PostPosted: Thu Jan 22, 2009 3:08 pm    Post subject:
Reply with quote

Expat,
The file is created from unix server (different application) and they will post into mainframe dataset.

Frank,
I tried the above code unfortunately our system don't have the translater program load module (IEV90) in our library. I got the below abend..

"SYSTEM ABEND: 806
The system load of module IEV90 failed. The load module was not found in the standard MVS search path."

Could you plz tell me, Is there any other possibilities
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jan 22, 2009 5:43 pm    Post subject:
Reply with quote

Try changing IEV90 to ASMA90.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Thu Jan 22, 2009 5:48 pm    Post subject: Reply to: Convert Hexadecimal to Alphanumeric
Reply with quote

the wisest thing is to ask systems support to provide a proper compile and link procedure
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Jan 22, 2009 9:44 pm    Post subject:
Reply with quote

Hello,

Is there some good/business reason that the unix system cannot be changed to create proper text files that could be uploaded and used directly. This would make the process much more straight-forward and would cut the size of the transmission in half. . .

I suspect that this "hex" data was created in this manner because of a lack of understanding about how data from unix could be uploaded/used on the mainframe.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Nov 02, 2010 11:53 pm    Post subject:
Reply with quote

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 quite easily like this:

Code:

//NEW EXEC PGM=SORT                                             
//SYSOUT DD SYSOUT=*   
//SORTIN   DD  DSN=... input file (FB/800)
//SORTOUT DD DSN=... output file (FB/400)
//SYSIN DD *                                                     
  OPTION COPY                                                   
  INREC BUILD=(1,800,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?rs=114&uid=isg3T7000242
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us