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

Updating dynamic itab(deep) - ECC6.0

Former Member
0 Likes
977

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

1 ACCEPTED SOLUTION
Read only

arseni_gallardo
Active Participant
0 Likes
942

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.

7 REPLIES 7
Read only

arseni_gallardo
Active Participant
0 Likes
943

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.

Read only

0 Likes
942

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

Read only

0 Likes
942

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

Read only

former_member214857
Contributor
0 Likes
942

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

Read only

0 Likes
942

Thanks Carlos, much appreciated.

Read only

Former Member
0 Likes
942

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

Read only

Former Member
0 Likes
942

>

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.