How to convert IBM file to hexadecimal using DFSORT?

落花浮王杯 提交于 2019-12-13 17:43:13

问题


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.


回答1:


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 and OUTREC are similar, INREC operates before a SORT or MERGE, OUTREC afterwards.

What I recommend, unless you need to be doing it after a SORT/MERGE, is to use INREC.

So:

 INREC BUILD=(1,4,TRAN=ETOA)

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.

 INREC OVERLAY=(1,4,TRAN=ETOA)

If you replace your OUTREC with that, your output file will be encoded in ASCII.

If you want to see the ASCII as well:

 INREC OVERLAY=(1,4,TRAN=ETOA,1,4,TRAN=HEX)

If you want to see the ASCII instead:

 INREC OVERLAY=(1,4,TRAN=ETOA,1:1,4,TRAN=HEX)

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.



来源:https://stackoverflow.com/questions/26993739/how-to-convert-ibm-file-to-hexadecimal-using-dfsort

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!