Show TOC

Example documentationExamples for Inbound and Outbound Processing Locate this document in the navigation structure

 

The following simple examples help to explain how the new API is used:

  • bgRFC Type t: Outbound

  • bgRFC Type q: Outbound

  • bgRFC Type q: Outbound to Inbound

  • bgRFC Type t: Inbound

  • bgRFC Type q: Inbound

bgRFC Type t: Outbound

This example creates a bgRFC unit type t that contains two function module calls and which is sent to a remote system via the outbound scheduler.

Syntax Syntax

  1. DATA: my_destination TYPE REF TO if_bgrfc_destination_outbound,
  2.       my_unit        TYPE REF TO if_trfc_unit_outbound,
  3.       dest_name      TYPE bgrfc_dest_name_outbound.
  4. dest_name = 'MY_DEST'.
  5. my_destination = cl_bgrfc_destination_outbound=>create( dest_name ).
  6. my_unit = my_destination->create_trfc_unit( ).
  7. CALL FUNCTION ’rfc_function_1’ IN BACKGROUND UNIT my_unit.
  8. CALL FUNCTION ’rfc_function_2’ IN BACKGROUND UNIT my_unit.
  9. COMMIT WORK.
End of the code.
qRFC Type q: Outbound

This example creates a bgRFC unit type q that contains two function module calls and which is sent to a remote system via the outbound scheduler. To do this, queue names are used for the serialization of units. At the same time, the example explains how to intercept exceptions to be able to handle any errors. In this example, we will specify the queue names retroactively. This is technically correct, but the maintenance of the programs can suffer as a result.

Syntax Syntax

  1. DATA: my_destination TYPE REF TO if_bgrfc_destination_outbound,
  2.       my_unit        TYPE REF TO if_qrfc_unit_outbound,
  3.       dest_name      TYPE bgrfc_dest_name_outbound,
  4.       queue_name     TYPE qrfc_queue_name,
  5.       queue_names    TYPE qrfc_queue_name_tab.
  6. TRY.
  7.     dest_name = 'MY_DEST'.
  8.     my_destination = cl_bgrfc_destination_outbound=>create( dest_name ).
  9.   CATCH cx_bgrfc_invalid_destination.
  10.     MESSAGE e102(bc).
  11. ENDTRY.
  12. my_unit = my_destination->create_qrfc_unit( ).
  13. TRY.
  14.     CALL FUNCTION ’rfc_function_1’ IN BACKGROUND UNIT my_unit.
  15.     my_unit->add_queue_name_outbound( 'DEBITOR-1234' ).
  16.     CALL FUNCTION ’rfc_function_2’ IN BACKGROUND UNIT my_unit.
  17.     queue_name = 'PRODUCT-4711'.
  18.     INSERT queue_name INTO TABLE queue_names.
  19.     queue_name = 'PRODUCT-5432'.
  20.     INSERT queue_name INTO TABLE queue_names.
  21.     my_unit->add_queue_names_outbound( queue_names ).
  22.   CATCH cx_qrfc_duplicate_queue_name.
  23.     MESSAGE e101(bc).
  24. ENDTRY.
  25. COMMIT WORK.
End of the code.
bgRFC Type q: Outbound to Inbound

The next example creates a bgRFC unit of type q that contains two function module calls and which is sent to a remote system using the outbound scheduler. Once there, it is placed in the inbound queue. To do this, queue names are used for the serialization of units. At the same time, we show how you can disable the exception raised for duplicate queue names, using the parameter IGNORE_DUPLICATES.

Syntax Syntax

  1. DATA: my_destination TYPE REF TO if_bgrfc_destination_outbound,
  2.       my_unit        TYPE REF TO if_qrfc_unit_outinbound,
  3.       dest_name      TYPE bgrfc_dest_name_outbound,
  4.       queue_name     TYPE qrfc_queue_name,
  5.       queue_names    TYPE qrfc_queue_name_tab.
  6. TRY.
  7.     dest_name = 'MY_DEST'.
  8.     my_destination = cl_bgrfc_destination_outbound=>create( dest_name ).
  9.   CATCH cx_bgrfc_invalid_destination.
  10.     MESSAGE e102(bc).
    ENDTRY.
  11. my_unit = my_destination->create_qrfc_unit_outinbound( ).
  12. CALL FUNCTION ’rfc_function_1’ IN BACKGROUND UNIT my_unit.
  13. CALL FUNCTION ’rfc_function_2’ IN BACKGROUND UNIT my_unit.
  14. queue_name = 'DEBITOR-1234'.
  15. INSERT queue_name INTO TABLE queue_names.
  16.     queue_name = 'PRODUCT-4711'.
  17. INSERT queue_name INTO TABLE queue_names.
  18.     queue_name = 'PRODUCT-5432'.
  19. INSERT queue_name INTO TABLE queue_names.
  20. my_unit->add_queue_names_outbound( queue_names = queue_names
  21.                                    ignore_duplicates = abap_true ).
  22. my_unit->add_queue_names_inbound( queue_names = queue_names
  23.                                   ignore_duplicates = abap_true ).
  24. COMMIT WORK.
  25.  
End of the code.
bgRFC Type t: Inbound

This example creates a bgRFC unit of type t that contains two function module calls and which is to be processed in the same system by the inbound scheduler.

Syntax Syntax

  1. DATA: my_destination TYPE REF TO if_bgrfc_destination_inbound,
  2.       my_unit        TYPE REF TO if_trfc_unit_inbound,
  3.       dest_name      TYPE bgrfc_dest_name_inbound.
  4. dest_name = 'MY_DEST'.
  5. my_destination = cl_bgrfc_destination_inbound=>create( dest_name ).
  6. my_unit = my_destination->create_trfc_unit( ).
  7. CALL FUNCTION ’rfc_function_1’ IN BACKGROUND UNIT my_unit.
  8. CALL FUNCTION ’rfc_function_2’ IN BACKGROUND UNIT my_unit.
  9. COMMIT WORK.
End of the code.
bgRFC Type q: Inbound

This is another example of an inbound bqRFC of type q. Unlike the bgRFC of type t example, we are using queue names here and, therefore, the method create_qrfc_unit instead of create_trfc_unit.

Syntax Syntax

  1. DATA: my_destination TYPE REF TO if_bgrfc_destination_inbound,
  2.       my_unit        TYPE REF TO if_qrfc_unit_inbound,
  3.       queue_name     TYPE qrfc_queue_name,
  4.       queue_names    TYPE qrfc_queue_name_tab,
  5.       dest_name      TYPE bgrfc_dest_name_inbound.
  6. dest_name = 'MY_DEST'.
  7. my_destination = cl_bgrfc_destination_inbound=>create( dest_name ).
  8. my_unit = my_destination->create_qrfc_unit( ).
  9. TRY.
  10.     CALL FUNCTION ’rfc_function_1’ IN BACKGROUND UNIT my_unit.
  11.     my_unit->add_queue_name_inbound( 'DEBITOR-1234' ).
  12.     CALL FUNCTION ’rfc_function_2’ IN BACKGROUND UNIT my_unit.
  13.     queue_name = 'PRODUCT-4711'.
  14.     INSERT queue_name INTO TABLE queue_names.
  15.     queue_name = 'PRODUCT-5432'.
  16.     INSERT queue_name INTO TABLE queue_names.
  17.     my_unit->add_queue_names_inbound( queue_names ).
  18.   CATCH cx_qrfc_duplicate_queue_name.
  19.     MESSAGE e101(bc).
  20. ENDTRY.
  21. COMMIT WORK.
  22.  DATA
End of the code.