Reputation: 611
I want to create a backup copy ztable through the abap program and not through SE11. Is there anyway to do it?
e.g. I want to copy the zmydbtable to zmydbtable_bckp, how can I do it dynamically?
Thanks
Upvotes: 0
Views: 1882
Reputation: 51
As you are referring to SE11, I assume you want to copy the definition / structure, not the contents. To archive this, you could do the following:
Define the new TADIR entry and write it with function module 'TR_TADIR_INTERFACE'
CALL FUNCTION 'TR_TADIR_INTERFACE'
EXPORTING
wi_test_modus = space
wi_tadir_pgmid = 'R3TR'
wi_tadir_object = 'TABL'
wi_tadir_obj_name = 'ZMYDBTABLE_BCKP'
wi_tadir_author = sy-uname
wi_tadir_devclass = 'YOUR_PACKAGE'.
Use function module 'DDUT_OBJECT_COPY' to copy the old table def. to the new one
CALL FUNCTION 'DDUT_OBJECT_COPY'
EXPORTING
type = 'TABL'
src_name = 'ZMYDBTABLE'
dst_name = 'ZMYDBTABLE_BCKP'.
Call function module 'DD_TABL_ACT' to activate the table
CALL FUNCTION 'DD_TABL_ACT'
EXPORTING
tabname = 'ZMYDBTABLE_BCKP'.
I only showed the basic parameters you need in the example; please add others as needed and proper exception handling.
Personally, I would discourage you to do so, as this is touching the core of the system and it can get a mess very easily. Any wrong use can result in serious issues on your system. Please note, that the mentioned function modules are not released by SAP for customer use, therefore you won't get any support if you break anything.
Upvotes: 2