Как восстановить сообщение об ошибке из ответа oData [SAPUI5]

У меня была эта проблема, и я много искал, как ее исправить, но пока не могу найти решения...

хорошо, проблема в следующем сообщении об ошибке, я могу написать ошибку, но мне нужна конкретная запись этого пакета.

Ошибка, окно сообщения и пакетный ответ.

код, показанный в окне сообщения:

{"message": "HTTP-запрос не выполнен", "headers": { "Content-Type": "application/xml;charset=utf-8", "Content-Length": "1333", "DataServiceVersion": "1.0" }, "statusCode": "400", "statusText": "Bad Request", "responseText": "http://schemas .microsoft.com/ado/2007/08/dataservices/metadata\"> SY/530 Нет разрешений для Центрального избирательного центра /SAP/ZQMGW_LECTURATANQUE_SRV00019488BBDEFA9E11E685950000705EE2FB20170224144147.5230000Run транзакция /IWFND/ERROR_LOG на сервисе шлюза SAP выше 171. /sap/support/notes/1797736) См. SAP-ноту 1869434 для получения подробных сведений о работе с $batch (https: //service. sap. com/sap/support/notes/1869434). Нет сведений о разрешении для доступа к Centro seleccionadoerror /IWBEP/CX_SD_GEN_DPC_BUSINS No posee permisos para el centro seleccionadoerror" }

мне нужно только восстановить тег сообщения, но я не знаю как....

код, который я использую, является встроенной обработкой ошибок для приложений Sapui5 Fiori:

    constructor: function(oComponent) {
        this._oResourceBundle = oComponent.getModel("i18n").getResourceBundle();
        this._oComponent = oComponent;
        this._oModel = oComponent.getModel();
        this._bMessageOpen = false;
        this._sErrorText = this._oResourceBundle.getText("errorText");

        this._oModel.attachMetadataFailed(function(oEvent) {
            var oParams = oEvent.getParameters();
            this._showServiceError(oParams.response);
        }, this);

        this._oModel.attachRequestFailed(function(oEvent) {
            var oParams = oEvent.getParameters("message");
            // An entity that was not found in the service is also throwing a 404 error in oData.
            // We already cover this case with a notFound target so we skip it here.
            // A request that cannot be sent to the server is a technical error that we have to handle though
            if (oParams.response.statusCode !== "404" || (oParams.response.statusCode === 404 && oParams.response.responseText.indexOf(
                    "Cannot POST") === 0)) {
                this._showServiceError(oParams.response);
            }
        }, this);
    },

    /**
     * Shows a {@link sap.m.MessageBox} when a service call has failed.
     * Only the first error message will be display.
     * @param {string} sDetails a technical error to be displayed on request
     * @private
     */
    _showServiceError: function(sDetails) {
        if (this._bMessageOpen) {
            return;
        }
        this._bMessageOpen = true;
        MessageBox.error(
            this._sErrorText, {
                id: "serviceErrorMessageBox",
                details: sDetails, 
                styleClass: this._oComponent.getContentDensityClass(),
                actions: [MessageBox.Action.CLOSE],
                onClose: function() {
                    this._bMessageOpen = false;
                }.bind(this)
            }
        );
    }

если кто-то знает, как восстановить это значение, я буду очень признателен.

Привет.

2 ответа

Решение

Я исправил эту проблему, изменив эту часть кода

if (oParams.response.statusCode !== "404" || (oParams.response.statusCode === 404 && oParams.response.responseText.indexOf(
                "Cannot POST") === 0)) {
            this._showServiceError(oParams.response);
        }
    }, this);

в

if (oParams.response.statusCode !== "404" || (oParams.response.statusCode === 404 && oParams.response.responseText.indexOf(
                    "Cannot POST") === 0)) {
                this._showServiceError($(oParams.response.responseText).find("message").first().text());

            }
        }, this);

Проверьте, есть ли у вас приложение HCM_LRQ_CRE BSP в вашем репозитории SAP ABAP, на самом деле это приложение HCM Leave Request Fiori. Вы можете найти там файл DataManager-dbg.js. Посмотрите на метод parseErrorMessages, он хорошо разбирает сообщения SAP. Вероятно, вы можете использовать его в качестве отправной точки.

Другие вопросы по тегам