ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Send Program Message (QMHSNDPM) API works differently from SNDPGMMSG command

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

  • Send Program Message (QMHSNDPM) API works differently from SNDPGMMSG command

    Good day.
    I have created a CLLE test program that sends a diagnostic message. When this program is launched, the message goes to the interactive task log and also appears in the status bar.
    Code:
    PGM
       SNDPGMMSG  MSGID(CPA2401) MSGF(QCPFMSG) +
                  MSGDTA('Diag message!') MSGTYPE(*DIAG)                  
    ENDPGM
    Next, I wrote a C program that also sends a diagnostic message via the Send Program Message (QMHSNDPM) API. However, when this program is launched, the message only goes to the job log. It does not appear in the status bar.

    Can someone explain to me why this is happening and how to fix it?

  • #2
    Best guess, it's something to do with the Call Stack entry parameter: https://www.ibm.com/support/knowledg...s/QMHSNDPM.htm

    Comment


    • #3
      You mean the 6th API parameter? Yes, I agree, probably this is the reason. The SNDPGMMSG command has a TOPGMQ parameter and is set to * PRV by default. However, the API does not have a similar value for parameter 6. In general, the command and API parameters are very different in terms of the call stack.

      Comment


      • #4
        I did an experiment. I wrote the TSLLE code in which I send a diagnostic message. If this code is compiled into a program and run, then the message appears both in the status line and in the task log.
        If you put the code into a module, put this module in the C program and call the code of this module for execution there, then when you start such a program, the message appears only in the task log. It is not broadcast on the screen.
        I don't understand anything now ...

        Comment


        • #5
          API Call Stack Entry can accept a numeric value to indicate the target entry for the message, relative to current. 0 means current program, 1 means previous program, etc. So I think 1 should be the same as SNDPGMMSG *PRV

          Comment


          • #6
            Try setting the call stack entry (6th parameter) to *PGMBDY and the call stack counter (7th parameter) to 1. This means to go one entry previous to the program boundary. Does that do what you wanted?

            Comment


            • #7
              Originally posted by Scott Klement View Post
              Try setting the call stack entry (6th parameter) to *PGMBDY and the call stack counter (7th parameter) to 1. This means to go one entry previous to the program boundary. Does that do what you wanted?
              Thank! Yes, the API settings you specified led to the desired behavior: when a message is sent, it gets into the job log and appears in the status line.

              Can you explain in more detail why if you specify any value other than *PGMBDY (for example, *EXT) as the sixth parameter, then this does not lead to the desired result (the seventh parameter is equal to 1)?

              Comment


              • #8
                For *EXT, you'd set the 7th parameter to 0. Otherwise, you're sending it to one stack entry prior to *EXT, which isn't what you want.

                Comment


                • #9
                  The problem is that if I use *EXT and set the seventh parameter to 0, then the message is sent to the job log, but does not appear in the status bar. Why is this happening?

                  Comment

                  Working...
                  X