[ABAP] Popupfenster mit Eingabefeldern (cl_gui_combobox, cl_gui_input_field)

CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_close FOR EVENT close OF cl_gui_dialogbox_container
        IMPORTING sender.

    CLASS-METHODS:
      on_select FOR EVENT selected OF cl_gui_combobox
        IMPORTING
            key
            sender.

    CLASS-METHODS:
      on_submit FOR EVENT submit OF cl_gui_input_field
        IMPORTING
            input
            sender.

    CLASS-METHODS:
      on_auto_submit FOR EVENT auto_submit OF cl_gui_input_field
        IMPORTING
            input
            sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
  METHOD on_close.
    IF sender IS NOT INITIAL.
      sender->free( ).
    ENDIF.
  ENDMETHOD.

  METHOD on_select.

    MESSAGE key && ' -> ' && sender->get_selected_item( ) TYPE 'S'.

    cl_gui_cfw=>flush( ).
  ENDMETHOD.

  METHOD on_submit.

    MESSAGE 'Submit:' && input && ' -> ' && sender->get_text( ) TYPE 'S'.

    cl_gui_cfw=>flush( ).
  ENDMETHOD.

  METHOD on_auto_submit.

    MESSAGE 'Auto-Submit:' &&  input && ' -> ' && sender->get_text( ) TYPE 'S'.

    cl_gui_cfw=>flush( ).
  ENDMETHOD.
ENDCLASS.

SELECTION-SCREEN: PUSHBUTTON 2(20) btn1 USER-COMMAND cmd_show.

AT SELECTION-SCREEN.
* wenn Button-Kommando 'CMD_SHOW'
  IF sy-ucomm = 'CMD_SHOW'.
* Container
    DATA(o_cnt) = NEW cl_gui_dialogbox_container( no_autodef_progid_dynnr = abap_true
                                                  caption                 = 'Werte'
                                                  top                     = 5
                                                  left                    = 5
                                                  width                   = 640
                                                  height                  = 240 ).

    SET HANDLER lcl_events=>on_close FOR o_cnt.

* Input
    DATA(o_input) = NEW cl_gui_input_field( parent               = o_cnt
                                            label_text           = 'InputLabel'
                                            label_width          = 10
                                            input_prompt_text    = 'Text'
                                            activate_find_button = abap_false
                                            activate_auto_submit = abap_true ).

    o_input->set_top( 30 ).
    o_input->set_text( '<default>' ).

    SET HANDLER lcl_events=>on_submit FOR o_input.
    SET HANDLER lcl_events=>on_auto_submit FOR o_input.

* Combobox
    DATA(o_combo) = NEW cl_gui_combobox( parent      = o_cnt
                                         label_text  = 'ComboLabel'
                                         label_width = 10 ).

    o_combo->set_items( VALUE vrm_values( ( key = 'A' text = 'Wert1' )
                                          ( key = 'B' text = 'Wert2' )
                                          ( key = 'C' text = 'Wert3' ) ) ).

    o_combo->set_selected_item( 'A' ).

    o_combo->activate_selection_event( ).

    o_combo->set_top( 10 ).

    SET HANDLER lcl_events=>on_select FOR o_combo.
  ENDIF.

[ABAP] Quellcode im ABAP-Editor anzeigen und mit Pretty Print überarbeiten

* https://wiki.scn.sap.com/wiki/display/ABAP/Create+your+own+New+Editor+for+BOR+objects
DATA(it_source_code_in) = VALUE stringtab( ).
DATA(it_source_code_out) = VALUE stringtab( ).

* Quelltext des Reports in Stringtab einlesen
READ REPORT sy-repid INTO it_source_code_in.

* Pretty Print für Code durchführen
CALL FUNCTION 'PRETTY_PRINTER'
  EXPORTING
    inctoo             = space
  TABLES
    ntext              = it_source_code_out
    otext              = it_source_code_in
  EXCEPTIONS
    enqueue_table_full = 1
    include_enqueued   = 2
    include_readerror  = 3
    include_writeerror = 4
    OTHERS             = 5.

IF sy-subrc = 0.
* ABAP-Editor im cl_gui_container=>default_screen anzeigen
  DATA(o_editor) = NEW cl_gui_abapedit( parent = cl_gui_container=>default_screen ).
* ReadOnly setzen
  o_editor->set_readonly_mode( 1 ).
* Quelltext setzen
  o_editor->set_text( it_source_code_out ).

* cl_gui_container=>default_screen erzwingen
  WRITE space.
ENDIF.