[ABAP] Neues SAP-Fenster (Modus) öffnen und wieder schließen

* Bsp.: Transaktion SU3
PARAMETERS: p_tcode TYPE tcode DEFAULT 'SU3'.

START-OF-SELECTION.

  DATA: lv_mode TYPE sy-index.

* Eröffnen eines neuen externen Modus
  CALL FUNCTION 'TH_CREATE_MODE'
    EXPORTING
      transaktion    = p_tcode
    IMPORTING
      mode           = lv_mode
    EXCEPTIONS
      max_sessions   = 1
      internal_error = 2
      no_authority   = 3
      OTHERS         = 4.

  IF sy-subrc = 0.
    WRITE: / 'Transaktion:', p_tcode.
    WRITE: / 'Modus:', lv_mode.

    DATA: ret TYPE string.

    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        titlebar              = 'Modus'
        text_question         = 'Modus wieder schließen?'
        display_cancel_button = abap_false
      IMPORTING
        answer                = ret.

    CASE ret.
      WHEN '1'.
* Löschen eines externen Modus
        CALL FUNCTION 'TH_DELETE_MODE'
          EXPORTING
            mode = lv_mode.
      WHEN OTHERS.
    ENDCASE.
  ENDIF.