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

dynamically inserting new line in Internal table

Former Member
0 Likes
668

Hi,

Can anyone help me how to insert a new line dynamically to the internal table.

Assume there are 5 records that has been added to ITAB.

In that if a particular field in that ITAB crosses the limit 10 then i have to split that line into two lines with the same data except that Par.field as 5 and the other record has 5.

In the third record that particular field has value 10.

Loop at ITAB.

Once i found that field has 10 then how to insert a new line dynamically over here to add another record.

endloop.

5 REPLIES 5
Read only

Former Member
0 Likes
584

Hi Joseph..

Are you looking at this type of code.

<b>

Data:

Begin of itab occurs 0,

f1 type i,

f2 type i,

f3 type i,

end of itab,

w_temp type i.

Loop at itab.

if itab-f3 GE 10.

w_temp = itab-f3 - 5.

itab-f3 = 5.

modify itab.

itab-f3 = w_temp.

insert itab index sy-tabix.

endif.

endloop. </b>

If it helps Reward with points

Regards Rk

Read only

Former Member
0 Likes
584

Hi..

Hi..

try this..

loop at itab.

if ( i found that field <f1> has 10 ).

w_line2 = itab-f1+5(5).

w_line3 = itab-f1.

***********First line********

itab-f1 = itab-f1+0(5).

modify itab index sy-tabix from itab transporting f1.

***********second line******** Hi..

try this..

loop at itab.

if ( i found that field <f1> has 10 ).

w_line2 = itab-f1+5(5).

w_line3 = itab-f1.

***********First line********

itab-f1 = itab-f1+0(5).

modify itab index sy-tabix from itab transporting f1.

***********second line********

itab-f1 = w_line2.

insert itab INDEX SY-TABIX.

**********third line**************

itab-f1 = w_line3.

insert itab INDEX SY-TABIX.

endloop.

itab-f1 = w_line2.

insert itab INDEX SY-TABIX.

**********third line**************

itab-f1 = w_line3.

insert itab INDEX SY-TABIX.

endloop.

Read only

Former Member
0 Likes
584

Hi !!

Your requirement is ideal to use the Function Module : RKD_WORD_WRAP .

Here you can specify the no of characters to which you want to split a given line . Even it takes care if a particular word i getting broken in between it is carried forward to the next line.

please have a look and let me know .

Read only

Former Member
0 Likes
584

Hi !!

Your requirement is ideal to use the Function Module : RKD_WORD_WRAP .

Here you can specify the no of characters to which you want to split a given line . Even it takes care if a particular word i getting broken in between it is carried forward to the next line.

please have a look and let me know .

Read only

Former Member
0 Likes
584

Hi,

Try this:

loop at itab.

if itab-field = 10.

clear wa_itab.

insert wa_itab into itab INDEX SY-TABIX.

endif.

endloop.

Hope this will help you.

Jogdand M B