drag&drop von alv_list ----> textedit

Die Objektorientierung mit ABAP®: Vererbung, Dynamische Programmierung, GUI Controls (u.a. ALV im OO).
8 Beiträge • Seite 1 von 1
8 Beiträge Seite 1 von 1

drag&drop von alv_list ----> textedit

Beitrag von abap-strizi (ForumUser / 83 / 0 / 0 ) »
ich habe versucht ein drag&drop von einer alv_liste zu einem texteditor zu machen allerdings funktioniert das irgendwie ganz und gar nicht und ich habe leider null ahnung wo ich ansetzen soll:

vielleicht hat ja einer lust und zeit mir weiter zu helfen :-)


mfg strizi

Code: Alles auswählen.


*&---------------------------------------------------------------------*
*& Report  Z_SUBSCR_TEST                                               *
*&                                                                     *
*&---------------------------------------------------------------------*
*&   SCHNÖLL BERNHARD
*&   TESTPROGRAMM
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  z_subscr_test.

*&----Allgemeine Deklarationen-----------------------------------------*

*Tabellen
 TABLES:  npat,
          rsodatum.

DATA: fieldcat TYPE lvc_t_fcat.
DATA: alv_list TYPE REF TO cl_gui_alv_grid.
DATA: text_row TYPE i,
      text_value(200) TYPE c,
      text_col TYPE i.


DATA: container TYPE REF TO cl_gui_custom_container.
DATA splitter TYPE REF TO cl_gui_easy_splitter_container.
DATA right TYPE REF TO cl_gui_container.
DATA left TYPE REF TO cl_gui_container.

* Klassen für Drag-Drop Funktionalität
DATA behaviour_left TYPE REF TO cl_dragdrop.
DATA behaviour_right TYPE REF TO cl_dragdrop.
DATA handle_ALV TYPE i.
DATA G_HANDLE_TREE TYPE i.
DATA G_HANDLE_ALV  TYPE i.

* Editor
DATA editor TYPE REF TO cl_gui_textedit.


*---------------------------------------------------------------------*
*       CLASS lcl_drag_object DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*

CLASS lcl_drag_object DEFINITION.
  PUBLIC SECTION.
  DATA text(200) TYPE c.
ENDCLASS.                    "lcl_drag_object DEFINITION

*---------------------------------------------------------------------*
* CLASS dragdrop_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_dragdrop_receiver DEFINITION.
  PUBLIC SECTION.

       DATA: E_DRAGDROPOBJ Type Ref To CL_DRAGDROPOBJECT.

    METHODS:
    flavor_select FOR EVENT on_get_flavor OF cl_gui_textedit
        IMPORTING index
                  line
                  pos
                  flavors
                  dragdrop_object,

    left_drag FOR EVENT ondrag OF cl_gui_alv_grid
        IMPORTING E_ROW
                  E_COLUMN
                  E_DRAGDROPOBJ,


    right_drop FOR EVENT on_drop OF cl_gui_textedit
        IMPORTING index
                  line
                  pos
                  dragdrop_object,

    drop_complete FOR EVENT ondropcomplete OF cl_gui_alv_grid
        IMPORTING E_ROW
                  E_COLUMN
                  E_DRAGDROPOBJ .



ENDCLASS.   "lcl_dragdrop_receiver DEFINITION



*---------------------------------------------------------------------*
* CLASS DRAGDROP_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_dragdrop_receiver IMPLEMENTATION.
  METHOD flavor_select.

IF sy-subrc = 0.
      SEARCH flavors FOR 'ALV_move_to_Edit'.
      IF sy-subrc = 0.
        CALL METHOD dragdrop_object->set_flavor
          EXPORTING
            newflavor = 'ALV_move_to_Edit'.
      ELSE.
        CALL METHOD dragdrop_object->abort.
      ENDIF.

    ELSE.
      SEARCH flavors FOR 'ALV_move_to_Edit'.
      IF sy-subrc = 0.
        CALL METHOD dragdrop_object->set_flavor
          EXPORTING
            newflavor = 'ALV_move_to_Edit'.
      ELSE.
        CALL METHOD dragdrop_object->abort.
      ENDIF.
endif.
  ENDMETHOD.                    "flavor_select

  METHOD left_drag.
  DATA:  e_row_no TYPE lvc_s_roid,
         drag_object TYPE REF TO lcl_drag_object.


   IF sy-subrc = 0.
    CALL METHOD alv_list->get_current_cell
      IMPORTING
        e_row   = text_row
        e_value = text_value
        e_col   = text_col.
  ENDIF.

    CREATE OBJECT drag_object.
    drag_object->text = text_value.
*Instanz der Klasse cl_dragdropobject bekommt 'drag_object' als
*Parameter für Atribut object mit
    E_DRAGDROPOBJ->object = drag_object.

  ENDMETHOD.                    "left_drag


  METHOD right_drop.
    DATA textline(256).
    DATA text_table LIKE STANDARD TABLE OF textline.
    DATA drag_object TYPE REF TO lcl_drag_object.
*entspricht move to
*cast: i.d.R Exception Behandlung nötig
    drag_object ?= dragdrop_object->object.
* holt sich den gesammten Text vom Control
    CALL METHOD editor->get_text_as_stream
      IMPORTING
        text = text_table.
* Synchronisiere die Automation Queue nach Get Methods
    CALL METHOD cl_gui_cfw=>flush.
    textline = drag_object->text.
* Einfügen von text in interne Tabelle
    INSERT textline INTO text_table INDEX 1.
* Sende modifizierte Tabelle ans Frontend
    CALL METHOD editor->set_text_as_stream
      EXPORTING
        text            = text_table
      EXCEPTIONS
        error_dp        = 1
        error_dp_create = 2.
  ENDMETHOD.                    "right_drop

* wenn ein move Erfolgen soll muss der Knoten gelöscht werden
  METHOD drop_complete.

  ENDMETHOD.                    "drop_complete
ENDCLASS.                    "lcl_dragdrop_receiver DEFINITION



*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
  PUBLIC SECTION .
    DATA:  e_row TYPE REF TO lvc_s_row.
    DATA:  e_column TYPE REF TO lvc_s_col.
    DATA:  es_row_no TYPE lvc_s_roid.

    METHODS:
*Double-click control
    handle_double_click
          FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column .
  PRIVATE SECTION.


ENDCLASS.                    "lcl_event_handler DEFINITION



*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .

*Handle Double Click
  METHOD handle_double_click .
    PERFORM handle_double_click USING e_row e_column es_row_no.
  ENDMETHOD .                    "handle_double_click

ENDCLASS .                    "lcl_event_handler IMPLEMENTATION




*---------------------------------------------------------------------*
*Class application definition
*---------------------------------------------------------------------*
CLASS application DEFINITION.

  PUBLIC SECTION.


    METHODS: constructor,
               fill_list,
      read_data
      IMPORTING eingabeparameter_vname TYPE npat-vname
                eingabeparameter_nname TYPE npat-nname
                eingabeparameter_gebdat TYPE rsodatum.



  PRIVATE SECTION.
    DATA:  namen_obj TYPE TABLE OF npat,
           wa_namen_obj TYPE npat.



    TYPES: BEGIN OF list,
          patnr(10) TYPE c,
          titel(15) TYPE c,
          nname(30) TYPE c,
          vname(30) TYPE c,
          gbdat TYPE d,
         END OF list.

    DATA: liste TYPE STANDARD TABLE OF list.
    DATA: wa_liste TYPE list.

ENDCLASS.                    "application DEFINITION

*---------------------------------------------------------------------*
* class implementation
*---------------------------------------------------------------------*
CLASS application IMPLEMENTATION.


  METHOD read_data.
    DATA test TYPE string.

    PERFORM datumbearb.

    IF eingabeparameter_vname = space
    AND  eingabeparameter_nname = space.

      SELECT *
                FROM npat
                INTO TABLE namen_obj
                WHERE gbdat IN datum.


    ELSE.

      SELECT *
                FROM npat
                INTO TABLE namen_obj
                WHERE ( vname = eingabeparameter_vname AND
                        nname = eingabeparameter_nname )
                OR  gbdat IN datum.

    ENDIF.

    LOOP AT namen_obj INTO wa_namen_obj.

      wa_liste-patnr = wa_namen_obj-patnr.
      wa_liste-titel = wa_namen_obj-titel.
      wa_liste-nname = wa_namen_obj-nname.
      wa_liste-vname = wa_namen_obj-vname.
      wa_liste-gbdat = wa_namen_obj-gbdat.

