[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.

[ABAP] IMG-Aktivität (Customizing-Punkt) zu einer Transaktion ermitteln

* Tabellen:
*  CUS_ACTEXT (Customizing Aktivität - zugeordnetes Erweiterungs-Objekt)
*  CUS_ACTH   (Customizing Aktivität - Kopfdaten)
*  CUS_ACTOBJ (Customizing Aktivität - Liste der Objekte)
*  CUS_ACTOBT (Customizing Aktivität - Liste der Objekte)
*  CUS_ACTT   (Texttabelle zu den Customizing Aktivitäten)

* TCode
PARAMETERS: p_tc TYPE tstc-tcode DEFAULT 'OMBT'.

START-OF-SELECTION.

  SELECT o~tcode,
         o~act_id,
         o~objectname,
         o~text AS etext,
         t~text,
         e~exit_name,
         e~impl_name,
         e~enhancement
    INTO TABLE @DATA(it_activities)
    FROM cus_actobt AS o
    INNER JOIN cus_acth AS h ON o~act_id = h~act_id
    INNER JOIN cus_actt AS t ON h~act_id = t~act_id
    LEFT OUTER JOIN cus_actext AS e ON o~act_id = e~act_id
    WHERE o~tcode = @p_tc
      AND o~spras = @sy-langu
      AND t~spras = @sy-langu.

  TRY.
* SALV-Table
      DATA: o_salv TYPE REF TO cl_salv_table.

      cl_salv_table=>factory( IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_activities ).

* Grundeinstellungen
      o_salv->get_functions( )->set_all( abap_true ).
      o_salv->get_columns( )->set_optimize( abap_true ).
      o_salv->get_display_settings( )->set_list_header( 'IMG-Aktivitäten zur Transaktion' ).
      o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
      o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

* Spaltenüberschriften: technischer Name und Beschreibungstexte
      LOOP AT o_salv->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<c>).
        DATA(o_col) = <c>-r_column.
        o_col->set_short_text( || ).
        o_col->set_medium_text( || ).
        o_col->set_long_text( |{ o_col->get_columnname( ) } [{ o_col->get_long_text( ) }]| ).
      ENDLOOP.

      o_salv->display( ).
    CATCH cx_root INTO DATA(e_txt).
      WRITE: / e_txt->get_text( ).
  ENDTRY.