Wednesday 18 December 2019

ABAP Development in VS Code

When I started learning ABAP I found myself getting increasingly frustrated with the speed at which the SAP GUI for Java responded and I looked for other options, this is how I found that you can mount your SAP system as a filesystem in VS Code. This blog will cover how you can get started with developing ABAP from VS Code.

Note: If you are not running Netweaver v7.51+ you will have to install a patch that can be found as part of the first plugin install options.

Getting the right plugins


VS Code is required for this tutorial along with the following plugins:

◉ ABAP Remote FileSystem
◉ ABAP Syntax Highlighting
◉ ABAP CDS Language Support
◉ ABAP Snippets

Once you have installed these plugins you can begin configuring your SAP System as a Remote FileSystem.

Note: In this blog I will only cover the configuration of the ABAP Remote FileSystem plugin. For further information on configuring the other plugins listed, please review the VS Code Marketplace/GitHub repositories.

Configuring your SAP system


In order to connect to your SAP system you will need to enable the ABAP Development Tools (ADT) ICF node, this is the same service that tools such as the SAP Hana Studio use.

Open your SAP GUI and connect to the target system, run the transaction SICF and then activate the ADT_SRV service as shown below.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

This enables the service that allows code editors and IDEs to connect to your SAP system.

Configuring VS Code


Configuring this plugin to connect to your SAP system is straightforward, just open up your VS Code settings by pressing “Control/Command + ,” select “Extensions” in the menu and then in the “ABAP-FS” plugin, click on “Edit in settings.json”.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

Then you need to update the below block of json to include your SAP system and user details. You can find the URL details by right-clicking the node in SICF on the SAP System (like when we turned the service on, earlier) and selecting “Test Service”.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

This will open the ADT service and you can copy the top-level domain and port number from there.

"abapfs.remote": {
  "My SAP System label": {
    "url": "https://my-sap-system:8012/",
    "username": "my-username",
    "password": "my-password",
    "client": "920",
    "language": "EN",
    "allowSelfSigned": true
  }
}

Note: The usual rules apply… if you’re on an SAP system that’s only accessible on a specific network then you’ll still need to be on that network to connect!

This will create a system profile for you to connect to in VS Code, once you’ve saved your settings press F1 (the shortcut to launch a command) and start typing “ABAP” and you should see the “ABAPfs Connect to an ABAP system” command appear, click on this. Then select the profile you just set-up and you will connect to your system.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

Writing ABAP in VS Code


Now that you’re connected to your SAP system, you can start creating your own reports, classes and structures in VS Code. To get started, make sure that you already have a transport open for your user, you cannot create transports from VS Code.

Transport Management

You can view transports assigned to you (or a colleague) by opening the SAP plugin in the sidebar as pictured below:

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

Creating an ABAP Object

To create an ABAP object in VS Code, you simply right-click somewhere in your workspace and select “ABAPfs Create object”.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

You will then have to select one of the supported object types, these include Core Data Services (CDS) objects. Once you have selected the type of object you are creating, you must write a name and description for the object and then assign it to a package and transport.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

Activating changes to an object

When you edit an ABAP object in VS Code, you don’t need to bounce back into the SAP GUI to activate your changes. You can do this in VS Code by clicking on the “activate” wand in the top right corner of your object editor.

SAP ABAP Tutorial and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Online Exam

The breadcrumbs along the top of your editor full support navigation to related objects just like any other language.

Using VS Code for ABAP day-to-day


Now you’re setup to write ABAP in VS Code! Congratulations and I hope you make use of VS Code’s “Zen Mode” (shortcut: Ctrl+K Z) to minimise distractions.

I will leave you with a word of warning, I don’t think that his setup is quite “production-ready” yet… The major issue I found using this for 5 weeks or so, is that your object-locking can be a little volatile and require a restart of VS Code and that there’s no SAP GUI integration like you have with Eclipse. That said, it’s still great for just sitting down and getting on with some code.

No comments:

Post a Comment