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” –
Navigate to “SAP menuToolsABAP WorkbenchDevelopmentSE38 -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.
Next, a dialog called “ABAP: Program Attributes” gets opened like below.
Fill all the information and click on “Save” button to proceed.
“Create Object Directory Entry” dialog gets opened.
Select the package($TCTMP) and click on “Local Object” or “Save” button to open ABAP Editor.
Now the ABAP Editor opened for the program ZNEWPROG99 like below.
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.
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 and proceed further.
Check for Syntactical errors –
To check the program for syntactical errors, press (Ctrl + F2) or click on the “Check” icon () 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.
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.
Activate the object –
Once the program is syntactically correct, activate the object by pressing (Ctrl + F3) or the “Activate” icon () on application toolbar.
Once the program successfully activated, the status bar displays the message –
Execute the object –
Step-5: Once the object is activated, execute the object by pressing “F8” and click on “Direct Processing” icon () to display the output like below.
The output of ZNEWPROG99 is highlighted on the screen.
ABAP Editor toolbar functions –
Below are the list of Standard toolbar and Application toolbar functions.