cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP CDS to UI5 Smart table. Annotations issue

b_deterd2
Active Contributor
3,097

I created an abap cds view with annotations . SYSTEM = 7.50.


@AbapCatalog.sqlViewName: 'z_cds_test_2'

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #CHECK

@EndUserText.label: 'Test 2 CDS'

@OData.publish: true

define view ZMYFLIGHTS2

   

    as select from spfli

    association [1..1] to scarr as spfli_scarr

    on spfli.carrid = spfli_scarr.carrid

    { 

     

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

      

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

       key spfli.carrid as id,

      

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

       key spfli_scarr.carrname as carrier,

      

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

       key spfli.connid as flight,

      

     

       @EndUserText:{ quickInfo:'Some info22' }

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

       spfli.cityfrom as departure,

      

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

       spfli.cityto as destination

    }

I can see the GW service is connected to a annotation model and the annotation model can be reached through:

.../sap/opu/odata/IWFND/CATALOGSERVICE;v=2/Annotations(TechnicalName='ZMYFLIGHTS2_CDS_VAN',Version='0001')/$value

For the UI5 part i created a simple test app:

Controller


var oModel, oView;

  oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/zmyflights2_cds", true);

  //oModel.setCountSupported(false);

  oView = this.getView();

  oView.setModel(oModel);

View


<smartTable:SmartTable id="mySmartTable"

       entitySet="ZMYFLIGHTS2"

       smartFilterId="smartFilterBar"

       tableType="Table"

       useExportToExcel="true"

       useVariantManagement="false"

       useTablePersonalisation="false"

       header="Flights"

       showRowCount="true"

       enableAutoBinding="true">

  <!-- layout data used to make the table growing but the filter bar fixed -->

  <smartTable:layoutData>

  <FlexItemData growFactor="1"/>

  </smartTable:layoutData> 

  </smartTable:SmartTable>

I UI5 i get an error:

Select at least one column to perform the search

What am I missing here?

Any help will be appreciated.

Regards,

Bert

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member196892
Participant

Hi Bert,

you have to set some initialy visible columns.

in the view on the SmartTable set property initiallyVisibleFields and enumerate some of your columns.

See below example

  1. <smartTable:SmartTable id="mySmartTable"  
  2.        entitySet="ZMYFLIGHTS2"  
  3.        smartFilterId="smartFilterBar"  
  4.        tableType="Table"  
  5.        useExportToExcel="true"  
  6.        initiallyVisibleFields="carrier,flight"
  7.        useVariantManagement="false"  
  8.        useTablePersonalisation="false"  
  9.        header="Flights"  
  10.        showRowCount="true"  
  11.        enableAutoBinding="true"


best regards,

Lucian

UI5_DEV1
Explorer
0 Kudos

Hi, 

you must specify the annotation model when creating the ODataModel.

new ODataModel("/sap/opu/odata/yourServiceName",
                {               annotationURI"/sap/opu/odata/IWFND/catalogservice;v=2/Annotations(TechnicalName='ANNOTATION_NAME',Version='0001')/$value/"
 
ANNOTATION_NAME: You find this name in the SEGW->RuntimeFile (Ends with 'ANNO_MDL'). 
 
 
jamie_cawley
Product and Topic Expert
Product and Topic Expert
0 Kudos

In your annotation at the top of the file try adding

@Search.searchable: true

and then setting a field to be searchable with

@Search.defaultSearchElement: true

spfli.cityto as destination

Regards,

Jamie

SAP - Technology RIG