Property | Use |
Id | This is the key field of the entity => unique for each node (including parent and child) |
ParentId | This field will act as a link on the current child entity node to the parent entity node. In other words, this property will hold the value of key field 'Id' of the parent entity node |
HierLevel | This property will hold the depth of the node. In the sample, we are having two levels only but this can be according to your requirement. For example, 0 => Root node and 1 => Child node |
DrillDownState | This property will determine whether the node will be expanded or collapsed by default on the UI. leaf => Collapsed, i.e. the OData service will not fetch the data of children nodes yet expanded => nodes are expanded on UI and OData will have fetched the data of children nodes |
...
super->define( ).
...
* To create hierarchical CDS
lr_entity = model->get_entity_type( iv_entity_name = 'ZCDS_I_ORDER_PO_HEADERType' ).
IF lr_entity IS BOUND.
lr_property = lr_entity->get_property( iv_property_name = 'ID' ).
lr_annotation = lr_property->/iwbep/if_mgw_odata_annotatabl~create_annotation(
iv_annotation_namespace = /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lr_annotation->add(
iv_key = 'hierarchy-node-for' "/IWBEP/IF_ANA_ODATA_TYPES=>GCS_ANA_ODATA_ANNOTATION_KEY–hierarchy_node_for
iv_value = 'ID' ).
lr_property = lr_entity->get_property( iv_property_name = 'HierLevel' ).
lr_annotation = lr_property->/iwbep/if_mgw_odata_annotatabl~create_annotation(
iv_annotation_namespace = /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lr_annotation->add(
iv_key = 'hierarchy-level-for'"/IWBEP/IF_ANA_ODATA_TYPES=>GCS_ANA_ODATA_ANNOTATION_KEY–hierarchy_node_for
iv_value = 'ID' ).
lr_property = lr_entity->get_property( iv_property_name = 'ParentId' ).
lr_annotation = lr_property->/iwbep/if_mgw_odata_annotatabl~create_annotation(
iv_annotation_namespace = /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lr_annotation->add(
iv_key = 'hierarchy-parent-node-for'
iv_value = 'ID' ).
lr_property = lr_entity->get_property( iv_property_name = 'DrillDownState' ).
lr_annotation = lr_property->/iwbep/if_mgw_odata_annotatabl~create_annotation(
iv_annotation_namespace = /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lr_annotation->add(
iv_key = 'hierarchy-drill-state-for'
iv_value = 'ID' ).
ENDIF.
"sap.ui.generic.app": {
"_version": "1.3.0",
"settings": {},
"pages": {
"ListReport|ZCDS_I_ORDER_PO_HEADER": {
"entitySet": "ZCDS_I_ORDER_PO_HEADER",
"component": {
"name": "sap.suite.ui.generic.template.ListReport",
"list": true,
"settings": {
"smartVariantManagement": true,
"tableType": "TreeTable"
}
},
....
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
7 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |