|
Richard wrote: >I have a CL program that applies constraints >to files used in our application. Right now >my only options of displaying errors are sending >messages and the job log. I was thinking of >creating a printer file and writing the error >messages to it, but I do not know if its even >possible to accomplish. You can't use printer files in a CL program unless you go to some lengths to create some commands that call an RPG program to do it for you. > >Otherwise I was thinking of creating an RPG >program that would use QCMDEXC to apply the >constraint and the RPG program to retrieve errors >and write them to a printer file. That's certainly one way. Consider using the QCAPCMD API instead of QCMDEXC. You'll have better error control that way. >Is there a better way to do this? Or is the >best way to end the program and display the >message, rather then running through the >whole program and retrieving a list of the errors? There is always the option of using a display file in the CL program and popping the messages up in a message subfile, although that would require an interactive session. This being the RPG list, I have no qualms about recommending RPG to produce your error report. You might consider something as complex as having the CL program do all the work except printing: PGM /* apply constraints */ MsgLoop: RCVMSG /* If no error, we're done! */ If ... (Goto QuitPgm) /* If first error, open error log */ callprc ErrorLog ('OPEN' '') /* Add error to report */ callprc ErrorLog ('PRINT' &MsgText) Goto MsgLoop QuitPgm: /* If we wrote to the log, close it */ If &errorhappened (callprc ErrorLog ('CLOSE' '')) EndPgm You'd write a fairly simple RPG program to take two parameters: "what to do" and "what to print". You could certainly expand on that (add spacing/skipping, formatting, etc.) Alan's suggestion about wrapping this in a service program is an excellent one, and might be very valuable experience dealing with the ILE aspects of RPG IV and CL. >Thanks in advance >Richard Hope this helped - I don't really understand the need for this particular logging function, so I'm not sure if I answered the real question. In my experience, adding constraints to a file is done once, and I would like to think that the programmer/DBA who's doing it would be able to read the messages in the joblog... Buck +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.