Wednesday 7 February 2024

Create CDS view in ABAP on BTP

Overview of ABAP for BTP


The foundation of SAP modification and development has always been ABAP. Developers may now fully utilize cloud-based solutions and expand the reach of ABAP applications to unprecedented levels thanks to the integration of ABAP on BTP. BTP offers a flexible and scalable platform that makes it possible to integrate numerous SAP and non-SAP services with ease.

Begin with Creating a Trial user and installing ADT tools


SAP has given a provision to create a trial user in the BTP environment - Create a Trial user - SAP BTP ABAP Environment

Install ABAP Development tools - Install ADT Tools

Create a cloud project - Cloud Project

Create and Expose the CDS View in the BTP environment

Once you installed the ADT and created a cloud project it will look similar to the one below.

Create CDS view in ABAP on BTP

Now create an ABAP Package like the one below.

Create CDS view in ABAP on BTP

Enter the package name and description and click next

Create CDS view in ABAP on BTP

Select Create a new request and enter the description to assign the package under a Transport Request and finish the package creation.

Create CDS view in ABAP on BTP

Create CDS view in ABAP on BTP

Create a CDS data definition by right-clicking the package as shown below.

Create CDS view in ABAP on BTP

Create CDS view in ABAP on BTP

Enter the CDS name and Description

Create CDS view in ABAP on BTP

Assign the Transport Request for the CDS.

Create CDS view in ABAP on BTP

After clicking finish CDS view will be created.

Create CDS view in ABAP on BTP

Create CDS view in ABAP on BTP

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS DATA MODEL'
define root view entity ZCDS_LEARN

  as select from ztab_travel as Travel

  /* Associations */
  association [0..1] to /DMO/I_Agency   as _Agency   on $projection.agency_id = _Agency.AgencyID
  association [0..1] to /DMO/I_Customer as _Customer on $projection.customer_id = _Customer.CustomerID
  association [0..1] to I_Currency      as _Currency on $projection.currency_code = _Currency.Currency

{
  key mykey,
      travel_id,
      agency_id,
      customer_id,
      begin_date,
      end_date,
      @Semantics.amount.currencyCode: 'currency_code'
      booking_fee,
      @Semantics.amount.currencyCode: 'currency_code'
      total_price,
      currency_code,
      overall_status,
      description,
      /*-- Admin data --*/
      @Semantics.user.createdBy: true
      created_by,
      @Semantics.systemDateTime.createdAt: true
      created_at,
      @Semantics.user.lastChangedBy: true
      last_changed_by,
      @Semantics.systemDateTime.lastChangedAt: true
      last_changed_at,
      /* Public associations */
      _Agency,
      _Customer,
      _Currency
}

Here we completed our first CDS creation in the ABAP on BTP environment. We can see the data preview by running the CDS in the eclipse.

Create CDS view in ABAP on BTP

Create CDS view in ABAP on BTP

No comments:

Post a Comment