Skip to Content

ABAP CDS Views:


A CDS is defined for existing database tables and any other views or CDS Views in ABAP Dictionary using the statement DEFINE VIEW in the DDL in ABAP Core Data Services(CDS) . This is done in CDS Source code in the ABAP Development tools(ADT). Every CDS view has its own CDS Source code.

Two objects are created in ABAP Dictionary of Every CDS View:


  • CDS Database View : It is read-only classical database view in ABAP Dictionary.
  • CDS Entity: It is actual CDS view. It covers the CDS Database view and makes other attributes possible, such as authorization checks defined in CDS view

A CDS View has two types of keys:


  • For CDS Entities ,KEY can be used to define key elements, This Key is the semantic key of the CDS View
  • The key of the CDS database view is determined implicitly, as in a classical view. This key is a technical key of the CDS View.

ABAP CDS- DEFINE VIEW parameter list


Syntax:


…..WITH PARAMETERS pname1:parameter type,pname2…

Effect: Defines Input parameters pname1,pname2 in a CDS View in ABAP CDS in a comma separated list. Each input parameter must be typed with a data type parameter type.

.

Example:


The following CDS View has a list of two input parameters in the WHERE Clause of the SELECT statement.

@AbapCatalog.sqlViewName:’DEMO_INPUT_CDS’

    Define view demo_parameters_cds

    With parameters p_country:LAND1_GP,

                                p_region:REGIO

    as Select from KNA1

        { key kunnr,

                land1 as Country key,

                name1,

                ort01 as City,

                region as Region

        } where land1 = : p_country and regio = : p_region;

Steps to be shown in this document:

  1. Define input parameters in a CDS View
  2. Use input parameters in a CDS View.
  3. Define a View as a parameterized view.
  4. Call a parameterized view with open SQL.

1.Define input parameters in a CDS View.


  • Start ABAP in Eclipse
  • Right click on the package icon,and from the context menu select New->other ABAP repository object.

/wp-content/uploads/2016/06/image1_970113.jpg

/wp-content/uploads/2016/06/image2_970114.jpg

/wp-content/uploads/2016/06/image3_970145.jpg

/wp-content/uploads/2016/06/image4_970146.jpg

2.Use input parameters in a CDS View.


@AbapCatalog.sqlViewName:’ZCDS_DDL_IP1′

@EnduserTextLabel :’ABAP CDS View with input parameters’

Define view ZCDS_DD1_IP_TEST

    With parameters matnr:abap.numc(18),

                                Lang:abap.char(1)

  As select from mara as a

        inner join  makt as b

        on a.matnr = b.matnr

      {

        key a.matnr as material,

              b.maktx as description,

              $parameters.Lang as language

      } where a.matnr = $parameters.matnr and b.spras = $parameters.Lang;

image15.JPG

image17.JPG

 

3.Define a Parameterized view.


Shown the material description as per the language specified on input parameter.

/wp-content/uploads/2016/06/image5_970165.jpg

/wp-content/uploads/2016/06/image6_970169.jpg

image8.JPG

image7.JPG

4.Call a parameterized view with open SQL.

Define view ZCDS_DD1_IP_CALLCDS

    With parameters  matnr:abap.numc(18),

                                 Lang:abap.char(1)

     As select * from ZCDS_DD1_IP_TEST(matnr:$parameters.matnr,lang:$parameters.Lang)

imag11.JPG

image13.JPG

Reference Links:


https://scn.sap.com/thread/3682537

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply