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

optimising loop

sudha_naik
Product and Topic Expert
Product and Topic Expert
0 Likes
858

Hello all,

Is there any way in which we can optimise this loop ??

LOOP AT I_SEA WHERE MATNR EQ I_MATNR.

T_SEA = I_SEA.

APPEND T_SEA.

ENDLOOP.

Regards

Sudha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
835

Hi,

Instead of using header line you can use fields symbols.

Field-symbols <f_sea> type <type of internal table i_sea>.

Loop at i-sea assigning <f_sea> where matnr EQ i_matnr.

wa_tea = <f_sea>.

append wa_seat to t_sea.

endloop.

Field symbols dioes not required any space... it point outs directly the data and pushes it further/

rewards if useful.

regards ,

nazeer

8 REPLIES 8
Read only

Former Member
0 Likes
835

Plz can you give clear information in your question.

Regards,

Vimal

Read only

Former Member
0 Likes
835

T_SEA[] = i_SEA[].

DELETE T_SEA where MATNR NE I_MATNR.

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
835

Hi,

Try

APPEND LINES OF I_SEA TO T_SEA.

DELETE T_SEA WHERE MATNR <> l_MATNR.

<b>Do not do</b>


T_SEA[] = I_SEA[]. "This will overwrite existing data

Regards,

Sesh

Read only

Former Member
0 Likes
836

Hi,

Instead of using header line you can use fields symbols.

Field-symbols <f_sea> type <type of internal table i_sea>.

Loop at i-sea assigning <f_sea> where matnr EQ i_matnr.

wa_tea = <f_sea>.

append wa_seat to t_sea.

endloop.

Field symbols dioes not required any space... it point outs directly the data and pushes it further/

rewards if useful.

regards ,

nazeer

Read only

varma_narayana
Active Contributor
0 Likes
835

Hi Sudha..

this will be much better if both the Tables have same structure...

<b>T_SEA[] = I_SEA[].

Delete t_sea where matnr ne i_matnr.</b>

Reward if Helpful.

<b></b>

Read only

sudha_naik
Product and Topic Expert
Product and Topic Expert
0 Likes
835

tsea[] = isea[]

delete tsea

This code consumes more time than the loop.

Read only

0 Likes
835

Hi,

Performance always depends on the kind of data and amount of data you have in this case.

For some cases your code can be good in performance and for some cases mycode can give you the performance.

So as you said if the performance is good with your code then its good for the current data you have.

Regards,

Sesh

Read only

Former Member
0 Likes
835

Hi Sudha,

The performance would depend on the no. of Entries in I_SEA which are equal to I_MATNR.

Since you are saying that the loop is taking less time as compared to T_SEA = I_SEA. Then the no. of records with I_SEA-MATNR = I_MATNR are less.

So this cant be further optimizied & the loop which you have placed is perfect.

Best regards,

Prashant