On 25-Apr-2014 17:15 -0500, Kurt Anderson wrote:

We're at 7.1. We recently started using the RPG control option of
MAIN to point the program to a procedure to process instead of using
the cycle and mainline code.

Today we had such a program, being called by a CL, get a hard error
in the main procedure. When we go in to debug it, it takes us to the
CL as being the current line, which means if we go into the actual
program to see the variables they're all out of scope. Is there a way
to get the error to halt the program in the procedure so we can debug
the active/MSGW job?

The RPG program\procedure is no longer on the stack, for the lack of one of an [RPG specific or ILE] exception handler, an ILE condition handler, or an ILE cancel handler, having been coded. The job will not go into Message Wait (MSGW) status due to the RPG Default Handler inquiry, because the RPG compiler would not have generated such a handler to be invoked at run-time in response to an error. The onus is on the programmer to code whatever they want done in the event of an error or any other [unexpected] condition that needs to be handled. That error handling could be code that is designed to act effectively identically to the RPG default handler to send an inquiry and await a reply message; although there is effectively no support for the ability to effect [easily the] retry of the failing statement.

IBM i 7.1 Information Center -> Programming -> Programming languages -> RPG -> ILE RPG Programmer's Guide -> Debugging and Exception Handling -> Handling Exceptions -> Exception Handling Overview -> ILE RPG Exception Handling
_Exception Handling within Subprocedures_
"Exception handling within a subprocedure, including one designated as a linear-main procedure, differs from exception handling within a cycle-main procedure in the following ways:

• If you are using a global file, then because you cannot code an INFSR subroutine for that file, you should handle file errors using error indicators, the 'E' operation code extender, or a MONITOR group.
• There is no default handler; in other words, users will never see an inquiry message.

Exception handling within a subprocedure differs from a cycle-main procedure primarily because there is no RPG cycle code generated for subprocedures. As a result there is no default exception handler for subprocedures and so situations where the default handler would be called for a cycle-main procedure correspond to abnormal end of the subprocedure. ..."

That and the other topics under the following section of the ILE RPG Programmer's Gd should be helpful:

This thread ...


Return to Archive home page | Return to MIDRANGE.COM home page