SELECT … ENDSELECT? [SAP]

As you know you can use SELECT statement to select data from tables. You can use SELECT with ENDSELECT. But using ENDSELECT means records will be looped without closing the link to database. So it will require more database processes. And database processes are known the most expensive processes in ABAP codes. You have to use database SQL statements minimum as much as you can. If you do so it will improve the performance a lot.

We had project couple months ago. Basically the company acquired another company which used to use SAP. Then we cancelled their SAP system and moved to our system.  At the same time -of course- we imported some custom ABAP programs to our system. But the problem started here. One of the programs is a crucial program that is used for delivery, labeling, and shipping process. It is a mixed of report, dialog program; Z tables, heavy data process, etc…

Long story short, we are having very bad performance problems for this program. Why? Okay it is processing large volume of data, but also because the program was designed very badly. It is exactly a quick-and-dirty program. The biggest problem is SELECT…ENDSELECT statements. There are several SELECT…ENDSELECT statements. For example, you can imagine a statement like that:

SELECT FROM dbtable
SELECT FROM dbtable
SELECT FROM dbtable
UPDATE dbtable
ENDSELECT

Who coded this program? I know output was okay, SAP system was quite small. But why did you that? Have you not learned that this is very bad programming style? Have you not heard about internal tables, FOR ALL ENTRIES etc? Why SAP has a course called “BC490 ABAP Performance Tuning“?

I have been coding ABAP for 10 years and since beginning I have never used SELECT…ENDSELECT.

When you code ABAP and complete program, use SE30 to analyze the performance. And decrease the database usage as much as you can.

As you see I am the person who struggles with those kinds of programs and it is my job to maintain these programs. Poor ABAP developers who need to maintain bad programs which were developed by irresponsible ABAP developers.

Tags: , , ,

Leave a Reply