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

Value Help and Table Function not working with CDS

TrattnigS
Explorer
0 Likes
482

Hello, following an approach without table function to see value help in CDS view for QueryBrowser in Fiori:

1)

@AbapCatalog.sqlViewName: 'ZCDSVSOITEST1'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'test for valuehelp'
define view ZCDSV_SALESOI_TEST1 as select from zddxxx
{
plant
}

2) As Cube:

@AbapCatalog.sqlViewName: 'ZCDSVTESTHIST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@Analytics.dataCategory: #CUBE
@EndUserText.label: 'Hisotry'
@ObjectModel.query.implementedBy: 'ABAP:ZCL_VH'
define view ZCDSV_TEST_HIST as select from ZCDSV_SALESOI_TEST1
{
plant
}

3) Query view with simple filter: 

@AbapCatalog.sqlViewName: 'ZCDSVTESTQ'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #CONSUMPTION
@Analytics.query: true
@OData.publish: true
@EndUserText.label: 'q'
define view ZCDSV_TEST_Q as select from ZCDSV_TEST_HIST
{
@Consumption.filter: {selectionType: #SINGLE, multipleSelections: true, mandatory: true}
plant
}

 
So as usual i see the value help and values: 

TrattnigS_0-1742571732834.png

Now the Problem case, I need to use an RANK over function which is possible only in native sql so table function with an abap class. So I define the ZTable: 

@ClientHandling.type: #CLIENT_DEPENDENT
@ClientHandling.algorithm: #SESSION_VARIABLE
@EndUserText.label: 'Test for valuehelp'
define table function ZTABLE_TEST
with parameters @Environment.systemField: #CLIENT    clnt :abap.clnt
returns {
  client : abap.clnt;
  plant : abap.char(4); --char4
}
implemented by method ZCL_VH=>VH;

Then as usual we use amdp and implement the query. For simplicity I query only plant which is sufficient for this example. Abap class:

CLASS zcl_vh DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .
  PUBLIC SECTION.
    INTERFACES if_amdp_marker_hdb.
    CLASS-METHODS:
        VH FOR TABLE FUNCTION ZTABLE_TEST.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_vh IMPLEMENTATION.
    METHOD VH
        BY DATABASE FUNCTION
        FOR HDB
        LANGUAGE SQLSCRIPT
        OPTIONS READ-ONLY
        USING ZCDSVSOITEST1.
           itab_coo1 =
                SELECT
                    '100' as client,
                    plant
                FROM ZCDSVSOITEST1;
         RETURN SELECT * FROM :itab_coo1;
    ENDMETHOD.
ENDCLASS.

Now I want to query the ZTable so we adjust the history cds from before..:

@AbapCatalog.sqlViewName: 'ZCDSVTESTHIST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@Analytics.dataCategory: #CUBE
@EndUserText.label: 'Hisotry'
@ObjectModel.query.implementedBy: 'ABAP:ZCL_VH'
define view ZCDSV_TEST_HIST as select from ZTABLE_TEST(clnt:'100')
{
    plant
}

 

Query view: Here I tried several approaches from associations to creating a search help in the dictionary nothing works. I left all the statement as comments so you can see the approach.

@AbapCatalog.sqlViewName: 'ZCDSVTESTQ'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #CONSUMPTION
@Analytics.query: true
@OData.publish: true
@EndUserText.label: 'q'
define view ZCDSV_TEST_Q as select from ZCDSV_TEST_HIST
association [0..1] to ZZ_BP_VALUEH as _countrytext on $projection.plant = _countrytext.plant

{
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: true, mandatory: true}
   -- @Consumption.valueHelp: '_countrytext'
   -- @Consumption.valueHelpDefinition: [{entity: { name: 'ZCDSV_SALESOI_TEST1', element: 'plant'  }}]
   --  @Consumption.valueHelpDefinition: [{entity: { name: '_countrytext', 
   -- element: 'plant'  }}]
    @Consumption.valueHelpDefinition: [{ entity: {name: 'ZZ_TEST_VH', element: 'plant' } }]
    /*@Consumption.valueHelpDefinition: 
      [{ entity: { name : 'ZCDSV_SALESOI_ TEST1' , element: 'plant' } ,
         additionalBinding: [{ element: 'plant',
                               localConstant: 'plant', usage: #FILTER }]
                               , distinctValues: true
                               }]*/
  --  @ObjectModel.text.association: '_countrytext'
   -- .defaultSearchElement: true
    plant,   
    _countrytext   
}

 

@AbapCatalog.sqlViewName: 'ZZBPVALUEH'
@ObjectModel.dataCategory: #TEXT
@ObjectModel.usageType.dataClass: #CUSTOMIZING
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.sizeCategory: #S
@ObjectModel.supportedCapabilities: [#SQL_DATA_SOURCE, #CDS_MODELING_DATA_SOURCE, #CDS_MODELING_ASSOCIATION_TARGET, #LANGUAGE_DEPENDENT_TEXT]
@Search.searchable: true
@VDM.viewType: #BASIC
@EndUserText.label: 'Value Help View for Business Partner'
define view ZZ_BP_VALUEH as select distinct from zddxxx
{
    @Semantics.text: true 
    @search.defaultSearchElement: true
    key plant
}

 

The result is always the same without value help so i need to know the values beforehand. If I use a cds view as value help association or the dictionary search help.

TrattnigS_1-1742571982064.pngTrattnigS_2-1742571997070.png

Here the search help in the dictionary for which I can do also a test. Below you can see it works.

TrattnigS_3-1742572025830.png

TrattnigS_4-1742572033931.png

I cannot understand, because as soon as I use a table function the information seams to be lost as without it works perfectly. But on the other side the information is there an accessible everything is active (association or dictionary search help). I think it is a matter of putting the right annotations in the query view but i tried so many approaches.
I am very thankful for any help!

 

 

Accepted Solutions (0)

Answers (0)