IDCAMS PRINT

The IDCAMS PRINT command displays or prints the contents of a dataset—VSAM (KSDS, ESDS, RRDS) or non-VSAM sequential—so you can inspect the actual records. Unlike LISTCAT, which shows catalog metadata (name, allocation, keys, etc.), PRINT shows the data itself. You choose the format (character, hex, or dump), and optionally where to start and stop (by record count, key, or address). PRINT is used for data verification, debugging, and quick inspection without writing a program. This page covers the PRINT syntax, INFILE vs INDATASET, CHAR/HEX/DUMP, SKIP/COUNT, FROMKEY/TOKEY, FROMADDRESS/TOADDRESS, FROMNUMBER/TONUMBER, and OUTFILE so you can use PRINT effectively in batch jobs.

What PRINT Does

When you run PRINT, IDCAMS reads the dataset you specify and writes the record contents to an output stream. By default that stream is SYSPRINT, so the records appear in the job output (e.g. the JES spool). You can redirect the output to a dataset using OUTFILE or OUTDATASET. PRINT does not change the dataset; it only reads and displays. Up to 120 characters are typically printed per line; longer records are shown in 120-character segments so you can see the full record. PRINT is the standard way to "look inside" a VSAM or sequential file from a batch job when you do not have a browse tool or program.

When to Use PRINT

Use PRINT when you need to: (1) Verify that a load or REPRO worked—spot-check records after loading. (2) Debug record content—see exact bytes in HEX or DUMP when data looks wrong. (3) Inspect a small range—e.g. first 10 records, or records from key 'A' to key 'B', or from a given RBA. (4) Check that a file is empty or has data—a simple PRINT with no range prints everything (or use SKIP(0) COUNT(1) to see one record). Do not use PRINT to list catalog information (use LISTCAT) or to copy data (use REPRO). For very large files, avoid printing the whole file; use SKIP/COUNT or key/address range to limit output.

General Syntax

You must specify the input with either INFILE(ddname) or INDATASET(dataset-name). All other parameters are optional. Typical form:

jcl
1
2
3
4
5
6
7
PRINT - { INFILE(ddname) | INDATASET(dataset-name) } - [ CHARACTER | CHAR | DUMP | HEX ] - [ OUTFILE(ddname) | OUTDATASET(dataset-name) ] - [ FROMKEY(key) | FROMADDRESS(address) | FROMNUMBER(number) | SKIP(number) ] - [ TOKEY(key) | TOADDRESS(address) | TONUMBER(number) | COUNT(number) ]

INFILE and INDATASET are mutually exclusive: use one. CHARACTER (or CHAR), DUMP, and HEX are mutually exclusive; if you omit them, the default is often DUMP. The FROM and TO parameters define the range; the exact pair you use depends on the dataset type (key for KSDS, address for KSDS/ESDS, number for RRDS, SKIP/COUNT for any).

Input: INFILE vs INDATASET

You tell PRINT which dataset to read in one of two ways. INFILE(ddname) means "use the dataset allocated to this DD name." In your JCL you must have a DD statement with that name (e.g. //MYIN DD DSN=MY.FILE.KSDS,DISP=SHR). INDATASET(dataset-name) means "use this physical dataset name." IDCAMS (and the catalog) resolve the name; you do not need a separate DD for the input dataset when using INDATASET. Use INFILE when the step already has a DD for the file (e.g. the same DD used by another command or by a program). Use INDATASET when you want to name the dataset directly in the command and avoid an extra DD. Both work for VSAM and for sequential datasets; for VSAM, the catalog must know the dataset when you use INDATASET.

jcl
1
2
3
4
5
6
PRINT INFILE(MYDD) CHAR /* with //MYDD DD DSN=MY.APPL.FILE.KSDS,DISP=SHR */ PRINT INDATASET(MY.APPL.FILE.KSDS) CHAR /* no DD needed for the input dataset */

Output Format: CHAR, HEX, DUMP

The format controls how each record is displayed. Choose one of CHARACTER (or CHAR), HEX, or DUMP. If you omit the format, the default is often DUMP. Each option is useful in different situations.

PRINT format options
FormatDescription
CHAR (CHARACTER)Prints each record in EBCDIC character format. Readable when the data is text. Control characters and binary data may show as dots or unprintable symbols. Best for inspecting normal character data.
HEXPrints each byte as two hexadecimal digits (0–9, A–F). You see the exact byte values. Useful for binary fields, packed decimals, or when you need to verify hex values. Not human-readable for text.
DUMPPrints both hexadecimal and character: typically a line of hex with the corresponding EBCDIC characters alongside. Default on many systems. Best for debugging when you need both the raw bytes and a character interpretation.

CHAR is best when the data is readable text (EBCDIC). HEX is best when you care about exact byte values (e.g. packed decimals, binary, or checking for X'00' or control characters). DUMP gives you both in one view: you see the hex and the character translation, which helps when some columns are text and others are binary.

Where to Start: SKIP, FROMKEY, FROMADDRESS, FROMNUMBER

You can start printing from the beginning of the dataset (default) or from a specific position. The starting parameter you use depends on the dataset type and what you know (record count, key, RBA, or RRN). Only one starting parameter is used per PRINT; they are mutually exclusive.

PRINT starting-position parameters
ParameterDataset typesDescription
SKIP(number)KSDS, ESDS, RRDS, non-VSAMSkips the first "number" records, then prints from there. Use when you want to start after a fixed number of records (e.g. SKIP(100) to start at record 101).
FROMKEY(key)KSDS, alternate indexStarts printing at the first record with this key (or the next higher key if exact match does not exist). Use for key-sequenced datasets when you know the key value.
FROMADDRESS(address)KSDS, ESDSStarts at the given relative byte address (RBA). Use when you have an RBA from LISTCAT or from a previous run and want to inspect from that point.
FROMNUMBER(number)RRDSStarts at the given relative record number (RRN). Use for relative record datasets when you want to begin at a specific slot.

SKIP is the simplest when you think in "record numbers": SKIP(0) starts at the first record (redundant), SKIP(10) starts at the 11th record. FROMKEY is natural for a KSDS when you know the key value. FROMADDRESS is useful when you have an RBA (e.g. from LISTCAT high-used RBA or from a program). FROMNUMBER is for RRDS when you want to start at a specific relative record number.

Where to Stop: COUNT, TOKEY, TOADDRESS, TONUMBER

You can let PRINT run to the end of the dataset or stop after a certain number of records or at a key, RBA, or RRN. Only one ending parameter is used per PRINT; they are mutually exclusive.

PRINT ending-position parameters
ParameterDataset typesDescription
COUNT(number)AllPrints only "number" records (after any SKIP or FROM). Use with SKIP to print a window (e.g. SKIP(5) COUNT(10) prints records 6 through 15).
TOKEY(key)KSDSStops at the last record with this key (or at that key). Defines the end of a key range with FROMKEY.
TOADDRESS(address)KSDS, ESDSStops at the given RBA. Use with FROMADDRESS to print a range of bytes.
TONUMBER(number)RRDSStops at the given RRN. Use with FROMNUMBER to print a range of relative record numbers.

COUNT is the most common way to limit output: COUNT(50) prints 50 records (after any SKIP or FROM). Together, SKIP(100) COUNT(20) prints records 101 through 120. TOKEY and FROMKEY define a key range for KSDS. TOADDRESS and FROMADDRESS define an RBA range for KSDS or ESDS. TONUMBER and FROMNUMBER define an RRN range for RRDS.

OUTFILE and OUTDATASET

By default, the printed records go to SYSPRINT (the IDCAMS message DD). To send the listing to a dataset instead, use OUTFILE(ddname) or OUTDATASET(dataset-name). OUTFILE requires a DD in the step that points to a sequential dataset or SYSOUT. OUTDATASET specifies the physical dataset name; IDCAMS will use or create it according to the command and your allocation. Sending PRINT output to a dataset is useful when the listing is long or when you want to keep it for later review or parsing.

Example: Print First 10 Records in Character Format

jcl
1
2
3
4
5
6
7
8
//PRINT1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * PRINT INDATASET(MY.APPL.CUSTOMER.KSDS) - CHAR - COUNT(10) /*

This prints the first 10 records of the cluster MY.APPL.CUSTOMER.KSDS in character format. The output goes to SYSPRINT. No DD is needed for the input because INDATASET is used.

Example: Print Records 11–20 Using SKIP and COUNT

jcl
1
2
3
4
5
6
7
//PRINT2 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //INDD DD DSN=MY.APPL.CUSTOMER.KSDS,DISP=SHR //SYSIN DD * PRINT INFILE(INDD) CHAR SKIP(10) COUNT(10) /*

SKIP(10) skips the first 10 records; COUNT(10) prints the next 10. So records 11 through 20 are printed. INFILE(INDD) uses the DD name INDD; the JCL allocates the VSAM cluster to that DD.

Example: Print a Key Range (KSDS)

jcl
1
2
3
4
5
6
7
8
//PRINT3 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * PRINT INDATASET(MY.APPL.ORDER.KSDS) - CHAR - FROMKEY(100) TOKEY(199) /*

For a KSDS with numeric keys, this prints all records whose key is in the range 100 to 199 (inclusive, depending on key type and comparison). FROMKEY and TOKEY are only valid for key-sequenced datasets (and alternate indexes). The key values (100, 199) must match the key length and type defined for the cluster.

Example: Print in DUMP Format for Debugging

jcl
1
2
3
4
5
6
7
//PRINT4 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * PRINT INFILE(DEBUG) DUMP COUNT(3) /* //DEBUG DD DSN=MY.TEST.FILE,DISP=SHR

DUMP format shows both hex and character. COUNT(3) limits the output to 3 records so the listing stays manageable. Use DUMP when you need to see exact byte values and character interpretation together.

Example: Check Whether a File Has Records (Empty vs Non-Empty)

A common use of PRINT is to see if a dataset has any records. If you PRINT with COUNT(1) and the job completes with condition code 0 (or 4), at least one record was read and printed. If the dataset is empty, IDCAMS may return a higher condition code (e.g. 12) indicating that no records were found. So a simple PRINT INDATASET(name) CHAR COUNT(1) can serve as an "is there data?" check.

Key Takeaways

  • PRINT displays the contents of VSAM and non-VSAM datasets. Use it to inspect records, verify loads, and debug data.
  • Specify input with INFILE(ddname) or INDATASET(dataset-name). Use CHAR for readable text, HEX for raw bytes, DUMP for both.
  • Limit output with SKIP/COUNT (record count), FROMKEY/TOKEY (KSDS key range), FROMADDRESS/TOADDRESS (RBA range), or FROMNUMBER/TONUMBER (RRDS).
  • Output goes to SYSPRINT unless you specify OUTFILE or OUTDATASET.

Explain Like I'm Five

PRINT is like opening a book and reading the pages out loud so someone can write them down. The book is your dataset. You can start from the first page or skip some pages (SKIP), and you can read just a few pages (COUNT) or until a certain page (TOKEY, TOADDRESS, etc.). CHAR means you read the words as words. HEX means you read the secret code for each letter. DUMP means you read both the words and the code so people can see exactly what is on the page. LISTCAT, by contrast, only reads the cover and the table of contents—it does not open the book.

Test Your Knowledge

Test Your Knowledge

1. Where does PRINT output go if you do not specify OUTFILE?

  • To the input dataset
  • To SYSPRINT (e.g. job log)
  • To SYSIN
  • Nowhere; PRINT fails

2. Which parameter do you use to print only the first 20 records?

  • SKIP(20)
  • COUNT(20)
  • FROMKEY(20)
  • TOADDRESS(20)

3. What format shows both hex and character in one view?

  • CHAR
  • HEX
  • DUMP
  • BOTH
Published
Updated
Read time8 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: IBM z/OS DFSMS documentationSources: IBM DFSMS Access Method Services Commands, mainframestechhelp.com, Tech AgilistApplies to: z/OS 2.5