Working across the two worlds
The useful skills are the joins: running a shell script from JCL, copying data between datasets and files, and dealing with the fact that one side is EBCDIC and the other is often ASCII.
Copying between the two sides
# dataset to Unix file cp "//'PROD.PAY.REPORT'" /u/vsaha1/report.txt # Unix file to dataset cp /u/vsaha1/data.txt "//'DEV.PAY.INPUT'" # a PDS member cp "//'DEV.PAY.SOURCE(PAYSUM)'" ./paysum.cbl # convert EBCDIC to ASCII on the way out iconv -f IBM-1047 -t ISO8859-1 report.txt > report.ascii.txt
# what is this file tagged as? ls -T report.txt t IBM-1047 T=on report.txt # tag a file that arrived untagged chtag -t -c ISO8859-1 incoming.csv # remove a wrong tag chtag -r broken.txt
Running Unix work from JCL
//RUNSH EXEC PGM=BPXBATCH, // PARM='SH /u/vsaha1/scripts/extract.sh 20260930' //STDOUT DD PATH='/u/vsaha1/logs/extract.out', // PATHOPTS=(OWRONLY,OCREAT,OTRUNC), // PATHMODE=(SIRUSR,SIWUSR,SIRGRP) //STDERR DD PATH='/u/vsaha1/logs/extract.err', // PATHOPTS=(OWRONLY,OCREAT,OTRUNC), // PATHMODE=(SIRUSR,SIWUSR,SIRGRP)
A DD pointing straight at a Unix file
Any DD statement can name a Unix path instead of a dataset with PATH=. That means a COBOL program can read a Unix file with no code change — the SELECT still names a ddname, and the JCL decides what is behind it.
The commands worth knowing here
| Command | Does |
|---|---|
| obrowse / oedit | Browse or edit a Unix file from TSO |
| df -k | File system space — the first check when writes fail |
| chtag / ls -T | Character-set tagging |
| iconv | Convert between code pages |
| tso -t 'command' | Run a TSO command from the shell |
| bpxmtext | Explain a z/OS Unix errno value |
Common mistakes
An untagged file may be converted or not converted depending on which tool touches it, giving results that differ between runs.
Binary transfer of text between ASCII and EBCDIC systems produces unreadable data. Choose the transfer mode deliberately.
You lose the error message entirely and are left with a bare return code.
A full file system makes writes fail in ways that look like application bugs. df -k first.
What you will see at work
- Integration between the mainframe and everything else usually passes through USS, so encoding problems land on whoever understands both sides — a useful position to be in.
- Scripts in USS often run under a functional userid with tightly scoped permissions. Test as that user, not as yourself.
- Return codes from shell scripts become step return codes, which is how a scheduler knows whether the work succeeded.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.