× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Mike wrote:
I might be calling this in a loop; for sure every displayed record. I
have the activation group as *CALLER. So all I have to do is check to
see if the file is open, and if it is to just continue processing?

That'll work.

Though, I'd probably create a procedure that opens all of the files you need, and then I'd simply call that procedure. The procedure can use %open() or a global indicator to verify that it doesn't do the work twice. The only reason I do that is to keep all the file open logic from cluttering up the main subprocedure. (Plus, the code tends to be repeated in every routine in the srvpgm).

I also like to code a "closefiles" subprocedure that does the opposite (closes all files) and turns off the global indicator (if you use one). This prevents a warning message from the compiler (it complains that the files are USROPN but you never close them unless it finds a close statement.)

You can even register your "closefiles" routine to be called automatically when the activation group ends. That's useful if you have any custom code you want to run when it shuts down (such as deleting a temp file, data queue, user space, override, etc.)

If you're looking for the "simplest" alternative, then you can simply omit the "USROPN" from your F-spec. In that situation, RPG will automatically open the file(s) the first time anything in the module is called. They'll still be closed automatically when the activation group ends, of course. With that logic, you don't need to code any open or close... Personally I like it to be explicit, but many people think I'm crazy.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.