Get backend RFC destination in SRM

Tags: SRM

This code is working properly, when the SRM system is connected to exactly one ECC Backend only.

    DATA:
      lt_logsys      TYPE bbpt_logical_system,
      ls_logsys      TYPE bbps_logical_system,
      lt_message     TYPE bbpt_balmi,
      lv_destination TYPE RFCDEST.

    CALL FUNCTION 'BBP_GET_BACKEND_SYSTEMS'
      TABLES
        et_logical_systems = lt_logsys
        et_messages        = lt_message.

    READ TABLE lt_logsys INTO ls_logsys INDEX 1.

    IF sy-subrc EQ 0 AND ls_logsys-logsys IS NOT INITIAL.

      CALL FUNCTION 'BBP_LOGICAL_SYSTEM_GETDETAIL'
        EXPORTING
          logical_system = ls_logsys-logsys
        IMPORTING
          destination    = lv_destination.

    ENDIF.