EXECIO
The REXX command for reading records from a dataset, or writing records to one, under TSO.
Also written EXECIO DISKR, EXECIO DISKW, DISKR, DISKW, DISKRU
EXECIO is how a REXX exec reads and writes datasets in TSO and batch. REXX itself has no statements for files, so EXECIO provides them.
It works through a DD name. First the exec allocates the dataset to a name, for example with ALLOC FI(INDD) DA('ZBANK.DATA.ACCOUNTS') SHR. Then "EXECIO * DISKR INDD (STEM REC. FINIS" reads every record into a stem variable. REC.1 holds the first record, REC.2 the second, and REC.0 holds the number of records read. FINIS closes the dataset afterwards.
Writing works the other way. DISKW writes records from a stem, or from the data stack, to a dataset allocated for output. DISKRU reads a record so that it can be changed and written back in place.
After the work, the exec should free the allocation with FREE FI(INDD). Most problems with EXECIO come from the allocation: a dataset name without quotes gets your user ID added in front, and forgetting FINIS after writing can leave the dataset open, with the last records not yet saved.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- REXXA readable scripting language used across the mainframe for automation, tooling and quick one-off tasks.
- Stem variableREXX's array, a variable with a dot in its name used to hold a list such as the lines of a file.
- REXX execA REXX program, stored as a member in a library and run by name from TSO or ISPF.
- DD statementThe JCL statement that connects a name inside a program to a real dataset outside it.
- DatasetWhat a mainframe calls a file: a named collection of records with a defined structure, rather than a loose stream of bytes.
- PARSEREXX's instruction for pulling a string apart into pieces, by position, by delimiter or by pattern.