Quick Tip
Sergio Cannelli
SAP Solutions and Innovative Design Specialist| SAP FULL STACK DEVELOPER
In our ABAP programs, performance problems are often reported to us. We begin to analyze TABLES accesses. It is also very important variables or internal tables that are used in METHODS or ROUTINES that are loaded every time we execute a process. We must see, if these variables or internal tables can be loaded only once.
How do we achieve this? Declaring these variables and internal tables with STATICS, not with the DATA instruction.
Example.
STATICS: TL_RANGEUSER TYPE STANDARD TABLE OF ZFIGET_TVARVC=>TS_DATA.
STATICS: TL_RANGETX TYPE STANDARD TABLE OF ZFIGET_TVARVC=>TS_DATA.
*$. LEE USUARIO
IF LINES( TL_RANGEUSER ) EQ 0.
ZFIGET_TVARVC=>GET_RANGE( EXPORTING IV_NAME = 'ZR2R_USUARIO_DEVPROV'
IMPORTING ER_RANGE = TL_RANGEUSER ).
ENDIF.
* $. LEE TRANSACCIONES
IF LINES( TL_RANGETX ) EQ 0.
ZFIGET_TVARVC=>GET_RANGE( EXPORTING IV_NAME = 'ZR2R_TRANSACCION'
IMPORTING ER_RANGE = TL_RANGETX ).
ENDIF.
In this case I fill 2 ranges that would only be loaded once, validating if the internal table is empty it is not necessary that every time my method is executed the ranges are loaded.
Doing this with our program we can observe that the performance improves a lot.
ABAP || Javascript || Life Coach
1 年First thanks for this great blog. ???? Second I have a question because not knowing it. In OOP we can use constructor method which is loaded once when the class was created, right? I suppose that some developers use this. Maybe I'm completely wrong but no matter. I'm waiting for a senior response to learn something new.