Show TOC

Enabling Actions for OData ConsumptionLocate this document in the navigation structure

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:

Syntax (for LineItem)
  ...
  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>' },
	  ...
	]
    ...
  }
										
Note The dataAction element references the technical name of an action of the BOPF. The string pattern is BOPF:<technical name of action in BOPF>.
Adding Annotations for Quick Action in the Consumption View

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,	
	...
  }			
			
Reactivating the Data Definition of Consumption View

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).

Configuring Action Parameters for OData Consumption

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

  1. If you have not yet already done so, open the editor of the business object (in our case: ZDEMO_I_SALESORDER_TX) and click the Actions tab.
  2. Select the action SET_TO_PAID and choose CTRL + Click to open the Action Overview.
    Opening the action overview to add configuration details
    Figure 1: Opening the action overview to add configuration details
  3. Specify the following details:
    • Exporting Type: Select Node from the list box, since the action operates on the business object’s node.

      This option allows the action to return instances of a node that is defined by the following two fields:

      • Exporting Parameter BO: Enter the name of the business object.
      • Exporting Parameter Node: Enter the name of the business object node (in our case: the same name as for the business object).
    • Exporting Multiplicity: Select 1 from the list box. For the resulting OData service we want to allow the action to operate on a single sales order node only.
      Added details for configuration
      Figure 2: Added details for configuration
  4. Leave the other details unchanged and save the changed entries.
  5. Activate the business object.

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.