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

copying internal table

hi,

iam having two internal tables itab1 and itab2.i have to copy contents of table itab1 to itab2 and delete the duplicate entries in itab2.

please provide the code for this.

thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Nov 21, 2007 at 02:25 PM

    If you have defined your tales with the OCCURS 0.

    data: itab1 like mara occurs 0 with header line,
    itab2 like mara occurs 0 with header line.
    itab1[] = itab2[].
    sort itab2.
    delete adjacent duplicates from itab2.

    If you have defined tables with the types than:

    data: itab1 type standard table of mara ,
    itab2 type standard table of mara .
    itab1 = itab2.
    sort itab2.
    delete adjacent duplicates from itab2.

    Regards,

    Naimesh Patel

    Message was edited by:

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 02:28 PM

    Hi Surya,

    itab2[] = itab1[].

    or

    Loop at itab1.

    move-corresponding itab1 to itab2.

    append itab2.

    Endloop.

    Note : Ensure that two internal tables must contains the same structure.

    Delete duplicate values :

    DELETE ADJACENT DUPLICATES FROM ITAB.

    Thanks,

    Reward If Helpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 02:28 PM

    Hi,

    You have the copy the values of itab1 to itab2 as below :

    itab2[] = itab1[]

    or

    append lines of itab1 to itab2.

    To delete the duplicate entries.

    sort itab --> Sort the itab with necessary fields.

    delete adjacent duplicates from itab comparing <fieldnames>.

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 02:37 PM

    Hi,

    Make sure itab1 & itab2 are of same structure.

    itab2[] = itab1[].

    delete adjacent duplicates from itab2.

    Bye,

    kc

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 02:43 PM

    Hi,

    Do like this

    itab2[] = itab1.

    sort itab2 by key field.

    delete adjacent duplicates from itab2 comparing keyfield.

    Regards,

    Satish

    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.