ABAP Syntax

Preface – This post is part of the ABAP Beginner series.

Mandatory ABAP Syntax for Every Coder

The following ABAP syntax is mandatory for every coder:

  1. ABAP is not a case sensitive language (It is case sensitive in the case of field name being passed in the function module).
  2. Every program must start with a keyword.
  3. Each program must end with a period (.)
  4. Every chained statement must have a single keyword followed by a colon (:) and the individual statement followed by a comma (,).
    Example:
    DATA :LV_PLAYER(10) TYPE c,

LV_SCORE (100) TYPE n,

LV_WICKET (10) TYPE n.

  1. To make the entire line comment use an asterisk (*) mark at the beginning of the statement.
  2. To make a comment after a statement in the same line, use a double inverted comma (“) before the comment.
  3. Use PRETTY PRINTER to provide indentation to your codes and make them readable for testers
  4. Nomenclature: Use the following prefixes before given types of fields
Prefix Field Name
LWA Local Work Area
GWA/WA Global Work Area
LTY Local Structure
LT Local Internal Table
GT Global Internal Table
IT/ITAB Internal Table
V Variable
C Contant
ZRP Custom Report Program
ZCL Custom Class
LV Local Variable

 

[Note: Use underscores (_) after using prefixes]
  1. ABAP codes are whitespace sensitive.
    Example: a = b+c(d) and a = b + c ( d ) have different meanings. The first one c(d), will give ‘c’ of length ‘d’. The second one will call function ‘c’ with parameter ‘d’.
  2. In the ABAP custom field, i.e. custom reports, custom data element, custom domain always starts with ’Z’. It means everything we are going to create will be custom and not standard (SAP creates standard ones). So, they will start with ‘Z’ or ‘Y’.

Example: ZBarry_Allen might be my report name

 

  1. ABAP provides both statements based syntax as well as the expression-based syntax
    Example:

    1. ADD Tax to Total.
    2. Total = Total + Tax.

Both will give the same output.

Author

  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.