CDS - Dynamic Semantic Navigation

👋 Hello Everyone!

Dynamic Semantic Navigation in CDS

I recently encountered a scenario where I needed to navigate to different apps based on the type of a technical object — Functional Location or Equipment.

Since CDS doesn’t support dynamic semantic object/action assignment, I implemented a workaround by grouping two fields into a single column, each configured with its own semantic object and action. Based on the object type, I conditionally hide one of the fields.

For example, if the object type is Equipment, the column shows a link that navigates to the Equipment app. If it’s Functional Location, it displays a link to the Functional Location app.

Below is the CDS logic that enables this dynamic navigation:

@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity ZR_TechnicalObject
  as select from I_TechnicalObject
{
  key TechnicalObject,
  key TechObjIsEquiporFuncnlloc,

  @UI.lineItem: [{ position: 10, 
  				   label: 'Technical Object', 
                   qualifier: 'Structure', 
                   type: #AS_FIELDGROUP, 
                   valueQualifier: 'TechnicalObject' }]
  @ObjectModel.text.element: ['TechnicalObjectDescription']
  @UI.fieldGroup: [{ qualifier: 'TechnicalObject', 
  					 semanticObject: 'MaintenanceObject', 
                     semanticObjectAction: 'displayEquipment', 
                     type: #WITH_INTENT_BASED_NAVIGATION, 
                     hidden: #(HideEQUI) }]
  Equipment,

  @ObjectModel.text.element: ['TechnicalObjectDescription']
  @UI.fieldGroup: [{ qualifier: 'TechnicalObject', 
  					 semanticObject: 'MaintenanceObject', 
                     semanticObjectAction: 'displayFunctionalLoc', 
                     type: #WITH_INTENT_BASED_NAVIGATION, 
                     hidden: #(HideFL) }]
  FunctionalLocation,

  @UI.lineItem: [{ position: 20, qualifier: 'Structure' }]
  TechnicalObjectDescription,

  case when TechObjIsEquiporFuncnlloc = 'EAMS_EQUI' 
  	   then cast('' as abap_boolean) 
       else cast('X' as abap_boolean) end as HideFL,
       
  case when TechObjIsEquiporFuncnlloc = 'EAMS_FL' 
       then cast('X' as abap_boolean) 
       else cast('' as abap_boolean) end as HideEQUI
}

This workaround allows dynamic navigation while keeping your UI clean and flexible.

Comments

Popular posts from this blog

Fiori URL Generation and Navigation Using CL_LSAPI_MANAGER

RAP - Real Time UI Updates Using Event-Driven Side Effects

ABAP - Create CSV Files Easily Using CL_CSV_FACTORY