*---geschlechtsprüfung und änderung der anrede ------------------------*
      IF  wa_namen_obj-titel = space.
        IF wa_namen_obj-gschl = '1'.
          wa_liste-titel = 'Herr'.
        ELSE.
          wa_liste-titel = 'Frau'.
        ENDIF.
      ENDIF.


      APPEND wa_liste TO liste.
      CLEAR wa_liste.

    ENDLOOP.

  ENDMETHOD.                    "read_data


  METHOD constructor.

    CREATE OBJECT container
     EXPORTING container_name = 'LISTAREA'.

    CREATE OBJECT splitter
      EXPORTING parent = container
      orientation = 1.

    left = splitter->top_left_container.
    right = splitter->bottom_right_container.

    CREATE OBJECT editor
      EXPORTING parent = right.

    CREATE OBJECT alv_list
      EXPORTING i_parent = left.

    PERFORM fill_fieldcat.


    DATA: layout TYPE lvc_s_layo.
    PERFORM prepare_layout
                CHANGING
                   layout.


*Varianten des ALV-LAYOUTS speichern siehe BÜCHER alv-grid.pdf seite 18
    DATA: x_save, "for Parameter I_SAVE
          gs_variant TYPE disvariant. "for parameter IS_VARIANT.
    DATA:    g_repid TYPE sy-repid.


    g_repid = sy-repid.
    gs_variant-report = g_repid.

    x_save = 'U'. "layouts can only be saved as user specific ones


    CALL METHOD alv_list->set_table_for_first_display
      EXPORTING
        is_layout       = layout
*---- um Varianten des ALV-LAYOUTS zu speichern ----------------------
        is_variant      = gs_variant
        i_save          = x_save
      CHANGING
        it_fieldcatalog = fieldcat
        it_outtab       = liste.

  ENDMETHOD.                    "constructor


  METHOD fill_list.
    CALL METHOD alv_list->refresh_table_display.
  ENDMETHOD.                    "fill_list




ENDCLASS.                    "application IMPLEMENTATION


DATA: object_ref TYPE REF TO application.
DATA: gr_event_handler TYPE REF TO lcl_event_handler .

*&---------------------------------------------------------------------*
*& Processing Blocks called by the JRE                                 *
*&---------------------------------------------------------------------*

START-OF-SELECTION.
  CREATE OBJECT object_ref.
*--Creating an instance for the event handler
  CREATE OBJECT gr_event_handler .
  SET HANDLER gr_event_handler->handle_double_click FOR alv_list .
*---Aufruf des Ausgabescreens-----------------------------------------*
  CALL SCREEN 0100.



*---------------------------------------------------------------------*
*  MODULE status_0100 OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  SET PF-STATUS 'SCREEN_100'.
  CALL METHOD object_ref->fill_list.


* Definition of drag drop behaviour
    CREATE OBJECT behaviour_left.
    CALL METHOD behaviour_left->add
      EXPORTING
        flavor     = 'ALV_move_to_Edit'
        dragsrc    = 'X'
        droptarget = ' '
        effect     = cl_dragdrop=>copy.
    CALL METHOD behaviour_left->add
      EXPORTING
        flavor     = 'ALV_copy_to_Edit'
        dragsrc    = 'X'
        droptarget = ' '
        effect     = cl_dragdrop=>copy.

* Liefert das am Frontend bekannte Handle
* wird den Knoten als Parameter mitgeben
* diese können dann behandelt werden
* handle (ID) von behaviour.left zugeordnet



    call method behaviour_left->get_handle
      IMPORTING
        HANDLE      = handle_alv.


