Skip to Content
Author's profile photo Tolga POLAT

Recording Deep Structure to Database via Data Cluster

While writing with ABAP, many programer uses deep structure. Some case we need to record data in deep structure but normal SE11 dictionary type doesnt allow us.

So i came up with this :

Using Data Cluster for Deep structure Data Clusters in the Database

Now my example here is like this:

Purpose of this example saving email data ( I know SAP records all e-mail data, this is just a example of using data cluster )

First we need to create ZMAIL_INDX table


First key is relid this is Area ID

Second key is our record unique ID

Third key is counter for our record

after this we can add as many line as we like for data identification

last two line CLUSTR and CLUSTD fill automaticaly and this is our deep structure data.

Now creating our Mail data Deep structure:


Now we can write code:

DATA : ls_mail_data TYPE zmail_s_data,
          ls_mail TYPE zmail_indx,
          lv_keyid TYPE char20.

To save :

   ls_mail-ernam = sy-uname.
   ls_mail-erdat = sy-datum.
   ls_mail-pgmid = sy-repid.
   ls_mail-tcode = sy-tcode.
EXPORT mail = ls_mail_data TO DATABASE zmail_indx(zm) ID lv_keyid FROM ls_mail.


lv_keyid our unique ID

For information we sent ernam, erdat etc.

To read :

IMPORT mail = ls_mail_data FROM DATABASE zmail_indx(zm) ID lv_keyid TO ls_mail.

You must give keyid

Just like this we can record deep structure to database.

PS : I use CL_BCS for e-mail, all mail data created for CL_BCS. I assume ls_mail_data is filled with data, so i dont give example of CL_BCS.

Now i wonder,

Advantage and Disadvantage of using Data Cluster?

Any idea?

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Not a bad idea, but the table is better not to use the cluster for long-term storage of data. DBAs like to clean them.

      Author's profile photo Tolga POLAT
      Tolga POLAT
      Blog Post Author

      Thank you Олег Точенюк ,

      SAP using Cluster table too, ( in HR, BW etc. ). and this can be usefull for transporting deep structure between 2 or more program.

      But this is very rare usage, DB table better for long term use 😀

      Author's profile photo Former Member
      Former Member

      Cluster tables must belong to the past ... HANA technology does not involve them at all 🙂