Normally, the answer to the question "How do I find a BAPI?"
is quite easy. When you are interested in finding BAPIs for a given object
type (like CompanyCode) or a given appli-cation area, you use the
SAP Interface Repository at http://ifr.sap.com
or the SAP BAPI Explorer (SAPGUI transaction code "BAPI").
But sometimes the question arises in a different context. Suppose somebody
mentions an RFC-enabled Function Module (RFM), e.g. "BAPI_COMPANYCODE_GETDETAIL",
and you want to find the Business Object Repository (BOR) object type
to which this function belongs and its method (BAPI) name. For RFM "BAPI_COMPANYCODE_GETDETAIL",
the answer would be object type name CompanyCode and method name
GetDetail. Not difficult to guess, you might say, since most RFMs
implementing BAPIs follow a naming convention that makes sense. In some
cases, though, the object type is not easily derived from the name of
Why would you ever be interested in this
information anyway? Don't we just call the RFM itself at runtime? Here
are some reasons:
- Knowing the object type to which a BAPI belongs allows you to easily
find other BAPIs for the same object type, even if their RFM names are
totally different from the one you started with.
- A BAPI can be obsolete, but you cannot find that out on the level
of the RFM; you have to look it up in the SAP BAPI Explorer, and for
that you need to know the object type. If a BAPI is obsolete, you usually
want to use its new incarnation (SalesOrder.CreateFromDat1 instead
of SalesOrder.CreateFromData), which can be easily found in the
- A BOR object type may be delegated to one of its sub-types. The subtype
may overwrite a method (BAPI) of its supertype. This implies that you
should not call the RFM that implements the supertype's BAPI, but the
RFM that implements the same BAPI for the subtype.
- The table parameters of an RFM are passed by reference. In the BOR,
on the other hand, the developer of a BAPI can specify whether a table
parameter is "import" (sent to SAP) or "export"
(returned from SAP) or both. This information can speed up your understanding
of the BAPI's interface.
- BOR object types may have general documentation in addition to the
documentation available for each individual BAPI. Needless to say, reading
all available documentation is always a good idea when dealing with
- In the BOR, you can find out whether an IDoc Message Type has been
generated for a BAPI. This would allow you to invoke the BAPI asynchronously
through ALE if you so desire.
Using the BOR Metadata Access Functions
Fortunately, SAP provides a suitable function to help us find the BOR
information based on an RFM name. The name of this function is "SWO_QUERY_API_METHODS"
and it retrieves all BAPIs. Table parameter "API_METHODS" contains
the complete list.
Before calling the function, set the "WITH_OBJECT_NAMES"
parameter to "X". If you worry about performance, consider setting
parameter "WITH_TEXTS" to a space character, which speeds up
the function execution considerably (the default for this parameter is
"X", which means that descriptive texts are retrieved in addition
to what we are interested in).
In order to find the required information,
you look at the "FUNCTION" column of table "API_METHODS"
and check for the RFM name that you are interested in. If you cannot find
it, then this RFM is not a BAPI. Otherwise, column "OBJECTNAME"
contains the object type name ("CompanyCode" in our example)
and column "METHODNAME" the method name ("GetDetail").
You can call "SWO_QUERY_API_METHODS"
in the SAP Function Builder (transaction code "SE37") and scan
the table manually or (in more recent releases) use the Edit/Find
function available on the menu of the Function Builder (when displaying
the table contents).
is RFC-enabled itself (i.e., an RFM), you can also write a utility method
(in Java, for example) that invokes the function from outside of SAP and
returns the desired information. Listing 1 shows some of the client code
that I have used to find the object type and method names for RFM "BAPI_COMPANYCODE_
GETDETAIL", whether the object type is delegated, and whether this
BAPI is obsolete in the SAP system.
I hope that I have convinced you that the
additional BAPI metadata available for an RFM more than pays for the five
minutes required to do the look-up.
ObjectFactory bof = new ObjectFactory(mConnector);
BOMethod bom = bof.getBapiForRfmName("BAPI_COMPANYCODE_GETDETAIL");
if (bom == null)
System.out.println("This RFM does not exist or is not a BAPI.");
System.out.println(bot.getObjectName() + "." +
bom.getName() + "\t" +
bot.isDelegated() + "\t" +
||Finding the BAPI for RFM "BAPI_COMPANYCODE_GETDETAIL"
G. Schuessler is the founder of ARAsoft (www.arasoft.de),
a company offering products, consulting, custom development, and training
to a worldwide base of customers. The company specializes in integration
between SAP and non-SAP components and applications. ARAsoft offers various
products for BAPI-enabled programs on the Windows and Java platforms.
These products facilitate the development of desktop and Internet applications
that communicate with R/3. Thomas is the author of SAP's BIT525 "Developing
BAPI-enabled Web Applications with Visual Basic" and BIT526 "Developing
BAPI-enabled Web Applications with Java" classes, which he teaches
in Germany and in English-speaking countries. Thomas is a regularly featured
speaker at SAP TechEd and SAPPHIRE conferences. Prior to founding ARAsoft
in 1993, he worked with SAP AG and SAP America for seven years. Thomas
can be contacted at firstname.lastname@example.org
or at email@example.com.