Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ABAP Short Dump on append of a sorted table

Tags:

abap

Why does my ABAP program short dump when I append a line to a sorted table?

ST22 Shows ITAB_ILLEGAL_SORT_ORDER

data: sorted_tab type sorted table of ty_tab with non-unique key key,
      line       type ty_tab.

line-key = 1. 
append line to sorted_tab.  "works fine" 

line-key = 2. 
append line to sorted_tab.  "works fine" 

line-key = 1. 
append line to sorted_tab.  "<==== Short dump here" 
like image 512
Esti Avatar asked Oct 05 '09 06:10

Esti


People also ask

Can we use APPEND in sorted table in SAP ABAP?

With a sorted table, it is not possible to use statement APPEND to add line in a table. APPEND will resquest to add the line at the end, which will perturbate the sort of table. Use statement INSERT, which will automatically manage in which index will be inserted the line.

Can we use APPEND in sorted internal table?

APPEND will adds the line to the internal table one after the other, if the sort sequence is not kept the program will dump, on sorted table should use INSERT instead of APPEND.

How do I add a new line to a sorted internal table in ABAP?

To add several lines to an internal table, use the statement: INSERT LINES OF itab1 [FROM n1] [TO n2] INTO TABLE itab2. itab1 and itab2 are tables with a compatible line type. The system inserts the lines of table itab1 one by one into table itab2 using the same rules as for single lines.

How do you fill a sorted internal table in SAP?

Only the statement APPEND with the addition SORTED BY can be used to fill the internal table.


1 Answers

The program short dumps when appending a sorted table in the wrong sort order

data: sorted_tab type sorted table of ty_tab with non-unique key key,
      line       type ty_tab.

line-key = 1.
append line to sorted_tab.  "works fine"

line-key = 2.
append line to sorted_tab.  "works fine"

line-key = 1.
append line to sorted_tab.  "<==== Short dump here"

Use INSERT in stead:

data: sorted_tab type sorted table of ty_tab with non-unique key key,
      line       type ty_tab.

line-key = 1.
insert line into table sorted_tab.  "works fine"

line-key = 2.
insert line into table sorted_tab.  "works fine"    

line-key = 1.
insert line into table sorted_tab.  "works fine"

Note If you had a UNIQUE key you would still get a short dump because you're using the same key twice

like image 120
Esti Avatar answered Oct 18 '22 06:10

Esti