Steps to create first ABAP Program


ABAP stands for Advanced Business Application Programming. It is SAP’s proprietary programming language and is a 4th generation programming language. Most part of the SAP ERP System including applications is build using ABAP. The ABAP source programs are stored in the database but in executed in the Application server that has the ABAP runtime environment.

ABAP Syntax

  • ABAP Program is collection of individual statements.
  • Every ABAP statement starts with an ABAP keyword and ends with a period.
  • Separate two words with space.
  • ABAP is not case sensitive, but it is recommended to have ABAP keywords and their additions in uppercase and operands in lowercase.

Features of ABAP Programming language

  • supports type conversions and type casting
  • it enables multi-language applications ( using text elements )
  • Open SQL is embedded into ABAP for direct database access
  • ABAP started as a procedural programming language and later enhanced to Object-oriented programming language
  • ABAP is platform-independent
  • It is upward-compatible

SAP ABAP Pretty Printer

  • You need not format ABAP statements manually, but make use of Pretty Printer function. Customize Pretty Printer settings Utilities -> Settings -> ABAP Editor -> Pretty Printer. It will take care of Indent as well as case.
  • 
This image has an empty alt attribute; its file name is sap-abap-online-course-12.jpg

We use ABAP Editor TCode – SE38, to create ABAP Programs. ABAP Editor is part of ABAP Workbench tools (we will discuss ABAP Workbench in later lesson).

Create your first ABAP Program

Customer Namespace

Name of any custom development in SAP, should start with Y or Z. This is known as customer namespace.

Execute Tcode – SE38

Enter program name ZAMARMN_HELLO and click Create. The name of an ABAP program can be maximum 30 characters.

This image has an empty alt attribute; its file name is sap-abap-online-course-9.jpg

In the dialog box, enter Title – First ABAP Program, choose Type – Executable Program, and click Save.

This image has an empty alt attribute; its file name is sap-abap-online-course-10.jpg

In the next window, it asks to enter package, but since we have not created a package, click on Local Object. We will discuss about package and local object in a later lesson.

This image has an empty alt attribute; its file name is sap-abap-online-course-11.jpg
Write the ABAP Code. Click Pretty Printer, Save, check for any Syntax, and Activate the code. Activating the program generates a runtime object for the program for later execution.
This image has an empty alt attribute; its file name is sap-abap-online-course-13.jpg

Click Execute to execute the program. Enter you name in p_name field and click execute to see the output.

This image has an empty alt attribute; its file name is sap-abap-online-course-14.jpg

Comments in ABAP

Lines that begin with an asterisk (*) in the first column are recognized as comment lines by the ABAP runtime system and are ignored.
A double quotation mark (“) indicates that the rest of a line is a comment.

Combination of Statements with Colon operator

It is good practice to combine statements starting with same keyword into a chained statement. It’s a simplified syntax.

  • Add a colon after the keyword
  • Separate the statements with a comma instead of a period
  • The last statement ends with a period.

In the above code the two statements WRITE ‘Hello’ and WRITE p_name can be chained.

REPORT zamarmn_hello.PARAMETERS p_name TYPE c LENGTH 30.WRITE 'Welcome to ABAP.'.NEW-LINE.* this is comment - applying chain operatorWRITE : 'Hello',         p_name.

Access to standard documentation for ABAP keyword

Place the cursor on keyword and press F1 help to open SAP documentation for the ABAP keyword. This will be very useful when you want to explore additions of a keyword.