It has been a few years since Björn Goerke, the SAP Chief Technology Officer, announced that SAP Cloud Platform will soon support ABAP at the SAP TechEd conference in the fall of 2017.
At present, on domestic technical media platforms, there are already some Chinese articles that briefly introduce the SAP Cloud Platform ABAP programming environment, but there are relatively few articles involving specific operation details.
In fact, for a traditional developer who has been proficient in using ABAP Development Tools to connect to On-Premises ABAP Netweaver server for development, it is not difficult to migrate from On-Premises to SAP cloud platform, just need to pay attention to some development concepts The transformation of this transformation will be mentioned in the follow-up specific development.
This relatively flat migration and learning curve is undoubtedly good news for enterprises and developers in SAP’s vast global ecosystem – which means that in SAP’s ongoing journey to digital transformation to the cloud, these enterprises and Individuals can also join in, and their valuable technical and business domain knowledge accumulated in the age of On-Premises can continue to shine in the age of cloud.
Many developers who are self-taught SAP ABAP, the first hurdle is to set up a Netweaver server locally. As an old developer who has written code for 15 years, the author has also used various local development environments, and I know how deep the water is. My former Manager also shared with us his experience of using Netweaver locally when he came to the SAP Chengdu Research Institute for an interview, and read hundreds of pages of Netweaver English documents in just a few days.
I believe that every ABAP learner who builds Netweaver locally will feel a sense of accomplishment when he successfully sees the output of Hello World.
However, when Jerry saw Hello World on the ABAP programming environment of SAP Cloud Platform for the first time, he did not have much sense of accomplishment, because he could just follow the project creation wizard in the ABAP Development Tool step by step, and the process was relatively simple and easy. Understand – this also reflects the impact of the cloud era on the way of traditional application developers’ work: you don’t need to worry about resources such as the underlying hardware or operating system, you can focus on writing application logic. In other words, SAP is responsible for managing and maintaining the underlying HANA database and the middle-level ABAP runtime, and users only need to manage the top-level ABAP application code. Project creation wizard using ABAP Development Tools: New->ABAP Cloud Project:
Service Instance Connection, select SAP Cloud Platform CloudFoundry environment:
Select Region, enter the username and password, provided that you have a global Account under this region.
The following picture is my Global Account in the CloudFoundry environment of SAP Cloud Platform:
The space to which this Global Account belongs I created an ABAP system instance with an ID of ME1:
This ABAP running instance has 16GB running memory and 64GB HANA memory.
Going back to the ABAP Development Tools, use the above properties maintained in Cockpit in the project creation wizard:
Click Next and you will see an embedded login window in the ABAP Development Tools. Because Jerry is using the SAP Community Mentor account, the title displayed in the login window is: Welcome to Mentors!
Click the Finish button in the wizard:
After clicking, you can see the created ABAP Cloud project in the project list on the left side of ABAP Development Tools. Next, the way to write ABAP code in this project for development is basically the same as we use ADT to connect the On-Premises system. You can see the highlighted ABAP Cloud project created in the following figure (system ID is ME1), which is no different in appearance from other ABAP projects on On-Premises.
The difference between the two ABAP projects is that the ABAP language features that can be used in the ABAP Cloud project are only a subset of the traditional ABAP language, such as keywords related to Dynpro in the traditional ABAP language, that is, those that can only work in SAPGUI The keyword, because it is no longer applicable in the Cloud environment, is prohibited in the ABAP Cloud project of the ABAP Development Tools.
Now you can write the first line of ABAP program. As in the On-Premises environment, first create a local package ZJERRY (local package):
Then a prompt pops up asking to create a Transport Request:
Once the Package and Transport Request are in place, it’s time to start coding. In the era of On-Premises, we want to use ABAP to print Hello World, directly create a report with SE38 (Program, as shown in the figure below), and then WRITE: ‘Hello World’ is fine.
On SAP Cloud Platform, the ABAP Program item is no longer available in the new list option.
So we can only choose to create a new ABAP Class:
Specify to store this class in the newly created Transport Request:
The next operation is like printing Hello World with System.out.println in the static public void main(String[] args) method of the Java class. This new ABAP class implements the IF_OO_ADT_CLASSRUN interface to print Hello World:
Activation code, you can see that, like On-Premises, the various components of this class need to be activated together.
After activation, Run As->ABAP Application(console):
See the output in the Console:
Observing the interaction log of this class execution, we found that the execution action we triggered in the ABAP Development Tools, the IDE sent a POST request with the endpoint /sap/bc/adt/oo/classrun on the SAP Cloud Platform.
This program is executed on the ABAP instance of the SAP cloud platform, and the result is returned to the IDE in the form of an HTTP response.
A significant difference between ABAP programming on the SAP cloud platform and the traditional On-Premises system programming is the principle of keeping simplicity, reducing operational risks, and providing operational flexibility and cloud platform security. Considering the compromise, developers in the ABAP programming environment of SAP Cloud Platform cannot arbitrarily access resources on Netweaver like the latter.
Take the most commonly used ABAP OPEN SQL table reading operation on Netweaver by traditional ABAP developers for secondary development. This behavior of directly accessing database tables will cause syntax errors on SAP Cloud Platform.
Even if the database table of Netweaver is directly referenced in the ABAP code as shown in the figure below, it is not allowed on the SAP cloud platform.
All access to the underlying resources must be carried out through the APIs in the whitelist defined by SAP, namely the APIs contained in Released Objects in the following figure.
Summarize
This article first introduces the historical inevitability of the migration of ABAP programming language from the local deployment environment to the cloud. Then, starting from the Hello World level example, it introduces how to create the simplest Class in the ABAP cloud programming environment, and the programming attention that distinguishes the cloud from the local environment. matter.
The text and pictures in this article are from InfoQ
This article is reprinted from https://www.techug.com/post/write-the-first-paragraph-of-abap-program-on-the-abap-programming-environment-of-cloud-platform.html
This site is for inclusion only, and the copyright belongs to the original author.