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.
As an Amazon Associate we earn from qualifying purchases.