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
former_member14709
Contributor
0 Kudos
Hello Sumita,

Thanks for detailed explanation. I have some queries:

  1. In your example, I see you are adding a new node below a custom node ZR_SourcingProjectItemTP, so basically here you are creating a reference to a standard node and then adding a child node to it, but not directly adding a child node to a standard BO, am I getting this right?

  2. Can we extend nodes of any standard BO with this approach or only the ones which have extensibility enabled?


Thanks,

Aman Garg
sumita_nagpal
Explorer
Hello Aman,

Your understanding is correct. I am creating a custom node on the extension of standard BO.

Here I have written the steps to create custom nodes, only for extension enabled objects.

Thanks,

Sumita

 
sankar_bhatta
Participant
0 Kudos
Hi Sumita,

 

thanks for posting this. could you please upload the codes of CDS extensions etc., in a git repository? Also we are trying to add a new field in App "Manage Sourcing Project , I believe the node you are referring to belongs to same app ).  we have successfully added the field by extending the underlying CDS views, but for some reason the field comes as read-only when we create/update sourcing project. I tried feature control option by extending BD for R_SOURCINGPROJECTTP, but no luck. could you give me some hints? we are working with an on-premise system 2021 FP01
sumita_nagpal
Explorer
0 Kudos
Hello Sankara,

Can you be more exact with the problem? You are facing issue with read-only behavior of a field in CDS extension.

If yes, you can refer to the below link for more information.
https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/a5055eef86fa492d99a29b3...

 

Thanks,

Sumita
sankar_bhatta
Participant
0 Kudos
Hi Sumita,

 

Thanks for replying. I am trying to add a custom field to a standard app in product sourcing which is called "Manage Sourcing project". I have followed the approach explained in below link

https://help.sap.com/docs/BTP/923180ddb98240829d935862025004d6/0936aff0be264826a102264fb5b04976.html...

the custom field is now appearing in Sourcing project > under Basic data. But the field is not editable.
sankar_bhatta
Participant
0 Kudos

giving steps what I have followed

  • Added new structure and added a field to include structure SRCGPROJHDR_INCL_EEW_PS

below are the CDS extensions I did

  • first enhanced the E_SourcingProject view

@AbapCatalog.sqlViewAppendName: 'ZESRCPROJH'
@EndUserText.label: 'Extension for CDS E_SOURCINGPROJECT'
extend view E_SourcingProject with ZE_SOURCINGPROJECT {
Persistence.zz_custfield as zz_custfield
}

  •  Added field to root entity view

extend view entity R_SourcingProjectTP with {
_Extension.zz_custfield,
_Extension
}

  • Added field to consumption root view C_SourcingProjectTP

extend view entity C_SourcingProjectTP with {

@UI.identification: [{ position: 50, importance: #HIGH  }]
_SourcingProjectTP._Extension.zz_custfield
}

sankar_bhatta
Participant
0 Kudos
the problem is in the last CDS extension. we should keep_SourcingProjectTP.zz_custfield instead of  _SourcingProjectTP._Extension.zz_custfield