Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
sumita_nagpal
Explorer
Introduction

Most of the time we need to create child nodes as per our project requirements. For Example: We may need to add a new table that is linked to a standard object. Thus, in this case in RAP we need to create a new child node for that standard object.

We would create child node in a similar fashion as its parent node. In our case we would take reference of standard sourcing project (C_SourcingProjectTP) and item (C_SourcingProjectItemTP).

I’ll provide you example on how to create a new child node for Sourcing Project Item standard object.

Below are the steps that you need to follow to create a child node:

Step 1. Create all of node related objects:

  1. Create persistence table and all the relevant fields that are needed

  2. Create a draft table for the relevant fields

  3. Create basic view, transactional view, consumption view and metadata








































Object Type Object Name Comments
Persistence table ZTest_CNode
Draft table ZTest_CNode_d Must have all fields from Persistence table +
"%admin": include sych_bdl_draft_admin_inc;
Basic view ZTest_SP_R_CNode The best option is that
field names of Basic view = field names of Persistence table because it allows to avoid writing of mapping (Refer Step 4 below about mapping)
Transactional view ZTest_SP_R_CNodeTP
Consumption view ZTest_SP_C_CNodeTP
Metadata ZTest_SP_C_CNodeTP

 

Step 2. Add a new node to each level of parent node, here we want a new node below the sourcing project item node:























Object Type Object Name Comments
Transactional view R_SourcingProjectItemTP
-> R View Extension (ZR_SourcingProjectItemTP)--> ZTest_SP_R_CNodeTP
Expose the above transactional view(ZTest_SP_R_CNodeTP) in ZR_SourcingProjectItemTP through composition
Consumption view C_SourcingProjectItemTP
-> C view Extension (ZC_SourcingProjectItemTP)


Expose the above composition in ZC_SourcingProjectItemTP along with the below annotation

@ObjectModel.association.reverseAssociation:
'>>@EXPOSE_TARGET@<<'
Metadata C View Metadata Extension (ZC_SourcingProjectItemTP)


Step 3. Define behavior for a new node:


















Object Type Object Name Comments
Transactional BDef. R_SourcingProjectTP
-> Extension R BDEF
---> ZTest_SP_R_CNodeTP
Here you need to define the behavior for the new child node (Determinations, validations, feature control, action etc…)
Consumption BDef. C_SourcingProjectTP
-> Extension C BDEF
---> ZTest_SP_C_CNodeTP
 The behavior for child node needs to be defined at the consumption level as well.

 

Step 4. Mapping between table field names and CDS view field names

You should define a mapping for every field which has different name for Persistent Table and Transactional View:

  mapping for <persistent_table_name> corresponding

  {

    <transactional_view_field_name> = <persistent_table_field_name>;

...

  }

 

Summary

This blog would be helpful when you want to extend any standard object and want to add a custom child node for the same. In case you need to introduce the new node in the form of a table on UI , you can create the table directly from UI and then bind it with this node or it can be achieved via backend annotations as well.

Please refer to the above steps of this blog for creating a new child node, and do reach out to me through comments in case of any questions.

 
7 Comments