Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
shanthi_bhaskar
Active Contributor
We used to spend lot of time in identifying the SAP delivered CDS view(s) or Existing CDS View(s) in the system before starting the development which is very important so that we don't create duplicate objects and also we can utilize SAP delivered objects. Personally I felt the process was really painful and time taking.

As a Coding Savvy I could able to identify the tables which has all the Meta data information about the CDS view(s). So I had created a table function in S/4 HANA system which makes CDS search is easy. I am hoping that developers could able to leverage this code so that they could save lot of investigation time.

Below is the code for the table function and corresponding the AMDP Class. Only change which needs to done is to update the client number in the Class where I had mentioned as '000' at line number 23.

 

Table Function Code


@EndUserText.label: 'table function for CDS Meta Data'
define table function ZT_CA_CDS_METADATA

returns
{
Client : mandt;
SqlviewName : objectname;
CDSView : ddlname;
CDSViewDesc : abap.char(60);
FieldName : fieldname;
Position : tabfdpos;
DataElement : rollname;
DataType : datatype_d;
Length : ddleng;
Decimals : decimals;
}
implemented by method
ZCL_CDS_META=>GET_CDS_META


Code for the Class


class zcl_cds_meta definition
public
final
create public .

public section.
interfaces: if_amdp_marker_hdb.
class-methods: GET_CDS_META for table function ZT_CA_CDS_METADATA.
protected section.
private section.
endclass.



class zcl_cds_meta implementation.
method GET_CDS_META by database function
for hdb
language sqlscript
options read-only
using RSODPABAPCDSVIEW DD25T DD03L.

i_sqlview = SELECT
'000' as CLIENT,
RSODPABAPCDSVIEW.SQLVIEWNAME,
RSODPABAPCDSVIEW.DDLNAME,
DD25T.DDTEXT
FROM RSODPABAPCDSVIEW
INNER JOIN DD25T AS DD25T
ON DD25T.VIEWNAME= RSODPABAPCDSVIEW.SQLVIEWNAME;

return select
sqlview.client,
sqlview.SqlviewName,
sqlview.DdlName as CdsView ,
sqlview.ddtext as CdsViewDesc,
DD03L.Fieldname,
DD03L.Position,
DD03L.rollname as DataElement,
DD03L.Datatype,
DD03L.leng as Length,
DD03L.Decimals
from :i_sqlview as sqlview
left outer join DD03L as DD03L
on DD03L.tabname = sqlview.sqlviewName;

endmethod.

endclass.


Get the Data through Data Preview option or through writing SQL as displayed below


Open the image in a new window for clearer picture.



 



 

or you can modify the SQL query for getting the CDS views which has Billing in the CDS name



 



 

For Instance if you want to see all the CDS views which has name General Ledger





This Table Function can answer below questions



  1. Search for CDS view(s) by using the CDS View description.

  2. Get the Data Base View name of the CDS View(s).

  3. Get the Field names of the CDS view(s).

  4. Get the Data Type, Data Element and Length of Fields in the CDS View(s)


 

Hope this blog gives good sense and makes your development easy in order to identify the CDS views which was delivered by SAP and also you can reuse the CDS which were already built by other colleagues.

 

Please let me know if any suggestions and questions.

 

Regards,

Shanthi
4 Comments