Best practices
Quick answer
Perform authorization checks (AUTHORITY-CHECK) in custom transactions, avoid dynamic code injection, and never bypass SAP’s data validations with direct table writes.
Key takeaways
- No SELECTs in loops; read data once into internal tables.
- Select only needed rows/columns; use indexes; aggregate in the DB (CDS/Open SQL).
- Use sorted/hashed tables and field-symbols for large data.
- Watch out: Modifying SAP standard instead of enhancing (breaks clean core).
Performance
- No SELECTs in loops; read data once into internal tables.
- Select only needed rows/columns; use indexes; aggregate in the DB (CDS/Open SQL).
- Use sorted/hashed tables and field-symbols for large data.
Correctness and robustness
- Null/initial checks and defensive coding; handle errors via class-based exceptions.
- Always check BAPI RETURN and commit/rollback correctly.
- Write ABAP Unit tests for logic in classes.
Maintainability and clean core
- Object-oriented, small single-purpose methods; clear naming conventions.
- Use enhancements/BAdIs and side-by-side extensions instead of modifying SAP standard (clean core).
- Keep code in transports, documented, and follow the customer namespace (Z/Y).
Security
Perform authorization checks (AUTHORITY-CHECK) in custom transactions, avoid dynamic code injection, and never bypass SAP’s data validations with direct table writes. Secure, clean custom code is far easier to upgrade and audit.
Common pitfalls
- Modifying SAP standard instead of enhancing (breaks clean core).
- Ignoring performance rules, slow programs at scale.
- No error handling or unit tests, fragile code.
Want to learn this properly?
Our live, instructor-led SAP Training covers this hands-on, with real projects and a certification path.
Check your understanding
Which statement is true of Best practices?
- A. This how-to hub collects task-focused guides, the concrete "how do I actually do X in SAP?" answers, from…
- B. Secure, clean custom code is far easier to upgrade and audit.
- C. F110 is the SAP transaction code for Automatic Payment Program (FI).
Show answer
B. Secure, clean custom code is far easier to upgrade and audit.
Covered in the “Security” section of this lesson.
Which of these also applies to Best practices?
- A. Assuming fiscal = calendar year, many companies differ.
- B. Choosing the wrong stack (ABAP vs Java) for the product.
- C. Null/initial checks and defensive coding; handle errors via class-based exceptions.
Show answer
C. Null/initial checks and defensive coding; handle errors via class-based exceptions.
Covered in the “Correctness and robustness” section of this lesson.
Which part of the Learn SAP curriculum covers Best practices?
- A. SAP certification
- B. SAP ABAP development
- C. SAP architecture
Show answer
B. SAP ABAP development
This lesson sits in the SAP ABAP development section of the Learn SAP course.