Start of Content Area

Function documentation Internal and External Data Formats  Locate the document in its SAP Library structure

Use

BAPIs are not end user interfaces, they are programming interfaces that can be used in diverse application areas, for instance, to connect non-SAP systems and PC products to the R/3 System. To meet the requirements of this diverse range of applications, a common 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.
Reason : The internal format is used since the server cannot anticipate client-specific data.

For example, the date in a BAPI must be in the format used internally, 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

This graphic is explained in the accompanying text

Exceptions

There are exceptions where the calling program has to 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 Converting Between Internal and External Data Formats describes how to generate these function modules. You can use these function modules in the source code of your BAPI for the following:

These exceptions are:

In an SAP System, a currency amount field can only be used when accompanied by a currency code. Only then can the decimal point be set correctly. A currency code field must be assigned to each currency amount field. For example, two yen are stored as 0.02 in the field of data type CURR in the database. Non-SAP systems will not understand this syntax.

All SAP 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 SAP internal data formats into external data formats. The function module BAPI_CURRENCY_CONV_TO_INTERNAL converts currency amounts from SAP external data formats into internal data formats.

Example 

For an example of mapping, see Application Example.

Like currency amount fields, the decimal point in quantity fields and unit of measurement fields must be converted correctly.

A field to indicate the amount or the unit of measure must be assigned to all amount and quantity fields.

Quantity fields have no standard 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.

To convert activity codes in networks, the following function modules are provided:

These conversion transactions are not included in the transactions described in the section Converting Between Internal and External Data Formats.

In an SAP System, 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.

Implement the BAPI as follows:

Domains for SAP internal codes and ISO codes

Always try to use the standard domains listed below for fields. We recommend that you use your own data elements for the fields. If it does not make sense to use your own data elements, use the standard data elements that are listed below.

 

Field

Standard Domains

Standard Data Element

 

Country (SAP code)

LAND1

LAND1

 

Country (ISO code)

INTCA

INTCA

 

Currency (SAP code)

WAERS

CURCY or WAERS

 

Currency (ISO code)

ISOCD

ISOCD

 

Language (SAP code)

SPRAS

SPRAS

 

Language (ISO code)

LAISO

LAISO

 

Unit of measurement (SAP code)

MEINS

MSEHI or MEINS

 

Unit of measurement (ISO code)

ISOCD_UNIT

ISOCD_UNIT

Reason: If standard domains are used, the generated mapping modules automatically convert the ISO code. If you use other domains, you have to manually convert the ISO code in the module modules. See Mapping Between Internal and External Data Formats.

Example

The CustomerData parameter of the FlightCustomer.CreateFromData method contains, in addition to the LANGU field (language key in SAP code, domain: SPRAS), the LANGU_ISO field (language key in ISO code, domain: LAISO).

 

In accordance with ISO standard 8601 dates and times must be transferred between two external systems in Universal Coordinated Time (UTC). UTC is the equivalent of the formerly used term GMT (Greenwich Mean Time) and is now used as the unique time reference across the globe.

In the BAPI interface you have to provide a field for the time zone, that is, the location of an object with respect to its local time, as well as a field for the UTC time stamp. You can also specify the local time.

The naming convention for the UTC time stamp field is <Field name for time zone>_ISO.

The following types are provided for dates and time.

These fields are:

For more information see Address Parameters.

BAPIs for Converting Between Internal and External Data Formats (Domain Conversion)

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 conversion BAPIs to convert data into the required format: These are described in the BAPI User Guide in the section Service BAPIs for General BAPI Functions.