Modify Syntax on Internal table of type ANY TABLE
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,
Clemens Li replied
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.