ABAP Syntax

by | Mar 8, 2018 | ABAP Beginner

Home » SAP » ABAP » ABAP Beginner » 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
PrefixField Name
LWALocal Work Area
GWA/WAGlobal Work Area
LTYLocal Structure
LTLocal Internal Table
GTGlobal Internal Table
IT/ITABInternal Table
VVariable
CContant
ZRPCustom Report Program
ZCLCustom Class
LVLocal 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

0 Comments

Submit a Comment

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.

Author