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



Birgitta, no disrespect but I think you are missing a few things. I agree
you could use the new SND-MSG command now(Relatively recent) but the only
thing you are going to know is that an error occurred.

The question I pondered 26 years ago was that I have procedure A that calls
procedure Serv1 in service program MySP1 that calls Serv2 in service
program MySP2. I throw errors all the way up but how do I report what
caused the error. That's what the standard error handler does. It stores
the errors in a list that can be reported. You can report what really
caused the error.

Also, 26 years ago and until recently the only way to do this from an RPG
program was using the System API 's and as you know QMHSNDPM is a dozzy.

I just wanted a simple consistent(This is the most important) interface to
report and manage errors in an ILE environment. My standard error handler
does that.

On Thu, Feb 15, 2024 at 12:16 AM Birgitta Hauser <Hauser@xxxxxxxxxxxxxxx>
wrote:

... may be I misunderstood something
But...
Why not simply send an escape message (meanwhile there is even an opcode
SND-MSG) ... and in the caller you catch the error with a Monitor Group.
BTW the error message if you need it can be taken from the program status
data structure position 91-170.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i
Database and Software Architect
IBM Champion since 2020

"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!"
"Train people well enough so they can leave, treat them well enough so
they don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!" (Albert
Einstein)

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Alan
Campin
Sent: Thursday, 15 February 2024 05:50
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Stopping processing with using a bunch of if statements

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-handl
er

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.


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


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