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.
Procedure
To create a function import for a custom operation, proceed
as follows:
- Right click the Data Model folder, and select
Create and then select Function Import.
The Create Function Import dialog opens.
- In Return Type Kind column select the kind of return
type (if any) you want the function import to return data at runtime.
- 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 will not take an 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.
- In Action for Entity Type column 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 import belong to a particular
entity type.
- In the Label column, you can enter a label for the new
function import. You can enter a free-text label directly or use the
Label Text Reference Editor to enter the reference
type (program, data element, or class). The reference type you select
influences the other input fields (Object Name, Key, and
Label) you have to edit.
- Specify the Function Import name. Function Imports opens in mass maintenance view.
Do the following in mass maintenance view: You can create a subsequent function
import when you right click Function Import folder and select Create and follow above
procedure.
Alternatively, In the mass maintenance view of Function Imports, click
(Display<->Change) and then
(Insert Row) to add new Function Import.
Note To delete a function
import select the relevant function import row from the mass maintenance view and
click

(Delete Row)
- Click Save to save the changes and invoke the custom operation
at runtime.