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

Copy the content among two internal tables

Hi Experts,

I have a query regarding internal table copy.

it may look silly, but could nt get the solution in single or two lines of code.

my query is:

I have two internal tables, which is having differnt structure, but over all, the fields are same, the order is different, how can I copy one table to another in one or two lines of code.

I can do it by looping one internal table and move every field to the destination, but I dont want to go for it, I want one or 2 lines of code to achive this functionality.

Pls advice.

Regards,

SR

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 03:37 PM

    Hi,

    It is not possible in one line / two lines to move from one internal table to another if the structures are different.

    As you mentioned it can be done by LOOP..ENDLOOP.

    Thanks

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 03:38 PM

    Hi ,

    Loop at itab1 into wa1.

    move-corresponding wa1 to wa2.

    append wa2 to itab2.

    endloop.

    Thanks,

    Rajinikanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 03:39 PM

    appending lines of itab from 1 to 20 to itab .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 03:39 PM

    try this ...

    Loop at itab1.

    move-corresponding itab1 to itab2.

    append itab2.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 03:42 PM

    Hi,

    you have to do a LOOP, but with the MOVE-CORRESPONDING statement there are not so much line of code required.

    DATA ls_dest TYPE ZS_DEST.
    DATA lt_dest TYPE TABLE OF ZS_DEST.
    DATA lt_source TYPE TABLE OF ZS_SOURCE.
    FIELD-SYMBOLS <ls_source> TYPE ZS_SOURCE.
    
    LOOP AT LT_SOURCE ASSIGNING <ls_source>.
      MOVE-CORRESPONDING <ls_source> TO ls_dest.
      APPEND ls_dest TO lt_dest.
    ENDLOOP.
    

    Regards Rudi

    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.