on 03-11-2019 7:19 PM
We are using setProperty() method to change fields of an existing entity. These changes are collected for a batch submit using the setDeferredGroups() method. If we call submitChanges() later on, only changed fields and the keys are submitted to the backend OData Service. But we need to have all fields of the entity send back for processing in backend. How can that be achived?
This is how we collect changes:
oModel.setDeferredGroups(["myChanges"]);
oModel.setChangeBatchGroups({"*":{batchGroupId:"myChanges", single: false }});
oModel.setProperty(path + "/DepCode1", selectEl.getSelectedKey());
oModel.setProperty(path + "/DepCodeGroup1", "YCSNCS");
Then in a central onSave method the changed data is submitted:
onSave: function(oEvent) {
var that = this;
var successHandler = function(errorEvent) {
sap.m.MessageBox.success("Success", {
title: "Success",
initialFocus: null
});
that.getModel().refresh(true);
};
var errorHandler = function(successEvent) {
sap.m.MessageBox.error("Error!", {
title: "Success",
initialFocus: null
});
};
var oModel = this.getView().getBindingContext().getModel();
if (oModel.hasPendingChanges()) {
oModel.submitChanges({
success: successHandler,
error: errorHandler
});
}
},
But if we check the data of the request in data provider class (/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_PROCESS) in ABAP, we can only see the keys and the changed fields are send to the backend. For further processing of the data we would need also the unchanged fields, otherwise we would have to read the data again from backend tables which would be a massive overhead.
By default, when you call the submitChanges() method of the OData model, the Merge operation is used. The Merge operation sends only the fields that have been changed.
If you want to send all the fields during the SubmitChanges() method, then you need to change the default behavior to Put operation. You can do this in your manifest.json file when you are defining the model.
"": { "dataSource": "mainService", "preload": true, "settings": { "defaultUpdateMethod": "Put", "defaultOperationMode": "Server", "defaultBindingMode": "TwoWay" } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would mark this answer as correct. But put should be capitalize 'PUT'. Otherwise you might run into this issue
by default, the framework will call getentity for you automatically, but I don't know the case when you process through CHANGESET_PROCESS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.