Reputation: 83
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?
Upvotes: 2
Views: 4097
Reputation: 2745
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 default 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
Upvotes: 2
Reputation: 1
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
Upvotes: 0
Reputation: 2745
@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.
Upvotes: 3
Reputation: 8134
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
//*
Upvotes: 0