SAP Message type Value Help – CDS Code

Value help CDS code for SAP Message types

CDS – ZI_MessageType

@AbapCatalog.sqlViewName: 'ZIMSGTYP'
@EndUserText.label: 'Message Type'

@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #NOT_REQUIRED

@ObjectModel.resultSet.sizeCategory: #XS

@VDM.viewType: #BASIC

/*+[hideWarning] { "IDS" : [ "CALCULATED_FIELD_CHECK" ]  } */
define view ZI_MessageType
  as select from dd07l
  association [0..*] to ZI_MessageTypeText as _Text 
   on $projection.MessageType = _Text.MessageType
{
      @ObjectModel.text.association: '_Text'
  key cast(LEFT( dd07l.domvalue_l, 1 ) as MSGTYP ) as MessageType,

              _Text
}
where
      dd07l.domname  = 'MSGTYP'
  and dd07l.as4local = 'A'

CDS Text – ZI_MessageTypeText

@AbapCatalog.sqlViewName: 'ZIMSGTYPT'
@EndUserText.label: 'Message Type Text'

@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #NOT_REQUIRED

@VDM.viewType: #BASIC
@ObjectModel.dataCategory: #TEXT

/*+[hideWarning] { "IDS" : [ "KEY_CHECK", "CALCULATED_FIELD_CHECK" ]  } */
define view ZI_MessageTypeText
  as select from dd07t
  association [0..1] to I_Language      as _Language
     on $projection.Language = _Language.Language
  association [1..1] to ZI_MessageType as _MessageType
     on $projection.MessageTypeText = _MessageType.MessageType
{
      @Semantics.language: true
      @ObjectModel.foreignKey.association: '_Language'
  key dd07t.ddlanguage               as Language,
      @ObjectModel.foreignKey.association: '_MessageType'
  key cast(LEFT( dd07t.domvalue_l, 1 ) as  MSGTYP ) as MessageType,
      @Semantics.text:true
      dd07t.ddtext               as MessageTypeText,
      _Language,
      _MessageType
}
where
      dd07t.domname  = 'MSGTYP'
  and dd07t.as4local = 'A'

You can use CDS ZI_MessageType as projection, at field level define projection as foreignKey. This should bring message type text in the list also filter will appear as a dropdown.

define view Z...
   association [1] to ZI_MessageType as _MessageType on 
   $projection.MessageType = _MessageType.MessageType
{
   ..
   @ObjectModel.foreignKey.association: '_MessageType'
   MessageType,
   ..
   _MessageType
}

One Reply to “SAP Message type Value Help – CDS Code

Leave a Reply