MainframeMaster

Printable Formatting

Printable formatting in DFSORT refers to how report output is prepared for printing or viewing: specifically carriage control (the first byte of each record that tells the printer to eject a page, skip a line, or single space) and the options that change or remove it. When DFSORT builds reports with HEADER1, HEADER2, LINES=, SECTIONS=, and related parameters, it typically inserts ASA (American Standards Association) or machine carriage control in the first byte of each line. For output sent to a printer, that byte is needed so the printer can advance correctly. For output that will be viewed online, edited, or imported (e.g. into Excel or HTML), that byte can cause problems, so you use REMOVECC to strip it. Options like BLKCCH1, BLKCCH2, and BLKCCT1 replace specific control characters with blanks so headers and trailers do not force unwanted page ejects. This page explains carriage control, when to use REMOVECC, and how BLKCCH1/BLKCCH2/BLKCCT1 affect report layout. For report structure (headers, trailers, pagination), see Report writing and Building reports.

Report Generation
Progress0 of 0 lessons

What Is Carriage Control?

On the mainframe, carriage control is the convention that the first byte of each record in a print file is not data but an instruction to the printer: advance to the next page, skip one line, single space, or overprint. The printer reads that byte and acts on it; it does not print that byte as part of the line. So from the application's point of view, the "content" of the line starts at byte 2, but the full record (including the control byte) is what gets written to the dataset or sent to the printer. ASA (American Standards Association) carriage control uses single-byte codes; some environments use machine (MCC) control with different conventions. DFSORT report output often uses ASA by default when you build reports with LINES=, HEADER, and TRAILER.

Common ASA Control Characters

The exact meaning of each character can vary by site and printer; the following are typical:

Typical ASA carriage control characters
CharacterMeaning
1Page eject: advance to the top of the next page. Used at the start of a new page (e.g. first line of HEADER2 on each page).
0Double space: skip one blank line (advance two lines). Used to leave a blank line between sections or after a title.
Single space: advance one line. Normal line spacing for detail lines.
+No advance (overprint): do not advance; print on the same line. Used for underlining or overprinting.
-Triple space: skip two blank lines (advance three lines). Less common.

So when DFSORT writes a report with pagination (LINES=), it may put "1" in the first byte of the first line of each page (the page header) so the printer ejects to a new page. Detail lines may have " " (blank) for single spacing. If you view that file in an editor or send it to a program that does not interpret the first byte, you see that character as part of the line (e.g. a leading "1" or blank), which can look wrong or break fixed-position parsing. REMOVECC removes that first byte so the line contains only the printable content.

REMOVECC: When to Use It

REMOVECC tells DFSORT to remove the first byte (the carriage control character) from each record written by that OUTFIL. After REMOVECC, each record is one byte shorter. Use REMOVECC when:

  • The report will be viewed online (e.g. in ISPF browse or a web viewer) and you do not want a leading control character in each line.
  • The report will be edited or parsed by a program that expects only data (e.g. column 1 is the first data character).
  • The output will be imported into Excel, converted to HTML, or sent to a destination that does not expect mainframe carriage control.

Do not use REMOVECC when the output is going to a printer or print subsystem that expects ASA (or machine) control. In that case the first byte is required for correct page ejects and line spacing; removing it would cause incorrect paging or spacing.

REMOVECC and Record Length

Because REMOVECC removes one byte from each record, the output record length is one less than it would be without REMOVECC. For example, if the report would normally produce 81-byte records (1 control + 80 data), with REMOVECC each record is 80 bytes. The DD statement for the OUTFIL output should specify an LRECL that matches the actual output (80 in this example). Some products adjust this automatically for OUTFIL; check your DFSORT manual. If you copy the file or use it in a downstream step, ensure the receiving program or dataset expects the shorter record length.

BLKCCH1: Report Header on Same Page as Data

By default, the first character of the first line of HEADER1 might be set to a control character that causes a page eject. So the report title would appear on its own page, and the first data would start on the next page—leaving a blank page in between. BLKCCH1 (block carriage control header 1) tells DFSORT to replace that first character with a blank. After that, the first line of HEADER1 no longer triggers a page eject, so the report header and the first detail lines can appear on the same page. Use BLKCCH1 when you want the title and the first data together instead of on separate pages.

