Copy SAP Table Programmatically Using ABAP

To copy a SAP table use function module RS_DD_COPY_OBJ. To activate the copied table use the function module RS_DD_ACTIVATE.

CONSTANTS: c_type TYPE ddeutype VALUE 'T'.

DATA: g_ok TYPE c.

PARAMETERS : p_source TYPE ddobjname,
             p_target TYPE ddobjname.

*Copy DDIC Table
CALL FUNCTION 'RS_DD_COPY_OBJ'
  EXPORTING
    source_name        = p_source
    target_name        = p_target
    objtype            = c_type
  EXCEPTIONS
    not_executed       = 1
    permission_failure = 2
    OTHERS             = 3.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
  WRITE:/ 'Table Copied Successfully'.

*Activate the copied table
  CALL FUNCTION 'RS_DD_ACTIVATE'
    EXPORTING
      objname = p_target
      objtype = c_type
    IMPORTING
      ok      = g_ok.
ENDIF.

In the selection screen enter Source table and Target table.

copy-sap-table-programatically-1

Output

copy-sap-table-programatically-2

Now go to ABAP Dictionary (SE11) and check the new table created.

copy-sap-table-programatically-3


3 thoughts on “Copy SAP Table Programmatically Using ABAP

  • June 6, 2013 at 2:25 am
    Permalink

    sort the fields as we want ????

    Reply
  • September 13, 2013 at 7:31 am
    Permalink

    In above program what is the use of that variable

    Reply
  • September 13, 2013 at 7:32 am
    Permalink

    PLEASE HELP ME
    WHAT IS THAT CONSTANT DATATYPE AND ALSO THAT VARIABLE DATA TYPE

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *