2 PROGRAMMING GUIDELINES. 8. Naming conventions. 8. Namespace. 8. A standardized and readable source code: Pretty. Policy Statement on SAP Standard Objects. External ABAP Program Elements . .. Table 2 – Programming Standards Definitions. . Documentation Workflow Processor stores the official copy of this document in the. Documentum. Sappress Official Abap Programming Guideline - Download as PDF File .pdf), Text File .txt) or read online.
|Language:||English, Spanish, French|
|Genre:||Health & Fitness|
|ePub File Size:||23.54 MB|
|PDF File Size:||18.24 MB|
|Distribution:||Free* [*Sign up for free]|
The official ABAP programming guidelines provide clarity and security by PDF ( 9 MB), EPUB (4 MB), and MOBI file (9 MB) for download, DRM-free with. Official ABAP™ Programming Guidelines. Bonn Boston . Which Guidelines Are Involved Here? ABAP Objects as a Programming Model. The official ABAP Programming Guidelines were presented at TechEd in The compliance with these guidelines should be a given for a.
Multiple commands can be on one line; however, as a standard start each new command on a new line. This will allow for easier deleting, commenting, and debugging. Event keywords are typically not indented. GET table. AT NEW f1. CASE F1. Whenever possible, the LIKE parameter should be used to define work fields.
All processing blocks are supported except for the reporting event blocks and function mod- ules. Only methods are possible as processing blocks. You can create a function group using the Function Builder. Processing blocks and classical dynpros or selection screens are not pos- sible. EE Module pool A module pool can contain all possible declarative statements. All processing blocks are supported except for the reporting event blocks.
You can call their function modules. It supports classical dynpros as well as selection screens and can be executed both using the SUBMIT statement and transaction codes. EE Interface pool An interface pool can only contain the declarative statements for a global inter- face. EE Function group function pool A function group can contain all types of declarative statements. It supports classical dynpros as well as selection screens.
The possible program types in ABAP are as follows: EE Executable program An executable program can contain all possible declarative statements.
All pro- cessing blocks are possible except for function modules. EE Type group type pool A type group can contain the declarative statements. Pro- cessing blocks and classical dynpros or selection screens are not possible. The program flow within the standalone program execution depends on the selected program type and the type of the program call: EE In a program call via a transaction.
You can call the subroutines. In ABAP. Source Code Organization. For object-oriented transactions. You cannot call or execute a type group. EE Subroutine pool A subroutine pool can contain all possible declarative statements.
Section 4. In addition to the mentioned compilation units. EE Standalone program execution In the standalone program execution. EE Called program execution In the called program execution. Section 6. Internal and External Procedure Calls. Select the Appropriate Program Type To select the program type. Dialog transactions. EE For the implementation of completed functionality that is not supposed to be dis- played in the class library.
You must select the program type taking into account the technical attributes of a program mentioned here and the requirements on the program execution.
EE If an execution is required within the scope of a background processing. EE No new module pools and type groups are supposed to be created any longer. The following list further describes the specific aspects: Not all mentioned program types can still be used reasonably for new developments.
EE The program type. Details The hierarchy provided in Rule 3. The dialog modules of the function group called by the dynpro flow logic should basically contain method calls only. EE To implement closed functionality that is not supposed to be called via a method call but instead by using a transaction code. EE Programs with a classical dynpro interface or selection screens as far as they should still be required.
This program type is suitable because it can contain both classical dynpros and an external func- tional interface in the form of function modules.
Because subroutines. The implementation will be carried out only via local classes. Subrou- tine pools were — as the name suggests — originally intended for subroutines that were called from other programs. EE For update function modules. Adhere to the SoC Principle.
EE An executable program includes several event blocks that are executed when the various reporting events occur. The implementation of the actual functionality. The call is done either via a method call or an OO transaction if you want a standalone program execution.
For this reason you should not create any new module pools. Executable programs should only be used where they are technically required. The same applied to the global storage of constants. This includes: Note In cases in which you still use program types other than class and interface pools. Declaration of Data Types and Constants. EE The type group program type was initially implemented as a workaround because occasionally it was not possible to define any types for internal tables in the ABAP Dictionary.
The event block of the initial event. In this case. EE The module pool used to be the program type. For this reason. As discussed in Chapter 2. Both gaps have been closed in the meantime. Extended Program Check to implement the same more stringent syntax check for the program components.
Sec- tion 2. Details Different behaviors or check severities are only provided for compatibility reasons to keep existing programs compilable and executable.
New programs should not use obsolete settings by any means. On a Unicode system. Rule Rule 3. EE Logical database For connecting an executable program with a logical database. Unicode programs. Only when the Unicode checks are activated can you ensure that the program can be exe- cuted both in Unicode systems and in non-Unicode systems and that it provides the same results. EE When you create a new program. EE Fixed point arithmetic For considering the decimal separator in operations with packed numbers.
Once the program attributes are set. ABAP Editor. Function Builder. You define the program attributes when you create a program using the corre- sponding tool Class Builder.
Accept the Standard Settings for Program Attributes Set the program attributes for new programs as follows: The programs provided by SAP are usually Unicode programs. This attribute must never be reset. If the calculation is sup- posed to be carried out with packed numbers without any decimal places. For obso- lete or problematic language constructs. Logical databases should no longer be used because they are based on the cross-program use of global data.
The following sections assume that you only work with the activated Unicode check and the fixed point arithmetic and without the logical databases. EE When you create a new executable program. Via this attribute. A logical database includes a hierarchical structure. Particularly for attributes that influence the syntax check currently the Unicode check you should always decide for the highest possible check sever- ity to be well prepared for subsequent. Because a subsequent change to the program attributes potentially involves change- over effort.
You should no longer create new logical databases. If the fixed point arithmetic is deactivated. The activation of the Unicode checks only provides benefits for the developer. Casting of the subarea takes place for the type c. Bad Example Figure 3. A live program must not contain such code by any means. Obsolete Language Constructs.
Accept the Standard Settings for Program Attributes. The result in the components depends on the alignment gaps. They are only mentioned briefly within the list of the obsolete language elements see Appendix A.
Figure 3. This usually results in erroneous data or runtime errors that are difficult to reproduce. Accept the Stan- dard Settings for Program Attributes. If it is possible to statically determine them. Unwanted subfield accesses are prohibited just like any other unwanted accesses to structures or other parts of the working memory. EE In case of a multilingual staff assignment of the development groups. All texts of the development object.
EE the original language of all development objects is either a language that all people involved understand. EE In case of a unilingual staff assignment of all development groups that partici- pate in a project.
EE or the original language of the development objects in individual parts of the project is based on the native language of the developers that mainly work on these parts multilingual development. The creation of the texts in other languages is implemented in a translation process.
This is done implicitly using the current logon language. Details When you determine the original language.
Developers may create their development objects only in the original language determined for the respective project or for a subproject in exceptional cases. The first reason usually out- weighs so that a unilingual development must be implemented in international development to use the development resources of a project as effectively as possi- ble. In individual cases.
In multilingual development groups. The translation is usually carried out in a down- stream translation system and then transported back into the development sys- tem.
This original language then enables all persons involved in the development and validation process to use the product at least for testing. The two possible settings for multilingual developer groups — unilingual or multilingual development — meet two different require- ments. EE Usually. In case of a unilingual development in multilingual development groups. EE When a user logs on to a system in a language different from the original lan- guage. The latter is the reason why English is not claimed as the comprehensive uniform original language of all development projects.
This means. On the other hand. Further developments of the ABAP language are either extensions of the existing language attributes to implement new functionality or to replace existing functionality with more advanced concepts. SAP has committed itself to a policy of strict downward compatibility. In addition.
Since the implementation of ABAP some 30 years ago. The replacement of existing language elements with new ones usually makes the existing language elements superfluous or obsolete. In a multilingual development. Correctness and Quality. Table contents should also be created in a uniform language. With regard to the ABAP language.
Note Irrespective of whether you implement a unilingual or multilingual development with a project. Tip Because the original language is determined by the logon language when a reposi- tory object is created. Obsolete lan- guage elements are only provided for downward compatibility reasons. Modern ABAP 3.
Appendix A. It is also recommended to incrementally change over to newer concepts as they are available.
For this reason among others. If in doubt. To remedy these problems.
For this purpose. A state- ment or statement addition is declared as obsolete only when a more powerful alternative exists or when the language element is determined as prone to errors in the sense that it invites insecure and nonrobust programming. The only exception is the changeover to Uni- code systems for which the ABAP programs must be converted into Unicode programs with slightly changed syntax rules. Details Newer language elements are always the better language elements. A pro- cedure is supposed to replace all occurrences of a substring in a text with a new character string new if the substring is not at the end of a word.
Further- more. Good Example Listing 3. By using FIND in connection with a regular expression. You should rather use the opportunity and directly change the entire procedure to the corresponding new language elements. By covering the procedures to be changed with module tests. This section now particularly discusses the syntactic correctness of ABAP programs.
There is only one area in which this is clearly syntactically defined. Checks for Correctness 3. EE As soon as a syntax error occurs. In this context.
Note In connection with Rule 3. Classical and Class-Based Exceptions in processing blocks. In many cases. Restrict the Nesting Depth of Control Structures. The severity of the ABAP syntax check is determined by the decisions that were made when the program was created see Section 3. As a result. Programs with syntax errors can be activated. In the extended program check.
EE Priority 2 This priority refers to all constructs that do not necessarily lead to error behavior but are obsolete and supposed to be replaced with current con- structs. EE If a syntax warning occurs.
The warnings notified by the syntax check are subdivided into three priorities that are only displayed by the extended program check. This priority also contains all constructs that should not be used at all because they suggest program errors and very likely lead to incor- rect behavior. Errors of priority 2 can become errors of priority 1 or syntax errors in future releases. EE Priority 3 Summarizes all errors whose correction is desirable. The syntax warnings are displayed in the ABAP Editor after an execution of the syntax check and the extended program check see Section 3.
Who should know better than the makers themselves how the ABAP language is supposed to be used and where possible pitfalls are hidden? You can therefore be assured that these programming guidelines are based on profound detailed technical knowledge of the ABAP language and the associated development tools as well as on the broad experience in the development and maintenance of comprehensive ABAP applications. But what are programming guidelines? It is indisputable that there are advantageous and less advantageous programming practices.
The general goal of programming guidelines is to promote the advanta- geous practices and force back the disadvantageous ones. Interestingly enough, many developers, and perhaps even more project leads and IT managers, think of naming conventions when they hear the term program- ming guidelines.
But programming guidelines are not just naming rules which are sometimes rightly considered random. In fact, they also provide rules for the program structure and modularization and for the use of problematic or obsolete language constructs among other things. For this reason, programming guidelines Personal Copy for Raul Garcia, user id fbbc8-b1bc-bd4f6ef6b 17 1 Introduction inevitably consist of two different components: specifications on the program- ming style, which are language-independent to a large extent, and specifications on the use or prevention of certain language constructs that strongly depend on the programming language.
Guidelines on the programming style are based on the knowledge that source code must be read and understood again and again by different persons during the software lifecycle.
It should therefore be designed in such a way that the human reader can comprehend it easily and quickly, even if this is completely irrelevant for the processing by the computer.
There are numerous scientific studies on the human-readable design of source codes whose results are summarized in various books, for instance, in Code Complete Microsoft Press, An important aspect when reading source code is the recognition value.
For this reason, the programming guidelines are used to ensure uniform source code stan- dards within a project or an entire organization. Such uniform standards facilitate the collaboration of multiple developers of a piece of software, the transfer of development or maintenance responsibility to other persons, or the involvement of third parties, for instance, within the scope of code reviews.
In general, the meaning of such uniform standards increases with the number of persons that participate in a software project.
But also the individual developer, who maintains and further develops his own programs in the long term, can achieve higher efficiency and program quality by adhering to advantageous programming practices.
The main problem of programming guidelines is often that they are too compre- hensive and possibly too difficult to understand so that a developer cannot know them all by heart.
We try to motivate the individual rules established here and to illustrate them in examples wherever reasonable so that they can be memorized more easily and always retraced. For the rules on the programming style, we focus on the basic aspects that are really helpful from our point of view. Programming guidelines are aimed at increasing the productivity in development and maintenance.
So, the guidelines in this book are aimed at being reasonable but not dogmatic, profound but not fundamentalist. The compli- ance with these guidelines should be a given for a developer and not understood as a formalistic necessity.
In software development, there are many aspects that must be considered if the product is to comply with professional requirements and possible legal require- ments. Such aspects include, for example, usability, documentation, throughput, response time behavior, functional correctness, and so on.
In each development organization, there will be corresponding product standards for these aspects to consistently ensure the quality of the software product. The ABAP guidelines pre- sented in this book are deliberately limited to such partial aspects that are directly linked with the use of the ABAP programming language.
These are recommenda- tions and specifications that are supposed to ensure that the ABAP code is compre- hensible, is understandable, and reliably carries out the tasks that the developers intended. So in these partial aspects, the ABAP programming guidelines support the different product standards or are derived from them. The remaining partial aspects that are also critical but not directly associated with the use of the ABAP programming language are not discussed in this book.
ABAP is a living pro- gramming language that is continuously further developed. In this ongoing devel- opment, great importance is attached to downward compatibility in order to not invalidate the large number of custom developments of SAP customers.