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

move fields from one table to another

Hi,

I would like to move fields from one internal table into corresponding fields of another internal table.

move-corresponding syntax seems only to work with structures. How do you accomplish this for internal tables? Do I have to use for loops?

regards

Baran

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Oct 19, 2006 at 10:48 AM

    Hi baran,

    yes u have to use the loop.

    say one internal table is itab and the other is itab1

    also workarea are wa_tab,wa_tab1 respectively.

    Loop at itab into wa_tab.

    move-corresponding wa_tab to wa_tab1.

    append itab1 from wa_tab1.

    clear : wa_tab,

    wa_tab1.

    Endloop.

    regards,

    Nagaraj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 19, 2006 at 10:53 AM

    Yes you have to use loops and move-correspoding statements unless you have all the common fields in the same order on both internal table and no different fields to the left most.

    eg:

    data: begin of itab1 occurs 0,

    field1 type i,

    end of itab1.

    data: begin of itab2 occurs 0,

    field1 type i,

    field2(1),

    end of itab2.

    do 5 times.

    itab1-field1 = sy-index.

    append itab1.

    enddo.

    itab2[] = itab1[].

    loop at itab2.

    write:/ itab2-field1.

    endloop.

    The above code would give you some idea.

    Regards,

    ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2006 at 10:40 AM

    Loop at itab into wstab.

    move-corresponding wstab to newtab.

    append itab1 from newtab.

    Endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 19, 2006 at 10:49 AM

    loop at itab.

    move corresponding fields of itab to itab1.

    append itab1.

    clear itab1.

    endloop.

    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.