0

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

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
ekekakos
  • 563
  • 3
  • 20
  • 39
  • Do you want a backup of the **structure** or of the **contents**? – vwegert Jan 31 '18 at 11:01
  • There is something that lets you create transparent tables programatically. It is used by SAP Archiving for creating `ZARI*` tables. I did it some time ago but can't find the coding at the moment. If I do I will post my answer. – Jagger Jan 31 '18 at 13:36
  • Why do you even want this? Your Z table is not dynamic, I guess, so why back up table should be? – Oguz Feb 02 '18 at 05:56

1 Answers1

2

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:

  1. 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'.
    
  2. 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'.
    
  3. 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.