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…:
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.
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.
Adjust the name of the local class to lcl_main
using inline editing.
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.
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.
Implement a simple WRITE statement in the method run.
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( ).
Step 6: Save and Activate ABAP Program
Save and activate your program by clicking on the Save and Activate buttons in the toolbar.
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.
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