This document is the final version of the ABAP Programming Standards and Guidelines that will be utilized by application developers. It has been signed off by NASA and will also be delivered as part of the Application Development Team’s final deliverable. Following this document is the superseded version that was developed by the Technical Architecture Team and signed off by the NASA.
Table of Contents
Table of Contents..................................................................................................................... 3
1 Overview............................................................................................................................. 8
2 General Standards........................................................................................................... 8
3 ABAP Program Elements............................................................................................... 9
3.1 Attributes....................................................................................................................... 9
3.1.1 Title................................................................................................................................. 9
3.1.2 Type................................................................................................................................ 9
3.1.3 Status............................................................................................................................. 9
3.1.4 Application.................................................................................................................... 10
3.1.5 Authorization Group.................................................................................................... 10
3.1.6 Development Class................................................................................................... 10
3.1.7 Logical Database....................................................................................................... 10
3.1.8 Screen........................................................................................................................... 10
3.1.9 Editor Lock.................................................................................................................... 10
3.1.10 Fixed Point Arithmetic............................................................................................. 10
3.1.11 Start via Variant......................................................................................................... 11
3.2 Source Code.................................................................................................................. 11
3.2.1 General Programming Requirements..................................................................... 11
3.2.1.1 Authorization Checking.......................................................................................... 11
3.2.2 Executable Programs: (Template Y_EXECUTABLE_PROGRAM)....................... 11
3.2.3 INCLUDE Programs:................................................................................................... 13
3.2.4 Module Pool Programs:.............................................................................................. 14
3.2.5 Function Pool (Group) Programs:............................................................................. 15
3.2.6 Function Module Programs:....................................................................................... 15
3.2.7 Subroutine Pool Programs:........................................................................................ 16
3.2.8 Class Pool Programs:................................................................................................. 17
3.2.9 Interface Pool Programs:............................................................................................ 17
3.3 Documentation.............................................................................................................. 17
3.3.1 Program Documentation:............................................................................................17
3.3.1.1 Class Pool Documentation.................................................................................. 18
3.3.1.2 Interface Pool Documentation............................................................................. 18
3.3.2 Changes and Enhancements:................................................................................. 19
3.3.3 User Documentation:................................................................................................. 19
3.4 Text Elements............................................................................................................... 19
3.4.1 Titles and Headings................................................................................................... 19
3.4.2 Selection Texts............................................................................................................. 20
3.4.3 Text-Symbols................................................................................................................ 20
3.5 Variants........................................................................................................................... 20
4 Style Guidelines................................................................................................................ 21
4.1 ABAP Style Guidelines................................................................................................. 21
4.1.1 R/3 Design Elements................................................................................................. 21
4.1.2 Work Area Design Elements.................................................................................... 22
4.2 NASA Style Guidelines................................................................................................ 22
4.2.1 Window Titles............................................................................................................... 22
4.2.2 Selection Screens....................................................................................................... 22
4.2.3 Transaction Screens................................................................................................... 22
4.2.4 Online Help................................................................................................................... 23
4.2.5 Report Titles................................................................................................................. 23
4.2.6 Report Headings and List Format............................................................................ 23
4.2.7 Report Footings........................................................................................................... 23
5 ABAP Programming Advanced Techniques.............................................................. 23
5.1 Message Classes........................................................................................................ 23
5.2 Views.............................................................................................................................. 23
5.3 Internal Tables:............................................................................................................. 24
5.4 Possible Uses Of Internal Tables............................................................................. 24
5.4.1 A Large Number Of Database Accesses Are Foreseen...................................... 24
5.4.2 Replacing Nested Selects......................................................................................... 24
5.5 Performance Concerns: Internal looping vs. Nested selects.......................... 24
5.5.1 The tradeoff................................................................................................................... 25
5.5.2 Methods Of Internal Table Population..................................................................... 25
5.6 Free System Resources............................................................................................. 26
5.7 Field Groups................................................................................................................... 26
5.7.1 INSERT f1 f2 ... INTO fg............................................................................................... 26
5.7.2 Extract .................................................................................................................... 27
5.7.3 Field Group Processing............................................................................................. 27
5.7.4 Sample of Field Group usage in a program:......................................................... 27
5.8 General Use Function Modules................................................................................ 28
5.8.1 Date Oriented Function Modules:............................................................................ 28
5.9 Logical Database:....................................................................................................... 29
5.10 Use of Indices:............................................................................................................. 29
6 Customer Enhancements – Enhancement Projects............................................. 29
7 Changing SAP Code....................................................................................................... 30
8 APPENDIX A: Programming Guidelines..................................................................... 31
8.1 Writing Maintainable Code....................................................................................... 31
8.1.1 Program Structure...................................................................................................... 31
8.1.2 Modularization............................................................................................................. 32
8.1.3 Statement Format....................................................................................................... 32
8.1.4 Pre-defined Coding Blocks....................................................................................... 32
8.1.5 Performance Considerations................................................................................... 34
8.1.6 Version Management................................................................................................. 34
8.1.7 DEFINING DATA FIELDS AND TABLES................................................................... 34
8.1.8 Field symbols.............................................................................................................. 35
8.1.9 Example Program...................................................................................................... 36
8.2 Using Tables and Fields............................................................................................ 37
8.2.1 Check Return Codes................................................................................................ 37
8.2.2 Initializing Fields and Structures............................................................................ 37
8.2.3 MOVE-CORRESPONDING...................................................................................... 38
8.2.4 SORT............................................................................................................................ 38
8.3 Working with Logical Operators and Control Structures................................ 38
8.4 Performance and Tuning Guidelines..................................................................... 40
8.4.1 Use SORT to organize reports and data............................................................... 40
8.4.2 Defining Custom Tables.......................................................................................... 41
8.4.3 Use of SELECT with Transparent and Pool tables............................................. 41
8.4.4 Use of the SELECT statement with Cluster tables............................................. 42
8.4.5 Matching field attributes in the SELECT WHERE clause................................... 43
8.4.6 Processing Internal Tables and Data Areas........................................................ 44
8.4.7 Processing large tables........................................................................................... 47
8.4.8 General Tips:.............................................................................................................. 47
8.5 SECONDARY INDEXES............................................................................................... 48
8.5.1 Always ensure your index is being used:.............................................................. 48
8.5.2 General Rules for creating and using secondary indexes:............................... 48
8.5.3 When to Create an Index.......................................................................................... 49
8.5.4 When Not to Create an Index:.................................................................................. 50
8.6 Controlling the Development Environment.......................................................... 50
8.6.1 Quality Assurance..................................................................................................... 50
8.6.2 CROSS-REFERENCING A PROGRAM................................................................. 50
8.7 Developer’s Issues for the Transport System.................................................... 52
8.8 Transport Checklist for Developer......................................................................... 52
9 Appendix B: Metrics-Driven Code Comparisons............................................... 55
9.1 SQL Interface............................................................................................................ 55
9.1.1 Select … Where vs. Select + Check...................................................................... 55
9.1.2 Select single vs. Select-Endselect........................................................................ 55
9.1.3 Select aggregates.................................................................................................... 56
9.1.4 Select with view......................................................................................................... 56
9.1.5 Select with buffer support........................................................................................ 56
9.1.6 Column Update......................................................................................................... 57
9.1.7 Select with index support........................................................................................ 57
9.1.8 Select … Into Table t................................................................................................. 57
9.1.9 Select-Endselect vs. Array-Select.......................................................................... 58
9.1.10 Select with select list............................................................................................ 58
9.1.11 Array Insert vs. Single-row Insert....................................................................... 58
9.2 String Manipulation................................................................................................... 58
9.2.1 Special operators in IF (CA, …).............................................................................. 58
9.2.2 String concatenation II............................................................................................. 59
9.2.3 Deleting leading spaces......................................................................................... 59
9.2.4 String concatenation................................................................................................ 60
9.2.5 String split.................................................................................................................. 60
9.2.6 String length.............................................................................................................. 61
9.3 Internal Tables........................................................................................................... 61
9.3.1 Building sorted tables............................................................................................. 61
9.3.2 Building tables without duplicates........................................................................ 61
9.3.3 Different forms of key access................................................................................ 62
9.3.4 Key access to multiple lines.................................................................................. 62
9.3.5 Copying internal tables........................................................................................... 63
9.3.6 Sorting internal tables............................................................................................. 63
9.3.7 Nested loops............................................................................................................. 63
9.3.8 Deleting a sequence of lines................................................................................. 64
9.3.9 Building condensed tables.................................................................................... 64
9.3.10 Linear vs. Binary search..................................................................................... 65
9.3.11 Secondary indices............................................................................................... 65
9.3.12 Using explicit work areas................................................................................... 66
9.3.13 Comparing internal tables................................................................................. 66
9.3.14 Joining internal tables........................................................................................ 67
9.3.15 Deleting duplicates............................................................................................. 67
9.3.16 Deleting a set of lines......................................................................................... 68
9.4 Typing.......................................................................................................................... 68
9.4.1 Typed vs. Untyped parameters........................................................................... 68
9.4.2 Typed vs. Untyped field-symbols........................................................................ 69
9.5 If, Case, …................................................................................................................. 69
9.5.1 If vs. Case................................................................................................................. 69
9.5.2 Case vs. Perform I of …......................................................................................... 70
9.5.3 While vs. Do............................................................................................................. 70
9.6 Field Conversion...................................................................................................... 70
9.6.1 Field Types I and P.................................................................................................. 70
9.6.2 Constants Type F.................................................................................................... 71
9.6.3 Mixed types.............................................................................................................. 71
9.6.4 Literals Type C and Type I..................................................................................... 71
9.6.5 Arithmetic................................................................................................................. 72
10 Appendix C: Tips and Tricks..................................................................................72
10.1 Helpful Hints on Commands:............................................................................... 72
10.2 General Hints:.......................................................................................................... 72
10.3 Programming Tips................................................................................................. 73
11 Appendix D: Quality ABAP Programming.......................................................... 74
11.1 OVERVIEW................................................................................................................ 74
11.2 Technical Principle for Program Optimization................................................ 75
11.3 Database access:................................................................................................... 75
11.3.1 Optimization of individual SQL statements................................................... 75
11.3.2 No unnecessary access................................................................................... 75
11.3.3 Use SAP buffers................................................................................................. 75
11.3.4 No unnecessary sort operations on the database..................................... 75
11.3.5 Optimize matchcodes....................................................................................... 75
11.3.6 Minimize DB lock times................................ ................................................... 75
11.3.7 Avoid deadlock situations................................................................................ 75
11.4 ABAP Programming.............................................................................................. 75
11.4.1 Processing internal tables.............................................................................. 76
11.4.2 Modularization.................................................................................................... 76
11.4.3 Costly language elements.............................................................................. 76
11.5 Analysis tools.......................................................................................................... 76
11.5.1 SQL trace (ST05)............................................................................................... 76
11.5.2 Transaction: SDBE............................................................................................ 76
11.5.3 ABAP trace analysis: SE30............................................................................... 76
11.5.4 Get RUN TIME FIELD f....................................................................................... 77
11.5.5 ABAP cross reference analysis: RSINCL00.................................................. 77
11.6 Note I: Optimization of individual SQL statement............................................ 77
11.7 Note II: Performance & Load Balancing for Batch Input............................... 78
11.7.1 Background of SAP BDC programs............................................................... 78
11.7.2 Where are the bottlenecks ?............................................................................ 78
11.7.3 What can we do to get around the bottlenecks ?......................................... 78
11.8 Note III: ABAP Programming Tips....................................................................... 79
11.8.1 TIP: When one uses the MOVE statement,.................................................. 79
11.8.2 TIP: Use the FREE command.......................................................... 79
11.8.3 TIP: When defining DATA statements............................................................. 80
11.8.4 TIP: When using the SORT statement,.......................................................... 80
11.8.5 TIP: When processing an internal table use the LOOP............................... 80
11.8.6 TIP: When the LOOP...AT...WHERE.................................................................. 80
11.8.7 TIP: Use the BINARY SEARCH,....................................................................... 81
11.8.8 TIP: Use a BINARY SEARCH read and MODIFY............................................ 81
11.8.9 TIP: If one performs many INSERTs or DELETEs........................................ 81
11.8.10 TIP: Use the CASE statement instead of a nested IF.................................. 81
11.8.11 TIP: Always place the mot likely condition first,............................................ 82
11.8.12 Comparison different modularization techniques....................................... 82
11.8.12.1 Internal subroutine........................................................................................ 82
11.8.12.2 External subroutines..................................................................................... 82
11.8.12.3 Function modules......................................................................................... 82
11.8.12.4 Dynpros........................................................................................................... 82
11.8.12.5 Dialog Modules.............................................................................................. 82
11.8.12.6 Transactions................................................................................................... 83
11.8.12.7 Reports............................................................................................................ 83
11.8.12.8 List processing............................................................................................... 83
Download attached file: You must be Loged in to download file