Show TOC

Querying the Distribution ModelLocate this document in the navigation structure

Prerequisites

The receivers of a BAPI call are defined in the distribution model in same way as with synchronous BAPI calls. If the distribution of the data is also dependent on conditions, these dependencies between BAPIs or between BAPIs and message types are defined as receiver filters .

For each of these receiver filters, before the distribution model is defined, a filter object is created whose value at runtimes determines whether the condition is satisfied or not.

Procedure

The query of the distribution model is divided into the two sub-phases determining receivers and calling the generated outbound function module .

Determine Receiver

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. This module returns a table with all the receivers. 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:

Example Program: Asynchronous Receiver Determination (Part 1)

call function 'ALE_ASYNC_BAPI_GET_RECEIVER'
        exporting
                object = 'TESTFH01'
                method = 'SAVEREPLICA'
        tables
                receivers = receivers
                filterobject_values = filterobject_values
        exeptions
                error_in_filterobjects = 1
                error_in_ale_customizing = 2.
            

For more information on receiver determination, please refer to the ALE Programming Guide under Determining Receivers for Asynchronous BAPIs .

Calling the Generated Outbound Function Module

If the receivers have been determined, you have to differentiate between local and remote receivers. The BAPI can be called directly for local receivers. For remote calls the generated ALE outbound function module must be executed so that processing is passed to the ALE layer. The data for the BAPI call and the list of allowed logical receiver systems are passed to this function module. The following program example illustrates the call of the ALE outbound function module:

Example Program: Asynchronous Call of a Remote BAPI (Part 2)

call function 'ALE_TESTFH01_SAVEREPLICA'
        exporting
                key1 = 'SAP'
                key2 = '007'
        tables
                receivers = receivers
                application_objects = application_objects
        exceptions
                error_creating_idocs    =    1.
        .....
        call function 'DB_COMMIT'.
        call function 'DEQUEUE_ALL'.
        commit work.
            
Caution

A COMMIT WORK must follow in the program context after the outbound function module calls the generated BAPI ALE interface. The database commit at the end of the transaction is not sufficient. If a COMMIT WORK is not executed, the IDoc is created with the correct status but is not dispatched.