Run ABAP Code directly from eclipse

SAP is providing free access to its' cloud instances, so let's dive right in. What this basically means is that we can code in ABAP using Eclipse on our local machine, and the code will be executed on a public free SAP server instance. The only downside for beginners is that for free server instance, we cannot access the SAP GUI in the cloud project.

Disclaimer

All the information provided here are solely for educational purposes. It is up to the reader on how this information shall be used.

Mandatory Software

Eclipse is required, any version is fine. An SAP cloud instance, and SAP ABAP Development tools plugin is required to work with SAP ABAP cloud.

First step - securing a free trial account

Step 1 :

Go to https://developers.sap.com/tutorials/hcp-create-trial-account.html and click on the locked 'Done' button to register on SAP.

Create a new account

Put in Email ID

Fill up necessary details and click on register

Step 2:

Now that id creation is done with, it's time to create that free instance. Free instances are provided for 30 days which can be extended up to a year.

Go back to the tutorial page and click on SAP BTP Trial hyperlink in Step 4, or directly go to https://account.hanatrial.ondemand.com/

Activating SAP BTP Trial
You need to verify your phone number and then you are good to go.

Phone VerificationPhone Verification 2nd window

Step 3:

Selecting proper server with ABAP support -

On clicking continue after the above step, you will land on a webpage like the one shown below. Click on 'Enter your trial account'.

Onboarding Page of SAP Cloud
After this, a window opens up wherein you have to select server location. Choose either US or Europe, the other servers don't have support for running ABAP on free instances.

Select US or EU server only

Step 4:

Selecting the ABAP booster from Cloud Platform Cockpit

When the Cockpit loads, go to the Boosters tab from the left sidebar.

Selecting Booster from menu
Select 'start' under 'Prepare an account for ABAP trial'.

Preparing environment for ABAP Trial
After successful boosting, a success message will be shown along with the option to download the Service Key. Download it.

Download Service Key

Second step - installation of ABAP Development Tools

From 'Useful Links' button in the left sidebar, situated at the bottom left corner, select 'Tools'.

ABAP Tools
Follow the steps in the ABAP section just beside the HOME section. They are pretty self-explanatory. You may be prompted to trust Eclipse.org's certificate; if so, provide the required permission.

Installing ABAP dev tools in Eclipse

Third Step - Creating a Global cloud project

That's right, your projects would be shared in the same server. Before that, change Eclipse perspective to ABAP. After that, go to File menu and click on ABAP Cloud Project.

Create new ABAP Cloud Project
In the next window, you'll see that it asks for your service key. This was what you had previously downloaded while boosting your server. Click on next and import, then select the downloaded .json file.

Click on next and provide Eclipse your service key
Import downloaded .json service key
Authentication would be required after this step. Just open logon page in browser and then login using your SAP email and password. Press finish once you've verified in browser.

SAP Logon screen
Legalities
Successful Logon splash screen
A window will be shown with your service instance connection. Click on Finish.

Service Instance Conection

Fourth Step - Creating Global Package

Package creation is exactly similar to package creation in Java, where a package signified interconnected classes and objects. A lot of people would be using the system, and therefore code modularization is essential. Under 'favorite packages' from the file explorer on the left, right click on ZLOCAL parent package. Create a new package as shown.

Package Creation
Make sure you add this package to your favorite packages to quickly access and work with them.

Package Creation
Create a new transport request and you're good to go.

Transport Request

Fifth Step - Class Creation

Okay now you are all set to code your first ABAP program in your Eclipse IDE. There is a catch though, report programs cannot be created in the free trial server. That's a good thing.

Can a method exist in Java without class? Similarly, a report program cannot exist without a class, at least in the trial version. Therefore, let's create a class.

Right click on the package you created earlier. It should be under your favorites sub-menu. Click on New -> ABAP Class.

New Class Creation

Defining Class

You will be asked to select a transport request. Choose and click Finish.
Selecting Transport Request

Final Step - Hello ABAP in Cloud!

Apparently the cloud instances provide restricted usage of ABAP syntax, which means that syntax like the following isn't possible:

1
2
3
WRITE v_somevar.
ULINE.
DESCRIBE TABLE t_sometable LINES ln.

Instead, to print to the console, an interface if_oo_adt_classrun is implemented, which contains a main method ( told you, it's almost Java! ) and contains the out object using which we print output to the console. Yes, it takes us back to System.out.println(); just that over here, we are calling the write method using the out object.

Code Execution

CLASS zmyfirstclass DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.


CLASS zmyfirstclass IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    out->write('Hello ABAP in Cloud!').
  ENDMETHOD.
ENDCLASS.

References

Edit Report
Pub: 06 Feb 2021 02:57 UTC
Edit: 06 Feb 2021 03:36 UTC
Views: 25