2011 Sep 02 4:02 PM
Hi, I'm reading a dynamic itab in a loop using type any field symbols. This is working nicely. However I want to alter values in the dynamic internal table. How can I do this? I can extract values from the dynamic itab but cannot seem to write them back. The following is some code to demonstrate.
field-symbols: <fs_alvdata_wa> type any,
<fs_1> type any,
<fs_2> type any.
loop at <lt_alvdata> ASSIGNING <fs_alvdata_wa>.
ASSIGN COMPONENT 'SOMEFIELD' OF STRUCTURE <fs_alvdata_wa> to <fs_1>.
if <fs_1> = '1'.
<fs_1> = '2'.
endif.
*This part is missing. How do I update <fs_alvdata_wa>-'SOMEFIELD' with <fs_1>???
*This part is missing. How do I update <fs_alvdata_wa>-'SOMEFIELD' with <fs_1>???
modify <lt_alvdata> FROM <fs_alvdata_wa>.
endloop./Thanks in advance,
Kevin
2011 Sep 02 4:49 PM
Kevin,
As you are working with field symbols you do not have to use MODIFY at all. When you modify the value of <fs_1> you are already modifying the internal table.
Kevin,
As you are working with field symbols you do not have to use MODIFY at all. When you modify the value of <fs_1> you are already modifying the internal table.
2011 Sep 02 4:49 PM
Kevin,
As you are working with field symbols you do not have to use MODIFY at all. When you modify the value of <fs_1> you are already modifying the internal table.
2011 Sep 03 3:43 AM
Hi Arseni, thanks much for your response. When I do this, change the value of <fs_1>, it is not changing the value in the internal table. Am I missing something?
Kevin
2011 Sep 07 2:24 AM
Ooops, I saw my problem. It was during my debug session, you are right it was changing the value in the internal table, like an idiot I was looking at another variable.
Thanks much,
Kevin
2011 Sep 03 8:44 PM
Hello Kevin
You can try code below as a sample:
FIELD-SYMBOLS: <lt_alvdata> TYPE ANY TABLE,
<fs_alvdata_wa> type any,
<fs_1> type any,
<fs_2> type any.
DATA:
BEGIN OF t_month OCCURS 0,
month(10) TYPE c,
END OF t_month.
ASSIGN t_month[] TO <lt_alvdata>.
t_month-month = 'January'. APPEND t_month.
t_month-month = 'February'. APPEND t_month.
t_month-month = 'March'. APPEND t_month.
loop at <lt_alvdata> ASSIGNING <fs_alvdata_wa>.
ASSIGN COMPONENT 'MONTH' OF STRUCTURE <fs_alvdata_wa> to <fs_1>.
IF sy-subrc EQ 0.
<fs_1> = '123'.
ENDIF.
endloop.Best regards
2011 Sep 07 2:22 AM
2011 Sep 07 6:14 AM
Hi
U can pass the below 2 values into some varible otherwise u can takb one temprary variable and pass the '2' value into
that varible.
if <fs_1> = '1'.
<fs_1> = '2'. "or VAR1 = <FS_1>
<fs_alvdata_wa>-'SOMEFIELD' = <fs_1>. "OR = VAR1
modify <lt_alvdata> FROM <fs_alvdata_wa> INDEX SY-TABIX.
endif.
Regards,
muralii
2011 Sep 07 11:04 AM
>
field-symbols: <fs_alvdata_wa> type any, > <fs_1> type any, > <fs_2> type any. > > loop at <lt_alvdata> ASSIGNING <fs_alvdata_wa>. > > ASSIGN COMPONENT 'SOMEFIELD' OF STRUCTURE <fs_alvdata_wa> to <fs_1>. > > if <fs_1> = '1'. > <fs_1> = '2'. > endif. > > *This part is missing. How do I update <fs_alvdata_wa>-'SOMEFIELD' with <fs_1>??? > > *This part is missing. How do I update <fs_alvdata_wa>-'SOMEFIELD' with <fs_1>??? > > modify <lt_alvdata> FROM <fs_alvdata_wa>. > > endloop./>
> Thanks in advance,
>
> Kevin
We can use append statement. No need to use the modify statement.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |