ABAP Tips and Tricks #3: Programming Tips

  1. When one uses the MOVE statement, try keep the destination operands as the same data type as the ‘from’ operands.
  2. Use the FREE <table> command once the program has completed using the table. If the program ends on completion of the table processing, this is obviously not required eventhough SAP has a robust garbage collection in place.
  3. When defining DATA statements only define variable required throughout the program as global (i.e. at the top of the program). If variables are only required for processing within a FORM/ METHODS, then define the variable within the FORM/METHODS itself.
  4. When using the SORT statement, always specify the sort key. Try keep the key as short as possible.
  5. When processing an internal table use the LOOP instead of an SQL select  statement. When using the LOOP statement use the LOOP…AT…WHERE instead of a LOOP…AT…CHECK and if possible use parallel cursors inside loops.
  6. When the LOOP…AT…WHERE is used ensure the condition variables have been defined with the same data type.
  7. Use the BINARY SEARCH, when performing an direct read on an internal table.
  8. Use a BINARY SEARCH read and MODIFY instead of COLLECT if the internal table is large.
  9. Use the CASE statement instead of a nested IF.
  10. Beautify the program, use pretty printer.
Comments