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

Data assign from one table table field to another table field

Dear Experts,\

Can I assign one table field to another table field like below.

Table1-FieldA = Table2-Fieldc.

My requirement is to assign fieldc value to fieldA.

Is it possible by the above statement or if any other ways please provide the sample code.

Kind Regards,

Ajit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on Jan 03, 2014 at 08:32 AM

    Hi ajit,

    Can u explain a bit more?

    Regards,

    Sindhuja

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 08:33 AM

    Hi Ajit,

    are you dealing with internal table, if yes you can use

    itab1 [] = itab2 []

    by this way values of table itab2 will be copies to itab1.

    If both the fields have same data types, you can copy it from one table to

    another table

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 08:34 AM

    Hi Ajit,

    If both field are same data type and length, you can insert the record using modify or update table.

    Arivazhagan S

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 08:37 AM

    Hi Ajit,

    No its not possible in the way you have specified. If the structure of both internal tables are same then use append lines of itab1 to itab2. If not then use like

    wa1 is work area with structure same as itab1 and

    wa2 is work area with structure same as itab2.

    loop at itab1 into wa1.

    wa2-field1 = wa1-field1.

    and so on.....

    append wa2 to itab2.

    endloop.

    You can use move-corresponding wa1 to wa2 as well.

    Regards,

    Sheetal.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 08:40 AM

    hi,

    its not possible. using work area r internal table u can do this.

    Regards,

    gopi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 08:40 AM

    Hi Ajit,

    You cannot assign a table field to another table field directly as you have shown.

    You have to copy the field of the first table to a work area and then copy this work area to the work area

    of the second table and modify the second table.

    eg: lt_table type table of sflight,

    lt_table1 type table of sbook,

    lx_table type sflight,

    lx_table1 type sbook.

    READ TABLE lt_table into lx_table index 1.

    lx_table1-carrid = lx_table-carrid.

    MODIFY lt_table1 from lx_table1 index 1 transporting carrid.

    Thanks and regards,

    Ashish Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 04, 2014 at 07:08 AM

    hi Ajit,

    if you are working with Internal table and both field having same data type and same length then its ok .

    other wise create 2 ztable having same structure and move value like below

    it_first1[] = it_second[].

    Thanking You,

    Shrikant

    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.