Analogous to the synchronous call of a BAPI, the distribution model defines the potential receivers of a BAPI call. If distribution of data is linked to additional conditions, these dependencies between BAPIs or between BAPIs and message types are defined as receiver filters.
A filter object is initially created for each receiver filter before the distribution model is maintained; the value of the filter object determines at runtime whether the condition is satisfied or not.
The query of the distribution model is divided into the two sub-phases determining receivers and calling the generated outbound function module.
Before receiver determination can be performed, the filter objects that have been assigned to the BAPI must be determined. In the process, we have to differentiate whether the filter objects are known at runtime or not.
If the filter objects are known at runtime, they can be specified directly during receiver determination. If not, function module ALE_BAPI_GET_FILTEROBJECTS is available: it extracts the corresponding filter objects for a specific BAPI.
Once the filter objects have been resolved, the receivers can be determined. During an asynchronous BAPI call, the application program uses function module ALE_ASYNC_BAPI_GET_RECEIVER. This module returns a table with all the receivers. The table contains only the logical receiver systems.
If receiver determination is tied to conditions, then the function module must be given the values of the filter objects that were determined above.
Receiver determination for calling a remote BAPI from the ALE distribution model generally appears as follows:
Program Example: Asynchronous Receiver Determination (Part 1)
call function 'ALE_ASYNC_BAPI_GET_RECEIVER'
object = 'TESTFH01'
method = 'SAVEREPLICA'
receivers = receivers
filterobject_values = filterobject_values
error_in_filterobjects = 1
error_in_ale_customizing = 2.
For more information on receiver determination, please refer to the ALE Programming Guide underDetermining Receivers for Asynchronous BAPIs.
Calling the Generated Outbound Function Module
Once the receivers have been determined, you have to differentiate whether these receivers are local or remote. The BAPI can be called directly for local receivers. For remote calls, in contrast, the generated ALE outbound function module is executed, which forwards processing to the ALE layer. This function module is given the data for the BAPI call and the list of valid logical receiver systems.
The following program example illustrates the call of the ALE outbound function module:
Program Example: Asynchronous Call of a Remote BAPI (Part 2)
call function 'ALE_TESTFH01_SAVEREPLICA'
key1 = 'SAP'
key2 = '007'
receivers = receivers
application_objects = application_objects
error_creating_idocs = 1.
Important:A COMMIT WORK must follow in the program context after the outbound function module calls the generated BAPI ALE interface. A database COMMIT at the end of the transaction is not sufficient. If no COMMIT WORK is triggered, the IDoc will be generated with the correct status, but it will not be dispatched.