Application Development 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: 

experts plz do smthng help me

Former Member
0 Kudos

i have an internal table itab

which contains22 rows now i want to exchange the position of row no 22 with row p

plz write the code 4 it

plz help me

thanx in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

read table itab into wa1 index 22.

read table itab into wa2 index p.

w = wa1.

wa1 = wa2.

wa2 = w.

modify itab by wa1.

modify itab by wa2.

Reward if useful!

10 REPLIES 10

Former Member
0 Kudos

Hi,

read table itab into wa1 index 22.

read table itab into wa2 index p.

w = wa1.

wa1 = wa2.

wa2 = w.

modify itab by wa1.

modify itab by wa2.

Reward if useful!

0 Kudos

hi

thanx 4 ur rply

but it is saying unable to interpret <b>by</b> in modify.

0 Kudos

use <b>FROM</b> not <b>BY</b>

Former Member
0 Kudos

I think the code below will help u..

check it .. some modification may be required.. let me know it helps u..

<b>

DATA: BEGIN OF itab OCCURS 0,

fld TYPE i,

END OF itab,

wa LIKE LINE OF itab.

FIELD-SYMBOLS: <fs_wa> LIKE itab.

INITIALIZATION.

DO 22 TIMES.

wa-fld = sy-index.

APPEND wa TO itab.

ENDDO.

START-OF-SELECTION.

LOOP AT itab ASSIGNING <fs_wa>.

READ TABLE itab INTO wa INDEX 22.

MODIFY itab INDEX 22 FROM <fs_wa>.

<fs_wa> = wa.

ENDLOOP.</b>

Reward points if useful

regards

Prax

former_member223537
Active Contributor
0 Kudos

MODIFY ITAB FROM WA.

0 Kudos

Hello ,

Check this code :


DATA: BEGIN OF itab OCCURS 0,
        f1,
        f2,
      END OF itab.
DATA: wa_tab LIKE LINE OF itab.
DATA: wa_tab1 LIKE LINE OF itab.


wa_tab-f1 = '1'.
wa_tab-f2 = '2'.
APPEND wa_tab TO itab.
CLEAR wa_tab.

wa_tab-f1 = 'A'.
wa_tab-f2 = 'B'.
APPEND wa_tab TO itab.
CLEAR wa_tab.

wa_tab-f1 = '3'.
wa_tab-f2 = '4'.
APPEND wa_tab TO itab.
CLEAR wa_tab.


wa_tab-f1 = 'C'.
wa_tab-f2 = 'D'.
APPEND wa_tab TO itab.
CLEAR wa_tab.

wa_tab-f1 = '5'.
wa_tab-f2 = '6'.
APPEND wa_tab TO itab.
CLEAR wa_tab.

LOOP AT itab INTO wa_tab.
  WRITE:/ wa_tab-f1,
          wa_tab-f2.
ENDLOOP.

READ TABLE itab INTO wa_tab INDEX 3.

IF sy-subrc = 0.
  READ TABLE itab INTO wa_tab1 INDEX 5.
  CLEAR wa_tab1.
  wa_tab1 = wa_tab.
  MODIFY itab FROM wa_tab1 INDEX 5.
ENDIF.

WRITE:/ '*********************************************'.

LOOP AT itab INTO wa_tab.
  WRITE:/ wa_tab-f1,
          wa_tab-f2.
ENDLOOP.

Regards,

Deepu.K

0 Kudos

bro thanx 4 rply

it is helpful

but what it is doin it is deleting the entry at 5th position and replacing it with entry at index 22

i want to insert the entry at index 22 to the index 5.

plz help me

reward points will b awarded

Former Member
0 Kudos

check this



tables : mara.
data : begin of itab occurs 0,
       matnr like mara-matnr,
       matkl like mara-matkl,
       end of itab.
data : wtab like itab.
select matnr mtart into table itab from mara up to 22 rows.

read table itab into wtab index 22.

insert  wtab into itab index 5.

delete itab index 23.

loop at itab.
write : / itab-matnr, itab-matkl.
endloop.

regards

shiba dutta

Former Member
0 Kudos

Hi,

please check this :

data : begin of itab occurs 0,

field(1),

end of itab.

data wa like itab-field.

data n type i.

data idx type i value 2.

*ITAB contains :

*A

*B

*C

move 'A' to itab-field.

append itab.

move 'B' to itab-field.

append itab.

move 'C' to itab-field.

append itab.

*Getting index of last entry from ITAB

describe table itab lines n.

*Reading last entry of ITAB

read table itab index n into wa.

*Inserting it to wished position

insert wa into itab index idx.

*Deleting last entry (don't forget to increment the index as there is 1 more entry in ITAB now)

n = n + 1.

delete itab index n.

*ITAB now contains

*A

*C

*B

loop at itab.

write 😕 itab-field.

endloop.

Former Member
0 Kudos

thank u all u guys r experts

thank u very much