Professional Documents
Culture Documents
Page 1/30
Table of Contents
1 2 INTRODUCTION........................................................................................5 ABAP REPOSITORY NAMING CONVENTIONS...............................................6 2.1 ABAP REPORTS........................................................................................................ 6 2.2 REPORT PAINTER REPORTS.......................................................................................... 6 2.3 DIALOG PROGRAMS (MODULE POOL PROGRAMS)............................................................7 2.4 INCLUDES (WITHIN MODULE POOL PROGRAMS).................................................................7 2.5 TRANSACTION CODES................................................................................................. 8 2.6 SCREEN PAINTER SCREENS.......................................................................................... 8 2.7 FUNCTION GROUPS.................................................................................................... 8 2.8 FUNCTION MODULES.................................................................................................. 8 2.9 MESSAGE CLASSES.................................................................................................... 9 2.10 DEVELOPMENT CLASSES............................................................................................ 9 2.11 AREA MENUS.......................................................................................................... 9 2.12 BDC SESSION NAMES............................................................................................... 9 2.13 TRANSPARENT TABLES............................................................................................10 2.14 POOLED TABLES.................................................................................................... 10 2.15 CLUSTER TABLES................................................................................................... 10 2.16 STRUCTURES........................................................................................................ 11 2.17 VIEWS................................................................................................................. 11 Database view......................................................................................................... 11 Help view................................................................................................................ 11 Maintenance view................................................................................................... 11 Projection views...................................................................................................... 12 2.18 DOMAINS............................................................................................................. 12 2.19 DATA ELEMENTS.................................................................................................... 12 2.20 LOCK OBJECTS ..................................................................................................... 12 2.21 SEARCH HELPS...................................................................................................... 13 2.22 TYPE GROUPS....................................................................................................... 13 2.23 VARIANTS............................................................................................................ 13 2.24 LAYOUT SETS....................................................................................................... 13 2.25 REPORT PAINTER LIBRARIES.....................................................................................14 2.26 REPORT PAINTER SETS............................................................................................14 3 ABAP PROGRAMMING NAMING CONVENTIONS.........................................15 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4 DATA VARIABLES..................................................................................................... 15 GLOBAL VARIABLES.................................................................................................. 15 LOCAL VARIABLES.................................................................................................... 15 CONSTANTS........................................................................................................... 15 INTERNAL TABLES.................................................................................................... 15 PARAMETERS.......................................................................................................... 16 SELECT OPTIONS..................................................................................................... 16 FORMS.................................................................................................................. 16 TRANSPORTS.......................................................................................................... 16
ABAP PROGRAMMING STANDARDS..........................................................18 4.1 ABAP PROGRAMS.................................................................................................... 18 Program header...................................................................................................... 18 Report header......................................................................................................... 19 Report trailer........................................................................................................... 19 4.2 PROGRAM FLOW...................................................................................................... 19 4.3 INITIALIZATION EVENT............................................................................................... 20 4.4 START OF SELECTION EVENT......................................................................................20
151866248.doc
Page 2/30
Printed 14/6/13
4.5 4.6 4.7 5 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 6.10 6.11 7 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.10
END OF SELECTION EVENT......................................................................................... 20 TOP OF PAGE EVENT................................................................................................ 20 FORMS.................................................................................................................. 20 CASE STATEMENT................................................................................................... 22 CHECK STATEMENT................................................................................................ 22 COLLECT STATEMENT.............................................................................................22 IF STATEMENT........................................................................................................ 22 LOOP STATEMENT................................................................................................... 23 SELECT STATEMENT...............................................................................................23 SHIFT STATEMENT.................................................................................................. 23 MOVE STATEMENT ................................................................................................. 23 WHILE STATEMENT.................................................................................................24 DATA RETRIEVAL WITH GET STATEMENT......................................................................25 DATA RETRIEVAL WITH SELECT STATEMENT.................................................................25 PROGRAM SIZE....................................................................................................... 26 MESSAGES............................................................................................................. 26 PROGRAM CHECKS................................................................................................... 26 TABLE UPDATES AND MODIFICATIONS...........................................................................26 TEXT ELEMENTS...................................................................................................... 27 SYSTEM FIELDS....................................................................................................... 27 READING TABLES..................................................................................................... 27 BATCH SESSIONS................................................................................................... 27 DEVELOPMENT WORKBENCH....................................................................................27 LIST OF SAP MODULES............................................................................................. 28 LIST OF SAP SUBMODULES.......................................................................................28 LIST OF REPORT TYPES.............................................................................................28 FUNCTIONAL MESSAGE CLASSES.................................................................................28 DEVELOPMENT CLASSES............................................................................................28 FUNCTIONAL AREAS FOR REPORT PAINTER LIBRARY........................................................29 LIST OF REPORT PAINTER SETS..................................................................................29 LIST OF TEAMS........................................................................................................ 29 LIST OF SUB TEAMS.................................................................................................29 CHANGE REQUEST EXAMPLES..................................................................................29
GENERAL GUIDELINES............................................................................25
APPENDIX.............................................................................................. 28
151866248.doc
Page 3/30
Printed 14/6/13
151866248.doc
Page 4/30
Printed 14/6/13
1 Introduction
The purpose of this document is to establish the ABAP development standards and naming conventions for all SAP R/3 repository items likely to be affected in the project. It serves as a guideline for all the developers to strictly follow such that a unique standard of custom objects can be maintained throughout the project. These standards should be followed in order to achieve consistent and high quality programming code. To enforce the above all custom developments should undergo a final review at the completion of the task to ensure that these standards were applied and adhered to. The author of this document does not claim to have fully documented every single item and aspect, as some of the repository items are self-explanatory and therefore have no validity for further documentation. Missing objects that warrant documentation should be added to this document to make it an up-to-date and complete document. This might also be required in the case of a software upgrade containing enhancements, new features and functionality. This document was written on the basis of a SAP/R3 system release 4.70
151866248.doc
Page 5/30
Printed 14/6/13
6 7-8 9-20
I 17 _Cash_Discou nt
151866248.doc
Z GS C0 _ 12
Constant Z List
Constant _ Range
This will identify the report as a custom development. Identification of SAP module the report is developed for. See appendix for a list of valid SAP modules. Identification of the report painter library. Always use the last two characters of the library name. Separator Sequential numbering for programs in the same module/report painter library. Always use the next available number.
7-8
05
Range
151866248.doc
151866248.doc
Page 8/30
Printed 14/6/13
1 2 3-30
Z _ SET_DATE
Constant Z Constant _
This will identify the function module as a custom development. Separator Any meaningful description about the functionality of the function module. Multiple underscore characters to separate words are allowed. A total length of thirty characters is permitted.
151866248.doc
2 3-12
_ JRNLS
Constant _
customer generated BDC session. Separator Any abbreviated word describing the functionality of the BDC session. No special characters are permitted.
3-18
VENDTL
3-8
FINPERIODS
151866248.doc
functionality will be used the table name must not exceed five characters in total. This is a SAP/R3 restriction.
2.16 Structures
Structures are typically created as a reference to external data storage. Structures represent working storage definitions or copybooks. The following naming conventions apply. Positio n 1-2 Sample ZZ Type Constant ZZ Description/Purpose This identifies the structure as a custom development. SAP/R3 has used the prefix Z for some structures. To clearly identify custom developed structures the prefix ZZ is to be used. Any abbreviated word describing the data addressed in this structure. Underscores are not permitted in the third and fourth position. This is a SAP restriction.
3-8
VENDORDT
2.17 Views
Four types of views are available to the developer. The naming conventions shown below will apply to all of them. A brief description of the purpose of each view type follows the naming conventions. Positio n 1 2-18 Sample Z VENDORVW Type Constant Z Description/Purpose This identifies the View as a custom development. Any abbreviated word describing the data defined in the view.
Database view
Database Views are typically used to join secondary tables to primary tables via a foreign key. This type of view disallows updates. Database views should be generated when accessing two or more related tables to reduce network traffic.
Help view
Help Views are used by SAP/R3 whenever a pull-down on a data dictionary field is done. In most cases this field will be a field generated by Screen Painter or by an ABAP Report. This only applies if no matchcode is defined for the field. Help views are useful as they allow linking to secondary tables via foreign keys.
Maintenance view
Maintenance Views are commonly generated for non-transactional data tables. Multiple tables can be used that are linked via foreign keys. Maintenance views allow the speedy generation of maintenance screens. Due to system restrictions in the locking area, the typical candidates for this type of view are One user at a time update tables. Tables containing fairly static data are also prime examples.
151866248.doc Page 11/30 Printed 14/6/13
Projection views
These types of views are only permissible on one table and selection restrictions are not permitted. They are used to filter data from views. Recommendation is to use Database Views instead.
2.18 Domains
Domains are used to describe data fields. Developers are encouraged to use a SAP equivalent Domain if it is available. Naming conventions for Domains are as follows. Positio n 1-2 Sample ZZ Type Constant ZZ Description/Purpose This identifies the domain as a custom generated domain. SAP has used the Z prefix for some domains. To clearly identify custom developed domains a prefix of ZZ is used. Any meaningful abbreviation describing the inherence of the domain.
3-8
INT_ID
3-8
NAME
151866248.doc
2.23 Variants
Variants are used to store default ABAP report parameters. The naming conventions are as follows. Positio n 1-14 Sample GL_UPLOAD Type Description/Purpose Any meaningful abbreviation to describe the purpose of the variant. Multiple underscore characters are allowed.
151866248.doc
Page 13/30
Printed 14/6/13
151866248.doc
Page 14/30
Printed 14/6/13
PROJECT
3.4 Constants
Constants will be prefixed with C_. A length restriction of 30 characters applies. Constants must be declared with the CONSTANTS statement. Example CONSTANTS: C_ONE(1) TYPE C VALUE 1.
151866248.doc
PROJECT
3.6 Parameters
Parameters are restricted to a length of eight characters. They are prefixed with P_ followed by the data dictionary field it resembles or represents. For parameters with no data dictionary field reference, the name can be freely chosen. Example PARAMETERS: P_BUKRS LIKE T001-BUKRS.
3.8 Forms
Forms should be named in such a way that it provides a meaningful description of the functionality of the form. Words should be separated with the underscore character. A maximum length of thirty characters is permissible. Example FORM CALCULATE_WEEKLY_AVERAGE. ENDFORM. FORM FIND_FILES_TO_PROCESS. ENDFORM.
Example
3.9 Transports
Transports are the SAP/R3 way to promote developments to other systems. This will mainly be transports of objects from the development environment to the test and production environment. The short description of the underlying change request should be entered according to the following naming conventions. (See appendix for examples of change request descriptions). Positio n 1-2 3 Sample FI GL CCA Type List Constant - List List Description/Purpose This will identify the team. See appendix for a list of valid teams. Separator This will identify the sub team. No positions are provided as the length of
Page 16/30 Printed 14/6/13
151866248.doc
PROJECT
-60
Constant :
this part of the transport description is variable. See appendix for a list of valid teams. Separator This will identify the contents of the transport. A meaningful short text must be provided.
151866248.doc
Page 17/30
Printed 14/6/13
PROJECT
Description Object name of program Title of program. This is the technical name of the program Name of developer (First and surname) Date of development commencement SAP/R3 system release the program was originally developed for Name of module and submodule the program was developed for Short but meaningful functional description of the program Provide details about explicit authority checks performed in this program First and surname of the developer who applied the modification Date when the modification was applied The SAP/R3 change request the modification was activated under Brief but meaningful description why the modification was required and how it was achieved.
PROJECT
* Modifications : *-----------------------------------------------------------------------
Report header
ABAP programs producing report output must have the defined standard header lines. Construction of these lines should be programmed in a function module for easy inclusion. The following is a list of elements and a sample of a header line report output produced by an ABAP program utilizing a function module call. Element Program Corporation Date System Client Report Description Time User Page Sample
PROGRAM: ZBC00000 SYSTEM : DP1/110 USER : THGXS Automobile (Thailand) Interface Initiator DATE: 23/01/2001 TIME: 17:36:25 PAGE: 1
Description Import parameter Value of text element Value of SAP/R3 system Value of SAP/R3 system Value of SAP/R3 system Value of SAP/R3 system Value of SAP/R3 system Value of SAP/R3 system Value of SAP/R3 system
Report trailer
ABAP programs producing report output must have the defined standard trailer line. Construction of this line should be programmed in a function module for easy inclusion. The following is a list of elements and a sample of a trailer line report output produced by an ABAP program utilizing a function module call. Element Text Description The first sample is for a report that outputted detail lines. The second sample is for a report that did not produce detailed output.
Sample
***** END OF REPORT ***** *** NO DATA TO REPORT ***
PROJECT
4.7 Forms
These subroutines must always use the LIKE statement to declare the forms parameter characteristics. This allows the SAP ABAP generate process to reserve precise dimensions in the generated object. The effect of not having the LIKE statement is that only at run time can ABAP evaluate the size of passed parameters. This has the effect of increasing the programs buffer size. Constant calls to a FORM with varying parameter sizes can mean constant extensions by the ABAP processor. This can simply be avoided by using the LIKE statement. Use the TYPE ASSIGNMENT facility in SE38 (Utilities Menu). There will be cases where the FORMAL parameter size declared on the FORM routine with the LIKE statement doesnt match the ACTUAL parameter size due to the fact that more than one parameter type is passed to the same formal parameter field. A program check will determine this. In this case it is permissible to use the TYPE statement. Forms should be headed by a brief description of the functionality embedded in the form. The input and output parameters should also be described. It is important to distinguish between the input and output parameters in the documentation, as there is no inherent distinction made by SAP ABAP. Any parameters whose values do not change are considered input and any parameters whose value gets set, reset, or changed should be documented as output. The use of directional arrows is a good way to indicate which parameters are input or output. Another way of distinguishing between input and output parameters is to declare those variables, which are changed by the subroutine with the extension CHANGING. In actuality this extension does not affect the data in any way (in this particular case), but it used strictly as a distinguishing feature. Also when declaring your FORM you should always put all input parameters first and then all output parameters. Sample
----------------------------------------------------------------------------* This routine simply concatenates 2 strings separated by a space and places * them in an output string. ----------------------------------------------------------------------------* Parameters: * --> STR1 - string 1 * STR2 - string 2 * <-- O_STRING - output string
151866248.doc Page 20/30 Printed 14/6/13
PROJECT
*---------------------------------------------------------------------------FORM CONCAT_STRINGS USING STR1 LIKE G_CHAR10 STR2 LIKE G_CHAR10 CHANGING O_STRING LIKE G_CHAR10. DATA: L_LEN1 TYPE I. L_LEN1 = STRLEN( STR1 ). L_LEN1 = L_LEN1 + 1. O_STRING = STR1. WRITE STR2 TO O_STRING+f_LEN1. ENDFORM.
151866248.doc
Page 21/30
Printed 14/6/13
PROJECT
5.4 IF statement
When coding nested IF statements, no more than three levels should be constructed. This will restrict lengthy control events congesting a program and making it difficult to read. Each level must be consistently aligned and indented. Deeply nested IF statements are not recommended and should be replaced with CASE statements. When coding IF tests, nest the testing conditions so that the outer conditions are those which are most frequently true. For logical expressions with AND, place the most likely false first and for the OR, place the mostly likely true first. Avoid the use of double nive checks, as this can be difficult to understand and maintain.
151866248.doc Page 22/30 Printed 14/6/13
PROJECT
Example
151866248.doc
Page 23/30
Printed 14/6/13
PROJECT
151866248.doc
Page 24/30
Printed 14/6/13
PROJECT
6 General guidelines
The following sections are intended to provide general guidelines for ABAP developers in the . The subjects discussed will be familiar to all developers but are reiterated here because of their importance.
151866248.doc
Page 25/30
Printed 14/6/13
PROJECT
The developer should endeavor to retrieve the data in one operation. This can be achieved with the INTO TABLE addition to the SELECT statement. This form of coding will reduce the network traffic between the SAP/R3 work process and the database thread assigned to the work process. Using the SELECT statement in this form can bring other potential processing time savings as well in the areas of reduced input/output due to the fact the database buffers could store all results after the input/output operation without having it flushed due to other thread requests by competing programs. The usage of views instead of nested SELECT statements will also improve program performance for the same reasons as stated above.
6.4 Messages
The will try to use existing SAP/R3 messages whenever possible. This way the messages are not duplicated within the system and the user will not get different messages depending on in which part of the system he or she operates in.
151866248.doc
Page 26/30
Printed 14/6/13
PROJECT
151866248.doc
Page 27/30
Printed 14/6/13
PROJECT
7 Appendix
7.1 List of SAP modules
Module FI CO MM BC Description Financials Controlling Material Management BASIS
PROJECT
ZFI ZMM
Financials Material
PROJECT
151866248.doc
Page 30/30
Printed 14/6/13