ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

MONMSG - What is the better way to handle unknown errors in RPG from a CL?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MONMSG - What is the better way to handle unknown errors in RPG from a CL?

    Experts,

    I am writing a CL program, and I wanted to use MONMSG on where the called program is error out.

    ON my CL, I call RPG program, and after calling RPG program, I have a MONMSG.

    RPG can blew for many reasons.. example CPF0000, RNQ0000, RNX, MCH, I don't what to check for all these codes. even though I can do multiple message ID with generic a single MONMSG.

    I can do a RCVMSG.. but before even using RCVMSG, I may need to know first whether the program error out or not..

    OR

    Is that possible to have one MONITOR for a whole RPG?.

    OR

    Is PSSR is better and do not handle this in CL?


    What is the better way to handle unknown errors in RPG from a CL?


    Thanks
    Stillin400



  • #2
    For any CL command, you can view what messages may be monitored by entering the command on a command line, prompting it, then hitting F1, then F2, and scrolling to the very bottom of the resulting text, where you will see a list of messages.

    If you do this for command CALL, you'll see that the list of messages is not very long.

    So, to answer your question, yes, a PSSR or other method of monitoring for messages from within the RPG program and dealing with the error there is better.

    Cheers,

    Emmanuel

    Comment


    • #3
      Thanks Emmanuel.
      We have latest installation of OS/400 which I think 7.3 or later.

      We are writing in RPG FREE.

      Are there any example or link of PSSR in RPG FREE that anyone can share?


      To my understanding is that we are going away from PSSR in RPG FREE.

      My program is too big and do not wanted to go and change every step by a Monitor command.

      Thank You
      Stillin400



      Comment


      • #4
        I would use MONITOR. You don't have to code it separately for everything, you just do something like this:
        Code:
           monitor;
              MainRoutine();
           on-error;
              // handle errors here
           endmon;
        In this case, MainRoutine() contains everything the program does, so putting the call to MainRoutine() inside MONITOR will trap any error. (This includes errors from all subprocedures you call, unless they are in a separate activation group.)

        This is much better than the clunky/nasty old *PSSR. (Which would also require stuff like an INFSR for file errors, a separate *PSSR in each subprocedure, extra code to make sure you don't have an error in the PSSR itself since that would create a loop, etc.)

        Comment


        • #5
          Thank You Scott.
          I will try that, and will keep posted.
          Stillin400

          Comment


          • #6
            Thank You Scott,
            That Worked perfect.

            Comment

            Working...
            X