2014 Aug 18 1:45 PM
Hi everyone,
I have a internal table with two columns STATE and ID, using table control user can change the id for specific state. When he press enter i want to sort the internal table by id, but when the state have id = 0 he goes to final of list.
Exemple:
STATE ID
AC 0
AM 0
PR 2
RJ 0
RS 0
SC 1
SP 3
Well, after SORT the table needs to stay:
STATE ID
SC 1
PR 2
SP 3
AC 0
AM 0
RJ 0
RS 0
Anyone can help me?
Thanks!
2014 Aug 18 1:58 PM
Have 2 ITABS.
then ITAB1[] = ITAB2[] "at this point both itabs contain:
STATE ID
AC 0
AM 0
PR 2
RJ 0
RS 0
SC 1
SP 3
now,
sort itab1 by ID STATE.
sort itab2 by ID STATE.
delete ITAB1 where ID = 0.
delete ITAB2 where ID <> 0.
append ITAB2 to ITAB1.
now your itab1 will be:
STATE ID
SC 1
PR 2
SP 3
AC 0
AM 0
RJ 0
RS 0
2014 Aug 18 1:58 PM
Have 2 ITABS.
then ITAB1[] = ITAB2[] "at this point both itabs contain:
STATE ID
AC 0
AM 0
PR 2
RJ 0
RS 0
SC 1
SP 3
now,
sort itab1 by ID STATE.
sort itab2 by ID STATE.
delete ITAB1 where ID = 0.
delete ITAB2 where ID <> 0.
append ITAB2 to ITAB1.
now your itab1 will be:
STATE ID
SC 1
PR 2
SP 3
AC 0
AM 0
RJ 0
RS 0
2014 Aug 18 2:46 PM
Genius!!!
Only thing that i need to change is put a loop into itab2 to append itab1, but your answer is right!
Thanks so much!!
2014 Aug 18 3:11 PM
happy i could help.
No loop necessary:
APPEND LINES OF ITAB2 TO ITAB1.