Skip to Content
author's profile photo
Former Member

Looping in internal table

Hello Friends,

I am copying some values from one internal table to a structure. Now problem is that, I just filled some fields of the structure not all. E.g I am not filling the field Ist, but 2nd and 3rd. But in the end, it will put some value of my 2nd field into 1st field ( in structure ) and the value of 3rd comes in 2nd and so on ....

It would be nice if some one helps me out, in solving this issue ?

Thanks in advance...

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Oct 04, 2005 at 11:52 AM

    hai,

    what you can do is you can make use of move-corresponding command , this command will move the fields with same values to the fields of same name.

    remember the source and destination fieldname s should be same , even if the number of fields or different.

    syntax

    move-corresponding <itab1> to <itab2>

    any doubtds pls come back

    cheers

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 04, 2005 at 11:52 AM

    hi,

    try with into corresponding fields

    or use transporting

    read table itab into wa_1 with key ..... transporting field1 field2.

    cheers,

    sasi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 04, 2005 at 11:57 AM

    Hi

    You can use field-symbols:

    data: struct1 like ...

    struct2 like sturct1.

    data: index1 type i,

    index2 type i.

    field-symbols: <field_in> type any,

    <field_out> type any.

    Loop at itab.

    move: itab-field1 to struct1-field1,

    ............

    ............

    ............

    move struct1 to strcut2.

    index1 = 1.

    do.

    index1 = index1 + 1.

    assign component index2 of strct2 to <field_in>.

    if sy-subrc <> 0. exit. endif.

    index2 = index1 - 1.

    assign component index1 of struct1 to <field_out>.

    <field_out> = <field_in>.

    enddo.

    endloop.

    Max

    Add comment
    10|10000 characters needed characters exceeded