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.
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/
You need to verify your phone number and then you are good to go.
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'.
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.
Step 4:
Selecting the ABAP booster from Cloud Platform Cockpit
When the Cockpit loads, go to the Boosters tab from the left sidebar.
Select 'start' under 'Prepare an account for ABAP trial'.
After successful boosting, a success message will be shown along with the option to download the Service Key. Download it.
Second step - installation of ABAP Development Tools
From 'Useful Links' button in the left sidebar, situated at the bottom left corner, select '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.
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.
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.
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.
A window will be shown with your service instance connection. Click on Finish.
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.
Make sure you add this package to your favorite packages to quickly access and work with them.
Create a new transport request and you're good to go.
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.
You will be asked to select a transport request. Choose and click Finish.
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:
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.