Converting any file from one code page to another

  • Post category:Utilities
  • Reading time:1 mins read

The easiest way on z/OS to convert a file from one code page to another is to use the standard unix iconv utility.

The sample below is using a traditional batch job, but you can see it can just as easily be run from a shell environment or a shell script.

//STEP1    EXEC PGM=BPXBATCH                                   
//STDERR   DD SYSOUT=*                                         
//STDPARM  DD   *                                              
SH  iconv -f UTF-8 -t IBM-1140 inputfile.utf8 outputfile.ebcdic                
/*                                                             
//      ebcdic - Windows                                                       
SH  iconv -f IBM-1140 -t IBM-1252 inputfile.ebcdic outputfile.ibm1252            
//      Windows - ebcdic                                                        
SH  iconv -f IBM-1252 -t IBM-1140 inputfile.ibm1252 outputfile.ibm1140           
//      ebcdic - utf8                                                       
SH  iconv -f IBM-1140 -t UTF-8 inputfile.ebcdic outputfile.utf8                
//                                                              
 

Code page conversion of a file in a batch job

  • Post category:JCLUtilities
  • Reading time:2 mins read

In this post a sample of how to perform a code page conversion of z/OS Unix files in a batch job. The different iconv utility lines show invocation for different code pages.

//*                                      
//STEP1    EXEC PGM=BPXBATCH   
//STDERR   DD SYSOUT=*  
//STDPARM  DD   *              
 SH  iconv -f UTF-8 -t IBM-1140 < inutf8 > outebc 
/*                                                     
//               
 SH  iconv -f IBM-1140 -t IBM-1252 < inebc > out1252 
//  
 SH  iconv -f IBM-1252 -t IBM-1140 < in1252 > out1140 
//     
 SH  iconv -f IBM-1140 -t UTF-8 < inebc > oututf8  
 //