Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Command RTNVAL and MONSMSG

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

  • Command RTNVAL and MONSMSG

    The connundrum you're experiencing is consistent with how *NOTIFY exception messages and the command environment work. Passing parameters on a CALL command and passing them through a command using RTNVAL(*YES) both operate differently. When using the CALL command it passes pointers to the called program that directly reference storage in the calling program. When using a command with RTNVAL(*YES) the parameters are copied to a temporary space and the pointer passed to called program references this temporary space and not the storage in the calling program. When the called program ends normally the parameters in this temporary space are then copied back to the calling program. Exception type messages like *NOTIFY and *ESCAPE act differently. *ESCAPE always causes a program to end prematurely, but with *NOTIFY this depends on whether or not the calling progamm is monitoring for the message. If a calling program is monitoring for a *NOTIFY message then when the called program sends it, it acts like an *ESCAPE message and forces the called program to terminate prematurely. If this called program was invoked through a command with RTNVAL(*YES) then none of the return parameters will be returned. When the caller is not monitoring for the message then the called program won't end prematurely and any command environment parameters will be returned. In the first case you're bypassing the command environment and calling the CPP directly. The calling program is passing a pointer that directly references one of it's own storage locations, so when the CPP changes the field it's changing it directly in the calling program's storage before is sends the *NOTIFY message. It doesn't matter that the program ended prematurely because the storage location was already changed. In the 2nd case you're using the command interface, but you're not monitoring for the *NOTIFY message. Since the CPP is not ending prematurely the command environment is returning the changes to the calling program. In the 3rd case you're using the command and you're monitoring for the *NOTIFY message. While the CPP is ending prematurely you didn't pass the parameter so in the end it doesn't matter. In the 4th case your using the command, passing a parameter, and monitoring for the *NOTIFY message. The CPP ends prematurely, the command environment senses this and doesn't return any RTNVAL(*YES) parameters, so &JB ends up being blank.

  • #2
    Command RTNVAL and MONSMSG

    I am having a problem using MONMSG with a Return value on a command. You can see the code for the command and the CPP in the txt document attached. In fact I can't get the return value (blank) if I use MONSMG to monitor the command execution in my program. Thanks for any help on this subject.

    RTNVAL_MONMSG.txt

    Comment

    Working...
    X