|
Hi Donnie, > > I am executing a command interactively from the command line using a rpgle > program as its processor. When the rpgle program encounters an error, > QMHSNDPM is used to send an error. Unfortunately, the error flashes and is > gone. In the rpgle processing after the message is sent, the program ends. > How do I get the message to remain on the display after message is sent? In OS/400 there are many different message "types", and each one has it's own purpose. Here are the program message types that I use frequently: A *STATUS message (the type that you are sending) is intended to show what's currently happening in a program. You use them to say things like "processing orders from March, 2003..." something like that. They're not intended to remain on the screen when the program stops, since they're to report the current program's status. Likewise, *DIAG (diagnostic) messages are intended for adding debugging or troubleshooting information to the job log. *COMP messages are sent to the previous program on the stack to tell that program that your program has completed. They are usually used when a program is successful. *ESCAPE messages are sent when an error occurs in a program. They end the program that's running, and must be monitored for by the calling program (or else the caller stops with a "function check") The reason your program "flashes and then is gone" is because you're sending a *STATUS message and then ending the program immediately. > > I have tried different variations of the message type and '*' for the > call stack entry, but without success. I know on SNDPGMMSG, *PRV can be > used for TOPGMQ, but I can't seem to find the equivalent option for the > api. Here is an excerpt of the code: [SNIP] Nice code. Looks like something that I'd write. :) Specifying *PRV on a CL command is the same as specifying CallStkEnt='*' and CallStkCnt=1. Why? Because * means the current call stack entry and 1 means to count one step back. So, it's one step earlier than the current entry... HOWEVER, an ILE RPG program is different from an OPM CL program. If you look at the call stack for an ILE RPG program, you'll see something like this: Program Rqs or Lvl Procedure Library Statement Instruction ...this is where the calling program would be... < P_WIIFGIR4 LIBSCK WIIFGIR4 LIBSCK 0000000511 GET_PROD LIBSCK 0000000605 The first entry (P_WIIFGIR4) is the program itself. The second is the "main procedure" (WIIFGIR4) which is called automagically by the program when it starts, and then GET_PROD is a subprocedure that's called in my program. So, for GET_PROD to return an escape message that goes back to the calling program, it needs to set CallStkEnt='*' and CallStkCnt=3. Because, if you count back 3 levels from GET_PROD, you'll see that you're at the calling program. I'd use message type *ESCAPE to signal an error. Likewise, if I wanted to send back an *ESCAPE from the main procedure (WIIFGIR4) I'd use CallStkEnt='*' and CallStkCnt=2. This is the big diff between ILE RPG and OPM CL. In OPM CL, there's just the one call stack entry -- so any message to the previous program would be *PRV. But in a more sophisticated language, I'm able to create multiple call levels... If you want to display your call stack, you can do it with: DSPJOB OPTION(*PGMSTK) or, if you want to do it from another terminal/window while your program is executing, you can use WRKACTJOB, then put a 5 next to the job you want to display, followed by an 11 for "display call stack". Good luck!
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.