2009 Jul 30 6:14 AM
Dear All ..
Do any one how to change the internal table location ??? Example,
Itab A.
from -
> become
item item
-
-
10 10
10 20
10 10
20 10
i want move the item 20 to second place ... any idea... except the using Looping ..
Thanks .
2009 Jul 30 6:25 AM
i think cnt sort it ....... bc if sort , the 20 will go to top ...
Dear All ..
Do any one how to change the internal table location ??? Example,
Itab A.
from -
> become
item item
-
-
10 10
10 20
10 10
20 10
i want move the item 20 to second place ... any idea... except the using Looping ..
Thanks .
2009 Jul 30 6:15 AM
Hi,
Can you please elaborate your question? Its not clear from what you have mentioned.
2009 Jul 30 6:18 AM
2009 Jul 30 6:21 AM
Dear All ..
Now i want everytime when i run things program , the No 20 always at second place .... cnt at 1st or others .
THanks
2009 Jul 30 8:28 AM
Hi,
Here's my take:
DATA: BEGIN OF ITAB OCCURS 0,
item1(10) type c,
item2(10) type c,
end of itab.
data: BEGIN OF itab2 OCCURS 0,
item1(10) type c,
item2(10) type c,
end of itab2.
itab-item1 = '10'.
itab-item2 = '10'.
append itab.
itab-item1 = '20'.
itab-item2 = '10'.
append itab.
itab-item1 = '10'.
itab-item2 = '10'.
append itab.
itab-item1 = '10'.
itab-item2 = '10'.
append itab.
itab2[] = itab[].
DELETE ADJACENT DUPLICATES FROM ITAB2 COMPARING item1.
modify table itab2.
INSERT LINES OF itab from 4 INTO table itab2.
loop at itab2.
write:/ itab2-item1, itab2-item2.
endloop.thanks\
Mahesh
2009 Jul 30 10:49 AM
Hi ,
Creat an another internal table for temporary
Try this code.
itab
itab1 is the same structure of itab
loop at itab.
cnt = 2.
ind = 1.
if sy-tabix = '2'.
read table itab with key <fieldname> = '20'.
move corresponding itab to itab1.
else.
move corresponding itab to itab1.
endif.
append itab1.
endloop.
delete adjacent duplicates from itab1.
Regards,
John Victor
2009 Jul 30 6:21 AM
2009 Jul 30 6:25 AM
i think cnt sort it ....... bc if sort , the 20 will go to top ...
2009 Jul 30 6:28 AM
Use modify stmt.
wa-field1 = 20.
Modify itab INDEX 2 FROM wa transporting field1
Edited by: ShreeMohan Pugalia on Jul 30, 2009 7:28 AM
2009 Jul 30 6:29 AM
Hi,
If you use
sort itab with field1 ascending
20 will come to the second place if there only one value less than 20.
2009 Jul 30 6:33 AM
Hi,
You can create another itab and populate it in such a way that the field in second place has 20 and use
MOVE itab1-field TO itab2-field.
Thanks,
Sri.
2009 Jul 30 6:30 AM
ya .. u r right ...... but my 3rd n 4th value , also same with 1st value are 10 ...
if we use sort ........ will become 10 10 10 20 rite ?
my case is : 10 20 10 10 ......
2009 Jul 30 6:36 AM
Read the field value for second index and store it in one variable.
Modify field value of second index by 20.
and replace the value stored in variable where actually 20 is there.
2009 Jul 30 6:36 AM
Hi,
In that case i dont think it is possible to make it work without looping. You can try this way
v_index = '2'.
loop at itab.
if itab-field1 = '20'.
move-corresponding itab to wa_itab.
endif.
endloop.
delete itab where field1 = '20'.
insert wa_itab into itab index v_index.
Regards,
Vik
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |