
CDS external entities provide a modern way to handle secondary database connections in ABAP Cloud. They allow ABAP programs to retrieve and modify data from other databases using SQL. Sounds interesting? Read this blog post for further details.
The standard database of AS ABAP is the SAP HANA database. Until now, if an ABAP program wanted to access a database system other than the standard database, the developer could configure a secondary connection in transaction DBCON and use this connection in ABAP SQL (addition CONNECTION), native SQL, or AMDP. Now, ABAP CDS provides CDS external entities for retrieving data from other database systems. The remote connection is managed using the data federation approach of the SAP HANA Smart Data Access technology.
Secondary connection | External entity | |
Possible secondary database | Only to other SAP HANA databases. | SAP-HANA databases, non-SAP-HANA databases, other AS ABAP (for a full list of possible connection targets, see 2600176 - SAP HANA Smart Data Access Supported Remote Sources - SAP for Me)). Note: External entities can be used to connect to public Cloud systems - SAP S/4HANA Cloud public edition, SAP BTP ABAP environment, or SAP HANA Cloud. |
Remote object | Remote object name, field names, and types need to match local ABAP objects. | External entity represents remote object. Object name and field names in ABAP and of the external object can differ. |
Number of connections in a single SELECT | Only one connection per statement. | A single select statement can retrieve data from multiple remote sources. |
Technology | ABAP database connections | SAP HANA Smart Data Access |
Here’s an example for an ABAP SQL SELECT statement using a secondary connection.
SELECT
FROM scarr
LEFT OUTER JOIN spfli ON scarr~carrid = spfli~carrid
FIELDS scarr~carrid, scarr~carrname, spfli~connid
INTO TABLE @FINAL(lt_data)
OPTIONS CONNECTION my_conn.
Here’s an example of an ABAP SQL SELECT statement that uses a CDS external entity.
CDS external entity: design time object that represents a remote data source
define external entity as_external_scarr
external name VIEW_ON_SCARR
{
key carrid : s_carr_id external name ...;
carrname : s_carrname external name ...;
...
}
with federated data
provided at runtime
ABAP SQL SELECT statement retrieving data from a remote data source using an external entity and a logical external schema
SELECT
FROM demo_cds_external_entity AS scarr
PROVIDED BY les_scarr
LEFT OUTER JOIN external_spfli AS spfli
PROVIDED BY les_spfli
ON scarr~carrid = spfli~carrid
FIELDS scarr~carrid, scarr~carrname, spfli~connid
INTO TABLE @FINAL(lt_data).
AS an ABAP developer, here’s what you need to do to establish outbound SQL access using a CDS external entity:
These are the steps performed by an ABAP developer in ABAP Development Tools for Eclipse. For the remote connection to work, a system administrator must configure the logical external schema with all the details required to establish the communication between the local system and the remote system.
The system administrator must perform the following steps using the SAP Fiori application Communication Arrangement:
Here’s an example:
CDS external entity
A CDS external entity is a CDS artifact that represents an external database object. It specifies ABAP names and, optionally, the original field names of the remote data source are specified after EXTERNAL NAME.
@EndUserText.label: 'Demo CDS external entity'
define external entity demo_cds_external_entity
external name DATATYPES
{
key charField : abap.char(10) external name K_CHAR;
F_INT1 : abap.int1;
F_INT2 : abap.int2;
}
with federated data
provided at runtime
Logical external schema
A logical external schema is created in a form-based editor in the ABAP development tools for Eclipse. It is a CDS proxy artifact whose configuration specifies the connection details required to connect to an external system. It has only one field – Default Remote Schema – that can be left empty.
Communication scenario with outbound service
A communication scenario is a design-time description of how two communication partners communicate with each other. It consists of inbound and/or outbound services and supported authentication methods. A logical external schema must be included as an outbound service in a communication scenario. This is done in a form-based editor in the ABAP development tools for Eclipse.
Outbound service referring to a logical external schema
Communication Scenario with outbound service
ABAP SQL Access:
select
from demo_cds_external_entity
provided by demo_cds_logicl_externl_schema
fields *
order by charField
into table @final(lt_federated_data).
Result: (Data fetched from an SAP HANA system in the Canary landscape).
A system administrator creates a new Communication Arrangement, Communication System, and Outbound User in the SAP Fiori Application Communication Arrangement. The following screenshots show all the relevant fields that must be entered.
Communication Arrangement
Communication System
For details on the adapters and their connection parameters, see the corresponding topics for the adapter types in Creating Remote Sources (Smart Data Access) | SAP Help Portal.
Outbound User
As of release 2502, an external entity can also be defined as writable. Writable external entities allow modifying data on external database systems using ABAP SQL operations, such as INSERT, UPDATE, MODIFY, and DELETE. This facilitates write access in data integration scenarios. Writing is always done via a service connection in order to decouple the remote transaction from the local transaction.
Here's what you need:
Further details are described on SAP Help Portal under Writable External Entities | SAP Help Portal.
This blog post introduces CDS external entities for outbound SQL access. Currently, only dynamic external entities are supported. This kind of external entity does not specify a logical external schema in its data definition, but uses the addition PROVIDED AT RUNTIME. Dynamic external entities can only be accessed using ABAP SQL. They cannot be used as a data source for other CDS entities.
It is planned to provide static external entities in one of the future releases. A static external entity defines a logical external schema directly in its data definition. Static external entities can be used as data sources in ABAP SQL SELECT statements, in other CDS entities, and in ABAP Managed Database Procedures (AMDP).
Feedback and questions are welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
16 | |
14 | |
13 | |
9 | |
9 | |
9 | |
8 | |
7 | |
7 | |
7 |