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



You'll may be pleased to know that, just as the cleanup program
specified by an *EXT scope msg gets called from within the job, just
before the job is terminated, a *PGM scope msg will call the cleanup
program just before the program is terminated.

It does not seem unreasonable that a cleanup program could by design
know what it must clean up.
However, since the originating program is still in the stack when the
cleanup program is called then that also means that it is technically
possible for it to make a callback into a procedure coded in the
originating program that has been specifically designed to cleanup just
what is required. You can't do much better than that.

This solution would mean that the original question posed by this thread
could be resolved in a way such that a program being terminated for any
reason, even ENDSBS, would get control passed into it's own end of
program handler, even if it is sleeping or has been put on hold. There's
very little involved in architecting this.

You may come to believe, like me, that scope msgs are indeed blessed.

Cheers, Peter


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rory Hewitt
Sent: Thursday, 21 May 2009 5:08 p.m.
To: RPG programming on the IBM i / System i
Subject: Re: Detecting that a submitted batch job is ending from w/in an
RPGprogram.

Peter,


Correct me if I'm wrong (I've not really used scope messages, although
I've seen some code where they're used), but a scope message scenario
has program A, which sends a scope message when it initializes. This
scope message specifies program B as the program to call when A ends.
Then, when program A does end (for whatever reason - normal, abnormal,
ENDSBS, ENDJOB, ENDSYS, whatever), program B is called by the system.

Well if the OP has a NEP which has opened a bunch of files etc. which
should be closed when the program ends (and maybe other stuff that
should be cleaned up), how does it sending a scope message help?

Assuming Program A is the NEP. It starts up, opens its files, does its
mess (which will require cleanup) and sends a scope message to tell the
system to invoke program B. At some point in the future, program A is
ended, and the system calls program B. Well program B is a separate
program - how can it do program A's cleanup? Surely, at the point that
the system has called program B, program A (the NEP) has *already*
ended, leaving a mess behind. Maybe program B could clean up some of
that mess, but it doesn't in any way help program A end 'gracefully',
does it?

Or have I missed the point?

In the OP's case, he wanted program A (the NEP) to know when *it* was
being ended (because of e.g. an ENDSBS), so it could do its own cleanup.
He was concerned that if it was in the middle of a sleep cyccle, it
wouldn't know that its job was being ended. For this, there is no
solution, except to use a 'signal' (in the broader sense of the word) -
either a special data queue entry on a data queue that the NEP is
monitoring being received to say "Hey!
End gracefully" or maybe a sigalarm being sent to the program which
would wake itself up from up from its sleep. I guess potentially using
the SHUTDN opcode would work, but only if the program was checking it
often enough to 'catch' it before the system actually *did* shut the
program down 9I think there's only a short period of time between the
system triggering the SHUTDN flag and it actually ending the program).

Personally, I'd use the data queue method, because it allows you very
simply to have a command to send the 'end' data queue entry. It's very
flexible and neat. In fact, I've attached some code I wrote a while back
for a 'generic'
data queue server. If anyone thinks it might make sense, let me know (it
doesn't help with triggering of the data queue, but it can be used as
the 'server' portion). I was thinking about making t as a black-box
tool, but I really can't be bothered, so the code is for anyone to use.
Just compile the objects and try it out...

Rory

On Wed, May 20, 2009 at 8:31 PM, Peter Connell <
Peter.Connell@xxxxxxxxxxxxxxxxx> wrote:

Yes, devolved from "how to monitor EOJ for an RPG pgm" for which I
still recommend a scope msg.
I'm not going anywhere near the other discussion.

Peter

#####################################################################################
This correspondence is for the named person's use only. It may contain confidential or legally privileged information, or both. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this correspondence in error, please immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this correspondence if you are not the intended recipient. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of Veda Advantage. If you need assistance, please contact Veda Advantage on either :- Australia 133124 or New Zealand +64 9 367 6200

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.