Skip to Content
Author's profile photo Former Member

ABAP Coding Standards – (As chosen by Neal Wilhite)

General Coding Standards:  (Please note, If I have taken the standard from another source, it’s source will be referenced by a link back to the source in [].

  • Each ABAP/4 command consists of a sentence ending with a period. Multiple commands can be on one line; however, as a standard start each new command on a new line. This will allow for easier deleting, commenting, and debugging. [ http://web.mit.edu/fss/dev/newdevstand.html ]
    • Bad:
      • IF t_subrc IS INITIAL.  CLOSE DATASET t_mfile.  ENDIF.
    • Better:
      • IF t_subrc IS INITIAL. 

      •   CLOSE DATASET t_mfile. 

      • ENDIF.

  • Many ABAP statements have multiple parameter phrases that can run over multiple lines.  It is legal to divide these across lines at the end of any word.  For reading clarity, we will divide (where possible so that a parameter phrase is not broken across lines.
    • Bad:
      • OPEN DATASET t_mfile FOR INPUT IN TEXT MODE ENCODING

      •           DEFAULT WITH WINDOWS LINEFEED.

    • Better:
      • OPEN DATASET t_mfile FOR INPUT

      •      IN TEXT MODE ENCODING DEFAULT

      •      WITH WINDOWS LINEFEED.

Assigned tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Frédéric Girod
      Frédéric Girod

      Hi Neal,

      good beginning !

      Fred

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Frédéric,

      It's a work in progress.  I'll try to make the rest of the additions in much bigger hunks so you guys won't have to suffer through it.

      Neal

      Author's profile photo Frédéric Girod
      Frédéric Girod

      Before, I thought I'm a fanatic about good coding ...  now I know I'm not alone 😉

      I'm really agree about your document, I go deeper and I ask people to align SELECT statement, WRITE statement ...   More regular the code is, easier it is to maintain.

      Author's profile photo Steffi Warnecke
      Steffi Warnecke

      And to read!

      The horror of nested IF / ELSE / ELSEIF / ENDIF-statements that are written as a block one long line after another with no logical breaks for my poor eyes and brain.

      I like this, Neal. Good idea with the good/bad examples, that always helps understanding a lot. I'm looking forward to more of this. 🙂

      Author's profile photo Former Member
      Former Member

      I see that you are focusing on readability.

      Readability can be improved by:

      1. Line breaks
      2. Indentation
      3. Uppercase/lowercase

      Your examples cover the case of missing line-breaks, and these are the cases that Pretty Printer does not touch.

      A script can be written that inserts/deletes line-breaks as per your standards, and then rest can be taken care of by Pretty Printer.