Array Operations PDF Print E-mail
User Rating: / 0
PoorBest 
ABAP Tutorials - Performance tips and tricks
Written by mastram   
Saturday, 05 July 2008 06:06

Always use the tools given by ABAP Kernel to do the array operations like appending, inserting deleting duplicates etc. Using your own code to achieve the same functionality will be much slower as compared to ABAP Kernel.

Thus, you can improve the performance of your ABAP program to much extent. Here are some examples:

PS: Run time given in the examples is approximate run time in micro seconds.

Appending tables

With the APPEND variant "APPEND LINES OF itab1 TO itab2" the task of appending a table to another table can be transferred to the kernel.

Using your algorithm

RT: 400

Using ABAP Kernel

RT: 80

LOOP AT ITAB1 INTO WA.
  APPEND WA TO ITAB2.
ENDLOOP.
APPEND LINES OF ITAB1 TO ITAB2.

Inserting tables

With the INSERT variant "INSERT LINES OF itab1 INTO itab2 INDEX idx" the task of inserting a table into another table can be transferred to the kernel.

 Using your algorithm

RT: 750

Using ABAP Kernel

RT: 80

I = 250.
LOOP AT ITAB1 INTO WA.
  INSERT WA INTO ITAB2 INDEX I.
  ADD 1 TO I.
ENDLOOP.
I = 250.
INSERT LINES OF ITAB1 INTO ITAB2
                      INDEX I.

Deleting lines from table

Using your algorithm

RT: 500

Using ABAP Kernel

RT: 80

DO 101 TIMES.
  DELETE ITAB INDEX 450.
ENDDO.
DELETE ITAB FROM 450 TO 550.

Deleting duplicates

With the DELETE variant "DELETE ADJACENT DUPLICATES" the task of deleting duplicate entries can be transferred to the kernel.

Using conventional algorithm

RT:550

Using ABAP Kernel

RT: 70

READ TABLE ITAB INDEX 1 INTO PREV_LINE.
LOOP AT ITAB FROM 2 INTO WA.
  IF WA = PREV_LINE.
    DELETE ITAB.
  ELSE.
    PREV_LINE = WA.
  ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ITAB
                COMPARING K.
Comments
Add New Search
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Thursday, 21 August 2008 14:44 )
 

Advertisement

 

Google Search

Advertisement