* Drag Drop behaviour of tree control nodes are defined in the node
* structure

* Einfügen eines neuen Types in das behaviour_right
    CREATE OBJECT behaviour_right.
    CALL METHOD behaviour_right->add
      EXPORTING
        flavor     = 'ALV_move_to_Edit'
        dragsrc    = ' '
        droptarget = 'X'
        effect     = cl_dragdrop=>copy.
    CALL METHOD behaviour_right->add
      EXPORTING
        flavor     = 'ALV_copy_to_Edit'
        dragsrc    = ' '
        droptarget = 'X'
        effect     = cl_dragdrop=>copy.
* assign drag drop behaviour to TextEdit
    CALL METHOD editor->set_dragdrop
      EXPORTING
        dragdrop = behaviour_right.
* Registrierung der Drag and Drop Events
    DATA dragdrop TYPE REF TO lcl_dragdrop_receiver.
    CREATE OBJECT dragdrop.
*Setzen Eventhandler
    SET HANDLER dragdrop->flavor_select FOR editor.
    SET HANDLER dragdrop->left_drag FOR alv_list.
    SET HANDLER dragdrop->right_drop FOR editor.
    SET HANDLER dragdrop->drop_complete FOR alv_list.


ENDMODULE.                    "status_0100 OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*

MODULE user_command_0100 INPUT.

  IF sy-ucomm = 'BACK' OR
      sy-ucomm = 'EXIT' OR
      sy-ucomm = 'CANCEL'.
    LEAVE PROGRAM.
  ELSE.
    CALL METHOD object_ref->read_data
      EXPORTING
        eingabeparameter_vname  = npat-vname
        eingabeparameter_nname  = npat-nname
        eingabeparameter_gebdat = datum.
  ENDIF.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&--------------------------------------------------------------------*
*&      Form  handle_double_click
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->I_ROW      text
*      -->I_COLUMN   text
*      -->IS_ROW_NO  text
*---------------------------------------------------------------------*
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.

  IF sy-subrc = 0.

    CALL METHOD alv_list->get_current_cell
      IMPORTING
        e_row   = text_row
        e_value = text_value
        e_col   = text_col.

    PERFORM get_daten.

  ENDIF .
ENDFORM .                    "handle_double_click


*&--------------------------------------------------------------------*
*&      Form  datumbearb
*&--------------------------------------------------------------------*
FORM datumbearb.

  IF datum-high = '00000000'.
    datum-high = datum-low.
  ENDIF.

ENDFORM.                    "datumbearb

*&--------------------------------------------------------------------*
*&      Form  prepare_layout
*&--------------------------------------------------------------------*

FORM prepare_layout CHANGING layout TYPE lvc_s_layo.
* Layout des ALV definieren

  layout-zebra = 'X'.         "Streifenmuster
  layout-no_hgridln = 'X'.
  layout-grid_title = 'Patienten' .
*   Spaltenbreite optimieren
  layout-cwidth_opt = 'X'.
*    layout-smalltitle = 'X' .

ENDFORM. " prepare_layout


*&---------------------------------------------------------------------*
*&      Form  fill_fieldcat
*&---------------------------------------------------------------------*
*   Fieldcat muss die struktur der Daten übergeben werden
*----------------------------------------------------------------------*
FORM fill_fieldcat.
  DATA: wa_fc TYPE LINE OF lvc_t_fcat.

  wa_fc-fieldname = 'PATNR'.
  wa_fc-inttype = 'N'.
  wa_fc-outputlen = '10'.
  wa_fc-coltext = 'Patientennummer'.
  APPEND wa_fc TO fieldcat.

  wa_fc-fieldname = 'TITEL'.
  wa_fc-inttype = 'C'.
  wa_fc-outputlen = '10'.
  wa_fc-coltext = 'Anrede'.
  APPEND wa_fc TO fieldcat.

  wa_fc-fieldname = 'NNAME'.
  wa_fc-inttype = 'C'.
  wa_fc-outputlen = '20'.
  wa_fc-coltext = 'Nachname'.
  APPEND wa_fc TO fieldcat.

  wa_fc-fieldname = 'VNAME'.
  wa_fc-inttype = 'C'.
  wa_fc-outputlen = '20'.
  wa_fc-coltext = 'Vorname'.
  APPEND wa_fc TO fieldcat.

  wa_fc-fieldname = 'GBDAT'.
  wa_fc-inttype = 'N'.
  wa_fc-outputlen = '9'.
  wa_fc-coltext = 'Geburtsdatum'.
  APPEND wa_fc TO fieldcat.

ENDFORM.                    " fill_fieldcat



*&--------------------------------------------------------------------*
*&      Form  get_daten
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM get_daten.
*  DATA: i_daten TYPE TABLE OF npat,
*        wa_i_daten TYPE npat.
*
*  SELECT SINGLE *
*              FROM npat
*              INTO wa_i_daten
*              WHERE patnr = text_value.
*
*  SELECT SINGLE *
*              FROM npat
*              WHERE patnr = text_value.
MESSAGE I007(SU).
ENDFORM.                    "get_daten


gesponsert
Stellenangebote auf ABAPforum.com schalten
kostenfrei für Ausbildungsberufe und Werksstudenten


Beitrag von Jupp (ForumUser / 47 / 0 / 2 ) »

Code: Alles auswählen.

CLASS lcl_event_handler DEFINITION . 
  PUBLIC SECTION . 
    DATA:  e_row TYPE REF TO lvc_s_row. 
    DATA:  e_column TYPE REF TO lvc_s_col. 
    DATA:  es_row_no TYPE lvc_s_roid. 
Die beiden

Code: Alles auswählen.

type ref to
schauen mich etwas komisch an.

Weiterhelfen können die SAP-DemoProgramme
RSDEMO_DRAG_DROP_EDIT_TREE und BCALV_DND_01
Always Better Alternatives Possible.

hmm

Beitrag von abap-strizi (ForumUser / 83 / 0 / 0 ) »
Hmm hab vor lauter herumtüfteln total die Übersicht verloren !!!
Die beiden Reports kannte ich schon allerdings kann ich das ganze nicht in mein Beispiel ummünzen.

Trotzdem danke für die Hilfe!

mfg strizi

Beitrag von Flo ( / / 0 / 3 ) »
Ich setze auch ein ALV mit DragDrop ein, was ich vermisse ist beim erzeugen des Grids ein zuweisen des DragDrop Handles:

call method dragdrop->get_handle
importing
handle = grid_handle.
_layout-s_dragdrop-grid_ddid = grid_handle.

Beitrag von Jupp (ForumUser / 47 / 0 / 2 ) »
Fragt sich jetzt nur noch zu welchem fachlichen Zweck und betriebswirtschaftlichen Behufe man ein Drag&Drop von ALV-Grid zu Textedit braucht.
:shock:
Jupp
neugierigfragend
Always Better Alternatives Possible.

flo ?!?

Beitrag von abap-strizi (ForumUser / 83 / 0 / 0 ) »
Flo könntest mir nicht bitte dein coding von deinem alv d&d posten !??!!

würde mir sehr weiterhelfen !!!

lg strizi

Beitrag von Jupp (ForumUser / 47 / 0 / 2 ) »
Ein Mix aus RSDEMO_DRAG_DROP_EDIT_TREE und BCALV_DND_01 sieht bei mir folgendermassen aus.

Code: Alles auswählen.

REPORT z_test MESSAGE-ID sap.


CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw DEFINITION LOAD.


DATA: g_application TYPE REF TO lcl_application,
      g_docking_container_1 TYPE REF TO cl_gui_docking_container,
      g_docking_container_2 TYPE REF TO cl_gui_docking_container,
      g_alv TYPE REF TO cl_gui_alv_grid,
      g_edit TYPE REF TO cl_gui_textedit,
*     DragDrop Instanzen
      g_behaviour_edit TYPE REF TO cl_dragdrop,
      g_behaviour_alv TYPE REF TO cl_dragdrop,
*
      g_repid LIKE sy-repid,
      g_ok_code TYPE sy-ucomm,
      gt_outtab TYPE TABLE OF sbook,
      g_max TYPE i VALUE 50.

DATA:   gs_layout TYPE lvc_s_layo.

* lokale Klasse für Datentransport
CLASS lcl_dragdropobj DEFINITION.
  PUBLIC SECTION.
    DATA: ls_sbook TYPE sbook,
          index TYPE i.
ENDCLASS.                    "lcl_dragdropobj DEFINITION

*---------------------------------------------------------------------*
*       CLASS LCL_APPLICATION DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
* Methoden für Reaktion auf Drag-Drop Ereignisse
* 3 reichen wenn nur eine Richtung erlaubt

CLASS lcl_application DEFINITION.

  PUBLIC SECTION.

    METHODS:
      handle_alv_drag
        FOR EVENT ondrag
        OF cl_gui_alv_grid
        IMPORTING e_row e_column e_dragdropobj,
      handle_edit_drop
        FOR EVENT on_drop
        OF cl_gui_textedit
        IMPORTING index line pos dragdrop_object,
      handle_alv_drop_complete
        FOR EVENT ondropcomplete
        OF cl_gui_alv_grid
        IMPORTING e_row e_column e_dragdropobj.
ENDCLASS.                    "lcl_application DEFINITION

*---------------------------------------------------------------------*
*       CLASS LCL_APPLICATION IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION.
*-------------------------------------------------------------------
*Drag: Aufnehmen der ALV-Grid Zeile in lokales DragDropObjekt

  METHOD handle_alv_drag.
    DATA: dataobj TYPE REF TO lcl_dragdropobj,
          line TYPE sbook.

*
    READ TABLE gt_outtab INDEX e_row-index INTO line.

*
    CREATE OBJECT dataobj.
    MOVE line TO dataobj->ls_sbook.

*
    MOVE e_row-index TO dataobj->index.

    e_dragdropobj->object = dataobj.
  ENDMETHOD.                    "handle_alv_drag
*--------------------------------------------------------------------
* Ereignishandler für Drop: Einfüllen der Zeile in Editor

  METHOD handle_edit_drop.
    DATA:   dataobj TYPE REF TO lcl_dragdropobj,
            textline(255) TYPE c,
            texttable LIKE TABLE OF textline.



    CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.

      dataobj ?= dragdrop_object->object.
      CALL METHOD g_edit->get_text_as_stream
        IMPORTING
          text = texttable.
      CALL METHOD cl_gui_cfw=>flush.
      MOVE dataobj->ls_sbook-carrid TO textline.
      INSERT textline INTO texttable INDEX 1.
      CALL METHOD g_edit->set_text_as_stream
        EXPORTING
          text            = texttable
        EXCEPTIONS
          error_dp        = 1
          error_dp_create = 2.


    ENDCATCH.
    IF sy-subrc <> 0.
       CALL METHOD dragdrop_object->abort.
    ENDIF.
  ENDMETHOD.                    "handle_edit_drop
*-------------------------------------------------------------------
* Ereignishandler wenn Drop komplett hier als Beispiel Löschen der Zeile
* aus ALV-Grid

  METHOD handle_alv_drop_complete.
    DATA: dataobj TYPE REF TO lcl_dragdropobj.

*
    CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.

      dataobj ?= e_dragdropobj->object.
      IF e_dragdropobj->effect = cl_dragdrop=>move.
*
        DELETE gt_outtab INDEX dataobj->index.
        IF sy-subrc EQ 0.
           CALL METHOD g_alv->refresh_table_display.
        ENDIF.
      ENDIF.
    ENDCATCH.
    IF sy-subrc <> 0.
      CALL METHOD e_dragdropobj->abort.
    ENDIF.
  ENDMETHOD.                    "handle_alv_drop_complete

ENDCLASS.                    "lcl_application IMPLEMENTATION
*&---------------------------------------------------------------------*
*&      Module  PBO_0400  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo_100 OUTPUT.

  SET PF-STATUS 'MAIN'.
  SET TITLEBAR 'MAIN'.
  IF g_alv IS INITIAL.
    PERFORM create_and_init_controls.
  ENDIF.

ENDMODULE.                 " PBO_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PAI_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pai_100 INPUT.

  CASE g_ok_code.
    WHEN 'BACK'. " Finish program
      IF NOT g_docking_container_1 IS INITIAL.
        " destroy tree containers (destroys contained tree control, too)
        CALL METHOD g_docking_container_1->free
          EXCEPTIONS
            cntl_system_error = 1
            cntl_error        = 2.
        IF sy-subrc <> 0.
          MESSAGE a000(sap).
        ENDIF.
        CALL METHOD g_docking_container_2->free
          EXCEPTIONS
            cntl_system_error = 1
            cntl_error        = 2.
        IF sy-subrc <> 0.
          MESSAGE a000.
        ENDIF.
        CALL METHOD cl_gui_cfw=>flush
          EXCEPTIONS
            cntl_system_error = 1
            cntl_error        = 2.
        IF sy-subrc <> 0.
          MESSAGE a000.
        ENDIF.
        CLEAR g_docking_container_1.
        CLEAR g_edit.
        CLEAR g_docking_container_2.
        CLEAR g_alv.
      ENDIF.
      LEAVE PROGRAM.
  ENDCASE.

  CLEAR g_ok_code.
ENDMODULE.                 " PAI_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  CREATE_AND_INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_and_init_controls.
  g_repid = sy-repid.

* create docking container
  CREATE OBJECT g_docking_container_1
    EXPORTING
      repid = g_repid
      dynnr = '100'
      extension = 205
      side  = cl_gui_docking_container=>dock_at_left.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.

* create docking container
  CREATE OBJECT g_docking_container_2
    EXPORTING
      repid = g_repid
      dynnr = '100'
      extension = 160
      side  = cl_gui_docking_container=>dock_at_top.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.

* editor
  CREATE OBJECT g_edit
    EXPORTING
*    MAX_NUMBER_CHARS       =
*    STYLE                  = 0
*    WORDWRAP_MODE          = WORDWRAP_AT_WINDOWBORDER
*    WORDWRAP_POSITION      = -1
*    WORDWRAP_TO_LINEBREAK_MODE = FALSE
*    FILEDROP_MODE          = 1
      parent                 = g_docking_container_1
*    LIFETIME               =
*    NAME                   =
*  EXCEPTIONS
*    ERROR_CNTL_CREATE      = 1
*    ERROR_CNTL_INIT        = 2
*    ERROR_CNTL_LINK        = 3
*    ERROR_DP_CREATE        = 4
*    GUI_TYPE_NOT_SUPPORTED = 5
*    others                 = 6
      .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


* alv control
  CREATE OBJECT g_alv
     EXPORTING i_parent = g_docking_container_2.

* create the application object
  CREATE OBJECT g_application.

* Events alv control
  SET HANDLER g_application->handle_alv_drag FOR g_alv.
  SET HANDLER g_application->handle_alv_drop_complete FOR g_alv.


* Events edit control
  SET HANDLER g_application->handle_edit_drop FOR g_edit.

* describe behaviour of drag&drop
  PERFORM build_handles.


* select and display data from SBOOK
  SELECT * FROM sbook INTO TABLE gt_outtab UP TO g_max ROWS.

  gs_layout-grid_title = text-101.

  CALL METHOD g_alv->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SBOOK'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_outtab.

ENDFORM.                               " CREATE_AND_INIT_CONTROLS
*&---------------------------------------------------------------------*
*&      Form  build_handles
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*

FORM build_handles.

  DATA: node LIKE mtreesnode,
        effect TYPE i,
        handle_edit TYPE i,
        handle_alv TYPE i.


  CREATE OBJECT g_behaviour_edit.
  effect = cl_dragdrop=>move + cl_dragdrop=>copy.
  CALL METHOD g_behaviour_edit->add
    EXPORTING
      flavor     = 'Line'                                   "#EC NOTEXT
      dragsrc    = ' '
      droptarget = 'X'
      effect     = effect.
  CALL METHOD g_behaviour_edit->get_handle
    IMPORTING
      handle = handle_edit.


  CREATE OBJECT g_behaviour_alv.
  effect = cl_dragdrop=>move + cl_dragdrop=>copy.
  CALL METHOD g_behaviour_alv->add
    EXPORTING
      flavor     = 'Line'
      dragsrc    = 'X'
      droptarget = ' '
      effect     = effect.
  CALL METHOD g_behaviour_alv->get_handle
    IMPORTING
      handle = handle_alv.

  CALL METHOD g_edit->set_dragdrop
    EXPORTING
      dragdrop = g_behaviour_edit.

  gs_layout-s_dragdrop-row_ddid = handle_alv.

