SAP Joule 是SAP近期推出的生成式AI工具,旨在帮助业务用户和开发人员更快速地生成代码和应用程序。
通过利用SAP Business Technology Platform(BTP)中的AI能力,SAP Joule可以直接在SAP环境中生成代码,从而加速应用程序的创建和集成过程。以下是SAP Joule如何支持自动生成代码并创建应用程序的步骤:
接入SAP Joule的AI助手
在SAP BTP平台中,用户可以接入SAP Joule的生成式AI功能。它会通过自然语言理解来接收用户的需求描述,比如"创建一个库存管理应用程序"。然后,Joule会将这些需求转化为可执行的代码建议。
2. 生成代码建议
SAP Joule可以根据用户的描述生成初步的代码结构,涵盖用户界面、数据模型、业务逻辑等方面。例如,用户可以描述应用程序的功能需求,比如查询库存、生成报告等,Joule会相应地生成包含必要API调用和逻辑的代码。
3. 代码调试与优化
用户在生成代码后,可以通过Joule获得代码调试建议。Joule能够自动检测代码中的错误或逻辑不一致,并提供修复建议。这样可以显著缩短开发周期,减少人为错误。
4. 自定义和扩展功能
SAP Joule不仅能生成基本的应用程序代码,还可以根据用户需求进行进一步的自定义。比如,用户可以指定特定的功能模块(如销售订单、财务报表等),Joule会生成符合SAP标准的代码,并与现有SAP系统进行无缝集成。
5. 自动化应用部署
在应用代码生成完毕后,Joule支持将应用程序自动部署到SAP BTP环境中,使应用可以立即用于测试和生产。通过SAP BTP的支持,这些应用可以集成到公司现有的SAP系统中,提供完整的业务流程覆盖。
6. 持续迭代和更新
SAP Joule生成的代码并非一次性的,它支持持续迭代。用户可以根据业务需求调整应用功能,Joule会自动生成新的代码片段或更新现有代码,以适应业务流程的变化。
适用场景
SAP Joule在自动生成代码和创建应用程序方面的应用场景广泛,特别适合以下几种场景:
定制化报表和分析工具:自动生成符合企业需求的BI报表,结合SAP Analytics Cloud进行数据展示。
库存和生产管理:创建用于实时库存查询和生产调度的应用。
财务流程优化:生成财务报表、自动化财务流程等代码。
总的来说,SAP Joule能够帮助用户快速生成代码并创建应用,显著提升开发效率,降低技术门槛,加速SAP系统的应用扩展。
SAP Joule 创建一个CAP服务的例子:
您将使用Joule的生成式AI功能在SAP Build Code中创建一个CAP服务。
1. Create a New Project Using SAP Build Code
Navigate to the SAP Build lobby.
Click Create, and from the dropdown list, select Create.
3. Click the Build an Application tile.
4. Click the SAP Build Code tile to develop your project in SAP Business Application Studio, the SAP Build Code development environment, leveraging the capabilities of the services included in SAP Build Code.
5. Click the Full-Stack Application tile.
6. Enter a name for your project.
7. Select the dev space where you want the project to reside.
SAP Build Code recommends the dev space it deems most suitable, and it will automatically create a new one for you if you don’t already have one. If you have other dev spaces of the same type (for example, Full-Stack), you can select between them. If you want to create a different dev space, or a dev space or another type, go to the Dev Space Manager. See Working in the Dev Space Manager.
Click Create.
You can see the project being created in the Project table of the lobby.
9. After you see a message stating that the project has been created successfully, click the project to open it.
The project opens in SAP Business Application Studio, the SAP Build Code development environment.
2. Create Data Entities with Joule
让我们创建一个客户忠诚度计划的应用程序。客户可以通过购买产品获得积分,并可以兑换这些积分。
[注意] Joule 是一个生成式AI助手,会为您创建代码。每次触发提示时生成的代码可能会有所不同,因此教程中显示的示例可能与您系统中看到的不完全相同。
In SAP Business Application Studio, the SAP Build Code development environment, open the digital assistant, Joule, from the activity bar.
2. Copy the prompt below.
Design a customer loyalty program application. Define 4 data entities: Customers, Products, Purchases and Redemptions. Each customer must have the following fields: name, email, 7-digit customer number, total purchase value, total reward points, total redeemed reward points. All fields for each customer should be integer except name and email that will be stored as string. Each product should have a name, description and price. Purchases should include the following fields: purchase value, reward points. All fields in Purchases must be integer. Redemptions must have 1 field in integer: redeemed amount. Each purchase and redemption will be associated to a customer. Each purchase will be associated to a product and is called selectedProduct.
3. At the bottom of the Joule view, select one of the slash commands suggested and then paste the code in the text field.
4. Click the arrow to send the prompt to Joule,
the code is generated and is displayed below your prompt.
5. Accept the code.
根据服务器的不同,Joule 创建数据模型和服务可能需要几分钟的时间。一旦您接受代码,您将在右侧的 Storyboard 标签页中看到更新。
Tip: To open the Storyboard, navigate to the Project Explorer, expand your project, and select Storyboard.
3. Enhance the Application Data Using Joule
Joule created the CAP data model and the OData service. In addition, Joule created some data by default. We will now ask Joule to provide additional data.
Click Open Data Editor.
2. In the Data Editor, select the Customers data entity, go to the SAMPLE DATA tab, and add 5 more rows. Click Add.
3.Click Enhance. This will reopen Joule to modify the application data.
4. Copy the prompt below:
Enhance my sample data with meaningful data. Any phone numbers must be 10 digits long.
All customer numbers must be 7 digits long and one customer must use the customer number 1200547.
No fields may be empty.
Total purchase value must be smaller than 10000 not rounded.
Both total reward points and total redeemed reward points must not be rounded, must not be identical. and must always sum to one-tenth of the total purchase value for each customer.
5. Paste the prompt in the text field, and click the arrow to send the prompt to Joule.
The code is generated and is displayed below your prompt.
6. Accept the code. This will add the customer names, email addresses, and purchases.
4. Create Application Logic with Joule
我们已经使用Joule创建了数据模型、服务和示例数据。现在我们想要为服务创建一些逻辑。我们希望在客户购买产品时自动计算奖励积分。此外,我们还想提供客户兑换这些奖励积分的逻辑。
In the Storyboard, click on the Purchases entity under Services, and select Add Logic. In the Add Application Logic dialog, leave the default values, and click Add.
The Application Logic Editor opens.
3. In the Standard Event section, select Create. That means that this logic will be automatically executed if an OData create operation is requested.
4. Click Open Code Editor, and select Application Logic. This will open Joule again to allow us to send a prompt to Joule to create the logic for us.
5. Copy the prompt below:
Reward points of each purchase will be the one tenth of the purchase value.
Each purchase value will be added to the total purchase value of the related customer.
Each reward point will be added to the total reward points of the related customer.
6. Paste the prompt in the text field, and click the arrow to send the prompt to Joule.
So Joule created code that implements the following logic:
Check if the customer exists
Calculate the rewardPoints from the purchase value
Update the total purchase value and the total reward points in the customers entity
7.Accept the code.
Joule 每次生成的代码通常都会有所不同,即使对于相同的提示也是如此。如果您生成的代码与这里显示的不同,只要功能相同就没有问题。如果没有明显的错误,您可以继续进行练习。如果您不确定,可以通过点击“Regenerate”(重新生成)按钮让Joule再次尝试。
Go back to the storyboard.
Select the Redemptions entity under Services and select Add Logic.
10. In the Add Application Logic dialog, leave the default values, and click Add.
11.In the Standard Event section, select Create.
12. Click Open Code Editor, and select Application Logic. This will open Joule again to allow us to send a prompt to Joule to create the logic for us.
13. Copy the prompt below::
Deduct the redemption amount from the customer's total reward points and add that to their total redeemed points.
14. Paste the prompt in the text field, and click the arrow to send the prompt to Joule.
15. Accept the code.
Have a closer look at the generated code. It even includes some checks to see if the customer has enough points to redeem.
5. Add UI to the Application
To display and test the content we created for the customer loyalty program, we need to create an SAP Fiori elements UI.
Go to back to the Storyboard and add a UI application. We will start with the user interface for the Purchases data entity.
Set the Display name to Purchases and the Description to Manage Purchases, and then click Next.
We are using the browser, so we will select Template-Based Responsive Application as the UI Application type, and click Next.
Select List Report Page as the UI application template, and click Next.
Select Purchases as the Main entity, and click Finish. The page will be created now.
It might take a few moments for the UI to be created because the dependencies need to be installed.
Repeat steps 2 through 5 to create additional UI apps for the Customers and the Redemptions entities. Customer:
1. Display name: Customers 2. Description: Manage Customers 3. UI Application type: Template-Based Responsive Application 4. UI Application Template: List Report Page 5. Main Entity: Customers Redemptions:
1. Display name: Redemptions 2. Description: Manage Redemptions 3. UI Application type: Template-Based Responsive Application 4. UI Application Template: List Report Page 5. Main Entity: Redemptions And that’s it! You’ve created an application.
To preview your application, once the files have been generated, go to the upper-right corner, and click preview (Run and Debug). The application’s preview is displayed.
Click Go.
The customer information is displayed.
From the dropdown list at the top of the page, select Home to go back and preview the other applications.
总结:SAP Joule的优势:
SAP Joule相较于其他AI工具,尤其是在企业级业务环境中的生成式AI工具,拥有一些独特的优势,主要体现在对SAP系统的深度集成、业务智能化支持以及高安全性上。以下是SAP Joule的核心优势:
1. 深度集成SAP系统和业务流程
SAP Joule的最大优势在于它与SAP的生态系统紧密集成。由于它专为SAP系统设计,它能够直接读取并理解SAP ERP、SAP S/4HANA等系统中的业务数据和流程。相比于通用的生成式AI工具,SAP Joule能更精准地生成符合业务需求的代码和流程,无需大量的定制化接口或中间件。
2. 业务语义理解
SAP Joule不仅仅是一个代码生成工具,它更深层次地理解企业业务逻辑和语义。例如,当用户提到“库存优化”或“财务分析”,Joule能够直接理解这些词汇的具体业务含义,并生成相关代码或应用,而不需要额外的转换层。这让非技术用户也可以借助Joule通过简单的业务描述,快速获取业务应用的开发建议和代码。
3. 端到端的企业应用开发支持
SAP Joule能够提供从代码生成、调试到部署的端到端支持,帮助用户快速开发并上线业务应用。它不仅生成代码,还可提供自动化部署选项,将生成的应用直接部署在SAP Business Technology Platform (BTP) 上,实现快速迭代和应用更新。这种端到端的开发和交付流程在其他AI工具中并不常见。
4. 企业级安全性和合规性
SAP Joule基于SAP自身的安全和合规性标准构建,适用于各行业对数据隐私和合规要求较高的企业用户。相比于其他AI工具,SAP Joule在数据保护和隐私方面具有优势。SAP还提供行业特定的合规方案,如GDPR、HIPAA等,让企业用户在部署生成的应用程序时更为放心。
5. 行业和场景的预置模型
SAP Joule内置了许多行业和场景特定的AI模型,能够根据不同行业的需求提供定制化支持。这些预置模型可以根据行业的常见流程和数据格式生成更符合业务需求的应用。其他通用的生成式AI工具通常需要进行大量的配置和训练,才能满足不同企业的具体需求,而SAP Joule内置的行业知识则省去了这一环节。
6. 优化的成本效益
由于SAP Joule集成在SAP BTP中,企业能够以更低的成本直接在其SAP环境内获得生成式AI支持,无需单独购买、集成外部的AI服务。这对于SAP用户而言,不仅能节约成本,还能确保系统的稳定性和数据的一致性。
7. 持续更新和SAP支持
SAP Joule享受SAP的官方技术支持,并且会随着SAP生态的升级不断优化和更新。这意味着用户可以持续享受到最新的生成式AI技术,保障其生成的应用程序能够持续适应业务发展的需求。这一优势在第三方AI工具中较为少见。
总的来说,SAP Joule的优势在于其对SAP业务流程的深度集成、企业级安全和合规性、丰富的行业知识、以及便捷的端到端开发支持,使其成为SAP客户在生成式AI方面的理想选择。