Problems when ILE CL Monitors for Notify and Status Messages

If your ILE RPG procedure is called by an ILE CL procedure in the same activation group, and the caller is monitoring for status or notify messages, then your ILE CL caller may get control prematurely because of a notify or status message that the ILE RPG procedure was trying to ignore.

For example, if the ILE RPG procedure writes a record to a printer file and the actual printer file has a shorter record length that was declared in the RPG procedure, notify message CPF4906 is sent to the RPG procedure. The RPG exception handling percolates this message which causes the default reply of 'I' to ignore the message. This should allow the output operation to continue normally, and the RPG procedure should proceed to the next instruction.

However, when the ILE CL MONMSG gets control, control passes immediately to the action for the MONMSG or the next statement in the ILE CL procedure.

Note:
For this problem to occur, the procedure monitoring for the message does not have to be the immediate caller of the RPG procedure.

This problem is most likely to occur with a MONMSG in an ILE CL caller, but it can also occur with other ILE languages that can monitor for notify and status messages, including ILE RPG using ILE condition handlers enabled using CEEHDLR.

If you encounter this problem, you have two possible ways to avoid it:

  1. Ensure that the caller is in a different activation group from the ILE RPG procedure.
  2. Enable an ILE condition handler in the RPG procedure. In the handler, if the message is one that you want to ignore, indicate that the message should be handled. Otherwise, indicate that it should be percolated.

    You could also make this handler more generic, and have it ignore all messages with a severity of 0 (information) and 1 (warning).

    Figure 147 shows an example of a ILE condition handler that ignores CPF4906.

    Figure 147. ILE Condition Handler that Ignores CPF4906
          *----------------------------------------------------------------
          * Handler definitions
          *----------------------------------------------------------------
         D Action          S             10I 0
         D Token           DS
         D   MsgSev                       5I 0
         D   MsgNo                        2A
         D                                1A
         D   Prefix                       3A
         D                                4A
          *----------------------------------------------------------------
          * Actions
          *----------------------------------------------------------------
         D Handle          C                   10
         D Percolate       C                   20
          *----------------------------------------------------------------
          * Severities
          *----------------------------------------------------------------
         D Info            C                   0
         D Warning         C                   1
         D Error           C                   2
         D Severe          C                   3
         D Critical        C                   4
         C     *ENTRY        PLIST
         C                   PARM                    Token
         C                   PARM                    dummy             1
         C                   PARM                    Action
          *----------------------------------------------------------------
          * If this is CPF4906, handle the notify msg, otherwise percolate
          *----------------------------------------------------------------
         C                   IF        Prefix = 'CPF' AND
         C                             MsgNo = X'4906'
         C                   EVAL      Action = Handle
         C                   ELSE
         C                   EVAL      Action = Percolate
         C                   ENDIF
         C                   RETURN

    Figure 148 shows how you would code the calculations if you wanted to ignore all status and notify messages. Escape messages and function checks have a severity of 2 (Error) or higher.

    Figure 148. How to Ignore Status and Notify Messages
          *----------------------------------------------------------------
          * Handle information or warning messages, otherwise percolate
          *----------------------------------------------------------------
         C                   IF        MsgSev <= Warning
         C                   EVAL      Action = Handle
         C                   ELSE
         C                   EVAL      Action = Percolate
         C                   ENDIF
         C                   RETURN

 



[ Top of Page | Previous Page | Next Page | Contents | Index ]