Professional Documents
Culture Documents
HANDBOOK
Version: 1.3
Classification: Protect - Commercial
DOCUMENT CONTROL
Release History
Approval
Reviewers
Name Role
Andre Muecke Business Applications Manager – SAP
Ken Saggers SAP Technical Manager
Giampaolo Lupi Transition Manager – SAP
Satyan Ghumatkar SAP Technical Consultant
1 INTRODUCTION 7
1.1 Purpose 7
1.2 Scope 7
3.4 Forms 29
3.4.1 SAPscript/Form Painter 29
3.4.2 Smart Forms/Interactive Forms 29
3.4.3 ALE & IDocs 30
3.4.4 Workflow 33
3.4.5 Packages/Development Classes 34
3.4.6 Area Menus 34
3.4.7 Messages 35
3.7 Datasets 38
3.7.1 File Naming 40
6 PROGRAMMING STANDARDS 48
6.1 General Rules 48
7 SAP NOTES 91
8 QUALITY ASSURANCE 91
8.1 Unit Test 91
9 APPENDIX 93
9.1 New Standards 93
9.1.1 Shared Objects 93
9.1.2 Exception Handling 93
9.1.3 Switch Framework 93
9.1.4 New BADI’s 93
9.1.5 Developing Persistence 94
1.1 Purpose
The purpose of this handbook is to define the standards and guidelines for custom ABAP development
that is valid in both operational (Application Management) and non-operational (Project) related
environments. The use of a universal set of standards and guidelines supports a consistent approach to
software development. The benefits of such an approach are:
Whilst this handbook is being issued to the Projects and SAP Support, it may not cover all types of
development as the document is currently being created.
1.2 Scope
Standards and guidelines address the quality aspect of custom code created during the build phase
(development & unit test) of the development lifecycle. The definition of custom code in the ABAP
environment covers Enhancements, Modifications, and standalone custom applications.
The creation of new functionality and adaptations to existing functionality are subject to these standards
and guidelines albeit existing functionality is not expected to be adjusted in retrospect to conform.
To develop SAP solutions different techniques and programming languages are at a developer’s
disposal. Architectural standards set-out which techniques and programming languages are permissible
in the SAP development environment. The setting of architectural standards is not the focus of this
document. However, a section on this subject has been included to provide context.
This document has been written for a SAP NetWeaver 7.0 system release.
1.5.2 Don’ts
Start Realization without sign-off of the Functional Specification
Write complex code unless it is really required.
Release the development request without proper testing.
Update the backend database directly.
Forget to capture the exceptions of all function and method calls.
Use own naming convention and patterns.
Build with reusability in mind. Encapsulate reusable functionality in OO classes and function
modules.
Divide large unit of code into Form routines X
Do not overload coding with technical refinements
Do not encapsulate if-statements too much
Keep select statements as simple as possible (for example, do not use overly complex
joins)
Optimize only where it is useful or meaningful to do so
Create types and data definitions only with a DDIC reference Central changes are possible
(for example, field lengths) and it is better to use TYPE instead of LIKE (constant typing Basis
recommendation)
Do not declare class static variables as public, because write access is possible
from outside then.
Better: Declare as “private” and provide (public) get-method for reading access.
Then only reading access is possible from outside the class.
3.1 Overview
A naming convention specifies the set of rules used to identify development objects. SAP plays a role
in the setting of the rules insofar it enforces its own recommendations. (See the following the section
called Customer Name Space ID). In the ABAP environment the non-reserved aspect of a custom
repository object name (and the names of any custom internal components) are arbitrary. The overall
responsibility for the enforcement of the naming conventions lies with the individual developers.
What is prescribed in the following sections ensures: (1) a distinction between SAP standard code,
partner code, and customer code and (2) meaningful names for custom developed objects that promote
ease-of-identification.
As part of the delivery process Code Inspector (Transaction code “SCII”) will be used to check whether
programs adhere to naming conventions or not. (A Global Variant will be created called
‘SSC_DEFAULT’ to aid the developers.
Name space identification is the means SAP uses to segment development objects in the repository.
SAP has reserved name ranges for customer objects and SAP objects. SAP reserves the “Z” and “Y”
repository name spaces for its customers that ensure that objects created in this space are preserved
from patching and upgrades. EFDE Corporate SAP adopts the policy of naming test-related objects in
the “Y” name space and Production-related objects in the “Z” namespace. The customer name space
identifier always occupies the first character in the name of a custom development.
Beware that SAP does deliver a few system objects with names that fall within the customer name
space. These objects are listed in table TDKZ.
The process area/application ID identifies the relevant business domain for custom development. It is
represented by a two character code which logically groups related development objects together.
Creation of custom data dictionary objects (DDIC) should be kept to minimum to maintain a low cost
of ownership. New DDIC objects should be created when a requirement exists that cannot be met by a
standard DDIC object.
The following general points are to be kept in mind during definition of new data dictionary object:
General
Check whether a suitable DDIC object already exists before creating a new one.
Data Element Design
Documentation at the data element level should make use of the long text facility to make on-
line help effective.
Transparent Table Design
Ensure that Client (MANDT) is utilised when creating a new table.
Foreign keys referencing SAP table primary keys are highly recommended.
Technical settings (SE13) should be maintained on all custom tables created (Consult the
BASIS team for assistance with the technical settings).
The table maintenance dialogue facility (ZSM31) permits a user to maintain data directly in a
Client. Data that is purported to be static and crucial to a process may necessitate the
activation of table logging for audit purposes. An example of such data would be FAL limits.
Each requirement needs to be discussed with the functional owner to determine whether it is
warranted.
Table logging is a standard SAP feature that records changes to table data. This system
feature is enabled in the EDF Production environment.
o In a table’s technical settings the log data changes indicator is used to enable logging
for that table.
o Logs can be viewed using transaction SCU3.
Non-dialogue maintained table entries should include at least a stamp for the user and date. A
reason code for the change may also be applicable.
A DDIC table name may be specified up to 16 characters. The first character should be the standard ‘Z’
for custom objects. The 2ndand 3rd characters should contain the Process Area. The remaining
characters are open.
Format: A BB C DDDDDDDDDDDD
Open (description)
Separator “_”
Process
Area
Customer
space
SAP ABAP Developer Handbook Page 14 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
identifier -
‘Z’
Example: ZHR_REGION
3.2.2 Structures
A structure is defined like a table, but it does not store records in the database – it is typically used as a
reference data definition to ensure consistency between programmes. Structures can be shared by
multiple ABAP programs.
A DDIC structure may be specified up to 30 characters. The first two characters must be specified as
‘ZS’ for custom structure. The 3 rd and 4th characters specify the Process Area. The remaining characters
are open.
Format: AA BB C DDDDDDDDDDDDDDDDDDDDDD
DDD
Open (Description)
Separator “_”
Process
Area
Customer
space
identifier -
‘ZS’
A DDIC table name may be specified up to 16 characters. The first two characters of the view must be
specified as ‘ZV’. The 3rd and 4th characters specify the Process Area. The other characters can be
arbitrarily assigned. For clarity purposes, the main table name can be used.
Format: AA BB C DDDDDDDDDDD
Open. Should incorporate the
main table name and be unique
Separator “_”
Process Area
Customer
space
identifier -
‘ZV’
Example: ZVHR_REGION
3.2.5 Domains
A domain is a central object for describing the attributes of a business object. A domain describes the
value set for a field. This set of values is defined by specifying the format attributes, such as external
format, length and type.
A DDIC data domain may be specified up to 30 characters. SAP does create domains that begin with a
‘Z’, so custom domains should begin with the first two characters ‘ZZ’. The remaining characters can
be arbitrarily assigned but should be a meaningful name.
Format: AA BBBBBBBBBBBBBBBBBBBBBBBBBBBB
Open (Description)
Customer space
identifier -
‘ZZ’
A DDIC data element may be specified up to 30 characters. The first two characters must be ‘ZZ’ and
the remaining characters can be arbitrarily assigned.
Format: AA BBBBBBBBBBBBBBBBBBBBBBBBBB
BB
Open
Customer space
identifier -
‘ZZ’
Lock objects control simultaneous access to a particular table/entry by two update users – i.e. ensure
two users are prevented from updating the same data object simultaneously. Locks are set and released
by calling a function module. When a lock object is activated, the system automatically generates the
function modules to be included in an ABAP program.
A DDIC lock object may be specified up to 16 characters. Lock object names should start with the
prefix ‘EZ’ followed by the process area. The remaining characters are open to the developer.
However, the table name should be used if it is less than seven characters.
Format: AA BB C DDDDDDDDDDD
Customer
space
identifier -
‘EZ’
Example: EZHR_REGION
A DDIC Search Help may be specified up to 30 characters. The first two characters must be ‘ZH’
followed by the process area. For clarity purposes, the main table/ view name should be used if
possible.
Format: AA BB C DDDDDDDDDDDDDDDDDDDDDDDDD
Open
Separator
“_”
Process
Area
Customer
space
identifier -
‘ZH’
Example: ZHFI_T001
Matchcode objects are obsolete and have been replaced first by the technology of the help views and
later by search help.
Customer
space
identifier
-
‘ZTT’
Example: ZTTFI_REGUH
Format: A BB CC
Freely assignable characters – Use number
assignment
Process
Area
Customer
space
identifier
-
‘Z’
Example:ZQM01
The following program IDs are used to describe the type of program:
Format: A BB C D E F G
Description
from
Functional
Specification
Separator
“_”
WRICEF
Ref #/
CR Ref #/
IR Ref # -
Length of
this sub-
segment
will vary
Separator
“_”
Program
Type
Identifier
App./
Process
Area
‘Z’
ABAP WebDynpro’s should be named using the standard convention, plus a reference to the
functional specification/task number and then a descriptive part. For Example
‘ZFIW_CNN0127_CFP_Report’
Module pools should be named using the standard convention, plus a reference to the
functional specification/task number and then a descriptive part. For example
'SAPMZHR1_EHL00001_EXT.
Transactions should be named in line with the report/program. For example a transaction for
the module pool above would be 'ZHRP01'.
Use descriptive names and hyphenate it with “_” underscore. Use the following prefixes:
New Type definitions should be named starting with ‘T_’.
Global variables should be named starting with ‘G_’.
Global constants should be named starting with ‘GC_’.
Global internal tables should be named starting with ‘GT_’.
Global structures should be named starting with ‘GS_’.
Global range tables should be named starting with ‘GR_’.
Local variables should be named starting with ‘L_’.
Local constants should be named starting with ‘LC_’.
Local internal tables should be named starting with ‘LT_’.
Local structures should be named starting with ‘LS_’.
Local range tables should be named starting with ‘LR_’.
Subroutine parameters should be prefixed with a ‘P’
Field Symbols should be named starting with ‘<FS>.
Selection-screen Parameters should be named starting with ‘P_’.
Select-Options should be named starting with ‘S_’.
An explicit type should always be assigned to the formal parameters of a subroutine to improve
performance.
Where possible, use the Parameter ID associated with a data object to enable automatic population.
This will also aid with the passing of data between programs and transactions.
The use of the MOVE-CORRESPONDING statement, though convenient, should be used with care. In
some cases the use of explicit MOVE statements can aid clarity.
Numeric Value
Process
Area
Constant
‘SAPxZ’
Example: SAPMZPS01_PROC_CHQ
Module pools should be named using the standard convention detailed above, plus a descriptive part.
Example: ‘SAPMZPS01_Project_Systems’.
Remarks: It is mandatory to use the ‘ABAP Workbench’ to construct module pools. The SAP
Workbench is designed to enforce standard naming conventions.
The identification of a screen painter dynpro consists of an ABAP program name and a four digit
dynpro number. The number range reserved for customised dynpros should be between 9000 - 9999.
The initial screen number for a given transaction should be 9000 and additional screens numbers
increment by 10.
ABAP Module
Pool
Format: AAAAAAAA
Open
Example
STANDARD
Format: AAAAAAAAAAAAAAAAAAAA
Open
Example
INITIAL
A Transaction Code can not be more than 20 characters. The naming convention for bespoke
Transaction Codes is as follows:
First character is ‘Z’.
Second and third characters are reserved for the Process Area.
The fourth character is reserved to indicate Function.
o “D” is to be specified for a display-only function.
o “U” is to be specified for maintenance-related functions. IE create, modify, delete
The remaining characters are freely assignable.
Format: A BB C DDDDDDDDDDDDDDDD
Open (any alphanumeric identifier)
Function
Process Area
Constant ‘Z’
Format: AA BB C DDDDDDDDDDD
Example: Z_FI_CREDITNOTE
Format: AA BB C DDDDDDDDDDDDDDDDDDDDDDDD
D
Open (Description) – incorporate original
form name if copied from SAP
Separator
“_”
Applicat
ion/
Process
Area
Consta
nt ‘Z_’
Example: Z_FI_CREDITNOTE
The IDOC Message Type can be up to 30 characters long (although compatibility with SAP systems
prior to Release 4.0 requires a name of 6 characters or less). The name must begin with ‘Z’ to
SAP ABAP Developer Handbook Page 28 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
differentiate custom IDocs from standard IDocs. The next two characters of the name will contain the
application/process area. The outstanding characters should contain a meaningful description.
Format A BB C DDDDDDDDDDDDDDDDDDDDDDDDD
: D
Open (Description) – Message type name
Separator
“_”
Application/
Process Area
‘Z
’
Example: ZMM_METREAD
The IDOC basic type can be up to 30 characters long (although compatibility with SAP systems prior to
Release 4.0 requires a name of 8 characters or less). The name must begin with ‘Z’ to differentiate
custom IDocs from standard IDocs. The next two characters of the name will contain the
application/process area. The remaining characters should contain a meaningful description that
includes version release number. E.G. ‘01’.
Format: A BB C DDDDDDDDDDDDDDDDDDDDDDD
DDD
Open (Description) – Idoc name
Separator “_”
Application /
Process Area
‘Z’
Example: ZMM_METREAD01
The name of the IDoc Segment type can be up to 27 characters long (although compatibility with SAP
systems prior to Release 4.0 requires a name of 7 characters or less). The name must begin with ‘Z’ to
differentiate custom Idoc segments from standard Idoc segments. The next six characters (or more) of
the name will contain a meaningful description.
Format: A BB C DDDDDDDDDDDDDDDDDDDDD
DD
Open (Description) – Idoc segment
name
Separator “_”
Application /
Process Area
SAP ABAP Developer Handbook Page 29 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
‘Z’
Example: ZMM_METREAD
The function module used to process incoming IDocs with message type
"ZMM_METREAD" could be "Z_IDOC_INPUT_ ZMMI_METREAD".
The logical system name will contain 10 characters. The first three characters specify the system id and
the next four will contain the constant ‘CLNT’ to represent the client number. The last three will
contain the client number.
The model view technical name will contain 10 characters. The first character specifies a customer
object. The next two characters specify the process area followed by a free text description.
Format: A BB CCCCCCC
Open (Description) – Model view
name
Application/
Process Area
Constant ‘Z’
A prefix number needs to be assigned per client / SAP System to allow the differentiation and
verification. This is set automatically but needs to be checked when the system is delivered.
Position Usage
1 “Z” Application programs that will be moved to production.
2-3 SAP Functional Area/Module (refer to Appendix B).
4 Workflow type (‘W’ for Master workflows ‘S’ for Sub workflows).
5 - 12 Alphanumeric unique identifier
Note: whenever possible, objects should be delegated to the super object (with the
super object referenced in the workflow).
Packages/Development classes group together development objects (e.g. programs, tables, function
modules) which can be corrected and migrated together along a transport path. A
Package/Development class can, for example, consist of a transaction or a group of related transactions
along with programs, DDIC objects, menu painters, screen painters, lock objects, message classes,
match codes, etc.
As general rule a Package/Development class should be created for each new major project.
Notwithstanding this, if a developer believes that a unit of work is significant and deserves its own
Package/Development class, then an additional Package/Development class may be required.
The developer should request an additional Package/Development class from the SAP Custom
Development Team Lead.
No objects should be defined under the $TMP development class – prototyping should
only occur in the Sandbox environment.
The area menu follows the same naming conventions as transaction codes.
Format: A BB CCC
Open (any
alphanumeric
identifier)
Process
Area
Constant ‘Z’
Example
ZHR001
SAP ABAP Developer Handbook Page 32 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
3.4.7 Messages
Messages are used in ABAP programs to send information to the user. There are six different types of
messages: information, warning, error, abend, exit and success.
A message consists of a 4 character message class and a 3 digit number. The first character of the
message class should be a constant ‘Z’ and the next three characters will contain the Process Area. The
message number is open to any number between 000 and 999.
According to the naming conventions, only one message class can exist for each Process Area. When a
developer needs to create new message numbers, they need to request a number range within a specific
class from the development team lead.
Format: A BB CCC
Message Number between 000 - 999
Process Area
Constant ‘Z’
Example
Message Id ‘ZCO’ Type ‘E’ Number ‘001’.
Due to the strategic importance of logical databases and the potential impact on system performance,
careful consideration should be made before creating any new logical databases. Consequently, only
the DBA will be able to create logical databases.
Logical database names consist of six characters. The first character must begin with a constant ‘Z’.
The next three characters will contain the process area. The last two characters will represent the series
of logical database created in that process area eg 01, 02.
Format: A BB CC
Numbers
(00 - 99)
Process
Area
Constant
‘Z’
Example: ZPS01
Frequency: D - Daily
W - Weekly
M - Monthly
Q - Quarterly
R - On Request
Sequenti
ally
assigned
number
Requester’s
SAP Logon
& ‘_’
Critical/
Non-
Critical &
‘_’
Frequency
Flag
Live/Test
Run Flag
Program
Name &
‘_‘
Example ZMOPARI001_PMC_DS_001
Format: AAAAAAAAA B CC
Sequential number
matching last 2
digits of dataset
serial number (for
interfaces).
<or> Open (for
non-interfaces
Underscore “_”
<or> Open (for
non-interfaces)
Name of main
program that
created the session
Example: ZPRPI001_01
3.7 Datasets
It is important that SAP-specific dataset naming conventions be adhered since external systems will be
interfacing with SAP. Please note that the following naming convention will be confirmed and
amended accordingly after the details of interface control mechanism have been confirmed.
The file structure for all sap related datasets will be:
/INTERFACES
/<Process Area>
/IN /OUT
3.8.1 Project
Project ID is the highest level of the conversion object repository however individual objects needs to
be transported independently. Hence a new project will be created for each object.
i.e. FUSION – FOR Fusion Project
SAPSUPPORT – For SAP Support Team
3.8.2 Subproject
This should equate to the Process Area as defined in Section 3.1
3.8.3 Object
Object ID is used to identify the conversion objects created under each Subproject, Ensure that it is
named in such a way that a user can easily understand what the LSMW has been created for.
Example:
IT0001 – Organisation Assignment
FBD2 – Change re-occurring Payments
Notes:
Always use the ‘V’ in the prefix for definition of variables to avoid misunderstanding. In
normal ABAP GS_<variable_name> represents a global structure.
SAP ABAP Developer Handbook Page 37 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
Avoid using verbs at the start of names for variables in a class (CLASS-DATA, DATA),
because they will conflict with method names.
Protected data definitions start with an ‘S’ in accordance to the ‘super’ statement for the access
from a subclass to these data.
The parameters are seen from the point of view of the method that implements them:
Type Value
EXISTING An object that you want to create exists on the database already.
FAILED The method was not able to carry out its task, due to the current
environment situation. This exception is intended in particular for
situations where the environment is temporarily in a constellation that
makes it impossible to carry out task of the method.
..._FAILED A sub-function of the method could not be carried out, due to the current
environment situation. (OPEN_FAILED, CLOSE_FAILED,
SELECTION_FAILED, AUTHORIZATION_FAILED)
INVALID The specified object data is incorrect. (For example, company code not
available) ( as opposed to NOT_QUALIFIED)
INTERNAL_ERROR The last resort. Use this EXCEPTION when all else fails and the error
can not be narrowed down any further.
Path: TBC
Use the activatable checkpoints tool (transaction SAAB) to maintain checkpoint groups, their
respective activation variants, and the corresponding activation settings.
Checkpoints are used for test and control purposes. An ABAP program can contain the following types
of checkpoints:
Breakpoints
Logpoints
Assertions
To open the tips and tricks, on the initial screen, choose Tips & Tricks.
The Coverage Analyzer is a tool for software testing and quality assurance.
You use it to monitor the system-wide execution of ABAP programs on statement level. The Coverage
Analyzer counts the number of executions and runtime errors for processing blocks and statements
separated according to periods, test groups, and functional areas. You can use it to:
Determine the test coverage (even for single test runs)
Find areas of a program not covered by tests and to create additional ones in order to increase
the test coverage
Determine unused code
6 PROGRAMMING STANDARDS
This section contains the ABAP coding standards. The purpose of these standards is to:
Promote a consistent set of practices among developers. That means developers on the same
project and developers on different projects follow the same set of coding conventions.
Emphasise the importance of program documentation and style to the overall standard. Programs
should be documented and styled to the extent that another developer can pick up the code and
immediately start to understand it.
Write programs for people first, Computers second. This means an emphasis on code readability.
Readability has a positive effect on all these aspects of a program:
Comprehensibility
Reviewability
Debugging
Modifiability (for the original author and other editors)
Development time – a consequence of all the above factors
Quality - a consequence of all the above factors
ABAP programs that update master and/or transactional data MUST ALWAYS use SAP transaction
codes (where transaction codes are available) by utilizing BDC or ‘call transaction’ utilities. The only
exception to this would be the use of a BAPI or "direct input" program or Class Methods provided by
SAP. These methods ensure that logical units of work, rollback, locking operations and edits are
performed.
SAP-supplied tables MUST NEVER be updated directly by custom programs – always use standard
Function Modules/BAPI’s. ABAP programs MUST NEVER be used to update configuration tables.
Before writing any code, make sure that no existing programs or function modules, either custom or
SAP-supplied, satisfy the coding requirements. If custom coding is necessary, attempt to write the
module so that it is re-usable and can be stored in a central library. Function modules are an example of
this approach.
Internal and external documentation (design documents etc) must exist for a program. Because internal
documentation is bundled with the source code it is important that it remains reflective of the code
through-out its life.
The purpose of comments should be to say things about the code that the code cannot say about its
self. Good comments don’t repeat the code or explain it. Goods comments summarise the code and
clarify its intent. Comments should be written to explain at a higher level of abstraction than the
code what the developer has attempted to achieve. The following description of comment
classifications clarifies the distinctions between helpful and unhelpful comments:
Repeat of the code. A repetitious comment restates what the code does in different words.
These types of comments provide the reader with more to read without providing any
additional information.
Explanation of the code. Explanatory comments are used to explain complicated units of
code. Whilst these comments maybe useful it is because the code causes is not clear. If
the code is so complicated that is needs explanation, a better approach would be to
improve the code.
Intent Comments. Explains the purpose of the code. These types of comments operate
more at the level of the problem than the solution. That is, they explain “why” more than
the “how”.
Redundant Code should be removed from the program, i.e. the fields which are never referenced
and code which can never logically executed.
Internal online documentation (Documentation sub-object of a program) must be maintained for all
ABAP reports. This provides reference information for both developers and end-users.
*&---------------------------------------------------------------------*
*& Program Name : ZSKELTP01 *
*& Title : Basic ABAP List Report *
*& Module Name : Process Area *
*& Sub-Module : - *
*& Author : Waller (Change Author Name) *
*& Create Date : 15/08/2011 *
*& Logical DB : None *
*& Program Type : Report/Interface *
*& SIR/ CR No. : WRICEF Reference/CR/IR No *
*& SAP Release : ECC6.0 *
*& Description : This is a program template for Basic ABAP List *
*& Report. *
*&---------------------------------------------------------------------*
*& REVISION LOG *
*& *
*& LOG# DATE AUTHOR DESCRIPTION *
Every subsequent correction must be documented in the revision log section of the header comments
block. Not only do these log entries provide auditability but also allows for “at a glance” version
comparisons between different environments rather than via remote comparisons.
When modifying existing custom code delete all redundant code. That is, - don’t comment-out code and
mark with the change reference. Version Management will be utilised to identify changes. This will aid
readability of the code.
When a custom ABAP is modified, the information must be appended to the original Program
Specification. SAP Standard Version Control will be utilised to keep track of the changes.
Every logical section within the program should have descriptive comments immediately prior to the
actual code. End of line comments should be minimised.
*----------------------------------------------------------------------*
* Data declaration (<- Main function block)
*----------------------------------------------------------------------*
* data for storing formulas for analysis (<- Description of the data)
data: gt_work type yt_log_formulas,
gt_formula_listing type cfftb occurs 0.
* global variables for buffering receiving market (<- Description of the data)
* and step level during navigation
data: g_rcv like tkesk_lk01-eeinheit,
g_co_step type rkesk_konsstufe.
IF sy-subrc = 2.
STOP.
ENDIF.
START-OF-SELECTION.
SAP ABAP Developer Handbook Page 45 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
* check transaction (<- Intermediate commentary)
IF ( sy-tcode(4) NE 'KESK' ) AND
( sy-batch IS INITIAL ).
MESSAGE ID 'KESK' TYPE 'E' NUMBER '311'
WITH sy-tcode.
ENDIF.
* set flag for consolidation in function group KESK_02 (<- Intermediate commentary)
CALL FUNCTION 'RKE_SK_CONS_LOG'
EXPORTING
i_action = 'K'.
...
Allow the ABAP editor to generate the comments box. Construct the "PERFORM <form>"
statement and double-clicking on the <form>.
Provide a description of the subroutine’s purpose.
Describe each parameter declared in the parameter list.
o Each parameter must be prefixed with a “p_” and named in accord with EDF’s
standards for well-defined variable names. (Local declarations will be identified with
an “l_” prefix.
o Global variables must be visible within the scope of the subroutine. Global variables
may be accessed as actual parameters via the subroutine’s formal interface.
Example:
*&---------------------------------------------------------------------*
*& Form fc_tr_objects_append
*&---------------------------------------------------------------------*
* Append field cat. objects for transport interface
*----------------------------------------------------------------------*
* --> PV_OBJNAME name of object
* --> PV_TABKEY key of entry for object
* --> PV_OBJFUNC object function
* <->PT_E071 table with objects
* <->PT_E071K table with keys
* <-- PV_SUBRC returncode (= 0 if successful)
*----------------------------------------------------------------------*
Layout and formatting are features of a programming style. The use of these features aid the reduction
in a program’s complexity by highlighting the logical organisation of the code making it easier to read
and understand. Good layout can be achieved by using the following:
One statement per line. Although the ABAP intepretator does allow more than one statement per
line use of this style is to be avioded.
Indentation. Use indentation to show the logical structure of code. As a rule statements should be
indented under the statement to which they are logically sub-ordinate.
o The PRETTY PRINTER command uniformly indents each nested command structure by
2 positions. Use the convert Keyword to Upper Case option.
Alignment. Align elements that belong together. Alignment of code reinforces the idea that a group
of statements belong together. All TYPEs, TOs, VALUEs, DEFAULTs, table names, and
comments should be aligned among themselves throughout the code, For example.
Modularise code. Dividing code into partitions is a technique to improve the readability of the
overall logic structure.
Use Data Dictionary names (short, medium, long) for field text on screens where applicable;
Always define the field with a Format = OK as OK_CODE. This field is used to validate the
OK Event;
Screen and program field names should generally be identical;
Define all global data in the main program (TOP) module instead of the PBO/PAI;
To handle a lock entry failure, invoke an error message (type E) to prevent any further
progress but leaving the user on the current screen. The user can then take an alternative action
or continue to try to lock the object. To minimize the impact on users, limit retries;
When activating buttons or boxes, activate the associated text as well. This enables the user to
click on either the button/box or the text;
Do not use AT PFnn in programs. Instead use the function name so that any method of
invoking the function will have the same effect as the use of the PF-Key.
Database tables can be stored locally on each application server. Performance time may be improved
because reading from the buffer avoids directly accessing the database. Within SAP, only POOLED
and TRANSPARENT tables allow buffering.
Considerations:
Only buffer a table that has read-only accesses made against it and is referenced frequently.
Only buffer tables that are modifiable, if write access occurs infrequently. Changes to buffered
tables get automatically logged in the database and are transferred to the application servers at
regular intervals. If buffered tables are modified frequently, the additional processing needed
may cancel any performance gains attained by buffering.
Native SQL commands always bypass the buffer and access the database directly. If native SQL was to
update a buffered table directly, the buffer status is not changed; this could result in inconsistencies
between data in the buffer and the database.
The order of preference for the development of ALV grid reports is to use the ALV object
model primarily. Where a developer is unfamiliar with the object oriented nature of this ALV
model then it may be allowable to use the List Viewer Class (LVC) functions to implement
and ABAP list views. The older style SLIS ALV reports should not be used unless it is to
maintain compatibility with an existing development.
Classes using the latest ALV object models may be found using wildcard searches on classes
and functions using the SALV* or *SALV* parameters. Example and demo programs exist
that may be used as a reference. These are available within transactions SE80 and SE38.
Field catalogues for ALV reports are to be generated from dictionary based structures using
ALV field catalogue merge function modules. Manual fields may be added when a suitable
structure does not exist and less than 5 fields are required. Reference dictionary structures are
used to provide long text help, correct field formatting and column headings. Refer to
function LVC_FIELDCATALOG_MERGE
Column headings must not be hard coded. The column headings may be created using text
elements in instances where fields are added manually to the field catalogue.
Reference fields in ALV field catalogues should point to structure / fieldname combinations
wherever possible. (i.e. do not use direct reference of data types such as CHAR).
Fields not intended for display or field catalogue selection are to have the technical value set to
TRUE (X) to ensure they are not displayed.
SAP ABAP Developer Handbook Page 50 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
ALV field catalogue maintenance authority should default to own user maintenance by default
unless other specified by the technical script. Default Global layouts may be created in the
development client and transported to other clients if required.
ALV layouts should also include the grouping and sorting internal tables passed to the
functions as a default to allow the groups and sorting to be retained.
ALV fields that are editable or require F4 lookup help should not have hotspot (hyperlink)
function enabled as this will override the Enter or F4 functionality in the field.
Standard ALV functions such as Excel export should be retained unless the Specification
specifically excludes the requirement.
Generally ALV performance is good however in certain situations degradation may occur if too many
round trips caused by statements that flush data between the front
end (PC) and backend systems (SAP). Therefore any design that uses large datasets must consider the
performance over a wide area network (WAN) and not just the local network.
Web Dynpro ABAP is the SAP standard UI technology for developing Web applications in the ABAP
environment. It consists of a runtime environment and a graphical development environment with
special Web Dynpro tools that are integrated in the ABAP Workbench (SE80). Web Dynpro offers the
following advantages:
The use of declarative and graphical tools significantly reduces the implementation effort
Web Dynpro supports a structured design process
Strict separation between layout and business data
Reuse and better maintainability by using components
The layout and navigation is easily changed using the Web Dynpro tools
Stateful applications are supported – that is, if the page is changed and the required data
remains intact so that you can access it at any time throughout the entire application context.
Note that stateless applications are not possible.
Automatic data transport using data binding
Automatic input check
User interface accessibility is supported
Full integration in the reliable ABAP development environment
UI objects are created using drag and drop of UI elements which fastens overall development
time.
supports both JAVA and ABAP development
While designing the UI layout, it should follow any one of the pattern which is shown below.
A form pane shall not have a white background color. With all SAP-branded background colors, the
white input fields appear slightly highlighted and the blueish disabled or read-only fields are down
lighted. This guides the user to the editable parts of the screen. A form pane can only have max 2
“columns” of label-field combinations.
SAP ABAP Developer Handbook Page 52 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
6.6.1.2 BSP (Business Server Pages)
The SAP Web Application Server provides a page-based programming model with server-side scripting
as well as server page technology for developing, designing and implementing Web applications:
Business Server Pages (BSP). Server-side scripting enables direct access to all elements in the
application server (such as function modules, database tables, ABAP Objects, and so on.).
Flexible for web oriented development since it mixes ABAP, HTML, HTMLB and JavaScript.
Only supports ABAP development
There should be no hard-coding of date formats in the programs, the date format of the users’ default
information (SU50) should be used to output any date. When creating a BDC session the ABAP should
use the user default date format when formatting the record for the screen. We can’t make assumptions
about the date format of the user executing the program.
There will be no hard-coding of currency output formats in our programs. The decimal notation of the
users’ default information (SU50) should be used to output any currency value.
SAP currently does not support multiple time zones, so the time used in the system is the time that the
database server is set to. The system field SY-TZONE indicates the time difference in seconds to GMT
time.
Basic event such as START-OF-SELECTION, END-OF-SELECTION should be included in the
program to improve the readability of the program.
I2 = <F>. I2 = <FS_I>.
I3 = <F>. I3 = <FS_I>.
I4 = <F>. I4 = <FS_I>.
Use Data Dictionary names (short, medium, long) for field text on screens where applicable. Always
define the field with a Format = OK as OK_CODE. This field is used to validate the OK Event.
Screen and program field names should generally be identical. Define all global data in the main
program (TOP) module instead of the PBO/PAI.
To handle a lock entry failure, invoke an error message (type E) to prevent any further progress but
leaving the user on the current screen. The user can then take an alternative action or continue to try to
lock the object. To minimize the impact on users, limit retries.
While activating buttons or boxes, activate the associated text as well. This enables the user to click on
either the button/box or the text.
Do not use AT PFnn in programs. Instead use the function name so that any method of invoking the
function will have the same effect as the use of the PF-Key.
Example:
AT SELECTION-SCREEN.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = P_LDSNME
IMPORTING
FILE_NAME = G_PDSNAME
EXCEPTIONS
FILE_NOT_FOUND = 01.
IF SY-SUBRC <> 0.
*-------No physical filename can be determined for &
MESSAGE E016(MG)WITH P_LDSNME.
ENDIF.
START-OF-SELECTION.
IF SY-SUBRC <> 0.
* Insert error processing here.
ENDIF.
6.6.6 Message
Messages are included at appropriate places to indicate illegal operation like no authorization, no data
found, etc. Although consistency with SAP-supplied messages is highly encouraged, do not use SAP-
A program should test the system return code field (SY-SUBRC) after any statements that could
potentially change its value unless the outcome of the statement is not important for subsequent
processing.
The return code should always be checked after any database table read/update statements or READ
statements.
E.G: SELECT * FROM PA0000.
…DO Processing
ENDSELECT.
IF SY-SUBRC = 0.
WRITE: / ‘ ‘
ENDIF.
CHECK, EXIT, REJECT, STOP is used to suspend processing or skip unnecessary processing.
CASE statements are clearer for legibility and slightly faster than IF-constructions. After about five
nested Ifs the performance of the CASE is more efficient.
WHILE is used instead of a DO+EXIT-construction, because WHILE is easier to understand and faster
to execute.
Do While
I1 = 0. I1 = 0.
DO. WHILE C1A = SPACE.
IF C1A NE SPACE. EXIT. ENDIF. ADD 1 TO I1.
ADD 1 TO I1. IF I1 GT 10. C1A = 'X'. ENDIF.
IF I1 GT 10. C1A = 'X'. ENDIF. ENDWHILE.
ENDDO.
Runtime Measure(in microsec): 5 Runtime Measure(in microsec): 3
Notes: The runtimes depicted in this manual are just sample measurement, they are measured on multi-
processor environment, and they are, however, not runtime measurement benchmarks.
Case Perform i Of …
* (I1 = 5 in this test) * (I1 = 5 in this test)
CASE I1. PERFORM I1 OF
WHEN 1. PERFORM PV1. PV1
WHEN 2. PERFORM PV2. PV2
WHEN 3. PERFORM PV3. PV3
WHEN 4. PERFORM PV4. PV4
WHEN 5. PERFORM PV5. PV5
WHEN 6. PERFORM PV6. PV6
WHEN 7. PERFORM PV7. PV7
WHEN 8. PERFORM PV8. PV8.
Runtime Measure(in microsec): 5 Runtime Measure(in microsec): 2
LOOP …. WHERE is faster than LOOP/CHECK because LOOP …. WHERE evaluates the specific
condition internally.
Loop/Check Loop/Where
LOOP AT ITAB. LOOP AT ITAB WHERE NAME1 = KVAL.
CHECK ITAB-NAME1 = KVAL. ……….
ENDLOOP. ENDLOOP.
Avoid the use of this statement. The expressed use of “MOVE” is recommended.
The way SQL statements are construction within an ABAP program will have an affect on its overall
runtime performance. The developer’s role should be to build programs that access the database in the
most efficient manner. Awareness of the following rules during the design phase will aid the decision-
making process:
Minimise the number of transfers between the database and application server.
Minimise the amount of data to be transferred between the database and application server.
Minimise the workload of the database.
Aim to retrieve only the database table columns required. That is, limit the usage of the Select All fields
(Select *) statement to scenarios which dictate the need to transfer all the table’s columns from the
database to the program. The number of columns retrieved may be restricted in two ways:
Specification of a field list within the SELECT clause; or
Use of a DDIC table view projection. (A DDIC view has the added advantage of being
reusable).
SELECT statement that specifies all fields SELECT statement with a field list
specified
SELECT * FROM DD01L SELECT DOMNAME FROM DD01L
WHERE DOMNAME LIKE 'CHAR%' INTO DD01L-DOMNAME
AND AS4LOCAL = 'A'. WHERE DOMNAME LIKE 'CHAR%'
ENDSELECT. AND AS4LOCAL = 'A'.
ENDSELECT.
Runtime Measure(in microsec): 42,880 Runtime Measure(in microsec): 11,402
Use a select list with aggregate functions instead of checking and computing, when try to find the
maximum, minimum, sum and average value or the count of a database column, thus network load is
considerably less.
Aim to minimise the number of database table rows retrieved. The specification of the WHERE-clause
avoids the need to retrieve each row of a database table to determine whether it is valid or not for
further processing.
A justification to omit the WHERE-clause is when the entire contents of the database table are required.
The once-only read of a reference value table would fit this criterion.
A WHERE-clause should be formulated to employ a database table index. Each SAP database table has
a primary key (UNIQUE index) and maybe one or more secondary keys defined that supports efficient
searches of its content. Avoid the use of unsupported SELECT statements that result in expensive
searches.
When the primary key can be fully qualified make use of the SELECT SINGLE option instead of
SELECT-ENDSELECT. SELECT SINGLE requires one communication with the database system
whereas SELECT-ENDSELECT needs two.
In the scenario where the available primary or secondary keys defined for a table cannot be fully
qualified then consider the following options:
Evaluate the source of data being used and identify whether an alternative table exists (that
contains the desired data) that can be accessed more efficiently. For example, an unsupported
read on a large (CLUSTER) table like BSEG should be replaced with a read on one of the
accounting secondary indexed tables (BSAD, BSID, BSIS, BSAS, BSAK, BSIK).
Create a new secondary index for the target table in the DDIC.
Make use of the “UP TO N ROWS” option in the FROM-clause to restrict the number of table
rows returned.
Index utilisation is part of the “Minimize the Amount of Data Transferred” objective. To ensure that the
actual table search is optimal developers heed the following factors:
Satisfy as much of the chosen index definition as possible. The database optimiser can still
make use of an index even though the query does not make use of all of the columns specified
in its definition. In this case the sequence of the columns in the index is important as a column
can only be used if all of the columns preceding it in the index’s definition have also been
specified as part of the condition.
Phrase each condition within the query to be positive where possible. Use of negative
operators such as “Not Equal” or “Not Exist” or “Not Like” disables the database optimizer
from using a table index.
The use of equality (EQ) checks and conjunctions (AND) are the most efficient expressions.
“OR” expressions may prevent the database optimiser making use of the full index. This
means that the index columns involved in the “OR” expression may not be included in the
index search. An exception to this are “OR” expressions at the outside of conditions.
SAP ABAP Developer Handbook Page 60 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
6.7.2.1.3 INTO Clause
Use the “INTO TABLE” OR “APPENDING TABLE” options rather than Append each record one at a
time.
It is recommended that the use of the ORDER BY clause is restricted to when the primary key is fully
qualified. Otherwise, store the data in an internal table and use the ABAP SORT statement.
Use array operations instead of single-row operations to modify database tables. The frequent
communication between the application program and database system produces considerable overhead.
Use column-specified table updates instead of entire row updates.. Network load can then be
considerably less.
Avoid the use of nested select statements. Instead use one of the following options:
Table join statement,
DDIC view,
Sub-query select statement
“For All Entries” statement.
o Ensure that the internal table contains at least one entry; and
o Sort internal table by the fields to be used in the WHERE-clause.
Aim to read a given set of data once. Repeated reads of the same data increases the number of database
accesses and increases the load on the database. An example of a repeated read is SELECT before an
UPDATE.
Table buffering on the application server for accessing frequently used, read-only tables, network load
can be considerably less. However, in case of retrieving latest data in multi-user environment, you may
need to bypass the buffer.
For a buffered table do not to use any Open SQL statements that bypass the buffer. The SELECT
statement will bypass the table buffer when any of the following options are used:
The use of a logical database is an option supplied by SAP to limit the database workload. A logical
database executes authorization checking for data access, but even if you just access one table, you will
still need to access all the tables above the current hierarchy level in logical database, which creates
data access inefficiency.
Internal table access can be done more efficiently with the right use of the table type. See
documentation on ABAP keyword TABKIND for the different table types:
any
index
standard
sorted
hashed
Apart from performance advantages that can be obtained, the different table types can have a different
syntax for table operations. Please refer to the online help for more details.
Especially with large amounts of data, internal table access can take a lot of time if the wrong table type
is used.
When loading data into Internal table, INTO TABLE OR APPENDING TABLE is used instead of a
SELECT/APPEND combination.
Use one-step approach READ/INSERT, If the amount of data is small (< 20 entries), or if users need
read-access to the internal table while it is being filled, however, if the data amount is larger and you
need read-access only to the completely-filled table, the two-step algorithm APPEND/SORT or three-
step approach APPEND/SORT/DELETE DUPLICATE (for tables without duplicates) is preferable.
COLLECT is used instead of READBINARY/INSERT If number of entries greater than 1000. READ
BINARY runs in O(log2 (n)) time, and the internal table's index must be adjusted with each INSERT,
however, COLLECT uses a hash algorithm and is therefore independent of the number of entries and
does not need to maintain a table index. If the amount of data is small, the READ/INSERT approach
isn't bad, but for large amounts of data (> 1000), COLLECT is much faster.
Use BINARY SEARCH instead of linear search when internal table has more than 20 entries. If TAB
has n entries, linear search runs in O(n) time, whereas binary search takes only O(log2 (n)). And also
when reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ.
Therefore, SORT the table and use READ TABLE WITH KEY BINARY SEARCH.
READ TABLE TAB WITH KEY K = 'X'. READ TABLE TAB WITH KEY K = 'X'
BINARY SEARCH.
Runtime Measure(in microsec): 875 Runtime Measure(in microsec): 11
Specify the key fields for read access explicitly, use READ TABLE WITH KEY k = ‘X’ instead of
READ TABLE WITH KEY. Otherwise, the key fields have to be computed dynamically by the run
time system.
Access via implicit default key Access via key specified explicitly
* Table TAB is filled with 30 entries of 500 bytes * Table TAB is filled with 30 entries of 500 bytes
each each
* The READ ends with SY-SUBRC=4 * The READ ends with SY-SUBRC=4
LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified
condition internally. The performance can be further enhanced if LOOP ... WHERE is combined with
FROM i1 and/or TO i2, if possible.
Internal tables can be compared, copied in logical expressions just like other data objects. Two internal
tables are equal if
- They have the same number of lines and
- Each pair of corresponding lines is equal.
Pedestrian way to compare internal tables Let the kernel to do the work …
* Tables TAB1 & TAB2 are each filled with 100 * Tables TAB1 & TAB2 are each filled with 100
entries entries
SAP ABAP Developer Handbook Page 66 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
* of 100 Bytes each. * of 100 Bytes each.
IF TAB_DIFFERENT = SPACE.
" ...
ENDIF.
Runtime Measure(in microsec): 741 Runtime Measure(in microsec): 152
Specify the sort fields on the sort statement, not leave the fields as default, the more restrictively you
specify the sort key, the faster the program will run.
Sort internal table with default sort key Sort with sort key specified explicitly
* Table TAB is filled with 100 entries of 500 bytes * Table TAB is filled with 100 entries of 500
each bytes each
Use parallel cursor instead of join two tables or nested loop. If TAB1 has n1 entries and TAB2 has n2
entries, the time needed for joining TAB1 and TAB2 with the straightforward algorithm is O( n1 *
log2( n2 ) ), nested loop is O( n1 * n2 ), whereas the parallel cursor approach takes only O( n1 + n2 )
time.
Native join: loop tab1, read tab2 with key More sophisticated: use parallel cursor
* Table TAB1 is filled with 1000 entries of 100 * Table TAB1 is filled with 1000 entries of 100
bytes each bytes each
* Table TAB2 is filled with 300 entries of 100 * Table TAB2 is filled with 300 entries of 100
bytes each bytes each
* Table TAB2 is assumed to be sorted by K in * Tables TAB1 & TAB2 to be sorted by K
ascending ascending
* order
I2 = 1.
LOOP AT TAB1. LOOP AT TAB1.
READ TABLE TAB2 WITH KEY READ TABLE TAB2 INDEX I2.
K = TAB1-K BINARY SEARCH. IF SY-SUBRC <> 0. EXIT. ENDIF.
IF SY-SUBRC = 0. IF TAB2-K = TAB1-K.
" ... " ...
ENDIF. ADD 1 TO I2.
ENDLOOP. ENDIF.
ENDLOOP.
Runtime Measure(in microsec): 16,723 Runtime Measure(in microsec): 6,228
Straight forward nested loop More sophisticated loop: parallel cursor
* Table TAB1 is filled with 100 entries of 100 * TAB1 is filled with 100 entries of 100 bytes
SAP ABAP Developer Handbook Page 67 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
bytes each each
* Table TAB2 is filled with 10 * 100 = 1000 * TAB2 is filled with 10 * 100 = 1000 entries of
entries of 100 bytes each
* 100 bytes each * TAB1 & TAB2 assumed to be sorted by K in
ascending order
LOOP AT TAB1. I2 = 1.
LOOP AT TAB2 WHERE K = TAB1-K. LOOP AT TAB1.
“… LOOP AT TAB2 FROM I2.
ENDLOOP. IF TAB2-K <> TAB1-K.
ENDLOOP. I2 = SY-TABIX.
EXIT.
ENDIF.
“…
ENDLOOP.
ENDLOOP.
Runtime Measure(in microsec): 180,472 Runtime Measure(in microsec): 8,839
Use the MODIFY variant “MODIFY itab ... TRANSPORTING f1 f2 ...” for single line, and
“MODIFY itab ... TRANSPORTING f1 f2 ...” WHERE condition for a set of line, to accelerate the
updating of internal table. The longer the table line is, the larger the speed-up is. The effect increases
for tables with complex structured line types.
Use APPEND LINES OF itab1 TO itab2 and INSERT LINES OF itab1 INTO itab2 INDEX idx instead
of APPEND and INSERT. And thus the task of appending and insert a table to another table can be
transferred to the kernel.
Use DELETE ADJACENT DUPLICATES / DELETE itab FROM ... TO ... / DELETE itab [FROM ...]
[TO ...] WHERE ... instead of DELETE, to transfer the task of deleting entries to the kernel.
Use “DELETE itab WHERE ...” instead of “LOOP AT itab WHERE ... DELETE itab. ENDLOOP.”
increases with the number of entries the internal table contains and the number of lines to be deleted.
If the data is processed only once, use a SELECT-ENDSELECT loop instead of collecting data in
an internal table with SELECT ….INTO TABLE because the Internal table handling takes up much
more space.
Internal tables can be copied by move just like any other data object.
Use the special operators CO, CA, CS, instead of programming the operations yourself. If ABAP
statements are executed per character on long strings, CPU consumption can rise substantially.
Some function modules for string manipulation have become obsolete and should be replaced by ABAP
statements or functions:
STRING_CONCATENATE... -> CONCATENATE,
STRING_SPLIT... -> SPLIT,
STRING_LENGTH -> strlen(),
STRING_CENTER -> WRITE...TO...CENTERED,
STRING_MOVE_RIGHT -> WRITE...TO...RIGHT-JUSTIFIED,
Use the CONCATENATE / SPLIT statement instead of programming a string concatenation of your
own.
"Mrs. Jane Miller from New York City" I "Mrs. Jane Miller from New York City" i
Use of SEARCH and MOVE with Offset Use of the SPLIT statement
"CMA contains '(410)-45174-66354312' and shall "CMA contains '(410)-45174-66354312' and shall
"be split into AREA_CODE, "be splitted into AREA_CODE,
" TEL_NO1, " TEL_NO1,
" TEL_NO2. " TEL_NO2.
SEARCH CMA FOR '-'.
MOVE CMA(SY-FDPOS) TO AREA_CODE.
I1 = SY-FDPOS + 2. SPLIT CMA AT '-' INTO AREA_CODE
SEARCH CMA FOR '-' STARTING AT I1. TEL_NO1
I1 = I1 - 1. TEL_NO2.
MOVE CMA+I1(SY-FDPOS) TO TEL_NO1.
I1 = I1 + SY-FDPOS + 1.
MOVE CMA+I1 TO TEL_NO2.
Runtime Measure(in microsec): 27 Runtime Measure(in microsec): 4
If you want to delete the leading spaces in a string, use the ABAP statement SHIFT...LEFT
DELETING LEADING.... Other constructions (with CN and SHIFT...BY SY-FDPOS PLACES, with
CONDENSE if possible, with CN and ASSIGN CLA+SY-FDPOS (LEN) ...) are not as fast. In any
case, avoid using SHIFT inside a WHILE-loop!
Use the STRLEN( ) function to restrict the DO loop to the relevant part of the field, e.g. when
determining a check-sum.
I1 = STRLEN( CLA ).
DO 64 TIMES VARYING STR FROM CLA DO I1 TIMES VARYING STR FROM CLA
NEXT CLA+1. NEXT CLA+1.
CHECK STR NE SPACE. CHECK STR NE SPACE.
ADD STR-LINE TO CHECK_SUM. ADD STR-LINE TO CHECK_SUM.
ENDDO. ENDDO.
Use "CLEAR f WITH val" whenever you want to initialize a field with a value different from the field's
type-specific initial value.
6.8.2 BAPI’s
It is difficult to formalize the contents and functional scope of a BAPI. Every BAPI has a different
functional content, even those that perform similar functions, for example, the standardized BAPIs. The
differences are mainly due to the different characteristics of SAP business object types and their
contents.
Minimize interface complexity. Supply the BAPI with the minimum of data and group the data from a
business perspective. Structure your BAPI in the most efficient way. BAPIs must not invoke COMMIT
WORK commands. In the case of exceptions: If the BAPI contains a COMMIT WORK command; this
must be documented.
CALL TRANSACTION
SUBMIT REPORT
SUBMIT REPORT AND RETURN
INCLUDE structures must not be used in BAPI structures. Database changes can only be made through
updates. The global memory must not be used to transfer values. Due to transparency it is strongly
recommended not to use Set and Get. If required every BAPI must be able to carry out its own
SAP ABAP Developer Handbook Page 72 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
authorization checks. Values relevant for Customizing are not allowed to be changed. Language-
dependent values cannot be used as interface parameters.
BAPIs must not produce any screen output. This means that lists, queries and dialog boxes must not be
returned to the calling program. This is true for the BAPI itself and for any function module that may be
indirectly called by the BAPI.
BAPIs must not cause program terminations, they can only return a message (type A: termination
message) in the return parameter. Messages of type E (error) and A (termination) cannot be output in
the program.
Standardized parameters must be implemented consistently. Each BAPI must have a return parameter
for returning messages to the calling application. All quantity and amount fields must be assigned
quantity unit fields. All currency amount fields must be assigned currency IDs. All key fields in
GetDetail() and GetList() BAPIs must be displayed as text fields. Whenever possible, F4 input help for
fields in BAPI parameters must be made available
Except for:
You must always use a period for the decimal point. Currency amounts with decimal points must be
formatted with a decimal point in the interface. For example, the value "10.12" must be formatted as
"10.12" and not as "1012".
If the BAPI to be implemented is a standardized BAPI, use the generic names, for example,
GetList, GetDetail. You should particularly note the difference between reading and writing
methods and between simple and multiple methods.
The individual components of a BAPI name are separated by the use of upper and lower case.
Example: GetList
Underscores ("_") are not allowed in BAPI names.
Each BAPI has a return parameter that is either an export parameter or an export table.
Customers can enhance BAPIs, each BAPI must have an ExtensionIn and an ExtensionOut
parameter.
Obligatory parameters should be checked to see if they can become optional in the future. This
is important to avoid possible incompatible changes to the interface and to guarantee the
stability of the interface.
If standardized parameters are used, you have to use the names specified for standardized
parameters.
BAPI parameter names should be as meaningful as possible.
The components of a parameter name in the BOR are separated by upper and lower case letters
to make them easier to read. Example : FlightList.
Values that belong to each other semantically should be grouped together in one structured
parameter, instead of using several scalar parameters.
SAP ABAP Developer Handbook Page 73 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
For ISO-relevant fields (country, language, unit of measure, currency), additional fields for
ISO codes are provided.
Unit of measure fields must accompany all quantity fields and currency identifiers must
accompany currency amount fields
6.8.3 IDOC’s
Below are some of the design guidelines and formatting rules for creating new segments and IDOC
types,
Do not re-invent the wheel. Before you create a new segment, check whether your
requirements can be met by an existing segment.
Group your data in a meaningful manner. Business data is contained in segment fields. Data
which belongs together from a logical point of view should be combined to form a segment.
Segments which belong together from a logical point of view should be combined to form a
segment group. For example, the materials in a purchase order could be contained in one
segment. Together with other segments (information about the partner, taxes and terms of
payment), this segment can then form part of the "Items" segment group.
Create universal segments. You can use segments which you have already created in other
IDoc types. Check whether a segment can be used for different messages. An example of a
universal segment is one which contains general address data.
Create clearly arranged segments and segment groups. Position the required fields as close as
possible to the start of the segment. Two segments which always occur together should be
combined in one segment. Consider whether the use of qualifiers can be avoided. Qualifiers
indicate how a segment is used and are difficult to document and interpret. Qualifiers are not
usually defined on a cross-application basis, with the result that these segments are not
universal.
Don’t waste space. The maximum length of all the fields in a segment is 1000 characters. The
larger the segment, the better the ratio of useful data to administration data. A certain amount
of space should be reserved in segments to allow for additional fields in the future.
Document your segments. Use the documentation options provided by the segment editor. You
can store an additional data element for each field to provide information about how the field
is used in the application. You can also document a segment to explain the attributes and
structure of the entire segment. When documenting segments, remember that the segment
fields are used in both inbound and outbound processing.
Remember that conversion to EDI standards may be necessary.
The segment fields may only contain alphanumeric data. You can make sure that this is the
case by using data elements which contain characters in the segment fields.
No distinction is made between upper case and lower case letters.
The fields are maintained in such a way that the values are left-justified.
The standard date representation (without qualifiers) is YYYYMMDD. February 28, 1996 is
therefore represented as 19960228.
The standard time representation (without qualifiers) is HHMMSS. 8.35pm is therefore
represented as 203500.
Values with a fixed decimal point are represented with a decimal point only - there is no
thousand delimiters. Negative values are indicated by a minus sign after the value. The number
-2,097,152.64 is represented as 2097152.64-.
Floating point numbers are represented with a decimal point - there is no thousand delimiters.
Negative values are indicated via a minus sign after the value and the exponent is always
specified. The number -23.4 is represented as -2.34E+01.
The following rules may be useful if your IDocs are to be converted to other EDI standards (EDIFACT,
ANSI X12):
If possible, segment fields in the IDoc should be represented directly by EDI data elements.
Avoid splitting or combining fields or other changes which could lead to problems with
automatic conversion.
SAP ABAP Developer Handbook Page 74 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
The field length should be equal to the maximum length of the SAP application or relevant
EDI standard (depending on which is longer), so that all the existing information can always
be transferred.
The required segment fields in the EDI standard must be present in the IDoc segment, to
ensure that the IDocs can be converted correctly.
Custom developments can be realised through various instruments. An overview is given in the
following table.
The approach to adaptation should be to first exhaust all Customization possibilities. Where
Customization is not flexible enough to satisfy a business requirement then Enhancement options
should be investigated. The use of Modification should be avoided because the total cost of ownership
is higher than that of an Enhancement option.
The Enhancement concept provides a framework to enhance core source code without Modification.
The basic mechanism is to offer the enhancement options that function like “hooks” where you can
attach the enhancements.
Explicit enhancement options of the enhancement point type allow you to insert source code
plug-ins. These are additional code lines that, if they exist, are executed there additionally.
Explicit enhancement options of the type Enhancement Section behave in the same way – the
only difference being that the source code plug-in replaces the section in the original code.
Business Add-Ins (BAdIs) are “hangers” for object plug-ins. A BAdI definition comprises an
interface with methods. BAdIs are enhanced by classes that implement the BAdI interface. If
you instantiate a BAdI and then call its methods, you can, among other things, specify which
method implementations are to be carried out on the basis of filter values. In other words, a
BAdI method call is a dynamic method call with a specified interface, for which it is not
determined until runtime which method implementations are to take place.
Enhancement spots are used to manage explicit enhancement options. Enhancement spots carry
information about the positions at which enhancement options were created. The enhancement spot is a
similar concept to a ‘SAP Enhancement’ and the enhancement options corresponds to a user exit within
a ‘SAP Enhancement’.
You create an explicit enhancement option when processing a Repository object with the relevant tool
by creating an enhancement spot element definition at a point where this is possible. This enhancement
option can then be called at different points using enhancement spot element calls. The enhancement
spot element definition and the corresponding enhancement spot element calls make up the definition of
an enhancement option. For example, when editing an ABAP program with the ABAP Editor, you can
define explicit enhancement options in the form of the ENHANCEMENT-POINT statement, which
also represents the element definition and element call.
Where enhancement spots exist in SAP these should be used to provide custom modifications.
Transaction SE18 can be used to view Enhancement Spots.
The Append technique permits the enhancement of a transparent table or structure in a modification-
free manner which is protected from SAP updates. An Append structure can only be assigned to
exactly one table or structure albeit a table or structure can have many Append statements.
Append Structures follow the naming pattern as Z* or Y*. Underscores ‘_’ are not allowed in
the name at 2nd &3rd character.
The fields in the append structure must also reside in the customer namespace. That is, - a field
name should begin with ZZ or YY.
SAP ABAP Developer Handbook Page 77 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
SAP may make available one or more pre-define append structures names available for use at
the time of creation.
Customer Append structures are not permissible for Pool tables and Cluster tables.
Some SAP standard tables contain a reserved part for enhancements occupied by a special structure
called a Customer or Customizing Include. These special structures can be identified in the DDIC with
the prefix “CI_”. Like the Append technique a customer’s changes are protected from SAP updates.
The fields in the Customer/Customizing Include must reside in the customer namespace. That
is, - a field name should begin with ZZ or YY.
A Customer/Customizing Include may be reused in multiple tables or structures.
The terms “Customer Include” and “Customizing Include” are used synonymously.
6.9.2.1.3 Views
If there are views (projection views, help views, and maintenance views) of tables that have been
enhanced using APPENDs or INCLUDEs, these views usually need to be enhanced accordingly and
regenerated if you want the new fields to appear in them.
7 SAP NOTES
A SAP Online Service System (OSS) Note is a published response to a specific issue related to a SAP
product. A “Note” typically provides a source code correction to a standard object but may provide
other information such as answers to frequently asked questions.
Transaction code “SNOTE” automates the process of note download and implementation. A SAP note
should be applied using “SNOTE” when applicable.
This section focuses on aspects of quality assurance. Development efforts that include quality
assurance activities produce better deliverables than those that do not. Two techniques used to improve
quality are unit testing and technical reviews.
A good Unit Test plan is always helpful in putting together the conditions and various inputs that the
individual objects have to be tested with. The following template can be used to write this test plan.
During the actual testing, it serves as a check list. It is also important to collect the results in the form of
Remarks/Comments in this document to ensure completeness.
Find attached the Code Review checklist and Design review checklist which should be completed by
the Reviewer during the Code Review Phase.
ABAP features a class-based exception concept. It is similar to the corresponding concept in Java, but
offers the user more flexibility in a number of aspects. When you write new code, you should only use
the new class-based exceptions for error handling.
For more information check out the following link:
http://help.sap.com/saphelp_nwpi71/helpdata/en/cf/f2bbc8142c11d3b93a0000e8353423/frameset.htm
ABAP http://help.sap.com/saphelp_nwpi71/helpdata/en/
43/55509bf8a75f6be10000000a1553f6/frameset.htm
Function Library http://help.sap.com/saphelp_nwpi71/helpdata/en/2a/
f9ff44493111d182b70000e829fbfe/frameset.htm
SDN - ABAP https://www.sdn.sap.com/irj/sdn/abap
The objective is to ensure that a consistent approach is adopted across the Orchard Programme which is
robust, flexible and consistent across all Orchard SAP systems and environments.
9.5.2 Audience
Functional Consultants
Technical Designers
9.5.3 Summary
Interface files will be delivered to and retrieved from a consistent location on all SAP systems
Logical file names / file paths will be used within custom developments rather than hard
coding or the use of input parameters.
Mapping of logical file names / file paths to physical file names / file paths will be done using
the SAP Standard Transaction “FILE”.
Manual retrieval of Interface Files or Background Scheduled Reports will use a standard
approach.
It does not apply where idocs or ALE are used as the means of passing data
Note: Although specifically intended for SAP systems the same physical directories could be used
on non SAP systems if required.
The directory structures will have the following physical location formats:
Where:
/INTERFACES/ is a mounted file system on the appropriate NFS server
(Development, Test, Production).
<INTERFACE_NAME> is the name of the interface e.g. “thamescard”
For example the following screen shot (from EDF Energy Corporate SAP system) shows the mapping
of the Logical File Name “Z_BENEFEX_IN” to the physical location
“/INTERFACES/BENEFEX/IN”
Custom developments must not contain hardcoded physical locations, but must use Logical Names as
described in the next section.
Note: The FILE transaction can be used to map a logical name to a fully qualified physical file name
or to all or part of the physical path as proposed in this document.
Using the previous example if G_fname = “Z_BENEFEX_IN” the function module would return
“/INTERFACES/BENEFEX/IN/” in the ECC6.0 system.
For inbound files “IN/<FILE_NAME>” would have to be appended to the returned physical location in
order to generate the fully qualified filename for the required inbound file. Similarly for outbound files
“OUT/<FILE_NAME>” would have to be appended to the returned physical location in order generate
the fully qualified filename for the required outbound file.
Note: <FILE_NAME> should normally follow the convention specified in section 3.6.1 of the ‘SAP
- ABAP Developer Handbook’.
Note: Where a custom development is used to process only a single file type then the appropriate
Logical File Name should be hardcoded into the development as a parameter (so that it can
easily be amended if required)
If a custom development can be used to process more than one file type then it is suggested
that the Logical File Name be included as an input parameter so that for a particular variant the
program will process the appropriate files.
If an inbound file has not been processed successfully it may be moved from the
“/INTERFACES/XXX/IN” directory to an error sub-directory - “/INTERFACES/XXX/IN/ERROR” -
depending on the functional requirements for error processing.
Note: As part of the inbound functionality, the program should also be developed to include the
functionality to delete any files from the ARCHIVE directory that are older than ‘Y’ Days (as defined
on the selection screen) ,
Step 1. On the report selection screen, if a file download option is selected, the user should be
asked to provide a unique identifier which will be used as part of the file name e.g.
“MPAN20080106”
Step 2. The users id “SY_USERID” is used as a prefix to the identifier in step 1 to create the
full filename. Thus if the logged on user’s ID is “white1p” then the created file name
is “white1p_MPAN20080106.csv”
Step 3. The physical file path is obtained as described earlier in this document using the
Logical File Name “Z_MANUAL_DOWNLOAD”. E.g. in system SD1 the return
physical file path might be “/interfaces/SD1/manualdownloads/”.
To retrieve the file manually the user would be allowed to run transaction Z_REPORT_DOWNLOAD
which would run a custom program1 which would allow the user to browse the physical directory
corresponding to the Logical File Name “Z_MANUAL_DOWNLOAD” and a select file beginning
with their own user Id (SY-USERID). The selected file will then be downloaded to the file on their PC
the user has specified in the download program selection screen
For manual file downloads other than reports then a refinement of this approach may be adopted.
1
possibly based on existing EDF Energy program ZFILETRANSFER
SAP ABAP Developer Handbook Page 85 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
Table screen shot:
Domain 30 Y* Z*
Printer macro - Y* Z* 9*
Dynpro 4 9000-9999
If the screen does not belong
to a module pool in the
customer name range.
Package 30 Y* Z*
Enhancement 8 Y* Z*
Enhancement project 8 *
Function Builder
Function module 30 Y_* Z_*
Function group 26 Y* Z*
26 XZ*
User exit function module
26 *
User exit function module (customer-
specific)
IDOC development
Segment Type 27 Z1*
Segment Name 30 Z2*
30 Y* Z*
Basis IDOC type
30 *
Enhancement type
30 *
Logical message
Logical database 20 Y* Z*
Menu 20 Y* Z* +*
Module pool
Module pool for dialog 30 SAPDY* SAPDZ*
INCLUDES 30 DY* DZ*
30 SAPMY* SAPMZ*
Module pool for screens
30 MY* MZ*
INCLUDES
30 MP9*
Module pool for info types 30 MP9*
INCLUDES 30 SAPFY* SAPFZ*
Module pool for subroutines 30 FY* FZ*
30 SAPUY* SAPUZ*
INCLUDES
30 UY* UZ*
Module pool for update programs
INCLUDES
Message
Message ID 20 Y* Z*
Message number 3 900-999
Report Writer
Report 8 1. First character not numeric
Report group 4 1. First character not numeric
3 1. First character not numeric
Library
7 1. First character not numeric
SAP ABAP Developer Handbook Page 90 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
Standard layout
Standard task 8 9*
Standard role 8 9*
Search help 30 Y* Z*
SYSLOG message ID 2 Y* Z*
Table
Pooled tables and cluster tables 10 Y* Z* T9* P9* PA9* PB9*
PS9* PT9* HRT91* HRP91*
HRI91*
YY* ZZ* (in the append
Transparent tables 16 structure, if possible)
If included using the append
structure: YY* ZZ*
16
Table field
Transaction code 20 Y* Z* +*
Types in the ABAP Dictionary (Underscore allowed)
Data element 30 Y* Z*
Structure 30 Y* Z*
30 Y* Z*
Table type
EDM
Data model 10 Y* Z*
Entity 10 Y* Z*
View
Database view, projection view, 16 Y* Z*
maintenance view 16 H_Y* H_Z*
SAP ABAP Developer Handbook Page 91 of 92 Version: 1.1
Status: Draft
Confidential 20/01/2024 11 October 2012
Help view
View cluster 16 Y* Z*
View maintenance data
View content - reserved in TRESC
Table contents - reserved in TRESC