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: 

ABAP insert rule

Former Member
0 Kudos
102

hi

I have 4 records in my internal table, i want to insert a record at index 3. what is the syntax?please suggest.

Thanks,

Sumera.

4 REPLIES 4

Former Member
0 Kudos
73

inset from wa index i.

Sameer

Former Member
0 Kudos
73

<b>loop at itab.

if sy-tabix eq 3.

insert <something> into itab.

endif.

endloop.</b>

-


Here is another example....

DATA: int TYPE i,

dref TYPE REF TO i.

DATA: int_tab LIKE STANDARD TABLE OF int,

ref_tab LIKE HASHED TABLE OF dref

WITH UNIQUE KEY table_line.

DO 10 TIMES.

INSERT sy-index

INTO int_tab INDEX 1

REFERENCE INTO dref.

INSERT dref

INTO TABLE ref_tab.

ENDDO.

LOOP AT int_tab INTO int.

WRITE / int.

ENDLOOP.

SKIP.

LOOP AT ref_tab INTO dref.

WRITE / dref->*.

ENDLOOP.

Regards,

Pavan

Former Member
0 Kudos
73

Hi Sumera,

you can use the following syntax

Loop at itab.

if sy-tabix = 3.

*here you can use the lock F.M for better coding standards

call function 'Enque_ .....'

insert into table from itab.

if sy-subrc = 0.

call function 'Deque_......'

Exit.

endif.

Endloop.

Former Member
0 Kudos
73

Hi sumera shireen ,

Welcome to SDN.

I hope this site helps you a lot.

Here is the complete code:

REPORT z_test_1.

data:

begin of fs_data,

f1 type c,

f2 type i,

end of fs_data.

data:

t_data like standard table of fs_data.

data:

fs_temp like fs_data.

fs_data-f1 = 'a'.

fs_data-f2 = 1.

append fs_data to t_data.

fs_data-f1 = 'b'.

fs_data-f2 = 2.

append fs_data to t_data.

fs_data-f1 = 'c'.

fs_data-f2 = 3.

append fs_data to t_data.

fs_data-f1 = 'd'.

fs_data-f2 = 4.

append fs_data to t_data.

read table t_data index 3 into fs_temp.

delete t_data index 3.

fs_data-f1 = 'e'.

fs_data-f2 = 5.

insert fs_data into t_data index 3.

insert fs_temp into t_data index 4.

Regards,

Rama.Pammi