Previous Topic: Sending a Message to Other UsersNext Topic: Writing JCL to a JES2 Internal Reader


Writing to a Printer

You can request DC to transmit data from a task to a printer; this allows you to print reports during online processing.

Steps to Transmit Data to a Printer

To transmit data to a printer, perform the following steps:

  1. Initialize the variable-storage location from which DC is to write the specified information.
  2. Initiate the printing procedure by issuing a WRITE PRINTER statement that indicates the appropriate variable-storage location and report ID, and specifies the print class or destination.
  3. Issue subsequent WRITE PRINTER statements that indicate the variable-storage location of the data and the report ID.
  4. Optionally, you can indicate the end of a report by issuing a WRITE PRINTER statement that includes the ENDRPT parameter.

CA IDMS Queue

DC does not transmit data directly from program variable storage to the printer. Rather, data is passed to a queue maintained by DC, and from the queue to the printer. The data stream passed to the queue by the WRITE PRINTER request contains only data; DC adds the necessary line and device control characters when it writes the data to the printer.

Note: The WRITE PRINTER command is used extensively under the DC-BATCH operating mode. For more information, see Appendix C, “Batch Access to DC Queues and Printers”.

Example of Writing to a Printer

The program excerpt below writes a report to the printer associated with print class 33. The report consists of the employee ID and name, old department ID, and new department ID for each employee assigned to a new department.

DATA DIVISION.
WORKING-STORAGE SECTION.
01  CHNGSHOW                   PIC X(8)   VALUE 'CHNGSHOW'.
01  PRINT-CLASS                PIC 999    VALUE 33.
01  PRINT-AREA.
    05 PRI-EMP-ID              PIC X(4).
    05 PRI-EMP-LNAME           PIC X(15).
    05 PRI-EMP-FNAME           PIC X(10).
    05 PRI-OLD-DEPT-ID         PIC X(4).
    05 PRI-NEW-DEPT-ID         PIC X(4).
    05 PRINT-AREA-END          PIC X.
01  TEMP-DEPT-DBKEY            PIC S9(8) COMP.
01  MAP-WORK-REC.
    05  WORK-PRI-CTR           PIC 99.
    05  WORK-OLD-DEPT-ID       PIC 9(4).
    05  WORK-NEW-DEPT-ID       PIC 9(4).
    05  WORK-EMP-ID            PIC 9(4).
    05  WORK-FIRST             PIC X(10).
    05  WORK-LAST              PIC X(15).
    05  WORK-ADDRESS           PIC X(42).
PROCEDURE DIVISION.
 .
 .
 .
*** DISCONNECT EMPLOYEE FROM OLD DEPARTMENT ***
*** CONNECT EMPLOYEE TO NEW DEPARTMENT      ***
 .
 .
 .
*** PRINT PROCESSING FOR EMP TRANSFER REPORT ***
*** IF COUNTER = ZERO, SPECIFY CLASS 33      ***
    IF MAP-PRI-CTR = 0
 WRITE PRINTER FROM PRINT-AREA
               TO PRINT-AREA-END
               REPORT ID 100
               CLASS 33
    ELSE
*** IF COUNTER > 50, GO TO NEW PAGE ***
 IF-MAP-PRI-CTR > 50
    WRITE PRINTER NEWPAGE FROM PRINT-AREA
                  TO PRINT-AREA-END
                  REPORT ID 100
*** OTHERWISE WRITE LINE ***
    ELSE
 WRITE PRINTER FROM PRINT-AREA
               TO PRINT-AREA-END
               REPORT ID 100.
    ADD 1 TO MAP-PRI-CTR.
    MAP OUT USING DCTEST03 OUTPUT DATA IS ATTRIBUTE
  MESSAGE IS EMP-CONNECTED-MESS LENGTH 80.
    DC RETURN NEXT TASK CODE CHNGSHOW.