cancel
Showing results for 
Search instead for 
Did you mean: 

RAP: Creating a child entity with 'create by association' for an existing root entity fails

kheba
Discoverer
0 Kudos

Hello dear SAP community!

I would like to create an action in my RAP model that creates a child entity with the keys plant, material number and workcenter for an existing root with the keys plant and material number. The work centre is specified by the user in a dialogue window. The action is located on the object page of the root node.

If I click on the action and enter a work centre, I do not encounter an error but end up with an empty object page. A table entry with the new child is also created, but as soon as I click on the entry in the table in the app, the message 'The requested data was not found' is displayed.

Below are the corresponding screenshots of the code. Thanks in advance 🥳


Muthu_raja
Active Participant
0 Kudos

Hello Kim,

why action specifically used here ?

I guess we can use CBA method. Have you tried ?

kheba
Discoverer
0 Kudos

Hey,

the action will be expanded later with additional functionalities. The crucial point is that creating a child entity with an existing parent, outside the action, did not work with a report either:

SamAriekela
Explorer
0 Kudos
Hi Kheba, Were you able to solve this? Thanks!
patrick_winkler
Product and Topic Expert
Product and Topic Expert
0 Kudos
I would recommend to define the action as factory action.
SamAriekela
Explorer
0 Kudos

Thanks Patrick, I am trying to add this factory function to a child node. Will it be possible to get the parents keys in this function? Similar question is asked here:

https://community.sap.com/t5/technology-q-a/static-factory-action-for-child-nodes-no-access-to-paren...

View Entire Topic
SamAriekela
Explorer
0 Kudos

Hi Patrick,  Very similar to your GIF but in my case , I need to create multiple child entities. I ended up using your initial suggestion of  static factory action in main page. It worked well . But I am getting below error. I am using Odata V4 and this error seems to be intermittent.  I see my header and child entities in mapped table after create by association fine. I am being navigated to the object page but only see key values of the header and nothing else.

SamAriekela_1-1713049436961.png

 

 I followed this while creating the child entities:

 

https://help.sap.com/docs/abap-cloud/abap-rap/modify#loio9000a42dcd604a7799527cbb00bc4a69__create_ex...

 

Can you tell what the issue might be. Thanks again for your time!

patrick_winkler
Product and Topic Expert
Product and Topic Expert
0 Kudos
Remote diagnosis is difficult. I haven't seen that error yet. Double check whether you use %tky and %is_draft correctly in all places. If you have character-like key fields, try to create a root entity and then create child entities with uppercase keys to ensure that the issue is not case-sensitivity.
SamAriekela
Explorer
0 Kudos
Hi Patrick, After spending a lot of time debugging, this morning I found out the issue was indeed due lower case key value . I hope this is documented somewhere as I couldn't find anywhere. Really appreciate your inputs. Thanks!