cancel
Showing results for 
Search instead for 
Did you mean: 

SAP-ME notification Using addNotification PAPI is not triggering Message

bpratik16
Explorer
0 Kudos
293

Hello Experts
There is one issue which we are facing and is looking forward for your help

Application Used:SAP-ME and SAP-UI5

Scenario: We are doing Data Collection Using PAPI services in SAP-ME and the collected data we are showing it in our Custom SAP-UI5 screen. We have used two PAPI action blocks which are findNoticationConsumersForClient and addNotificationMessageConsumer. This PAPI is used to create a Channel and a topic Name and whenever there are Data collection happening these PAPI are getting called which in turn is calling our controller page(Which has a listener) and our SAP-UI5 screen is getting refreshed. We are using this so that we dont have to do a manual refresh every-time after Data Collection.

Below is the controller code.

/***********************************Start of Controller Code***************************************************************************/

listening Started: function ()

{

return new Promise(function (e, t) { jQuery.getScript("/manufacturing/com/sap/me/messaging/client/MessagingIO.js").done(function () { MessagingIO.prototype.getContextRoot = function ()

{ return "/manufacturing/"

}, this._oMessagingIO = new MessagingIO, this.fireConnecting(),this._oMessagingIO.startListening({

fnMessageCallback: this.handleMessage,

fnContext: this,

iKeepAlivePeriod: 0, sClientId : 'Standard_Plant' }),

this._oMessagingIO.oEventSource.onopen = function (e)

{ this.fireOpen(e)

}.bind(this), this._oMessagingIO.oEventSource.onerror = function (e)

{ this.fireError(e), 2 === this._oMessagingIO.oEventSource.readyState && this.fireClose()

}.bind(this), e() }.bind(this)).fail(function () {

t() })

}.bind(this)) },

handleMessage: function (e)

{ var t = e[0];

t.message = this.formatResponseData(t);

var RefreshType=t.message.topicKeys.RefreshType },

addConsumer: function (e) { return this._oMessagingIO ? this._oMessagingIO.addConsumer(e) : -1 },

removeConsumer: function (e) { this._oMessagingIO && this._oMessagingIO.removeConsumer(e) },

stopListening: function () { this._oMessagingIO && (this.fireClose(), this._oMessagingIO.stopListening(), delete this._oMessagingIO) },

getClientId: function () { return this._oMessagingIO ? this._oMessagingIO.getMessageClientId() : -1 },

attachConnecting: function (e, t, n) { return this.attachEvent("connecting", e, t, n), this },

detachConnecting: function (e, t) { return this.detachEvent("connecting", e, t), this },

fireConnecting: function (e) { return this.fireEvent("connecting", e), this }, attachOpen: function (e, t, n) { return this.attachEvent("open", e, t, n), this },

detachOpen: function (e, t) { return this.detachEvent("open", e, t), this },

fireOpen: function (e) { return this.fireEvent("open", e), this }, attachMessage: function (e, t, n) { return this.attachEvent("message", e, t, n), this },

detachMessage: function (e, t) { return this.detachEvent("message", e, t), this },

fireMessage: function (e) { return this.fireEvent("message", e), this },

attachError: function (e, t, n) { return this.attachEvent("error", e, t, n), this },

detachError: function (e, t) { return this.detachEvent("error", e, t), this },

fireError: function (e) { return this.fireEvent("error", e), this },

attachClose: function (e, t, n) { return this.attachEvent("close", e, t, n), this },

detachClose: function (e, t) { return this.detachEvent("close", e, t), this },

fireClose: function (e) { return this.fireEvent("close", e), this },

REGEX_MESSAGE: /\[message=(.*?)]/,

REGEX_TOPIC_KEYS: /\[topicKeys={(.*?)}]/,

formatResponseData: function (e) { var t = e.message, n = {}; n.message = this.REGEX_MESSAGE.exec(t)[1];

for (var s = [], i = this.REGEX_TOPIC_KEYS.exec(t)[1].split(","), r = 0; r < i.length; r += 1) { var o = i[r].split("="), a = o.shift().trim(), h = o.join("="); s[a] = h.trim() }

return n.topicKeys = s, n },

/******************************************* End Of Controller Code********************************************************/

Issue: There is one issue which we are facing in the above scenario. The issue is that when we are opening multiple Custom Data-Collection SAPUI5 screen and doing data collection then that particular notification is getting triggered to only one user i.e only on one screen and not on all Screen. For Example Suppose User A, User B and User C has opened the screen at the same time and the Data-Collection happens then the notification is going only to User A and not to User B and User C and hence the new refreshed data is shown only on User A screen.This is happening very randomly we need some assistant for this

Accepted Solutions (0)

Answers (0)