Searching for the right CDS view can be a time consuming task. A DB table / DDic View or CDS View can have hierarchically more than 8000 related views. DB table MARA has for example 8201 related views in S/4HANA 2022. Searching is also error prone, because searching based on naming does not always lead to the right view.
A good way to search is to find all related CDS views based on DB table, DDic view or CDS view which are directly and indirectly related. This can go up to 15 or more levels deep. So doing this manually by executing where-used list is not doable. Therefor I created the “ABAP Search CDS View Tool” which also can filter the found views.
The following scenarios explain how the tool works.
Scenario: Find all related views of MARC
◉ Start program ZSCV_SEARCH_CDS_VIEWS
◉ Fill “DDic table / view”: MARC
◉ Press F8
◉ The status bar will mention how many Views are found.
◉ The results will show 3 types of Views
◉ DDic Views
◉ DDic CDS Views
See that the DDL Source Name and DDic View Name is filled.
◉ Entity CDS Views
See that the DDic View Name is not filled.
Scenario: Filter for ABAP allowed internal CDS views
Now I only want to see all CDS views which are allowed to be used in ABAP.
◉ Go back to selection screen
◉ Push the button “Internal API (C1)”. Now the field “C1 Release state” will be filled with RELEASED and field “C1 In ABAP allowed” wil be checked.
◉ Push F8.
Now 84 Views are found. Here are some views.
◉ See that the DDic CDS views and Entity CDS views are found.
◉ The views have all C1 RELEASED and have C1 Use in Cloud Platform selected.
◉ Also other annotations are shown like Data Category, VDM View Type, Authorization check, Data Class and Contract Type.
◉ See that some have Contract Type #PUBLIC_LOCAL_API.
Scenario: Filter for #BASIC views
I want to search for the basic views for table MARC.
◉ Go back to selection screen and fill VDM View Type: #BASIC.
◉ Press F8.
Now 13 views are found.
◉ In the description in SE11 we can see that the description of table MARC is “Plant Data for Material”.
So based on the naming the most basic CDS view for MARC is CDS View I_PRODUCTPLANTBASIC.
Scenario: Filter on Public API CDS views
Now I want to search for CDS views which are enabled and released for OData.
◉ Go back to selection screen and clear the VDM View Type.
◉ Push button “Public API (C2)”. Now the filter for the C1 fields are cleared and field “C2 Released state” is filled.
◉ Press F8
Click on the picture to enlarge it.
See that all these CDS views have C2 status RELEASED. And also have Contract Type #PUBLIC_REMOTE_API. Also the view names start with A_ which stands for API.
Scenario: Filter on custom views
I want to know which custom views call directly or indirectly the DB table MARC.
◉ Go back to selection screen and clear the VDM View Type.
◉ Push button “All statuses”, to clear all status fields.
◉ Fill ABAP View with Z*.
◉ Press F8.
Now DDic views (also DDic CDS views) and Entity CDS views starting with Z will be shown.
Scenario: CDS views specified by SAP
For some database tables SAP defined in table ARS_W_API_STATE the relation from the DB table to the CDS view.
◉ Go back to selection screen.
◉ Fill “DDic Table/View” AUFK.
◉ Press button “Successor CDS view”.
See that it finds de DDic name IORDER of DDic CDS view I_ORDER.
◉ Press F8 to find all Views related to the CDS view I_ORDER.
How does the tool work?
DDic tables and DDic views are related in table DD26S. CDS views are related to CDS views and DDic views and tables via table DDLS_RIS_INDEX. I have created some CDS views to create one UNION CDS views for both type of relations. By using a Hierarchy CDS View (ZSCV_AbapViewHier) the HANA database searches hierarchically all the related Views.
CDS views relation table DDLS_RIS_INDEX
DDic CDS Views are related to other views by DD26S and DDLS_RIS_INDEX, because they are activated as DDic View and as CDS View.
DDLS_RIS_INDEX contain however beside the FROM and JOIN also ASSOCIATION relations. This causes an explosion of relations. When I used the DDLS_RIS_INDEX also for DDic CDS Views, than I had these results:
1. MARA: 28.935
2. MARC: 28.400
3. AUFK: 27.137
4. AUFM: 13
5. PROJ: 27.584
6. AUSP: 26.942
The problem is that many tables have relations with for example a view related to MARA and than it also selects all MARA view related views.
For now the search works, because there are not that much Entity CDS views, but in future when SAP might decide to convert DDic CDS Views to Entity CDS Views and for sure will create more and more Entity CDS views. Than the tool should be changed that only the FROM and JOIN will be used, and not the ASSOCIATION.
Please do not use the second option yet, because it will probably result in a memory error. In the upcoming version I changed the technique to use ABAP code instead of a Hierarchy CDS View.
Download and install Open Source code
Download code from GitHub: https://github.com/alwinvandeput/zscv_search_cds_views
No comments:
Post a Comment