ABAP Naming Conventions
-
Upload
sabari-nathan -
Category
Documents
-
view
201 -
download
4
description
Transcript of ABAP Naming Conventions
Naming Conventions
Document Change Control
Release Description Created By
Date ReviewedBy
Date Approved Date
1.1 Local / Country naming conventions
Kannan Gopal
20th July
1 Naming Conventions for ABAP /4 1.1 Definitions in the Data Dictionary ( SE 11)
1.2 ABAP /4 programming objects
1.3 Conventions for Data Declarations 1.3.1 Variables1.3.2 Types1.3.3 Constants1.3.4 Other
1.4 Naming Conventions for ABAP - Object Oriented 1.4.1 Global Conventions 1.4.2 Local Conventions 1.4.3 Class - local Conventions 1.4.4 Data definitions ( variables ) 1.4.5 Guidelines and Conventions for JAVA development 1.4.6 Conventions from Other Areas 1.4.7 CRM - specific Naming Conventions
1.5 Application area
1.6 Country Codes
1.7 ABB Mandatory Naming Conventions 1.7.1 LSMW1.7.2 SAPSCRIPT
Programming Guidelines ABB V 0.1.doc Page 1 of 15
Naming Conventions
1. Naming Conventions for ABAP/4Naming 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 <Z> is representing the customer name range and <AS> the application specific id of the customer project and <CN> 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
1. Definitions in the Data Dictionary (SE11)
Dictionary Element Naming Convention Example
Database table <Z><AS><CN>_<name> ZMMIN_AVDK
Views <Z><AS><CN>_V_<name> ZMMIN_V_AVDK
Data element <Z><AS><CN>_<name> ZMMIN_WERKS
Structure <Z><AS><CN>_S_<name> ZMMIN_S_AVDK
Append Structures <Z><AS><CN>_<database table>_<name>
ZMMIN_MARA_COLOR
Table type <Z><AS><CN>_IT_<name> ZMMIN_IT_AVDK
Domain <Z><AS><CN>_<name> ZMMIN_WERKS
Search help <Z><AS><CN>_H_<name> ZMMIN_H_AVDK
Lock object E<database table> EZMMIN_AVDK
…
Notes:
● Also names for customer specific lock objects must start with an ‘E’.2. 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
<Z><AS>N ZMM0
Programming Guidelines ABB V 0.1.doc Page 2 of 15
Naming Conventions
Transaction codes <Z><AS><CN><text><number> 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 <Z><AS>N ZMM0
Report <Z><AS><CN>_<name> Test and check programs are created in the development class $TMP (local objects).
Includes <Z><AS><CN>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 <Z><AS><CN>_<name>
Menu Z<AS><CN><Menus>
Dynpro Number >= 9000
Function modules Z<AS><CN> _<text> ZMMIN_STRMAT_INBOUND
Function Group Z<AS><CN>_<Text> ZMMGL_PURCHASE_ORDER
Enhancements Z<AS><CN>_<Text> ZFIGL_GLCHECK
Programming Guidelines ABB V 0.1.doc Page 3 of 15
Naming Conventions
For country perspective it is followed as given below :Object type Naming Convention Example or Comment
Package / Development class
<Y><AS><CN>N YMMIN0
Transaction codes <Y><AS><text><number> 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 <Y><AS>N YMM0
Report <Y><AS>_<name> Test and check programs are created in the development class $TMP (local objects).
Includes <Y><AS>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 <Y><AS>_<name>
Menu <Y><AS><Menus>
Programming Guidelines ABB V 0.1.doc Page 4 of 15
Naming Conventions
Dynpro Number >= 9000
Function modules Z<AS><CN> _<text> ZMMIN_STRMAT_INBOUND
Function Group Z<AS><CN>_<Text> ZMMGL_PURCHASE_ORDER
Enhancements Z<AS><CN>_<Text> ZFIGL_GLCHECK
3. Conventions for Data Declarations
1. Variables
There are the following general naming conventions for variables:<Visibility><Data type>_<Name>
Visibility
Data Type
L Local V Variable (optional)
G Global S Structure
I Import parameter (non-changeable) 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.
2. TypesType Data
TypeT Type V Variable (optional)
S Structure
T Table
R Range table / selection table
Type pools are no longer used!
Programming Guidelines ABB V 0.1.doc Page 5 of 15
Naming Conventions
3. ConstantsConstants are defined globally with the prefix "GC" (or "global" or "constant".)
ConstantsGC Constant
4. OtherOtherP Selection parameters
SO Selection options
TCTRL Table control
TSTRP Tabstrip
Example:Types Value
Program-internal type TV_mytype
Program-internal type with structure TS_mytype
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
4. Naming Conventions for ABAP-Object Oriented
The following additional conventions apply to the use of ABAP-OO:
Legend: In the following text <Z> is representing the customer name range (Z or Y or /name range/) and <AS> the application id of the customer project and <CN> the country code.
1. Global ConventionsClasses and interfaces in the class library must be defined in the customer namespace Z**.
Class in the class library* <Z><AS><CN>CL_<class name>The class name must consist of nouns and always be singular.
<Z><AS><CN>CL_COMPANY_CODE, <Z><AS><CN>CL_GENERAL_LEDGER_ACCOUNT
Interface in class library* <Z><AS><CN>IF_<interface name>The same naming conventions are used for interfaces as are used for classes
<Z><AS><CN>IF_STATUS_MANAGEMANT, <Z><AS><CN>IF_CHECKER
Programming Guidelines ABB V 0.1.doc Page 7 of 15
Naming Conventions
Type in DDIC* <type name>
Program-local class (recommendation) LCL_<class name>The class name must consist of nouns and always be singular.
LCL_TREE_MANAGEMENT
Program-local interface(recommendation)
LIF_<interface name>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.
2. Local ConventionsClasses and interfaces in the class library must be defined in the customer namespace Y**.
Class in the class library* <Y><AS>CL_<class name>The class name must consist of nouns and always be singular.
<Y><AS>CL_COMPANY_CODE, <Y><AS>CL_GENERAL_LEDGER_ACCOUNT
Interface in class library* <Y><AS>IF_<interface name>The same naming conventions are used for interfaces as are used for classes
<Y><AS>IF_STATUS_MANAGEMANT, <Y><AS>IF_CHECKER
Type in DDIC* <type name>
Program-local class (recommendation) LCL_<class name>The class name must consist of nouns and always be singular.
LCL_TREE_MANAGEMENT
Program-local interface(recommendation)
LIF_<interface name>The same naming conventions are used for interfaces as are used for classes
LIF_PRINTER
Programming Guidelines ABB V 0.1.doc Page 8 of 15
Naming Conventions
3. Class-local ConventionsMethod name <method name>
The method name must start with a verb.GET_STATUS, CREATE_ORDER, DETERMINE_PRICE
Event <event name>Event names must be assigned as follows: <Noun>_<Verb in past tense>.
BUTTON_PUSHED, COMPANY_CODE_CHANGED, BUSINESS_PARTNER_PRINTED
Class-local type definitions(recommendation)
All type definitions that are not defined in the DDIC are marked with “Y+_”
YV/S/T_<type name>YV_INTERNAL_TYPE, YS_STRUCTURE, YT_TABLE
Data definition (constant)(recommendation)
C_<constant name>C_MAX_LINE
4. 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:
Instance Static
Public GIV/GIS/GIT_<variable name>
gis_mara TYPE mara
GSV/GSS/GST_<variable name>
gsv_matnr TYPE matnr
Private LIV/LIS/LIT_<variable name>
lis_mara TYPE mara
LSV/LSS/LST_<variable name>
lsv_matnr TYPE matnr
Protected SIV/SIS/SIT_<variable name>
sis_mara TYPE mara
SSV/SSS/SST_<variable name>
ssv_matnr TYPE matnr
Notes:
● Always use the ‘V’ in the prefix for definition of variables to avoid misunderstanding. In normal ABAP GS_<variable_name> 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_<attribute name>, GET_<attribute name>
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_<event name>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
AS_<new type>AS_STRING, AS_ISOCODE
Methods that deliver a Boolean valueThese methods must not return any EXCEPTIONs
Recommendation: The Boolean value should be represented by the values SPACE/’X’ for false/true
IS_<adjective>IS_OPEN, IS_EMPTY, IS_ACTIVE
Check methodsThese methods are different from the “IS_<adjective>“ – methods in that they include the option of returning EXCEPTIONS.
CHECK_<objective>CHECK_AUTHORIZATION, CHECK_PROCESS_DATE
The parameters are seen from the point of view of the method that implements them:
IMPORTING-Parameter IV/S/T_<parameter name>
EXPORTING-Parameter EV/S/T_<parameter name>
Programming Guidelines ABB V 0.1.doc Page 10 of 15
Naming Conventions
CHANGING-Parameter XV/S/T_<parameter name>
RESULT RV/S/T_<result>
EXCEPTIONS See “EXCEPTIONs”
Note: The use of prefixes in NOT mandatory. However, if prefixes are used, then they must be the prefixes described above.
ExceptionsAgreeing 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_FOUND)
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, CLOSE_FAILED, SELECTION_FAILED, AUTHORIZATION_FAILED)
FOREIGN_LOCK Data is locked by another user.
INCONSISTENT Object data on the database is 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)
Programming Guidelines ABB V 0.1.doc Page 11 of 15
Naming Conventions
..._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.
5. Guidelines and Conventions for JAVA developmentThe coding and naming conventions proposed by SUN would be used
6. Conventions from Other AreasThis 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.
7. CRM-specific Naming ConventionsThere are the following additional conventions for developments within the my.SAP.com component CRM.
IncludesIncludes 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
Programming Guidelines ABB V 0.1.doc Page 12 of 15
Naming Conventions
● 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 TYPDue to the technical restrictions of function groups, the last three characters give information on the type of Includes (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 smaller include for each theme area for data statements, constants, types, ...(Flexible
implementation, definitions that are not required are not loaded)
Programming Guidelines ABB V 0.1.doc Page 13 of 15
Naming Conventions
5. Application area
SAP application area ID SD – Sales and Distribution
PS -- Project Systems
MM – Materials Management
QM – 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
6. 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
7. ABB Mandatory Naming Conventions
1. LSMWLegacy 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
2. SAPSCRIPTR/3 Documentation (SE61)When creating an object that documents a Workbench object, the document has the samename as the object.For dialogue texts, the name of the related workbench object (calling program) is to beused.For independent documents (e.g. general texts, chapters of an online manual etc.) you arefree to allocate any name within the customer name range.
Programming Guidelines ABB V 0.1.doc Page 15 of 15