ABAP Tips #1 : SELECT?ENDSELECT is not good


Insted of using select?..endselect opensql statement, select the whole table into internal table ! The rule is ?access the database as less as posible?. The reason behind this is that SAP using the 3 tier architecture therefore accessing the database rows by rows involved a lot of information exchange between SAP and database server.

USE

SELECT *
 INTO TABLE lt_bookinfo
 FROM /sie/lib_book
 WHERE book_id = lv_bookid.

DON?T USE

SELECT *
 FROM /sie/lib_book
 INTO lw_bookinfo
 WHERE book_id = lv_bookid.

 MOVE-CORRESPONDING lw_bookinfo TO lt_bookinfo_temp.
 APPEND lw_bookinfo TO lt_bookinfo.

ENDSELECT.

Leave a Reply

Your email address will not be published. Required fields are marked *