Programming

How to Create an ABAP Object in VS Code

The ABAP system is mounted to VS Code as a file system, which introduces certain challenges to the development workflow.

 

In this blog post, we’ll teach you how to create an ABAP object in the VS Code system.

 

Supported Object Types

When running the Abap Fs Create object command, you’re presented with a list of supported object types, which includes the following common objects:

  • Authorization fields and objects
  • CDS metadata, data, and annotation definitions
  • Classes
  • Data elements
  • Function modules
  • Packages
  • Tables

For the purposes of this post, we’ll create a class. Run the Abap Fs Create object command and then select Class from the menu. Now, enter a name (in our example, zcl_ leon_class) and description and assign a local package but no transport. Once the class is created, it will be opened in VS Code, as shown below.

 

New ABAP Class

 

For creating any objects in the ABAP system, the Command Palette is quite easy to follow and provides the context for any required prompts to create your object.

 

Activating Changes

To see your changes at runtime, you must activate the object. Activating the object will run a syntax check and updates the runtime version of the object. This step will also generate a version in the object history. To activate an object, click the Activation icon (the magic wand icon), in the top-right corner of the Editor, as shown in the figure above.

 

Navigating Objects

The easiest way to navigate the ABAP system for objects is using Abap Fs Search for Object, which allows you to perform a fuzzy search in the Command Palette and suggests matching results as you type, as shown here.

 

Fuzzy Object Search

 

Finally, note that the whole ABAP system exists in the side bar so you can browse through packages quite quickly.

 

Another method is using the Abap Fs Add Favourite command to add objects and folders to your favorites (also available via the right-click context menu). Favorites are displayed in the File Explorer, under the Favorites heading, as shown in this final figure.

 

Favorite ABAP Objects

 

Editor’s note: This post has been adapted from a section of the book Visual Studio Code for SAP by Leon Hassan.

Recommendation

Visual Studio Code for SAP
Visual Studio Code for SAP

Start programming your SAP applications in Visual Studio Code! This hands-on guide begins with an overview of how VS Code works and how it connects to your SAP systems. Then learn how to manage version control by integrating VS Code with Git. Follow step-by-step instructions to develop SAPUI5 web components, build applications with ABAP, create SAP Fiori apps using SAP Fiori elements, and work with the SAP Cloud Application Programming Model. Get everything you need to master this IDE!

Learn More
SAP PRESS
by SAP PRESS

SAP PRESS is the world's leading SAP publisher, with books on ABAP, SAP S/4HANA, SAP CX, intelligent technologies, SAP Business Technology Platform, and more!

Comments