Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

ABAP Programming Best Practices

$
0
0

ABAP Programming Best Practices

 

Contents

Introduction

Top 10 Rules

Maintainability Rules

Stability Rules


1.     Introduction

 

 

               This document is intended to cover the basics of good ABAP programming for ABAP developers and ABAP learners. In a normal SAP environment we use ABAP to write a code for doing a look-up in transformation or to code function modules to extract data from source systems. This process would generally involve declarations, selection of data, read the selected data to manipulate it or to perform calculations. I have taken into consideration only these basic steps for this document.

 

2.     Top 10 Rules

 

     Rule 1: Use the Code Inspector (CI), the Extended Syntax Check (if code inspector is not available) or ABAP Test Cockpit (ATC) and fix all errors and warnings – respectively P1 and P2 for ATC.

    

     Rule 2: Use the TRY / ENDTRY instead of CATCH / ENDCATCH statement to trap runtime errors and handle them.

    

     Rule 3: Always handle all exceptions of a function module or method call. If the function module/method actually issues messages, handle the exceptions with the default message statement. Otherwise handle them with your own error messages.


      Rule 4: Always check for the deletion flag on key master data tables. LOEVM, LOEKZ, LVORM, etc are some of the Deletion flags.


      Rule 5: Check the return code after every statement that updates it. Check with SY-SUBRC only.

 

      Rule 6: Internal tables must be defined with the appropriate table type based on usage (HASHED, SORTED or STANDARD).


      Rule 7: When using the FOR ALL ENTRIES option in an SQL WHERE clause, you must ensure that the internal table used in the FOR ALL ENTRIES option is not empty, immediately before the SQL statement.

 

      Rule 8: Alway apply lock to a tables before issuing update commands.


      Rule 9: Use Join conditions instead of SELECT....INTO itab with subsequent SELECT.....FOR ALL ENTRIES IN itab, except for buffered tables.


      Rule 10: Don't use INSERT, UPDATE, etc. within loops.


3.     Maintainability Rules

                         The Maintainability Rules are available in the following document: ABAP Programming Best Practices: Part-II

4.     Stability Rules

                         The Stability Rules are available in the following document: ABAP Programming Best Practices: Part-III

 

 

Note: I will keep updating this document based on further corrections/suggestions.



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>