ENDFORM.                               " build_nodes_and_handles


START-OF-SELECTION.
  SET SCREEN 100.
Ablauf Dynpro

Code: Alles auswählen.

PROCESS BEFORE OUTPUT.
MODULE PBO_100.
*
PROCESS AFTER INPUT.
MODULE PAI_100.
Dynpro 100 hält als einziges Element g_ok_code für den Ok-Code.

Du brauchst aber eigentlich nur bei deinem Code das Modul MODULE status_0100 OUTPUT.

nach
call method behaviour_left->get_handle
IMPORTING
HANDLE = handle_alv.
ergänzen um die Zeile

Code: Alles auswählen.

layout-s_dragdrop-grid_ddid = handle_alv
-die Struktur layout solltest du dann aber als globale Variable setzen.



mfg Jupp
Always Better Alternatives Possible.

Beitrag von Gast ( / / 0 / 3 ) »
Hallo,
schau dir doch den Beispielreport RSDEMO_DRAG_DROP_EDIT_TREE aus der Transktion DWDM an.
Ist zwar ein Tree aber das solltest du ja dann auch hinkriegen.
Gruß

Seite 1 von 1

Vergleichbare Themen

2
Antw.
1478
Views
TextEdit Verwaltung
von Miss » 17.04.2014 14:55 • Verfasst in ABAP® für Anfänger
0
Antw.
1911
Views
Toolbar im Textedit-Control?
von ewx » 30.08.2007 15:42 • Verfasst in ABAP Objects®
3
Antw.
3919
Views
Dynpro Textedit-Control
von gazzle » 19.01.2010 12:00 • Verfasst in Dialogprogrammierung
1
Antw.
2416
Views
TextEdit Control nicht eingabebereit ?
von jesse001 » 13.11.2019 17:46 • Verfasst in Dialogprogrammierung
7
Antw.
8025
Views
Textedit-Control in modalem Dialogfenster
von PatrickMA » 20.04.2006 13:34 • Verfasst in Dialogprogrammierung

Über diesen Beitrag


Unterstütze die Community und teile den Beitrag für mehr Leser und Austausch

Aktuelle Forenbeiträge

Dialog-Container mit Toolbar/Status
vor 11 Stunden von black_adept gelöst 23 / 3663
User Exit EXIT_RQCPRM10_001
vor 12 Stunden von a-dead-trousers 2 / 259
Trennen Strasse und Hausnummer
vor 18 Stunden von payten 13 / 10588
Daten an Tabelle binden
Gestern von Lukas Sanders 2 / 1308

Newsletter Anmeldung

Keine Beiträge verpassen! Wöchentlich versenden wir lesenwerte Beiträge aus unserer Community.
Die letzte Ausgabe findest du hier.
Details zum Versandverfahren und zu Ihren Widerrufsmöglichkeiten findest du in unserer Datenschutzerklärung.

Aktuelle Forenbeiträge

Dialog-Container mit Toolbar/Status
vor 11 Stunden von black_adept gelöst 23 / 3663
User Exit EXIT_RQCPRM10_001
vor 12 Stunden von a-dead-trousers 2 / 259
Trennen Strasse und Hausnummer
vor 18 Stunden von payten 13 / 10588
Daten an Tabelle binden
Gestern von Lukas Sanders 2 / 1308

Unbeantwortete Forenbeiträge

aRFC im OO-Kontext
vor 4 Wochen von ralf.wenzel 1 / 2852
Hilfe bei SWEC/SWE2
September 2024 von retsch 1 / 9441