Creating a well-defined SAP Gateway OData service for use with IBM App Connect

Learn how to create a well-defined SAP Gateway OData service, as part of the general requirements for SAP OData, to enable IBM® App Connect to pass key information between a SAP OData system and your apps.

About this task

As part of the general requirements for connecting SAP OData to App Connect, the SAP Gateway OData service must conform to the following requirements:

  • Define your SAP objects without relationships. The SAP OData connector in App Connect does not support object relationships. If your SAP service is defined with object relationships, then App Connect lists your SAP objects for CRUD operations, but ignores the relationship information.
  • Ensure that your SAP Gateway OData service is enabled with sap:creatable:true flag. If sap:creatable:false is used, then App Connect ignores the objects identified from your SAP service for CREATE operations; however your objects will be available for RETRIEVE, UPDATE, and DELETE operations.
  • Ensure that the operations are implemented for the service. App Connect uses a SERVICE_URL/metadata call to obtain a list of operations to display. But it does not verify if the obtained operations are implemented.
  • Ensure that an object property that you want to use does not have sap:filterable="false". If all the fields of an object have sap:filterable='false' then App Connect won't support the RETRIEVE operation.
  • Ensure that your SAP objects do not have composite keys. (Composite keys are currently not supported by App Connect.) Example of a Customer object with composite key
             <EntityType Name="Customer" sap:content-version="1">
                <Key>
                   <PropertyRef Name="Customerno" />
                   <PropertyRef Name="PiSalesorg" />
                </Key>
                <Property ...
    

For general information about connecting SAP OData to App Connect, see How to use IBM App Connect with SAP (via OData) . For more information about the SAP Gateway and OData, see the SAP Help Portal; for example: SAP Gateway and OData

Procedure

