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.