Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jun 04, 2004 10:07 am Post subject:
Well, the obvious way to go from C'F1F2F9' to C'129' would be:
Code:
OUTREC FIELDS=(2,1,4,1,6,1)
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Fri Jun 04, 2004 11:52 am Post subject:
Frank,
I was thinking along these lines too. But, hypertech does not categorically say, that the data will always be 'numeric characters in double-byte format'. That is, input as C'F1' and output as C'1'.
What if the input data was C'7D' and the required output were to be ' ?
Hypertech,
Can you please elaborate? _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jun 04, 2004 12:33 pm Post subject:
Cogito,
Obviously, that would be a different question requiring a different answer. I just answered the question hypertech asked. For the more general case, I'd use an E35 exit with the appropriate logic. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jun 04, 2004 6:22 pm Post subject:
Conceptually, you need to convert each pair of characters to a left and right hex nibble.
First character of pair: C'0'-C'F' -> X'00'-X'F0'
Second character of pair: C'0'-C'F' -> X00'-X'0F'
Then use OR or shift to get the byte value.
If you don't know how to do this kind of thing and nobody else volunteers, let me know and I can code up an Assembler E35 exit for you tomorrow. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sat Jun 05, 2004 10:36 am Post subject:
Hypertech,
Here's a DFSORT job with an E35 exit to do what you want. I assumed your input data set has RECFM=FB and LRECL=80, but the job can be changed for other attributes.
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 6 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
MVC OUTRCD,BLANKS INIT. OUTPUT RECORD TO BLANKS
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 CL80 BUFFER FOR OUTPUT RECORD
BLANKS DC CL80' '
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=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
MODS E35=(E35UNHEX,1000,EXIT)
//*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Oct 28, 2010 3:26 pm Post subject:
Quote:
How can I change 'C1D4F1' into X'C1D4F1'?
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:
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum