2009-10-05 7 views
7

Warum wird mein ABAP-Programm kurz abbrechen, wenn ich eine Zeile an eine sortierte Tabelle anfüge?ABAP Short Dump beim Anhängen einer sortierten Tabelle

ST22 Zeigt 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" 
+0

Das ist wie eine dumme Frage scheint - aber ich habe gerade genug Zeit, um die Antwort zu speichern die verschwendete Nächste Person ein wenig Kummer. (Google war hilfreich, SAP-Hilfe war nicht) – Esti

+2

Bitte geben Sie die Deklaration Ihrer sortierten Tabelle an! – Thorsten

+0

guter Punkt - als ob Ihre Tabelle mit einem eindeutigen Schlüssel deklariert wäre, würden Sie noch einen weiteren kurzen Dump bekommen – Esti

Antwort

13

Das Programm Kurzdumps wenn eine sortierte Tabelle in der falschen Reihenfolge, um

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" 

Verwendung INSERT anstelle anhängt:

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" 

Hinweis Wenn Sie hatte eine UNIQUE Schlüssel Sie noch einen kurzen Dump erhalten würde, weil man mit dem gleichen Schlüssel sind zweimal