ABAP programing standards for performance tuning

Programing standards for SAP ABAP programers, best practices SAP ABAP programing

+ -
Programming Standard Bad example Good example
Never use select *, always use select with list of fields because if you use select * it will get all columns from database, if you use select list of fields it will get selected columns only.
 SELECT * FROM MARA
    INTO TABLE ...
 SELECT MATNR MTART MEINS MBRSH FROM MARA ..
Always specify key fields in where condition, because it will be having primary index.
 SELECT * FROM MARA
    INTO TABLE IT_MARA
    WHERE MTART = 'FERT'.
 SELECT MATNR MTART MEINS FROM MARA
        INTO TABLE IT_MARA
        WHERE MATNR = '0001'.
Some times we may need to use non-key fields in where condition, in such cases create secondary index to improve performance.
 
 
Never use select with corresponding .
 SELECT * FROM MARA
 INTO CORRESPONDING FIELDS OF TABLE IT_MARA.
 SELECT MATNR MTART MEINS FROM MARA
        INTO TABLE IT_MARA.
Always use read table key with binary search, binary search will improve performance.
 READ TABLE IT_MARA INTO WA_MARA WITH KEY MATNR = '001'
                       BINARY SEARCH.
READ TABLE IT_MARA INTO WA_MARA WITH KEY MATNR = '001'.
Avoid using select joins for more than 3 database tables. Select Joins in SAP ABAP Using select for all entries
Always use select for all entries for more than three tables. Select Joins in SAP ABAP Using select for all entries
When using select for all entries, check whether the parent internal table is initial or not .
 SELECT * FROM MAKT 
INTO IT_MAKT
    FOR ALL ENTRIES IN IT_MARA
    WHERE MATNR = IT_MARA-MATNR.
IF IT_MARA IS NOT INITIAL.
SELECT * FROM MAKT INTO IT_MAKT
FOR ALL ENTRIES IN IT_MARA
WHERE MATNR = IT_MARA-MATNR. ENDIF.
Never use nested loops.
LOOP AT IT_MARA INTO WA_MARA.
LOOP AT IT_MAKT INTO WA_MAKT.


ENDLOOP.
ENDLOOP.
LOOP AT IT_MARA INTO WA_MARA.
READ TABLE IT_MAKT INTO WA_MAKT WHERE MATNR = WA_MARA-MATNR.

ENDLOOP.
Never use select statements inside loops .
 
LOOP AT IT_MARA INTO WA_MARA.
SELECT * FROM MAKT ...

ENDLOOP.
 INSTEAD USE FOR ALL ENTRIES 

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 47 People out of 47 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →