2

I am trying to convert Mainframe file to Unix readable format using below iconv command.
iconv -f IBM-037 -t ISO8859-1 FileA > FileB

This command converts data as expected, but writes output data in one single row. Can someone help on how to handle this file format conversion?

NRC
  • 83
  • 1
  • 5

4 Answers4

3

@Steve Ives, you can do this in one step, eliminating the intermediate file, and a couple of I/Os.

In z/OS UNIX, the cp utility can read and write (unix) files as well as (MVS) data sets. With this in mind, your job can be done as follows:

//CONVERT  EXEC PGM=BPXBATCH,REGION=8M                                    
//STDERR   DD   SYSOUT=*                                                  
//STDOUT   DD   SYSOUT=*                                                  
//STEPLIB  DD   DISP=SHR,DSN=SYS1.CEE.SCEERUN                             
//*                                                                       
//STDPARM  DD   *                                                         
sh /bin/cp -T -O c=iso8859-1 
   "//'P.OPS.CA7GRAPH.MCAWKLY.REPORT'"
   /u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/phpNoSecure/MCAWKLY.txt         
/* 

Note that cp silently assumes the source code page is IBM-1047. This cannot be changed. But in your case this is fine.

phunsoft
  • 2,674
  • 1
  • 11
  • 22
  • Thanks - I'd been struggling with a simple, reliable conversion and got my solution from IBM after raising a PMR. – Steve Ives Jan 28 '21 at 11:42
  • A few of the z/OS UNIX utilities officially support reading or writing from or to MVS data sets, resp. Those that do havie it documented in the manual or man pages. They are safe to use for productive matters.Some other utilities *seem* to support as well, but the doc doesn't mention it. ```cat``` being one example. – phunsoft Jan 28 '21 at 19:26
2

I guess you transfer the data in binary from z/OS to UNIX, then use iconv on the UNIX side. There are no line end characters on z/OS data set records, so there is nothing in the data that iconv can convert to line end character(s).

You need to transfer in ASCII. FTP will take care of the translation, and will insert line end character(s).

You can set influence the code pages used in translating, if the fefault set on the FTP server on z/OS is not what you need:

quote site sbdataconn=(*host-code-page*,*network-(unix)-code-page*)

Default line end characters are 0x0d0a. You can change this with

quote site sbsendeol=NL
                     CR
                     CRLF  (default)
                     NONE
phunsoft
  • 2,674
  • 1
  • 11
  • 22
0

As previously answered, a z/OS file has no CR or LF characters in it.

I have an application where I need a z/OS file processed by a PHP program, so I copy the file from z/OS to USS using the USS OCOPY command in batch:

//COPYMCA  EXEC PGM=IKJEFT01                                            
//*                                                                     
//MVS    DD   DISP=SHR,DSN=P.OPS.CA7GRAPH.MCAWKLY.REPORT    MCA Data     
//*                                                                     
//HFS    DD PATH='/u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/phpNoSecure/ 
//             MCAWKLY_EBC.txt',                                        
//          PATHDISP=(KEEP,DELETE),                                     
//          PATHOPTS=(OWRONLY,OCREAT), Add OEXCL to fail if exists      
//          PATHMODE=(SIRUSR,SIWUSR,SIROTH)                             
//*        
//SYSTSPRT DD SYSOUT=*                                                  
//SYSTSIN  DD *                                                         
OCOPY INDD(MVS) OUTDD(HFS) TEXT CONVERT((BPXFX000))    

and then a second step which runs iconv to do the code page conversion:

//*  Convert USS file to correct character set.                            
//CONVERT  EXEC PGM=BPXBATCH,REGION=8M                                    
//STDERR   DD   SYSOUT=*                                                  
//STDOUT   DD   SYSOUT=*                                                  
//STEPLIB  DD   DISP=SHR,DSN=SYS1.CEE.SCEERUN                             
//*                                                                       
//STDPARM  DD   *                                                         
sh /bin/iconv -f IBM-1047 -t ISO8859-1                                    
 /u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/phpNoSecure/MCAWKLY_EBC.txt >   
 /u/jocs065/ihsconfig/ihs/jocs065/cgi-bin/phpNoSecure/MCAWKLY.txt         
//*      

                                                             
             
Steve Ives
  • 7,894
  • 3
  • 24
  • 55
  • "As previously answered, a z/OS file has no CR or LF characters in it." No, z/OS (UNIX) *text files* do have line end characters (0x0A), but z/OS (MVS) data sets do not. Picky? maybe, but it helps to clarify what you're talking about, especially when you have both in context, as in yoyur example. No offence intended, just a suggestion. – phunsoft Jan 27 '21 at 19:50
  • Maybe - I’m just used to people referring to z/OS or MVS files/datasets one the one side and USS files on the other side. I don’t recall anyone ever referring to a file in the USS environment as a z/OS file. – Steve Ives Jan 27 '21 at 20:01
0

I used the following technique to perform iconv on a z/OS data set:

cat "//'MY.MVS.DATA.SET'" | iconv -f IBM-273 -t UTF-8 > ./my.unix.file

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 01 '23 at 16:38