Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Recording Deep Structure to Database via Data Cluster

$
0
0

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

ZMAIL_INDX.PNG

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:

 

ZMAIL_S_DATA.PNG

 

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.

 

Now i wonder,

Advantage and Disadvantage of using Data Cluster?

Any idea?


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>