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



Each of our service programs has a $Close[serviceprogram] procedure (and an $Open as well). In retrospect, maybe these are misleading names, as they really stand for EndOfServiceProgramProcessing and Initialize). For instance, a file encapsulated service program will open the file in the $Open, and close it in the $Close. Some of the more complex service programs may have more going on in those procedures, and sometimes there is nothing at all.

-Kurt
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeff Young
Sent: Tuesday, March 08, 2011 9:40 AM
To: RPG programming on the IBM i / System i
Subject: Re: RPG ILE Problems (Activation Groups)

Louis,
What I normally do is to add a parm to my service program to indicate when to close the file(s).
If the value is not set to close, I test if the file(s) are not open, and open them.
When the calling program is finished processing, I call the service program with a close flag and it then closes all of its files.
Normally, I make all parms other than the close flag optional so that I do not need to pass dummy values when calling it to close the files.
 
Jeff Young
Sr. Programmer Analyst
IBM -e(logo) server Certified Systems Exper - iSeries Technical Solutions V5R2 IBM  Certified Specialist- e(logo) server i5Series Technical Solutions Designer V5R3 IBM  Certified Specialist- e(logo)server i5Series Technical Solutions Implementer V5R3

  
 






________________________________
From: LuisMaldonado <lmaldonado@xxxxxxxx>
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Sent: Tue, March 8, 2011 9:03:09 AM
Subject: RE: RPG ILE Problems (Activation Groups)


Hi ,
If I have a RPG module in a service program and I have an RPG procedure defined with P specs, and I coded the F spec within the procedure,

the file would be automatically closed when the procedure ends.
If  I do DSPJOB OPTION(*OPNF) OUTPUT(*PRINT) in the CL program before and after you do the call to the service program, no files are open and closed in this scenario (like you said).
My question is about the performance:
if the service program is called a lot of times , to open and close the same file thousands of times,  it´s correct ? how can avoid this ?
If no procedure are used the file it´s not open and closed each time, it´s better for performance ? 

but the  RCLRSC Can not be used !!!!  (cause all are in the DAG) Could be a good idea have all the programs in the DAG (with *caller) and only the service programs in the QILE 

then if I need I can reclaimed the qile activation group??

Thank you.

Lluis
________________________________________
De: rpg400-l-bounces@xxxxxxxxxxxx [rpg400-l-bounces@xxxxxxxxxxxx] en nombre de Barbara Morris [bmorris@xxxxxxxxxx] Enviado el: viernes, 04 de marzo de 2011 21:46
Para: rpg400-l@xxxxxxxxxxxx
Asunto: Re: RPG ILE Problems (Activation Groups)

On 3/4/2011 1:13 PM, LuisMaldonado wrote:
Thank you Barbara
Now your example works and I understand.
If I open a file inside  the SRVPGM and do RCLRSC and error ocurrs
like you said.
But if SRVPGM has a PI and open the file inside the PI  no error
occurs. it´s correct ?  why ?


Luis, I'm not sure what you mean by "SRVPGM has a PI".

But anyway, the syntax of the RPG code doesn't matter.  The scenario that will cause the problem is that the RPG module is in a service program, and that the RPG module uses a file which is still open when the RPG procedure returns to its caller.

Try adding a DSPJOB OPTION(*OPNF) OUTPUT(*PRINT) in your CL program before and after you do the RCLRSC, to see if there are any files that are open and that get closed by the RCLRSC.

If you have an RPG procedure defined with P specs, and you coded the F spec within the procedure, like the procedure below, the the file would be automatically closed when the procedure ends.

      P c              b                  export
      Fqsysprt  o    f  80        printer
      D prtDs          ds            80
      D  line                        80    inz('printer line')
      D fld            s            20a  inz('init')
      /free
          dsply 'new value for srvpgm field' '' fld;
          write qsysprt prtDs;
          return;
      /end-free
      P c              e

But if you coded the STATIC keyword on the F spec, then the problem would occur, because the file would stay open when the procedure ends.


      P c              b                  export
      Fqsysprt  o    f  80        printer static
      ...

Just a reminder, when working with service programs running in the DAG, make sure you sign off and sign back on after changing the service program.  Or submit your tests to batch so you always get a fresh job.

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.