Show TOC

Conversion Handling in OData Channel Locate this document in the navigation structure

 

OData Channel offers a way for applications to delegate handling of conversion exits, currency or units of measurements conversions to the SAP NetWeaver Gateway framework.

Caution Caution

Note that conversion handling functionality is only available in the OData Channel framework that is part of the SAP Business Suite backend system where IW_BEP is deployed, not on the SAP NetWeaver Gateway hub system.

End of the caution.

Conversions for the following operations in inbound and outbound flow are available:

  • Create entity

  • Update entity

  • Read entity

  • Read entity set

Caution Caution

At present, there is no support for conversion of URL parameters.

For example, for a Read operation the Id fields with a conversion exit have to be converted by application coding. If you have an outbound conversion of Id 0100000000 to 100000000 and try out the input conversion by executing /sap/opu/odata/sap/my_test/Id('100000000') then the method GetEntity can not find the instance, because the Id is 100000000 instead of 0100000000. The self link you get in the feed then has the external representation /sap/opu/odata/sap/my_test/Id('100000000'). For this the application has to provide conversion handling.

End of the caution.

The following types conversions are covered:

  • Conversions exits (for example, ALPHA)

  • Conversion of currency/unit code between SAP internal and external (ISO) ones

  • Conversion of currency amounts (for example, a currency amount stored internally as 100.00 may de-facto mean 10.000 if it is about Japanese Yen)

If no conversion exit is registered, the SAP NetWeaver Gateway framework uses the IDOC function modules CURRENCY_AMOUNT_SAP_TO_IDOC and CURRENCY_AMOUNT_IDOC_TO_SAP for amount conversion. However, these function modules only work correctly for amounts with two decimal places. For currency and unit of measure, the SAP NetWeaver Gateway framework always uses the global data type conversions (methods for outbound and inbound flow of CL_GDT_CONVERSION). You can use method DISABLE_CONVERSION of the current property object to disable the property conversion that is otherwise performed automatically by the SAP NetWeaver Gateway framework. You can also use method ENABLE_CONVERSION to enable the conversion at property level. Be aware that you can only enable the conversion if method SET_NO_CONVERSION is not used for the entire model. Once set, the conversion for the affected property is valid for inbound and outbound flow. The conversion of a property must be disabled in the following cases:

  • An amount does not have exactly two decimal places. In this case your data provider is responsible for converting this amount.

  • The OData consumer wants to work with SAP unit of measure or currency and not with ISO codes.

API

In the model provider class the programming interfaces are available for the application to specify that an automatic call of conversion routines is desired. Either a direct API or an indirect API can be used.

Direct API

For each entity field the following methods are available in the /IWBEP/IF_MGW_ODATA_PROPERTY interface:

  • SET_CONVERSION_EXIT

    Sets the name of conversion exit to be called for the property.

  • SET_SEMANTIC

    Marks the property as currency code or unit of measurement field.

  • SET_UNIT

    Sets the relation between the amount field and the field containing currency or unit code.

  • ENABLE_CONVERSION

    Enables the conversion for the property.

  • DISABLE_CONVERSION

    Disables the conversion for the property.

Indirect API

Alternatively, applications can use method BIND_STRUCTURE either for an entity type or for a complex type (/IWBEP/IF_MGW_ODATA_CMPLX_TYPE) to tell the framework to take over the conversion information from the corresponding ABAP Dictionary structure. The optional parameter IV_BIND_CONVERSIONS has to be set to X.

More Information

For general information on conversion functionality see Input and Output Conversions.