Wednesday, June 3, 2026

RAP 3: Text and Text Element in Same Entity

  • In this post will Show the Text and Text element in Same Entity (Airline  Code and Airline Name should be display in single line). 
  • Step 1: Create one CDS view name which contain Airline ID and Airline Name
        
    
    • Add Annotation in in the CDS View as show above
    • CDS view Code:
    • @AbapCatalog.viewEnhancementCategory: [#NONE]

      @AccessControl.authorizationCheck: #NOT_REQUIRED

      @EndUserText.label: 'Airline Detail'

      @Metadata.ignorePropagatedAnnotations: true

      @ObjectModel.dataCategory: #TEXT

      define view entity ZI_AIRLINE_DETAIL

      as select from /dmo/carrier

      {

      key carrier_id as CarrierId,

      @Semantics.text: true

      name as AirlineName

      }

  • Step 2: Join Step 1 CDS View with Flight Detail Interface view using Association and call the  AirlineName field in Flight Detail Interface view also expose the Association.
    • Flight Detail Interface View CDS Code:
    • @AbapCatalog.viewEnhancementCategory: [#NONE]

      @AccessControl.authorizationCheck: #NOT_REQUIRED

      @EndUserText.label: 'Basic Inte view for Flight Connection'

      @Metadata.ignorePropagatedAnnotations: true

      define root view entity ZI_CONNECTION_R

      as select from /dmo/connection

      composition [0..*] of ZI_FLIGHT_INFORMATION_R as _Flight

      association [1] to ZI_AIRLINE_DETAIL as _Airline on $projection.CarrierId = _Airline.CarrierId

      {

      key carrier_id as CarrierId,

      key connection_id as ConnectionId,

      airport_from_id as AirportFromId,

      airport_to_id as AirportToId,

      departure_time as DepartureTime,

      arrival_time as ArrivalTime,

      @Semantics.quantity.unitOfMeasure: 'DistanceUnit'

      distance as Distance,

      distance_unit as DistanceUnit,

      _Airline.AirlineName as AirlineName,

      _Flight,

      _Airline

      }

  • Step 3: Open Flight Detail Projection view(Main ROOT CDS View) and Add ObjectModel  Annotation and Expose Airline CDS View as show in below:
        
    • Projection View Code:
    • @AccessControl.authorizationCheck: #NOT_REQUIRED

      @EndUserText.label: 'Consuption view for Flight connection'

      @Metadata.ignorePropagatedAnnotations: true

      @Metadata.allowExtensions: true

      define root view entity ZC_CONNECTION_R

      as projection on ZI_CONNECTION_R

      {

      @ObjectModel.text.element: [ 'AirlineName' ]

      key CarrierId,

      key ConnectionId,

      AirportFromId,

      AirportToId,

      DepartureTime,

      ArrivalTime,

      @Semantics.quantity.unitOfMeasure: 'DistanceUnit'

      Distance,

      DistanceUnit,

      AirlineName,

      _Airline,

      _Flight : redirected to composition child ZC_FLIGHT_INFORMATION_R

      }       

  • Step 4: In Flight detail projection extension view write the  UI annotation as show in Below:
        

    • Projection View Metadata Extension View code:
    • @Metadata.layer: #CORE

      @UI.headerInfo: { typeName: 'Flight Detail',

      typeNamePlural: 'Flight Detail'}

      @Search.searchable: true

      annotate entity ZC_CONNECTION_R with

      {

      @UI.facet: [{ id: 'FlightConnection',

      purpose: #STANDARD,

      position: 10,

      label: 'Flight Connection',

      type: #IDENTIFICATION_REFERENCE },

      { id: 'FlightInfo',

      purpose: #STANDARD,

      position: 20,

      label: 'Flight Information',

      type: #LINEITEM_REFERENCE,

      targetElement: '_Flight' } ]

      @UI.selectionField: [{position: 10 }]

      @UI.lineItem: [{ position: 10, label: 'Airline ID' }]

      @UI.identification: [{ position: 10 }]

      @UI.textArrangement: #TEXT_FIRST

      @Search.defaultSearchElement: true

      @Consumption.valueHelpDefinition: [{ entity: { name: 'ZI_AIRLINE_VH',

      element: 'CarrierId' } }]

      CarrierId;

      @Search.defaultSearchElement: true

      @UI.selectionField: [{position: 20 }]

      @UI.lineItem: [{ position: 20, label: 'Flight ID' }]

      @UI.identification: [{ position: 20 }]

      ConnectionId;


      @UI.selectionField: [{position: 30 }]

      @UI.lineItem: [{ position: 30, label: 'Departure From' }]

      @UI.identification: [{ position: 30 }]

      @Search.defaultSearchElement: true

      @Consumption.valueHelpDefinition: [{ entity: { name: 'ZI_AIRLINE_VALUE_HELP',

      element: 'AirportId' } }]

      AirportFromId;


      @UI.selectionField: [{position: 40 }]

      @UI.lineItem: [{ position: 40, label: 'Destination To' }]

      @UI.identification: [{ position: 40 }]

      @Search.defaultSearchElement: true

      @Consumption.valueHelpDefinition: [{ entity: { name: 'ZI_AIRLINE_VALUE_HELP',

      element: 'AirportId' } }]

      AirportToId;


      @UI.lineItem: [{ position: 50, label: 'Departure Time' }]

      @UI.identification: [{ position: 50 }]

      DepartureTime;


      @UI.lineItem: [{ position: 60, label: 'Arrival Time' }]

      @UI.identification: [{ position: 60 }]

      ArrivalTime;


      @UI.lineItem: [{ position: 70, label: 'Distance' }]

      @UI.identification: [{ position: 70 }]

      Distance;


      @UI.hidden: true

      DistanceUnit;

      @Search.defaultSearchElement: true

      @Search.fuzzinessThreshold: 0.8

      @UI.hidden: true

      AirlineName;

      }

  • Step 5: Output:


No comments:

Post a Comment

RAP8: Early numbering

In this post will show you how to use early numbering . Step 1: Add early numbering key word in interface behavior definition and activate b...