cancel
Showing results for 
Search instead for 
Did you mean: 

XCO framework expects C1-released database table

11-04-2026 4:20 PM
Saftladen Discoverer
168 views 7 comments Go to solution
Subscribe

Hi SAP-Community,

I am currently very desperate, and I count with your help.

In the ABAP Cloud context I am trying to get the information dynamically, if a field of a database table is a key field.

The relevant RTTI/RTTS objects are forbidden in the ABAP Cloud scope, so now I'm looking at the XCO framework.

Specifically, I try to do something like this (this is copied from the SAP documentation):

" Content handle for the field KEY_FIELD of database table ZMY_DBT.
DATA(lo_field_content) = xco_cp_abap_dictionary=>database_table( 'ZMY_DBT'
  )->field( 'KEY_FIELD'
  )->content( ).
" Get the complete content (i.e. all the available attributes of the field)
" as a structure of all attributes.
DATA(ls_field_content) = lo_field_content->get( ).
DATA(lv_key_indicator) = lo_field_content->get_key_indicator( ).

The problem is that when I'm trying to get the content (line 7), I get a CX_XCO_NEWS_EXCEPTION "Database table ZMY_DBT does not exist.

After some debugging, I found out, that the framework expects that ZMY_DBT is C1-released. But I cannot release database tables with C1.

This seems highly contradictory.

Did I find a bug or am I missing something?

What are alternative solutions to dynamically get the key indicator of a database table field (without creating a CDS View)? 

Thank you very much in advance!

View Entire Topic
Sandra_Rossi
Active Contributor

I guess it's a bug because Read APIs | XCO Library | SAP Help Portal contains an example for database table which is exactly yours (XCO_CP_ABAP_DICTIONARY=>DATABASE_TABLE):

" Content handle for the field KEY_FIELD of database table ZMY_DBT.
DATA(lo_field_content) = xco_cp_abap_dictionary=>database_table( 'ZMY_DBT'
  )->field( 'KEY_FIELD'
  )->content( ).
" Get the complete content (i.e. all the available attributes of the field)
" as a structure of all attributes.
DATA(ls_field_content) = lo_field_content->get( ).
" Get each attribute individually.
DATA(lv_short_description) = lo_field_content->get_short_description( ).
DATA(lv_key_indicator) = lo_field_content->get_key_indicator( ).
DATA(lv_not_null) = lo_field_content->get_not_null( ).
DATA(lo_type) = lo_field_content->get_type( ).
DATA(lv_language_indicator) = lo_field_content->get_language_indicator( ).
DATA(ls_currency_quantity) = lo_field_content->get_currency_quantity( ).

and there's no standard SAP database table which may be queried based on this SELECT FROM ARS_W_API_STATE which returns nothing:

select ars_w_api_state.object_id
from ars_w_api_state, dd02l
where ars_w_api_state.object_id = dd02l.tabname
  and ars_w_api_state.object_type = 'TABL'
  AND ars_w_api_state.COMPATIBILITY_CONTRACT = 'C1'
  AND ars_w_api_state.release_state in ('RELEASED','DEPRECATED')
  AND ars_w_api_state.USE_IN_SAP_CLOUD_PLATFORM = 'X'
  and dd02l.tabclass = 'TRANSP'

The query is based on the filters defined in the CDS view ARS_APIS_RELEASED_FOR_C1_SCP.

The best thing is that you contact SAP Support.

Sandra

NB: tests done with ABAP 7.58 SP 1 ON-PREMISE. For information, I did a test with a C1-released structure (XCO_CP_ABAP_DICTIONARY=>STRUCTURE and method COMPONENT), it works:

TRY.
    DATA(lo_field_content) = xco_cp_abap_dictionary=>structure( 'ZMYSTRUCTURE'
      )->component( 'MSGID'
      )->content( ).
    DATA(ls_field_content) = lo_field_content->get( ).
  CATCH cx_root INTO DATA(error).
    DATA(text) = error->get_text( ).
ENDTRY.

 

Saftladen
Discoverer
0 Likes
Thank you for your clarification! I will contact SAP Support immediately. One interesting thing I found is, that I can release database tables with C1 in one SAP system we have, because it does not have the latest SAP Notes implemented yet. Of course this is not intended. But after it has C1 assigned, the XCO framework accepts it and returns the key indicator as expected. So the only problem seems to be the contradicting C1 check.
Sandra_Rossi
Active Contributor
0 Likes
Thanks. What is the ABAP version and SP of that system?
Saftladen
Discoverer
Both systems are 2023 FPS02 ON PREMISE systems, have SAP_BASIS 758 SP2 and SAP_ABA 751 SP2. I also compared SAP Notes. The system where you cannot assign C1-contracts to database tables has the following notes: 3507814, 3525807, 3540445. For SAP systems without these notes, it seems like you could just assign C1-contracts to database tables and use the XCO framework without problems. But this does not look like the intended way. I issued an SAP Support ticket. I will keep you up to date.
Sandra_Rossi
Active Contributor

Thanks. These SAP notes refer to ATC/Code Inspector only, I don't think they prevent C1. In my S/4HANA 2023 FPS 01 / ABAP 7.58 SP 1 system), without these SAP notes, I can't assign C1 contract to tables. Let's see what SAP Support says. NB: the 3 notes fix the two Code Inspector classes CL_CLS_CI_CHECK_ENVIRONMENT and CL_CLS_CI_CHECK_E_ONPR_CLOUDIF.