11.4    Data Clusters

Data clusters are a type of storage that can only be used by ABAP programs. A data cluster is a group of data objects that stored in a storage medium. The data of data objects can be stored in different media using data clusters, and this data can then be read by ABAP programs.

Data clusters are in an ABAP-specific format and can only be accessed using IMPORT and EXPORT statements. A data cluster consists of an administration section and a data section. The administration section stores administration information about the data cluster, and the data section contains the compressed data objects. The administrative information that is stored in a data cluster varies based on the storage medium.

The following media support data clusters:

The following statements are used when working with data clusters:

A data cluster stored in a database table is stored persistently, so it can be imported later by ABAP programs. In this section, we’ll discuss storing data clusters in a database table.

When storing data clusters in database tables, the table should have a specific structure. These structures are called INDX structures (see Figure 11.11), because they’re based on the standard table INDX provided by SAP.

The table structure should satisfy the following conditions:

11.4.1    Exporting Data Clusters to Databases

The EXPORT TO DATABASE statement exports the data cluster to the special database that is of table INDX.

With the EXPORT statement, a two-character area specification and ID are supplied. The area specification splits up the rows of the database table into several areas so that data clusters with the same ID can exist multiple times in the database table.

Listing 11.14 shows sample code using the EXPORT statement.

DATA: it_kna1  TYPE STANDARD TABLE OF kna1.
SELECT * FROM kna1 INTO TABLE it_kna1 UP TO 10 ROWS.
EXPORT tab = it_kna1
TO DATABASE zdemo_dc(SA)
ID 'TABLE'.

Listing 11.14    Exporting Data Cluster to Table

11.4.2    Importing Data Clusters

Using the IMPORT statement, the data cluster that was written to the database table dbtab in the area ar and under the ID specified in id using the EXPORT statement is imported.

Listing 11.15 shows an example of importing data clusters using the IMPORT statement.

DATA: it_kna1 TYPE STANDARD TABLE OF kna1.
IMPORT tab = it_kna1
FROM DATABASE zdemo_dc(SA)
ID 'TABLE'.

Listing 11.15    Importing Data Clusters