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

Extend the RAP Travel Application to integrate workflow capability

Enhance the business object behavior using determination to add workflow functionality.

Overview

🎓 beginner 30 min. SAP BTP ABAP EnvironmentIntermediateABAP DevelopmentSAP Business Technology PlatformLicensen

You will learn

  • βœ”How to define determinations
  • βœ”How to implement determination
  • βœ”How to use EML in Local Mode
Ruchi Dobriyal R Ruchi Dobriyal November 22, 2024
Created by June 24, 2024
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.
  • Latest Version of ADT with abapGit plugin
  • You have created the Travel App with workflow handler class as explained here

Steps

Intro

As part of this tutorial, you would extend the Managed Business Object behaviour by defining and implementing a Determination on Save trigger_travelworkflow during action Create (trigger condition). You will use the Entity Manipulation Language to implement the transactional behavior of the Travel business object.

On Creation of the travel booking, during save event Determination on Save trigger_travelworkflow will be called. trigger_travelworkflow will intern trigger workflow for travel approval and set the overall status of the travel to awaiting approval.

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

A determination is an optional part of the business object behavior that modifies instances of business objects based on trigger conditions. Determinations are implemented when we need to calculate values of few fields based on trigger conditions.

A determination is implicitly invoked by the RAP framework if the trigger condition of the determination is fulfilled. Trigger conditions can be CRUD operations or fields. Determinations can be created On modify or On save based on if we want to display the value of a calculated field to the user before save or after save.

Please refrain from writing fields which needs to be determined / calculated in the trigger conditions of that determination as it might lead to infinite loop since we are specifying the calculated field in the trigger condition and changing the field inside that determination which is resulting in application dumps.

Step 1 Define Determination.
β€”

Extend the Business Object Behaviour definition with Determination On Save.

  1. Go to behaviour definition of the Travel root entity
    alt text
    alt text
    ZR_RAP_TRAVEL_#### and define the determination trigger_travelworkflow. For that, insert the following code as shown in the screenshot below.
ABAP

    determination trigger_travelworkflow on save `{create;}`

TriggerTravelWorkflow
TriggerTravelWorkflow

Short explanation: This statement specifies that the determination would be triggered during the save event of the operation Create. The determined values would be visible after save.

  1. Activate

    alt text
    alt text
    the changes

  2. Click on the Quick Assist

    alt text
    alt text
    besides the newly added line of code and the Add method for determination to declare the required method in behavior implementation class.

    QuickAssist
    QuickAssist

  3. As a result, you can see the method trigger_travelworkflow for determination is added in the local handler class LHC_TRAVEL of Behaviour implementation class ZBP_R_RAP_TRAVEL_RD02

    LocalHandlerClass
    LocalHandlerClass

    Short Explanation:

    • The addition FOR DETERMINE indicates that the method provides the implementation of a determination and the addition ON SAVE indicates the specified trigger time (during save event).

    • IMPORTING parameter keys – is an internal table containing the keys of the instances the determination will be executed on. Includes all entities for which keys must be assigned.

    • Implicit CHANGING parameter reported - used to return messages in case of failure.

  4. Activate

    alt text
    alt text
    the changes

Step 2 Implement Determination
+
Step 3 Add Value Help to enrich Travel Application UI.
+
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 Determination. 2. Implement Determination 3. Add Value Help to enrich Travel Application UI. 4. Test yourself

Learn more →