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

internal tables - sorted table

Former Member
0 Likes
1,084

hi experts,

if am inserting records in a sorted table like

field1 field2

1 4

3 7

4 6

using append statement.

Then if i append 2 8 to the table,

what will happen?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
827

Hi,

Its a sorted table. Now you are going to break the order of the Sorted Table.

So it will gives the Error.

Thanks,

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

7 REPLIES 7
Read only

Former Member
0 Likes
827

Hi

it will be added after 1 2

as a second record since it is a sorted table

Regards

Anji

Read only

JozsefSzikszai
Active Contributor
0 Likes
827

hi Shori,

your table will look like:

field1 field2

1 4

2 8

3 7

4 6

this is what sorted tables are about, if you use unsert records will be inserted into the table acc. to sort key automatically.

hope this helps

ec

Read only

Former Member
0 Likes
828

Hi,

Its a sorted table. Now you are going to break the order of the Sorted Table.

So it will gives the Error.

Thanks,

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
827

But am using append statement.

Append statement always inserts at the last index is it?

Read only

Former Member
0 Likes
827

Hi Shori,

Sorted table will sort the records based on the kay fields.

First it will sort based on the first key field. second preference for second key field like that.

Read only

varma_narayana
Active Contributor
0 Likes
827

Hi Shori..

In sorted Table you have to use the Command INSERT (without index) to add the records.

Then the records are INSERTED in the Sorted order as per the key fields.

Using APPEND may give dump if the Sort key is voilated .

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
827

Hi,

This is lead to ABAP dump ITAB_ILLEGAL_SORT_ORDER.

Becasue whenever an append statement is triggered table will sorted. This will lead to ABAP dump. To overcome this declare a standard internal table and append all the values and sort the table based on the key. Then pass the values to Sorted table.

Thanks,

Sriram Ponna.