SAP ABAP Interview Questions (31 - 40)
31. What are performance tuning techniques in ABAP?
Performance tuning in ABAP involves optimizing code and database queries to improve execution speed and resource utilization. Key techniques include:
- Avoid
SELECT *, fetch only required fields. - Use FOR ALL ENTRIES, proper database indexes, and avoid nested loops (use parallel cursor).
- Use JOIN instead of multiple SELECTs, and field symbols instead of work areas.
- Use sorted/hashed internal tables for faster access.
32. What is the difference between JOIN and FOR ALL ENTRIES?
JOIN is used to combine rows from two or more tables based on a related column between them. It is executed at the database level.
FOR ALL ENTRIES is used to fetch data from a secondary table based on values in an internal table. It is executed at the application level.
* JOIN example
SELECT a.emp_id, a.name, b.dept
FROM zemp AS a
INNER JOIN zdept AS b
ON a.dept_id = b.dept_id.
* FOR ALL ENTRIES example:
SELECT * FROM zdept INTO TABLE it_dept
FOR ALL ENTRIES IN it_emp
WHERE dept_id = it_emp-dept_id.
33. What is SQL Trace (ST05)?
SQL Trace (ST05) is a tool used to analyze database performance by tracing SQL queries executed by a program. It helps identify slow queries, unnecessary database calls, and performance issues.
Example: We can run ST05, execute our report, and see which SELECT statements are taking more time.
34. What is Code Inspector (SCI)?
Code Inspector (SCI) is a tool used to check code quality, performance, and syntax issues in ABAP programs. It helps detecting problems like inefficient queries, unused variables, and security risks.
35. What is Runtime Analysis (SE30)?
Runtime Analysis (SE30) is a tool used to measure execution time and performance of an ABAP program. It shows which parts of the code (like loops, SELECTs) are taking more time.
Example: Run SE30 on a report to identify slow sections and optimize them.
36. What is Buffering in SAP tables?
Buffering means storing table data temporarily in SAP application server memory instead of reading from the database every time. This can improve performance a lot for small and frequently used tables that do not change often.
37. Why is SELECT * considered bad practice?
SELECT * reads all fields from the database table, even if the program only needs a few of them. This can lead to:
- Increased network traffic and memory usage.
- Slower query execution due to unnecessary data transfer.
- Reduced code maintainability and clarity.
* Good and bad practice example
" Bad
SELECT * FROM mara INTO TABLE @DATA(it_mara).
" Better
SELECT matnr, mtart, meins
FROM mara
INTO TABLE @DATA(it_mara_small).
38. What is the difference between Smart Forms and SAP Scripts?
SAP Script is the older SAP form technology, while Smart Forms is a newer and easier tool for designing forms. Smart Forms provides a better graphical interface and reduces manual coding compared to SAP Script.
39. What is ALV Report?
ALV stands for ABAP List Viewer, and it is used to display report output in a user-friendly table format. It gives built-in features like sorting, filtering, subtotaling, exporting, and layout saving. Because of these ready-made features, ALV is very common in SAP reporting.
40. What is the difference between ALV and regular reports?
ALV (ABAP List Viewer) is an advanced reporting tool that provides built-in functionalities like sorting, filtering, totals, subtotals, column hide/show, and export to Excel. It offers a user-friendly interface with minimal coding effort, and users can interact with the data dynamically.
* ALV Report (simple)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'ZEMP'
TABLES
t_outtab = itab.
Regular reports are created using basic WRITE statements, and they display static output. They do not have built-in features like sorting or filtering, so all logic must be coded manually.
* Regular Report
WRITE: / 'Employee ID:', emp_id,
/ 'Name:', emp_name.