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

Code List based on CDS View doesn't show View Entities but only shows Custom Entities

DiegoValdivia
Active Participant
0 Kudos
3,452

Hi guys,

When creating a CDS View with the purpose of using it as a Code List in a Custom Field I found the following:

If I create the CDS view as a View Entity, it's not shown in the "Code List based on CDS View".

This is the code I'm using to create the CDS View (I Released it for Use in Key User Apps (C1 Contract) )

@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Freight Codes'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.dataCategory: #VALUE_HELP
@Search.searchable: true
@ObjectModel.representativeKey: 'FreightCode'

define view entity Y43MM_VH_FreightCode
  as select from y43mm_frgtcode
{
      @search.defaultSearchElement: true
      @search.fuzzinessThreshold: 0.8
      @search.ranking: #LOW
  key freight_code      as FreightCode,
  
      @search.defaultSearchElement: true
      @search.fuzzinessThreshold: 0.8
      @search.ranking: #LOW  
      freight_code_desc as FreightCodeDesc
}

But if I change the CDS View to be a Custom Entity, the view is correctly shown in the "Code List based on CDS View"

@EndUserText.label: 'Freight Codes'
@ObjectModel.dataCategory: #VALUE_HELP
@Search.searchable: true
@ObjectModel.representativeKey: 'FreightCode'
@ObjectModel: {
    query: {
        implementedBy: 'ABAP:Y43TMCL_CE_FREIGHTCODE'
    }
}
define custom entity Y43TM_VH_FREIGHTCODE
{
      @search.defaultSearchElement: true
      @search.fuzzinessThreshold: 0.8
      @search.ranking: #LOW
  key FreightCode: y43tmdt_freight_code;
  
      @search.defaultSearchElement: true
      @search.fuzzinessThreshold: 0.8
      @search.ranking: #LOW  
      FreightCodeDesc: y43tmdt_freight_code_desc;
}

As additional information:

  • This behavior only occurs in S/4HANA Cloud Public edition. If I create a View entity in an On-Premise system 2023, the CDS view is correctly shown in the "Code List based on CDS View"
  • I read the information on the following link Creating a Field of the Type Code List Based on CDS View: Example in point 4 it perfectly says "You can either select a CDS-based view, or you can select a custom entity". So, as per my understanding, it should work ok with View Entities in Cloud as well. So I'm not sure what's going on.

Let me know if you have any information that could help me with this problem.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

DiegoValdivia
Active Participant
0 Kudos

The answer to my original question was given by @georg_wilhelm inside a comment of one of the other answers, his answer was: "currently one can only use Custom Entities as value help views for Key User Custom Fields. You can not use customer created view entities...even if you release them C1 for key users. We are aware of this gap and are already working on that."

Answers (3)

Answers (3)

Karsten_Schaser
Product and Topic Expert
Product and Topic Expert
0 Kudos

Regarding the paging issue:

How to implement paging for a custom entity is described in https://help.sap.com/docs/btp/sap-abap-restful-application-programming-model/requesting-and-setting-...
There the following note is given: "If data is requested, the method set_data must be called. If the total number of records is requested, the method set_total_number_of_records must be called. Otherwise there will be an error during runtime. The io_response->set_data( ) method is only allowed to fill elements listed by io_request->get_requested_elements( ). System may react with a failure or a short dump if these rules aren't followed. In UI scenarios with Fiori Elements the total number of records is always requested by the UI."

Regarding the available CDS views:

The field type "Code List based on CDS View" and also the restrictions regarding available CDS views is explained here: https://help.sap.com/docs/SAP_S4HANA_CLOUD/0f69f8fb28ac4bf48d2b57b9637e81fa/acb2907f362944a5a9e1b5eb...

One can sum up the restrictions as follows: "You can either select a CDS-based view (Custom CDS View/SAP delivered CDS view released according to the C1 contract), or you can select a custom entity."

FabrizioD
Explorer
0 Kudos
Thank you Karsten! I have followed all the steps reported on help.sap.com. I have created the CDS custom entity and the service too. Checking the service I can see the data, but I still cannot find the CDS View into the list, so I cannot use it for my custom field. I cannot undersand why is so complex
DiegoValdivia
Active Participant
0 Kudos

