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

Explore the declarative power of status-transition flows

Learn what CAP's status-transition flows feature is, and how to use it.

Overview

🎓 beginner 20 min. SAP Cloud Application Programming ModelSAP Business Technology PlatformCloudBeginner

You will learn

  • โœ”What the status-transition flows feature is
  • โœ”Where it can be useful
  • โœ”What facilities it provides
  • โœ”How you can use it
DJ Adams D DJ Adams August 3, 2026
Created by August 3, 2026
Contributors

Prerequisites

Prerequisites

You will need a development environment for CAP Node.js. See the tutorial Set up a self-contained development environment for CAP Node.js The assumptions in this tutorial are based on option 1 or option 2 in that tutorial, in that you have a VS Code (or GitHub Codespace) environment based on the foundation repository used in the setup described there, which also means that your starting directory will be /workspaces/cap-nodejs-dev-env. If you have your own CAP Node.js development environment setup, then please make the appropriate adjustments where necessary.

Steps

Intro

Released towards the end of 2025, status-transition flows moves us one step closer to declarative nirvana, and in the right direction with regards to LLM-based learning about CAP powered solutions, a smaller code surface area, and a shift left of logic and definitions.

In this tutorial we’ll explore the feature with a simple model with different states and restrictions on transitions between them.


Step 1 Create a new CAP project and CDS model
โ€”

๐Ÿ‘‰ First, initialize a new CAP project, specifying that it will be a Node.js based one, and then open it up in a new IDE session:

Shell
cds init --add nodejs cap-status-transition-flows

๐Ÿ‘‰ Now open the new cap-status-transition-flows/ directory in a new VS Code / Codespace window:

Shell
code cap-status-transition-flows/

This should place you and any new terminal session in the new cap-status-transition-flows/ directory.

๐Ÿ‘‰ Following the mantra of “the simplest thing that could possibly work”, create a new services.cds file with the following contents:

CDS
context narrowboat {

  type Position : String enum {
    Forward;
    Neutral;
    Reverse;
  }

  entity Controls {
    key ID       : Integer;
        position : Position default #Neutral;
  }
}

service Morse {

  entity Controls as projection on narrowboat.Controls

    actions {
      action engageForward();
      action engageNeutral();
      action engageReverse();
    };

}

If you wish, you can also remove extraneous project files to keep things clean and to a minimum to avoid distractions:

Shell
rm -rf app/ db/ srv/ readme.md
Step 2 Examine the model details
+
Step 3 Set up for cds test
+
Step 4 Add and run basic tests
+
Step 5 Add transition related tests
+
Step 6 Assess the status and current facilities of the model
+
Step 7 Add status-transition flow annotations
+

However, for the purposes of learning and clarity, the annotations are made separately:

  • on the flow status element
  • on the bound actions
Step 8 Examine the annotations
+
Step 9 Retry the tests
+
Step 10 Add more transition tests
+
Step 11 Wrap-up and further info
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 11
1. Create a new CAP project and CDS model 2. Examine the model details 3. Set up for cds test 4. Add and run basic tests 5. Add transition related tests 6. Assess the status and current facilities of the model 7. Add status-transition flow annotations 8. Examine the annotations 9. Retry the tests 10. Add more transition tests 11. Wrap-up and further info

Learn more →