File open output and assign to printer works fine but need to add contents from a binary file running on Redhat

Here is my select statement for a file used as printer handling

 


SELECT PRINT-FILE
ASSIGN TO PRINTER "prt109"
FILE STATUS IS ERR-STATUS.


FD PRINT-FILE
RECORD CONTAINS 132 CHARACTERS
LABEL RECORDS ARE OMITTED.

01 PRT-BUFFER.
    10 PL PIC X(132).

I have an environment statement of 

dd_prt109=>lp -dprt109 -s -oraw

 

Writing out records to this file and then doing a close works just perfectly, however I need to add in contents from an existing file which happens to contain some binary data and is much larger than my print file definition.  As such I cannot just read one line at at time from the binary file and inset to the print file.

 

Any suggestions?

 

Parents
  • Verified Answer

    As Michael.Wojcik says, it would be possible to modify the COBOL program to use byte-stream I-O. Here's a link to byte-stream I-O in the Visual COBOL documentation:

    documentation.microfocus.com/.../HRCLRHCALL04.html

    Here is sample COBOL source code using byte-stream I-O:

    documentation.microfocus.com/.../HRCLRHCALL7C.html

    But I speculate this would be more work than your alternative of using a script outside of COBOL to 'cat' the two types of output into the 'lp' command, and of invoking this script from COBOL using CALL "SYSTEM".

    For others reading this discussion: the COBOL program could write the output file to disk (instead of writing directly to the "lp" command with dd_prt109=>lp -dprt109 -s -oraw). Then the COBOL program could invoke a shell script that would cat the binary data and the disk file together into the "lp" command. The COBOL program could invoke the script using CALL "SYSTEM" immediately after it finishes writing the file.

    Here's a knowledgebase article about invoking shell scripts using CALL "SYSTEM". The article concentrates on retrieving the return code from the scripts, but the sample code shows the basic use of CALL "SYSTEM":


    community.microfocus.com/.../invoke-a-unix-command-from-within-cobol-using-call-system-and-retrieve-return-code

Reply
  • Verified Answer

    As Michael.Wojcik says, it would be possible to modify the COBOL program to use byte-stream I-O. Here's a link to byte-stream I-O in the Visual COBOL documentation:

    documentation.microfocus.com/.../HRCLRHCALL04.html

    Here is sample COBOL source code using byte-stream I-O:

    documentation.microfocus.com/.../HRCLRHCALL7C.html

    But I speculate this would be more work than your alternative of using a script outside of COBOL to 'cat' the two types of output into the 'lp' command, and of invoking this script from COBOL using CALL "SYSTEM".

    For others reading this discussion: the COBOL program could write the output file to disk (instead of writing directly to the "lp" command with dd_prt109=>lp -dprt109 -s -oraw). Then the COBOL program could invoke a shell script that would cat the binary data and the disk file together into the "lp" command. The COBOL program could invoke the script using CALL "SYSTEM" immediately after it finishes writing the file.

    Here's a knowledgebase article about invoking shell scripts using CALL "SYSTEM". The article concentrates on retrieving the return code from the scripts, but the sample code shows the basic use of CALL "SYSTEM":


    community.microfocus.com/.../invoke-a-unix-command-from-within-cobol-using-call-system-and-retrieve-return-code

Children
No Data