Many ABAP developers know Open SQL, internal tables, and SE11 database views, but still get stuck when a project asks for cds views in ABAP. The syntax looks simple, but the real skill is knowing what CDS should model, how to activate it in ADT, how to preview it, and how to consume it in an ABAP program. This guide covers SAP NetWeaver 7.50+ and SAP S/4HANA 1909+.
You need Eclipse with ABAP Development Tools, usually called ADT. ADT is the Eclipse-based ABAP development environment used for CDS definitions, ABAP classes, RAP objects, and many S/4HANA development tasks.
You also need an ABAP package, a transport request if your system requires transport tracking, and access to a demo table such as SCARR or SPFLI. In S/4HANA Cloud or ABAP Cloud, you may need released CDS views or released APIs instead of direct access to classic demo tables.
Use transaction SE11 only to inspect Dictionary tables and fields. Create CDS views in ADT, not in SE38. SE38 is for ABAP reports, while CDS data definitions belong in Eclipse ADT.
Step 1 — Understand What a CDS View Actually Does
A CDS view does not store data by itself. It defines a reusable data model over one or more sources such as database tables, database views, or other CDS views. When you query the CDS view, the database reads the underlying sources.
This point matters for cds views in SAP ABAP for beginners because many developers think CDS is just another table. It is not a table. It is a definition that tells the ABAP runtime and database how to read and shape data.
In older ABAP releases, many examples use classic DDIC-based CDS views with define view and @AbapCatalog.sqlViewName. In modern S/4HANA and ABAP Platform releases, SAP documentation recommends CDS view entities for new development where supported. You will still see both styles in real projects.
Classic CDS view pattern:
@AbapCatalog.sqlViewName: ‘ZV_CARR_OLD’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Classic CDS view for carrier data’
define view ZI_Carrier_Old
as select from scarr
{
key carrid as CarrierId, ” Airline carrier ID
carrname as CarrierName, ” Airline carrier name
currcode as CurrencyCode ” Airline currency code
}
Modern CDS view entity pattern:
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘CDS view entity for carrier data’
define view entity ZI_Carrier
as select from scarr
{
key carrid as CarrierId, ” Airline carrier ID
carrname as CarrierName, ” Airline carrier name
currcode as CurrencyCode ” Airline currency code
}
The second style avoids the old generated SQL view name requirement. If your system supports CDS view entities, use that for new training examples and new S/4HANA work unless your project standard says otherwise.
Step 2 — Create a Basic CDS View in ADT
Open Eclipse ADT, right-click your package, and choose New → Other ABAP Repository Object → Core Data Services → Data Definition. Give the object a name such as ZI_Carrier. Select a transport request if the system asks for one.
Use this starter example for cds views in sap abap tutorial practice. It reads carrier data from SCARR, which is a common demo table in SAP training systems. If your system does not have SCARR, replace it with a local training table or an allowed released view.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Carrier list for CDS beginner example’
define view entity ZI_Carrier
as select from scarr
{
key carrid as CarrierId, ” Key field for airline carrier
carrname as CarrierName, ” Descriptive airline name
currcode as CurrencyCode, ” Currency used by the carrier
url as Website ” Carrier website if maintained
}
This is a safe first cds views in sap abap example because it selects a small number of fields and uses clear aliases. Aliases make the CDS output easier to read in ADT and in ABAP code. Keep the first view simple before adding joins, parameters, or annotations.
Activate the CDS object. If activation fails, read the Problems view in Eclipse. The error usually points to a missing source table, wrong field name, unsupported syntax, or package issue.
Step 3 — Preview the CDS View Output
After activation, right-click the CDS view entity in ADT and choose Open Data Preview. This lets you check the result without writing an ABAP report. Data preview is one of the fastest ways to validate a beginner CDS view.
Check four things: field names, key field, row count, and sample values. If CarrierId or CarrierName looks wrong, fix the CDS definition before writing ABAP code. Do not continue into program consumption until the CDS output is clean.
You can also run a simple select in the ADT SQL Console if your system allows it. The SQL Console helps you test filters and field output quickly.
select *
from ZI_Carrier
In a real S/4HANA project, do not treat data preview as the only validation. Authorization checks, DCL roles, client handling, and service consumption can affect what a user sees. For training, data preview is enough to confirm the object activates and returns rows.
Step 4 — Consume the CDS View in an ABAP Program
A common beginner question is how to use a cds view in abap program. The answer is simple: query the CDS view with Open SQL, just like you query a database table or Dictionary view. The CDS object becomes a reusable read source for ABAP.
Create an executable report in SE38 or ADT. SE38 is the SAP GUI transaction used to create, change, and run ABAP reports. In modern S/4HANA development, ADT is often preferred, but SE38 still appears in many on-premise systems.
REPORT zread_cds_carrier.
TYPES: BEGIN OF ty_carrier,
carrier_id TYPE scarr-carrid, ” Carrier ID type from Dictionary
carrier_name TYPE scarr-carrname, ” Carrier name type from Dictionary
currency_code TYPE scarr-currcode, ” Currency code type from Dictionary
END OF ty_carrier.
DATA lt_carriers TYPE STANDARD TABLE OF ty_carrier WITH EMPTY KEY. ” Result table
DATA ls_carrier TYPE ty_carrier. ” Work area
SELECT CarrierId,
CarrierName,
CurrencyCode
FROM ZI_Carrier
INTO TABLE @lt_carriers. ” ABAP 7.40+ host variable syntax
IF sy-subrc <> 0. ” Check whether the CDS view returned data
WRITE: / ‘No carrier data found.’.
RETURN. ” Stop report if no rows exist
ENDIF.
LOOP AT lt_carriers INTO ls_carrier. ” Loop through result rows
WRITE: / ls_carrier-carrier_id,
ls_carrier-carrier_name,
ls_carrier-currency_code.
ENDLOOP.
This section is where many tutorials stop too early. The CDS view is useful only when another consumer can reuse it. That consumer may be ABAP Open SQL, a service, a RAP projection, an analytical model, or another CDS view.
Step 5 — Add a Join or Association Safely
After the basic example works, add a second source. Use SPFLI, the demo flight connection table, if your system has it. The goal is to show carrier data with connection data.
For beginners, start with an explicit join before moving to associations. Joins are easier to debug because the result set appears immediately in the selected fields.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Carrier connection example’
define view entity ZI_CarrierConnection
as select from scarr as Carrier
inner join spfli as Connection
on Carrier.carrid = Connection.carrid
{
key Carrier.carrid as CarrierId, ” Carrier key
key Connection.connid as ConnectionId, ” Connection key
Carrier.carrname as CarrierName, ” Carrier name
Connection.cityfrom as DepartureCity, ” Departure city
Connection.cityto as ArrivalCity ” Arrival city
}
Now consume the joined CDS view in ABAP.
REPORT zread_cds_connection.
SELECT CarrierId,
ConnectionId,
CarrierName,
DepartureCity,
ArrivalCity
FROM ZI_CarrierConnection
INTO TABLE @DATA(lt_connections) ” ABAP 7.40+ inline declaration
UP TO 20 ROWS. ” Limit output for beginner test
IF sy-subrc <> 0. ” Check result status
WRITE: / ‘No connection data found.’.
RETURN.
ENDIF.
LOOP AT lt_connections ASSIGNING FIELD-SYMBOL(<connection>). ” Avoid row copy
WRITE: / <connection>-CarrierId,
<connection>-ConnectionId,
<connection>-CarrierName,
<connection>-DepartureCity,
<connection>-ArrivalCity.
ENDLOOP.
Associations are useful when you want modeled relationships that can be followed by consumers. They are important in S/4HANA and RAP-style data modeling. Do not use associations just to look advanced; use them when the relationship should be part of the reusable model.
For cds views in abap on hana, the important point is not only syntax. CDS helps push data selection and projection closer to the database, but bad joins, missing filters, and overly broad views can still create performance problems. Always test the generated access path in real data volume.
Testing & Validation
Start with ADT activation. If the CDS object activates, open Data Preview and verify the field list, aliases, row count, and sample rows. Then run the ABAP report and compare the output with the CDS preview.
Use ST05 when performance matters. ST05 is the SAP GUI transaction for SQL trace, used to inspect database calls made by an ABAP program or CDS query. Run it only for focused tests because broad traces create noise.
Check authorization behavior separately. A CDS view with @AccessControl.authorizationCheck: #NOT_REQUIRED is fine for a training example, but production CDS views may need DCL access control. If a user sees fewer rows than the developer, authorization may be the reason.
For S/4HANA Cloud, also check whether a released standard CDS view already exists. The View Browser app and SAP Business Accelerator Hub help find released views for reuse. Do not create a custom CDS view if a released standard view already fits the requirement.
Common Issues During Setup
Issue 1: ADT does not show Core Data Services.
Install or update ABAP Development Tools and check whether your backend release supports CDS development. Old ECC systems without the right ABAP Platform level may not support the same syntax.
Issue 2: define view entity does not activate.
Your system may support only classic CDS views or your syntax level may be lower than the example. Use classic define view with @AbapCatalog.sqlViewName if your project release requires it.
Issue 3: Data Preview returns no rows.
Check the source table in SE16N or another allowed table-display tool. SE16N displays table contents in many on-premise systems, but authorization may block it.
Issue 4: ABAP SELECT from CDS fails.
Check the CDS object name, aliases, package activation, and release restrictions. In ABAP Cloud, only released objects may be consumable depending on your environment.
Issue 5: Join creates duplicate rows.
Check key fields and join cardinality. A wrong join can multiply rows and make reports look wrong even when the CDS activates correctly.
Conclusion
CDS views in ABAP work as reusable data models over existing sources, not as physical tables that store data. A practical CDS workflow starts in ADT, continues with activation and data preview, then moves into ABAP consumption through Open SQL. That flow helps developers move from table-level thinking to reusable data modeling.
For beginners, start with one simple CDS view, validate it, then consume it in a report. Don’t start with annotations, associations, access control, parameters, and OData exposure all at once. First prove that you can create a CDS view, preview the result, and read it from an ABAP program.
For S/4HANA projects, learn CDS view entities, associations, access control, and released standard views. Modern S/4HANA development often expects developers to understand how CDS supports Fiori apps, analytical models, RAP services, and clean data-access layers. That does not mean every requirement needs CDS, but it does mean CDS is now a core ABAP skill. To learn why CDS Views Fail in SAP Hana
Use CDS when the data model should be reused by reports, services, analytics, or other CDS views. Avoid CDS when the requirement is mainly procedural logic, dynamic runtime decisions, update processing, or a small one-off read that a simple Open SQL statement can handle clearly. Good ABAP design is not about forcing CDS everywhere; it is about choosing the right layer for the job.
The best next step is to build a small progression: create a basic view, add clear field aliases, consume it in ABAP, then add a join or association. After that, learn authorization checks, parameters, annotations, and view entities. That order keeps CDS practical instead of turning it into confusing syntax memorization.
Frequently Asked Questions
1. What are CDS views in ABAP?
CDS views in ABAP are reusable data definitions created in ABAP Development Tools. They read data from tables, views, or other CDS views and expose a structured model. They do not store data by themselves; they describe how data should be read.
2. How do I consume a CDS view in an ABAP program?
Use Open SQL to select from the CDS view or the CDS view entity. A cds view in abap program can be queried with SELECT FROM <cds_name> and loaded into an internal table. Check sy-subrc and validate the output.
3. What is the difference between ABAP CDS and HANA CDS?
ABAP CDS belongs to the ABAP platform and is developed in ADT. HANA CDS belongs to native SAP HANA development. For cds views in abap on hana, ABAP CDS is usually the right path for ABAP and S/4HANA developers.
4. What is the difference between CDS view and CDS view entity?
A CDS view entity is the newer CDS object type for many current ABAP scenarios. Older CDS views use DDIC-based generated SQL views and often include @AbapCatalog.sqlViewName. Use view entities when your release and project standard support them.
5. How to create CDS views in SAP ABAP tutorial?
Source: Google autosuggest
Create a CDS data definition in Eclipse ADT, choose a source table or view, define fields, activate the object, preview data, and consume it in ABAP. A cds views in sap abap tutorial should always include activation and validation, not only syntax.
6. What is a CDS views in SAP ABAP example?
A common CD view in an SAP ABAP example selects fields from SCARR or joins SCARR with SPFLI. Training systems often use these demo tables because they are small and readable. In S/4HANA Cloud, use released views when required.
