‎2009 Jul 08 9:27 AM
Hello everyone,
I'm a BW-guy with some ABAP background, but it has been a while since I've used field symbos. I'm writing an enhancement for a BI-extractor using a badi. This is the situation:
I have a dynamic table <t_data> over which I need to loop to change data. The fields I need to change are in another table, t_fields. I've written the following code, but in <fieldname>, I get the value of temp instead of the value in <s_data>-fieldname.
-
LOOP AT <t_data> INTO <s_data>.
LOOP AT t_fields INTO s_fields.
concatenate '<s_data>-' s_fields-fieldname into temp.
ASSIGN temp TO <fieldname>.
ENDLOOP.
ENDLOOP.
-
for example a possible result is:
<fieldname> = '<s_data>-calday' in stead of '01.01.2009'
Can anyone tell me what I've been doing wrong? Your help is greatly appreciated.
‎2009 Jul 08 9:37 AM
Hi,
Try this
LOOP AT <t_data> INTO <s_data>.
LOOP AT t_fields INTO s_fields.
assign component s_fields-fieldname of structure <s_data> to <fieldvalue>.
<fieldvalue> = "...here <fieldvalue> should have '01.01.2009'
ENDLOOP.
ENDLOOP.
Regards
Marcin
‎2009 Jul 08 9:37 AM
Hi,
Try this
LOOP AT <t_data> INTO <s_data>.
LOOP AT t_fields INTO s_fields.
assign component s_fields-fieldname of structure <s_data> to <fieldvalue>.
<fieldvalue> = "...here <fieldvalue> should have '01.01.2009'
ENDLOOP.
ENDLOOP.
Regards
Marcin
‎2009 Jul 08 9:52 AM
Thanks Marcin,
This is exactly what I wanted to do.
Abhilash and Sourav, thanks for your replies as well. I've assigned points
‎2009 Jul 08 9:37 AM
Hi,
You are assinging to the temp.
BUt after that modify the main internal table by trtansporting the field which you have changed.
then only it will be updated.
Please revert for any help.
Regards
Abhilash.
‎2009 Jul 08 9:45 AM
Hi,
Please let me know if I am clear on this.
You have two internal tables, itab1 and itab2. You would like to change the value of field (say fld1) in itab1. This fld1 value is available from fld in itab2.
If this is the situation, following is the code.
FIELD-SYMBOLS: <w_tab1> TYPE ty_tab1.
DATA: w_tab2 TYPE ty_tab2.
LOOP AT itab1 ASSIGNING <w_tab1>.
READ TABLE itab2 into w_tab2 WITH KEY
fldkey = <w_tab1>-fldkey.
IF sy-subrc EQ 0.
<w_tab1>-fld1 = w_tab2-fld.
ENDIF.
ENDLOOP.This is it. Table itab1 will be changed.
Let me know if this works or if your issue is different.
Regards,
Sourav
Edited by: Sourav1233 on Jul 8, 2009 2:15 PM