Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 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.