P. 1
A Tutorial on BAPI

A Tutorial on BAPI

|Views: 5,453|Likes:
Published by api-27047119

More info:

Published by: api-27047119 on Oct 18, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less






BAPIs are programming interfaces 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. In particular, the use of values that
affect Customizing or are language dependent must be avoided.

BAPIs are programming interfaces, not application interfaces. Fields such as a date field,
should not be used in the BAPI interface in any other format than the format used in the
database, i.e. YYYYMMDD, where YYYY is the year, MM the month and DD the day.


Because of the reasons above, BAPIs should only carry out data conversions between the
data format used in the database and external formats used by the calling program in
exceptional circumstances.

These exceptions are listed below. To convert data formats in these exceptional
circumstances, you can use the transaction described in Converting Between Internal and
External Data Formats.

These exceptions are:

Currency amount fields

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 must not use parameters and fields of data type CURR in the interface

- All parameters and fields for currency amounts must use the domain BAPICURR

- The position of the decimal point in currency amount fields must be converted

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.

Quantity fields

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.

Internal keys

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

_________ __________________________________________________________________

A Tutorial on Business Application Programming Interface_____________________________

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

ISO codes

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:

- When you export data from the BAPI both fields must contain corresponding values.

- When you import data into the BAPI the ISO code is only significant if no value was
given in the SAP code.

Use the domains below for the ISO codes:

Domains for SAP internal codes and ISO codes


ISO Code Domain

SAP Code Domain

Currency key

Unit of measure

Language key

Country key









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

BAPIs for Converting Between Internal and External Data Formats (Converting

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 following conversion BAPIs exist for this purpose. The calling program uses them 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.

_________ __________________________________________________________________

A Tutorial on Business Application Programming Interface_____________________________

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->