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!
Request clarification before answering.
Hi all,
I consulted SAP Support regarding this issue and wanted to share the outcome in case others run into the same problem.
The key factor was the software component, which in our case was not configured for ABAP Cloud.
If a database table belongs to a package that is assigned to an ABAP Cloud software component, the corresponding XCO APIs can be used for that table without requiring a C1 release contract.
There is another important aspect: if your system contains at least one ABAP Cloud software component, it is also possible to assign a C1 release contract to database tables outside that component. These tables can then also be accessed using the corresponding XCO APIs.
This was the main source of confusion in my case. We had two systems with seemingly identical circumstances, but one contained an ABAP Cloud software component while the other did not. As a result, assigning a C1 contract to a database table was possible in one system but not in the other.
I personally found this behavior quite confusing, especially since other object types can be assigned a C1 contract even when no ABAP Cloud software component exists in the system.
SAP Support confirmed that the documentation will be updated to make the prerequisites for using the XCO APIs clearer.
I hope this helps anyone running into the same issue!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
| User | Count |
|---|---|
| 12 | |
| 7 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.