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

Modify Dynamic Internal Table

Former Member
0 Likes
5,159

I need to modify a dynamic internal table, but i don't know how.

I've already built the table, but how can i access to the fields???

loop at <gt_table> assigning <wa_table>.

endloop.

1 ACCEPTED SOLUTION
Read only

former_member69765
Contributor
0 Likes
1,883

Hi ..

I do not know how you have created the dynamic internal tables...

but just for your reference ... I am giving u a piece of code ... Its quiet simple ..

Say.. You want to change the 3rd column of the table. So to read the 3rd column, I write the statement : ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs_val>.

Then on it is simple since I am using the Field symbols.

Just see in debugging mode and you will understand everything.

FIELD-SYMBOLS : <fs_table> TYPE ANY TABLE,

<fs_wa> TYPE ANY,

<fs_val> TYPE ANY.

LOOP AT <fs_table> ASSIGNING <fs_wa>.

ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs_val>.

<fs_val> = 'Test Change'.

MODIFY TABLE <fs_table> FROM <fs_wa>.

BREAK-POINT.

ENDLOOP.

Feel free to contact in case it is not clear .. I can give u another example ..

Plz reward points if this was helpful ..

5 REPLIES 5
Read only

Former Member
0 Likes
1,883

HI jose,

Just click on the below link.........

" http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm "

Here you can see the complete details of HOW TO CREATE DYANMIC INTERNAL TABLE. It is Crystal Clear.By analysing this code you get idea of solving your problem

on your own.

Hope you can understand it easily.

Reward all helpful answers.

Regards,

V.Raghavender.

Read only

Former Member
0 Likes
1,883
chk this

CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog           = it_fieldcatalog
    IMPORTING
      ep_table                  = new_table
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2.
  IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  ASSIGN new_table->* TO <it_final>.

*********CREATE WORK AREA****************************

CREATE DATA new_line LIKE LINE OF <it_final>.
  ASSIGN new_line->* TO <wa_final>.

*********INSERTTING WORK AREAR TO INTERNAL TABLE******

    INSERT <wa_final> INTO TABLE <it_final>.

*******POPULATING DATA*******************************  
  LOOP.
   
   ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
   <w_field> = '12345'.

    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
   <w_field> = '21453DD'.

   FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
    
ENDLOOP.     
Read only

athavanraja
Active Contributor
0 Likes
1,883

field-symbols: <l_field> type any .

loop at <gt_table> assigning <wa_table>.

assign component 'FIELDNAME' of structure <wa_table> to <l_field>.

if <l_field> is assigned .

<l_field> = 'some value' .

endif .

endloop.

Raja

Read only

Former Member
0 Likes
1,883

You can access the fields using

<wa_table> - field_name.

Read only

former_member69765
Contributor
0 Likes
1,884

Hi ..

I do not know how you have created the dynamic internal tables...

but just for your reference ... I am giving u a piece of code ... Its quiet simple ..

Say.. You want to change the 3rd column of the table. So to read the 3rd column, I write the statement : ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs_val>.

Then on it is simple since I am using the Field symbols.

Just see in debugging mode and you will understand everything.

FIELD-SYMBOLS : <fs_table> TYPE ANY TABLE,

<fs_wa> TYPE ANY,

<fs_val> TYPE ANY.

LOOP AT <fs_table> ASSIGNING <fs_wa>.

ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs_val>.

<fs_val> = 'Test Change'.

MODIFY TABLE <fs_table> FROM <fs_wa>.

BREAK-POINT.

ENDLOOP.

Feel free to contact in case it is not clear .. I can give u another example ..

Plz reward points if this was helpful ..