Remember when doing a sorted table insert you should use the INSERT ABAP statement instead of APPEND, but maybe you have done this but you are getting a TABLE_ILLEGAL_STATEMENT short dump. Even though when you perform an ABAP syntax check you don’t get any error!
Does your code look something like this
INSERT wa_tab into it_tab. ???
You have probably also tried
APPEND wa_tab to it_tab and it works fine!!
So what is wrong? well, it’s something very simple…. you should basically use “INTO TABLE” instead of just “INTO” when appending new entries to a SORTED table.
INSERT wa_tab into TABLE it_tab.
Give this a try and it should now work.
Here are the full details of the error I was getting before I added the into TABLE
You attempted to change, delete or create a line in the
internal table “\PROGRAM=ZMYPROGRAM\DATA=IT_DATA”, but no valid
for the table.
1. The relevent ABAP/4 statement does not include the addition
“…INDEX…”, although the statement is not
inside a “LOOP…ENDLOOP” loop processing this table.
2. The relevent ABAP/4 statement was called from within a
“LOOP…ENDLOOP” loop after a DELETE