Book Excerpt: First Steps in ABAP®


Espresso Tutorials

Fabian Bentz

62Excerpt from First Steps in ABAP by Dr. Boris Rubarth

Reports are a good starting point for familiarizing yourself with general ABAP principles and tools. Although modern user interface features aren’t used, ABAP reports are still used in many areas.

This chapter will show how easy it is to write a simple ABAP Report. With the knowledge provided in this chapter, readers will be able to examine existing ABAP applications delivered by SAP or as part of a customer implementation project.
1.1 Hello ABAP
So let’s get started with the common Hello World example:
WRITE ‘Hello world!’.

Each ABAP statement starts with an ABAP keyword and ends with a period. Keywords must be separated by at least one space. It does not matter whether or not you use one or several lines for an ABAP statement.

Now where should you write this statement – in the text editor of your choice? No, you will need to enter your code using the ABAP Editor, which is part of ABAP Tools delivered with the SAP NetWeaver Application Server ABAP (AS ABAP). No ABAP code can be developed without AS ABAP – but you do not need access to a productive SAP system to start your work. The SAP Developer Network (SDN) offers trial downloads that are a
perfect starting point (http://www.sdn.sap.com/irj/scn/nw-downloads).

1.2 Using the ABAP Editor
Assuming that you are familiar with how to log on to and
navigate in an SAP system, start transaction SE38 to navigate to the ABAP Editor.
The ABAP Editor is the tool used to view or to edit existing code, as well as create new code. Let’s start creating a Report, which is one of several ABAP objects. ABAP Reports

On the initial screen of the editor, specify the name of your report in the input field PROGRAM. Specify the name as ZHELLOWORLD01 as shown in Figure 1.1.

img1

Figure 1.1: Initial screen of the ABAP Editor (transaction SE38)

The preceding Z is important for the name; the Z ensures that your report resides in the Customer Namespace.

You can type the report name in lower case letters, but the editor will change it to upper case – names of ABAP objects are not case sensitive.

After specifying the name of the report, click the CREATE button. (The system will check that another report with that name does not exist.) A popup window ABAP: PROGRAM ATTRIBUTES will pop up and you will provide more information about your report.

First, you will have to provide a title for your report and then specify the report TYPE. For this example, we will select EXECUTABLE PROGRAM as the report type. The title will be visible when we start the report and can be edited later on as well. Let’s title this report “My first ABAP report” as shown in Figure 1.2. Select SAVE to continue.

img2

Figure 1.2: Program attributes for your first report

We aren’t quite finished with attributes yet; the CREATE OBJECT DIRECTORY ENTRY window will pop up next, as shown in Figure 1.3.

img3

Figure 1.3: Creating an object directory entry for your report

Select the button LOCAL OBJECT and the popup will close. We will cover explanations of the object directory and the attribute package in subsequent chapters.

img4

Figure 1.4: Initial code for your first report

Further down, the statement REPORT with the name of your first report is already entered (along with a period terminating the REPORT statement). This REPORT statement must precede each report.

Now you can complete your first report by entering the WRITE statement below the REPORT statement, so that the complete report contains just two (uncommented) lines:
REPORT ZHELLOWORLD01.
WRITE ‘Hello world!’.

Keep reading in First Steps in ABAP for:

  • Step-by-Step Instructions for Beginners
  • Comprehensive Descriptions and Code Examples
  • Guide to Create Your First ABAP Application
  • Various Tutorials Provide Answers for Programming Questions