Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Tree in Docking Control

Former Member
0 Likes
1,391

Hi,

Can someone tell me as to how can we create an ALV Tree in the Docking Control??

What are the classes and methods used?

Can you send me the steps and the related code if possible?

Thanks,

Supriya Manik.

Hi,

Can someone tell me as to how can we create an ALV Tree in the Docking Control??

What are the classes and methods used?

Can you send me the steps and the related code if possible?

Thanks,

Supriya Manik.

5 REPLIES 5
Read only

Former Member
0 Likes
996

Hi

please check the below code it will be help full to you.

----


  • PROGRAM : ZCN_CONTROLS_DRAG_DROP_GB02 *

  • TITLE : DRAG AND DROP *

  • AUTHOR : BHANU P R GATTU *

  • DESCRIPTION : THIS IS AN EXAMPLE PROGRAM ON MATERIALS *

----


  • MODIFICATION LOG *

----


REPORT zcn_controls_drag_drop_gb02 NO STANDARD PAGE HEADING

MESSAGE-ID z_mm_pr_gb01.

----


  • DATA DECLRTION *

----


*-----Variable declaration.

DATA v_handle TYPE i.

*-----Instance declaration for custom, splitter and abstract container

DATA : i_container TYPE REF TO cl_gui_custom_container,

i_splitter TYPE REF TO cl_gui_easy_splitter_container,

i_con_right TYPE REF TO cl_gui_container,

i_con_left TYPE REF TO cl_gui_container.

*-----Instance declaration for textedit,simple tree and dragdrop

DATA : i_editor TYPE REF TO cl_gui_textedit,

i_tree TYPE REF TO cl_gui_simple_tree,

i_dragdrop_left TYPE REF TO cl_dragdrop,

i_dragdrop_right TYPE REF TO cl_dragdrop.

*-----Internal table for simple tree

DATA node_itab LIKE node_str OCCURS 0 WITH HEADER LINE.

*-----Structure for simpletree

DATA node LIKE node_str.

*-----Tree control declaration for simple tree

DATA: node1 LIKE mtreesnode.

*-----Internal table for material numbers.

DATA : BEGIN OF itab OCCURS 0,

matnr(18),

END OF itab.

----


  • SELECTION SCREEN PARAMETERS *

----


SELECTION-SCREEN BEGIN OF BLOCK mybox WITH FRAME TITLE text-001.

PARAMETER p_no_mat TYPE i.

SELECTION-SCREEN END OF BLOCK mybox.

----


  • AT SELECTION SCREEN *

----


AT SELECTION-SCREEN ON p_no_mat.

IF p_no_mat > 10.

MESSAGE e004(z_mm_pr_gb01).

ENDIF.

IF p_no_mat IS INITIAL.

MESSAGE e005(z_mm_pr_gb01).

ENDIF.

----


  • CLASS lcl_dragdrop DEFINITION *

----


CLASS lcl_dragdrop DEFINITION.

PUBLIC SECTION.

*-----Variable declaration to store node data.

DATA v_text TYPE mtreesnode-text.

METHODS :

*-----Method for event to drag selected flavor

drag FOR EVENT on_drag

OF cl_gui_simple_tree

IMPORTING node_key drag_drop_object,

*-----Method for event to drop selected flavor

drop FOR EVENT on_drop

OF cl_gui_textedit

IMPORTING index line pos dragdrop_object.

ENDCLASS. "lcl_dragdrop DEFINITION

----


  • START-OF-SELECTION *

----


START-OF-SELECTION.

*-----Calling the screen to dispaly custom container

CALL SCREEN 100.

END-OF-SELECTION.

----


  • Module STATUS_0100 OUTPUT

----


MODULE status_0100 OUTPUT.

*-----To creat menu bar

SET PF-STATUS 'MENU'.

*-----To check if container is initial or not.

IF i_container IS INITIAL.

*-----Creat object for custom container

CREATE OBJECT i_container

EXPORTING

container_name = 'CUSTOM_CONTROL'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

*-----Creating object for splitter container

CREATE OBJECT i_splitter

EXPORTING

parent = i_container

orientation = 0

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

OTHERS = 3.

*-----To store splitter container attributes into instance of gui

*-----container.

i_con_left = i_splitter->top_left_container.

i_con_right = i_splitter->bottom_right_container.

*-----Creating object Textedit on bottom right

CREATE OBJECT i_editor

EXPORTING

parent = i_con_right

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

OTHERS = 6.

*-----Creating object for simple tree on top left

CREATE OBJECT i_tree

EXPORTING

parent = i_con_left

node_selection_mode = i_tree->node_sel_mode_single

EXCEPTIONS

lifetime_error = 1

cntl_system_error = 2

create_error = 3

failed = 4

illegal_node_selection_mode = 5

OTHERS = 6.

*-----Creating object for dragdrop

CREATE OBJECT i_dragdrop_left.

*-----Calling the method To insert a new type into behavior

PERFORM add USING i_dragdrop_left.

*-----Calling the method returns handle known at frontend

CALL METHOD i_dragdrop_left->get_handle

IMPORTING

handle = v_handle

EXCEPTIONS

obj_invalid = 1

OTHERS = 2.

*-----Selecting material numbers to display as nodes

SELECT matnr

FROM mara

INTO

  • CORRESPONDING FIELDS OF

TABLE itab

UP TO p_no_mat ROWS.

*-----Creating the tree for top left

CLEAR node1.

