softshipper
softshipper

Reputation: 34099

Why do the selection fields not appear?

I've created a CDS view with metadata allow extension as following:

@AbapCatalog.sqlViewName: 'ZAMCCLASSSEL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Classification selection'
@VDM.viewType: #CONSUMPTION 
@Metadata.allowExtensions: true

define view ZAM_C_CLASS_SEL
  as select from ZAM_I_CLASS_SEL
{
  key InternalClass,
      ClassType,
      ClassNum,
      _ClassKeyword,
      _ClassType
}

the composite view:

@AbapCatalog.sqlViewName: 'ZAMICLASSSEL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Classification selection'
@VDM.viewType: #COMPOSITE

define view ZAM_I_CLASS_SEL
  as select from ZAM_I_CLASS_HEAD
  association [1..1] to ZAM_I_CLASSTYPE   as _ClassType    on $projection.ClassType = _ClassType.ClassType
  association [1..1] to ZAM_I_CLASS_KEYWS as _ClassKeyword on $projection.InternalClass = _ClassKeyword.InternalClass
{
      @ObjectModel.foreignKey.association: '_ClassKeyword'
  key InternalClass,
      @ObjectModel.foreignKey.association: '_ClassType'
      ClassType,
      ClassNum,
      ValidFrom,
      ValidUntil,
      _ClassType,
      _ClassKeyword
}

and the meta data extension:

@Metadata.layer: #CORE
annotate view ZAM_C_CLASS_SEL with
{

  @UI.hidden: true
  InternalClass;
  @UI.selectionField: [{position: 10}]
  ClassType;
  @UI.selectionField: [{position: 20}]
  ClassNum;

}

The smartfilterbar should show the both fields ClassType and ClassNum as selection fields on the screen:

<mvc:View controllerName="ch.mindustrie.FIORI_ELE_SELECTION.controller.Selection" xmlns:mvc="sap.ui.core.mvc"
    xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" displayBlock="true" xmlns="sap.m">
    <Shell id="shell">
        <App id="app">
            <pages>
                <Page>
                    <smartFilterBar:SmartFilterBar id="smartFilterBar" persistencyKey="UniqueAndStablePersistencyKey" entitySet="ZAM_C_CLASS_SEL"></smartFilterBar:SmartFilterBar>
                </Page>
            </pages>
        </App>
    </Shell>
</mvc:View>  

but instead I've got an empty smartfilterbar:

enter image description here

clicking on Filters button and it shows:

enter image description here

That it means, the both fields are available but maybe an option is missing to set on the smartfilterbar control.

Update
I've figured out, that when I change meta extension as following:

@Metadata.layer: #CORE
annotate view ZAM_C_CLASS_SEL with
{
  @UI.selectionField: [{position: 20}]
  @Consumption.filter : { mandatory: true}
  ClassType;
  @UI.selectionField: [{position: 10}]
  @Consumption.filter : { mandatory: true}
  ClassNum;

}  

The selection fields will be shown.

Upvotes: 0

Views: 1139

Answers (1)

Suncatcher
Suncatcher

Reputation: 10621

Putting the answer from OP here for better searchability on SO.

When changing meta extension as following the selection fields will be shown:

@Metadata.layer: #CORE
annotate view ZAM_C_CLASS_SEL with
{
  @UI.selectionField: [{position: 20}]
  @Consumption.filter : { mandatory: true}
  ClassType;
  @UI.selectionField: [{position: 10}]
  @Consumption.filter : { mandatory: true}
  ClassNum;

} 

Upvotes: 0

Related Questions