‎2014 Mar 03 3:57 PM
Hi gurus,
shortly; I need to populate a table whose elements are made as follows:
CODE TYPE MDM_FIELD_CODE (a string, basically)
VALUE TYPE REF TO DATA.
I need to loop over an item table and populate the above sketched table; so I wrote as follows:
LOOP AT lt_item INTO ls_item.
*** MDMSRM_SHORT_DESCRIPTION ***
CLEAR value_pair.
MOVE 'MDMSRM_SHORT_DESCRIPTION' to value_pair-code.
GET REFERENCE OF ls_item-short_desc INTO value_pair-value.
APPEND value_pair TO lt_value_pair.
....
ENDLOOP.
The problem is: each time the loop is performed, all the VALUE fields already appended have the value of the last iteration.
How can I overcome this problem? Is there a sort of unassignment technique for GET REFERENCE?
Thanks,
‎2014 Mar 03 4:11 PM
‎2014 Mar 03 4:11 PM
‎2014 Mar 03 4:26 PM
Thanks Raymond,
your solution solved my problem.
One more question... in that LOOP cycle, I have to build up a structure in this way:
LOOP... ASSIGNING <item>.
CLEAR ls_min_qty.
MOVE <item>-min_qty TO ls_min_qty-content.
MOVE '$$$' TO ls_min_qty-unit_code.
GET REFERENCE OF ls_min_qty INTO value_pair-value.
APPEND value_pair TO lt_value_pair.
---
ENDLOOP.
I assume this would lead to the same problem I posted above, as each GET REFERENCE of structure will overwrite previous assignments. How would you overcome this issue?
Thanks again
‎2014 Mar 04 7:34 AM
‎2014 Mar 04 8:48 AM
Had some difficulties in working with field-symbols as I have to reference to a structure which is partly derived from the workarea and partly fixed...
I did as follows, maybe it's not the best solution, however, seems to work:
FIELD-SYMBOLS <item> TYPE zsrm_cat_files_i.
FIELD-SYMBOLS: <minqty> TYPE mdm_gdt_quantity-content.
FIELD-SYMBOLS: <minqty_unit> TYPE MDM_CDT_MEASURE_UNIT_CODE.
FIELD-SYMBOLS: <minqty_struct> TYPE mdm_gdt_quantity.
DATA minimum_qty TYPE REF TO mdm_gdt_quantity
LOOP ... ASSIGNING <item>.
...
CREATE DATA minimum_qty.
ASSIGN minimum_qty->* TO <minqty_struct>.
ASSIGN COMPONENT 1 OF STRUCTURE <minqty_struct> TO <minqty>.
ASSIGN COMPONENT 2 OF STRUCTURE <minqty_struct> TO <minqty_unit>.
<minqty> = <item>-min_qty.
<minqty_unit> = '$$$'.
GET REFERENCE OF <minqty_struct> INTO value_pair-value.
APPEND value_pair TO lt_value_pair.