To configure a well-defined SAP Gateway OData service, complete the following steps in your SAP system. These steps cover the general procedure, but need some consideration for your own SAP OData system and your preferred techniques for configuring SAP.

  1. Display the SAP Gateway Service Builder (transaction SEGW)
  2. Create a project
    Figure 1. Select Create Project
    Select Create Project
  3. Configure details for the project
    Chose a project name, give your project a description, select Standard generation strategy, and specify the package. The project will be saved as a local object (Package: $TMP, or click Local Object.)
    Figure 2. Create Project, specify details
    Create Project, specify details
  4. Create the Entity type by importing a pre-defined DDIC Structure for the Order header.
    Right-click Data Model, and then select Import > DDIC Structure.
    Figure 3. Data Model, Import > DDIC Structure
    Data Model, Import > DDIC Structure
  5. Choose the required structure.
    If the Sales order structure is not available in your SAP system, select the ABAP structure ZST_VBAK. Click Next.
    Figure 4. Import from DDIC Structure, step 1 of 3
    Import from DDIC Structure, step 1 of 3
  6. Choose the required fields, and then click Next.
    Figure 5. Import from DDIC Structure, step 2 of 3
    Import from DDIC Structure, step 2 of 3
  7. Select the key field, VBELN, and then click Finish.
    Figure 6. Import from DDIC Structure, step 3 of 3 Result: You should now see the new Entity that has been created.
    Import from DDIC Structure, step 3 of 3 Result: You should now see the new Entity that has been created.
  8. Repeat the same sequence of steps from 4 to 7 to import the next structure, OrderStatus.
    This structure might be an Item structure. The following example shows the import of another custom structure called ZST_SO_STATUS.
    1. Second Import from DDIC Structure, step 1 of 3
      Second Import from DDIC Structure, step 1 of 3
    2. Second Import from DDIC Structure, step 2 of 3
      Second Import from DDIC Structure, step 2 of 3
    3. Second Import from DDIC Structure, step 3 of 3
      Second Import from DDIC Structure, step 3 of 3
    When you have completed the preceding steps, you should see the two newly-created Entity Types: OrderStatus and SalesOrder:
    Figure 7. Result of Import from DDIC Structures – The two newly-created Entity Types: OrderStatus and SalesOrder
    Result of Import from DDIC Structures – The two newly-created Entity Types: OrderStatus and SalesOrder
  9. Create the Entity Sets for the entity types that you have just created.
    1. Right-click the folder Entity Sets, and then select Create.
      Figure 8. Create Entity Sets
      Create Entity Sets
    2. Create an Entity Set SalesOrderSet for the entity type SalesOrder.
      (A naming convention is to make the Entity Set name by appending ‘_Set’ to the Entity Type name.)
      Figure 9. Create Entity Set SalesOrderSet for the entity type SalesOrder
      Create Entity Set SalesOrderSet for the entity type SalesOrder
    3. Create an Entity Set OrderStatusSet for the entity type OrderStatus:
      Figure 10. Create Entity Set OrderStatusSet for the entity type OrderStatus
      Create Entity Set OrderStatusSet for the entity type OrderStatus
    You should now see the newly-created entity sets:
    Figure 11. The newly-created Entity Sets
    The newly-created Entity Sets
  10. Create the Associations which sets the cardinal rules, and then click Next.
    Figure 12. Create Association, step 1 of 3
    Create Association, step 1 of 3
  11. Set the Dependent Property, Vbeln, and then click Next.
    Figure 13. Create Association, step 2 of 3
    Create Association, step 2 of 3
  12. Click Finish.
    Figure 14. Create Association, step 3 of 3
    Create Association, step 3 of 3
  13. Click Save.
    Figure 15. Save the changes made
    Save the changes made
  14. Check Consistency. Right-click ZORDER_MAINTAIN and then select Check Consistency:
    Figure 16. Check Consistency
    Check Consistency
  15. Generate runtime objects
    To use the service with the changes that you have made, you need to generate the runtime objects. This creates the underlying ABAP classes that contain all the information that you've specified in the service builder. Click the Generate Runtime Objects icon or right-click ZORDER_MAINTAIN and then select Generate Runtime:
    Figure 17. Generate Runtime Objects
    Generate Runtime Objects

    While generating the runtime objects, the class and service details are generated as shown below.

    Figure 18. Generate Runtime Objects – Model and Service Definition
    Generate Runtime Objects – Model and Service Definition
  16. Choose the package for the objects.
    Figure 19. Generate Runtime Objects – Create Object Directory Entry
    Generate Runtime Objects – Create Object Directory Entry
    Now, you should see that the runtime objects were created successfully:
    Figure 20. Messages confirming that the runtime objects were created
    Messages confirming that the runtime objects were created

    This completes the design stage. Next, you need to develop the code as part of the implementation.

  17. Expand the Runtime Artifacts folder.
    Figure 21. Expand the Runtime Artifacts folder
    Expand the Runtime Artifacts folder
  18. Double-click the Data Provider Class Extension (DPC_EXT)
    Figure 22. Double-click the Data Provider Class Extension (DPC_EXT)
    Double-click the Data Provider Class Extension (DPC_EXT)
  19. Implement the insert method
    Because more than one structure or table is involved, you need to implement the method '/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY' for implementing CREATE (POST) functionality for deep insert. However, for single insert, you can use the CREATE_ENTITY method.
    1. To implement the method, first click the Change Mode icon:
      Figure 23. Click the Change Mode icon
      Click the Change Mode icon
    2. Select the method:
      • Deep Insert (Nested)
        Figure 24. Select the Deep Insert method
        Select the Deep Insert method
      • Independent Insert Implement separate CREATE ENTITY methods as shown below:
        Figure 25. Select the Independent Insert method
        Select the Independent Insert method
    3. After selecting the method, click the Redefine icon.
      Figure 26. Click the Redefine icon to redefine and edit the method
      Click the Redefine icon to redefine and edit the method

      The method has been redefined and is available to code the business logic.

    4. Add the business logic for your requirements.
      Figure 27. Add business logic to the method
      Add business logic to the method
    After completing the logic development, the CREATE functionality is complete.
  20. Register the service Use Service Registration: Transaction: /IWFND/MAINT_SERVICE
    1. In the Activate and Maintain Service window, click Add Service
      Figure 28. Activate and Maintain Service window – Add Service
      Activate and Maintain Service window – Add Service
    2. Get the Technical service name from the transaction SEGW.
      The Runtime artifact which ends with 'SRV' in SEGW refers to the Technical Service; for example:
      Figure 29. Example runtime artifact in SEGW that refers to the Technical Service
      Example runtime artifact in SEGW that refers to the Technical Service
    3. In the next screen, specify the System Alias (created by Basis) and the new service which has been created.
      After that, click the Get Services icon. The result is displayed:
      Figure 30. Result: New service has been added
      Result: New service has been added
    4. Click Add Selected Services.
      This adds the service so that it can be used by App Connect.

Results

A well-defined SAP Gateway OData service has been created so that it can be used by App Connect.