Application Development 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: 

Modify Syntax on Internal table of type ANY TABLE

Former Member
0 Kudos

Hi,

I have declared one internal table which is of type ANY TABLE.

In the Loop statement, I am trying to Modify that Internal table from WA.

Then I am getting one Error message

"You cannot use explicit or implicit index operations on tables with types "HASHED TABLE" or "ANY TABLE". "C_T_DATA" has the type "ANY TABLE".

Above code I have placed in method of a corresponding Class.

Can u please advise me on this..How to modify the Intenal table .

Thanks and Regards,

K.Krishna Chaitanya.

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Krishna,

the modify statement is obsolete.

You can always LOOP AT [itab] ASSIGNING <field-symbol>.

This makes the loop never slower, depending on the table structure faster or much faster.

If you know the table structure at run time, you can use a field-symbol of that type. If not, you can use a field-symbol TYPE any. Then you have to assign the components to field-symbol to modify them, i.e.

field-symbols:
  <table_line> type any,
  <matnr>        type mara-matnr.

loop at itab assigning  <table_line>.
  assign component 'MATNR' of structure <table_line> to <matnr>.
  clear <matnr>.
endloop.

This technique (available more than ten years) works incredibly fast. My estimate is that if SAP would change all the old standard programs that way and use it consequently in the new ones, the whole system would be 20 % faster because myriads of unnecessary copy operations of LOOP INTO would not happen.

Regards,

Clemens.

2 REPLIES 2

former_member198275
Active Contributor
0 Kudos

Hi,

Can you paste your sample code here ? How you have declared the internal table ?

Clemenss
Active Contributor
0 Kudos

Hi Krishna,

the modify statement is obsolete.

You can always LOOP AT [itab] ASSIGNING <field-symbol>.

This makes the loop never slower, depending on the table structure faster or much faster.

If you know the table structure at run time, you can use a field-symbol of that type. If not, you can use a field-symbol TYPE any. Then you have to assign the components to field-symbol to modify them, i.e.

field-symbols:
  <table_line> type any,
  <matnr>        type mara-matnr.

loop at itab assigning  <table_line>.
  assign component 'MATNR' of structure <table_line> to <matnr>.
  clear <matnr>.
endloop.

This technique (available more than ten years) works incredibly fast. My estimate is that if SAP would change all the old standard programs that way and use it consequently in the new ones, the whole system would be 20 % faster because myriads of unnecessary copy operations of LOOP INTO would not happen.

Regards,

Clemens.