EXPERT RESPONSE
1. A BAPI function is indeed an RFC function module and can be called from an external system directly via RFC.
Details:
A BAPI is the official programming interface to a SAP business object. A BAPI (see transaction BAPI) consists usually of several BAPI function modules. For a function module to become a BAPI function module it has to comply to some preconditions:
* A BAPI function must be RFC enabled
(which answer the second question: a BAPI can be called via RFC from any external systems without going through an IDoc)
* A BAPI function should be used within a BAPI
* BAPI function parameter should have self-explaining, English-language parameter names
* BAPIs are published in the SAP Interface Repository (ifr.sap.com)
A typical BAPI is BUS2032 (SalesOrder) and a BAPI function mapped to method CreateFromDat2 is Function BAPISALESORDERCREATEFROMDAT2. The BAPI is defined with transaction SWO1 and published in transaction BAPI. Those who are using the Mini-SAP version on Linux for training may want to have a look at BAPI BUS1093 (ExchangeRates).
An IDoc is a data file format used by SAP to exchange data in a unified way. Before you send an IDoc you have to pack your data into the IDoc envelope. A received IDoc must be unpacked, as the handling routine usually cannot interpret the raw data format of the IDoc (have a look at the EDID4-SDATA segment in SE11).
2. In the IDoc partner definition the partner is linked with an IDOC TYPE and PROCESS CODE for inbound processing. This process code is in turn linked with a FUNCTION MODULE to process the IDOC such as IDOC_INPUT_INVOIC_MRM.
Practically there is hardly a BAPI that allows processing an IDoc directly. The background is, that IDocs are effectively a data container and the contained data must be freed from the surrounding envelope fist. If you want to use BAPIs, you would have to create an own receiver function module that complies to the restriction of the IDoc engine. This function would unpack the IDoc and convert it into the format that is required by the BAPI.
Every IDoc handler that is to be called via the standard IDoc engine, must comply to the following function interface format, because it is called dynamically:
call function function_name
exporting
input_method = input_method
mass_processing = mass_processing
importing
workflow_result = workflow_result
application_variable = application_variable
in_update_task = in_update_task
call_transaction_done = call_transaction_done
tables
idoc_contrl = idoc_contrl
idoc_data = idoc_data
idoc_status = idoc_status
return_variables = return_variables
serialization_info = serialization_info
exceptions
wrong_function_called = 1
others = 2.
Additional parameters will be simply ignored, if you leave out a parameter the data cannot be seen within the function. For more details have a look in my book: "The SAP R/3 Guide to EDI and Interfaces", which guides you through all steps of creating your own IDoc processing routines.
|