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.
ZM is RELID
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?