Application Development 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: 

Problem with assign component

Former Member
0 Kudos
122

Hi All

I have a problem with assign component

its working and when subrc = 0 it moves the value to the right

field but the problem is the in the second time (subrc = 0.)

its overite the field with wrong value

what i miss here ? i want to assign the right fiels value

to the suitable field in <ls_attr_structure>

LOOP AT it_mapping INTO ls_mapping.
      ASSIGN COMPONENT ls_mapping-target_field OF STRUCTURE <ls_attr_structure>
      TO <lv_root_attr>.
      IF sy-subrc = 0.
       <ls_attr_structure> = ls_mapping-field_value.
      ENDIF.
    ENDLOOP.

All the structure and field are type any .

Regards

Alex

Edited by: Alex Dean on Nov 17, 2010 8:43 AM

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos
84

You are assigning value to whole structure


<ls_attr_structure> = ls_mapping-field_value.

and should be only to component


   <lv_root_attr> = ls_mapping-field_value.

Regards

Marcin

2 REPLIES 2

MarcinPciak
Active Contributor
0 Kudos
85

You are assigning value to whole structure


<ls_attr_structure> = ls_mapping-field_value.

and should be only to component


   <lv_root_attr> = ls_mapping-field_value.

Regards

Marcin

Former Member
0 Kudos
84

Hi,

First time it will work fine but second time you are using the same field symbol which is holding the Previous entry. So after you check SY-SUBRC store the value some where else (Append to an internal table) then use the field symbol.

You are using the same field symbol for eack record in the LOOP and not saving that entry to any of the global variable.

Please try to save the Field symbol values to an internal table and do the coding accordingly.

Regards,

Srinivas