Wednesday, July 25, 2007

Development Guidelines

1.1. General

  • Only one statement per line
  • Use a template for creation of ABAP programs with the standard includes
  • Indent the program for readability

  • Creation of variables
  1. Parameter – P_
  2. Select option – S_
  3. Radio button – RB_
  4. Ranges – R_
  5. Checkbox – PX_
  6. Constants – C_
  7. Counters – N_
  8. Internal tables – IT_
  9. Sorted – IS_
  10. Hashed – IH_
  11. Structure – X_
  12. Flags – FG_
  13. Global variables – G_
  14. Local variables – L_
  15. All literals that are displayed on a report must use Text Elements
  16. Use GUI_UPLOAD and GUI_DOWNLOAD to upload or download data

1.2. Guidelines for Internal tables
  • Read internal table WITH KEY particularly for sorted and hashed
  • Read only the needed fields thru TRANSPORTING
  • Use the BINARY search wherever possible
  • Avoid nested looping
  • Avoid COLLECT statement
  • Specify the sort fields
  • Use COMPARING for deleting duplicate data in the internal tables
  • Do not use index operations while populating sorted tables
  • Do not resort a sorted type of an internal table
  • Index operations cannot be used on hashed tables
  • Do not use OCCURS 0 in the declaration unless less than 8K data is stored.
  • Use CLEAR to initialize the header record
  • Use REFRESH to clear the contents of the internal table. This statement does not clear the header record
  • Use FREE to free the resources used by the internal table

1.3. Optimization

  • Remove all code and variables that are not used in the program
  • Perform the Extended Program Check
  • Use selection criteria to effectively select and limit the number of database reads
  • Select only those columns that are needed – Do not use a SELECT * unless necessary
  • Use aggregate functions wherever required
  • To update table entries, specify the columns
  • Use a SELECT SINGLE if the primary keys are known, otherwise SELECT UPTO 1 ROWS
  • Do not use nested SELECTs – Use views, joins or the FOR ALL ENTRIES option
  • Do not use SELECTs in loops
  • Restrict the database access by using the WHERE clause – do not use a CHECK
  • Use indexes wherever available
  • Avoid NOT in the WHERE condition
  • Do not select the same data more than once
  • To populate an internal table thru a SELECT, use the INTO addition
  • Use sort on the internal table for small amounts of data and database ORDER BY for larger amount

No comments: