✒️ABAP / La performance en ABAP Por Jaime Gomez Arango

Selector Alummnos / Empresas

ABAP La performance en ABAP

ABAP La performance en ABAP

Performance in ABAP

Performance refers to the analysis of the execution and efficiency of ABAP programs. In this analysis, there are three fundamental aspects:

  • The processing time of the program logic.
  • The processing time of accesses to database tables.
  • The processing time of the ABAP system.

Of these three times, the most resource-consuming one is the processing time of accesses to database tables, followed by the processing of logic, and finally the processing of the ABAP system.

For this analysis, we have the transaction SE30, which evaluates how the execution and processing time of the program are distributed.

To do this, upon entry, the name of the program is indicated, and the Evaluate button is pressed. This will show us how the percentage distribution of processing times for ABAP logic, the database, and the system.

The ideal situation would be for the highest percentage of processing to be the ABAP logic and the lowest to be the database table. To achieve this, it is necessary to adhere to good programming practices.

Good and Bad Practices in Database Access

  • Avoid SELECT*: The SELECT* statement retrieves ALL data from the specified or indicated table. Instead of fetching all, it is suggested to specify which data needs to be retrieved, like so:

Wrong:

SELECT * FROM zuser_table INTO TABLE it_users.

Right:

SELECT user_id, username, email
FROM zuser_table
INTO TABLE it_users.

  • Avoid SELECT ENDSELECT: The SELECT ENDSELECT statement generates a loop to process records retrieved from another database table. However, it's more efficient to use SELECT INTO TABLE.

Wrong:

SELECT * FROM zuser_table INTO TABLE it_users.
ENDSELECT.

Right:

SELECT user_id, username, email
FROM zuser_table
INTO TABLE it_users.

  • Avoid SELECT without WHERE: When using the SELECT statement without a condition, ALL records from the database table are processed or fetched. It is ideal to use WHERE with as many specifications as possible to reduce processing to what is necessary. It is also suggested to avoid negative conditions or the use of NE.

Wrong:

SELECT * FROM zuser_table INTO TABLE it_users.

Right:

SELECT user_id, username, email
FROM zuser_table
WHERE is_active = 'X'
INTO TABLE it_users.

  • Avoid SELECT within a LOOP: Executing one or more SELECT statements within a LOOP ENDLOOP will result in selecting each record while looping through the table. It's possible to use a SELECT SINGLE with specific conditions to select the first applicable case. Or retrieve all necessary records in internal tables first, then within the LOOP, access them using the READ TABLE statement. Additionally, retrieving all records from database table executes FOR ALL ENTRIES within the SELECT to retrieve records from the database into memory.

Wrong:

LOOP AT it_orders INTO wa_order.
SELECT * FROM zuser_table INTO wa_user WHERE user_id = wa_order-user_id.
" Process user data...
ENDLOOP.

Right:

SELECT * FROM zuser_table INTO TABLE @it_users WHERE user_id IN @it_orders-user_id.

LOOP AT it_orders INTO wa_order.
" Access user data from it_users table...
ENDLOOP.

  • Avoid using INSERT, UPDATE, MODIFY, and DELETE statements within a LOOP: Doing this inside the LOOP will generate a longer table and require more resources. Instead, it is recommended to use these statements at the end or outside the LOOP.

Wrong:

LOOP AT it_items INTO wa_item.
INSERT INTO zitem_table VALUES wa_item.
ENDLOOP.

Right:

INSERT zitem_table FROM TABLE it_items.

  • SELECT vs JOIN: When data from multiple database tables is required, using SELECT after SELECT is not recommended. Instead, use the JOIN statement as necessary. For example:

Wrong:

SELECT carrid, connid FROM spfli INTO TABLE @it_spfli.
SELECT dldate, planetype FROM sflight INTO TABLE @it_sflight.

Right:

SELECT tl~carrid, tl~connid, t2~dldate, t2~planetype, tl~countryfl
FROM spfli AS tl
INNER JOIN sflight AS t2
ON tl~carrid = t2~carrid AND tl~connid = t2~connid
INTO TABLE @it_combined_data.

Good and Bad Practices in ABAP Logic Processing

  • READ TABLE BINARY SEARCH: When searching for a record in a table using the READ TABLE statement, the search is done sequentially. However, binary search partitions the table, searching in halves, offering better performance. To implement it, the search field in the internal table must be sorted ascendingly or descendingly, and add the BINARY SEARCH clause at the end of the READ TABLE:

Bad Practice:

READ TABLE it_suppliers INTO wa_suppliers WITH KEY name = 'Ariel'.

Good Practice:

SORT it_suppliers BY name ASCENDING.
READ TABLE it_suppliers INTO wa_suppliers WITH KEY name = 'Ariel' BINARY SEARCH.

  • Avoid LOOP ENDLOOP within another LOOP ENDLOOP: Performing LOOPS within another LOOP generates an exponential search for records. It's suggested to use the WHERE conditional and binary search to optimize processing, like so:

Bad Practice:

LOOP AT it_suppliers INTO wa_suppliers.
LOOP AT it_users INTO wa_users.
" Processing logic
ENDLOOP.
ENDLOOP.

Good Practice:

SORT it_users BY name ASCENDING.
LOOP AT it_suppliers INTO wa_suppliers WHERE dni GT '50000000'.
READ TABLE it_users INTO wa_user WITH KEY dni = wa_suppliers-dni BINARY SEARCH.
ENDLOOP.

  • LOOP CHECK vs LOOP WHERE: While CHECK and IF-ENDIF statements can be used as filters within a LOOP, they are not recommended as they read all records. It's optimal to implement WHERE with specific conditions.

Bad Practice:

LOOP AT it_customers INTO wa_customer.
CHECK wa_customer-status = 'Active'.
" Processing logic for active customers
ENDLOOP.

Good Practice:

LOOP AT it_customers INTO wa_customer WHERE status = 'Active'.
" Processing logic for active customers
ENDLOOP.

  • Don't forget WHEN OTHERS in CASE statement: In the CASE-ENDCASE conditional, it's crucial to specify the case where none of the indicated cases are found, as otherwise, the system will throw an error or lead to unexpected situations. Implement the alternative WHEN OTHERS.

Bad Practice:

CASE lv_condition.
WHEN 'A'.
" Case A logic
WHEN 'B'.
" Case B logic
ENDCASE.

Good Practice:

CASE lv_condition.
WHEN 'A'.
" Case A logic
WHEN 'B'.
" Case B logic
WHEN OTHERS.
" Handling unexpected conditions
ENDCASE.

  • APPEND from one internal table to another internal table: When adding records from one internal table to another of the same type, the worst option is to take the content of one table in a LOOP, transferring the information record by record to the other table. Instead, it's more efficient to use the APPEND LINES OF statement in a single line to transfer the content from one table to another, like so:

Bad Practice:

LOOP AT itab1 INTO wa_itab1.
APPEND wa_itab1 TO itab2.
ENDLOOP.

Good Practice:

APPEND LINES OF itab1 TO itab2.

  • INSERT from one internal table to another internal table: When it's necessary to insert records from one internal table to another of the same type, the worst option is to insert record by record from one table to another. Instead, it's optimal to insert the content at a specific position from one table to another using the INSERT LINES OF statement, like so:

Bad Practice:

LOOP AT itab1 INTO wa_itab1.
INSERT wa_itab1 INTO TABLE itab2.
ENDLOOP.

Good Practice:

INSERT LINES OF itab1 INTO TABLE itab2 INDEX lv_index.

  • Removing duplicate records from an internal table: When it's necessary to check and eliminate duplicate records from a table, primarily, the fields to be examined must be sorted. The worst option would be to check record by record if the first record looks like the next one and if so, delete it. However, it's possible to use the DELETE ADJACENT DUPLICATES statement along with COMPARING to compare the specified fields in this process.

Bad Practice:

DELETE ADJACENT DUPLICATES FROM itab.

Good Practice:

DELETE ADJACENT DUPLICATES FROM itab COMPARING field1 field2.

  • Copying internal tables: When it's necessary to copy records from one internal table to another of the same type, the worst option is to clear the content of one table to pass the information from the other there. However, it's optimal to assign table1[] = table2[], overriding the content of one table with another.

Bad Practice:

CLEAR itab2.

LOOP AT itab1 INTO wa_itab1.
APPEND wa_itab1 TO itab2.
ENDLOOP.

Good Practice:

itab2[] = itab1[].

  • Comparison of internal tables: When it's necessary to compare two internal tables to determine if their content is the same, the worst way is to do it manually. However, there's an optimal way to carry out this task using an IF-ENDIF within which the tables will be assigned, and in a single line, it will be determined if there's a duplicate, like so:

Bad Practice:

LOOP AT itab1 INTO wa_itab1.
READ TABLE itab2 INTO wa_itab2 WITH KEY field1 = wa_itab1-field1.

IF sy-subrc <> 0.
" Records not matching
ENDIF.
ENDLOOP.

Good Practice:

IF itab1[] = itab2[].
" Processing logic for equal tables
ENDIF.


 

Escanear / Compartir

 

 


Sobre el autor

Publicación académica de Jaime Eduardo Gomez Arango, en su ámbito de estudios para la Carrera Consultor ABAP Nivel Inicial.

SAP Expert


Jaime Eduardo Gomez Arango

Profesión: Ingeniero de Sistemas y Computación - España - Legajo: SW34C

✒️Autor de: 149 Publicaciones Académicas

🎓Egresado de los módulos:

Disponibilidad Laboral: FullTime

Presentación:

Ingeniero de sistemas y computación con 8 años de experiencia el desarrollo frontend & backend (react/node) y en cloud (aws), actualmente desarrollando habilidades en sap btp, ui5, abap y fiori.

Certificación Académica de Jaime Gomez

✒️+Comunidad Académica CVOSOFT

Continúe aprendiendo sobre el tema "La performance en ABAP" de la mano de nuestros alumnos.

SAP Master


La Performance en ABAP Se analizan las prácticas de programación que afectan el desempeño y rendimiento en ABAP, priorizando la performance. Los tres aspectos fundamentales son: tiempo de procesamiento de la lógica ABAP, de los accesos a la base de datos y del sistema SAP. El acceso a la base de datos suele ser el principal factor de impacto en recursos y tiempo, aunque con SAP HANA este impacto ha disminuido. Se recomienda utilizar la transacción SE30 para medir los tiempos de procesamiento y detectar cuellos de botella. Lo ideal es que el mayor porcentaje de tiempo se invierta en la lógica ABAP y el menor en los accesos a base de datos. Buenas y malas prácticas de acceso...

Acceder a esta publicación

Creado y Compartido por: Juan Ignacio Romero

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

¿Qué afecta la performance? 1. Accesos a base de datos (el más crítico). 2. Lógica ABAP (bucles, condiciones, tablas internas). 3. Tiempo del sistema (carga del servidor). Herramienta de análisis: · Transacción SE30 (Análisis de tiempo de ejecución). Buenas Prácticas - Base de Datos: Mala Práctica Buena Práctica Razón SELECT * SELECT campo1 campo2 Evita traer datos innecesarios SELECT ... ENDSELECT SELECT ... INTO TABLE 8x más rápido SELECT sin WHERE Siempre usar WHERE Evita full table scan SELECT dentro de LOOP SELECT FOR ALL ENTRIES Reduce accesos a DB INSERT/UPDATE en LOOP INSERT/UPDATE ... FROM TABLE 1 acceso vs N accesos...

Acceder a esta publicación

Creado y Compartido por: Mara Fadua Romero Hernandez

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master

Introducción: La performance en ABAP se centra en tres pilares: tiempo de acceso a BD, lógica ABAP y carga del sistema. ¡Domina las buenas prácticas para evitar cuellos de botella en programas críticos! Diagnóstico: Transacción SE30 Herramienta clave: Analiza distribución de tiempos: Base de datos (Mayor impacto) Lógica ABAP Sistema SAP Objetivo ideal: Minimizar tiempo de BD (< 30%) Maximizar eficiencia en lógica ABAP Malas Prácticas en Acceso a BD SELECT * Problema: Recupera campos innecesarios. Solución:...

Acceder a esta publicación

Creado y Compartido por: Oscar Aravena Muller / Disponibilidad Laboral: FullTime

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert



La performance en ABAP dentro del ecosistema SAP es un tema fundamental para garantizar la eficiencia, escalabilidad y estabilidad de los sistemas empresariales. ABAP (Advanced Business Application Programming) es el lenguaje de programación principal del sistema SAP ERP, utilizado para desarrollar aplicaciones de negocio críticas que deben procesar grandes volúmenes de datos con alta confiabilidad. La performance en este contexto hace referencia al tiempo de ejecución, consumo de recursos y optimización de procesos dentro del entorno SAP. Este resumen aborda en 1000 palabras exactas los principios, prácticas y consideraciones clave para mejorar la performance en programación ABAP. La performance...

Acceder a esta publicación

Creado y Compartido por: David Ibarra / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


La performance en ABAP 1 La performance en ABAP Se refiere al rendimiento y la eficiencia con la que se ejecuta el código. Es un aspecto fundamental, ya que un mal desempeño puede afectar no solo la ejecución de un programa, sino el funcionamiento general del sistema SAP. Existen tres aspectos clave que determinan la performance de un programa ABAP: Tiempo de procesamiento de la lógica ABAP: Se refiere al tiempo que toma ejecutar las instrucciones y procesos internos del programa. Tiempo de acceso a la base de datos: Es el tiempo necesario para consultar, insertar, modificar o eliminar datos en las tablas del sistema. Este es el factor que más influye en el rendimiento,...

Acceder a esta publicación

Creado y Compartido por: Geovanny Martínez Campoverde

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

Performace en ABAP en abap existe buenas y malas practicas, por que afectan rendimiento o performance (analisis de desempeño y rendimiento) de programas o otros factores tiene que ver con 3 aspectos base: *el tiempo de proceso de la logica *tiempo de proceso de accesos a tablas de database *tiempo de proceso de sistema SAP el tiempo de procesamiento a las tablas es el que mas consume recursos la transaccion SE30 Analisis de tiempo de ejecucion permite evaluar la distribucion del tiempo en un programa: en la pantalla principal se pone nombre del prog a evaluar buenas y malas practicas en accesos a la base de datos evitar usar SELECT * es mejor especificar los campos evitar SELECT ENDSELECT es mejor usar INTO TABLE evitar SELECT...

Acceder a esta publicación

Creado y Compartido por: Luciano Martinez / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


Dentro de la programación en ABAP podemos identificar cuáles son las buenas y las malas prácticas de programación, desde el punto de vista de la performance de nuestros desarrollos. Es sumamente importante tener bien claro que prácticas son desaconsejadas y cuales si son recomendadas, de modo de poder apuntar a realizar programas de alta calidad, que funcionen perfectamente en el ambiente productivo, donde las tablas de la base de datos contienen millones de registros y cada micro segundo cuenta. ABAP nos proporciona una herramienta muy útil e interesante para el análisis de la performance que es la transacción estándar ST05 Tips and Tricks. Allí veremos que los tiempos de...

Acceder a esta publicación

Creado y Compartido por: Jose Medina / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master

LA PERFORMANCE EN ABAP: en ABAP existen lo que en programación se denomina buenas y malas prácticas, ya sea porque afectan al rendimiento o la performance de los programas o porque afectan a otros factores que son determinados como ser la reutilización y el mantenimiento de código. Cuando hablemos de performance nos estaremos refiriendo al análisis del desempeño y el rendimiento del programa ABAP. Dentro de ABAP podemos decir que la performance de un programa tiene que ver con 3 aspectos fundamentales que son los siguientes: - El tiempo de procesamiento de la lógica ABAP existente en el programa. - El tiempo de procesamiento de los accesos a las tablas de la base de datos. - El tiempo de procesamiento...

Acceder a esta publicación

Creado y Compartido por: Jean Carlos Lopez / Disponibilidad Laboral: FullTime

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


Performance in ABAP Performance refers to the analysis of the execution and efficiency of ABAP programs. In this analysis, there are three fundamental aspects: The processing time of the program logic. The processing time of accesses to database tables. The processing time of the ABAP system. Of these three times, the most resource-consuming one is the processing time of accesses to database tables, followed by the processing of logic, and finally the processing of the ABAP system. For this analysis, we have the transaction SE30, which evaluates how the execution and processing time of the program are distributed. To do this, upon entry, the name of the program is indicated, and the Evaluate button is pressed. This will show us...

Acceder a esta publicación

Creado y Compartido por: Jaime Eduardo Gomez Arango / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

Performance en ABAP El performances refiere a el análisis del desempeño y el rendimiento del programa ABAP. En este análisis existe los siguiente 3 aspectos fundamentales: * El tiempo de procesamiento de la lógica del programa. * El tiempo de procesamiento de los accesos a las tablas de las bases de datos. * El tiempo del procesamiento del sistema ABAP. De estos 3 tiempos, el que más recursos consume es el tiempo de procesamiento de los accesos a las tablas de bases de datos, luego esta el procesamiento de la lógica y finalmente el procesamiento del sistema ABAP. Para este análisis contamos con la transacción SE30 que evaluar cómo se distribuye el tiempo de ejecución y procesamiento...

Acceder a esta publicación

Creado y Compartido por: Linda Carolina Zambrano León

 


 

👌Genial!, estos fueron los últimos artículos sobre más de 99.000 publicaciones académicas abiertas, libres y gratuitas compartidas con la comunidad, para acceder a ellas le dejamos el enlace a CVOPEN ACADEMY.

🔎Buscador de Publicaciones:

 


 

No sea Juan... Solo podrá llegar alto si realiza su formación con los mejores!