When App Connect makes a request to an SAP OData service, the response is returned as an OData collection of structured entries. The entries are enriched with a __metadata name/value pair whose value is a JSON object of name/value pairs. For more information about __metadata, see the OData documentation.

An OData collection is typically represented as an Atom feed with an XML-based format, or as an array of JSON objects, as shown in the following examples.

Example 1: OData V2 XML-based Atom format for an SAP OData service response

In this response, an XML format was returned for this sample API call (made via a browser):
https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet?$top=1

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/">
  <id>
    https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet
  </id>
  <title type="text">BusinessPartnerSet</title>
  <updated>2019-07-02T21:19:01Z</updated>
  <author>
    <name/>
  </author>
  <link href="BusinessPartnerSet" rel="self" title="BusinessPartnerSet"/>
  <entry m:etag="W/"datetime'2019-07-02T20%3A52%3A24.0000000'"">
    <id>
      https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000000')
    </id>
    <title type="text">BusinessPartnerSet('0100000000')</title>
    <updated>2019-07-02T21:19:01Z</updated>
    <category term="GWSAMPLE_BASIC.BusinessPartner" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
    <link href="BusinessPartnerSet('0100000000')" rel="edit" title="BusinessPartner"/>
    <link href="BusinessPartnerSet('0100000000')/ToSalesOrders" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ToSalesOrders" type="application/atom+xml;type=feed" title="ToSalesOrders"/>
    <link href="BusinessPartnerSet('0100000000')/ToContacts" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ToContacts" type="application/atom+xml;type=feed" title="ToContacts"/>
    <link href="BusinessPartnerSet('0100000000')/ToProducts" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ToProducts" type="application/atom+xml;type=feed" title="ToProducts"/>
    <content type="application/xml">
      <m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
        <d:Address m:type="GWSAMPLE_BASIC.CT_Address">
          <d:City>Walldorf</d:City>
          <d:PostalCode>69190</d:PostalCode>
          <d:Street>Dietmar-Hopp-Allee</d:Street>
          <d:Building>16</d:Building>
          <d:Country>DE</d:Country>
          <d:AddressType>02</d:AddressType>
        </d:Address>
        <d:BusinessPartnerID>0100000000</d:BusinessPartnerID>
        <d:CompanyName>SAP</d:CompanyName>
        <d:WebAddress>http://www.sap.com</d:WebAddress>
        <d:EmailAddress>do.not.reply@sap.com</d:EmailAddress>
        <d:PhoneNumber>0622734567</d:PhoneNumber>
        <d:FaxNumber>0622734004</d:FaxNumber>
        <d:LegalForm>SE</d:LegalForm>
        <d:CurrencyCode>EUR</d:CurrencyCode>
        <d:BusinessPartnerRole>01</d:BusinessPartnerRole>
        <d:CreatedAt>2019-07-02T20:52:24.0000000</d:CreatedAt>
        <d:ChangedAt>2019-07-02T20:52:24.0000000</d:ChangedAt>
      </m:properties>
    </content>
  </entry>
</feed>

Example 2: OData V2 JSON format for an SAP OData service response

For this response, an OData JSON format was requested using the $format query parameter in the sample request call:
https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet?$top=1&$format=json

{
  "d" : { 
    "results":  [ 
      { 
        "__metadata": {
            "id":"https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000000')",
            "uri":"https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000000')",
            "type":"GWSAMPLE_BASIC.BusinessPartner",
            "etag":"W/\"datetime'2019-07-02T20%3A52%3A24.0000000'\""
        },
        "Address":{"__metadata":{"type":"GWSAMPLE_BASIC.CT_Address"},"City":"Walldorf","PostalCode":"69190","Street":"Dietmar-Hopp-Allee","Building":"16","Country":"DE","AddressType":"02"},
        "BusinessPartnerID":"0100000000",
        "CompanyName":"SAP",
        "WebAddress":"http://www.sap.com",
        "EmailAddress":"do.not.reply@sap.com",
        "PhoneNumber":"0622734567",
        "FaxNumber":"0622734004",
        "LegalForm":"SE",
        "CurrencyCode":"EUR",
        "BusinessPartnerRole":"01",
        "CreatedAt":"\/Date(1562100744000)\/",
        "ChangedAt":"\/Date(1562100744000)\/",
        "ToSalesOrders":{"__deferred":{"uri":"https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000000')/ToSalesOrders"}},
        "ToContacts":{"__deferred":{"uri":"https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000000')/ToContacts"}},
        "ToProducts":{"__deferred":{"uri":"https://192.0.2.0:8000/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/BusinessPartnerSet('0100000000')/ToProducts"}}
            }
        }
    }
}

Accessing or exposing OData __metadata information in an SAP OData service response

In App Connect, the OData __metadata information is available as an odata_details object, but is not explicitly exposed for mapping because it’s not used routinely, and requires an understanding of OData metadata. If you have an advanced use case requirement for this metadata, you can access or expose it either by using the JSON parser or a JSONata expression.

Using a JSON parser node in the flow

The following example shows a set of standard response fields that were returned for a sample SAP OData Retrieve action.

  • Example of standard response fields for an SAP OData Retrieve action

    Standard response fields for a sample SAP OData Retrieve action

To expose the odata_details object in the response, you can use a JSON parser node to parse the response from your SAP OData node by providing sample output schema for the OData metadata.

  • Example of JSON parser node entries

    Sample output schema for the OData metadata in the JSON parser

The JSON parser response will then expose the odata_details object and object properties, as shown in the following example, and you can directly map to the odata_details properties in the JSON parser response:

  • Example of standard response fields and metadata fields exposed by a JSON parser

    Standard response fields and metadata fields exposed by a JSON parser

Using a custom JSONata expression to reference the odata_details object

You can directly add odata_details in a JSONata expression by using the following notation:
$SAPNodeResponse_property.odata_details

  • Type a JSONata expression directly into a field with .odata_details appended.

    Typed JSONata example

  • Edit a mapped value in a field to append .odata_details.

    Mapped JSONata example

Join The Discussion

Your email address will not be published. Required fields are marked *