Learn SAP from the Experts | The SAP PRESS Blog

How to Create an ABAP Object in VS Code

Written by SAP PRESS | Oct 11, 2023 1:00:00 PM

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.

 

 

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.

 

 

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.

 

 

Learn ABAP OOP in Our Upcoming Rheinwerk Course!

Enhance your ABAP skills with object-oriented programming! Create classes, implement polymorphism, and more. Use exceptions for error handling and write unit tests to improve your code. Learn about key design patterns and apply your ABAP Objects knowledge to the ALV object model (SAP List Viewer). This upcoming course in January is live on the web and will teach you all you need to know about these topics. Click on the banner below to learn more and order your ticket.

 

 

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