1 reply

Step 1: Run your iconv against this file to convert the file to the desired EBCDIC code page. In my test, I just used line mode iconv. You would also want to substitute your desired code page in this command: iconv -f ISO8859-1 -t IBM-1047 /your/source.file >/your/ebcdic.file

This will leave you with an EBCDIC file with end of record delimiters: the 0x0A will be converted to 0x15. However, the file will still have a spurious 0x0D at the end of each line, right before the 0x15. This is because we're dealing with a Windows file in an UNIX context.

Step 2: This question presumes that you want your file out of the UNIX file system and into the MVS file system. If you simply want this file to be a valid UNIX file (that is, remove those residual 0x0D characters) you could simply do this command: tr -d "\r" /your/ebcdic.file /your/justNLonly.file

But, our goal is to get this file into the MVS file system. We need to determine the longest record length possible in this source file. This is to make sure we allocate an MVS data set with adequate record length. If you don't already know the max record length, you can use the awk command like this: awk 'length > l {l=length;line=$0} END {print line}' /your/ebcdic.file | wc -m This will give you the number of bytes in your longest record. If you want to double check, you can display the longest line with this command: awk 'length > l {l=length;line=$0} END {print line}' /your/ebcdic.file

Step 3: The cp command can recognize this unusual end of record sequence (0x0D15). So, let's move the file to MVS with something like this: cp -F crnl -P "recfm=VB,lrecl=nnn" /your/ebcdic.file "//'some.data.set'" Note that nnn is the number returned on the awk against this file -- don't forget to add at least four bytes for the record descriptor word (RDW).

With thanks to Ray Parks for assisting me in developing this solution....