receivePgmMsg()

This procedure receives message to program from call stack entry.

ParameterTypeDescription
callStackEntry4096AMandatoryCall stack entry. The program name from call stack to which the message was sent.
msgKey4AMandatoryUnique message key of message. Input/Output parameter. Used to loop thorugh all messahges. It can be unique message number of special value *TOP. The receivePgmMsg function will receive first message after message with mesgKey provided.
msgType10AOptionalType of message to receive. If not provided the value is defaulted to *NEXT. See QMHRCVPM api descriptin form IBM.
msgAction10AOptipnalAction to take after message is received. Valid values are *OLD, *SAME, *REMOVE. The default value is: *SAME. See QMHRCVPM api descriptin form IBM.
callStackCount10I 0OptionalCall stack counter A number identifying the location in the call stack of the call stack entry to whose message queue the message is to be sent. The number is relative to the call stack entry identified by the Call stack entry parameter. It indicates how many calls up the call stack the target entry is from the one identified by the Call stack entry parameter. it could be 0 or any positive number.
callStackEntryLen10I 0OptionalLength of call stack entry The length of the value for the Call stack entry parameter. See QMHSNDPM IBM API for more details.
callStackEntryQual20AOptionalCall stack entry qualification. This parameter is used when it is necessary to further identify the call stack entry. The parameter consists of two 10 character parts. The first part is the module name qualifier and the second part is the program name qualifier. See QMHSNDPM IBM API for more details.

Procedure returns message info data structure (see data structure description bellow).

FieldTypeDescription
msgId7AId of message
msgText1*Pointer to first level text of message.
msgText1Len10I 0Length of first level text.
msgText2*Pointer to second level text of message.
msgText2Len10I 0Length of second level text.
msgFields1024Afields names coma separated which are connected to message.
msgType10AType of message.

Examples:

   //Definition of variables
D  dsMsgInfo      DS                  likeds(msgInfo_template)  
D  lMsgKey        S              4a                             

//Receive one message from call srtack of program MGRR0001
lMsgKey = "*TOP";
dsMsgInfo = receivePgmMsg("MGRR0001" : lMsgKey);

//Loop trough all messates 
lMsgKey = "*TOP";
dsMsgInfo = receivePgmMsg("MGRR0001" : lMsgKey);
dow dsMsgInfo.msgText1Len > 0;   
    
    // ener your code here....

  dsMsgInfo = receivePgmMsg(callStackEntry :lMsgKey);  
enddo;