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

Performance issue in internal table

Former Member
0 Likes
1,168

Hi experts

can you help to increase the performance of this code.

say best statements to replace the following code.which will give good performance.

DATA: itab TYPE STANDARD TABLE OF (db table)

WITH HEADER LINE.

DATA: BEGIN OF itab1 OCCURS 0,

field1 LIKE itab-field1,

field2 LIKE itab-field2,

END OF itab1.

LOOP AT itab.

MOVE-CORRESPONDING itab TO itab1.

APPEND itab1.

DELETE itab.

ENDLOOP.

REFRESH itab. CLEAR itab.

Edited by: sailu k on Mar 18, 2009 1:10 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,136

hi,

DATA: itab TYPE STANDARD TABLE OF /psyng/usertcode(db table)
WITH HEADER LINE.

DATA: BEGIN OF itab1 OCCURS 0,
field1 type itab-field1,
field2 type itab-field2,
END OF itab1.


LOOP AT itab.
*****REMOVING THIS******MOVE-CORRESPONDING itab TO itab1.
itab1-field1 = itab-field1.
itab1-field2 = itab-field2.
APPEND itab1.
************Not required*********DELETE itab.
ENDLOOP.

REFRESH itab. CLEAR itab. " Any ways you are clearing and refreshing the itab else
                                               " reverse of it delete in the loop and just clear the header line

Thanks
Sharath

9 REPLIES 9
Read only

Former Member
0 Likes
1,136

>DATA: itab TYPE STANDARD TABLE OF /psyng/usertcode(db table)

>WITH HEADER LINE.

Dont use with header line.

>DATA: BEGIN OF itab1 OCCURS 0,

>field1 LIKE itab-field1,

>field2 LIKE itab-field2,

>END OF itab1.

declare structure using types and declare itab1 of type that structure.

Dont use move coreesponding instead use field names like this

loop at itab into wa.

wa1-field1 = wa-field1.

wa1-field2 = wa-field2.

append wa1 to itab1.

clear wa1.

endloop.

кu03B1ятu03B9к

Edited by: kartik tarla on Mar 18, 2009 5:41 PM

Read only

Former Member
0 Likes
1,137

hi,

DATA: itab TYPE STANDARD TABLE OF /psyng/usertcode(db table)
WITH HEADER LINE.

DATA: BEGIN OF itab1 OCCURS 0,
field1 type itab-field1,
field2 type itab-field2,
END OF itab1.


LOOP AT itab.
*****REMOVING THIS******MOVE-CORRESPONDING itab TO itab1.
itab1-field1 = itab-field1.
itab1-field2 = itab-field2.
APPEND itab1.
************Not required*********DELETE itab.
ENDLOOP.

REFRESH itab. CLEAR itab. " Any ways you are clearing and refreshing the itab else
                                               " reverse of it delete in the loop and just clear the header line

Thanks
Sharath

Read only

former_member222860
Active Contributor
0 Likes
1,136

Hi,

Avoid using MOVE- CORRESPONDING.

u get many results here with that.

Read only

Former Member
0 Likes
1,136

Hi,

You can use the following:

DATA: itab TYPE STANDARD TABLE OF /psyng/usertcode(db table)

WITH HEADER LINE.

DATA: BEGIN OF wa_itab1,

field1 LIKE itab-field1,

field2 LIKE itab-field2,

END OF wa_itab1.

DATA itab1 like table of itab1.

LOOP AT itab.

MOVE-CORRESPONDING itab TO wa_itab1.

APPEND wa_itab1 to itab1.

ENDLOOP.

Clear itab[].

Best Regards,

Suresh

Read only

Former Member
0 Likes
1,136

try using work area.

LOOP AT itab.

MOVE-CORRESPONDING itab TO itab1. " Remove Move corresponding

APPEND itab1.

*DELETE itab. " Comment delete

ENDLOOP.

Refresh Itab.

Clear Itab.

Regards,

Gurpreet

Read only

Former Member
0 Likes
1,136

LOOP AT itab.

itab1-field1 = itab-field1.

itab1-field2 = itab-field2.

APPEND itab1.

DELETE itab.

ENDLOOP.

Read only

Former Member
0 Likes
1,136

i) Move individual fields of internal table instead of MOVE CORRESPONDING.

ii) Use TYPES and declare internal table like :

TYPES : Begin of itype1,

....

...

end of itype1.

data: itab1 type table of itype1.

And make sure you are using proper SELECTs to fill data .

Regards,

Deepthi

Edited by: Deepthi Upadhyaya on Mar 18, 2009 1:18 PM

Read only

Peranandam
Contributor
0 Likes
1,136

Hi,

write the code in following way

types: begin of stru,

field1 type itab-field1,

field2 type itab-field2,

end of struc.

DATA: itab TYPE STANDARD TABLE OF (db table).

field-symbols: <itab> like line of itab.

data: itab1 type table of stru,

wa like line of itab1.

LOOP AT itab assigning <itab>.

wa-field1 = <itab>-field1.

wa-field2 = <itab>-field2.

append wa to itab1.

ENDLOOP.

refresh itab.

Regards,

Peranandam

Read only

Former Member
0 Likes
1,136

Hi,

Why you are using two internal tables for holding 2 fields of information.

directly us can select the 2 fields from the DB-table into your 2nd internal table, any way you are not at all using the 1st internal table for any purpose.

Regards,

Sreeram