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 tuning

Former Member
0 Likes
286

<b>Hey guys,</b>

<b>I have two things to confirm regarding performance in abap program.</b>

1-Comparision of Loop..Endloop stmt in SELECT query and

Selectoption parameter IN option in SELECT query.

(which process is more fast in performance.)

2-Could you pls confirm whether Code-2 is more faster than code-1 operation.?

if so can you pls tell will the result of both code-1 and 2 are same?

Here wk_monat is Month(duration) input.

<b>Code-1.</b>

WK_MONAT = '01'.

DO.

SELECT BELNR BUZEI BLART MWSKZ HKONT SHKZG DMBTR

INTO CORRESPONDING FIELDS OF TABLE ITAB_BSIS

FROM BSIS WHERE BUKRS = itab_t001-BUKRS AND

GJAHR = P_GJAHR AND <b>MONAT = WK_MONAT</b> AND

WK_MONAT = WK_MONAT + 1.

ENDDO.

<b>COde-2</b>

wk_monat is parameter.

SELECT BELNR BUZEI BLART MWSKZ HKONT SHKZG DMBTR

INTO CORRESPONDING FIELDS OF TABLE ITAB_BSIS

FROM BSIS WHERE BUKRS = itab_t001-BUKRS AND

GJAHR = P_GJAHR AND <b>MONAT <= WK_MONAT</b> AND

ambichan.

<b></b>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
259

Hi,

As you might be aware of the SAP system 3-tier architecture, the idea is to keep the roundtrips to the database as low as possible. When you issue a SELECT statement inside any sort of a loop (do, while, loop at), the R/3 has to issue a SELECT in every loop pass. This is not advisable. In case of selection options, the complete select-option table is first interpreted into an SQL query and then passed to the database in one go. Hence only a single trip to the database is required thus improving performance.

In code-1, you have issued the SELECT in a loop. Please avoid this. Keeping other checks aside, the SELECT statement in code-1 is not logically correct. Rather that writing


AND MONAT = WK_MONAT AND WK_MONAT = WK_MONAT + 1.

you should write


AND ( MONAT = WK_MONAT OR WK_MONAT = WK_MONAT + 1 )...

If you want to select a range of data, you might would like to give BETWEEN a try.

Regards

Message was edited by: Shehryar Khan

1 REPLY 1
Read only

Former Member
0 Likes
260

Hi,

As you might be aware of the SAP system 3-tier architecture, the idea is to keep the roundtrips to the database as low as possible. When you issue a SELECT statement inside any sort of a loop (do, while, loop at), the R/3 has to issue a SELECT in every loop pass. This is not advisable. In case of selection options, the complete select-option table is first interpreted into an SQL query and then passed to the database in one go. Hence only a single trip to the database is required thus improving performance.

In code-1, you have issued the SELECT in a loop. Please avoid this. Keeping other checks aside, the SELECT statement in code-1 is not logically correct. Rather that writing


AND MONAT = WK_MONAT AND WK_MONAT = WK_MONAT + 1.

you should write


AND ( MONAT = WK_MONAT OR WK_MONAT = WK_MONAT + 1 )...

If you want to select a range of data, you might would like to give BETWEEN a try.

Regards

Message was edited by: Shehryar Khan