Before proceed, let us see some of ABAP guidelines for writing a program.

Guidelines to remember while writing the programs -

  • ABAP doesn’t care about the statement in which column the actual statement starts.
  • ABAP can recognize the statements even though if multiple statements are coded in a single line.
  • ABAP Editor convert all text strings except the strings which are surrounded by single quotes.

Writing a simple program -

As discussed in the previous topics, SAP ABAP has a dedicated editor to create new programs. We need to open ABAP editor by using transactions SE38 or SE80 to start writing the new program.

The below are the steps for the whole process of opening editor to executing the program -

  • Open ABAP Editor
  • Add the code and Save Program
  • Check for Syntactical Errors
  • Activate the Object
  • Execute the Object

Let us discuss the above process step by step.

Open ABAP Editor -

We have already discussed ABAP Editors topic in the Basic Screen Navigation . For this example, we use "Simple ABAP Editor (SE38)" and the editor can be opened in below two ways from SAP Easy Access screen.

Type SE38 on the command field of "SAP Easy Access Screen" -

Open ABAP Editor

Navigate to "SAP menu Tools ABAP Workbench Development SE38 -ABAP Editor"

Open ABAP Editor

From the above two ways, the below ABAP Editor: Initial Screen gets opened. Enter the program name, select the subobjects and click on "Create" button to navigate next screen.

  • Program Name - Enter the new program name (For example - ZNEWPROG99).

    Important Note! The preceding "Z" is require to ensure that the report resides in the customer namespace. The customer namespace includes all objects with the prefix "Y" or "Z". "Y" or "Z" should always prefixed to the program names to differentiate the object with system objects and to prevent object name conflicts.
  • Subobjects - Select the subobject based on the type that are going to create in the editor.
Open ABAP Editor

Next, a dialog called "ABAP: Program Attributes" gets opened like below. Open ABAP Editor

Fill all the information and click on "Save" button to proceed.

Open ABAP Editor

"Create Object Directory Entry" dialog gets opened.

Open ABAP Editor

Select the package($TCTMP) and click on "Local Object" or "Save" button to open ABAP Editor.

Open ABAP Editor

Now the ABAP Editor opened for the program ZNEWPROG99 like below.

Open ABAP Editor

Add the code & Save Program -

In this first program we are trying to display "Hello world, Welcome to TutorialsCampus..!". So add the Write statement with it.

Add code and save program

Once the code added, click on "Save" button on the "Standard toolbar" or press (Ctrl + S) to save the program. Check the status bar for the status Add code and save program and proceed further.

Check for Syntactical errors -

To check the program for syntactical errors, press (Ctrl + F2) or click on the "Check" icon (Check for syntactical errors) on Application toobar.

In the above example, we have intentionally missed a period(.) at the end of Write statement . So we got the errors for the same like below.

Check for syntactical errors

Add a period at the end of the write statement and check (Ctrl + F2) again. When no errors, then status bar gets displayed like below.

Check for syntactical errors

Activate the object -

Once the program is syntactically correct, activate the object by pressing (Ctrl + F3) or the "Activate" icon (Activate Object) on application toolbar.

Activate Object

Note! Sometimes, it opens a dailog with all inactivated programs if any inactive program existed. Select from the list and Click on "Continue" icon to activate.
Activate Object

Once the program successfully activated, the status bar displays the message - Activate Object

Execute the object -

Step-5: Once the object is activated, execute the object by pressing "F8" and click on "Direct Processing" icon (Direct Processing) to display the output like below.

Direct Processing

The output of ZNEWPROG99 is highlighted on the screen.

ABAP Editor toolbar functions -

Below are the list of Standard toolbar and Application toolbar functions.

ABAP Editor Toorbar Functions