How to add Feature Control in ABAP Restful Application Programming Model

Hello,

In this beginner blog post we are going to see how to work with Feature Control – Action in ABAP Restful Application Programming Model.

Dynamic Feature Control with Action

Ref : https://help.sap.com/docs/BTP/923180ddb98240829d935862025004d6/a5055eef86fa492d99a29b3a9c7c2b88.html

Feature Control :

Feature Control is used to control the Fiori UI. Feature Control is used to send information to Services which tells how to display Information or Controls on Fiori UI.

Feature Controls can be Implemented in 2 ways:

  1. Static Feature Control : Static Feature Controls can be used to set field’s properties like if its a mandatory or read only field.
  2. Dynamic Feature Control : With the Dynamic Feature Control state of any control can be controlled based on certain field’s value. Ex: If some button on List report page should be made enable or disable based on certain field’s value. The State of any control can only be determine at runtime.

Instance Feature Control can only be Implemented on when an active Instance is available of Business Object, for EX: only on Edit or Delete state of Business Object.

This can not be implemented with Create state of Business Object because until record is not created till that time active Instance is not available of Business Object.

Feature Control is defined in Behavior Definition. Implementation is done in Class created.

Actions can be defined in Behavior Definition and can be defined with or without Feature Control.

Action without Feature Control : if an Action is defined without Feature Control then there will not be any difference or change in Action for any state of Business Object or for any field value. Ex: If a Button control is implemented then state and functionality of that button will always be same for all Business Object Instances.

Action with Feature Control : If an Action is defined with Feature Control then state of control can be controlled based on Business Object’s field value. Ex: Button control can be made enable or disables based on value.

To Implement dynamic Feature control we need to implement method “get_instance_features”.

Syntax:

action ( features : instance ) <Method Name> result [1] $self;

Step by Step Guide :

Step 1:

Define Action with Instance feature (instance : feature) in Behavior Definition.

Step 2

Implement method with with functionality on button. This method can have any Business Logic based on requirement. in current scenario we are setting field value with True.

Step 3

Implemented method GET_INSTANCE_FEATURES which is responsible to set Controls state (Enable or Disable in our scenario)

Step 4

Run Application:

Scenario : If Student got Admission in college then status set Admitted is set to Yes. If field Got Admitted has value “X” then button will be disabled else button will be Enabled.

Now If student Got Admitted field shows value No then Set Admitted button will be Enabled.

Feature Control with Action always works with List report page and Object Page as well…

Thanks-

Abhishek