Naming Conventions
Document Change Control
Release
1.1
1
Description
Local / Country naming conventions
Created By
Date
Kannan Gopal
20th July
Reviewed
Date
Approved
Date
By
Nami Na ming ng Co Conv nven enti tion ons s fo forr AB ABAP AP /4 1.1
Defifini De nitition ons s in the Da Data ta Dicti Diction onar ary y (SE11 11))
1.2
ABAP /4 programmi progr amming ng objects objec ts
1.3 Convent Conv ention ions s for Data Decl Declara aratio tions ns 1.3.1 Variables 1.3.2 Types 1.3.3 Constants 1.3.4 Other 1.4 Namin Naming g Con Conve vent ntio ions ns fo forr ABAP -Ob -Obje ject ct Ori Orien ente ted d 1.4.1 Global Conventions 1.4.2 Local Conventions 1.4.3 Class Cla ss-lo -local cal Conventions 1.4.4 Data Dat a de defifini nititions ons (va vari riab able les s) 1.4.5 Guidel Gui deline ines s and Conv Convent entio ions ns for JAVA dev devel elopme opment nt 1.4.6 Conv Co nven entition ons s fro from m Oth Other er Are Areas as 1.4.7 CRM-sp -speci ecific fic Naming Conventio Conven tions ns 1.5
Applicatio Appli cation n area
1.6
Country Coun try Code Codes s
1.7 ABB Mand Mandato atory ry Nami Naming ng Conv Convent ention ions s 1.7.1 LSMW 1.7.2 SAPSCRIPT
Programming Guidelines ABB V 0.1.doc
Page 1 of 15
Naming Conventions
Naming Conventions for ABAP/4 Naming conventions are the result of agreement among customer and implementation partner to use standard generic prefixes when assigning names to development objects, for example, function modules, programming elements, or variables. The system itself does not usually check that these naming conventions are adhered to. The responsibility for this lies with the individual developer. Legend: In the following text
is representing the customer name range and the application specific id of the customer project and the country codes. It has to be GL for global developments and two letter country code for country specific developments. The details of these are specified in section 2.5 and 2.6
Definitions in the Data Dictionary (SE11) Dictionary Element
Naming Convention
Example
Database table
_
ZMMIN_AVDK
Views
_V_
ZMMIN_V_AVDK
Data element
_
ZMMIN_WERKS
Structure
_S_
ZMMIN_S_AVDK
Append Structures
__
ZMMIN_MARA_COLOR
Table type
_IT_
ZMMIN_IT_AVDK
Domain
_
ZMMIN_WERKS
Search he help
_H_
ZMMIN_H_AVDK
Lock object
E
EZMMIN_AVDK
…
Notes: ●
Also names for customer specific lock objects must start with an ‘E’.
ABAP/4 programming objects The N in package/Development class and message class stands for number Object type
Naming Convention
Example or Comment
Package / Development class
N
ZMM0
Transaction codes
It makes sense to follow the SD convention that a suffix in the form of digits refers to the function: 01 = Create
Programming Guidelines ABB V 0.1.doc
Page 2 of 15
Naming Conventions 02 = Change 03 = Display
Message class
N
ZMM0
Report
_
Test and check programs are created in the development class $TMP (local objects).
Includes
nnnXmm
Include names are proposed by the SAP system and structured logically by the developer. Follow the naming conventions from the ABAP fundamentals course. Further includes: Pattern: ZAAGLnnnXmm AA = Application GL = Global nnn = 001 to 999 consecutive number within the application X = Type of content: F = FORM-Routines I = PAI – Routines O = PBO – Routines mm = 01 to 99 consecutive number of the include
Module Pool
_
Menu
Z
Dynpro
Number >= 9000
Function modules
Z _
ZMMIN_STRMAT_INBOUND
Function Group
Z_
ZMMGL_PURCHASE_ORDER
Enhancements
Z_
ZFIGL_GLCHECK
For country perspective it is followed as given below : Object type
Naming Convention
Example or Comment
Package / Development class
N
YMMIN0
Programming Guidelines ABB V 0.1.doc
Page 3 of 15
Naming Conventions Transaction codes
It makes sense to follow the SD convention that a suffix in the form of digits refers to the function: 01 = Create 02 = Change 03 = Display
Message class
N
YMM0
Report
_
Test and check programs are created in the development class $TMP (local objects).
Includes
nnnXmm
Include names are proposed by the SAP system and structured logically by the developer. Follow the naming conventions from the ABAP fundamentals course. Further includes: Pattern: ZAAGLnnnXmm AA = Application GL = Global nnn = 001 to 999 consecutive number within the application X = Type of content: F = FORM-Routines I = PAI – Routines O = PBO – Routines mm = 01 to 99 consecutive number of the include
Module Pool
_
Menu
Dynpro
Number >= 9000
Function modules
Z _
ZMMIN_STRMAT_INBOUND
Function Group
Z_
ZMMGL_PURCHASE_ORDER
Enhancements
Z_
ZFIGL_GLCHECK
Programming Guidelines ABB V 0.1.doc
Page 4 of 15
Naming Conventions Conventions for Data Declarations Variables There are the following general naming conventions for variables: _
Vi sib ilit y L Local
Data Type
V
Variable (optional)
G
Global
S
Structure
I
Import parameter (nonchangeable)
T
Table
E
Export parameter
C
Changing / referenced
R
Range table / selection table
S
Static variable
REF
Pointer (type ref to data)
O
Objects (instances)
Note: Tables with header lines should not be used anymore.
Types T y p e
T Typ
D at a T y p e V
Variable (optional)
S
Structure
T
Table
R
Range table / selection table
e
Type pools are no longer used!
Programming Guidelines ABB V 0.1.doc
Page 5 of 15
Naming Conventions
Constants Constants are defined globally with the prefix "GC" (or "global" or "constant".) Cons tants GC
Constant
Other Other P
Selection parameters
SO
Selection options
TCTRL
Table control
TSTRP
Tabstrip
Example: Types
Value
Program-internal type
TV_mytype
Prog Progra ramm-in inte tern rnal al type type wit with h struc structu ture re
TS_m TS_myt ytyp ype e
Program-internal table type
TT_mytype
Constants
Value
Constant (global)
GC_myconst
Variables
Value
Local variable
LV_myvar
Local structure
LS_mystruc
Local table
LT_mytab
Global variable
GV_myvar
Global structure
GS_mystruc
Global table
GT_mytab
Statics variable
SV_myvar
Statics structure
SS_mystruc
Statics table
ST_mytab
Import variable
IV_myvar
Export variable
EV_myvar
Programming Guidelines ABB V 0.1.doc
Page 6 of 15
Naming Conventions
Changing variable
CV_myvar
Import structure
IS_mystruc
Export structure
ES_mystruc
Exchange structure
CS_mystruc
Import table
IT_mytab
Export table
ET_mytab
Changing table
CT_mytab
Parameter
P_mypara
Selection option
SO_mysel
Local pointer
LREF_mypointer
Naming Conventions for ABAP-Object Oriented The following additional conventions apply to the use of ABAP-OO: Legend: In the following text is representing the customer name range (Z or Y or /name range/) and the application id of the customer project and the country code.
Global Conventions Classes and interfaces in the class library must be defined in the customer namespace Z**.
Clas Class s in the the cla class ss lib libra rary ry**
< < >C >CL_ L_ e>
The class name must consist of nouns and always be singular. CL_COMPANY_CODE, CL_GENERAL_LEDGER_
ACCOUNT
Inte Interf rfac ace e in cla class ss lib libra rary ry**
< < >I >IF_ F_ e>
The same naming conventions are used for interfaces as are used for classes IF_STATUS_MANAGEMA NT, IF_CHECKER Type in DDIC*
Programming Guidelines ABB V 0.1.doc
Page 7 of 15
Naming Conventions Program-local class (recommendation)
LCL_
The class name must consist of nouns and always be singular. LCL_TREE_MANAGEMENT
Program-local interface (recommendation)
LIF_
The same naming conventions are used for interfaces as are used for classes LIF_PRINTER
The objects marked with * are protected by the global TADIR. They do, however, have the same namespace as data elements, tables, structures, and types.
Local Conventions Classes and interfaces in the class library must be defined in the customer namespace Y**. Clas Class s in in the the clas class s lib libra rary ry**
< C >CL_ L_ >
The class name must consist of nouns and always be singular. CL_COMPANY_CODE, CL_GENERAL_LEDGER_ACCO
UNT
Inte Interf rfac ace e in in cla class ss lib library rary**
< I >IF_ F_ >
The same naming conventions are used for interfaces as are used for classes IF_STATUS_MANAGEMANT, IF_CHECKER Type in DDIC*
Program-local class (recommendation)
LCL_
The class name must consist of nouns and always be singular. LCL_TREE_MANAGEMENT
Program-local interface (recommendation)
LIF_
The same naming conventions are used for interfaces as are used for classes LIF_PRINTER
Class-local Conventions Method name Programming Guidelines ABB V 0.1.doc
Page 8 of 15
Naming Conventions
The method name must start with a verb. GET_STATUS, CREATE_ORDER, DETERMINE_PRICE Event
Event names must be assigned as follows: _. BUTTON_PUSHED, COMPANY_CODE_CHANGED, BUSINESS_PARTNER_PRINTED Class Class-lo -local cal type type defini definitio tions ns YV/S/T_ (recommendation) YV_INTERNAL_TYPE, YS_STRUCTURE, All type definitions that are not YT_TABLE defined in the DDIC are marked with “Y+_” Data definition (constant) (recommendation)
C_
C_MAX_LINE
Data definitions (variables) Visibility of data in classes has 2 dimensions: Public / Private / Protected ● Instance / Static To meet these dimensions the following conventions are recommended: ●
Public
Private
Protected
Instance
Static
GIV/GIS/GIT_
GSV/GSS/GST_
gis_mara TYPE mara
gsv_matnr TYPE matnr
LIV/LIS/LIT_
LSV/LSS/LST_
lis_mara TYPE mara
lsv_matnr TYPE matnr
SIV/SIS/SIT_
SSV/SSS/SST_
sis_mara TYPE mara
ssv_matnr TYPE matnr
Notes: ●
Always use the ‘V’ in the prefix for definition of variables to avoid misunderstanding. In normal ABAP GS_ represents a structure!
Programming Guidelines ABB V 0.1.doc
Page 9 of 15
Naming Conventions ●
●
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.
Note: (recommendation) means that the specified prefix is NOT mandatory. However, if prefixes are used, then they must be the prefixes described above.
Attribute access
SET_< SET_
name>, name>,
GET_< GET_
Attribute accesses for every kind of attribute must have the prefix GET_ or. SET_ GET_STATUS, SET_USE_COUNT Methods that deal with an event
ON_
Methods that deal with an event must start with ON, and the name must include the event that they deal with. ON_BUTTON_PUSHED, ON_BUSINESS_PARTNER_PRINTED
Methods that carry out type conversions Methods that deliver a Boolean value
AS_
AS_STRING, AS_ISOCODE IS_
IS_OPEN, IS_EMPTY, IS_ACTIVE
These methods must not return any EXCEPTIONs EXCEPTIONs Recommendation: The Boolean value should be represented by the values SPACE/’X’ for false/true Check methods
CHECK_
These methods are different from the “IS_“ – methods in that they include the option of returning EXCEPTIONS.
CHECK_AUTHORIZATION, CHECK_PROCESS_DATE
The parameters are seen from the point of view of the method that implements them:
Programming Guidelines ABB V 0.1.doc
Page 10 of 15
Naming Conventions
IMPORTING-Parameter
IV/S/T_
EXPORTING-Parameter
EV/S/T_
CHANGING-Parameter
XV/S/T_
RESULT
RV/S/T_
EXCEPTIONS
See “EXCEPTIONs”
Note:
The use of prefixes in NOT mandatory. However, if prefixes are used, then they must be the prefixes described above.
Exceptions
Agreeing on a standard name for EXCEPTIONS makes life easier for all developers. The following table contains meaningful EXCEPTIONS that can also be used generically. (Example: NOT_FOUND could be changed to DATE_NOT_FOUN DATE_NOT_FOUND) D)
EXCEPTION
Meaning
ACTION_NOT_SUPPOR TED
The requested action or OK code is not supported.
CANCELLED
This EXCEPTION can be used if a dialog in a method has determined what is to be done (example: selection list) and the user chooses “Cancel”.
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 subfunction of the method could not be carried out, due to the current environment situation. (OPEN_FAILED, (OPEN_FAILED, CLOSE_FAILED, SELECTION_FAILED, AUTHORIZATION_FAILED)
FOREIGN_LOCK
Data is locked by another user.
INCONSISTENT
Object data on the database is
Programming Guidelines ABB V 0.1.doc
Page 11 of 15
Naming Conventions inconsistent. ..._INCONSISTENT
The subobject data of an object on the database is inconsistent.
INVALID
The specified object data is incorrect. (For example, company code not available) ( as opposed to NOT_QUALIFIED) NOT_QUALIFIED)
..._INVALID
The specified subobject data of an object is incorrect. (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.
NOT_AUTHORIZED
The user is not authorized for the action.
NOT_CUSTOMIZED
The requested object has been customized incorrectly.
..._NOT_CUSTOMIZED
The subobject of the requested object has been customized incorrectly.
NOT_FOUND
The requested object had not been found.
..._NOT_FOUND
The subobject of the requested object has not been found.
NOT_QUALIFIED
The combination of the input parameters is insufficient to trigger the function of the method. (As opposed to INVALID)
..._NOT_QUALIFIED
A particular parameter of the method is not qualified.
NUMBER_ERROR
Error in the numbering.
SYSTEM_ERROR
This EXCEPTION can be set when the Basis system returns an unexpected error code.
Guidelines and Conventions for JAVA development The coding and naming conventions proposed by SUN would be used
Conventions from Other Areas This section addresses additional or supplementary conventions from other areas of SAP development. These can be adopted as they are or used as a basis for developing corresponding conventions in SDP.
CRM-specific Naming Conventions There are the following additional conventions for developments within the my.SAP.com component CRM.
Programming Guidelines ABB V 0.1.doc
Page 12 of 15
Naming Conventions Includes
Includes are subject to the following naming conventions Main program contains an include for all PBO modules in the program ● Ending O0O ● The module does not contain any coding, only Perform Call Sorted alphabetically ● ● Main program contains an include for all PAI modules in the program ● Ending I0I The module does not contain any coding, only Perform Call ● ● Sorted alphabetically ● The main program contains an include for each form routine in the program ● Ending F<**> (for Forms 01-ZZ) ● Sorted alphabetically ● The form routine name is entered as a comment, alongside the include name ● Constants: Ending CON ● Data definitions: Ending DAT ● Type definitions: Ending TYP Due to the technical restrictions of function groups, the last three characters give information on the type of Includes (PBO/PAI/Form/Function) (PBO/PAI/Form/Function) ●
Rules ● ● ● ● ● ●
An include for each form routine (for less problems with support packages, avoid conflicts) An include for all PBO modules An include for all PAI modules The modules do not contain any coding except for the form routines call Sort new includes alphabetically in the main program and enter the routine names as a comment A small smaller er inclu include de for for each each them theme e area area for for data data stat statem ement ents, s, cons constan tants, ts, type types, s, ...(F ...(Flex lexib ible le implementation, definitions that are not required are not loaded)
Programming Guidelines ABB V 0.1.doc
Page 13 of 15
Naming Conventions Application area SAP application area ID SD – Sales and Distribution Distribution PS -- Project Systems MM – Materials Management QM – Quality Quality Management PP
– Production Planning
PM – Plant Maintenance FI
– Finance
CO - Controlling HR – Human Resources CR - CRM Sales CS – CRM Service PL - PLM EH - EHS
Country Codes SAP Country Code ID ( for country specific) : IN – India AU -- Australia MY -- Malaysia PK – Pakistan PH – Phillipines SG – Singapore TH – Thailand VN -- Viatnam NZ – Newzealand ID - Indonesia For developments applicable to all countries: GL: Global
Programming Guidelines ABB V 0.1.doc
Page 14 of 15
Naming Conventions
ABB Mandatory Naming Conventions LSMW Legacy system migration workbench. As this tool resides in a specific namespace, there is technically no SAP conventions on names. ABB
Maintenance
Local
Projects Naming
Z PPPP
Sub-Project Naming
Z PPPP
Object Naming
Meaningful name for the uploaded object
SAPSCRIPT R/3 Documentation (SE61) When creating an object that documents a Workbench object, the document has the same name as the object. For dialogue texts, the name of the related workbench object (calling program) is to be used. For independent documents (e.g. general texts, chapters of an online manual etc.) you are free to allocate any name within the customer name range.
Programming Guidelines ABB V 0.1.doc
Page 15 of 15