Skip to Content

Transferring of Data from One Internal Table to Another Internal Table

Dear forumers,

This is a newbie question.

form process_data.

loop at itab_1.

itab_final-matnr = itab_1-matnr.

itab_final-charg = itab_1-charg.

itab_final-vfdat = itab_1-vfdat.

COLLECT itab_final.

endloop.

loop at itab_2.

itab_final-bismt = itab_2-bismt.

itab_final-mhdrz = itab_2-mhdrz.

itab_final-meins = itab_2-meins.

COLLECT itab_final.

endloop.

loop at itab_3.

itab_final-maktx = itab_3-maktx.

COLLECT itab_final.

endloop.

loop at itab_4.

itab_final-lbkum = itab_4-lbkum.

itab_final-salk3 = itab_4-salk3.

COLLECT itab_final.

endloop.

endform.

From the debugger, ITAB_FINAL only has three fields filled up (MATNR, BISMT and MAKTX), even to the end of this form processing block. It should have more fields filled up actually.

Any idea why, and how I can correct this?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 16, 2008 at 08:36 AM

    Hi,

    Try like this.....

    loop at itab_1 into wa_itab1.

    clear : wa_itab_final.

    wa_itab_final-matnr = wa_itab1-matnr.

    wa_itab_final-charg = wa_itab1-charg.

    wa_itab_final-vfdat = wa_itab1-vfdat.

    APPEND wa_itab_final to itab_final.

    endloop.

    loop at itab_2 into wa_itab2.

    clear : wa_itab_final.

    wa_itab_final-bismt = wa_itab2-bismt.

    wa_itab_final-mhdrz = wa_itab2-mhdrz.

    wa_itab_final-meins = wa_itab2-meins.

    APPEND wa_itab_final to itab_final.

    endloop.

    loop at itab_3 into wa_itab3.

    clear : wa_itab_final.

    wa_itab_final-maktx = wa_itab3-maktx.

    APPEND wa_itab_final to itab_final.

    endloop.

    loop at itab_4 into wa_itab4.

    clear : wa_itab_final.

    wa_itab_final-lbkum = wa_itab4-lbkum.

    wa_itab_final-salk3 = wa_itab4-salk3.

    APPEND wa_itab_final to itab_final.

    endloop.

    hope it is helps

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 07:38 AM

    Hi,

    Use APPEND LINES OF command

    append lines of : itab1 to ltab_final,

    itab2 to itab_final,

    itab3 to itab_final,

    itab4 to itab_final.

    or

    append lines of itab1 to itab_final.

    append lines of itab2 to itab_final.

    append lines of itab3 to itab_final.

    append lines of itab4 to itab_final.

    hope it is helps

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Gowri,

      It doesn't work. I have the following error message in my syntax check:

      "ITAB_FINAL" and "ITAB_2" are not mutually convertible. In Unicode programs, "ITAB_FINAL" must have the same structure layout as "ITAB_2", independent of the length of a Unicode character.

      This is because ITAB_1, ITAB_2, ITAB_3, ITAB_4 and ITAB_FINAL all have different structures from one another, while APPEND requires that they all have the same structure (is this right?).

  • avatar image
    Former Member
    Sep 16, 2008 at 07:42 AM

    Hi;

    if you will use APPEND statements it will definately help you

    append lines of <source table name> to <destination table name>.

    thanks and regards

    Rahul sharma

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 16, 2008 at 07:49 AM

    Hi Deborah,

    You check first your internal table itab_fianl has all fields where u are passing ur value...

    do like this:---

    types: begin of ty_final,

    matnr TYPE matnr,

    charg TYPE ,

    vfdat TYPE ,

    bismt TYPE ,

    mhdrz TYPE

    meins TYPE

    maktx TYPE

    lbkum TYPE

    salk3 TYPE

    end of ty_final.

    DATA: it_final TYPE STANDARD TABLE OF ty_final.

    try this...and declare your internal table according to fields.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 08:28 AM

    Hi

    If you have a key field in itab1 and itab2 then you can do like this.

    append the fields normally from first table itab1 to final table.

    and try this logic to append contents from second table

    loop at itab2.

    read table itab3 with key <keyfield> = itab2-keyfield.

    move-corresponding itab2 to itab3.

    append itab3.

    endloop.

    here itab3 is final output,

    thanks,

    Usha

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 16, 2008 at 09:41 AM

    You use collect so each record what is to be added to the itab-final will be checked for the same alphadata. when you start collecting the fields for the second table your itab-final fields used in the first tabel are not cleared. so they will have the content of the last record filled in the first loop. this wil go on for each following loop you process because you use each time different fields.

    therefor you will not get the number of records you expected. first make sure the content of the four itab-tables are matched and then you write to the itab-final.

    Regards,

    Guido

    Edited by: G. Bouman on Sep 16, 2008 11:41 AM

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 17, 2008 at 08:00 AM

    Dear forumers,

    Thank you for all your inputs.

    The issue was resolved with your help, and below are the codelines used for it.

    SORT: itab_1, itab_2, itab_3, itab_4.

    LOOP AT itab_1.

    move-corresponding itab_1 to itab_final.

    read table itab_2 with key matnr = itab_1-matnr binary search.

    move-corresponding itab_2 to itab_final.

    read table itab_3 with key matnr = itab_1-matnr binary search.

    move-corresponding itab_3 to itab_final.

    read table itab_4 with key matnr = itab_1-matnr binary search.

    move-corresponding itab_4 to itab_final.

    append itab_final.

    ENDLOOP.

    Add comment
    10|10000 characters needed characters exceeded