BLKCCH2: Page Header on Same Page

Similarly, the first character of HEADER2 (the page header) might be a page-eject character. That can cause the first page header to eject before printing, so the first page of data appears to start with a blank or wrong line. BLKCCH2 replaces the first character of the first line of HEADER2 with a blank so the first page header does not force an extra page eject. Use BLKCCH2 when you want the first page header and the first data on the same page (e.g. when HEADER1 and HEADER2 are both used and you do not want two ejects before the data).

BLKCCT1: Report Trailer on Same Page

BLKCCT1 (block carriage control trailer 1) replaces the first character of the first line of TRAILER1 with a blank. That prevents the report trailer from forcing a new page. So the last detail lines and the report trailer (e.g. grand total, record count) can appear on the same page instead of the trailer alone on a new page. Use BLKCCT1 when you want the report footer to follow the last data on the same page.

Printable formatting options
OptionEffect
REMOVECCRemove the first byte (carriage control) from each record. Use for online/view/file output.
BLKCCH1Replace first char of first line of HEADER1 with blank; avoid page eject after report title.
BLKCCH2Replace first char of first line of HEADER2 with blank; avoid extra page eject on first page.
BLKCCT1Replace first char of first line of TRAILER1 with blank; keep report trailer on same page as last data.

Example: Report with and without REMOVECC

Same OUTFIL can be used for two outputs: one for the printer (with carriage control) and one for viewing (with REMOVECC). You would use two OUTFIL statements with different FNAMES= and only one would specify REMOVECC. Conceptually:

text
1
2
OUTFIL FNAMES=PRINT,BUILD=(1,80),HEADER1=(1:'REPORT'),LINES=60 OUTFIL FNAMES=VIEW,BUILD=(1,80),HEADER1=(1:'REPORT'),LINES=60,REMOVECC

PRINT might go to a printer DD; VIEW might go to a dataset for browsing or export. PRINT keeps the first-byte control character; VIEW strips it. BUILD and headers are the same; only REMOVECC differs. In practice you might use a single OUTFIL and choose REMOVECC based on where the output is going.

Explain It Like I'm Five

Imagine every line of the report has a secret first letter that tells the printer "go to the next page" or "move down one line." The printer reads that letter and does the action but does not print it. When you look at the file on the screen, that letter is still there and can look funny or mess up your columns. REMOVECC is like erasing that first letter so the line only has the real words and numbers. When you send the report to a real printer, you leave that letter in so the printer knows what to do.

Exercises

  1. Your report has 81-byte lines (1 control + 80 data). You use REMOVECC. What LRECL should the output DD have if you want 80 data bytes per record?
  2. When would you use BLKCCH1 and BLKCCH2 together?
  3. Why might a file that was produced with carriage control look wrong when opened in a text editor?

Quiz

Test Your Knowledge

1. What is the first byte of each record used for in traditional mainframe print files?

  • Part of the data
  • ASA (or machine) carriage control—e.g. "1" = page eject, "0" = single space—so the printer knows how to advance
  • Record length
  • Only in OUTFIL

2. When should you use REMOVECC on OUTFIL?

  • Always
  • When the output will be viewed online, edited, or sent to a destination that does not expect carriage control (e.g. file for Excel, HTML, or editor)—REMOVECC strips the first byte so the line is clean
  • Only for SORT FIELDS
  • Only when using HEADER1

3. What does BLKCCH1 do?

  • Removes all control characters
  • Replaces the first character of the first line of HEADER1 with a blank so that line does not cause a page eject—the report header can appear on the same page as the first data
  • Blocks the report
  • Only for TRAILER2

4. After REMOVECC, what happens to the record length?

  • Unchanged
  • The record is one byte shorter—the first byte (the control character) is removed, so LRECL effectively becomes original LRECL minus 1
  • Doubled
  • Only for headers

5. Why might you omit REMOVECC when sending a report to a printer?

  • REMOVECC is only for files
  • The printer (or print subsystem) expects the first byte to be ASA carriage control so it can perform page ejects and line spacing; removing it would break paging and spacing
  • Printers require REMOVECC
  • Only for TRAILER1