on 2025 Feb 10 1:35 PM
I am currently working my way into SAP Cap.
Now I have written a test ui5 page and would like to send an update to the cds service after pressing a button, via Postman this is no problem but in the ui5 controller I just can't get it to work. I have already tried 5 different ways. can someone please help me with a short explanation would be good thanks.
My setup:
Backend: SAP CAP (Node.js)
Frontend: SAPUI5 (XML view)
Model: OData V4 (generated by CAP)
Current code
buttonTimeEnd: async function () {
const oAccount = this.getView().getModel("oAccountData");
const oToLoggedProductionOrderOperation = this.getView().getModel("oToLoggedProductionOrderOperation");
const vView = this.getView();
const vAccountPage_ToolboxSection = vView.byId("AccountPage_ToolboxSection");
const vAccountPage_CurrentOrdersSection = vView.byId("AccountPage_CurrentOrdersSection");
if (!oAccount || !oToLoggedProductionOrderOperation) {
MessageBox.error(this.getResourceBundle().getText("errorLoadingBackgroundData"));
return;
}
const oToLoggedProductionOrderOperationData = oToLoggedProductionOrderOperation.getData();
if (oToLoggedProductionOrderOperationData.controlStatus === 'logged') {
try {
const oModel = this.getView().getModel("modelAccount");
const oOperation = oModel.bindContext("/UpdateLogProductionOrderOperation(...)");
oOperation.setParameter("UUID", oToLoggedProductionOrderOperationData.UUID);
oOperation.setParameter("controlStatus", "waitingSend");
await oOperation.execute().then(() => {
MessageToast.show(this.getResourceBundle().getText("timeRecordingSuccessful"));
// Aktualisiere die lokale Ansicht
oToLoggedProductionOrderOperation.setProperty("/controlStatus", "waitingSend");
// Sektionen aktualisieren
if (vAccountPage_CurrentOrdersSection) vAccountPage_CurrentOrdersSection.setVisible(false);
if (vAccountPage_ToolboxSection) vAccountPage_ToolboxSection.setVisible(true);
}).catch((oError) => {
MessageBox.error(this.getResourceBundle().getText("errorTimeRecording"));
console.error("Execute Error:", oError);
});
} catch (oError) {
MessageBox.error(this.getResourceBundle().getText("errorTimeRecording"));
console.error("Catch Error:", oError);
}
}
},
Request clarification before answering.
User | Count |
---|---|
61 | |
7 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.