Skip to Content
Previous

Create and run an ABAP application

By olgadolinskaja

Create and run an ABAP application based on tables from the sample EPM data model.

You will learn

In this tutorial you will learn how to create and run an ABAP application based on tables of the SAP NetWeaver Demo sample EPM Model (details in the SAP Community The SAP NetWeaver Enterprise Procurement Model – An Introduction. So you can reiterate the tutorial on any SAP NetWeaver 7.5 system.

Details


Step 1: Create New ABAP Program

a. Create a global Data Dictionary (“DDIC”) structure: In the toolbar, select the New icon, then choose ABAP Program…:

Image depicting create new

A wizard appears to create a new ABAP Program. Enter z_invoice_items_euro in the name field. Enter a meaningful text in the description field. Click Finish to create the report.
Afterwards an editor will be opened which shows the empty report.

new ABAP program
Please log in to access this content.
Step 2: Create ABAP local class

Type lcl and press Ctrl+Space to get code completion proposals. Select the code template for the insertion of a local class by double-clicking on lcl - Local class or press Enter if the right entry is already selected.

local class value help

Adjust the name of the local class to lcl_main using inline editing.

local class
Please log in to access this content.
Step 3: Create CREATE method

Position the cursor in the class definition statement and press Ctrl+1 to open the Quick Fix menu. Double-click on Generate factory method create to create a static factory method.

create method
Please log in to access this content.
Step 4: Implement RUN method

a. Add the definition of an additional instance method run by entering methods run. in the public section.
b. Then position the cursor on the method name and press Ctrl+1 to open the Quick-Fix menu. Double-click on Add implementation for run.

run method

Implement a simple WRITE statement in the method run.

write statement
Please log in to access this content.
Step 5: Make ABAP program runnable

a. Add a START-OF-SELECTION event to your report
b. Create an instance of the local class lcl_main.
c. Call the run method.
That is, enter the following code:

START-OF-SELECTION.
    lcl_main=>create( )->run( ).
create run statement
Please log in to access this content.
Step 6: Save and Activate ABAP Program

Save and activate your program by clicking on the Save and Activate buttons in the toolbar.

save and activate program
Please log in to access this content.
Step 7: Run ABAP Program

Press F8 to run your program. An embedded SAP GUI will open inside of an Eclipse editor. After checking the output of the report click on the Close icon to close the tab.

run program
Please log in to access this content.

Next Steps

You have 2 options:
a. Retrieve data from the database by:
- creating a Data Dictionary structure (from an SQL query)
- a global ABAP class
- and a data element:

Display database content and run SQL queries

OR

b. Retrieve data from the database by creating a CDS view:

Create a CDS View

Updated 07/17/2017

Time to Complete

5-10 Min.

Beginner

Tags

Next
Back to top