Structure of a Cluster Database
Cluster databases have the following structure:
The rules for the structure of a cluster database are listed below. The fields listed in steps 1 to 4 must be created as key fields. The data types listed are ABAP Dictionary types.
- If the table is client-dependent, the first field must have the name MANDT, type CHAR, and length 3 bytes. It is used for the client number. The system fills the MANDT field when you save a data cluster - either automatically with the current client or with a client that you explicitly specify in the EXPORT statement.
- The next field (the first field in the case of client-independent tables) must have the name RELID, type CHAR, and length 2 bytes. This contains an area ID. Cluster databases are divided into different areas. The system fills the field RELID with the area ID specified in the EXPORT statement when it saves a data cluster.
- The next field has type CHAR and variable length. It contains the name <key> of the cluster, specified in the program with the addition ID in the EXPORT statement. Since the next field is aligned, the system may fill out the field RELID with up to three unused bytes. When you create your own cluster databases, you should plan for the length of this field.
- The next field must have the name SRTF2, the type INT4, and length 4. Single data clusters can extend over several lines of the database table. Theoretically, up to 2**31 lines are possible. The field SRTF2 contains the current line number within the data cluster. Its value can be from 0 to 2**31 -1. The field is filled automatically by the system when you save a data cluster (see step 7).
- After SRTF2, you can include any number of user data fields of any name and type. The system does not automatically fill these fields when you save a cluster. Instead, you must assign values to them explicitly in the program before the EXPORT statement. These fields normally contain administrative information such as program name and user ID.
- The penultimate field of a line must have the name CLUSTR and the type INT2 with length 2. This contains the length of the data in the following field CLUSTD. The field is filled automatically by the system when you save a data cluster.
- The last field in the line must have the name CLUSTD and the type VARC. You can define it with any length. It is usually around 1000 bytes long. This is the field in which the system saves the actual data in the data cluster. The data is saved in compressed form. If CLUSTD is not long enough to accommodate a data cluster, it is split across two or more lines. The lines are numbered in field SRTF2 (see step 4).
You can either create your own cluster databases by following the above rules (for further information, refer to the
ABAP Dictionary documentation), or you can use the system cluster database INDX.
Example of a Cluster Database