× 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 are probably not going to be interested but I have a standard error
handler that I wrote 26 years ago and still uses in every project I create.
It is a service program called XVERRH.

It has functions to throw errors, rethrow errors, save messages and get
messages.

For example,

dcl-s MessageId Char(7);
dcl-s MessageData VarChar(32767);

dcl-ds dsQualifiedMessageFile Qualified;
FileName Char(10);
LibName Char(10);
end-ds;

Monitor;
Procedure1();
On-Error;
DoW TRUE;
If XVERRH_GetMessages(MessageId: dsQualifiedMessageFile: MessageData);
// Process Message
Else;
Leave; // Done processing messages.
EndIf;
EndDo;
EndMon;

dcl-proc Procedure1;
dcl-pi *N end-pi;

Monitor;
Procedure2();
On-Error;
XVERRH_Rethrow(); // Throws message back to caller.
EndMon;

end-proc;

dcl-proc Procedure2;
dcl-pi *N end-pi;

// Perform some actions and error occurs.
XVERRH_Throw('CPF9898':
CPF_MESSAGE_FILE_NAME:
'Error occurred in Procedure2. See job log');

end-proc;

What is happening when an error occurs is that it stores the message in a
list and throws an error to the caller where the caller can throw it back
up. This can occur for any number of levels.
when it gets to the top it can retrieve the messages and display them. I
think this is what you want to do.

I will send you the source code if you are interested. Just one service
program with three modules.



On Wed, Feb 14, 2024 at 6:28 PM Mark Waterbury <
mark.s.waterbury@xxxxxxxxxxxxx> wrote:

Hi, John,

At V7R3 or earlier, you can use the ILE condition handler -- see:


https://www.ibm.com/docs/en/i/7.3?topic=handlers-using-condition-handler

Hope that helps,

Mark S. Waterbury

On Wednesday, February 14, 2024 at 05:10:01 PM EST,
smith5646midrange@xxxxxxxxx <smith5646midrange@xxxxxxxxx> wrote:

I have an RPGLE program that calls a number of procedures. If it is in a
procedure and it detects an error, I want it to stop processing and exit
back to the main procedure where the initial screen is displayed to inform
the user of the error. I do not want the program to abend. Is there a way
do to this without placing an if statement after each procedure? That
could
get really ugly and it would probably be easy to miss one because not all
procedures can encounter an error.

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

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.