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: 

Inserting at a particular position in an itab

Former Member
0 Kudos

Hi all.

Have a internal table as follows:

TYPES:BEGIN OF gty_kopfitab,
 MATNR TYPE mara-MATNR,
 maktx TYPE makt-maktx,
 MTART TYPE mara-MTART,
 loekz TYPE stko-loekz,
 datuv TYPE stko-datuv,
 compMatnr type mara-MATNR,
 compmaktx type  makt-maktx,
 warengruppe type mara-matkl,
 ERSKZ type stpo-erskz,
 posnr type stpo-posnr,
 menge type stpo-menge,
 ME type stpo-meins,
END OF gty_kopfitab.

types: tt_kopfitab TYPE TABLE OF gty_kopfitab.
data gt_kopfitab type tt_kopfitab WITH HEADER LINE.

After I have filled the "gt_kopfitab" I have to insert some new lines at a particular position in the internal table.

For Eg.- If the internal table has an entry as follows, I have to insert some more lines after the following line OR "MATNR" in the internal table.

MATNR maktx MTART POSNR CompMatNr

2100030931 EPS/PDF/Liz. Col.C WVF 0010 2100027625

How could I do that.

Thanks

K

1 ACCEPTED SOLUTION

former_member386202
Active Contributor
0 Kudos

Hi,

Use INSERT Statement with INDEX.

Regards,

Prashant

5 REPLIES 5

former_member386202
Active Contributor
0 Kudos

Hi,

Use INSERT Statement with INDEX.

Regards,

Prashant

0 Kudos

Tried something as follows,but not working

kopfindex = SY-TABIX.

INSERT wa_kopfitab into TABLE gt_kopfitab index kopfindex.

Edited by: Kohinoor72 on Sep 14, 2010 10:28 AM

0 Kudos

Hi,

Just hit F1 on the INSERT statement & you will get the help.

Regards

Abhii

0 Kudos

Hi,

Try to add one counter in your internal table structure. Just give 10,20,30 etc for each records in your internal table.

For ex, your requirement is you need to add the record at the 5th position, just read the 4th record and and increment the counter by 1. So your counter variable will have 41, add this in your work area and insert it in your internal table.Finally sort your internal table with counter ascending. Now you can see your new record will be in the 5th place as per your requirement.

0 Kudos

Thanks all...