Function module to get RFC destinations.
In CRM system FM CRM_AV_CHECK_R3_GET_DESTIN can be used to get destination as follows,
  Data: lv_dest     type rfcdest.
  call function 'CRM_AV_CHECK_R3_GET_DESTIN'
      importing
        ev_destination  = lv_dest
      exceptions
        invalid_release = 1
        others          = 2.
  Another way in CRM side,
  DATA: lt_erpsites  TYPE STANDARD TABLE OF  smof_erpsh,
        ls_erpsites  TYPE    smof_erpsh,  
        lv_dest  TYPE   rfcdest.  
    
 * * Read ERP destination
  CALL FUNCTION 'SMOF_READ_SMOFERPSH'
    EXPORTING
      i_sitetypeid = 'SMOF_ERPSITE'
      i_mandt      = sy-mandt
    TABLES
      t_erpsites   = lt_erpsites.
  
  READ TABLE lt_erpsites INTO ls_erpsites INDEX 1.
  lv_dest = ls_erpsites-rfcdest. 
In ECC system FM CRM0_READ_RFC_DEST can be used to get destination as follows,
  Data: lt_dest   type table of CRMRFCPAR.
  CALL FUNCTION 'CRM0_READ_RFC_DEST'
    EXPORTING
      I_CONSUMER             = 'CRM'
      i_download_type          = ' '
      i_objname                   = ' '
    tables
      t_crmrfcpar           = lt_dest.
From the lt_dest internal table we have to pick the rfcdest value.