Create a Simple OData Interface
- How to create a simple OData interface
- How to set up monitoring of an OData service in SAP Application Interface Framework
Prerequisites
- You’ve set up SAP Application Interface Framework
- SAP S/4HANA 1709 or later
- You have set up SAP Gateway and registered the basic OData sample service for SAP Gateway, see Registering Sample Service - Basic
In this tutorial, you will learn how to create a simple SAP Application Interface Framework interface that enables you to monitor an OData service. In our example, we use the basic OData sample service GWSAMPLE_BASIC.
- Step 1
If you’ve completed other tutorials for SAP Application Interface Framework, you might already have created a package. In this case, you can skip this step.
Create a package that serves as the destination for your newly created objects.
- Open your system and navigate to the Object Navigator (transaction code
SE80
). - From the drop-down menu, choose Package and enter the name
ZDEMO
. Press Enter or choose Display or Create Object. - Confirm the dialogue window, enter a meaningful short description for your new package, and select Confirm. If prompted, enter a workbench request and confirm again.
You have successfully created a new package named
ZDEMO
.Log in to complete tutorial - Open your system and navigate to the Object Navigator (transaction code
- Step 2
Next, create a new structure in ABAP Dictionary to be used in your interface later.
Run the ABAP Dictionary (transaction code
SE11
) and create a new structure namedZDEMO_ODATA_SALES_ORDER
.Enter the Data type name
ZDEMO_ODATA_SALES_ORDER
and choose Create.In the upcoming dialog, select the
Structure
radio button. Choose Continue.Enter a short description.
Switch to the Components tab and maintain the following structure:
Component Typing Method Component Type ODATA_STD
Types /AIF/ODATA_STD_RAW_FLDS_S
PAYLOAD
Types CHAR_132
The DDIC structure needs to contain a component of type
/AIF/ODATA_STD_RAW_FLDS_S
and a component of any type that can be used to display the payload.Save and activate your changes.
Log in to complete tutorial - Step 3
As interfaces in SAP Application Interface Framework are grouped using namespaces, you must create a namespace.
Go to Customizing for SAP Application Interface Framework (transaction code
/n/AIF/CUST
) and navigate to Interface Development > Define Namespace.Select New Entries and enter the following name and description for your new namespace:
Namespace Namespace Description DEMO_4
Namespace for AIF OData tutorials
Log in to complete tutorial - Step 4
Now it’s time to create an interface using the structure you created before.
While still in Customizing (transaction code
/n/AIF/CUST
), navigate to Interface Development > Define Interfaces.In the upcoming dialog, enter your previously created namespace
DEMO_4
and press Enter.Select New Entries and enter the following parameters based on your previously created structure:
Field name Description Value Interface Name Name of the interface to be created SALESORD
Interface Version Version number of the interface 1
Description Description of the interface Sales Order interface for OData tutorial
SAP Data structure Input substructure of the RFC ZDEMO_ODATA_SALES_ORDER
Raw Data structure Input structure of the RFC ZDEMO_ODATA_SALES_ORDER
Interface Direction Indicates the direction of the interface Inbound
Save your changes.
Log in to complete tutorial - Step 5
Next, select the engines that should be used to handle the messages that are processed.
While still in Customizing (transaction code
/n/AIF/CUST
), navigate to Interface Development > Additional Interface Properties > Specify Interface Engines.In the upcoming dialog, enter your previously created namespace
DEMO_4
and press Enter.If your namespace contains more than one interface, select interface
SALESORD
of version1
. If not, your interface is already displayed.Change the values for the following engines:
Parameter Value Application Engine OData application engine
Persistence Engine OData persistency engine
Selection Engine AIF Index Tables
Logging Engine OData logging engine
Save your changes.
Log in to complete tutorial - Step 6
Next, you need to assign the OData service to the interface.
While still in Customizing (transaction code
/n/AIF/CUST
), navigate to Interface Development > Additional Interface Properties > Define OData Services.In the upcoming dialog, enter your previously created namespace
DEMO_4
, and press Enter.If your namespace contains more than one interface, select interface
SALESORD
of version1
. If not, your interface is already displayed.For oData Service Name, enter
GWSAMPLE_BASIC
.Save your changes.
Log in to complete tutorial - Step 7
It’s recommended to implement an interface-specific single index table to ensure full flexibility, especially if you expect a high load of messages or if you plan to define key fields for your interface (now or later).
You can also switch the single index table later, but when you do, all processed messages stored in the old single index table will no longer be visible in the Interface Monitor. The information for the newly incoming messages is stored in the new single index table of the interface.
Create a table via transaction
SE11
. You can use table/AIF/T_ODATA_IDX
as a template by entering/AIF/T_ODATA_IDX
in the field Database table, right-clicking it and selecting Copy…. Enter the nameZSO_MON_IDX
for the new table and select Continue. When prompted, enter packageZDEMO
, which you created earlier.After creating the single index table, activate it by selecting Display and then Activate.
Go to Customizing (transaction code
/n/AIF/CUST
) and navigate to SAP Application Interface Framework > Error Handling > Define Namespace-Specific Features. Enter your namespaceDEMO_4
and select Continue.Select New Entries to create a new entry in Define Interface-Specific Features. Enter your interface name
SALESORD
and version1
and enter the name of the newly created single index tableZSO_MON_IDX
in the field Message Index Table.Save your changes.
Log in to complete tutorial - Step 8
If you want to monitor the newly created interface in the Interface Monitor of the Message Dashboard app, you need a recipient for the interface.
While still in Customizing (transaction code
/n/AIF/CUST
), navigate to SAP Application Interface Framework > Error Handling > Define Namespace-Specific Features. Enter or select your namespaceDEMO_4
and choose Continue.In the menu on the left, navigate to Define Recipients by double-clicking it. Choose New Entries, enter the name
ZODATA_TEST_RECIPIENT
for your new recipient, and add a meaningful description.Save your changes.
Log in to complete tutorial - Step 9
To be able to see any data in the Interface Monitor or the Message Dashboard, a recipient must be assigned to the interface they want to monitor.
While still in Customizing (transaction code
/n/AIF/CUST
), navigate to SAP Application Interface Framework > Error Handling > Define Interface-Specific Features. Enter or select your namespaceDEMO_4
, as well as your interface nameSALESORD
and interface version1
. Choose Continue.In the menu on the left, double-click Assign Recipients Without Key Fields and create a new entry. Enter or select the namespace and the recipient you created before.
Save your changes.
Log in to complete tutorial - Step 10
Now the users in charge of monitoring the OData service must be assigned to the recipient.
Run transaction
/AIF/MYRECIPIENTS
and create a new entry.Select the namespace
DEMO_4
and recipientZODATA_TEST_RECIPIENT
you created in the steps before.Check the boxes for Overview and Technical User.
Save the new entry.
Log in to complete tutorial - Step 11
The OData logs are passed to SAP Application Interface Framework via the OData transfer job. First, you need to create a variant of the respective program for the particular OData service.
Run the ABAP Editor (transaction code
SE38
) and enter/AIF/ODATA_TRANSFER_JOB
in the Program field. Select the Variants radio button, and choose Display.On the next screen, enter a name for the variant, here
SALES_ORDER
, and choose Create.On the next screen, enter the Service Name
GWSAMPLE_BASIC
and choose Attributes.Finally, enter a description.
Save your changes.
Log in to complete tutorial - Step 12
After creating a variant of the OData transfer job, you need to schedule the respective program to collect the OData logs and pass them on to SAP Application Interface Framework.
For demo purposes, you may also directly execute the program with variant instead of scheduling a background job once you have sent an erroneous sample message. In this case you can skip this chapter.
Run the Define Background Job (transaction code
SM36
).
Enter the job nameODATA_TRANSFER_JOB
and choose Start condition.In the upcoming Start Time dialog, choose Immediate, which selects the Immediate Start flag. At the bottom of the dialog, choose Period values and enter a time value after which the job should be started periodically, for example, every
5 mins
. The option Periodic Job is now selected. Save your changes.To maintain the program, choose Step from the toolbar.
In the Create Step dialog, enter the program name
/AIF/ODATA_TRANSFER_JOB
and the previously created variantSALES_ORDER
. Then save.Click on Back, and then save. This will schedule the background job to run on a regular basis.
Log in to complete tutorial - Step 13
By default, only technical errors are logged in the SAP Gateway error log. To also add business-related errors, you need to change the log level.
Open the SAP Gateway: Error Log (transaction code
/IWFND/ERROR_LOG
) and navigate to Error Log > Global Configuration.In the Global Configuration, change the Error Log level to
Full
.Save your changes.
Log in to complete tutorial - Step 14
Before you can send sample requests, you need to determine the service endpoint.
Navigate to Activate and Maintain Services (transaction code
/IWFND/MAINT_SERVICE
), select the serviceGWSAMPLE_BASIC
with technical service nameZGWSAMPLE_BASIC
, and choose Call Browser.A browser window opens, displaying the service entities. From here, the basic endpoint URL can be gathered. In this tutorial, we use the
SalesOrderSet
collection.Since you’ll need the service endpoint in the next step, copy it or leave the window open.
Log in to complete tutorial - Step 15
Let’s send in sample requests to test the SAP Application Interface Framework interface. Use a test client of your choice to call the OData service to fetch the details of a particular sales order. If you use Postman, create a new GET request, and enter the end point URL of your OData service into the address field, see previous step Determine service endpoint above.
The URL should have the following format with host and port of your backend system and a particular sales order ID:
https://host:port/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/SalesOrderSet('id')
Enter the user credentials in your test client to log on to your backend system.
Let’s first run a successful request. Select a sales order ID that exists, e.g.
0500000000
. In this case, a response with http status code200
containing the sales order details should be returned. Since SAP Gateway doesn’t log successful messages, you won’t find a new entry in the message monitoring.Now, force an error by selecting a sales order ID that doesn’t exist, for example
1500000000
. In this case, you get an http error code400 Bad Request
.
Log in to complete tutorial - Step 16
Finally, test your settings and verify that the OData monitoring is working as planned.
If you’re using SAP GUI, check the results of your test in the Interface Monitor (transaction code
/n/AIF/IFMON
).If you don’t see the new interface, check that your user is correctly assigned to the recipient as described in step Assign users to recipient.
Select the summary line for your interface. You’re forwarded to Monitoring and Error Handling, which shows your selected test message(s).
Alternatively, if you’ve set up Message Monitoring in the SAP Fiori launchpad, you can check the test results there. See How to configure the SAP Fiori Apps for SAP Application Interface Framework.
Congratulations! You’ve created a simple OData interface and set up monitoring for it in SAP Application Interface Framework.
Log in to complete tutorial - Step 17
Why do you need to change the log level of the OData service configuration?
Log in to complete tutorial
- Create package
- Create structure in ABAP Dictionary
- Create namespace
- Create interface
- Specify interface engines
- Define OData services
- Create interface-specific single index table
- Create recipient for interface
- Assign recipient to interface
- Assign users to recipient
- Create variant for OData transfer job
- Define background job
- Change log level
- Determine service endpoint
- Send sample requests
- Monitor OData interface
- Test yourself