You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在SAP Cloud SDK Java客户端中调用Bound Functions与Actions?

Calling Bound Functions & Actions with the SAP Cloud SDK

Hey Matija, thanks a ton for the awesome feedback on the SAP Cloud SDK—we’re really glad the VDM generation and tutorials have worked well for you! 😊

To answer your question first: the info from that 2020 video is outdated now. Bound Functions and Actions are fully supported in the SAP Cloud SDK (this has been the case since SDK version 3.x, and all newer versions like 4.x include robust support for these operations).

Here’s how you can call them from your client:

1. Make Sure Your VDM Includes Bound Operations

When you generate your Virtual Data Model (VDM) from the OData service metadata, the SDK will automatically generate dedicated methods for any Bound Functions/Actions defined in the metadata. So first, double-check that your generated VDM classes have these methods—they’ll be attached to the entity class the operation is bound to.

2. Example: Calling a Bound Function

Let’s say you have a Bound Function GetSpecialDiscount tied to the Customer entity that accepts a LoyaltyLevel parameter. Here’s how to call it:

// First, fetch the target Customer entity instance
Customer targetCustomer = new CustomerService()
    .getCustomerByKey("CUST_123")
    .execute(HttpClientAccessor.getHttpClient());

// Call the Bound Function attached to this Customer
GetSpecialDiscountResult discountResponse = targetCustomer
    .getSpecialDiscount() // Auto-generated method for the Bound Function
    .withParameter("LoyaltyLevel", "GOLD") // Pass required parameters
    .execute(HttpClientAccessor.getHttpClient());

3. Example: Calling a Bound Action

For a Bound Action like UpdateCustomerTier (bound to Customer, takes a NewTier parameter), the code looks similar:

// Fetch the Customer instance first
Customer targetCustomer = new CustomerService()
    .getCustomerByKey("CUST_123")
    .execute(HttpClientAccessor.getHttpClient());

// Execute the Bound Action
UpdateCustomerTierResult actionResponse = targetCustomer
    .updateCustomerTier() // Auto-generated method for the Bound Action
    .withParameter("NewTier", "PLATINUM")
    .execute(HttpClientAccessor.getHttpClient());

Quick Notes

  • If you don’t see the auto-generated methods for your Bound operations, make sure your OData service metadata correctly defines the operations as "bound" to the target entity, and that you’re using a recent version of the SAP Cloud SDK to generate the VDM.
  • All the operations you mentioned (Get All, Get By Key, CRUD, Unbound Functions/Actions) working smoothly is a great sign—Bound operations follow the same authentication and execution patterns, so you should have no trouble integrating them.

内容的提问来源于stack exchange,提问作者Matija Lazar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 07:49:07