DATA: lo_meco TYPE REF TO /iwbep/if_message_container,
lx_busi_exc TYPE REF TO /iwbep/cx_mgw_busi_exception,
lt_log TYPE bapiret2_t.
IF lt_log IS NOT INITIAL. "Se vengono restituiti dei messaggi
LOOP AT lt_log INTO DATA(ls_log) WHERE type EQ 'E' OR type EQ 'A'.
ENDLOOP.
IF sy-subrc EQ 0. "Se ci sono messaggi di errore
lo_meco = mo_context->get_message_container( ).
lo_meco->add_messages_from_bapi(
EXPORTING
it_bapi_messages = lt_log
).
CREATE OBJECT lx_busi_exc
EXPORTING
message_container = lo_meco.
RAISE EXCEPTION lx_busi_exc.
ENDIF.
ENDIF.
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/m/MessageBox",
"./Utilities"
], function (Controller, JSONModel, MessageBox, Utilities) {
"use strict";
var a = JSON.parse(response.responseText);
var errDetails = a.error.innererror.errordetails;
Utilities.manageErrors(errDetails);
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
'sap/m/Link',
"sap/ui/core/Icon",
"sap/m/MessageItem",
"sap/m/MessageView",
"sap/m/Button",
"sap/m/Bar",
"sap/m/Text",
"sap/m/Dialog"
], function (Controller, JSONModel, Link, Icon, MessageItem, MessageView, Button, Bar, Text, Dialog) {
"use strict";
return {
initMessage: function (errDetails) {
// var oLink = new Link({
// text: "Show more information",
// href: "http://sap.com",
// target: "_blank"
// });
var a = this.getText("year");
var oMessageTemplate = new MessageItem({
type: '{type}',
title: '{title}',
description: '{description}',
subtitle: '{subtitle}',
counter: '{counter}',
markupDescription: '{markupDescription}'
// link: oLink
});
var aMockMessages = [];
for (var i = 0; i < errDetails.length; i++) {
var name = errDetails[i].severity;
var nameCapitalized =
name.charAt(0).toUpperCase() + name.slice(1);
var semiDescription =
errDetails[i].message.slice(0, 10);
semiDescription =
semiDescription.concat('...');
var oMockMessage = {
type: nameCapitalized,
title: semiDescription,
description: errDetails[i].message
};
aMockMessages.push(oMockMessage);
}
var oModel = new JSONModel();
oModel.setData(aMockMessages);
var that = this;
var oBackButton = new Button({
icon: sap.ui.core.IconPool.getIconURI("navback"),
visible: false,
press: function () {
that.oMessageView.navigateBack();
this.setVisible(false);
}
});
this.oMessageView = new MessageView({
showDetailsPageHeader: false,
itemSelect: function () {
oBackButton.setVisible(true);
},
items: {
path: "/",
template: oMessageTemplate
}
});
this.oMessageView.setModel(oModel);
this.oDialog = new Dialog({
resizable: true,
content: this.oMessageView,
state: 'Error',
beginButton: new Button({
press: function () {
this.getParent().close();
},
text: "Close"
}),
customHeader: new Bar({
contentMiddle: [
new Text({
text: "Error"
})
],
contentLeft: [oBackButton]
}),
contentHeight: "300px",
contentWidth: "500px",
verticalScrolling: false
});
},
manageErrors: function (errDetails) {
this.initMessage(errDetails);
this.oMessageView.navigateBack();
this.oDialog.open();
}
};
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |