Hi,
How can I call a program that will run in a named activation group without
starting in the DFTACTGRP?
You can't the 2 Default Activation Groups are started at job start and end
with job end. RCLACTGRP will not work for the default activation groups.
OPM programs are running in the default activation group and several system
programs, too.
OPM programs can be ended and closed and removed with RCLSRC.
ILE (service-)programs can only be ended and removed if the activation group
in which the (service-)program runs will be ended with RCLACTGRP (or CEEAPI
CEETREC).
RCLRSC will not remove ILE (service-)programs from the default activation
group. If a program ends with LR or RCLRSC is executed, the opened files
will be closed, but the reserved storage will not be released. With the next
call the files will be opened again and the reserved storage initialized.
Using RCLRSC for ILE (service-)programs will cause a lot of trouble.
Just an example:
Sometime ago I had to write a program to create a lot of different printer
file outputs. The client wanted to have a program, that was called when the
printer file had to be opened, when the printer file had to be closed, when
the header started, when the detail started, when a detail row started, when
a summary row started and for each field that had to be printed. Calling a
program in this way is a lot of overhead. So I wrote a program, that did
nothing else than call procedures in a service program (one procedure for
each action). I thought, sometime in the future the client may call the
procedures directly instead of the program.
As far as good. My Program and Service Program run both in a named
activation group and everything was fine.
Than the client insisted, he don't want to have programs running in other
activation groups than the default.
("I've a bunch of external software and everything runs in the default
activation group without problems, you won't explain me that your style is
the right one.").
Fortunately I warned, this may cause problems and even wrote an explication
why, but my manager said: "The client is the king and we'll do what he
want!"
... and then the trouble began. Instead of calling my program (or the
appropriate procedure) when the printer file had to be closed, the client
simply executed RCLRSC, which closed indeed the printer file. But the next
time my program get called, my service program failed with MCH3601, because
the printer file was not opened and there was no way to determine if it was
closed or not. Neither %OPEN, nor OPEN with (E) or error indicator, nor an
explicitly close and reopen, nor an (E) or error indicator on the write
statement, could determine that the printer file was closed. The
(service-)program crashed as soon as the write was executed independent if
an error indicator or (E) enhancement was specified. It took me 2 days to
test all the different ways. Finally I removed my service program and copied
everything into my program.
... good modular programming, though!
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Pete Hall
Gesendet: Monday, 05. October 2009 23:38
An: midrange-l@xxxxxxxxxxxx
Betreff: Re: ACTGRP problem
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David FOXWELL wrote:
Hi,
How can I call a program that will run in a named activation group without
starting in the DFTACTGRP?
All the user menus are displayed by old programs running in the DFTACTGRP.
If my program running in a named activation group was called directly from
the menu, and returning to the menu I ended that group, would that be OK?
Thanks.
You can specify the activation group in which a program will run in the
compile command, but that's not required. I generally do it, via a
compiler directive (the H spec in RPG.) The value is typically a literal
name, or the special value *CALLER. The program which specifies the
activation group name, is the initial program, and can destroy the
activation group when it completes, thereby releasing all resources that
have been allocated within the group, by calling the CEETREC API
program. I generally code that as the last operation before the normal
exit. The RPG compiler doesn't know about CEETREC, so it still requires
a return or LR just to keep the compiler happy.
A RTVACTGRP command in a CL menu program would accomplish the same thing.
The advantage of CEETREC is that the menu program doesn't need to know
the name of the activation group, and it also works transparently with
system menus, and in batch jobs. If you use CEETREC, don't neglect to
specify the two parameters. Null pointers (*OMIT) can be passed when
they're not needed.
hth
Pete Hall
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkrKZyIACgkQXczQcKdXKg4B/ACdETpnr6XIh7oLud2eTmBGF50d
VSEAnj1+byY4bCj/DO8efdchqQcNi0of
=cnWR
-----END PGP SIGNATURE-----
As an Amazon Associate we earn from qualifying purchases.