Skip to Content
author's profile photo Former Member
Former Member

copy a table with records to a new table

Is it possible to copy the entire table with its contents to a new table. If so, pls explain. Thank you.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jan 26, 2008 at 08:35 PM

    hi SRK

    assumptions: both the table structures are the same.

    the primary keys are the same.

    data: begin of itabA.
             include structure A.
    data: end of itabA.
    
    data: begin of itabB.
             include structure B. <<<<< if needed.
    data: end of itabB.
    
          select * from A into table itab.
    
          delete table B.
    
           modify table B by itab.
    
    

    The structure of Itab will the same structure of the Ztable we are updating.

    in the above case it will be of type B,

    Edited by: Jackandjay on Jan 27, 2008 6:09 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 26, 2008 at 07:40 PM

    Hi,

    Its possible to copy one table to another with records but there are few limitations.

    The table structure of both the internal tables should be exactly same i.e the field names and the field length.

    Then define the new table and just use the assignment statement to copy.

    For E.g. - A[] = B[]

    Here table B is copied on to table A[]. The contents of internal table A are completely overwritten by the contents of internal table B.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 26, 2008 at 09:09 PM

    Hi srk,

    this is a typical "If I don't know how top press F1 I have to try" question.

    [Conversion Rules for Internal Tables (SAP Library - ABAP Programming (BC-ABA)):|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb34d0358411d1829f0000e829fbfe/content.htm]

    Regards,

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.