
The Open Data Protocol (OData) includes standard CRUD (Create, Retrieve, Update, and Delete) operations that map to the HTTP methods POST, GET, PUT/MERGE, and DELETE.
In addition, OData supports further service operations (function imports) that can be invoked by the HTTP methods GET or POST for anything that cannot be mapped to the standard CRUD operations. You can implement such additional service operations in the Service Builder by creating function imports within your data model.
For example, you could create function imports for the following custom operations:
Confirm Work Item
Check Flight Availability
While it is simple to create new function imports to invoke custom operations, if the operation you want to use can be invoked using a standard CRUD operation, you should not create a function import. That is, you should only create function imports for custom operations that cannot be invoked using a standard operation.
To create a function import for a custom operation, proceed as follows:
Right click the Data Model folder, and choose Create, and then select Function Import.
Also, you can create a new Function Import when you right click the function import folder, and choose Create.
The Create Function Import dialog opens.
Specify the Function Import name.
Alternatively, use the following steps:
Open the Service Builder project in which you want to create a function import.
Expand the Data Model folder and double-click the Function Imports subfolder. The mass maintenance view for function imports is displayed.
Choose Edit and Add Line to create an entry for the new function import.
Enter a name for the function import you want to create, for example, CheckFlightAvailabilty. You must enter a name in this field to proceed with the creation process.
Select the kind of return type (if any) you want the function import to return data at runtime.
Possible entries are:
Complex type
Entity type
No return (no data returned)
In the Return Type column, enter the name of the complex type or entity type you want the function import to return. You can use the input help to select an existing complex type or entity type from your project. If the input help is empty, you must first create the relevant complex type or entity type in your project. If you selected No Return as the Return Type Kind, this field is not ready for input and has a grey background.
In the Return Cardinality column, select the number of complex type or entity type instances you want to be returned.
If you want more than one entity type instance to be returned, you must enter the entity set that is to be used for this purpose in the Return Entity Set column. In any other case, you are not required to specify an entity set and as such the field is not ready for input and has a grey background.
Select the HTTP method to be used to invoke the function import. If you do not select an HTTP method, the caller may invoke the function import using the GET or POST method.
Select the entity type to which the function import applies semantically as an action. While this setting has no effect at runtime, it can help the consumer of the service to ascertain the purpose of the function import or determine which function imports belong to a particular entity type.
Choose Save to create the new function import and invoke the custom operation at runtime.