Register Login

ABAP Programming & Coding Standards

Updated Jun 16, 2018

This document is a compilation of possible ABAP programming and efficiency standards and will provide guidance in creating readable, maintainable code. It is intended for all developers in the SAP R/3 Implementation Project Diamond at Novartis, USA.

The ABAP language is an “event driven”, “top-down” programming language. The ABAP processor controls the execution of an event. For example, the event AT SELECTION-SCREEN is executed when the user presses ENTER on the selection screen and the event START-OF-SELECTION is executed when the user executes the program. As the ABAP language incorporates many “event” keywords, it is necessary to implement in-house ABAP coding standards to create consistent and efficient maintainable code.

As a standard, The Object Browser should be used for all development in the SAP system.
A Source Code Change Process should be in place and adhered to prior to making changes to production ABAP programs and SAP source code.
The reader is also referred to the section dealing with the Naming standards required by this project when dealing with the CTS (Correction and Transport System), this is contained within the Appendix of this document.

1.   Document Revision History...........1

2. Introduction ..........................................2
3.     General Programming Standards ...........3
3.1   Naming Conventions of ABAP Developments ..........3
3.1.1    Internal data declaration........................................4
3.1.2    Development Classes...........................................4
3.1.3    Function Groups .................................................5
3.1.4    Functions Modules .............................................5
3.1.5    Functions Modules Tables Declaration ....................6
3.1.6    Layout Sets...........................................................6
3.1.7 Standard Text..........................................................6
3.1.8    Messages ............................................................6
3.1.10      Lock Object ....................................................7
3.1.11       Transaction Codes .........................................7
3.1.12      Using Logical File Names ...............................7
3.2       Program Attributes ..........................................11
3.2.1    Title ................................................................11
3.2.2    Type ..................................................................11
3.2.3    Status................................................................ 12
3.2.4    Application ........................................................12
3.2.5    Authorization Group ...........................................12
3.2.6    Logical Database ................................................12
3.2.7    From Application ....................................................12
3.2.8    Screen ..............................................................13
3.2.9    Editor Lock ...........................................................13
3.2.10      Fixed Point Arithmetic. ........................................13
3.2.11      Start via Variant......................................................13
3.3        Update programs, Comments, Formatting,.....................13
Structure.................................................................................13
3.3.1    Update programs .......................................................13
3.3.2    Comments ................................................................13
3.3.3    Formatting .............................................................15
3.3.3.1      Forms .............................................................15
3.3.3.2      Text Elements ................................................16
3.3.4    ABAP Coding Structure .....................................17
3.3.5    Module Program Structure ...................................18
3.3.5.1      Screen Flow Logic ............................................18
3.3.5.2      Screens and Screen Style Standards ....................19
3.3.5.2.1    Menu Standards ................................................20
3.3.5.2.2    Tabstrips in SAP Release 4.X ..............................21
3.3.5.3      Locking and Unlocking in Dialog/Interface Programs.........22
3.3.5.4      Database Update Techniques ...........................................23
3.3.5.5      GUI Status ......................................................................24
3.3.5.6      Back, Exit and Cancel Navigation .....................................24
3.3.5.7      Messages ........................................................................26
3.3.5.8      Validations and Data Volumes in Dialog Programs................28
3.3.5.9   Program call through a Function Module .................................28
3.4       ALV Reports .............................................................................29
3.5       Core Modifications .........................................................................30
3.6       Creation of additional tabs in SAP Standard Programs with Tab-strips......31
3.7       Smart Forms .......................................................................................31
4.     ABAP Internal Names .............................................................................33
4.1       Data Types .........................................................................................33
4.2       Data Fields ............................................................................................33
4.3       Abbreviations ......................................................................................34
4.4       Standard Header and Footer ..................................................................34
5.     ABAP DICTIONARY .............................................................................36
5.1       Tables ................................................................................................36
5.1.1    Transparent Tables .............................................................................36
5.1.2    Views ..................................................................................................36
5.1.3    Index ..................................................................................................36
5.2       Structures ...........................................................................................37
5.3       Data Elements ....................................................................................38
5.4       Domains ...........................................................................................38
5.5       Search Helps – SAP Release 4.X (replaces matchcodes) .......................38
5.6       Table Buffering .................................................................................39
5.7       Data Type Conversion ........................................................................39
6.     ABAP CODING TECHNIQUES .............................................................42
6.1       INTERNAL TABLES ..........................................................................42
6.1.1    Filling an Internal Table ........................................................................42
6.1.1.1      Select Into ......................................................................................42
6.1.1.2      Append ............................................................................................43
6.1.1.3      Insert .............................................................................................44
6.1.2    Retrieving from an Internal Table .........................................................44
6.1.2.1      Read Table ....................................................................................44
6.1.2.2      LOOP ...........................................................................................44
6.1.2.3      Nested Loops ................................................................................45
6.1.2.4      Events inside the LOOP. ..............................................................46
6.1.3    Modifying an Internal Table ................................................................46
6.1.3.1      Collect ..........................................................................................46
6.1.3.2      Modify ...........................................................................................47
6.1.3.3      Delete ....................................................................................47
6.1.4    Sorting Internal Tables .........................................................................48
6.1.5    General Internal Table Techniques ....................................................49
6.1.5.1      DESCRIBE ...............................................................................49
6.1.5.2      RANGES ..................................................................................49
6.1.5.3      Miscellaneous ...........................................................................50
6.1.6    FIELD GROUPS ..........................................................................51
6.1.7    Generation of Error Log from a Dialog Program ..............................51
6.1.8    Display of Traffic Lights ...................................................................52
6.1.9    Generation of Sequence Numbers ......................................................53
6.1.10      Use of Packed Numbers .............................................................54
6.1.11      Adding Leading Zeros ...............................................................54
6.1.12      Handling Dates in BDC Session ....................................................55
6.1.13      IF Comparison ........................................................................55
6.2       Internal Tables - SAP Release 4.x .................................................55
6.2.1    Memory Allocation for Internal Tables in SAP 4.x ...............................56
6.3       Code to add Function Key to Reports..................................................57
6.4        Logical Database.................................................................................57
6.4       Subroutines ........................................................................................59
6.4.1    Forms ............................................................................................59
6.4.2    Includes .........................................................................................60
6.4.3    Function Modules ..........................................................................60
6.4.4    Submit, Call, Leave To .....................................................................61
6.5       SQL ................................................................................................62
6.5.1    ABAP Open SQL ..............................................................................62
6.5.1.1      Data Selection from Transparent and Pool Tables ............................63
6.5.1.2      Data Selection from Cluster Tables ...................................................63
6.5.1.3      SELECT Aggregates .......................................................................64
6.5.1.4      SELECT with BUFFER support. ......................................................65
6.5.1.5      Group Level Data Access ..................................................................65
6.5.1.6      Column Update ...............................................................................66
6.5.1.7      Filling Internal Tables. ....................................................................66
6.5.1.8      UP TO nn ROWS ......................................................................67
6.5.1.9      ABAP Open SQL Enhancements – SAP Release 4.x ..........................67
6.5.1.9.1    Inner Join .........................................................................................67
6.5.1.9.2    Left Outer Join ..................................................................................68
6.5.1.10       Catch / Endcatch .....................................................................68
6.5.2    Native SQL .........................................................................................69
6.6       String Manipulation ...................................................................................69
6.6.1    CONCATENATE ....................................................................................69
6.6.2    Removing Leading Spaces ......................................................................70
6.6.3    SPLIT ...................................................................................................71
6.6.4    STRLEN ...............................................................................................71
6.7       FIELD-SYMBOLS .............................................................................72
6.8       General Statements ...............................................................................73
6.9       SAP Release 4.0X Object Oriented Programming ........................................74
7.     Hints and Tips .................................................................................................76

Appendix ..................................................................................................................I
1/ Conversion Process ...............................................................................................I
1.     Building Conversion Programs ............................................................................I
1.1       File Upload ..................................................................................................I
1.2       File Transfer ..................................................................................................I
1.3       Text file for .CSV File ..................................................................................II
2.     Conversion Reporting .....................................................................................II
3.     BDC Sessions vs. Call Transactions ..............................................................III
4.     Conversion Testing .........................................................................................III
2/ EDI Modifications ...........................................................................................IV
3/ Correction and Transport System (CTS) Naming Standards ....................................V
1.     Introduction .................................................................................................V
2.     Standard Outline........................................................................................V
4/ SAP Standard Conversion Programs....................................................................V


 Download attached file.

You must be Logged in to download this file

×