on 2023 Nov 23 11:40 AM
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 🥳
To add an action to the object page header of entity A to create a child entity B, add the following to the behavior definition of entity A.
factory action CreateChild parameter ZD_CreateChildP [1..*] { default function GetDefaultsForCreateChild ; }
side effects { action CreateChild affects $self; }
To add the action to the object page use the following annotation for entity A:
@UI.identification: [ {
position: 1
},{
type: #FOR_ACTION,
dataAction: 'CreateChild',
label: 'Create Child'
} ]
Example action implementation:
METHOD CreateChild.
MODIFY ENTITY IN LOCAL MODE ZI_Cubco4
CREATE BY \_Cubco4Child
AUTO FILL CID
FIELDS ( ParentId ChildId ) WITH VALUE #( FOR key IN keys (
%is_draft = if_abap_behv=>mk-on
id = key-Id
%target = VALUE #(
( %is_draft = if_abap_behv=>mk-on
ParentId = key-Id
ChildId = key-%param-Id )
) ) )
REPORTED reported FAILED failed MAPPED mapped.
ENDMETHOD.
Defaulting: https://community.sap.com/t5/technology-blogs-by-members/abap-rap-defaulting-action-parameters-with-...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Patrick,
wow, thanks for the super fast response and for the provided snippets!!
It works like a charm. Those were the issues why it didn't work for me:
Thanks again for your awesome support and have a nice day!
Daniel
User | Count |
---|---|
71 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.