Actions are often directly related to BO instances that you can see in a table with sales order records, for example. End users can select as a line item (that represents a BO instance) and execute certain actions on the selected item.
You can use the following UI annotation to expose actions to the consumer:
... define view <CDS_VIEW> as select from <DATA_SOURCE> as .. { @UI.lineItem: [ { type: #FOR_ACTION, dataAction: 'BOPF:<BO_ACTION_1>', label: '<ACTION_LABEL_1>' }, { type: #FOR_ACTION, dataAction: 'BOPF:<BO_ACTION_2>', label: '<ACTION_LABEL_2>' }, ... ] ... }
In our example, we add 'BOPF:SET_TO_PAID' as dataAction element to the consumption view:
... define view ZDEMO_C_SalesOrder_TX as select from ZDEMO_I_SalesOrder_TX as Document { @UI.lineItem.position: 10 @UI.lineItem: [ { type: #FOR_ACTION, position: 1, dataAction: 'BOPF:SET_TO_PAID', label: 'Set to Paid' } ] key Document.SalesOrder, ... }
To publish the new metadata to the OData service, activate the data definition that implements the consumption view (in our case: ZDEMO_C_SalesOrder_TX).
To make the action available for consumption in the OData service, the following configuration steps in the BO editor are required. Otherwise, the action would be unknown in the OData consumption layer.
Procedure
This option allows the action to return instances of a node that is defined by the following two fields:
Results
The BOPF framework assigns the configuration details to the action. As a result of this configuration procedure, the action will be exported as an additional function to the OData consumption layer.