node1-node_key = 'Materialnumbers'.

node1-isfolder = 'X'.

node1-text = 'Materialnumbers'.

node1-dragdropid = ' '.

APPEND node1 TO node_itab.

*-----Creating the nodes using material numbers for tree

LOOP AT itab.

CASE sy-tabix.

WHEN 1.

PERFORM tree_node USING 'x' .

WHEN 2.

PERFORM tree_node USING 'x1' .

WHEN 3.

PERFORM tree_node USING 'x2' .

WHEN 4.

PERFORM tree_node USING 'x3' .

WHEN 5.

PERFORM tree_node USING 'x4' .

WHEN 6.

PERFORM tree_node USING 'x5' .

WHEN 7.

PERFORM tree_node USING 'x6' .

WHEN 8.

PERFORM tree_node USING 'x7' .

WHEN 9.

PERFORM tree_node USING 'x8' .

WHEN 10.

PERFORM tree_node USING 'x9' .

ENDCASE.

ENDLOOP.

*-----Calling the method to add the nodes to tree

CALL METHOD i_tree->add_nodes

EXPORTING

table_structure_name = 'node_structure'

node_table = node_itab[]

EXCEPTIONS

error_in_node_table = 1

failed = 2

dp_error = 3

table_structure_name_not_found = 4

OTHERS = 5.

*-----Creating object for dragdrop

CREATE OBJECT i_dragdrop_right.

*-----Calling the method to insert a new type into behavior

PERFORM add USING i_dragdrop_right.

*-----Calling the method to assign dragdrop behavior to textedit

CALL METHOD i_editor->set_dragdrop

EXPORTING

dragdrop = i_dragdrop_right.

*-----Instance declaration for local class.

DATA dragdrop TYPE REF TO lcl_dragdrop.

*-----Creating object for local class.

CREATE OBJECT dragdrop.

*-----Set handler for event in drag method.

SET HANDLER dragdrop->drag FOR i_tree.

*-----Set handler for event in drop method.

SET HANDLER dragdrop->drop FOR i_editor.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

----


  • Module USER_COMMAND_0100 INPUT *

----


MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'CANCLE'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

----


  • CLASS lcl_dragdrop IMPLEMENTATION

----


CLASS lcl_dragdrop IMPLEMENTATION.

*-----Method implementation for on_drag event

METHOD drag.

*-----Instance declaration for local class

DATA drag_obj TYPE REF TO lcl_dragdrop.

*-----Creating the object for local class

CREATE OBJECT drag_obj.

*-----Reading the selected node value.

READ TABLE node_itab

WITH KEY node_key = node_key

INTO node.

*-----Assigning the selected text

drag_obj->v_text = node-text.

*-----Assigning the textobject

drag_drop_object->object = drag_obj.

ENDMETHOD. "drag

*-----Method implementation for on_drop event.

METHOD drop.

*-----Variable declaration

DATA v_textline(256).

*-----Creating a table to store the selected text

DATA text_table LIKE STANDARD TABLE OF v_textline.

*-----Instance declaration for local class

DATA drag_object TYPE REF TO lcl_dragdrop.

*-----To execute runtime errors and exception groups any order.

CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.

drag_object ?= dragdrop_object->object.

ENDCATCH.

*-----Calling the method to send table dat to frontend.

SELECT SINGLE maktx FROM makt INTO v_textline

WHERE matnr = node-text and spras = 'EN'.

INSERT v_textline INTO text_table INDEX 1.

*-----Calling the method to send modified table to frontend

CALL METHOD i_editor->set_text_as_stream

EXPORTING

text = text_table

EXCEPTIONS

error_dp = 1

error_dp_create = 2.

ENDMETHOD. "drop

ENDCLASS. "lcl_dragdrop IMPLEMENTATION

----


  • Form tree_node *

----


FORM tree_node USING a.

CLEAR node1.

node1-node_key = a.

node1-relatkey = 'Materialnumbers'.

node1-relatship = cl_gui_simple_tree=>relat_last_child.

node1-text = itab-matnr.

node1-dragdropid = v_handle.

APPEND node1 TO node_itab.

ENDFORM. "tree_node

----


  • Form add *

----


FORM add USING object TYPE REF TO cl_dragdrop.

CALL METHOD object->add

EXPORTING

flavor = 'BhanuPrakash_move'

dragsrc = 'X'

droptarget = 'x'

effect = cl_dragdrop=>copy

EXCEPTIONS

already_defined = 1

obj_invalid = 2

OTHERS = 3.

ENDFORM. "add

Thanks,

Bhanu Gattu

Read only

Former Member
0 Likes
996

hi,

check these below links may be helpful for you......

http://www.sapdesignguild.org/resources/MiniSG/1_Designing/1_Explicit_Selection.htm

/people/igor.barbaric/blog/2006/05/03/oo-abap-and-design-patterns-3-docking-containers-controller

If not useful for you sorry to waste your time

~~Guduri

Read only

Former Member
0 Likes
996

do control+ f in this below link for docking control.. u may find some more info..

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESITSSAPGUIHTML/BCFESITSSAPGUIHTML.pdf

one more link for you....

http://www.sap-hefte.de/download/dateien/1025/087_leseprobe.pdf

Read only

Former Member
Read only

Former Member
0 Likes
996

Supriya,

Plsease check the programs in

tcode "DWDM">container contrls>program "RSDEMO_DOCKING_CONTROL"

Or SE83

Don't forget to reward if useful.....