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



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 ?

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 17:04
Para: rpg400-l@xxxxxxxxxxxx
Asunto: Re: RPG ILE Problems (Activation Groups)

On 3/4/2011 10:06 AM, LuisMaldonado wrote:
Hi,
I create a module CRTRPGMOD X
Then I create the service program:
CRTSRVPGM X EXPORT (*ALL) ACTGRP (*CALLER)
Then I execute this CLLE:
CALL PGMB (this RPGLE uses the service program x)
RCLRSC
CALL PGMB (this RPGLE uses the service program x)
If I understood well the second call to PGMB must crash !!!!!
No problem occurs, Why?
Thank you.


Luis, the call to your service program will not necessarily fail. It
will fail if it uses a file and the file is left open when the service
program procedure returns.

Simple test:

CL program PGMA:
CALL PGMB
CALL PGMB
RCLRSC
CALL PGMB

RPG module B, create as module B:
D fld s 10a inz('init')
D c pr
/free
dsply 'new value for program field' '' fld;
c();
return;

RPG module C, create as module C:
D fld s 10a inz('init')
/free
dsply 'new value for srvpgm field' '' fld;
return;

crtsrvpgm C module(C)
crtpgm PGMB module(b) bndsrvpgm(C)

call pgma

Here is the DSPLY output from my programs:
DSPLY new value for program field init
my answer: pgm 1
DSPLY new value for srvpgm field init
my answer: srv 1

DSPLY new value for program field pgm 1
my answer: pgm 2
DSPLY new value for srvpgm field srv 1
my answer: srv 2

RCLRSC happens here

DSPLY new value for program field init
my answer: pgm 1a
DSPLY new value for srvpgm field srv 2
my answer: srv 3

For the second call, both the program and srvpgm remembered the values
of their variables "fld".

The RCLRSC caused the program's static storage to be reinitialized on
the third call, so the program's variable "fld" had its inz value
'init'. The RCLRSC had no effect on the service program's static
storage, so the srvpgm's variable "fld" still had it's new value "srv 2"
that I gave on the DSPLY.

If you change the source for C to look like this, you will see the error:

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;

Remember to sign off and back on after you change the code for srvpgm C.
The system will remember the old version of the service program even
if you delete it.



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