Writing in a specific output queue in C/400

50 pts.
Tags:
Application development
AS/400
CLP
Printing
Dear all, I need one more time your help... Well, I'm starting to learn C/400 programmation and I would like in my program to log all my traces in a specific output queue (not in the standard QPRINT output queue). I found a solution by changing the default output queue and using the simple printf... But I don't want to change the standard output queue... I made some test trying to open the output queue file and using fprintf... but it was not working. I hope you'll be able to help me and perhaps give me an example. Thanks in advance, Pierre

Answer Wiki

Thanks. We'll let you know when a new response is added.

Pierre,

there is no OUTQ file on OS/400, there is only a print file which is attached to an OUTQ. By default OS/400 identifies the C streams STDOUT and STDERR with file QPRINT. Unless you have changed it, this will point at output queue QPRINT as well. To use a different file or output queue you will have to issue and OVRPRTF for the file STDOUT and/or STDERR. You then have the option of using the system defined QPRINT file or some other one and placing it on a different queue.
Specify OVRPRTF (STDOUT) OUTQ(lirary/queue) where ‘queue’ is the name of the OUTQ you want to send output to and ‘library’ is the library containing it.
You might need to put this in a CL program before your C program runs or you may get away with using the ‘system’ function to execute the command as the first thing your C program does – I haven’t tried it myself so don’t know.

Hope this helps

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • PierreLG
    Ok, thanks for the information... Now I understand a little bit more how it's working. As I don't want to change the standard output queue for the other programs running on the AS/400, I don't think your solution should be used. What I'm looking for is a way in C/400 to open a printer file (of the type *OUTQ) in a specific directory and be able to read and write logs. Thanks one more time for your support. Pierre.
    50 pointsBadges:
    report
  • Ayahel1
    Hi Pierre, I don't think you understood alasdair727 recommendation. The OVRPRTF command does not change the system supplied QPRINT file. It only says: for this job, whenever you write data to printer file QPRINT, route it to a new OUTQ. While doing so, all your STDOUT (printf calls) will be printed into a spooled file that is attached to the new OUTQ. In the OVRPRTF, you can also rename the spooled file name so it will not be called QPRINT: OVRPRTF FILE(QPRINT) OUTQ(library/queue) SPLFNAME(newname) If you do not want to use QPRINT at all, you can create your own printer file (using the CRTPRTF command with similar parameters to the OVRPRTF). In your C program, you can open the file you created using the fopen("*LIBL/myfile") and perform write operation to your open file descriptor. Because this printer file is on the QSYS file system and not IFS file, you must compile your C module (CRTCMOD) with the following option: SYSIFCOPT(*NOIFSIO) Hope this helps
    0 pointsBadges:
    report
  • Ayahel1
    Hi Pierre, I don't think you understood alasdair727 recommendation. The OVRPRTF command does not change the system supplied QPRINT file. It only says: for this job, whenever you write data to printer file QPRINT, route it to a new OUTQ. While doing so, all your STDOUT (printf calls) will be printed into a spooled file that is attached to the new OUTQ. In the OVRPRTF, you can also rename the spooled file name so it will not be called QPRINT: OVRPRTF FILE(QPRINT) OUTQ(library/queue) SPLFNAME(newname) If you do not want to use QPRINT at all, you can create your own printer file (using the CRTPRTF command with similar parameters to the OVRPRTF). In your C program, you can open the file you created using the fopen("*LIBL/myfile") and perform write operation to your open file descriptor. Because this printer file is on the QSYS file system and not IFS file, you must compile your C module (CRTCMOD) with the following option: SYSIFCOPT(*NOIFSIO) Hope this helps
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following