## 4.2.15.16.3.2  Read APIs
The XCO Read APIs provide homogenous, yet strongly-typed, APIs that allow to access the content of ABAP Repository objects in a structured way.
## Hierarchical Object Model
The overall design of the XCO Read APIs (regardless of the concrete object type) is based on a natural hierarchical model for each respective object type. The hierarchical model used by the XCO Read APIs regards an object as a rooted tree, with the root node given by the header of the object and all other nodes
corresponding to parts of the object. To illustrate, the diagram below contains the hierarchical object model for a database table of the ABAP Dictionary as used by the XCO Read APIs:
<!-- image -->
For each node in the hierarchical object model for an object type, two abstractions are provided:
- Object/part handle
- Content handle
## Object/Part Handles
The object/part handle provides an abstraction which encapsulates all key values (object name and keys of the parts if applicable) of an object/part. For the database table example above we have:
- IF\_XCO\_DATABASE\_TABLE: The object handle for the database table (encapsulating the name of the database table)
- IF\_XCO\_DBT\_FIELD: The handle for the field of a database table (encapsulating the name of the database table and the name of the field)
- IF\_XCO\_DBT\_FOREIGN\_KEY: The handle for the foreign key of a field of a database table (encapsulating the name of the database table and the name of the field for which to consider the foreign key)
- IF\_XCO\_DBT\_SEARCH\_HELP: The handle for the search help of a field of a database table (encapsulating the name of the database table and the name of the field for which to consider the search help)
The following code sample illustrates how these four handles can be obtained:
## 
- Sample Code " Handle for database table ZMY\_DBT (IF\_XCO\_DATABASE\_TABLE). DATA(lo\_database\_table) = xco\_cp\_abap\_dictionary=&gt;database\_table( 'ZMY\_DBT' ). " Handle for the field KEY\_FIELD of database table ZMY\_DBT (IF\_XCO\_DBT\_FIELD).
- DATA(lo\_field) = lo\_database\_table-&gt;field( 'KEY\_FIELD' ).
- " Handle for the foreign key of field KEY\_FIELD of database table ZMY\_DBT (IF\_XCO\_DBT\_FOREIGN\_KEY). DATA(lo\_foreign\_key) = lo\_field-&gt;foreign\_key. " Handle for the search help of field KEY\_FIELD of database table ZMY\_DBT (IF\_XCO\_DBT\_SEARCH\_HELP). DATA(lo\_search\_help) = lo\_field-&gt;search\_help.
A given object/part handle allows to check the existence via the EXISTS method and provides access to the content handle of the respective object/part via the CONTENT method.
## Content Handles
Content handles exist in a natural 1:1 relationship with object/part handles and can be obtained via the CONTENT method of the object/part handle. In case the object type supports different versions (e.g. active and inactive) a choice for the version needs to be made before obtaining a content handle. More generally, a content handle fixes all degrees of freedom except for the origin (see below) such that the attributes exposed by the content handle can be read out.
A given content handle provides a dedicated GET\_* method for each exposed attribute as well as a method GET which will return all exposed attributes in a single structure. Note that for language-dependent attributes, e.g. short descriptions, the value will always be retrieved in the original language of the underlying ABAP Repository object.
For the database table example we have:
- IF\_XCO\_DBT\_CONTENT: The content handle for the header of the database table
- IF\_XCO\_DBT\_FIELD\_CONTENT: The content handle for a field of a database table
- IF\_XCO\_DBT\_FOREIGN\_KEY\_CONTENT: The content handle for the foreign key of a field of a database table
- IF\_XCO\_DBT\_SEARCH\_HELP\_CONTENT: The content handle for the search help of a field of a database table
The code sample below illustrates how the content handle for a database table field is obtained and used to read out the attributes of the field:
<!-- image -->
```
)->content( ). " Get the complete content (i.e. all the available attributes of the field) " as a structure of all attributes. DATA(ls_field_content) = lo_field_content->get( ). " Get each attribute individually. DATA(lv_short_description) = lo_field_content->get_short_description( ). DATA(lv_key_indicator) = lo_field_content->get_key_indicator( ). DATA(lv_not_null) = lo_field_content->get_not_null( ). DATA(lo_type) = lo_field_content->get_type( ). DATA(lv_language_indicator) = lo_field_content->get_language_indicator( ). DATA(ls_currency_quantity) = lo_field_content->get_currency_quantity( ).
```
## Origins
An origin is an abstraction that encapsulates where the content (and existence status) of an object or part thereof are read from. As explained above, object/part as well as content handles are only backed by the semantic identifiers (e.g. the name of the database table) but do not make any choices if the content is read from the local system or from elsewhere. To this extent, each GET* method on a content handle asks for an (optional) origin from which the attribute will henceforth be read. In short:
- Content handle: Encapsulates what shall be read
- Origin: Encapsulates where content shall be read from
As of now, the XCO Read APIs define the following three kinds of origins (availability depending on the implementation status of each object type):
- Default: The default origin will be used when no explicit origin is supplied. With the default origin, an object will be read exactly once per ABAP session from the local system. Once read from the local database, the content will be cached for the duration of the ABAP Session and used for any subsequent reads
- Local: The local origin reads from the local database. The caching behavior for individual or groups of objects can be configured freely
- Remote: Based on an RFC destination (given as IF\_RFC\_DEST) objects are read from remote systems. The caching behavior for individual or groups of objects can be configured freely
Note that not all object types support the origin concept yet (see table below). In case an object type does not yet support the origin concept the content will always be read from the local database.
## Object Type Feature Matrix
| Object Type   |                        | Supports Origins?   | Origin Factory               | Supports Local Origin   | Supports Remote Origin   |
|---------------|------------------------|---------------------|------------------------------|-------------------------|--------------------------|
| APLO          | Application Log Object | No                  | -                            | -                       | -                        |
| CLAS          | Class                  | Yes                 | XCO_CP_ABAP_O BJECTS=>ORIGIN | Yes                     | Yes                      |
| Object Type   |                             | Supports Origins?   | Origin Factory                         | Supports Local Origin   | Supports Remote Origin   |
|---------------|-----------------------------|---------------------|----------------------------------------|-------------------------|--------------------------|
| DDLS          | Data Definition             | No                  | -                                      | -                       | -                        |
| DOMA          | Domain                      | Yes                 | XCO_CP_DO- MAIN=>ORIGIN                | Yes                     | No                       |
| DRTY          | CDS Type Defini- tion       | Yes                 | XCO_CP_CDS_TY PE_DEFINITION            | Yes                     | No                       |
| DTEL          | Data Element                | Yes                 | XCO_CP_DATA_EL EMENT=>ORIGIN           | Yes                     | No                       |
| EVTB          | Event Binding               | Yes                 | XCO_CP_EVENT_ BINDING=>ORI- GIN        | Yes                     | No                       |
| FUGR          | Function Group              | Yes                 | XCO_CP_FUNC- TION_GROUP=>O RIGIN       | Yes                     | No                       |
|               | Function Module             | Yes                 | XCO_CP_FUNC- TION_MOD- ULE=>ORIGIN     | Yes                     | No                       |
| INTF          | Interface                   | Yes                 | XCO_CP_ABAP_O BJECTS=>ORIGIN           | Yes                     | Yes                      |
| MSAG          | Message Class               | No                  | -                                      | -                       | -                        |
| NONT          | SAP Object Node Type        | Yes                 | XCO_CP_SAP_OB- JECT_NODE_TYPE =>ORIGIN | Yes                     | No                       |
| RONT          | SAP Object Type             | Yes                 | XCO_CP_SAP_OB- JECT_TYPE=>ORI- GIN     | Yes                     | No                       |
| SRVB          | Service Binding             | Yes                 | XCO_CP_SERV- ICE_BIND- ING=>ORIGIN     | Yes                     | No                       |
| SRVC          | Service Consump- tion Model | Yes                 | XCO_CP_SERV- ICE_CONS_MODE L=>ORIGIN   | Yes                     | No                       |
| SRVD          | Service Definition          | Yes                 | XCO_CP_SERV- ICE_DEFINI- TION=>ORIGIN  | Yes                     | No                       |
| TABL          | Structure                   | No                  | -                                      | -                       | -                        |
|               | Database Table              | Yes                 | XCO_CP_DA- TABASE_TA- BLE=>ORIGIN      | Yes                     | No                       |
|               | Global Temporary Table      | No                  | -                                      | -                       | -                        |
| TTYP          | Table Type                  | No                  | -                                      | -                       | -                        |
| XSLT          | Transformation              | No                  | -                                      | -                       | -                        |