Recently I worked with the standard Fiori app HCMFAB_LEAV_MAN. All technical details related to the application are described in the following link My Leave Request (Version 3/Fiori 2.0).
And i faced a strange problem that not occure when using the standard version but happen if we extend the Fiori app.
I extend the controller Creating.controller.js by copying it.,
So i create a new one, CreationCustom.controller.js and i activate the whole source code and tried to create a leaving request without changing any thing on the source code.
When i click Save button i receive this error message Default changeset implementation allows only one operation. which is raised by the standard implementation of the CHANGESET_BEGIN method of my DPC_EXT Class.
What’s Happening ?
I’m sending multiple POST operations on the same change set which is not possible, because when we use Batch request we must process one by one operation.
Of course the first solution that come to my mind is to redefine the standard method and check my it_operation_info content to resolve the problem.
But i decided to go to the caller ( Fiori side ) and check the problem in the source
I searched for the operation called when the save action is triggered
And i analysed the source of the onSendRequest Method on controller.js
In the Method submitLeaveRequest we prepar the batch request and submit changes.
Until now i didn’t find the problem but by reading the v view content in debug i see that im sending two Leave Requests as changed entities so it confirm why on ABAP i have the error. Good.
With this information i undertsand that the problem is coming from the Select Component.
When the first item is added to the view Model ?
After some debug i understand that on onInit Method they add a default value for the first item of the Select Coponent ( Dropdown list ).
And here come my modification of the onAbsenceTypeChange Method. I added resetChanges() when the user select a Request Type from the drpdown list to remove the last View Model and add the new one to be sure that i will send only one Request when i submit my changes
Great!!! with this change i avoid the ABAP exception but when i tried to send directly the first item without changing my Dropdown list Request Type my error is still occured. I thougth to add a blank entry as first line to force the user to make a choice but unfortunately this option is not available with a Select component.
So i take few minutes and i find that it will be more easy to trigger the onAbsenceTypeChange even for the by default selected item. And i find a way by adding line below to _onCreateRouteMatched Method.
With this last change all the scenario is working. Hope my solution can help some one working with this app or facing the same issue. Enjoy!!!