sap.ui.define([ "sap/m/MessageToast" ], function (MessageToast) { 'use strict'; return { openSpreadsheetUploadDialog: async function (oEvent) { debugger; this.getView().setBusyIndicatorDelay(0); this.getView().setBusy(true); //if (!this.spreadsheetUpload) { this.spreadsheetUpload = await this.getView() .getController() .getOwnerComponent() .createComponent({ usage: "spreadsheetImporter", async: true, componentData: { context: this, standalone: false, createActiveEntity: false, activateDraft: false, showBackendErrorMessages: true, showOptions: true, hidePreview: true, hideSampleData: false, sampleData: [{ partner: "HC00001411", target_oth: "2.5", target_lay: "2.0", target_5s: "4", target_sfi: "1" }], spreadsheetFileName: "Emp_x_KPI_Template.xlsx", i18nModel: this.getView().getModel("i18n"), skipMandatoryFieldCheck: true }, }); this.spreadsheetUpload.attachCheckBeforeRead(function (oEvent) { debugger; const sheetData = oEvent.getParameter("sheetData"); let errorArray = []; let partnerOk = false; let target_othOk = false; let target_layOk = false; for (const [index, row] of sheetData.entries()) { for (const key in row) { if (key === "Business Partner Number[partner]") { partnerOk = true; } if (key === "Audits / Month[target_oth]") { target_othOk = true; } if (key === "Layered Evaluation / Month[target_lay]") { target_layOk = true; } } if (partnerOk === false) { const error = { title: "Business Partner Number is initial", row: index + 2, group: true, ui5type: "Error" }; errorArray.push(error); } if (target_othOk === false) { const error = { title: "Audits / Month is initial", row: index + 2, group: true, ui5type: "Error" }; errorArray.push(error); } if (target_layOk === false) { const error = { title: "Layered Evaluation / Month is initial", row: index + 2, group: true, ui5type: "Error" }; errorArray.push(error); } } oEvent.getSource().addArrayToMessages(errorArray); }, this); this.spreadsheetUpload.attachChangeBeforeCreate(function (oEvent) { let payload = oEvent.getParameter("payload"); oEvent.getSource().setPayload(payload); }, this); this.spreadsheetUpload.attachRequestCompleted(function (oEvent) { const success = oEvent.getParameter("success"); if (success) { console.log("Request Completed"); } else { console.log("Request Failed"); } }, this); this.spreadsheetUpload.openSpreadsheetUploadDialog(); this.getView().setBusy(false); } }; });