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