Skip to Content
Technical Articles
Author's profile photo Subhamoy Bhaumik

Create parametrized custom entity select from dynamic table in S/4 HANA ABAP


During ABAP coding in many occasion we need to create dynamic table. Similar situation can be handled during creation of custom entity by using annotation @ObjectModel.dynamic

Use case:

In SAP S/4HANA create a custom entity that selects data from a dynamic table based on a parameter using the ABAP CDS framework


  • Define a data type for the dynamic table using the ABAP CDS TABLE OF statement.
  • Use the @ObjectModel.dynamic annotation to specify that the table is dynamic.
  • Define the necessary fields for the dynamic table using the ABAP CDS LIKE statement.
  • In the custom entity data model, define a parameter that specifies the name of the dynamic table.
  • In the custom entity data model, define a field using the data type for the dynamic table, and use the @ObjectModel.readOnly annotation to indicate that the field is read-only.

Below Coding technique can be followed ,

@EndUserText.label: 'Test Custom Entity'

define root view entity ZCustomEntity

with parameters p_dynamic_table : abap.dynpalpha

as select from (p_dynamic_table)


key  key_field :,

dynamic_table : @ObjectModel.dynamic TABLE OF ZDynamicType



define type ZDynamicType {

field1 : abap.string,

field2 :,


Summary :

In the example above, the p_dynamic_table parameter specifies the name of the dynamic table to select data from. The custom entity data model includes a field named dynamic_table, which is defined as a dynamic internal table of ZDynamicType. The @ObjectModel.readOnly annotation indicates that the field is read-only, meaning that it cannot be modified through the custom entity.


Hopefully this blog post will help you. I look forward to your comments and feedback.

Thanks for reading this article !


Subhamoy Bhaumik

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Satheesh Sambandamurthy
      Satheesh Sambandamurthy

      Hi Subhamoy,

      Can you please let know from which version of S4 HANA, the above feature is supported.