Show TOC

Example documentationFilling Multiple Units in Parallel Locate this document in the navigation structure

 

To conclude, we show an example in which multiple units are filled at the same time. The units are processed in the same order as they were requested. In this example, unit 2 has priority over unit 1. Since both units are serialized by the same queue names, there is a sequence dependency. If different queue names were used, then both units could be processed in parallel.

DATA: my_destination TYPE REF TO if_bgrfc_destination_outbound,

my_unit_1 TYPE REF TO if_qrfc_unit_outbound,

my_unit_2 TYPE REF TO if_qrfc_unit_outbound,

dest_name TYPE bgrfc_dest_name_outbound,

queue_name TYPE qrfc_queue_name,

queue_names TYPE qrfc_queue_name_tab

TRY.

dest_name = 'MY_DEST'

my_destination = cl_bgrfc_destination_outbound=>create( dest_name )

CATCH cx_bgrfc_invalid_destination.

MESSAGE e102(bc).

ENDTRY.

my_unit_2 = my_destination->create_qrfc_unit( ). my_unit_1 = my_destination->create_qrfc_unit( ).

...CALL FUNCTION 'rfc_function_1' IN BACKGROUND UNIT my_unit_1.

CALL FUNCTION 'rfc_function_2' IN BACKGROUND UNIT my_unit_2.

queue_name = 'DEBITOR-1234'.

INSERT queue_name INTO TABLE queue_names.

queue_name = 'PRODUCT-4711'.

INSERT queue_name INTO TABLE queue_names.

queue_name = 'PRODUCT-5432'

INSERT queue_name INTO TABLE queue_names.

my_unit_1->add_queue_names_outbound( queue_names = queue_names

ignore_duplicates = abap_true )

my_unit_2->add_queue_names_outbound( queue_names = queue_names ignore_duplicates = abap_true )

COMMIT WORK.