Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Assign component in loop

Former Member
0 Likes
2,409

HI All

I doing the following loop and the table it_mapping can be with lot of records

There is a way that i can do the loop for just the relevant field (something that similar to LOOP and Where )

since for instance table ls_mapping can be with 10000 records and in structure <ls_attributes> i have just

2 fields that are the same (the loop run dynamically since <ls_attributes> can be differnt in every run of the program )

LOOP AT it_mapping INTO ls_mapping.

    ASSIGN COMPONENT ls_mapping-target_field OF STRUCTURE <ls_attributes>

    TO <lo_attr>.

    IF sy-subrc = 0.

      <lo_attr> = ls_mapping-field_value.

    ENDIF.

  ENDLOOP.

Regards

Alex

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,472

Hi

<ls_attributes> can be different, but it_mapping seems to be a normal internal table, so why don't you do:

LOOP AT it_mapping INTO ls_mapping where ......................

Max

4 REPLIES 4
Read only

Former Member
0 Likes
1,473

Hi

<ls_attributes> can be different, but it_mapping seems to be a normal internal table, so why don't you do:

LOOP AT it_mapping INTO ls_mapping where ......................

Max

Read only

0 Likes
1,472

HI Max

Since also the table it_mapping is coming with differnt fields and differnt fields values in every run ....

Regards

Alex

Edited by: Alex Dean on Nov 24, 2010 10:45 AM

Read only

0 Likes
1,472

Hi

Yes I know it

But the structure of it_mapping is constant, probably its values can be different

Max

Read only

0 Likes
1,472

Hi friend,

here ls_mapping contains fields same fields are available to <ls_attributes> fieldsymbol

then only when pass the value to <lo_attr> then automattically value comes then u can insert into the internal table that must declare as fieldsymbol.

TYPES:BEGIN OF TY_MAPPING,

FLD1 TYPE STRING,

VAL TYPE STRING,

END OF TY_MAPPING.

DATA:LS_MAPPING TYPE TY_MAPPING,

IT_MAPPING TYPE STANDARD TABLE OF TY_MAPPING.

FIELD-SYMBOLS:<LT_ATTRIBUTES> TYPE STANDARD TYPE OF (LS_MAPPING).

ASSIGN LT_ATTRIBUTES ->* <LS_ATTRIBUTES>.

LOOP AT it_mapping INTO ls_mapping.

ASSIGN COMPONENT ls_mapping-target_field OF STRUCTURE <ls_attributes>

TO <lo_attr>.

IF sy-subrc = 0.

<lo_attr> = ls_mapping-field_value.

APPEND <LS_ATTRIBUTES> TO <LT_ATTRIBUTES>.

ENDIF.

ENDLOOP.

I think it will be excuted.

thanks&regards.

murali