Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Change Internal table location ...

Former Member
0 Likes
1,682

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 .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,602

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 .

13 REPLIES 13
Read only

Former Member
0 Likes
1,602

Hi,

Can you please elaborate your question? Its not clear from what you have mentioned.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,602

sort field1 ascending.

i think ths was ur Qn

Read only

Former Member
0 Likes
1,602

Dear All ..

Now i want everytime when i run things program , the No 20 always at second place .... cnt at 1st or others .

THanks

Read only

0 Likes
1,602

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

Read only

0 Likes
1,602

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

Read only

Former Member
0 Likes
1,602

sort itab by field1 ascending.

Read only

Former Member
0 Likes
1,603

i think cnt sort it ....... bc if sort , the 20 will go to top ...

Read only

0 Likes
1,602

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

Read only

0 Likes
1,602

Hi,

If you use


sort itab with field1 ascending

20 will come to the second place if there only one value less than 20.

Read only

0 Likes
1,602

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.

Read only

Former Member
0 Likes
1,602

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 ......

Read only

0 Likes
1,602

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.

Read only

0 Likes
1,602

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