The other day we were asked to create a simple tool which will help all to find the CDS View based on the tables they are hitting or the name of the view. The idea was to check if there are any CDS already provided by SAP or already created by some other team members so that there is no repetition of efforts. We know we can try to do the same using where-used list. But the where-used list returns too many information.
Let us see how our tool looks like.
Let us try to find, how may CDS Views uses sales order header table VBAK as the base.
In our system, there are 160 CDS Views which uses sales order header table VBAK.
Let us see the CDS names. The standard view identification helps in SAP Analytic Cloud developments.
When we click the CDS View, it takes to Data Dictionary T-Code SE11.
Announcement
We are starting a new Instructor-Led Paid Training on Advanced ABAP CDS with SAP Fiori Elements. This will be 1 hour daily on working days from 7:30 AM to 8:30 AM IST starting 15th of June 2020. Please register using this link and we will share more details soon.
Our team is using this simple tool extensively. It helps us to find all the standard and custom CDS Views for any given table or just table name description. And our functional and technical team members are really finding it useful and happy about it. 🙂
We have developed this tool to be used only in our Development system. So, we have taken the liberty to not follow all naming conventions and it is not quality review ready. But, it does the work we were expecting for.
The three tables which do the trick are – DDLDEPENDENCY (DD: Objects in a DDL Source), DD25T (Short Texts for Views and Lock Objects) and DD26S (Base tables and foreign key relationships for a view).
If you are not too picky about the quality of the test programs, you may copy the below code snippet and use this CDS Finder Tool in your development system.
REPORT ZSAPYARD_CDS_FINDER.
TABLES: ddldependency,dd25t,dd26s.
DATA: gt_25t TYPE STANDARD TABLE OF dd25t,
gs_25t TYPE dd25t.
CONSTANTS: gc_true TYPE sap_bool VALUE 'X',
gc_false TYPE sap_bool VALUE ' '.
* Deferred Class Definition
CLASS lcl_handle_events DEFINITION DEFERRED.
DATA: gt_outtab TYPE STANDARD TABLE OF alv_t_t2.
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_container TYPE REF TO cl_gui_custom_container.
*... object for handling the events of cl_salv_table
DATA: gr_events TYPE REF TO lcl_handle_events.
DATA: g_okcode TYPE syucomm.
DATA: it_bdcdata TYPE bdcdata OCCURS 0 WITH HEADER LINE .
DATA:wa_bdcdata TYPE bdcdata .
* Event Handler Class Definition
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS .
* Event Handler Class Implementation
CLASS lcl_handle_events IMPLEMENTATION.
* On Click Method
METHOD on_link_click.
READ TABLE gt_25t INTO DATA(ls_25t) INDEX row.
PERFORM bdc_dynpro USING 'SAPLSD_ENTRY' '1000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RSRD1-TBMA_VAL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=WB_DISPLAY'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=WB_DISPLAY'.
PERFORM bdc_field USING 'RSRD1-TBMA'
'X'.
PERFORM bdc_field USING 'RSRD1-TBMA_VAL'
ls_25t-viewname.
* Navigate to Data Dictionary
CALL TRANSACTION 'SE11' USING it_bdcdata
MODE 'E'
UPDATE 'A' .
CLEAR:it_bdcdata,it_bdcdata[].
ENDMETHOD.
ENDCLASS.
* Selection Screen
SELECT-OPTIONS: s_view FOR dd25t-ddtext NO INTERVALS ,
s_tab FOR dd26s-tabname NO INTERVALS.
* At Selection Screen
AT SELECTION-SCREEN.
* Start of Selection
START-OF-SELECTION.
* Pull the data from the db tables
SELECT
a~viewname,
ddtext,
objecttype
FROM dd25t AS a INNER JOIN ddldependency AS b
ON a~viewname = b~objectname
INNER JOIN dd26s AS c
ON a~viewname = c~viewname
INTO TABLE @DATA(lt_final)
WHERE a~ddlanguage = 'E' AND
a~ddtext IN @s_view AND
c~tabname IN @s_tab.
LOOP AT lt_final INTO DATA(ls_final).
MOVE-CORRESPONDING ls_final TO gs_25t .
APPEND gs_25t TO gt_25t.
CLEAR:gs_25t.
ENDLOOP.
SORT gt_25t BY viewname ASCENDING.
DELETE ADJACENT DUPLICATES FROM gt_25t COMPARING viewname.
DESCRIBE TABLE gt_25t LINES DATA(l_tabix).
DATA: l_count TYPE c LENGTH 7.
l_count = l_tabix.
CONCATENATE 'Total no. of CDS found' l_count INTO DATA(msg).
MESSAGE msg TYPE 'I'.
* Call Factory Method
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_25t[].
DATA: lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( gc_true ).
lr_column ?= lr_columns->get_column( 'VIEWNAME' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).
lr_column->set_icon( if_salv_c_bool_sap=>true ).
lr_column->set_long_text( 'VIEWNAME' ).
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gr_table->get_event( ).
CREATE OBJECT gr_events.
* Set Handler
SET HANDLER gr_events->on_link_click FOR lr_events.
* Display ALV
gr_table->display( ).
*---------------------------------------------------
* form for bdc dynpro
*---------------------------------------------------
FORM bdc_dynpro USING program
dynpro.
CLEAR it_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO it_bdcdata.
CLEAR:wa_bdcdata.
ENDFORM. "bdc_dynpro
*---------------------------------------------------
* form for bdc field
*---------------------------------------------------
FORM bdc_field USING fnam
fval.
CLEAR it_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO it_bdcdata.
CLEAR:wa_bdcdata.
ENDFORM. "bdc_field
Hope you will find this tool useful. It might not be as robust as you expect, but it does the search for you.
Please follow our LinkedIn Page, LinkedIn Group, Facebook Page, Twitter and Instagram.
Save our number +1-646-727-9273 and send us a Whatsapp message ‘LEARN’ to be part of our Learning Community.
Free Step by Step Core Data Services Exercises
- CDS Part 1. Core Data Services – Introduction
- CDS Part 2. Core Data Services – Deep Dive
- ABAP on SAP HANA. Part XII. Open SQL, CDS or AMDP, which Code to Data Technique to use?
- CDS Part 3. Expose CDS Views as OData Service through Annotation
- CDS Part 4. Data Access in S/4HANA Cloud – CDS View Introduction
- CDS Part 5. ABAP CDS Views With Authorization
- CDS Part 6. Basic Expressions & Operations Available for CDS View – I
- CDS Part 7. Basic Expressions & Operations Available for CDS View – II
- CDS Part 8. Usage of Built-In Functions in CDS – I
- CDS Part 9. Usage of Built-In Functions in CDS – II
- CDS Part 10. Usage of Built-In Functions in CDS – III
- CDS Part 11. How to Consume CDS View in Smart Business Service KPI Fiori Apps?
- CDS Part 12. Useful 6 CDS Related Tools in ADT
- CDS Part 13. Key Definition in CDS Views
- CDS Part 14. ABAP Annotations for Translatable Texts in CDS Views
- CDS Part 15. Associations in CDS Views – I
- OData Service from CDS Annotation Not Working in Browser Mode
- CDS Part 16. Usage of Built-In Functions in CDS – IV
- CDS Part 17. How to Overcome GUID Mismatch Linking Problem in ABAP CDS?
- ABAP CDS Online Training – October 2019 Batch
- VDM 1 – S/4HANA Embedded Analytics Using CDS Virtual Data Model
- VDM 2 – S/4HANA Embedded Analytics Using CDS Virtual Data Model – Value Helps & Annotations
- CDS Part 18 – Bar Chart & Donut Chart using CDS Views
- VDM 3 – S/4HANA Embedded Analytics Using CDS Virtual Data Model – Meta Data Extensions(MDE)
- How to Append Standard Tables having Replacement Objects in S/4HANA
- ABAP Programming Model for SAP Fiori – 2 – CDS – Introduction
- ABAP Programming Model for SAP Fiori – 3 – CDS Views Creation
- CDS Part 19 – Finding Week of the Year in CDS Views
- CDS Part 20 – Virtual Elements (ABAP Functions) in CDS
- ABAP Programming Model for SAP Fiori – 13 – How to Preview and Download PDF in Fiori Apps
- CDS Part 21 – CDS View Finder Tool
- CDS – 22: How to Extend the CDS View if it Contains Aggregate Functions
- CDS – 23: CDS Performance Analysis – Basics – 1
- CDS with Fiori Elements – 1 – Create Your First Fiori List Report Using CDS
- CDS – 24 – How to build a Master-Detail Fiori Application using CDS Association
- CDS – 25: CDS Performance Analysis – 2
- CDS – 26: Analyzing CDS with Analytical Annotation and Manipulating its Filter Options
- How to Create SM30 Like Table Maintenance T-Code in SAP RAP – Part 1
- How to Create SM30 Like Table Maintenance T-Code in SAP RAP – Part 2 – Validations and Action via RAP
- Table Maintenance Generator from SAP RAP – Part 3 – FIORI UI App
Step by Step Virtual Data Model – VDM Tutorials
- VDM 1 – S/4HANA Embedded Analytics Using CDS Virtual Data Model
- VDM 2 – S/4HANA Embedded Analytics Using CDS Virtual Data Model – Value Helps & Annotations
- CDS Part 18 – Bar Chart & Donut Chart using CDS Views
- VDM 3 – S/4HANA Embedded Analytics Using CDS Virtual Data Model – Meta Data Extensions(MDE)
- VDM 4 – How to Expose & Consume CDS in Power BI?
- CDS – 26: Analyzing CDS with Analytical Annotation and Manipulating its Filter Options
Very Nice Blog.. it really helps to found CDS View that are related to any table…
I am actually looking that kind of stuff…
Thanks a lot!!!
Thanks himanshu and thanks raju for publish this article