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

runtime error in sorted itab

Former Member
0 Likes
1,430

Q2]] A runtime error occurs if you violate the sort order of a sorted table by appending to it -


WHY?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,300

Hi,

First of all you should try and understand the meaning of Append and Insert.

Append always adds a new line to the end of the internal table.If the table is empty,then it would add it as the first line.

Insert always inserts the row according to the sorting or if you have given any condition then accordingly.

Modify can play the role of either the Append or Insert depending on the type of the table.

Hence,if you try to use Append in a sorted table, it adds a new row at the end of the table and disturbs the sorting.Insert on the other hand includes the row at a place according to the sorting.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

8 REPLIES 8
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,300

hi,

APPEND always try to add new line to internal table as last line. If that is not according to the sort order ==> dump ocurs. You have to use INSERT wa INTO TABLE itab when adding new lines to SORTED internal table.

hope this helps

ec

Read only

Former Member
0 Likes
1,300

do this mean insert does auto-sorting?

Read only

0 Likes
1,300

yes, insert adds row at appropriate location

Read only

Former Member
0 Likes
1,301

Hi,

First of all you should try and understand the meaning of Append and Insert.

Append always adds a new line to the end of the internal table.If the table is empty,then it would add it as the first line.

Insert always inserts the row according to the sorting or if you have given any condition then accordingly.

Modify can play the role of either the Append or Insert depending on the type of the table.

Hence,if you try to use Append in a sorted table, it adds a new row at the end of the table and disturbs the sorting.Insert on the other hand includes the row at a place according to the sorting.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

Read only

0 Likes
1,300

Modify can play the role of either the Append or Insert depending on the type of the table.

How would modify play the role?

Read only

Former Member
0 Likes
1,300

How would modify play the role?

Read only

Former Member
0 Likes
1,300

Modify plays the role of either the append or insert only when we are dealing with the database tables.

If you try to use modify with the Transparent table ,then it would append the data if data does not exist already in the table OR if it already exists,then it will update the entries of that row with the data that you want it to have.

And if you use Insert with the Sorted tables,then the data would be inserted at the correct sorted place in the table.

I guess,you might have got my point by now.

And if you still have any clarifications regarding this,it's better if you read help.sap.com and get it cleared.

Regards,

Puneet Jhari.

Read only

0 Likes
1,300

thanks everyone