Show TOC

Technical Receiver Determination API: Coding ExamplesLocate this document in the navigation structure

Below are examples of ABAP code used to instantiate consumer proxies at runtime in the following scenarios:

  • Multiple provider applications are assigned to one Service Group

  • Only one provider application is allowed

  • Asynchronous request response pattern

Multiple Provider Applications are Assigned to a ServiceGroup

REPORT  service_group_demo_1.

DATA: l_sg_handler     TYPE REF TO if_srt_public_sv_group_handler,
      lt_applications  TYPE if_srt_public_sv_group_handler=>t_provider_applications,
      l_application    TYPE if_srt_public_sv_group_handler=>t_provider_application,
      lt_web_services  TYPE if_srt_public_provider_appl=>t_web_services,
      l_web_service    TYPE if_srt_public_provider_appl=>t_web_service,
      l_proxy          TYPE REF TO my_proxy_class,
      l_cx_config      TYPE REF TO cx_srt_public_config.

TRY.
*   Instantiate Service Group Handler
    l_sg_handler = cl_srt_public_factory=>get_service_group_handler( ).

*   Get applications
    lt_applications = l_sg_handler->get_provider_applications( 'MY_SERVICE_GROUP' ).

    READ TABLE lt_applications INTO l_application WITH KEY table_line->business_system_name = 'MY_BIZ_SYSTEM'.
    IF sy-subrc = 0.

*     get web services
      lt_web_services = l_application->get_web_services( ).

      READ TABLE lt_web_services INTO l_web_service WITH KEY table_line->proxy_class = 'MY_PROXY_CLASS'.
      IF sy-subrc = 0.

*       instantiate proxy
        l_proxy ?= l_web_service->create_proxy( ).

      ENDIF.

    ENDIF.

         

Only One Provider Application Allowed

REPORT  service_group_demo_02. 

DATA: l_sg_handler     TYPE REF TO if_srt_public_sv_group_handler,
      l_web_service    TYPE if_srt_public_provider_appl=>t_web_service,
      l_proxy          TYPE REF TO my_proxy_class,
      l_cx_config      TYPE REF TO cx_srt_public_config.

TRY.

*   Instantiate Service Group Handler
    l_sg_handler = cl_srt_public_factory=>get_service_group_handler( ).

*   Get web services
    l_web_service = l_sg_handler->get_web_service_single_system( service_group = 'MY_SERVICE_GROUP'
                                                                 proxy_class   = 'MY_PROXY_CLASS').

*   Instantiate proxy
    l_proxy ?= l_web_service->create_proxy( ).

  CATCH cx_srt_public_config INTO l_cx_config.
    MESSAGE ID l_cx_config->t100_msg-msgid  TYPE l_cx_config->t100_msg-msgty
      NUMBER l_cx_config->t100_msg-msgno WITH l_cx_config->t100_msg-msgv1 l_cx_config->t100_msg-msgv2
             l_cx_config->t100_msg-msgv3  l_cx_config->t100_msg-msgv4.

ENDTRY.

         

Asynchronous request response pattern

REPORT  service_group_demo_03.

DATA:
  l_cg_handler            TYPE REF TO if_srt_public_sv_group_handler,
  l_web_service           TYPE REF TO if_srt_public_web_service,
  l_proxy                 TYPE REF TO ztk_co_ztk_ws_string,
  l_cx_srt                TYPE REF TO cx_srt_public_config.

TRY.

*   instantiate service group handler
    l_cg_handler = cl_srt_public_factory=>get_service_group_handler( ).

*   get web service instance by business application id.
    l_web_service = l_cg_handler->get_web_service_by_bus_appl_id( service_group    = 'MY_SERVICE_GROUP'
                                                                  proxy_class      = 'MY_PROXY_CLASS'
                                                                  business_appl_id = 'RECEIVED_APPLICATION_ID' ).

*   instantiate the consumer proxy
    l_proxy ?= l_web_service->create_proxy( ).

  CATCH cx_srt_public_config INTO l_cx_srt.
    MESSAGE ID l_cx_srt->t100_msg-msgid TYPE l_cx_srt->t100_msg-msgty NUMBER l_cx_srt->t100_msg-msgno
      WITH l_cx_srt->t100_msg-msgv1 l_cx_srt->t100_msg-msgv2 l_cx_srt->t100_msg-msgv3 l_cx_srt->t100_msg-msgv4.

ENDTRY.