Can anyone tell me how to print a file from within a cobol program. I simply wish to write my data to a report and then print the report. I tried using the PC_PRINT_FILE but I keep getting status code 05. If anyone could share code examples that would be very helpful. I tried also using the example given in prntfile.zip. However, it keeps giving me an error about a missing .dll file and the prntfile.exe is missing.
What operating system are you working in? We use Linux and have the Cobol programs write to a temp print file and use an environment statement to send the print request. So Cobol writes to file prt01 and the environment has dd_prt01=>lp -dprt01 -s -oraw
I am using windows 10. I actually got it to work. I just needed to put the .dat file in the C:\ root folder. But, if you wanted to share some other code I would not mind at all.
If you are using PC_PRINT_FILE on Windows then you do not need to place the file in the C:\ root directory in order to print it.
What is the name of the file that you were trying to write to?
If the filename contains a space character then you will need to enclose it within quotes when creating it but in PC_PRINT_FILE you would just leave it as is but set the filename-len parameter to the actual length of the filename. The docs for PC_PRINT_FILE specify that the name is space or NULL terminated but that is not true.
select test-file assign to '"c:\my folder\printfile.txt"'. *>double quotes enclose name surrounded by single quotes
params used in PC_PRINT_FILE
03 filename-len pic x(2) comp-5 value 26.
03 filename pic x(256)
value 'c:\my folder\printfile.txt'.