The following example programs show how receivers are determined with synchronous BAPI calls.
The function module ALE_BAPI_GET_FILTEROBJECTS must be used if the application's filter object types are not known at runtime. Otherwise its use is optional.
A database commit is executed by the synchronous RFC - this means that database changes carried out before the RFC was executed cannot be rolled back.
Filter Object Types Are Not Known at Runtime
* data declaration data: filterobj_values like bdi_fobj occurs 0, filterobj_types like bdi_fobjtype occurs 0, bapi_server like bdbapidest occurs 0. constants: c_objtype_plant type c value 'WERKS', c_objtype_langu type c value 'SPRAS'. * get filterobjects from ALE distribution model call function 'ALE_BAPI_GET_FILTEROBJECTS' exporting object = 'BUS1001' method = 'GETDETAIL' tables filterobjects = filterobj_types exceptions error_in_ale_customizing = 1. * fill filterobject values into table loop at filterobj_types. case filterobj_values-objtype. when c_objtype_plant. filterobj_values-objtype = c_objtype_plant. filterobj_values-objvalue = '0002'. when c_objtype_langu. filterobj_values-objtype = c_objtype_langu. filterobj_values-objvalue = 'D'. when others. endcase. append filterobj_values. endloop. * get receiver from ALE distribution model call function 'ALE_SYNC_BAPI_GET_RECEIVER' exporting object = 'BUS1001' method = 'GETDETAIL' tables receivers = bapi_server filterobjects_values = filterobj_values exceptions error_in_filterobjects = 1 error_in_ale_customizing = 2. * call synchronous BAPI locally/remotely if sy-subrc = 0. if not bapi_server[] is initial. loop at bapi_server. call function 'BAPI_MATERIAL_GET_DETAIL' destination bapi_server-rfc_dest ... endloop. else. call function 'BAPI_MATERIAL_GET_DETAIL' ... endif. endif.
Filter Object Types Are Known at Runtime
* data declaration data: filterobj_values like bdi_fobj occurs 0, filterobj_types like bdi_fobjtype occurs 0, bapi_server like bdibapidest occurs 0. * fill filterobject values into table filterobj_values-objtype = 'KKBER'. filterobj_values-objvalue = '0002'. append filterobj_values. * get receiver from ALE distribution model call function 'ALE_SYNC_BAPI_GET_RECEIVER' exporting object = 'BUS1010' method = 'GETSTATUS' tables receivers = bapi_server filterobjects_values = filterobj_values exceptions error_in_filterobjects = 1 error_in_ale_customizing = 2. * call synchronous BAPI locally/remotely if sy-subrc <> 0. if not bapi_server[] is initial. loop at bapi_server. call function 'BAPI_DEBITOR_CREDITACC_GETSTATUS' destination bapi_server-rfc_dest ... endloop. else. call function 'BAPI_DEBITOR_CREDITACC_GETSTATUS' ... endif. endif.