Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDS Metadata Tables

matsolin
Explorer
7,411

Hi experts,

I need to figure out where to find metadata about CDS views (DDL) and their corresponding ABAP objects. I thought that the generated ABAP view would contain the same parameters as the CDS view that they are generated from but that is not the case. I have an example (C_PurRequisitionNoTouch from an S4/HANA IDES system) where the CDS defines three parameters but the generated ABAP view (CMMPRNOTOUCH) only lists two ‘Selection Condition’ in the definition in SE11. But when querying the ABAP view all three parameters must be set otherwise there will be a Syntax Error. So somehow I need to find the metadata for the CDS DDL in order to be able to query the ABAP View. The ABAP view metadata I have in ex table DD02V (field’WITH PARAMETERS’) and the Select Conditions are in table DD28S. There is the table RSODPABAPCDSVIEW that links the CDS with the ABAP view and the full CDS DDL can be found in DDDDLSRC. I can of course parse the CDS DDL but I am uncertain how that would work with extended CDS views if those contain multiple ‘layers’ of parameters. Any ideas?

Here is a small program illustrating the issue:

REPORT ZS4H2.
DATA:
  l_date_function(32) TYPE c,
  l_start_date TYPE date,
  l_end_date TYPE date.
DATA:
  t_view TYPE TABLE OF CMMPRNOTOUCH WITH HEADER LINE.

  l_date_function = ''.
  l_start_date = '20160101'.
  l_end_date = '20180101'.

*SELECT * FROM C_PurRequisitionNoTouch( P_DateFunction = @l_date_function , P_StartDate = @l_start_date , P_EndDate = @l_end_date )  
*This works

SELECT * FROM CMMPRNOTOUCH( P_DateFunction = @l_date_function, P_StartDate = @l_start_date , P_EndDate = @l_end_date ) 
*This works

*SELECT * FROM CMMPRNOTOUCH( P_StartDate = @l_start_date , P_EndDate = @l_end_date ) 
*This will not work
  
INTO CORRESPONDING FIELDS OF TABLE @t_view.

IF sy-subrc = 0.
  LOOP AT t_view.
    WRITE: / t_view-PURCHASEREQUISITION,
             t_view-PURCHASEREQUISITIONITEM,
             t_view-SUPPLIER.
  ENDLOOP.
ENDIF.
1 ACCEPTED SOLUTION
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
3,981

This is exactly one of the reasons, why you should not access ABAP managed database objects outside from ABAP.

The representation of a CDS (parameter) view on the DB is an internal affair of the ABAP runtime environment, it is database dependent and it might change from release to release.

See https://blogs.sap.com/2018/04/03/abap-managed-database-objects-and-how-to-access-them/ and https://launchpad.support.sap.com/#/notes/2511210 .

5 REPLIES 5
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
3,982

This is exactly one of the reasons, why you should not access ABAP managed database objects outside from ABAP.

The representation of a CDS (parameter) view on the DB is an internal affair of the ABAP runtime environment, it is database dependent and it might change from release to release.

See https://blogs.sap.com/2018/04/03/abap-managed-database-objects-and-how-to-access-them/ and https://launchpad.support.sap.com/#/notes/2511210 .

Read only

matsolin
Explorer
0 Likes
3,981

Hi Horst, thank you for your answer. Unfortunately I’m still not sure that I understand even after reading the blog and the note. I want to extract CDS view data by calling it from an ABAP program. The limitation of using Open SQL is not a problem. Should I select data from the CDS view or the ABAP view (which one of them is stable over time/releases)? Or none of them? From my example:

  1. The CDS view: SELECT * FROM C_PurRequisitionNoTouch… Is there some other source of metadata other than the definition itself (an ABAP Class or a table(s))?
  2. The ABAP view: SELECT * FROM CMMPRNOTOUCH… Where do I find the metadata for he view so that I can figure out how to query it?
  3. Or, am I totally wrong in my design?

/ Mats

Read only

matsolin
Explorer
0 Likes
3,981

After looking into it some more I believe that it is the generated ABAP view (in my example CMMPRNOTOUCH) I should call from the ABAP program. I also found a table with the parameters (all three) so that issue is solved as well. However, it would be great if you could confirm that this is the right approach you are describing in your blog horst.keller .

/ Mats

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
3,981

No, as documented you should not access the CDS database view CMMPRNOTOUCH but the CDS entity. The CDS database view CMMPRNOTOUCH is only there for technical reasons and should not be accessed at all. The full functionality of Open SQL is only available for accessing the CDS entity.

Read only

0 Likes
3,981

Ok, thanks a lot, I'll build the data extraction by querying the CDS Entity then/ Mats