cancel
Showing results for 
Search instead for 
Did you mean: 

Handling of Create/Update/Delete from Association/Child tables when using Building Blocks

0 Kudos

In the UI5 Application which was built using the building blocks(FPM). I wanted to understand how this scenario can be achieved. Assume we have a scenario, say sales order header and sales order item. First i display the sales order header in the list report, and when i click on the create button, a new create request is sent with ( SalesOrder('0') ) and navigate to the second page which is a custom page. Using the Field Group, i have displayed a forms to fill few header information and I have placed a list control to add the items.

Now initially, the context that was created and navigated when clicking on the Create button has the following properties.

  • IsActiveEntity - false
  • IsDraftEntity - true
  • HasActiveEntity - false.

Later, i made some changes to the field, and then patch request are triggered automatically. To active the entry i triggered a save request to the backend using this.editFlow.saveDocument();

After this function was executed, the context properties is changed as follows.

  • IsActiveEntity - true
  • HasActiveEntity - true
  • IsDraftEntity - false

Now after i click on Edit again, i execute the method this.editFlow.editDocument(oActiveContext). This triggers me a request to /SalesOrderHeader(ID='', isActiveEntity=true) with the payload { preserveChanges: true } and then a new context was created with the /SalesOrder(ID='', isActiveEntity=false). Now on this context which has active entity as false, when i modify the values of the fields and submits again, i am able to save the data. Until this scenario, it is working fine for me.

Now, i am trying to add a new item, in the item table. Though the context of the view has changed from IsActiveEntity true to false, the list that display the items is still bound to IsActiveEntity = true. When i click on create button , i am calling listBinding.create() to create a new context for the table. I am not using this.editFlow.createDocument() as this navigating to the new page and i don't want to do that. Also the Inline is only working for mdc table/ or atleast that is what i understood from the debugging.

Now for the new context that is created for the items , i am unable to save this entry. If i refresh the page and then go into edit mode, the items table is somehow changed to isActiveEntity false and the save of the Items works.

When i continuously work between edit and save, i ran into an situation where a new items is created on the active context and i am not able to proceed further unless the page is reloaded. in some cases i even end with a scenario where i am not able to work on the entity anymore because when i try to save, i get a message, draft changes exists and refresh the change to proceed. when i refresh the page i am still not able to save them.

I know this may not be a lot of information that explains the problem i am facing. What i wanted to know is how do i use this editFlow api. If someone can clarify on the edit flow api, then it would be a lot help to me.

https://sapui5.hana.ondemand.com/#/api/sap.fe.core.controllerextensions.EditFlow

editFlow.createDocument() -> creates a new context

editFlow.saveDocument() -> submit the changes to the service

editFlow.editDocument() -> create an isActiveEntity false

editFlow.cancelDocument() -> cancel the active entity

editFlow.applyDocument() -> apply the new context back to the table.

My knowledge is only limited to the one line information about these methods of the API.

Can someone clarify more on these API, one how these has to be used when working with the scenario that involves parent/child relationship. Pointing to some sample codes to an application built using FPM would be blessing to me.

And thanks for your patience to read through till end to help me out. Appreciate it a lot.

Thanks & Regards,
Arun K

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

If someone comes across the same problem, the following code fixed the issue for me. Adding $$ownRequest to the binding solved the issue i was facing.

<Table
                id="idBookingTable"
                items="{
                    parameters : {
                        $$ownRequest : true
                    },
                    path: 'to_Booking'
                }"
            >   
nicolas_lunet
Employee
Employee
0 Kudos

Hello Arun,

Maybe the first question to answer is why the standard Object Page is not an option for you ?

The second one then would be, whether or not you are doing something special with the context for the table or the one that is returned by the editFlow.

What you describe should work so it might just be due to some specific coding that would prevent this.

If you have a sample app somewhere we could check that would be helpful !

Regards

Nicolas

0 Kudos

Hi Nicolas,

Thanks for responding. I will prepare a sample code and paste it over here with my problem.

The object page is not an option, as the layout that i am trying to build is bit more complex with lots of side panels. Also in my case when i click on edit, all the entries of the tables needs to go into edit mode.

Regards,
Arun K

0 Kudos

Hi Nicholas,

Please find the git repository. In the issues tab, i have tried to explain the issue in detail, please take a look and let me know if this feature is supported in the FPM. Using the createDocument of the editFlow is navigation to the new view, and the inline seems to be only working with the macros table. i don't want either of them as i am trying to build a custom panel layout for each item. hence in this example i have given an responsive table.

https://github.com/arunkrishnamoorthy/cap-draft-enabled/issues/2

Regards,

Arun K

mariusfreitag
Product and Topic Expert
Product and Topic Expert
0 Kudos

Please also refer to https://answers.sap.com/comments/14008543/view.html, where I just responded to this question.