Getting to Know the Scripting Language

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Use the scripting language to define business objects and implement business logic

Getting to Know the Scripting Language

Business Objects​

SAP Cloud solutions are built using the concept of Business Objects (BO) to model the business environment.​ A business object is a technical representation of a real-world object and an integral part of the development framework.​ Business objects store data, implement business logic and reference other business objects that they interact with to build a business process.​

Some samples for business objects include:

  • Sales Quote
  • Product
  • Employee​

​Business objects are the basis for most items you can create with the studio, such as screens, PDF forms, and service integrations.

This is illustrated in the following graphic.​

Scripting Language​

The studio’s scripting language is used to define the structure of business objects and to implement business logic.​ The business object definition has its own syntax but is self-explanatory after familiarizing with the object based approach.

For the business logic implementation, you will notice similarities with other programming languages like Java or C#. Especially for this part it's beneficial to have experience in other programming languages, because we can’t teach you the basics of programming here. We will focus on giving you a good overview and explain some details through examples. Whether you are a beginner or an experienced developer, you should definitely have a look at the studio's help pages. They are a valuable source of information.

Business Object Definition

As already mentioned, the structure of a business object with its fields, data types, relationships to other objects, and so on, is called Business Object Definition. Therefore, this part of the scripting language is sometimes also referred to as Business Object Definition Language.

The following graphic shows the definition of a sample business object. Select Watch Demo below to see an interactive presentation that walks you through the different elements of this part of the scripting language.

To briefly summarize this, a business object definition basically consists of the following elements:

  • Elements (attributes, fields) to hold and store data.​

  • Nodes to structure the BO into different levels with different multiplicities (for example, to model a parent-child relationship -> implement items)​.

  • Associations to reference other business objects (build relationships).​

  • Messages that can be raised to make the user aware of certain circumstances​.

  • Actions to execute business logic​.

Saving data for a business object to the database is handled by the framework, without writing additional code or SQL statements. This also applies to translating the business objects’ structure into database entities and creating tables, relations, etc.

Business Logic Implementation

Implementing business logic is the second part where the scripting language comes into play.​ The syntax is similar to Java or C# and is usually easy to learn.​ It is often referred to as ABSL, which is short for Advanced Business Scripting Language and also the file extension of the business logic script files. (Fun fact: Some call it ABAP Scripting Language because it gets compiled to ABAP code in the backend of the cloud solution.)

Let's have a look at a sample script to introduce the basic language features. The following graphic shows a script that we will also implement later in the course. For the moment, we want to concentrate on the elements and syntax of the scripting language, rather than what it does. We'll explain that later in the course. Select Watch Demo underneath the graphic to get a guided tour through the most important language elements.

Implemented business logic can be executed in two ways:​

  • By events that are offered and triggered by the framework, such as AfterModify and BeforeSave, or​

  • Actions that are defined in the BO definition. They can be triggered by the UI, like when the user clicks a button, or by events that call the action.​

Don't forget to check out the Help Portal to get more details on the scripting language and its usage.​

Using Code Completion to Simplify Scripting

Code Completion is a very handy feature where the Editor provides you with all terms that are available for the current cursor position. It works for both the Business Object Definition as well as for implementing business logic.

Using code completion simplifies the scripting, as it suggests available data type names when working in the BO definition or declaring a variable with a data type. It provides all available fields when navigating through the structure of a business object and saves you time on typing.

The code completion windows can be opened in several ways:

  • By pressing CTRL + J
  • By pressing CTRL + SPACE
  • By typing the . operator to navigate through a business object structure when writing business logic.

The following two screenshots show how the code completion looks in the BO definition and when implementing the business logic:

Log in to track your progress & complete quizzes