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

Integrate the Wrapper into the Shopping Cart Business Object

Learn how to integrate your wrapper in a RAP BO, implement a new action to call the wrapper during the save sequence phase and expose it via service binding

Overview

🎓 intermediate 15 min. ABAP ExtensibilityIntermediateSAP S 4hanaABAP Development

You will learn

  • How to integrate a wrapper class in a RAP BO during the save sequence
  • How to implement a new action in RAP BO to call the wrapper class and use it to create a purchase requisition
  • How to expose the action via service binding

Prerequisites

Prerequisites

Steps

Intro

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

In this tutorial you will take the wrapper that you created and you will integrate it in your shopping cart RAP Business Object (RAP BO) to create purchase requisitions in your online shop application as indicated in the Using BAPIs in RAP blog post:

  • You will implement a new action. The action shall change the status of the business object instance to “Submitted”.
  • You will implement a validation for the status. When the status is “Submitted”, the validation will call the BAPI in test mode via the wrapper. It will return any error message raised by the BAPI. These error messages are then returned to the end user.
  • You will adapt the RAP BO and turn it into a RAP BO with unmanaged save. In the corresponding save_modified method implementation, when the status of a business object instance is “Submitted”, the wrapper will be called via the BAPI and a purchase requisition is created for that business object instance.
Step 1 Switch to strict (1) mode

Later in this tutorial we will implement a save_modified method in the RAP Business Object, which will invoke authorization checks during the save sequence. If the RAP behavior definition is implemented in ABAP for Cloud Development and the strict(2) mode is applied, this would lead to runtime errors. For this reason, we will switch to strict(1) mode. For more information, see The RAP Transactional Model and the SAP LUW.

Connect to your system via ADT and navigate to the package Z_PURCHASE_REQ_### containing the RAP BO. Open the behavior definition ZR_SHOPCARTTP_### and change to strict(1) mode:

Switch strict mode
Switch strict mode

Save and activate it.

Open the behavior definition ZC_SHOPCARTTP_### and change to strict(1) mode there as well:

Switch strict mode
Switch strict mode

Save and activate it.

Step 2 Implement new action `createPurchRqnBAPISave`
+
Step 3 Implement on save validation using the BAPI test mode
+
Step 4 Implement `unmanaged_save`
+
Step 5 Call wrapper class in unmanaged save implementation `save_modified`
+
Step 6 Expose the new action
+
Step 7 Run SAP Fiori Elements Preview to test action
+
Step 8 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 8
1. Switch to strict (1) mode 2. Implement new action `createPurchRqnBAPISave` 3. Implement on save validation using the BAPI test mode 4. Implement `unmanaged_save` 5. Call wrapper class in unmanaged save implementation `save_modified` 6. Expose the new action 7. Run SAP Fiori Elements Preview to test action 8. Test yourself

Learn more →