Skip to content

Latest commit

 

History

History
143 lines (98 loc) · 7.7 KB

README.md

File metadata and controls

143 lines (98 loc) · 7.7 KB

Home - RAP110

Exercise 12: Implement the Base BO Behavior - Dynamic Feature Control

Introduction

In the previous exercise, you've defined and raised a business event in the Travel BO entity in your Travel App (see Exercise 11).

In this exercise, you will implement the dynamic instance feature control for some of the standard and non-standard operations of the Travel BO entity as defined in Exercise 3 .

Exercises:

Reminder: Do not forget to replace the suffix placeholder ### with your choosen or assigned assigned suffix in the exercise steps below.

About Dynamic Feature Control

As an application developer you may want to determine based on certain attributes of your business object entity, which fields should be read-only or mandatory or which functionality like update or actions are allowed. As this property is related to an instance of this business object it is called Dynamic Feature Control.

Further reading: Adding Static and Dynamic Feature Control

Exercise 12.1: Implement the Dynamic Instance Feature Control for the Travel BO Entity

^Top of page

Implement the dynamic instance feature control for the standard operations update and delete, the draft action Edit, and the instance actions acceptTravel, and rejectTravel.

Folowing behavior is expected on the UI based on the overall status (OverallStatus) of a Travel entity instance:

  • If overall status is open, all standard and nonstandard operations should be enabled.
  • If overall status is accepted, then operations acceptTravel, draft action Edit, delete and update should be disabled.
  • If overall status is rejected, then operations rejectTravel, draft action Edit, delete and update should be disabled.
🔵 Click to expand!
  1. Implement the following logic in the instance feature control method get_instance_features in the implementation part of the local handler class of the Travel behavior pool ABAP classZRAP110_BP_TRAVELTP_###.

    The business logic consists of the following steps:

    1. Read the relevant data of the transferred travel instances. Only the fields TravelID and OverallStatus are needed to determine the operation state in the present scenario.
    2. Evaluate the conditions and determine the state of the different operations. The COND operator is used inline in the present scenario for the purpose.
    3. Set the result set appropriately.

    For that, insert the code snippet provided below into the method implementation of the instance feature control method get_instance_features.
    Replace the placeholder ### with your assigned suffix.

    **************************************************************************
    * Instance-bound dynamic feature control
    **************************************************************************
      METHOD get_instance_features.
        " read relevant travel instance data
        READ ENTITIES OF ZRAP110_R_TravelTP_### IN LOCAL MODE
          ENTITY travel
             FIELDS ( TravelID OverallStatus )
             WITH CORRESPONDING #( keys )
           RESULT DATA(travels)
           FAILED failed.
    
        " evaluate the conditions, set the operation state, and set result parameter
        result = VALUE #( FOR travel IN travels
                           ( %tky                   = travel-%tky
    
                             %features-%update      = COND #( WHEN travel-OverallStatus = travel_status-accepted
                                                              THEN if_abap_behv=>fc-o-disabled ELSE if_abap_behv=>fc-o-enabled   )
    
                             %features-%delete      = COND #( WHEN travel-OverallStatus = travel_status-open
                                                              THEN if_abap_behv=>fc-o-enabled ELSE if_abap_behv=>fc-o-disabled   )
    
                             %action-Edit           = COND #( WHEN travel-OverallStatus = travel_status-accepted
                                                                THEN if_abap_behv=>fc-o-disabled ELSE if_abap_behv=>fc-o-enabled   )
    
                             %action-acceptTravel   = COND #( WHEN travel-OverallStatus = travel_status-accepted
                                                                  THEN if_abap_behv=>fc-o-disabled ELSE if_abap_behv=>fc-o-enabled   )
    
                             %action-rejectTravel   = COND #( WHEN travel-OverallStatus = travel_status-rejected
                                                                THEN if_abap_behv=>fc-o-disabled ELSE if_abap_behv=>fc-o-enabled   )
                          ) ).
      ENDMETHOD.                    

    Your source code should look like this:

    Travel Behavior Pool

  2. Save save icon and activate activate icon the changes.

You're through with the implementation.

Exercise 12.2: Preview and Test the enhanced Travel App

^Top of page

Now the SAP Fiori elements app can be tested.

🔵 Click to expand!

You can either refresh your application in the browser using F5 if the browser is still open - or go to your service binding ZRAP110_UI_TRAVEL_O4_### and start the Fiori elements App preview for the Travel entity set.

You can go ahead and test the logic of the dynamic feature control implemented in the backend.

For example, select a travel instance that has the overall status Accepted, and check the state of the Accepted, the Edit, and the Delete buttons. They all shall be disable.

Travel Behavior Pool

Remember the implemented dynamic BO behavior expected on the UI:

  • If a travel instance has the overall status Accepted (A) or Rejected (X), then the button Edit and Delete must be disabled for the given instance.
  • In addition, following toggle behavior (enable/disable) should be displayed for both instance actions:
    • If the overall status Accepted (A), then the action Accept Travel must be disabled.
    • If the overall status Rejected (X), then the action Reject Travel must be disabled.

Summary

^Top of page

Now that you've...

  • defined the dynamic instance feature control for standard and non-standard operations in the behavior definition,
  • implemented it in the behavior pool, and
  • previewed and tested the enhanced Fiori elements Travel app,

you are done with this hands-on. Congratulations! 🎉🎉🎉

In this hands-on session, you have hopefully have some more insights into new RAP features!

Thank you for attending this workshop!

Go to the RAP110 entry page


Appendix

^Top of page

Optional Exercise: Develop and Run a Fiori Application with SAP Business Application Studio

You can follow the tutorial steps to create and deploy a productive version of your Travel app using the SAP Fiori tools in SAP Business Application Studio.