Skip to main content

Problem:

Program defined with ASSIGN TO PRINTER is not sending output to the printer

Resolution:

Printing from an application in Unix is usually done via unix pipes (dd_).  

set up dd_ environment variables so  commands will be executed by the operating system shell. The shell used is that defined in the environment variable SHELL or, if this has not been set, /bin/sh is used.

The ASSIGN TO PRINTER clause does not send output to a printer; it sends it to a file named LPT1.  To send output to a physical printer, you must use the dd_LPT1 environment variable or, if your system supports the lp printer spooler, you should use:

dd_LPT1=">lp";export dd_LPT1

    - Or you can just write in a normal sequential file and print it at the end:

working-storage section.

01 myfile-fid pic x(20).

01 my-print-call pic x(30).

procedure division.

......

close myfile

string "lp " myfile-fid x"00" delimited by size into

my-print-call

call "SYSTEM" using my-print-call

Old KB# 2201