I'm trying to pass a IBM file to hex values.
With this input:
H800
Would save this output in a file:
48383030
I tried by this way:
//R45ORF80V JOB (EFAS,2SGJ000),'LLAMI',NOTIFY=R45ORF80,
// MSGLEVEL=(1,1),MSGCLASS=X,CLASS=A,
// REGION=0M,TIME=5
//*---------------------------------------------------
//SORTEST EXEC PGM=ICEMAN
//SORTIN DD DSN=LF58.DFE.V1408001,DISP=SHR
//SORTOUT DD DSN=LF58.DFE.V1408001.OUT,
// DISP=(NEW,CATLG,DELETE),
// LRECL=4,DATACLAS=CDMULTI
//SYSOUT DD SYSOUT=X
//SYSPRINT DD SYSOUT=X
//SYSUDUMP DD SYSOUT=X
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,4,HEX)
END
/*
But it outputs the following:
C8F1F0F0
What am I doing wrong? Is posible to convert to hexadecimal a file with 500 of LREC with COMP-3 fields too? Just by the way I could use "HEX" command while I browse a file using file manager.
Your control cards are giving you the output you have asked for. They are showing you the hexadecimal values of those characters in EBCDIC, not in ASCII, the hexadecimal values you are expecting.
If you actually want to see the ASCII equivalent, use TRAN=ETOA, then TRAN=HEX.
You are using
OUTREC FIELDS
.FIELDS
has a new synonym (from exactly 10 years) which is BUILD. FIELDS is supported for backwards compatibility.INREC
andOUTREC
are similar,INREC
operates before aSORT
orMERGE
,OUTREC
afterwards.What I recommend, unless you need to be doing it after a SORT/MERGE, is to use
INREC
.So:
But, there is no need to use BUILD. BUILD always creates a new version of the record. Many times this is what you want when you are rearranging fields. Here, you are not.
If you replace your OUTREC with that, your output file will be encoded in ASCII.
If you want to see the ASCII as well:
If you want to see the ASCII instead:
Note the
1:
in the last example. This says "the results are going to be at position 1", so overwriting your previous converted data.OVERLAY
can do that,BUILD
cannot in one statement.