SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Enhance the Business Object Behavior With Unmanaged Internal Numbering

Enhance the business object behavior using early numbering with SAP BTP ABAP environment.

Overview

🎓 beginner 20 min. SAP BTP ABAP EnvironmentBeginnerABAP DevelopmentSAP Business Technology Platform

You will learn

  • How to define internal early numbering
  • How to implement internal early numbering
  • How to preview and test enhanced travel app In the previous exercise, you’ve enhanced the data model of the business object (BO) entity Travel. In the present exercise, you will define and implement the unmanaged internal early numbering to set the primary key TravelID of new Travel instances during their creation in your application. You will also use the static field control to specify some fields to read-only. A number range object will be used to determine the unique travel identifiers.
Merve Temel M Merve Temel April 17, 2024
Created by March 9, 2023
Contributors

Prerequisites

Prerequisites

  • You need to have access to an SAP BTP, ABAP environment, or SAP S/4HANA Cloud, ABAP environment or SAP S/4HANA (release 2022 or higher) system. For example, you can create free trial user on SAP BTP, ABAP environment.
  • You have downloaded and installed the [latest ABAP Development Tools (ADT)] (https://tools.hana.ondemand.com/#abap) on the latest Eclipse© platform.
  • You have created an ABAP Cloud Project.
  • Make sure, your system has the ABAP flight reference scenario. If your system hasn’t this scenario. You can download it here. The trial systems have the flight scenario included.

Steps

Intro

Reminder: Do not forget to replace the suffix placeholder ### with your chosen or assigned group ID in the exercise steps below.

Numbering: Numbering is about setting values for primary key fields of entity instances during runtime. Different types of numbering are supported in RAP which can be divided into two main categories:

Early numbering: In an early numbering scenario, the primary key value is set instantly after the modify request for the CREATE is executed. The key values can be passed externally by the consumer or can be set internally by the framework or an implementation of the FOR NUMBERING method. The latter will be implemented in the present exercise.

Late numbering: In a late numbering scenario, the key values are always assigned internally without consumer interaction after the point of no return in the interaction phase has passed, and the SAVE sequence is triggered. Further reading: Numbering

Step 1 Define internal early numbering

Define the (unmanaged) internal early numbering in the behavior definition

bdef icon
bdef icon
of the Travel entity.

  1. Open the behavior definition

    bdef icon
    bdef icon
    ZRAP100_R_TravelTP_### of the Travel entity.

  2. Specify the statement provided below just after the statement authorization master( global ), just before the opening curly bracket { as shown on the screenshot.

    ABAP
    early numbering

    The warning message Early Numbering for CREATE ZRAP100_R_TRAVELTP_### is not implemented is now displayed for the statement create;. You can hover the yellow underlined statement to display the message or have a look at the Problems view.

    You can ignore it for now. You will handle it later.

    Travel BO Behavior Definition
    Travel BO Behavior Definition

  3. Delete following statement:

    ABAP
    field ( mandatory : create ) 
    TravelID;
  4. Specify the field TravelID as read-only field since it will be set at runtime by the internal early numbering. Info: The static field control is used to restrict properties of particular fields.

    For that, replace the statement

    ABAP
    field ( readonly ) 
    TravelID;

    You can use the ABAP Pretty Printer function (Shift+F1) to format the source code.

    Travel BO Behavior Definition
    Travel BO Behavior Definition

  5. Save

    save icon
    save icon
    and activate
    activate icon
    activate icon
    the changes.

  6. To complete the definition, you need to declare the required method in behavior implementation class. You can use the ADT Quick Fix to do that.

    Set the cursor on the statement create; and press Ctrl+1 to open the Quick Assist view.

    Select the entry Add earlynumbering method for create of entity zrap100_i_travel_### in local handler from the dialog to add the FOR NUMBERING method earlynumbering_create to the local handler class lcl_travel of the behavior pool

    class icon
    class icon
    ZRAP100_BP_TRAVEL_###.

    Travel BO behavior Definition
    Travel BO behavior Definition

    The behavior implementation class

    class icon
    class icon
    ZRAP100_BP_TRAVEL_### will be enhanced appropriately.

    You are through with the definition of the early numbering and can now go ahead and implement its logic.

  7. Save

    save icon
    save icon
    and activate
    activate icon
    activate icon
    the changes.

Step 2 Implement internal early numbering
+
Step 3 Preview and test enhanced travel app
+
Step 4 Test yourself
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Define internal early numbering 2. Implement internal early numbering 3. Preview and test enhanced travel app 4. Test yourself

Learn more →