[ABAP] Systemnamen ermitteln

* Variante 1 (SQL)
DATA(man) = cl_abap_syst=>get_client( ).

SELECT SINGLE logsys FROM t000 INTO @DATA(lv_logsys) WHERE mandt = @man.

IF sy-subrc = 0.
  WRITE: / lv_logsys.
ENDIF.

* Variante 2 (OWN_LOGICAL_SYSTEM_GET)
DATA: lv_logsys TYPE tbdls-logsys.

CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
  IMPORTING
    own_logical_system             = lv_logsys
  EXCEPTIONS
    own_logical_system_not_defined = 1
    OTHERS                         = 2.

IF sy-subrc = 0.
  WRITE: / lv_logsys.
ENDIF.

[ABAP] Rolle eines Mandanten bestimmen

* aktueller Mandant
DATA(man) = cl_abap_syst=>get_client( ).

* verfügbare Mandanten
SELECT SINGLE *
  INTO @DATA(lv_t000)
  FROM t000
  WHERE mandt = @man.

IF sy-subrc = 0.
  DATA(it_dd07v_tab) = VALUE dd07v_tab( ).
  DATA(lv_rc) = VALUE sy-subrc( ).

* DDextern: Externe Schnittstelle zum Lesen der Domänenfestwerte
  CALL FUNCTION 'DD_DOMVALUES_GET'
    EXPORTING
      domname        = 'CCCATEGORY' " Feld CCCATEGORY: Client Control: Rolle des Mandanten (Productive, Test,...)
      text           = abap_true    " Text holen
    IMPORTING
      rc             = lv_rc
    TABLES
      dd07v_tab      = it_dd07v_tab
    EXCEPTIONS
      wrong_textflag = 1
      OTHERS         = 2.
  IF sy-subrc = 0.
    IF lv_rc = 0.
      IF line_exists( it_dd07v_tab[ domvalue_l = lv_t000-cccategory ] ).
        DATA(lv_dd07v) = it_dd07v_tab[ domvalue_l = lv_t000-cccategory ].

* logisches System, Mandant und Kategorietext ausgeben
        WRITE: / lv_t000-logsys, lv_dd07v-ddtext.
      ENDIF.
    ENDIF.
  ENDIF.
ENDIF.