× 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.



Joe Pluta wrote:
>
> Quick question - if I have a file in a module that specifies NOMAIN, the
> compiler warns me that I should manually close the file.  However, my
> procedure has ACTGRP(*CALLER) and is called by a program that specifies
> ACTGRP(*NEW).
>
> Am I correct in thinking that when the calling program ends, the file will
> be closed?  I don't know where I got this idea, but it seems to me that
> ending an activation group closes any files opened in that activation group.
>
> Is this true?  Are there exceptions?

Joe, I was going to say that it is true, but then I wondered about
opening with OPNSCOPE(*JOB) and ran a little test.  I was right - if you
open with opnscope(*job),
the file stays open even when the AG ends.

Test:

/* CLOSEFILE */
pgm
          OVRPRTF    FILE(QSYSPRT) OVRSCOPE(*JOB) OPNSCOPE(*JOB)
          callprc CLOSEFILE2
          call qcmd
endpgm

/* CLOSEFILE2 */
Fqsysprt   o    f   80        printer
C                   return

===> CRTCLMOD QTEMP/CLOSEFILE
===> CRTRPGMOD QTEMP/CLOSEFILE2
===> CRTSRVPGM QTEMP/CLOSEFILE2 ACTGRP(*CALLER) EXPORT(*ALL)
      (don't tell anyone I used export(*all), ok?)
===> CRTPGM QTEMP/CLOSEFILE ACTGRP(*NEW) BNDSRVPGM(CLOSEFILE2)
===> CALL QTEMP/CLOSEFILE
- when the command line comes up, do WRKJOB option 14
   - QSYSPRT *JOB shows up
- exit from the command line
- when the original command line comes up, do WRKJOB option 14 again
   - QSYSPRT *JOB is still there

Barbara Morris




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.