sap coding standards erpams
TRANSCRIPT
-
7/27/2019 SAP Coding Standards ERPAMS
1/19
The World Bank Official Use Only
Tem late Name: SAP Codin Standards
Document ID: COD-003Template Version: Ver. 3.0, 04/20/2006
Description
Purpose
Guideline
References DocumentIdentification
Number
Document Name
COD-001 Software Coding Process
Use the Quality Website to verify that this is the current version.
This workbook has 8 worksheets, grouping the SAP standards into the
following categories: Style, Naming Convention, Internal Table, Data
Dictionary, SQA, Object Oriented, Transport Request, and General. In
each worksheet, standards are labeled 'standard' if following them isrequired, or 'recommended' if they are optional. The worksheets can
also be used as checklists.
ISG QUALITY PROGRAMGUIDELINE
Template Overview
The SAP Coding Standards document describes the standards to be
followed when creating and modifying an ABAP object.
Electronically distributed, uncontrolled if printed.
1. Use the worksheets that correspond to the type of code that is being
developed.
2. Lines that are classified as "standard" must be followed.
3. Lines that are classified as "recommendation" are optional, but
recommended.
4. Use the standards as guidelines during code development.
5. Use the worksheets as checklists when code is being reviewed.
6. If code was developed using an earlier standard, modifications to
that code can be made using that same standard. This is at the
discretion of the Lead.
1 Ver. 3.0 04/20/2006Software Coding Process
SAP Coding Standards
-
7/27/2019 SAP Coding Standards ERPAMS
2/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
ST-01 Program Header Developers can refer the standard template from
program /ILAP/SAMPLE_PROG_ABAP_1, copy it into
their own program, and modify accordingly.
Standard
ST-02 Variable Indentation Each Variable should be in a new line. Standard
ST-03 Variable Documentation All variables should have a meaningful comment next
to it.
Standard Data: GV_UPD.
" UpdateIndicator
ST-04 Pretty Printer All programs must follow the default indentation offered
by Pretty Printer. ABAP Pretty Printer settings should
have lower case option on and keyword Uppercase
option should be on
Standard
ST-05 Modification search key Use UCM, JIRA or Project Number number as
modification search key.
Standard
ST-06 Modularization All global variables should be declared in a TOP
include and all subroutines should be defined in a F01
include
Standard ZR**TOP for
variables,
ZR**F01 for
subroutines
ST-07 Modularization forReport programs
Processing blocks must precede with a label header. Standard
ST-08 Modularization for
Report programs
Following is the best optimized sequence in which
various event statements (if they are coded) within a
report program should be defined: *
Events in the sequence of processing
LOAD-OF-PROGRAM.
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM read_data.
PERFORM process_data.
END-OF-SELECTION.
*Events that occur more than once during processingTOP-OF-PAGE.
TOP-OF-PAGE DURING LINE-SELECTION.
END-OF-PAGE.
* Interactive events
AT LINE-SELECTION.
AT USER-COMMAND
Standard
ST-09 Code deletion In most situations comment unneeded code, do not
delete it. However, use your discretion to delete code
in situations where doing so will improve readability.
Recommen-
dation
ST-10 Output display header If standard report/screen headers are defined and in
use for a team/project , then they must be used.
Recommen-
dation
SAP Standards: Style
2 ISG-QMS-COD003-3.0 SAP Standards: Style
-
7/27/2019 SAP Coding Standards ERPAMS
3/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
Y prefix namespace is supposed to be
used by third-party vendors and not
customers. Currently, there are a few
cases in which WBG has used "Y" prefix
for custom objects. In future, no additionalcustom objects should be defined with
the "Y" prefix. This comment is applicable
to all custom objects defined in the
Naming Conventions worksheet.
NC-01 Data Elements Standard ZFISCAL_YR
NC-02 Message Class _
Standard ZMM_PO_CLS
NC-03 PBO PBO modules should start with PBO Standard PBO_INITIALIZE
NC-04 PAI PAI Modules should start with PAI Standard PAI_FCODE
NC-05 POV POV should start with POV Standard POV_PO_VALUES
NC-06 POH POH modules should start withPOH Standard POH_F1_FOR_XYZ
NC-07 Function Group
Names
_name
Standard ZMM_STC
NC-08 Normal Function
Module Name
__
Standard Z_CREATE_VENDOR
NC-09 RFC Function
Module Name
_RF__
Standard Z_RF_CREATE_VENDOR_PARA
NC-10 Update Function
Module Name
_UPD__
Standard Z_UPD_VENDOR_MASTER_DB
NC-11 BAPI Function
Module Name
_BAPI__
Standard Z_BAPI_CREATE_VENDOR
NC-12 Type Group Type Groups should not be prefixed with
namespace; and hence must follow the
following guidelines: Z
where XX is the 2-character abbreviation for
the project and YY is a 2-character code (a
combination of alphabets and/or digits).
Standard A constant declaration within a Type
Group ZIL01 should be like
ZIL01_C_SUCCESS
NC-13 Transparent Table
Names
Standard ZSTC_HDR
NC-14 View Names V_ Standard ZV_STC_HDR_ITM
NC-15 Structure Names S_ Standard ZS_STC_SCR_ITM
NC-16 Domains Standard ZFISCAL_YR
NC-17 Table Types _TT_ Standard Z_TT_EKBE
NC-18 Search helps _SHLP
Standard ZPONUM_SHLP
NC-19 Adding fields to a
standard table
Column/Field names should start with ZZ** Standard
NC-20 Enhancements
Package
To hold components related to SAP
enhancements, package should be namedas: Z__SAP_ENHANCEMENTS
Standard
NC-21 Naming Packages To hold Type Groups and other exceptional
dictionary objects, package should be
named as: Z__DICT_OBJ
Standard
SAP Standards: Naming Convention
3 ISG-QMS-COD003-3.0 SAP Standards: Naming Convention
-
7/27/2019 SAP Coding Standards ERPAMS
4/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: Naming Convention
NC-22 Method parameters _ Parameter
Interface => I Importing, E Exporting, X
Changing, R Returning. Parameter Type =>
V (optional) Variable (i.e. all types ofelementary data types based variables, like
CHAR, NUMC, STRING, etc), S Structure,
T table, P Pointer(type ref to)
Standard
NC-23 Includes Custom developed INCLUDE files
(excluding the ones that are proposed by
SAP, e.g. when creating function modules,
etc) must be named based on following
standards: _Name
Standard
NC-24 BAPI BAPI__
Standard /ILAP/BAPI_DIS_GET_WDRWL_APPL
NC-25 BAPI Parameters _ Parameter
Interface => I Importing, E Exporting, X
Changing, T table. Parameter Type => V
(optional) Variable, S structure, T Table
type, P pointer (Type ref to data)
Standard I_CONTRACT_NUM
NC-26 Function Group _ Standard
NC-27 Function Group Function groups that are to be used for
storing code generated by table
maintenance generator option should be
created based on following naming
standards: If multiple functions for
withdrawal application processing are to be
combined in different function groups, it isrecommended to create function groups as
WDRL_APPL_01, WDRL_APPL_02, etc. It
would provide easy access to find all
function
Standard
NC-28 Tables Certain tables require inclusion of an
internal ID to uniquely identify the rows.
Such internal IDs, which are not usually
visible to end-users, should be named using
following standards:_INTL_ID
Standard
NC-29 SEARCH HELP _ Standard
NC-30 SEARCH HELPEXIT
SH_EXIT Standard
NC-31 LOCK OBJECT E_ Keep the Name
same as the actual table name for which the
lock object is defined (or abbreviate the
actual table name if it is lengthy for lock
object).
Standard
NC-32 Number range
objects
Standard /ILAP/ITXN
4 ISG-QMS-COD003-3.0 SAP Standards: Naming Convention
-
7/27/2019 SAP Coding Standards ERPAMS
5/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: Naming Convention
NC-33 Transactions Z__
Standard
NC-34 Transactions for
Table Maintenance
Z_TM_ Standard
NC-35 Executable Report
Program names
R_name
Standard A Report program should start with
ZRMM_**
NC-36 Executable Interface
Program Name
I_name
Standard An interface program name should start
with ZIMM_
NC-37 Executable BDC
Program Name
B_name
Standard A BDC program name should start with
ZBMM_
NC-38 Include Program
Names with Main
program
Standard ZRMM_**TOP for data declaration,
ZRMM_**F01 for subroutines
NC-39 Include Program
Names without Main
program
(Subroutine Pool)
SAPFZ_name
Standard SAPFZ_SMRTFORM_ROUTINS
NC-40 Subroutine Names Should start with F_** to represent form Standard F_GET_PO_DETAILS
NC-41 Classes __
Namespace prefix in Class Name should be
used only for defining global classes. Class
visibility-> LCL Local class (defined within
the program), CL Global class (defined
using Class Builder). All global classes
must belong to namespace (or begin with
pre-defined custom prefix for the project, if
namespace is not available). Local classes
need not be prefixed with namespace and
functional area.
Standard LCL_FRONTEND_SERVICES
NC-42 Interfaces __
Interface visibility->LIF Local interface (use
of namespace and function area prefixes
not required), IF Global interface
Standard LIF_FRONTEND_SERVICES
NC-43 General Method
Names
_ Standard CREATE_CONTRACT
NC-44 Attribute Access
Methods
GET_ or
SET_
Standard GET_UPDATE_MODE,
SET_UPDATE_MODE
NC-45 Event Related
Methods
ON_ Standard ON_MGR_APPROVAL
NC-46 Boolean Methods IS_ Standard IS_APPROVED, IS_CANCELLEDNC-47 Event Names _ Standard CONTRACT_APPROVED
NC-48 Check
methods(CHECK
methods are same
as Boolean methods
except the fact that
they can raise
exceptions)
CHECK_ Standard CHECK_CONTRACT_STAT
CHECK_AUTHORIZATION
CHECK_APPRV_CONDNS
5 ISG-QMS-COD003-3.0 SAP Standards: Naming Convention
-
7/27/2019 SAP Coding Standards ERPAMS
6/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: Naming Convention
NC-49 Validate methods VALIDATE_ Standard VALIDATE_WDRAWAL_APPL
NC-50 Variables and
Constants
_ Visibility -
> C Constant, L Local, G Global, I Import
parameter, E Export parameter, X
Changing, R Returning. Datatype -> VVariable (optional), S Structure, T Table, R
Range table(selection table), P Pointer (type
ref to data)
Standard GV_** for Global Variable
GS_** for Global Structure
GC_** for Global Constants
GP_** for Class Reference(Global Typeref to)
GT_ for global standard internal table
GTH_ for global Hashed Internal Table
GTI_ for global indexed Internal Table
GTS_ for global sorted Internal Table
LV_** for Local Variable
LS_** for Local Structure
LP_** for local Class Reference
LT_ for local standard internal table
LTH_ for local Hashed Internal Table
LTI_ for local indexed Internal Table
LTS_ for local sorted Internal Table
NC-51 Function Module /
Form Changing
parameter
XV for Variable, XS for Structures, XT for
Internal table (based on the internal table
type follow rules)
Standard XV_EBELN, XS_EKKO, XT_EKKO,
XTH_EKBE for hashed table, ITI_EKBE
for indexed table, ITS_EKBE for sorted
table.
NC-52 Function Module /
Form Table
parameters
T for standard table, TH for hashed table, TI
for Indexed table, TS for sorted table
Standard T_EKKO, TH_EKBE, TS_EKBE,
TI_EKBE
NC-53 Function Module
Import Parameter /
Form Using
Parameter
IV for Variable, IS for Structure, IT for
Internal table (based on the internal table
type follow rules). Note use the I prefix for
forms Using paameter also; do not use U
prefix.
Standard IV_EBELN, IS_EKKO, IT_EKKO,
ITH_EKBE for hashed table, ITI_EKBE
for indexed table, ITS_EKBE for sorted
table.
NC-54 Function ModuleExport Parameter
EV for Variable, ES for Structures, ET forInternal table (based on the internal table
type follow rules)
Standard EV_EBELN, ES_EKKO, ET_EKKO,ETH_EKBE for hashed table, ETI_EKBE
for indexed table, ETS_EKBE for sorted
table.
NC-55 Method Import
Parameter
IV for Variable, IS for Structure, IT for
Internal table (based on the internal table
type follow rules)
Standard IV_EBELN, IS_EKKO, IT_EKKO,
ITH_EKBE for hashed table, ITI_EKBE
for indexed table, ITS_EKBE for sorted
table.
NC-56 Method Export
Parameter
EV for Variable, ES for Structures, ET for
Internal table (based on the internal table
type follow rules)
Standard EV_EBELN, ES_EKKO, ET_EKKO,
ETH_EKBE for hashed table, ETI_EKBE
for indexed table, ETS_EKBE for sorted
table.
NC-57 Method Changing
parameter
XV for Variable, XS for Structures, XT for
Internal table (based on the internal table
type follow rules)
Standard RV_EBELN, RS_EKKO, RT_EKKO,
RTH_EKBE for hashed table, RTI_EKBE,
RTS_EKBE.NC-58 Method Returning
parameter
RV for Variable, RS for Structures, RT for
Internal table (based on the internal table
type follow rules)
Standard XV_EBELN, XS_EKKO, XT_EKKO,
XTH_EKBE for hashed table, XTI_EKBE,
XTS_EKBE.
NC-59 Method table
parameters
T for standard table, TH for hashed table, TI
for Indexed table, TS for sorted table
Standard T_EKKO, TH_EKBE, TS_EKBE,
TI_EKBE
NC-60 Subroutine Formal
Parameters
FPV for Variable, FPS for Structure, FPT for
Internal table (based on the internal table
type follow rules)
Standard FPV_EBELN, FPS_EKKO, FPT_EKKO,
FPTH_EKBE for hashed table,
FPTI_EKBE, PTS_EKBE.
6 ISG-QMS-COD003-3.0 SAP Standards: Naming Convention
-
7/27/2019 SAP Coding Standards ERPAMS
7/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: Naming Convention
NC-61 Global selection
Range
GR_** for Selection Range Standard GR_DATUM for SY-DATUM
NC-62 Local selection
Range
LR_** for Selection Range Standard LR_DATUM for SY-DATUM
NC-63 Field Symbols Standard NC-64 Global Field
Symbols
for field symbols Standard
NC-65 Data References DR_ Standard LDR_EKKO
NC-66 Data Types TY__Name Standard , TY_EBELN,
TY_T_EKKO, TY_TH_EKKO
NC-67 Select-options S_** for select-options Standard S_EBELN for EKKO-EBELN
NC-68 Parameters P_ for Parameters Standard P_GJAHR type EKKO-GJAHR
NC-69 Checkbox CBX_** for Checkbox Standard CBX_LIST as checkbox
NC-70 Radiobutton RB_** for radiobutton Standard RB_QTR1 radiobutton
NC-71 Table Control TC_** for Table Control Standard TC_PO_ITM
NC-72 Tab Strip TS_** for Tab strip Standard TS_ITM_DET
NC-73 Subscreen SUBSCR_nnnn for Sub screen Standard SUBSCR_0001 for schedule line details
NC-74 Custom Control CUSCTRL_** for Custom Control Standard CUSCTRL_ALV_TREENC-75 Screen input/output
Variable
IP_** For Screen Input Variable Standard IP_EBELN for PO Number
NC-76 Screen output
Variable
OP_** For screen Output Variable Standard OP_ERNAM - User Name
NC-77 Screen text If not used in programs leave it blank,
system will assign default value. STX_** for
screen texts.
Standard STX_POXT - PO Number text
NC-78 Screen Icon ICO_ For screen Icon Standard ICO_GO for Green light
NC-79 Screen Box/Frame If not used in programs leave it blank,
system will assign default value. BX_** for
screen texts.
Standard BX_HDR Frame for header details
NC-80 Class/Interface
attributes
_ Standard V_EBELN for single field, S_EKKO for
structure, T_EKKO for standard table,TH_EKKO for hashed internal table,
TS_EKBE for Sorted Internal table,
TI_EKBE for indexed internal table
NC-81 Parameters _
Standard
NC-82 Method Exceptions **_ERR if error occurred, **_NOT_FOUND
if not found, **_NOT_SUPPORTED if
not supported etc. There is no
standard way of coding exceptions. Make
sure it concise and meaningful
Standard UPI_NOT_FOUND
NC-83 Authorization
Objects
Z Standard
NC-84 Transport Requests Transport requests must be named based
on following standards:
:
-
Standard
7 ISG-QMS-COD003-3.0 SAP Standards: Naming Convention
-
7/27/2019 SAP Coding Standards ERPAMS
8/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: Naming Convention
NC-85 Type Group All fields defined within a Type Group must
be prefixed with the Type Group name, but
still the naming conventions for variables,
constants, and types must be followed.
Standard
NC-86 Exception Class Namespace>CX_
Standard
8 ISG-QMS-COD003-3.0 SAP Standards: Naming Convention
-
7/27/2019 SAP Coding Standards ERPAMS
9/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
IT-01 Work Area Declare a separate work area for internal tables.
Never use internal table with header line
Standard
IT-02 Reading internal table Always use 'READ' statement to read singlerecord from an internal table Standard
IT-03 Binary Search When reading standard internal tables use
BINARY SEARCH statement wherever
applicable. Binary search is faster than linear
search.
Standard
IT-04 Modify Index When modifying internal table using index key
word make sure index variable is a valid index
number. Index variable with '0' will make program
to dump
Standard
IT-05 Deleting Entries Do not delete statement with index when deleting
entries inside a loop
Standard
IT-06 For all entries Check internal table for valid entries before using
it for all entries sql statements. Empty internal
tables will fetch all records from the database
tables
Standard
IT-07 Nested Loops Avoid using nested internal table loops. Use
READ TABLE statement wherever applicable
Standard
IT-08 Append Lines of Use APPEND LINES OF statement to insert
records from one internal table to another do not
use loop and append statement
Standard
IT-09 Insert Lines of Use INSERT LINES OF statement to insert
records from one internal table to another do not
use loop and append statement
Standard
IT-10 Free internal tables Free internal tables which are no longer used in
the program
Standard
IT-11 Work Area Clear the work area inside the loop before
reading new data into it.
Standard
IT-12 Copying Internal tables Use MOVE statement than loop and append
technique
Standard ITAB1 = ITAB2
IT-13 Delete adjacent
duplicates
Make sure to sort internal table before using
DELETE ADJACENT DUPLICATES statement
Standard
IT-14 Collect Internal tables field types and length should be
considered before using collect statement
Recommen-
dation
IT-15 Modifying ITAB Use modify with TRANSPORTING F1 variant
wherever applicable.
Recommen-
dation
IT-16 Select Statement SAP recommends using the MOVE statement
instead of MOVE-CORRESPONDING for
performance reasons
Recommen-
dation
SAP Standards: Internal Table
9 ISG-QMS-COD003-3.0 SAP Standards: Internal Table
-
7/27/2019 SAP Coding Standards ERPAMS
10/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
DD-01 Changing field Names Never change a field name in a production table
as it would cause loss of data
Standard
DD-02 Table Maintenance
Generator
Maintain a separate function group for table
maintenance. Do not use existing function groups
(which are created for application development) togenerate table maintenance modules
Standard
DD-03 Transaction code -
Maintain table views
The table name should be the transaction code to
maintain the table views. Basis team will provide
access in PRD to the users as approved by the
manager to maintain the table entries
Standard If table name is ZTEST,
SM30 access for this table
will be driven by the
transaction code ZTEST
DD-04 Adding new fields to
tables
Always add a field/column to the end of a
production table.
Recommen-
dation
DD-05 Built in types Avoid using built in types unless, the table/column
is independent. If the column is going to be used
in more than one table always create data
elements. It makes maintenance easy
Recommen-
dation
DD-06 Data Elements Try to use existing DD elements. I f you are using
custom data elements make sure they are part of
your application/package/module. If data elements
from other packages/modules/applications are
used make sure it is properly communicated to
other teams.
Recommen-
dation
DD-07 Adding fields to a
standard table
Use append structure to add new fields to
standard tables.
Recommen-
dation
SAP Standards: Data Dictionary
10 ISG-QMS-COD003-3.0 SAP Standards: Data Dictionary
-
7/27/2019 SAP Coding Standards ERPAMS
11/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SQ-01 Select single Always use select single to select a
unique record from the database table
Standard
SQ-02 UP TO 1 ROWS If single select statement can not be used to
check existence of a record in a database tableuse UP TO 1 ROWS variants . Select single
should be used only when all keys are passed.
Standard
SQ-03 Aggregate functions Use aggregate functions wherever applicable Standard
SQ-04 Index support Try to use index wherever applicable Standard
SQ-05 Logical Operator Always use logical operators in where conditions Standard Where MANDT
eq SY_MANDT
and NOTwhere
MANDT = SY-
MANDT
SQ-06 Where condition Field
sequence
Always follow the field positions when using the
fields in where conditions
Standard Where MANDT
eq SY_MANDT
and EBELN eq
PO_NUM and
NOTwhere
EBELN eq
PO_NUM and
MANDT = SY-
MANDT
SQ-07 Database fields Always select the required fields from the
database table instead of using select * unless all
the fields have to be selected from the database
table
Standard
SQ-08 Alias in Database Joins Always use alias names in database joins even if
the fields are unique in both the tables
Standard
SQ-09 Nested Select Do not use nested select statements Standard
SQ-10 Select inside loop Avoid using select statements inside internal
table loops. Use for all entries wherever
applicable
Standard
SQ-11 Select Statement If you are selecting multiple records, try to avoid
select processing loop (SELECT...
ENDSELECT), by using into table or
appending table statements.
Standard
SQ-12 Select Statement Use 'SORT' statement instead of using ORDER
BY sql statement to sort records in internal table.
Standard
SQ-13 Database joins Join table only if they have foreign key
relationship
Recommen-
dation
SQ-14 For all entries For entries' will be faster only if all the fields in the
where condition are checked with 'EQ' logical
operator
Recommen-
dation
SQ-15 Select Statement If the data from a particular table is used in an
application at a single one time validation
(example initialization), it is better to use
SELECTENDSELECT statement than using an
internal table.
Recommen-
dation
SAP Standards: SQL
11 ISG-QMS-COD003-3.0 SAP Standards: SQL
-
7/27/2019 SAP Coding Standards ERPAMS
12/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: SQL
SQ-16 Select Statement If you are selecting a set of columns, make sure
that the work area and the database fields are of
same type and length when using dynamic work
areas. (620 Compiler throws a syntax error if thework area wide does not match the width of the
selected database fields). Make use of
corresponding fields statement only if it is
required as it requires more runtime.
Recommen-
dation
SQ-17 Select Statement When defining the work area for transaction
related programs, make sure the work area is
defined referring or including the structure rather
than including the fields of the structure in the
work area. This makes sure that work area
always has the latest structure definition.
Recommen-
dation
12 ISG-QMS-COD003-3.0 SAP Standards: SQL
-
7/27/2019 SAP Coding Standards ERPAMS
13/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
OO-01 Boolean Methods These methods should not return any exceptions
(otherwise they should be defined as CHECK_ or
generic methods).
Standard
OO-02 Class Methods Methods in a class must be listed in the followedorder of their visibility (with exception of CLASS-
CONSTRUCTOR and CONSTRUCTOR methods,
which are listed at the top):
o Public
o Protected
o Private
Standard
OO-03 Exception Class Exception handling in the programs can be made
more flexible by making it class-based. Common
errors like divide by zero, overflow errors, etc can
be caught using SAP pre-delivered exception
conditions (implemented via class-based
exceptions) whereas exceptions specific to a
project needs (custom exceptions) can also be
defined by the programmers. Programmers are
encouraged to use class-based exceptions
henceforth, unless absolute necessary to deviate
based on specific needs of the project.
Standard
OO-04 Messages In object oriented programming, when using
dynamic messages, make sure message class,
type and number are filled in before calling the
message to avoid short dump.
Standard
OO-05 Objects Free created objects after usage Standard
OO-06 Exceptions Handle exceptions when calling class methods Standard
OO-07 Objects Check for an object existence before using it Standard
OO-08 Initialization In ABAP OO (Object Oriented) Programming, if
any initialization has to be performed every time
an object is created, consider using
CONSTRUCTOR method instead of creating a
custom defined method to achieve the same
results.
Standard
OO-09 Exception Class It is encouraged not to use Exception Class texts
as an interface for communication with end user
(e.g. as message text for end-users, etc).
Instead, when an exception is caught/handled,
make use of appropriate message class andmessage number (from SAP Message Class,
transaction SE91) to get message text (for error,
warning, information, etc) and use that to interact
with end-users.
Recommen-
dation
SAP Standards: Object Oriented
13 ISG-QMS-COD003-3.0 SAP Standards: Object Oriented
-
7/27/2019 SAP Coding Standards ERPAMS
14/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
TR-01 Request Description Maintenance Log No (UCM/JIRA/Project Id)
should be mentioned in the beginning of the Short
Description
Standard UCM11818 - SRM changes for
Requisition role resolution. OR
SP0019 - Trip Approval for LLF
enhancements
TR-02 Request Consistency
check
Before releasing request, complete object syntax
check, request consistency check and display
inactive object.
Standard
TR-03 Storing Objects in TR When you are working on a medium/large
application where multiple developers are
accessing the same objects, store all the data
dictionary objects in a separate request. So the
objects can be tranported/released anytime.
Recommen-
dation
TR-04 Transport Copies Use transport copies to move program
copies/application to another system during
development phase.
Recommen-
dation
Two modifications have to be
done on a program and both
have to be moved together to
PRD. But only one modification
is completed and this has to betested in quality system.
Instead of releasing the
development/correction
request, create a transport
copy
TR-05 Transport Request
Description
Provide a concise, meaningful description. Use a
2 to 4 character functional area prefix. This will be
useful when you are working on multiple
projects/functional areas. When creating a
transport request make sure to add creation date
to the end of the TR
Recommen-
dation
MM-STC Days validation
changes. 01/02/05
SAP Standards: Transport Request
14 ISG-QMS-COD003-3.0 SAP Standards: Transport Request
-
7/27/2019 SAP Coding Standards ERPAMS
15/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
Not intended for
peer review of
source code,
but generalstandard for
developers.
G-01 Development Class Do not assign non-production ABAP objects (Dummy
objects created for testing/proof of concept etc) to
production development class. Always save them in
your local objects or use a development class lke
ZTEST or ZJUNK.
Standard
G-02 SAP Program
Modification
Always use Modification assistant to modify standard
SAP Programs
Standard
G-03 SLIN All programs have to undergo SLIN check (Extended
program check)
Standard
G-04 Break-point Never use BREAK-POINT statement in productive
code. Statement, if used for testing, should be
commented/deleted prior to transport to production.
Standard BREAK
WB240202.
G-05
Program Title Concise, Meaningful and easily identifiable title Standard Age Analysis
Report
G-06 Production Program
Status
Should have Customer Production Program status
before transporting to Production
Standard
G-07 Application Component
Assignment
Should be assigned to appropriate Application
component
Standard Ex: BASIS for
system
programs
G-08 Fixed point arithmetic
indicator
Should be on. If unchecked, should justify Standard
G-09 Editor Lock Should not enable editor lock Standard
G-10 Unicode Should be enabled Standard
G-11 Subroutine Formal
Parameters types
Always specify types for routines formal parameters.
Helps in code optimization and performance
Standard
G-12 Single Messages Self-explanatory checkbox should be checked if the
message is a single message and there is no long text
for the message
Standard
G-13 Message Text Messages should be meaningful to the end users..
Avoid descriptions like Project Sector not found.
Instead, construct it as Project Sectors not maintained
for the Project.
Standard
G-14 Message Variable Message variable should not be a character values.
They should be defined as a variable, constant or a
text element
Standard
G-15 Dynamic Messages When using dynamic messages, make sure message
class, type and number are filled in before calling the
message to avoid short dump
Standard
G-16 Character - Data type c When comparing a character variable with constants,
always declare values within codes
Standard check ch_subrc
eq '4'. NOT
ch_subrc eq 4
SAP Standards: General
15 ISG-QMS-COD003-3.0 SAP Standards: General
-
7/27/2019 SAP Coding Standards ERPAMS
16/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: General
G-17 Number type - Data type
I, P etc
Use numbers instead of character strings Standard sy-subrc eq 4
NOTsy-subrc
eq '4'
G-18 Mixed types Avoid mixing data types for calculations unless it isnecessary Standard
G-19 Check for initial values Always use 'IS INITIAL' statement to check variables
for initial values than using space, 0 etc. easy to
understand the logic/code
Standard If an integer has
to be checked
for initial value
use is initial
statement than
checking for '0'.
G-20 IF vs Case When a variable has to be checked for more than two
values use case condition than if condition. Case will
be litte faster than If condition
Standard
G-21 Coding Do not code business logic inside Modules. Code all
the logic in a subroutine call them in modules
Standard
G-22 FM Interface parameters Do not globalize interface parameters, if globalized,
should justify
Standard
G-23 Type Group If you are using type group, it is not necessary to use
TY prefix because all data types declared in type group
should start with type group id.
Standard
G-24 Function Module
Exceptions
**_ERR if error occurred, **_NOT_FOUND if not
found, **_NOT_SUPPORTED if not supported
etc. There is no standard way of coding exceptions.
Make sure it concise and meaningful
Standard UPI_NOT_FOU
ND
G-25 Structure Names All structure fields must refer (if possible) data
elements and should not explicitly refer standard data
types like NUMC, DEC, etc unless otherwise
necessary.
Standard
G-26 Global Variables Use/Change existing global variables only if it is
necessary. Avoid declaring global variables unless it is
necessary
Standard
G-27 BAPI Exceptions Exceptions must be qualified to specifically indicate the
process, step, object, etc that caused the exception.
E.g. Instead of using exception FAILED; qualify it as,
e.g., AUTHORIZATION_FAILED
Standard
G-28 Coding When processing multiple parameters, check for the
basic conditions (like is not null, is greater than zero,
etc) for all parameters first before pulling relevantinformation (table records, etc) for each parameter.
This will not only improve interaction with end-user but
will also improve the network traffic of making
database calls.
Standard
G-29 Code Layout and
Presentation
Proper spacing must be maintained within the program
statements for ease in readability. Insert a blank line
before and after important control blocks and
statements
Standard
16 ISG-QMS-COD003-3.0 SAP Standards: General
-
7/27/2019 SAP Coding Standards ERPAMS
17/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: General
G-30 Code Layout and
Presentation
Begin each new statement in a new line. Standard
G-31 Code Layout and
Presentation
Avoid excessive nesting of IF statements. Consider the
use of CASE statements to resolve such nesting, ifpossible.
Standard
G-32 Code Layout and
Presentation
Avoid the replication of code by using FORMs,
INCLUDEs, functions, etc.
Standard
G-33 Filenames Filenames must be prefixed with the complete path
name where the file is stored (or will be created). Avoid
hard-coding of the paths in the program or defining it
as constant in the variable declaration section of
program.
Standard
G-34 Macros No new macros should be allowed. Standard
G-35 Exceptions Handle exceptions when calling a function module Standard
G-36 Texts No hard coding of texts. Standard
G-37 Import parameters If an import parameter is optional/mandatory, then the
method or function module should work accordingly. It
should check the values and return proper error
messages.
Standard
G-38 Standard SAP Table
modification Standard SAP tables should never be updated directly.
It can be changed only through transactions.
Standard
G-39 Lock Objects usage Following sequence must be followed: As soon as the
data is retrieved for the purpose of making updates,
acquire an optimistic lock on the data (lock mode
O),(b) After making required changes (through
screen or background job etc), convert the already
acquired optimistic lock to exclusive lock (lock mode
E).
Standard
G-40 Code Layout and
Presentation
All operands for group statements (e.g. WRITE:,
CLEAR:, REFRESH:, etc) should appear on a new
line.
Recommen-
dation
WRITE:
gv_UPI,
gv_name.
G-41 Code Inspector Use this to improve the performance of the code Recommen-
dation
G-42 Boolean Variable SAP standard data element BOOLE_D can be used as
reference data type
Recommen-
dation
G-43 Numeric : Data type N Avoid using Numeric data type for calculations. Use
them for numeric character fields only
Recommen-
dation
Telephone
numbers, date
G-44 Negative statements Avoid using negative condition if positive condition is
easier to comprehend.
Recommen-
dation
If a variable has
to be checked
for value 'X' in it.
Use 'EQ' 'X'
statement thanif v_ch 'NE'
space.
G-45 While vs Do Use while statement than do statement wherever
possible. While statement is faster and easier to
understand
Recommen-
dation
17 ISG-QMS-COD003-3.0 SAP Standards: General
-
7/27/2019 SAP Coding Standards ERPAMS
18/19
Official Use Only
ID Guidelines Standard/ Recommendation Class Example
SAP Standards: General
G-46 Table Types If the table type is based on SAP delivered (or custom
created) structure or table, programmers are
encouraged to use the same name as that of structure
or table (excluding the namespace from the structureor table name).
Recommen-
dation
G-47 Modularization If it is a large scale enhancement, create a new
include/subroutine pool etc to add new subroutines,
programs etc
Recommen-
dation
G-48 Code Layout and
Presentation
Variables of same type should be declared in
alphabetical order, however a group of variables that
belong to same context should be declared at one
place (separated from the rest by a blank line).
Recommen-
dation
G-49 Sort statement Sort statement should not be inside loop. Recommen-
dation
G-50 Sort statement Sort internal table before Read statement to avoid
unpredictable result.
Recommen-
dation
G-51 Data Dictionary objects If a similar type of SAP delivered DD object already
exists for the custom DD object being defined, then the
custom DD object must be defined with same data
type and size as the one existing in SAP so as to
maintain consistency unless absolutely necessary to
deviate.
Recommen-
dation
G-52 Message Numbers Always use the next immediate available number for
new messages
Recommen-
dation
G-53 FM Interface parameters Always call by reference (performance) unless it is
necessary to call by value (example RFC)
Performance
hint
G-54 Outbound emails As per policy which is described in Stephen
Sebastian's email of 4/6/2006, which is filed in IRIS:
http://WBLN0036.worldbank.org/85256B52005840BB/(
ViewContentTransaction)?OpenAgent&DOCID=8F5B5
498524B19158525714800470DD9&Framework=IRIS&
Policy
18 ISG-QMS-COD003-3.0 SAP Standards: General
-
7/27/2019 SAP Coding Standards ERPAMS
19/19
Official Use Only
Change
Request
ID
Section
Changed
New
Version
Author /
Date
Approved
By / Date
Change Summary
Baselined All 3.0 J. Pauline
Devaraj
04/20/2006
SEPG
04/20/2006
Initial release of the new standards in spreadsheet
format. This new standard will also replace the
SAP Code Review Checklist (COD-004).
Template Change History
19 Ver 3 0 04/20/2006Software Coding Process
SAP C di St d d