‎2008 Dec 17 6:08 PM
Hi there,
how can I use the APPEND LINES statment with sorted tables? Is this possible???
Kind regards
Max
‎2008 Dec 17 6:15 PM
Below is F1 help Of Append Lines:
"Appending square numbers to a "sorted table" with elementary row type.
DATA: int TYPE i,
itab LIKE SORTED TABLE OF int
WITH UNIQUE KEY table_line.
DO 10 TIMES.
int = sy-index ** 2.
APPEND int TO itab.
ENDDO.
‎2008 Dec 17 6:13 PM
‎2008 Dec 17 6:15 PM
Below is F1 help Of Append Lines:
"Appending square numbers to a "sorted table" with elementary row type.
DATA: int TYPE i,
itab LIKE SORTED TABLE OF int
WITH UNIQUE KEY table_line.
DO 10 TIMES.
int = sy-index ** 2.
APPEND int TO itab.
ENDDO.
‎2008 Dec 17 8:35 PM
Amit: the above example from you works, but the only reason for that is that the rows are appended according to the sort sequence (APPEND adds the line to the internal table one after the other). Once the sort sequence is not kept, the program will dump. An example to understand better:
Here the dump is acc. to the sort sequence, so it works:
APPEND 1.
APPEND 2.
APPEND 3.Here the sort sequence is not kept:
APPEND 1.
APPEND 3.
APPEND 2. "this will dump at this lineAs Jerry suggested already INSERT has to be used in case of SORTED (and HASHED) tables.
‎2008 Dec 17 9:06 PM
Hi Eric,
Agreed.
But If this is the Case you would get Dump With Insert Also.
APPEND 1.
APPEND 3.
APPEND 2. "Dump ITAB_ILLEGAL_SORT_ORDER
‎2008 Dec 17 9:15 PM
It works ok for me.
REPORT zztemp.
TYPES: BEGIN OF intline,
int TYPE i.
TYPES: END OF intline.
DATA: intline TYPE intline,
itab LIKE SORTED TABLE OF intline WITH UNIQUE KEY int.
intline-int = 3.
INSERT intline INTO TABLE itab.
intline-int = 5.
INSERT intline INTO TABLE itab.
intline-int = 1.
INSERT intline INTO TABLE itab.
intline-int = 2.
INSERT intline INTO TABLE itab.
LOOP AT itab INTO intline.
WRITE:/ intline-int.
ENDLOOP.
‎2008 Dec 17 9:36 PM
>
> But If this is the Case you would get Dump With Insert Also.
>
APPEND 1. > APPEND 3. > APPEND 2. "Dump ITAB_ILLEGAL_SORT_ORDER
with simply INSERT ... INTO yes, but the correct syntax is INSERT ... INTO TABLE (I did not mention in my first reply, sorry)
‎2008 Dec 17 9:48 PM
‎2010 Aug 06 10:01 AM
I got the same issue.
With this code I got ITAB_ILLEGAL_SORT_ORDER
LOOP AT from_table INTO l_from.
READ TABLE to_table INTO l_to
WITH KEY thekey = ...
BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE sy-tabix TO l_index.
ADD l_from-volume TO l_to-volume.
MODIFY to_table INDEX l_index
FROM l_to
TRANSPORTING volume.
ELSE.
MOVE l_from TO l_to.
MOVE ... TO l_to-....
APPEND l_to TO to_table.
ENDIF.
ENDLOOP. " from_tableI replaced APPEND with INSERT and I got TABLE_ILLEGAL_STATEMENT
LOOP AT from_table INTO l_from.
READ TABLE to_table INTO l_to
WITH KEY thekey = ...
BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE sy-tabix TO l_index.
ADD l_from-volume TO l_to-volume.
MODIFY to_table INDEX l_index
FROM l_to
TRANSPORTING volume.
ELSE.
MOVE l_from TO l_to.
MOVE ... TO l_to-....
INSERT l_to INTO to_table.
ENDIF.
ENDLOOP. " from_tablewtf ?
Help !
‎2015 Mar 31 2:35 PM