As we saw in the Gateway Service Development Process module, building the Model Definition is our first step. In this demo, we are going to generate our model based on an existing remote RFC. However, to start, we need to create a new project to host our service.
SEGW
Add your project name. When you are creating your project, use Z[your ID]_DEMO_ORDERS
. For the purpose of training, the guide will just use Z_DEMO_ORDERS
.
Fill out the fields below as applicable.
After clicking on the green check button, your new project is created.
Now we can begin creating our data model for the service.
Right click on the Data Model folder and choose Import > RFC/BOR Interface
A wizard will now pop up helping determine which RFC to import, and where the RFC resides (local or remote).
Enter a human readable Entity Type Name: SalesOrder
In our case, we will connect to a separate ECC system.
Choose Remote Function Call
in the Data Souce Type drop down.
We are going to build our service off BAPI_EPM_SO_GET_LIST
.
If your Gateway instance is able to access the RFC, you should be prompted with what fields you want to expose from outputs.
Select the structure labeled SOHEADERDATA[]
. This will select all fields of the structure to expose.
Mark the Sales Order ID as the key for the structure.
Uncheck 'Create Default Entity Set'. We will create our own.
After clicking Finish, our Entity should be fully created into our Data Model.
Now that we have our entity, we can make a collection of that Entity. A collection of SalesOrder entities is called an EntitySet.
SalesOrders
Supply Entity Type Name: SalesOrder
Now, make sure Create/Update/Delete/Paging are all checked as enabled for the entity set.
We now have an Entity SalesOrder
and its corresponding Entity Set SalesOrders
created.
In the same way, go create Entity LineItem
using table SOITEMDATA[]
from BAPI_EPM_SO_GET_LIST
. Mark the keys of the LineItem
entity as well (SO_ID
and SO_ITEM_POS
). Uncheck 'Create Default Entity Set'. Then you can create a new Entity Set LineItems
.
Once your entities and entity sets are created, be sure to Save your progress. You should now see something similar to:
Right click on Associations and choose Create
In the Association Name column, put LineItems
(even though you see something else below). This will eventually be addressable by SalesOrders('x')/LineItems
.
For cardinality of the association, we have 1
Sales Order, which has 0..n
Line Items (since a Sales Order needs to exist to have 0 or more line items related to it).
Now, your associations will be created.
Fantastic. Our Data Model is defined, now we can generate our runtime objects so that the consumers of the service can start inspecting the data model and beginning to understand the relationships between the entities.
You will want to generate runtime objects every time you make changes to your data model or service implementations.
This step requires a Developer key in your SAP system. If you do not have this, you cannot continue.
We are now ready to register our service!