Skip to Content
Technical Articles
Author's profile photo Alwin van de Put

ABAP Search CDS View Tool (search hierarchically and on fields)

14-7-2023: New functionality added for filtering on fields with field names, data elements and domain names. Also searching on fields without the “hierarchically search” is possible. See scenario “Filter on field name, data element name or domain name” to see how it works.

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.

Scenario: Filter on field name, data element name or domain name

In this scenario we are going to search for a field “Minimum Lot Size” (BSTMI) in table “Plant Data for Material” (MARC).

  • Restart the program ZSCV_SEARCH_CDS_VIEWS, so that you have a clean selection screen.
  • Fill Field Name
  • Press F8.
    It will find in S/4HANA 2022 81 views.
    Those are DDic tables, DDic views, DDic CDS views and Entity CDS views with that name.
    However it won’t find CDS view I_ProductPlantBasic, because the field name is MinimumLotSizeQuantity in that CDS view. So we should search for field name MinimumLotSizeQuantity or we can search for the Data Element Name or Domain Name. The Domain Name is MENG13, so it is too generic. So let’s search on Data Element.
  • Clear Field Name and Fill Data Element Name with BSTMI and press F8.
    Now 158 views are found. Because many more CDS views are found.
  • Now we only want the released CDS views. Push on the selection screen the button ABAP C1 + C2.
  • Press F8.
    Now you see 15 released CDS views which have a field with data element BSTMI.
  • If you want to see only the views which are based on MARC, than set field Root Table / View MARC and press F8.
    Now 12 released CDS views are shown.

    See that for example CDS view A_PRODUCTPLANTMRPAREA is not shown now. That is because field MinimumLotSizeQuantity (BSTMI) is not retrieved from table MARC, but from table MDMA.

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

Use ABAP Git to install the software.

Other search options

Author: Alwin van de Put

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Angelos Chatzigiannakis
      Angelos Chatzigiannakis

      We made a gigantic advance in our project with your program, thanks a million!

      Author's profile photo Marco Paroti
      Marco Paroti

      Hi Alwin

      When activating the CDV views, e.g. ZSCV_ABAPVIEWCHILD, I get the error:
      "UNION" cannot be used in view entities.
      We are on 7.55.

      Author's profile photo Alwin van de Put
      Alwin van de Put
      Blog Post Author

      Hello Marco,

      Thank you for your feedback. My version is 7.5H I will change that view to a DDic CDS View and make a post when it is updated.

      Author's profile photo Alwin van de Put
      Alwin van de Put
      Blog Post Author

      I have changed the mentioned view from an Entity CDS view to a DDic CDS view. Please try it again.

      Author's profile photo Marco Paroti
      Marco Paroti

      Hi Alwin,

      Great service.

      I was now able to install and activate everything.

      Cool tool and thanks a lot, Marco

      Author's profile photo Caroline Rossetti
      Caroline Rossetti

      Hi Alwin,

       

      We are getting the same error as Marco.

      Do you plan on backporting this tool to version 2020/7.55.

      This looks like a great tool that would help us out too.

       

       

      Author's profile photo Alwin van de Put
      Alwin van de Put
      Blog Post Author

      Hello Caroline

      Yes, I will update the repository.

      Author's profile photo Alwin van de Put
      Alwin van de Put
      Blog Post Author

      I have changed the ZSCV_ABAPVIEWCHILD view from an Entity CDS view to a DDic CDS view. Please try it again.

      Author's profile photo Caroline Rossetti
      Caroline Rossetti

      Thank you!  It worked.  Great tool.

      Author's profile photo Amaury VAN ESPEN
      Amaury VAN ESPEN

      Really great shared content !

      Author's profile photo Joao Sousa
      Joao Sousa

      Really needed tool, SAP adopt this in the core product .

      Author's profile photo Gurpreet Jaspal
      Gurpreet Jaspal

      That's very cool. Thanks for your contribution and for sharing this.

      Author's profile photo Florian Schiller
      Florian Schiller

      Hi Alwin,

      i get a error message when i activate the cds-view ZSCV_CdsViewSourceField:
      "Expression type ARITHMETIC not allowed in function SUBSTRING, parameter 3"

      Our current SAP System Version: S/4HANA 2021 (Basis 7.56)

      Author's profile photo Bob Douglas
      Bob Douglas

      I have the same problem, do you know why is this happening Alwin van de Put ? I run a 75G so I was hoping to not have issues caused by the version.

      Author's profile photo Alwin van de Put
      Alwin van de Put
      Blog Post Author

      Hello Florian,

      I have ABAP version 75H (2022 SP level 2).

      I now see that in version 75H it is possible to use a argument (field) in parameter 3 of function substring and in versions below 75H only a literal (value) is permitted.

      I do not have a solution for that problem, so I think I am going to make two versions. One version for >= 75H and one for <= 75G.

      The version  <= 75G won't contain filtering on field names.