ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

User warning message

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

  • User warning message

    Hi

    I cannot figure out how I can send a simple user warning (not error) message from a RPGLE to the bottom of the iSeries session.

    I came across SNDPRGMSG which seems to be only used in CL.
    I also came across the following method as well but all I need is to send a message saying, "Hey, by the way A equals B" back to the session. Is the following the best/shortest way to do it?

    Code:
    D SendEscMsg      pr                  extpgm('QMHSNDPM')
    D   MsgID                        7    const             
    D   MsgFile                     20    const             
    D   MsgDta                      80    const             
    D   MsgDtaLen                   10i 0 const             
    D   MsgType                     10    const             
    D   MsgQ                        10    const             
    D   MsgQNbr                     10i 0 const             
    D   MsgKey                       4                      
    D   ErrorDS                     16                      
                                                            
    D ErrorDS         ds            16                      
    D   BytesProv                   10i 0 inz(16)           
    D   BytesAvail                  10i 0                   
    D   ExceptionID                  7                      
                                                            
    D MsgDta          s             80                      
    D MsgKey          s              4                      
                                                                   
    C                   eval      MsgDta = '[B]Something went wrong[/B]' 
    C                   callp     SendEscMsg ('CPF9898':           
    C                               'QCPFMSG   QSYS':              
    C                               MsgDta:                        
    C                               %len(MsgDta):                  
    C                               '*ESCAPE':                     
    C                               '*':                           
    C                               2:                             
    C                               MsgKey:                        
    C                               ErrorDS)

  • #2
    Re: User warning message

    An *ESCAPE message is normally sent to indicate that your program or subprocedure "ended abornmally". In other words, to indicate failure to a calling program on the call stack.

    A *COMP message would be used to indicate successful completion of a program.

    Not exactly sure how a "warning" message fits here -- I wouldn't typically see a warning message in program-to-program communications. but, perhaps a *COMP mesage would work for that, too.. or perhaps an *INFO or *INQ message would make sense. It really depends on what you're trying to do. I'm not sure that a calling progam would ever know how to handle a "warning" -- I would think that would be more useful in an interaction with a user.

    But, there are situations where I've put warnings in the job log as just *INFO, so that a user could go back and see the warnings if needed, even though they wouldn't interrupt the process. Or, in some cases, you want to stop the process and make them answer a message with "G=Go, or I=Ignore" or something like that -- ihn which case you'd want an *INQ message. Using messages is mostly useful for technical users -- like when your users are programmers or system operators. If your user is a non-technical person, you're better off using an actual user-interface (like displaying a screen.)

    The API you're using (which is called QMHSNDPM -- send program message) is pretty much identical to the SNDPGMMSG CL command. Not sure why you've called it 'SendEscMsg' whien *ESCAPE is a parameter that can be changed to other values.

    Comment


    • #3
      Re: User warning message

      If you want the message to show up after the program has completed, try message-type *COMP, pgm-queue *CTLBDY, and stack-offset 1.

      If you want the message to show up while the program is running, try message-type *STATUS, pgm-queue *EXT. I don't think the stack-offset matters for *EXT, but I use 0.

      Comment


      • #4
        Re: User warning message

        Having a program message appear somewhere on the screen implies that some program is managing the screen and that you are sending the message to that program. The receiving program might or might not show any message that is sent to it.

        I'd expect that a *STATUS message sent to *EXT is probably the best starting point. Whether or not the message actually appears can depend on what the job is doing with *STATUS messages. There are job and user attributes that can affect the display of *STATUS messages. If necessary for testing, those attributes can be changed until your programming works. Then you can begin testing variations.
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment

        Working...
        X