@georg_wilhelmCould you please confirm if value helps based con Custom Entities also limit the number of entries they can retrieve from the Database? I ask you this because my value help is showing only 132 characters even when my table contains 400 entries:

DiegoValdivia_0-1734618861593.png

by checking the Network tab in the browser, I notice the Odata call is sending top=132 by default:

DiegoValdivia_1-1734618948053.png

Thanks in advance.

 

 

DiegoValdivia
Active Participant
0 Kudos

I answer myself.

It seems the paging on the Custom Entity class must be handled in a different way when the caller is a value help. Or at least that's my understanding.

I had to call following method before performing paging:

 

io_response->set_total_number_of_records( LINES( lt_FreightCode_tab ) ).

 

By doing this, the Value Help now shows the correct total number of entries at the top and performs the paging correctly when I scroll down.

Karsten_Schaser
Product and Topic Expert
Product and Topic Expert
Karsten_Schaser
Product and Topic Expert
Product and Topic Expert
0 Kudos
There the following note is given: If data is requested, the method set_data must be called. If the total number of records is requested, the method set_total_number_of_records must be called. Otherwise there will be an error during runtime. The io_response->set_data( ) method is only allowed to fill elements listed by io_request->get_requested_elements( ). System may react with a failure or a short dump if these rules aren't followed. In UI scenarios with Fiori Elements the total number of records is always requested by the UI.
NAVI
Explorer
0 Kudos

Update

Diagnosis

Custom fields of type "Code List based on CDS View" must not reference custom CDS views, which use artefacts defined via ADT development. The key user extensibility concept guarantees lifecycle-stable extensions, which are upgrade-proof. But ADT artefacts are managed by customers and might contain errors which prevent an activation. Therefore, custom fields need to be decoupled from ADT development artefacts to ensure successful lifecycle-events.

System Response

The creation of the custom field is being prevented as long as the select CDS view itself or a view in a lower layer of the view stack, uses artefacts defined via ADT development.



I have same issue. Custom entity comes to list but cds views are not.

I copied one of the listed CDS views (for example C_BOMMaterialVH to ZC_BOMMaterialVH) and gives C1 contract but still not listed.

For second option, I try to create cds view which includes my Z view by using "Custom CDS View" app but it is still not listed.

Because there is a filter "Recommended Data Source". When remove that filter, my custom CDS view is listed. Then new cds view which starts with YY1 is listed custom field option

NAVI_0-1734560263164.png

NAVI_1-1734558798179.png

 

georg_wilhelm
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Navi, you stated "I have same issue. Custom entity comes to list but cds views are not. I copied one of the listed CDS views (for example C_BOMMaterialVH to ZC_BOMMaterialVH) and gives C1 contract but still not listed." This is not a bug...currently one can only use Custom Entities as value help views for Key User Custom Fields. You can not use customer created view entities...even if you release them C1 for key users. We are aware of this gap and are already working on that. Best regards Georg
NAVI
Explorer
0 Kudos

Hello George,

I' m little bit confused.

My requirement is using a table ( which is maintable by customer in custom fiori app ) in custom field as value help. 

  • I try to use Code List, but;
    I can't use cds views in RAP app to take descriptions which is generated by SAP.
    NAVI_0-1734607251556.png

    on the other hand, I have to give authorization for "Custom Field App" to customer maintain to list. But I don' t want to.

  • I can' t use CDS views. Because as you mentioned, they are not listed even C1 contracted.

At least, I have to use custom entity views.

Please let me know, if I' m wrong,

Thanks,

georg_wilhelm
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Navi, my understanding: you are in a S/4HANA Cloud Public Edition system. You want to create a custom field with a value help showing Product data and as description field you want to use the description field of an already existing key user custom field. Correct? And you tried to created your own C1 released developer extensibility CDS view and you want to use this view as value help view for the new key user custom field. Correct? If this is correct then your assumption is correct. In S/4HANA Cloud Public Edition it is not possible to utilize a C1 released developer extensibility CDS view as value help view for a key user custom field. You can use key user Custom CDS views as value help view for a key user custom field...but you can not use a C1 released developer extensibility CDS view as value help view for a key user custom field. Anyway: maybe I still did not fully get your context. Maybe let us continue via email in this case: g.wilhelm@sap.com. Best regards Georg