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

Create Value Help, Enhance the Behavior Definition and Behavior Implementation of the Shopping Cart Business Object

Create your first order in the shopping cart.

Overview

🎓 beginner 25 min. SAP S 4hana Cloud ABAP EnvironmentBeginnerABAP DevelopmentABAP Extensibility

You will learn

  • โœ”How to enhance a behavior definition
  • โœ”How to create a value help
  • โœ”How to enhance a behavior implementation
  • โœ”How to run the SAP Fiori Elements Preview
Merve Temel M Merve Temel January 12, 2026
Created by August 15, 2023
Contributors

Prerequisites

Prerequisites

Steps

In the shopping cart, customers can order various items. Once an item is ordered, a new purchase requisition is created via purchase requisitions API.

Intro

In this tutorial, wherever ### appears, use a number (e.g. 000). This tutorial is done with the placeholder 000.


Step 1 Enhance behavior definition of data model
โ€”

In this tutorial example a SAP S/4HANA on-premise system with release 2023 FPS03 was used. The mode therefore is strict (2).

  1. Open your behavior definition ZR_SHOPCARTTP_### to enhance it. Add the following statements to your behavior definition:
```ABAP
update (features: instance);
.
.
draft action(features: instance) Edit;
```

 ![projection](https://raw.githubusercontent.com/sap-tutorials/abap-core-development/main/tutorials/abap-s4hanacloud-purchasereq-enhance-shop/updatenew.png)
  1. Replace the following statements to your behavior definition:
```ABAP
draft determine action Prepare { validation checkOrderedQuantity;  validation checkDeliveryDate;}
  determination setInitialOrderValues on modify { create; }
  determination calculateTotalPrice on modify { create; field Price; } 
  validation checkOrderedQuantity on save { create; field OrderQuantity; }
  validation checkDeliveryDate on save { create; field DeliveryDate; }
```

 ![projection](https://raw.githubusercontent.com/sap-tutorials/abap-core-development/main/tutorials/abap-s4hanacloud-purchasereq-enhance-shop/bdef5xx.png) 
  1. Check your behavior definition:
```ABAP
managed implementation in class ZBP_SHOPCARTTP_### unique;
strict ( 2 );
with draft;

define behavior for ZR_SHOPCARTTP_### alias ShoppingCart
persistent table zashopcart_###
draft table ZDSHOPCART_###
etag master LocalLastChangedAt
lock master total etag LastChangedAt
authorization master( global )
{
  field ( readonly ) 
  OrderUUID,
  CreatedAt,
  CreatedBy,
  LastChangedAt,
  LastChangedBy,
  LocalLastChangedAt,
  PurchaseRequisition,
  PrCreationDate,
  DeliveryDate;      

  field ( numbering : managed )
  OrderUUID;

  create;
  update(features: instance) ;
  delete;

  draft action(features: instance) Edit;
  draft action Activate;
  draft action Discard; 
  draft action Resume;
  draft determine action Prepare { validation checkOrderedQuantity;  validation checkDeliveryDate;}
    determination setInitialOrderValues on modify { create; }
    determination calculateTotalPrice on modify { create; field Price; }
    validation checkOrderedQuantity on save { create; field OrderQuantity; }
    validation checkDeliveryDate on save { create; field DeliveryDate; }

  mapping for ZASHOPCART_### 
  {
    OrderUUID = order_uuid;
    OrderID = order_id;
    OrderedItem = ordered_item;
    Price = price;
    TotalPrice = total_price;
    Currency = currency;
    OrderQuantity = order_quantity;
    DeliveryDate = delivery_date;
    OverallStatus = overall_status;
    Notes = notes;
    CreatedBy = created_by;
    CreatedAt = created_at;
    LastChangedBy = last_changed_by;
    LastChangedAt = last_changed_at;
    LocalLastChangedAt = local_last_changed_at;
    PurchaseRequisition = purchase_requisition;
    PrCreationDate = pr_creation_date;
  }
}
```
**Hint:** Please replace **`###`** with your ID.
  1. Save and activate.
Step 2 Create data definition for products
+
Step 3 Add value helps in the CDS projection view
+
Step 4 Enhance behavior implementation
+
Step 5 Run SAP Fiori Elements preview and create first order
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 5
1. Enhance behavior definition of data model 2. Create data definition for products 3. Add value helps in the CDS projection view 4. Enhance behavior implementation 5. Run SAP Fiori Elements preview and create first order

Learn more →