SAP ABAP BEST Practices
SAP ABAP BEST Practices
NAMING CONVENTIONS
Naming conventions specify uniform, binding guidelines for naming software objects
(e.g. classes, function modules) and naming objects in the source code (e.g.
variables).
2. NAMESPACE
The separation of customer objects and SAP objects can be facilitated using the
prefixes Y and Z and also via a customer-specific namespace. The syntax is as
follows:
Z� Y�
/<customer-specific namespace>/�
� Modularisation
� No overly-long/complex procedures
4.Code formatting
� Layer-specific/technical affiliation
6.INTERNATIONALISATION
Language-dependent texts in programs should not be �hard coded�, but stored in text
elements (program text, class text, online text repository [OTR]), standard text or
message classes. As all independent developments should be of a standard that can
be applied worldwide, all the texts should be translated into the commensurately
principal languages.
The components of a computer system that are the most secure, fastest, most
accurate, cheapest, reliable and easiest to maintain and document are those that
are not there.� (Gorden Bell)
9 OBSOLETE STATEMENTS
SAP has a strict backwards compatibility policy. Nevertheless, be aware that using
obsolete statements such as headers in internal tables will cause problems if the
code is transferred to classes. More up-to-date alternatives are always available
for obsolete language elements. Habit aside, there is little reason to use these
elements and the use of such should consequently be avoided
� Extended Program Check can be executed for specific, already activated source
code (programs, global classes �) and will report potential problems using three
priority levels.
In addition, a number of standard tools are available that can also be used for
perfor- mance analysis
12.DATABASE ACCESS
When accessing the database, five golden rules (source: SAP, see reference in
Section 3.7) are to be complied with to ensure a performant execution of programs
with database access. These five rules are:
1. Keep the result sets small � if the volume of selected data is kept small,
loads are avoided both on the database system and on the network during transfer of
the data to the application server.
2. Minimise the amount of transferred data � as the transfer of data between the
database and application server is in blocks, it is best to keep the volume of data
small to minimise the load on the network.
14 PASSING PARAMETERS
16 ERROR HANDLING
The ABAP runtime environment offers a variety of options for indicating an error to
an application. These options are listed below together with best practices.
i) SY(ST)-SUBRC CHECKS
ii) MESSAGE STATEMENT
iii) CLASS-BASED EXCEPTIONS
iv) EXCEPTIONS THAT CANNOT BE HANDLED
Custom developed ABAP code in particular, must not pose a risk to the
confidentiality, integrity and availability of business data.
az