Internal and External Data Formats at the Interface

Use

BAPIs are not end user interfaces, they are programming interfaces that can be used in the most diverse application areas, for instance, to connect non-SAP systems or PC products to the R/3 System. To meet the requirements of this diverse range of applications, a shared strategy for representing data in the BAPI interface must be used.

General Guidelines

Fields in BAPI parameters must be presented in the internal form used in the database and not in a form formatted in the BAPI interface. Because of the reasons above, BAPIs should not carry out data conversions between the internal and external data formats, except in the circumstances outlined below.

For example, the date in a BAPI must be in the internally used format YYYYMMDD, where YYYY is the year, MM the month and DD the day.

The graphic below shows the BAPI programming interface where data is transferred at the source code level and not at the application interface level.

BAPI Programming Interface

Exceptions

There are, however, exceptions, where the calling program must map and convert the data between the internal and external data formats in a BAPI.

For these exceptions you can generate function modules that can map and, if required, convert between the internal and external data formats. The section Function Modules for Mapping and Converting Between Internal and External Data Formats describes how to generate these function modules. You can use the generated function modules in the source code of your BAPI for the following:

These exception are:

In an R/3 System a currency amount field is only useful when a currency code accompanies it, so that the decimal point in the amounts can be set correctly. Accordingly, a field for the currency code must be assigned to each currency amount field. For example, if two Yen are stored in the field of data type CURR as 0.02, a non-SAP system cannot reasonably be expected to understand these semantics.

All R/3 currency data types have two digits after the decimal point, even though currencies do exist with three digits after the decimal point.

For these reasons, the data type CURR cannot be used in the BAPI interface. Adhere to the following guidelines when using currency amount fields in BAPIs:

You can use two function modules for this conversion. The function module BAPI_CURRENCY_CONV_TO_EXTERNAL converts currency amounts from R/3 internal data formats into external data formats. The function module BAPI_CURRENCY_CONV_TO_INTERNAL converts currency amounts from external data formats into internal data formats.

Like currency amount fields, the decimal point in quantity fields must be converted correctly. A unit of measure field must be assigned to every quantity field.

Quantity fields have no general domain that can be used for BAPI structures.

In some situations an internal technical key is maintained in the database alongside the external key. Examples are work breakdown structure plans or networks in project systems.

You must always use the external key in the BAPI interface.

In R/3 Systems ISO codes are currently supported for language, country, currency, and unit of measure fields.

If you use one or more of these fields in your BAPI you have to make two fields available for each of these fields in the BAPI interface: one field containing the SAP code and another containing its corresponding ISO code. Use the naming convention, Fieldname_for_SAPCode_ISO for the field containing the ISO code.

For example, the field LANGU contains the country codes used internally in R/3, for instance E. The corresponding field for the ISO code would then be named LANGU_ISO and would contain the corresponding ISO code EN.

Implement the BAPI as follows:

Use the domains below for the ISO codes:

Domains for SAP internal codes and ISO codes

Size

ISO Code Domain

SAP Code Domain

Currency key

isocd

waers

Quantity unit

isocd_unit

meins

Language key

laiso

spras

Country key

intca

land1

For every domain there is a data element of the same name.

BAPIs for Converting Between Internal and External Data Formats (Converting Domains)

BAPIs are programming interfaces in which, with a few exceptions, only the internal data format should be used. However, application programmers calling a BAPI from within their program may sometimes require the external format, for example, to display data on the screen. In such cases the calling program must be able to convert between the internal and external data formats.

The calling program can use the following conversion BAPIs to obtain the required data formats:

This BAPI converts the internal data format into the required external data format.

This BAPI converts the external data format into the required internal data format.

Conversion routines are maintained in the ABAP Dictionary for the domains on which the data to be converted are based.

If this is not the case, no conversion takes place and the values are returned unconverted.

The following mapping shows how conversion BAPIs are used.

Conversion BAPIs