SAP Global Technical Development Programming Standards
SAP Global Technical Development Programming Standards
PURPOSE OF DOCUMENT.......................................................................................................................................4
ROLES AND RESPONSIBILITIES...................................................................................................................................4
WHAT THIS DOCUMENT DOES NOT COVER.................................................................................................................4
INTRODUCTION.........................................................................................................................................................5
GENERAL RULES......................................................................................................................................................6
Page 3 of 44
SAP Technical Development Programming Standards
Purpose of Document
This document explains the standards that BD has adopted for the development of custom code
within the SAP environment. They are to be used by both BD staff and 3 rd party contractors.
The Goal of these standards is to provide quality, consistency, and maintainability without hampering
the development process.
These Standards are updated periodically to stay aligned with future SAP release enhancements.
Page 4 of 44
SAP Technical Development Programming Standards
INTRODUCTION
These programming standards are intended to aid in the programming and related maintenance
work in the current SAP software development systems. The target audience of this document is anyone
with the necessary appreciation of best practices in software engineering in the SAP environment, and
those required to perform programming tasks.
This is not a programming manual and does not attempt to cover SAP functionality. However,
reference will be made to those features, which if not standardized or controlled could lead to problems in
performance. Programming standards do not exist for their own sake but as an attempt to achieve the
highest quality of work. When high quality of work is achieved, development times are shorter,
particularly in the testing and debugging stage, stakeholder and user expectations are met and system
maintainability is enhanced.
Page 5 of 44
SAP Technical Development Programming Standards
General Rules
Any modification to a standard SAP object requires supporting documentation and appropriate
signoff.
All custom developed SAP objects require an approved System Requirement Specification (SRS).
All custom developed SAP objects should be named according to the naming standards found in this
document.
Before creating a new object, an analysis should be performed to determine whether an existing
object can be used to perform the required processing.
Never perform direct updates to standard SAP tables using the ABAP commands UPDATE,
INSERT, MODIFY, and DELETE. Use standard function modules or SAP BAPIs to ensure data
integrity.
All custom programs and modifications need to be documented with the BD standard heading block
as outline in section 7.1, Header documentation.
Avoid inserting large blocks of code in mainstream logic; instead use subroutines to modularize your
code.
In order keep code clean, please remove all dead code from program, and log detail changes in the
header block. Old code can be reviewed using standard SAP version management.
From AS 7.40 on, ABAP is further developed in support packages that are bundled with kernel
releases. Further bundled SPs are to come, each with an own kernel and therefore with new ABAP
features can be leveraged on Everest systems.
Renewed ABAP features are not applicable on Tahiti, Monaco, Fiji, BD India and 4.0B SAP
system’s as basis component is lower than AS 7.40.
Page 6 of 44
SAP Technical Development Programming Standards
The naming convention for new development and custom modifications will distinguish SAP
standard reports from those that are custom developed or modified.
The naming standards for SAP development objects are divided into two categories:
Custom Developed
Custom Modified
When naming standards specify the need for a process team, use the following table to determine
appropriate values.
Team Description
MTC Market to Customer
OTS Opportunity to Sale
CTC Contract to Cash
UTR Use to Replenish
ITR Idea to Retire
STP Source to Pay
DTS Demand to Supply
FTM Finance to Manage
STS Source to Separate
EDM Enterprise Data Management
ATR Acquire to Retire
CGC Corporate Governance and Controls
UTL Utility
SAP SAP
Page 7 of 44
SAP Technical Development Programming Standards
Custom developed programs are ABAP programs that we (BDX) develop from scratch. It is new
development and not a modification of an existing SAP program. The name of the ABAP
program will be built by the following naming standards:
Customer modified SAP programs are SAP supplied ABAP programs that we modify for our
use. We can make modifications to a SAP supplied program by taking a copy of the current SAP
program and renaming it using the following naming standard:
Page 8 of 44
SAP Technical Development Programming Standards
1.3 Naming Standard for Module Pool Program
An ABAP module pool is a group of ABAP programs that access common processing modules,
checks and process user inputs during a transaction. The module pool is also a means of linking
all the associated screens, menus and function keys of the interface as a transaction. The module
pool has a program attribute type of ‘M’ and the following naming standards:
Example: SAPMZDTS_BOMS
An instance of the user interface, consisting of a menu bar, a standard toolbar, an application
toolbar, and a function key setting, is called a GUI status.
Page 9 of 44
SAP Technical Development Programming Standards
Example: ZCL_FTM_GETDATA
Example: GCX_CTC_ERROR
Example: LCL_GETDATA
Example: LCX_ERROR
Page 10 of 44
SAP Technical Development Programming Standards
Custom developed Interfaces are used to implement ABAP Classes. This can be both SAP and
customer developed classes. 2 types of interfaces that can be developed are local interface, and
global Interface.
SAP Rule
Example: ZIF_FTM_GETDATA
When passing values using methods the following naming convention should be used.
Class Attributes
Static Attribute G[T]
Instance Attribute M[T]
Constant C[T]
Page 11 of 44
SAP Technical Development Programming Standards
All Variants must be created with a meaningful name that defines the selection criteria being
saved.
Always refer to SAP fields by their full name, e.g. LFA1-KTNRA, SY-SUBRC
Use ‘TYPE’ when assigning attributes to variables declared in the data statement.
Page 12 of 44
SAP Technical Development Programming Standards
Subroutines must have meaningful names and their function and interfaces described.
All data structures and fields used will be commented with a description of their name &
function
The standard is a letter(s) corresponding to the declared object, separated from the variable name
by an underscore to distinguish it from SAP supplied data names. The following letters will be
used:
(In all following examples, MMM stands for meaningful name)
Page 13 of 44
SAP Technical Development Programming Standards
Page 14 of 44
SAP Technical Development Programming Standards
When defining a global variable, prefix the structure name with ‘W_’ followed by a meaningful
name.
When defining a local variable, prefix the structure name with ‘LW_’ followed by a meaningful
name.
DATA(LWA_VBAK) = VBAK
SELECT single matnr,
mtart FROM mara INTO @DATA(lwa_mara)
where matnr EQ lw_material.
In-Line Declaration:
Page 15 of 44
SAP Technical Development Programming Standards
Example of inline declared local internal table:
SELECT matnr,
mtart FROM mara INTO TABLE @DATA(lt_mara_02)
UP TO 10 ROWS ORDER BY PRIMARY KEY.
More Examples:-
Declaration of a result DATA lref_xml TYPE xstring. CALL TRANSFORMATION ... RESULT XML
CALL TRANSFORMATION ... RESULT XML DATA(lref_xml).
lref_xml.
1.9.4 Parameters
Parameters are used to allow data entry at the selection screen before program execution.
These variable names have a limited length of 8 characters, and should be prefixed with ‘P_’ for
easy identification.
Example: P_PLANT
1.9.5 Select-Options
The SELECT-OPTIONS statement generates a program variable used for selection
criteria against a table. It allows the user to enter in a range of values before program execution.
The select-options variable name should be the existing table field name which is being checked,
prefixed with ‘S_’, to indicate a Select-Option
Example: S_PLANT
Page 16 of 44
SAP Technical Development Programming Standards
1.9.6 Macros
Defines a program component (macro) under the name macro. It must consist only of
ABAP statements and is expanded at compilation time. A macro should always be concluded
with the END-OF-DEFINITION statement. In the definition, you can use &n to reference
positional parameters (n = 1, 2 .. 9). When the macro is called, &n is replaced by the n-th actual
parameter.
Example: M_Number.
1.9.7 Constants
Constant variables do not change value during the execution of a program. To indicate
these types, the variable name should be prefixed with ‘C_’
When passing variables into subroutine forms, use the below naming standard for parameters.
Page 17 of 44
SAP Technical Development Programming Standards
This section describes tables, views, structures, info structures, domains, data elements, fields,
match code objects, lock objects, and type-groups associated with the Data Dictionary.
Z MMM
| |
| Meaningful Name
|
SAP Rule
2.3 Views
Views are transparent tables consisting of an alternate view or combination of multiple tables,
such as a joined table. The length of the view name will vary based on the primary table name
for that view.
2.4 Structures
Structures are similar to tables although no records can be stored within them. They are defined
(almost) exactly like tables; the only difference is that no database tables are generated from
them. The same data elements and domains can be used in structures as in tables.
Page 18 of 44
SAP Technical Development Programming Standards
Structures are used especially to define the data at the interface of module pools and screens and
to define the parameter types of function modules.
Z MMM ‘_’ DS
| | |
| | Data Structure
| Meaningful Name
|
Required By SAP
Example: ZCUSTXREF_DS
Z MMM
| |
| Meaningful
SAP Rule
Example: ZWERKS
This section describes the naming standards for domains. The 8 character names are formatted
according to the following rules:
Z MMM
| |
| Meaningful Name
SAP Rule
The format specifications for a data element (fixed data type in the ABAP Dictionary, field
length and possibly the number of decimal places) are copied from the domain of the data
element.
Page 19 of 44
SAP Technical Development Programming Standards
The following naming standard is applicable to table structure, domain and data element:
Z MMM |
| |
| Meaningful field name
|
SAP Rule
There are a large number of both data elements and domains, which are part of the standard SAP
system. When developing new data dictionary structures that require these objects it may be
preferable to re-use existing objects rather than creates new ones.
In general, domains are re-used more often than data elements since the domain provides the
linkages for check tables and lists of values.
If there is any doubt about the applicability of an existing data element or domain, it is better to
create new ones rather than re-use the existing ones. Again, good programming and design
practice should be followed.
2.8.2 Domains:
Domains can be re-used if a domain that is needed :
provides the identical physical definition as existing domain with regards to short
text, physical attributes,
validation rules and key linkages of the existing domain.
Page 20 of 44
SAP Technical Development Programming Standards
Search helps can be used to assign an input help (F4 help) to fields in input masks.
Z SSS
| |
| Search Help identifier
|
SAP Rule
Page 21 of 44
SAP Technical Development Programming Standards
| |
| Primary table to be locked
|
SAP Rule It is mandatory for lock objects to start with “EZ”
Page 22 of 44
SAP Technical Development Programming Standards
Z MMM
| |
| Meaningful Name
|
SAP Rule
Z MMM
| |
| Meaningful Name
|
SAP Rule
The main difference between a function module and a normal ABAP/4 subroutine is a clearly
defined interface for passing data to and from the function modules. Declaring data as common
parts is not possible for function modules. The calling program and the called function module
have separate work areas for ABAP/4 Dictionary tables.
Page 23 of 44
SAP Technical Development Programming Standards
3.4 Naming Standard for Function Group
Function group is used to group function modules into functional units. The function group has
the following naming standard:
Z MMM
| |
| Meaningful Name
|
SAP Rule
For function groups that are copied from existing SAP function groups the following
naming convention should be used.
Z GGG
| |
| SAP function group
|
SAP Rule
Like form routines, function modules encapsulate program code, and provide an interface for
data exchange.
The function module name consists of 30 characters and has the following naming standards:
Example: ZCTC_GETNAME
Page 24 of 44
SAP Technical Development Programming Standards
Z YYY
| |
SAP Rule |
SAP Function Module
Example: Z_POPUP_TO_CONFIRM
When passing values to and from function modules, use the following naming conventions for
parameters
The logical database naming is limited to the alphanumeric identifier within the SAP application
identifier. A complete list of SAP application identifier is available in the ABAP Program
Attributes screen.
Page 25 of 44
SAP Technical Development Programming Standards
3.7 Events Naming Conventions
An event is a signal stating that a predefined status in the system has been reached. The
background processing system receives events and then starts the background job that is linked
to an event.
You can specify predefined events of the SAP applications or events you defined yourself.
Which SAP events you can use are explained in the documentation of the SAP application.
Z MMM
| |
| Meaningful Name
SAP Rule
Example: ZPRODUCT_CREATED
A field on the screen is only filled automatically with the value stored under the parameter ID of
the data element if this was explicitly permitted in the Screen Painter.
Z {Field Name} ID
| | |
| | Indicating Parameter ID
| Field Name of parameter ID to be used
SAP Rule
Much of the data in an SAP system has to be protected so that unauthorized users cannot access
it. Therefore the appropriate authorization is required before a user can carry out certain actions
in the system. When you log on to the SAP system, the system checks in the user master record
to see which transactions you are authorized to use. An authorization check is implemented for
every sensitive transaction.
Page 26 of 44
SAP Technical Development Programming Standards
ID <authority-field1> FIELD <field-value1>.
ID <authority-field2 > FIELD <field-value2>.
ID <authority-fieldn> FIELD <field-valuen>.
The OBJECT parameter specifies the authorization object.
Ex: ‘S_TCODE’
The ID parameter specifies an authorization field (in the authorization object).
Ex: ID ‘TCD’
The FIELD parameter specifies a value for the authorization field.
Ex: FIELD ‘ZDEV’
Authorization Object Class – All custom authorization objects need to be assigned to an object
class.
Z XXX
| |
| 3 Character Process Team code (refer to table on page 7)
SAP Rule
a) All custom executable programs, other than the exceptions noted below, must contain
a transaction code authorization check within the ABAP code. If the user does not
have the required authorization, program execution must be halted, with an
accompanying error message. The authorization check is applicable whether the
program is executed online or as a background job.
b) The authorization check can be accomplished via the AUTHORITY-CHECK
statement for authorization object S_TCODE, or via a call to function module
AUTHORITY_CHECK_TCODE. It is suggested that the check be placed in the
beginning of the INITIALIZATION event block, though it can also be implemented
in the LOAD-OF-PROGRAM, AT SELECTION SCREEN, or START-OF-
SELECTION event blocks.
c) When implemented in the START-OF-SELECTION event block, the check must be
carried out first, before reading from or writing to the database or any files. Under
normal circumstances, the transaction code for the authorization check will be the
same as the transaction code assigned to the program, but there are situations where
they may be different.
Z XXX “_”MMM
| | |
| | |
Page 27 of 44
SAP Technical Development Programming Standards
| | Meaningful Name
| |
| 3 Character Process Team code (refer to table on page 7)
SAP Rule
A total of 999 messages can be created per message class header. Generic messages with a ‘&’
(substituting variable) should be created as much as possible. Note that a maximum of four
parameters may be used in one message - any more will be ignored by the system.
When exporting and importing memory variables, use a meaningful name to describe the
memory ID so that it’s use can easily be determined. Also, document with comments where the
import and export will be set & used.
Export Example:
Import Example:
Overview
Page 28 of 44
SAP Technical Development Programming Standards
The enhancement concept allows you to add your own functionality to SAP’s standard
business applications without having to modify the original application. As part of the
enhancement concept, it is possible for the customer to add their own elements to application
logic, screens, and menus. The current possibilities for enhancement are as follows.
User Exits:
These are implemented in the form of subroutines and are also known as FORM EXITs. USER
EXITS exists in includes, and are usually attached to a standard SAP program(ex: MV45AFZZ).
USER EXITS are empty subroutines that SAP provides for customer to populate with their own
source code.
Since the subroutine names have already been provided by SAP, there is no naming
standard to adhere to, but keep in mind that all other naming standards must be followed for the
code being implemented.(variables, enhancements, etc…).
The name for CMOD Projects for SAP Enhancements should follow the naming standards for
custom developed.
Z XXX MMM
| | |
| | Meaningful Name
| 3 Character Process Team code (refer to table on page 7)
SAP Rule
Examples: Project Manager Enhancements ZCTCSAC
The name for SMOD SAP Projects should follow the naming standards for custom developed.
Z XXX NNNN
| | |
| | Numeric number
| 3 Character Process Team code (refer to chart on page 7)
SAP Rule
Examples: Project Manager Enhancements ZCFT0001 – Own Stock Placement
Text enhancements:
Allow the customer to add supplementary documentation for data fields, and to change key
word texts.
Page 29 of 44
SAP Technical Development Programming Standards
Z MMMM
| | Meaningful Name
SAP Rule
Field exits:
Every screen element with data element reference can branch to PBO or prior to PAI to a
function module if desired. The field contents are available here for doing special checks and
making changes (e.g. user- specific checks, authority checks, writing entered data and producing
statistics).
Function exits:
From the main program you branch into a software level, in which you can store ABAP/4
coding. The applications programmer at SAP determines where in the main program the function
exit is placed, and which data is imported/exported via the interface. The accompanying
documentation describes the functionality of the function exit.
Menu Exits:
SAP Delivered menu items can be activated and named. On the function code set at menu item
selection, there can be a reaction in a relevant function exit.
Screen Exits:
The customer can determine the layout of areas in screens provided by the applications
developer. Here, additional information can be displayed or data entered.
Page 30 of 44
SAP Technical Development Programming Standards
Enhancement Framework:
SAP Enhancement framework enable you to add functionality to standard SAP software without
changing the original SAP objects, and to organize these enhancements as effectively as
possible.
With this technology, you can enhance global classes, function modules, Web Dynpro
components, and all SAP source code using Implicit enhancements, Explicit enhancements, and
BADI implementations.
Explicit Enhancement
Predefined hooks already coded into the program by SAP at various points of the code where the
customer can implement custom functionality.
Implicit Enhancement:
These are the points within SAP code where SAP allows for the insertion of customer code.
Implicit Enhancements are permitted at the beginning and at the end of subroutines(forms) and
function modules
Enhancement Spot
Enhancement spots are used to manage explicit enhancement options
BADI Enhancement
A BADI is an object-oriented enhancement option that provides a mechanism to change the
functionality of a business function without making changes to the code. A BADI enhancement
is implemented using an enhancement Spot & a BADI Implementation.
Z XXX MMMMM
| | |
| | Meaningful name
| 3 Character Process Team code (refer to chart on page 7)
SAP Rule
ZGN_ENHANCEMENTFRAMEWORK
All enhancements must include a call to the ZGN_ENHANCEMENTFRAMEWORK Function
Module to determine if the code should be executed or not. Execution is controlled by SRS id
and enhancement implementation that are maintained in table ZGN_EXIT via Transaction
ZGNEXIT.
Table ZGN_EXIT
Page 31 of 44
SAP Technical Development Programming Standards
Example:
Page 32 of 44
SAP Technical Development Programming Standards
TRY .
result = value1 / value2.
CATCH cx_sy_zerodivide INTO ex_ref.
msg_text = ex_ref->get_text( ).
CATCH cx_root INTO ex_ref.
msg_text = ex_ref->get_text( ).
CLEANUP.
ENDTRY
Page 33 of 44
SAP Technical Development Programming Standards
Layout sets copied from the SAP standard layouts should be named as following.
Z XXX ‘_’ F ‘_’ SSSS
| | | |
| | Form Name of SAP form
| |
| 3 Character Process Team code (refer to table on page 7)
SAP Rule
Custom Layout sets should be named as follows:
Z XXX ‘_’ F ‘_’ MMM
| | | |
| | Form Meaningful Name
| |
| 3 Character Process Team code (refer to table on page 7)
|
SAP Rule
Custom Interface for Adobe Forms should be named as follows: (recommended to use the same
name as layout)
Z XXX ‘_’ I ‘_’ MMM
| | | |
| | | Meaningful Name
| | Interface
| 3 Character Process Team code (refer to table on page 7)
|
SAP Rule
Page 34 of 44
SAP Technical Development Programming Standards
| | |
| | Meaningful Name|
SAP Rule |
The word ‘STYLE’
Page 35 of 44
SAP Technical Development Programming Standards
Local symbols can be up to 30 characters long and have to describe the contents of
the variable.
Comments should follow the format: “** <author> <date> - <description>.
An Example: “** S.Pentavalli 7/30/98 – Delivery address picked up from Delivery
Note instead of Shipping Header.”
All modifications should have developer’s name, date and a brief description of the
modification. Add correction number for the first time or where ever meaningful.
Page 36 of 44
SAP Technical Development Programming Standards
The main documentation block is used to describe the program contents. The following describes the
contents of the documentation block:
Date and author of the program;
Name of the program;
Purpose of the program. This is freeform text that describes the use of the program. Use business
terminology more than computer terminology whenever possible;
Include documentation for each change to the program;
Date of change;
Developer;
Description of change.
*----------------------------------------------------------------------*
* Author : Daniel Bulka
* Creation Date : August 2014
* Transaction : ZLM52
* IM/CR/Defect : IM457239
* Technical Design : GBL-BDX-ERP.6.0-STP-09.4.02-TD-SDS4318
* Transport Number : ECDK982153
* Description : Non HU Put away
*
*----------------------------------------------------------------------*
* Modification Information
*----------------------------------------------------------------------*
* Author : Daniel Bulka
* Date : 10/16/2014
* IM/CM/CR/Defect : Defect 7449
* Transport number: ECDK983764
* Description : in form new_bin, do not issue message for blank batch
* if material is not batch managed. changes marked DB001
*----------------------------------------------------------------------*
Page 37 of 44
SAP Technical Development Programming Standards
7.2 Change Markers
Insertion/modification (Minor)
IF w_matnr IS INITIAL OR w_qty <= 0. "DB01
Insertion/modification (Major)
* Begin DB01 give message based on if material is batch managed or not
IF w_xchpf IS INITIAL.
IF w_matnr IS INITIAL OR w_qty <= 0.
PERFORM z_clear_message_variables.
w_msgid = c_msgid.
w_msgno = c_000.
w_msgv1 = text-020.
w_screen = sy-dynnr.
PERFORM z_message_9099 USING w_msgid w_msgno w_msgv1
w_msgv2 w_msgv3 w_msgv4.
MOVE 'W_DESTB' TO w_current_field.
LEAVE TO SCREEN w_screen.
ENDIF
* End DB01 give message based on if material is batch managed or not
7.2.3 Dead Code
The term Dead Code refers to code that has been commented out due to modifications.
No Dead code should remain in a program, as this causes confusion when reviewing the
program. All commented code should be deleted, and SAP version management should be used
to refer to prior changes.
Page 38 of 44
SAP Technical Development Programming Standards
7.2 The Standard Structure for ABAP Code.
SAP does not enforce a rigid coding structure within the syntax, and as a result we can place
elements in any section of a report. We should all develop using a common style so it will help
us navigate when modifications are being done to other team members code.
Declaration elements
TABLES
TYPES
DATA
CONSTANTS
PARAMETERS
SELECT-OPTIONS
RANGES
FIELD-GROUPS
FIELD-SYMBOLS
EVENTS
Event elements
INITIALIZATION
AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR
START-OF-SELECTION
END-OF-SELECTION
TOP-OF-PAGE
END-OF-PAGE
Control elements
TOP-OF-PAGE DURING LINE-SELECTION
AT LINE-SELECTION
AT PFnn
AT USER-COMMAND
Sub-function elements
FORM
ENDFORM
Page 39 of 44
SAP Technical Development Programming Standards
7.3 Program Comments
All initial declarations should contain definition and description comments to aid in future
maintenance. You should assume that support may need to be performed by someone with
limited understanding of the specification.
Within the data declaration area of your ABAP, you should describe the following:
Tables
INCLUDE code
Data Definition
Constants
Ranges
Select-Options
Parameters
Field-Groups
Dynpros
Field Symbols
Within the logic of your program, the following area needs to be documented with comments.
Before each major section (ABAP events, forms and large code sections that perform a
definable task)
Before small sections of code (20 or fewer lines of code that perform a definable task)
Before any complex or unclear logic.
While appending a record into an internal table, we can use below syntax. Before writing below
syntax we have write inline comments as below:
For checking the index of a record in internal table we can use below syntax which should be
supported by inline comments:
Page 40 of 44
SAP Technical Development Programming Standards
7.4 Table TVARVC
When circumstances arise where variables need to be compared against a specific value
in a program,(ex: company code), hard coding must be avoided, and these values need to be
maintained in table TVARVC. TVARVC is an SAP provided table that allows for the storage of
variables that can be changed without having to modify the code. Transaction STVARV is
provided to maintain table TVARVC.
Page 41 of 44
SAP Technical Development Programming Standards
The new features of AS7.40/Renewed ABAP can be referred in ECC system using Tcode
‘ABAPDOCU’.
Page 42 of 44
SAP Technical Development Programming Standards
7.6 Communication with Middleware
When coding interfaces utilizing BAPI’s or RFC’s, the standard BAPI return structure
BAPIRET2 should be used to provide a consistent look and feel when communicating to external
systems.
E = Error
I = Info
W = Warning
S = Success
Do not use type ‘A’ or abort as this is reserved for SAP only.
Page 43 of 44
SAP Technical Development Programming Standards
Appendix A-Glossary
Page 44 of 44