Entering content frame

Background documentationNaming Conventions in ABAP Objects  Locate the document in its SAP Library structure

Global classes and interfaces that you create in the Class Builder are stored in the class library and administered by the R/3 Repository: they therefore have the same namespace as all other Repository objects (database tables, structures, data elements, and so on).
It is therefore necessary to have naming conventions for object types and their components and to use them uniformly within program development.

Note

The following naming convention has been conceived for use within the SAP namespace:
If you do not observe the naming conventions for object types (classes and interfaces), conflicts will occur when the system creates persistent classes, since it will be unable to generate the necessary co-classes. 

Namespace for Components

A single namespace within a class is shared by:

§         All components of the class itself (attributes, methods, events, constructors, interfaces, internal data types in the class, and aliases)

§         All public and protected components of the superclasses of the class.

Note

Method implementation has a local namespace. The names of the local variables can obscure those of class components.

Naming Convention

The naming convention has been kept as general as possible to avoid adversely influencing the naming of objects.

General Remarks

When you choose names for development objects, you should:

·         Use English names

§         Use glossary terms when possible

For example, CL_COMPANY_CODE instead of BUKRS

§         In compound names, use the underscore character (_) as a separator. Since names are not case-sensitive, this is the only character that you can use to separate names.

Example: CL_COMPANY_CODE, CL_GENERAL_LEDGER_ACCOUNT

§         Names should describe the action, not the implementation of the action.

Example: PRINT_RECTANGLE, not RECTANGLE_TO_SPOOL

Conventions for Object Types

 

Class and interface names in the class library belong to the same namespace as data elements, tables, structures, and types. They are maintained centrally in table TADIR.

 

Class in the class library

CL_<class name>

The class name should be made up of singular nouns.

CL_COMPANY_CODE, CL_GENERAL_LEDGER_ACCOUNT

Interfaces in the class library

IF_<interface name>

The same naming convention applies to interfaces as to classes.

IF_STATUS_MANAGEMANT, IF_CHECKER

Local classes in programs
(recommendation)

LCL_<class name>

The class name should be made up of singular nouns.

LCL_TREE_MANAGEMENT

Local interfaces in programs
(recommendation)

LIF_<interface name>

The sane naming convention applies to interfaces as to classes.

LIF_PRINTER

Note

Recommended naming conventions are not compulsory. However, if you use prefixes for these class and interface names, you should use those listed above.

Conventions for Components

 

Method name

<method name>

Method names should begin with a verb:

GET_STATUS, CREATE_ORDER, DETERMINE_PRICE

Events

<event name>

Event names should have the form
<noun>_<participle>:

BUTTON_PUSHED, COMPANY_CODE_CHANGED, BUSINESS_PARTNER_PRINTED

Local type definitions within a class
(recommendation)

TY_<type name>

TY_INTERNAL_TYPE, TY_TREE_LIST

Data definitions (variables)

<variable name>

When you name variables within a class (CLASS-DATA or DATA), avoid using verbs at the beginning of the name (to avoid conflicts with method names).

LINE_COUNT, MARK_PRINTED, MARK_CHANGED, STATUS

Data definitions (constants)
(recommendation)

CO_<constant name>

CO_MAX_LINE, CO_DEFAULT_STATUS, CO_DEFAULT_WIDTH, CO_MAX_ROWS

Note

Recommended naming conventions are not compulsory. However, if you use prefixes for these class and interface names, you should use those listed above..

Concrete Method Descriptions

 

Attribute access

SET_<attribute name>, GET_<attribute name>

Methods that access attributes of any kind should be prefaced with GET_ or SET_.

GET_STATUS, SET_USE_COUNT

Event handler methods

ON_<event name>

Methods that handle events should begin with ON, followed by the name of the event that they handle.

ON_BUTTON_PUSHED, ON_BUSINESS_PARTNER_PRINTED

Methods that perform type conversions

AS_<new type>

AS_STRING, AS_ISOCODE

Methods that return a Boolean value

These methods may not return any exceptions.

Recommendation: Use SPACE and 'X' to represent false and true respectively.

IS_<adjective>

IS_OPEN, IS_EMPTY, IS_ACTIVE

Check methods

CHECK_<objective>

CHECK_AUTHORIZATION, CHECK_PROCESS_DATE

 

Local Conventions Within Methods

For parameters

The parameters are regarded from the point of view of the method that implements them:

 

IMPORTING parameters

IM_<parameter name>

EXPORTING parameters

EX_<parameter name>

CHANGING parameters

CH_<parameter name>

RESULT

RE_<result>

Note

Using prefixes is NOT compulsory. However, if you do use them, use those listed above.

For exceptions

The following table contains a series of possible exception names, that can also be used generically (for example, NOT_FOUND could also be used as DATE_NOT_FOUND)

 

EXCEPTION

Meaning

ACTION_NOT_SUPPORTED

The requested action or function code is not supported.

CANCELLED

If a method uses a dialog to find out what has to be dome (for example, a list of choices), and the user chooses "Cancel", you can set this exception.

EXISTING

A new object that you want to create already exists in the database.

FAILED

The method could not be executed because of the current environment. This exception is intended for cases where the method cannot be executed because of variable system circumstances.

..._FAILED

Part of the method could not be completed because of the current environment. (OPEN_FAILED, CLOSE_FAILED, SELECTION_FAILED, AUTHORIZATION_FAILED)

FOREIGN_LOCK

Data is locked by another user.

INCONSISTENT

Object data in the database is inconsistent.

..._INCONSISTENT

The component data for … of an object in the database is inconsistent.

INVALID

The object data entered is incorrect (for example, company code does not exist). Compare NOT_QUALIFIED.

..._INVALID

The component data entered for an object is incorrect. Compare NOT_QUALIFIED.

INTERNAL_ERROR

Last resort. Only use this exception if you cannot be more precise about the nature of the error.

NOT_AUTHORIZED

The user does not have the required authorization.

NOT_CUSTOMIZED

The object requested is not correctly customized.

..._NOT_CUSTOMIZED

The component … of the requested object is not correctly customized.

NOT_FOUND

Unable to find the requested object.

..._NOT_FOUND

Unable to find component … of the requested object.

NOT_QUALIFIED

The combination of input parameters is insufficient to run the method. Compare INVALID.

..._NOT_QUALIFIED

One parameter of the method is not qualified.

NUMBER_ERROR

Error assigning a number.

SYSTEM_ERROR

This exception is set if the system returns an unexpected error message.

 

 

 

 

Leaving content frame