pjs.sendMessage()
Sends a message to a session-based Subfile Program Message Queue. This API is utilized in conjunction with setting the sflMsgQueueType and the msgFileType configuration options.
There are two possible scenarios:
Message files are *MSGF objects on the IBM i (requires Profound.js 7.18.0 or above).
sflMsgQueueType must be set to “pjs session”.
msgFileType must not be set.
Message files have already been converted to json files.
sflMsgQueueType must be set to “pjs session”.
msgFileType must be set to "json".
The messages are then typically displayed within a Rich Display File that defines a messages grid with Message Subfile Settings.
Parameters
Message File - the name of the JSON-based message file; if not qualified, the pathlist is used to find the .json message file
Message ID - the ID of the message to retrieve from the message file
Message Replacement Data (optional) - data field or a data structure that contains all the replacement values required by the message; the length and format of the field depend on the substitution variables described in the message; for example, for a message with 2 substitution variables defined as *CHAR 10 and *CHAR 5, the replacement data should be a 15 byte field
Program Message Queue (optional) - the name of a message queue; if not specified, the current program name is used
Message File Library (optional - is ignored if msgFileType is set to "json") - the name of the library where the message file is located; default value is “*LIBL”.
Example if message files are *MSGF objects on the IBM i:
// ****************************************************
// Example with empty data and without message library
// ****************************************************
messageId = "CAE0002";
messageFile = "QCPFMSG";
messageData = "";
messageQ = "MYPGM";
pjs.sendMessage(messageFile, messageId, messageData, messageQ);
// *******************************************
// Example with data and with message library
// *******************************************
// The CAE0005 message expects 2 char fields with a length of 8.
pjs.define("msg_Data_DS", {
type: "data structure",
elements: {
day01: { type: "char", length: 8 },
day02: { type: "char", length: 8 }
},
});
messageId = "CAE0005";
messageFile = "QCPFMSG";
day01 = '01/02/99';
day02 = 'YY/MM/DD';
messageQ = "MYPGM";
messageLibrary = "QSYS";
pjs.sendMessage(messageFile, messageId, messageData, messageQ, messageLibrary);
Example if message files have been converted to the json format:
pjs.sendMessage('MYMSGF.json', 'ERR9999', msgdata);
Requires PJS version 7.18.0 or later.