ICETOOL performs work by running one or more operators. Each operator is a single task: copy data, sort data, merge files, count records, select a subset, compute statistics, and so on. This page goes deeper into the main ICETOOL operators: what each does, when to use it, and how it fits with the USING (control statement) dataset. We cover COPY, SORT, MERGE, COUNT, SELECT, DISPLAY, STATS, SUBSET, UNIQUE, DATASORT, and MODE.
COPY copies records from the input DD (FROM) to the output DD(s) (TO). Without USING, it is a straight copy. With USING(prefix), the prefixCNTL dataset can contain INCLUDE, OMIT, INREC, OUTREC, OUTFIL, etc., so you can filter and reformat while copying. COPY does not sort; order is preserved (or as defined by OPTION COPY in the control statements).
123456COPY FROM(INDD) TO(OUTDD) USING(CTL1) /* //CTL1CNTL DD * INCLUDE COND=(60,2,CH,EQ,C'IN') OUTREC FIELDS=(1,80) /*
SORT sorts the input and writes to the output. You must supply USING(prefix) with a dataset that contains SORT FIELDS=. Optionally the same dataset can have INCLUDE, OMIT, INREC, OUTREC, OUTFIL, SUM. SORT allows multiple input files (e.g. FROM(IN1,IN2)) in some implementations; control statements then typically use MERGE FIELDS= or SORT FIELDS=.
MERGE merges two or more sorted inputs into one or more outputs. You need multiple FROM DDs (e.g. FROM(IN1,IN2)) and control statements with MERGE FIELDS= and often OUTFIL to split or format the merged stream.
COUNT counts records. FROM(indd) is required. If you use USING(ctl), the ctlCNTL dataset can have INCLUDE so only records that meet the condition are counted. The count is written to TOOLMSG (or a count dataset). No data records are written to an output file.
SELECT selects records by key. Typical syntax includes ON(position,length,format) and FIRST(n) or LAST(n)—e.g. first 2 records per department. The selected records are written to the TO(...) DD. So you get a subset of the input (e.g. top N per group).
DISPLAY computes aggregates (min, max, total, average, count) for specified numeric fields and writes the result to a list dataset (LIST(listdd)). STATS displays statistics (min, max, average, total) for specified fields, often to the message output. Both operate on numeric data; exact syntax (ON, field list, format) is product-dependent.
SUBSET copies a subset of records by including or removing header and/or trailer records. You specify how many lines are header (HEADER(n)) and how many are trailer (TRAILER(n)), and whether to REMOVE or OUTPUT (keep) them. So you can strip header/trailer or keep only data records.
UNIQUE counts the number of unique values in a specified field (ON(position,length,format)) and writes that count to messages or a list file. It does not produce an output file of data records; it produces a single count.
DATASORT is for files that have a fixed number of header records at the top and trailer records at the bottom. You specify HEADER(n) and TRAILER(n). ICETOOL sorts only the records in between and writes header + sorted data + trailer to the output. So the structure of the file (header/trailer) is preserved.
MODE controls what happens when an operator returns a non-zero return code. STOP (default in many setups) stops processing; no further operators run. CONTINUE continues with the next operator. SCAN may continue but can affect how errors are reported. Use MODE when you want one failure not to stop the rest of the step.
| Operator | Purpose |
|---|---|
| COPY | Copy input to output; optional INCLUDE/OUTREC via USING |
| SORT | Sort input and write to output; needs SORT FIELDS= in USING |
| MERGE | Merge multiple sorted inputs |
| COUNT | Count records (optionally with INCLUDE); result to messages or count DD |
| SELECT | Select records by key (e.g. FIRST n per group) |
| DISPLAY | Aggregates (min/max/total/avg) to list dataset |
| STATS | Statistics for numeric fields to messages |
| SUBSET | Include/remove header and trailer lines |
| UNIQUE | Count unique values in a field |
| DATASORT | Sort only data between header and trailer |
| MODE | Error handling: STOP, CONTINUE, SCAN |
Each operator is like a different job for the same pile of papers. COPY is “copy these to that box.” SORT is “put them in order by name and then copy.” COUNT is “count how many are blue.” SELECT is “give me only the first two from each group.” DISPLAY is “tell me the smallest, biggest, and total number.” MODE is “if one job fails, do we stop or keep doing the next job?” So you pick the operator that matches what you want: copy, sort, count, select, or summarize.
1. Which ICETOOL operator would you use to copy records from one file to another with optional INCLUDE/OUTREC?
2. What does the SELECT operator do?
3. When would you use DATASORT instead of SORT?
4. What does the MODE operator control?
5. Which operator writes aggregate information (min, max, total, average) to a list dataset?