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: 

How to append row in internal table for perticular condition

Former Member
0 Kudos
1,994

Hi,

I have 4 records in my internal table and i want to append row

after second row when condition will match.

please guide me.

thanks in advancs

regards

SND

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos
299

if condition is true.

insert itab index 2.

endif.

Former Member
0 Kudos
299

hi,

U can use INDEX.

Former Member
0 Kudos
299

You can use statement:

INSERT <line> INTO <itab> [INDEX <idx>].

IF <condition>.

INSERT <line> INTO <itab> INDEX 2.

ENDIF.

Former Member
0 Kudos
299

Hi,

U can append records in between .U can only Insert records.

For that use,

if <cond>.

insert <itab> index 2.

endif.

Regards,

Padmam.

Former Member
0 Kudos
299

Hi,

Please check this :

DATA : BEGIN OF itab OCCURS 0,

num(2) TYPE p DECIMALS 2,

END OF itab.

DATA : count TYPE i.

itab-num = 1.

APPEND itab.

itab-num = 2.

APPEND itab.

itab-num = 3.

APPEND itab.

itab-num = 4.

APPEND itab.

DESCRIBE TABLE itab LINES count.

IF count = 4.

itab-num = '2.5'.

INSERT itab INDEX 3.

ENDIF.

-SatyaPriya

Former Member
0 Kudos
299

hi,

using key word INDEX u can insert a record in aspecified position as

if internal table is with header line.

INSERT <internaltable> index SY_INDEX [or index no if u know where to insert]

with out header line.

INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u know where to insert]

if condition is true.

insert itab index 2.

endif.

if helpful reward some points.

with regards,

Suresh.A