Exending SAME ALV tree control to different screens
Hi Experts,
I have to extend same ALV tree control to other different screens:
For exmaple:
I have screen 100 in that I have splitter control on Left ( say TREE_LEFT) which has ALV tree (ref to CL_GUI_ALV_TREE).
The same Tree I want to show it in Screen 200 with the same reference(TREE_LEFT) ..I do not want to create another rererence to for the same tree control, as I have to show the same tree display in screen 200 also.
Please suggest.
Regards,
Sathishkumar.V
Hi Sathish,
You are passing the Data to the Screen 100,200,..... by using ALV_GRID OO concept.so the screen is not a constant one.
It is possible to pass the Data (Based on the ALV_TREE user selection) and Modify the Screen dynamically by designing the Fieldcat.
So use only one screen may it 100 or 200 and then Pass data based on the user selection from the Tree control.
For Example Go to TCODE WE02 Execute it will appear one ALV Tree, Based on the Idocs in the Left side tree then screen will display the dynamic Data.
Thanks,
Kanagaraja .L
Similar Messages
-
Help required in ALV Tree Control
Hi All,
I am using OO ALV tree Control in my Project every thing is working fine.
in treecontrol 'If we double click on Node I con it displays resultant screen'- its fine for us
'If we double click on Node Text it is displaying nothing means no Event is triggering.
my Requirement is tha 'it should work even if we click on Node Text' . Like in standard Applications SE15 .
Suggest some Methods regarding this. Note All these nodes are Dynamic Nodes comes from Data Base table.
Thanks in Adv.
MurthyJust check Tcode: DWDM.
Good no of example programs for oops tree are available there -
S_ALR_87012284 - List Output - ALV Tree Control
Dear Friends,
In Standard Financial statement report when I use List output -> ALV Tree Control lay out. In the display area is it possible to save the expanded folders in lay out. So that next time when I run the report with the same ALV Tree Contorl lay out, I would like to see folders expanded.
Thanks,
VenkyHi Venky,
There is no way to have expanded tree list. You must hit Expand tree button to.
You can also use ttrasaction code F.01 for balance sheet.
Best regards -
TRIAL BALANCE WITH ALV TREE CONTROL
Hi Friends,
My manager wants to see trial balance with cost centers like ALV tree control display.
Does SAP have any Std trial balance report which can show cost centers also for accounts and activities within those cost centers.
Please help.
ThanksNelow message will appear and not possible technically
Output option ALV Tree Control: Parameter Scaling set to 0/0
Message no. FR098
Diagnosis
You selected output option ALV Tree Control. For technical reasons, only the value 0/0 is possible for the parameter Scaling.
System Response
Parameter Scaling set to the value 0/0.
Procedure
If you want to compare the program output for output options ALV Tree Control and Classical list, you have to also set the parameter Scaling to '0/0' when running the program with output option Classical list. -
Scaling in F.01 with ALV Tree Control
Hi Experts,
Is there any possibility of generating the financial statements in F.01 in ALV tree control with amount scaled to 3 or 5 zero's. When i try to use ALV with scaling, the scaling is reset to 0
Thanks in AdvanceNelow message will appear and not possible technically
Output option ALV Tree Control: Parameter Scaling set to 0/0
Message no. FR098
Diagnosis
You selected output option ALV Tree Control. For technical reasons, only the value 0/0 is possible for the parameter Scaling.
System Response
Parameter Scaling set to the value 0/0.
Procedure
If you want to compare the program output for output options ALV Tree Control and Classical list, you have to also set the parameter Scaling to '0/0' when running the program with output option Classical list. -
Hi experts,
How to create tree node with folder symbol dynamically in alv tree control.
Thanks
Ramesh VRIt is just a tree structure display in ALV output mode
BCALV_TREE_DEMO Demo program for ALV tree control
Many times in Finance there are requirements where User wants to see balance sheet report based on cost center groups and cost centres within it in this form -
How to avoid multiple selection in ALV tree control?
Hi,
Experts,
I want to avoid multiple selections on Alv tree control after pressing control keyboard button(Ctrl). Even by pressing Ctrl keyword button i want to select only one row of a Alv tree control.i have used cl_salv_tree class for it is there any method to achieve this please pass some code/idea on it.
Thanks in advance,
Shabeer ahmed.I haven't tried it before but it should help.
[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01] -
Drag and Drop between two ALV Tree Controls
Hello all,
I have designed a spilt control of two ALV Trees using CL_GUI_ALV_TREE.
I have a top node as the Sales order Number and the child node as the items belonging to that sales order number.
Now i need to drag and drop the lines from one sales order to another.
Also these drag drop can take place between the nodes of the two different trees.
Can someone provide with a detail example as i need to complete the same urgently.
Regards,
ArunOnce check the Below code For tree to tree drag an drop
* CLASS lcl_main DEFINITION
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
* Types
TYPES:
BEGIN OF t_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
END OF t_ekpo.
TYPES:
BEGIN OF t_vbap,
vbeln TYPE vbeln,
posnr TYPE vbelp,
END OF t_vbap.
* Internal Tables
DATA:
i_ekpo TYPE STANDARD TABLE OF t_ekpo,
i_ekpo_op TYPE STANDARD TABLE OF t_ekpo,
i_vbap TYPE STANDARD TABLE OF t_vbap,
i_vbap_op TYPE STANDARD TABLE OF t_vbap,
i_fcat_ekpo TYPE lvc_t_fcat,
i_fcat_vbap TYPE lvc_t_fcat.
* Work Areas
DATA:
wa_ekpo TYPE t_ekpo,
wa_ekpo1 TYPE t_ekpo,
wa_vbap TYPE t_vbap,
wa_vbap1 TYPE t_vbap.
* Data Declarations
DATA:
g_ebeln TYPE ebeln,
g_vbeln TYPE vbeln_va.
DATA: g_variant TYPE disvariant,
g_hierarchy_header TYPE treev_hhdr,
g_handle_drag TYPE i,
g_handle_drop TYPE i.
* Class data
DATA:
splitter TYPE REF TO cl_gui_splitter_container,
container TYPE REF TO cl_gui_custom_container,
container_1 TYPE REF TO cl_gui_container,
container_2 TYPE REF TO cl_gui_container,
tree1 TYPE REF TO cl_gui_alv_tree,
tree2 TYPE REF TO cl_gui_alv_tree,
g_drag TYPE REF TO cl_dragdrop,
g_drop TYPE REF TO cl_dragdrop.
* Constants
CONSTANTS:
c_30(2) TYPE c VALUE '30'.
* Methods
METHODS:
get_data, " Data Fatch
build_display, " Display Container
display_ekpo, " Ekpo table display
display_vbap, " Vbap table display
add_node_ekpo " Add node to Ekpo
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
add_node_vbap " Add node to vbap
IMPORTING table TYPE t_vbap
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
dnd_behaviour, " Drag and drop behavour
register_events_ekpo, " Register Events Ekpo
register_events_vbap, " Register events vbap
handle_drag_multiple " Drag Multiple Values
FOR EVENT on_drag_multiple
OF cl_gui_alv_tree
IMPORTING sender node_key_table fieldname drag_drop_object,
handle_drop " Drop the values
FOR EVENT on_drop
OF cl_gui_alv_tree
IMPORTING sender node_key drag_drop_object,
add_node_drop " Add node to Drop Node
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
CHANGING i_key TYPE lvc_nkey.
ENDCLASS. " Lcl_main DEFINITION
* CLASS LCL_DRAGOBJ DEFINITION
* Drag And drop Structure
CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
PUBLIC SECTION.
* Types
TYPES: BEGIN OF t_node_info,
l_ekpo TYPE t_ekpo,
l_node_text TYPE lvc_value,
l_node_key TYPE lvc_nkey,
END OF t_node_info.
* Data
DATA: i_node_info TYPE TABLE OF t_node_info,
wa_node_info TYPE t_node_info.
ENDCLASS. " LCL_DRAGOBJ DEFINITION
* Object Declarations
DATA obj_main TYPE REF TO lcl_main.
* Initialization *
INITIALIZATION.
CREATE OBJECT obj_main.
* Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
SELECT-OPTIONS:
s_ebeln FOR obj_main->g_ebeln,
s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT cs_vbeln.
SELECTION-SCREEN END OF BLOCK block1.
* Start of Selection *
START-OF-SELECTION.
* Call Screen
CALL SCREEN 100.
* CLASS lcl_main IMPLEMENTATION
* Local class Implementation
CLASS lcl_main IMPLEMENTATION.
* Get Data *
METHOD get_data.
* Data from Ekpo
SELECT ebeln
ebelp
FROM ekpo
UP TO 100 ROWS
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln.
* Data from Vbap
SELECT vbeln
posnr
FROM vbap
UP TO 100 ROWS
INTO TABLE i_vbap
WHERE vbeln IN s_vbeln.
ENDMETHOD. " Get_data
* Build Display *
METHOD build_display.
* Create Container
CREATE OBJECT container
EXPORTING
container_name = 'CUST_CONT'.
* Split the container
CREATE OBJECT splitter
EXPORTING
parent = container
rows = 1
columns = 2.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container_1.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = container_2.
* create tree control
CREATE OBJECT tree1
EXPORTING
parent = container_1
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
CREATE OBJECT tree2
EXPORTING
parent = container_2
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
g_variant-report = sy-repid.
g_variant-handle = space.
g_variant-log_group = space.
g_variant-username = space.
g_variant-text = space.
g_variant-dependvars = space.
* Call method for get data
CALL METHOD get_data.
* Drap And Drop behaviour method
CALL METHOD dnd_behaviour.
* Display the Ekpo table
CALL METHOD obj_main->display_ekpo.
* Diaplay the vbap table
CALL METHOD obj_main->display_vbap.
CALL METHOD tree1->frontend_update.
CALL METHOD tree2->frontend_update.
ENDMETHOD. " Build_display
* Display EKPO *
METHOD display_ekpo.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'EKPO'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_ekpo
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_ekpo FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Purchase Order Details'(001).
g_hierarchy_header-tooltip = 'Purchase Order'(002).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Diaply
CALL METHOD tree1->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_ekpo_op
it_fieldcatalog = i_fcat_ekpo.
LOOP AT i_ekpo INTO wa_ekpo1.
MOVE wa_ekpo1 TO wa_ekpo.
l_key1 = ''.
AT NEW ebeln.
MOVE wa_ekpo-ebeln TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key1
text = l_node_text
flag = space
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_ekpo-ebelp TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key2
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_ekpo INTO wa_ekpo1.
* Call method For Register events
CALL METHOD register_events_ekpo.
ENDMETHOD. " Display_ekpo
* Display VBAP *
METHOD display_vbap.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
REFRESH i_fcat_vbap.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'VBAP'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_vbap
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_vbap FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Sales Order Details'(003).
g_hierarchy_header-tooltip = 'Sales Order'(004).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Display
CALL METHOD tree2->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_vbap_op
it_fieldcatalog = i_fcat_vbap.
LOOP AT i_vbap INTO wa_vbap1.
MOVE wa_vbap1 TO wa_vbap.
l_key1 = ''.
AT NEW vbeln.
MOVE wa_vbap-vbeln TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key1
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_vbap-posnr TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key2
text = l_node_text
flag = space
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_vbap INTO wa_vbap1.
* Call method For Register events
CALL METHOD register_events_vbap.
ENDMETHOD. " Display_vbap
* Add Node to Ekko *
METHOD add_node_ekpo.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drag.
ENDIF. " IF flag = 'X'.
* Add node to tree1
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
ENDMETHOD. " Add_node_ekpo
* Add Node to Vbap *
METHOD add_node_vbap.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drop.
ENDIF. " IF flag = 'X'.
* Add node for tree2
CALL METHOD tree2->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
ENDMETHOD. " Add_node_vbap
* Dnd behaviour *
METHOD dnd_behaviour.
* Data
DATA: effect TYPE i,
l_flavor TYPE c VALUE 'f'.
* For drag
CREATE OBJECT g_drag.
effect = cl_dragdrop=>copy.
CALL METHOD g_drag->add
EXPORTING
flavor = l_flavor
dragsrc = 'X'
droptarget = ' '
effect = effect
effect_in_ctrl = effect.
CALL METHOD g_drag->get_handle
IMPORTING
handle = g_handle_drag.
* For Drop
CREATE OBJECT g_drop.
effect = cl_dragdrop=>copy.
CALL METHOD g_drop->add
EXPORTING
flavor = l_flavor
dragsrc = ' '
droptarget = 'X'
effect = effect
effect_in_ctrl = effect.
CALL METHOD g_drop->get_handle
IMPORTING
handle = g_handle_drop.
ENDMETHOD. " Dnd_behaviour
* register events *
METHOD register_events_ekpo.
* Data
DATA: lt_events TYPE cntl_simple_events.
* Tree events registers ALV Tree
CALL METHOD tree1->get_registered_events
IMPORTING
events = lt_events.
* Register events on frontend
CALL METHOD tree1->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
* Event Handling
SET HANDLER obj_main->handle_drag_multiple FOR tree1.
ENDMETHOD. " Register_events_ekpo
* register events *
METHOD register_events_vbap.
* Data
DATA: lt_events TYPE cntl_simple_events.
* Tree events registers ALV Tree
CALL METHOD tree2->get_registered_events
IMPORTING
events = lt_events.
* Register events on frontend
CALL METHOD tree2->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
* Event
SET HANDLER obj_main->handle_drop FOR tree2.
ENDMETHOD. " Register_events_vbap
* Handle drag multiple Values *
METHOD handle_drag_multiple.
* Data
DATA: dataobj TYPE REF TO lcl_dragobj,
l_node_key TYPE lvc_nkey,
l_ekpo TYPE t_ekpo,
l_node_text TYPE lvc_value,
l_node_layout TYPE lvc_s_layn.
* Create and fill dataobject for event ON_DROP.
CREATE OBJECT dataobj.
* Loop the Node key Table
LOOP AT node_key_table INTO l_node_key.
CALL METHOD sender->get_outtab_line
EXPORTING
i_node_key = l_node_key
IMPORTING
e_outtab_line = l_ekpo
e_node_text = l_node_text
es_node_layout = l_node_layout.
IF l_node_layout-isfolder NE 'X'.
dataobj->wa_node_info-l_node_key = l_node_key.
dataobj->wa_node_info-l_ekpo = l_ekpo.
dataobj->wa_node_info-l_node_text = l_node_text.
APPEND dataobj->wa_node_info TO dataobj->i_node_info.
ENDIF. " IF l_node_layout-isfolder NE 'X'.
ENDLOOP. " LOOP AT node_key_table INTO l_node_key
drag_drop_object->object = dataobj.
ENDMETHOD. " Handle_drag_multiple
* Handle drop multiple Values *
METHOD handle_drop.
DATA: dataobj TYPE REF TO lcl_dragobj,
l_new_key TYPE lvc_nkey,
l_node_text TYPE lvc_value.
CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.
* ON_DROP
dataobj ?= drag_drop_object->object.
LOOP AT dataobj->i_node_info INTO dataobj->wa_node_info.
MOVE dataobj->wa_node_info-l_node_text TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_drop
EXPORTING
table = dataobj->wa_node_info-l_ekpo
key = node_key
text = l_node_text
CHANGING
i_key = l_new_key.
ENDLOOP. " LOOP AT dataobj->i_node_info INTO dataobj->wa_node_inf
* Expand the node
CALL METHOD sender->expand_node
EXPORTING
i_node_key = node_key
CALL METHOD sender->frontend_update.
ENDCATCH.
IF sy-subrc NE 0.
CALL METHOD drag_drop_object->abort.
ENDIF. " IF sy-subrc NE 0
ENDMETHOD. " Handle_drop
* Add Node to drop *
METHOD add_node_drop.
* Add node to drop tree
CALL METHOD tree2->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
* is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0
ENDMETHOD. " Add_node_drop
ENDCLASS. " lcl_main IMPLEMENTATION
*& Module STATUS_0100 OUTPUT
* Screen 100 Pbo
MODULE status_0100 OUTPUT.
SET PF-STATUS 'BACK'.
* SET TITLEBAR 'xxx'.
CALL METHOD obj_main->build_display.
ENDMODULE. " Status_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* Screen 100 Pai
MODULE user_command_0100 INPUT.
IF sy-ucomm EQ 'BACK'.
LEAVE TO SCREEN 0.
ENDIF. " IF sy-ucomm EQ 'BACK'
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Report ZBPS_TREE_DRAG_DROP
REPORT zbps_tree_drag_drop.
* CLASS lcl_main DEFINITION
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
* Types
TYPES:
BEGIN OF t_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
END OF t_ekpo.
TYPES:
BEGIN OF t_vbap,
vbeln TYPE vbeln,
posnr TYPE vbelp,
END OF t_vbap.
* Internal Tables
DATA:
i_ekpo TYPE STANDARD TABLE OF t_ekpo,
i_ekpo_op TYPE STANDARD TABLE OF t_ekpo,
i_vbap TYPE STANDARD TABLE OF t_vbap,
i_vbap_op TYPE STANDARD TABLE OF t_vbap,
i_fcat_ekpo TYPE lvc_t_fcat,
i_fcat_vbap TYPE lvc_t_fcat.
* Work Areas
DATA:
wa_ekpo TYPE t_ekpo,
wa_ekpo1 TYPE t_ekpo,
wa_vbap TYPE t_vbap,
wa_vbap1 TYPE t_vbap.
* Data Declarations
DATA:
g_ebeln TYPE ebeln,
g_vbeln TYPE vbeln_va.
DATA: g_variant TYPE disvariant,
g_hierarchy_header TYPE treev_hhdr,
g_handle_drag TYPE i,
g_handle_drop TYPE i.
* Class data
DATA:
splitter TYPE REF TO cl_gui_splitter_container,
container TYPE REF TO cl_gui_custom_container,
container_1 TYPE REF TO cl_gui_container,
container_2 TYPE REF TO cl_gui_container,
tree1 TYPE REF TO cl_gui_alv_tree,
tree2 TYPE REF TO cl_gui_alv_tree,
g_drag TYPE REF TO cl_dragdrop,
g_drop TYPE REF TO cl_dragdrop.
* Constants
CONSTANTS:
c_30(2) TYPE c VALUE '30'.
* Methods
METHODS:
get_data, " Data Fatch
build_display, " Display Container
display_ekpo, " Ekpo table display
display_vbap, " Vbap table display
add_node_ekpo " Add node to Ekpo
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
add_node_vbap " Add node to vbap
IMPORTING table TYPE t_vbap
key TYPE lvc_nkey
text TYPE lvc_value
flag TYPE c
CHANGING i_key TYPE lvc_nkey,
dnd_behaviour, " Drag and drop behavour
register_events_ekpo, " Register Events Ekpo
register_events_vbap, " Register events vbap
handle_drag_multiple " Drag Multiple Values
FOR EVENT on_drag_multiple
OF cl_gui_alv_tree
IMPORTING sender node_key_table fieldname drag_drop_object,
handle_drop " Drop the values
FOR EVENT on_drop
OF cl_gui_alv_tree
IMPORTING sender node_key drag_drop_object,
add_node_drop " Add node to Drop Node
IMPORTING table TYPE t_ekpo
key TYPE lvc_nkey
text TYPE lvc_value
CHANGING i_key TYPE lvc_nkey.
ENDCLASS. " Lcl_main DEFINITION
* CLASS LCL_DRAGOBJ DEFINITION
* Drag And drop Structure
CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
PUBLIC SECTION.
* Types
TYPES: BEGIN OF t_node_info,
l_ekpo TYPE t_ekpo,
l_node_text TYPE lvc_value,
l_node_key TYPE lvc_nkey,
END OF t_node_info.
* Data
DATA: i_node_info TYPE TABLE OF t_node_info,
wa_node_info TYPE t_node_info.
ENDCLASS. " LCL_DRAGOBJ DEFINITION
* Object Declarations
DATA obj_main TYPE REF TO lcl_main.
* Initialization *
INITIALIZATION.
CREATE OBJECT obj_main.
* Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
SELECT-OPTIONS:
s_ebeln FOR obj_main->g_ebeln,
s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT cs_vbeln.
SELECTION-SCREEN END OF BLOCK block1.
* Start of Selection *
START-OF-SELECTION.
* Call Screen
CALL SCREEN 100.
* CLASS lcl_main IMPLEMENTATION
* Local class Implementation
CLASS lcl_main IMPLEMENTATION.
* Get Data *
METHOD get_data.
* Data from Ekpo
SELECT ebeln
ebelp
FROM ekpo
UP TO 100 ROWS
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln.
* Data from Vbap
SELECT vbeln
posnr
FROM vbap
UP TO 100 ROWS
INTO TABLE i_vbap
WHERE vbeln IN s_vbeln.
ENDMETHOD. " Get_data
* Build Display *
METHOD build_display.
* Create Container
CREATE OBJECT container
EXPORTING
container_name = 'CUST_CONT'.
* Split the container
CREATE OBJECT splitter
EXPORTING
parent = container
rows = 1
columns = 2.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = container_1.
CALL METHOD splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = container_2.
* create tree control
CREATE OBJECT tree1
EXPORTING
parent = container_1
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
CREATE OBJECT tree2
EXPORTING
parent = container_2
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = 'X'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
g_variant-report = sy-repid.
g_variant-handle = space.
g_variant-log_group = space.
g_variant-username = space.
g_variant-text = space.
g_variant-dependvars = space.
* Call method for get data
CALL METHOD get_data.
* Drap And Drop behaviour method
CALL METHOD dnd_behaviour.
* Display the Ekpo table
CALL METHOD obj_main->display_ekpo.
* Diaplay the vbap table
CALL METHOD obj_main->display_vbap.
CALL METHOD tree1->frontend_update.
CALL METHOD tree2->frontend_update.
ENDMETHOD. " Build_display
* Display EKPO *
METHOD display_ekpo.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'EKPO'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_ekpo
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_ekpo FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Purchase Order Details'(001).
g_hierarchy_header-tooltip = 'Purchase Order'(002).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Diaply
CALL METHOD tree1->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_ekpo_op
it_fieldcatalog = i_fcat_ekpo.
LOOP AT i_ekpo INTO wa_ekpo1.
MOVE wa_ekpo1 TO wa_ekpo.
l_key1 = ''.
AT NEW ebeln.
MOVE wa_ekpo-ebeln TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key1
text = l_node_text
flag = space
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_ekpo-ebelp TO l_node_text.
* Call method for Add Node to Ekpo
CALL METHOD add_node_ekpo
EXPORTING
table = wa_ekpo
key = l_key2
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_ekpo INTO wa_ekpo1.
* Call method For Register events
CALL METHOD register_events_ekpo.
ENDMETHOD. " Display_ekpo
* Display VBAP *
METHOD display_vbap.
* Data
DATA:
l_key1 TYPE lvc_nkey,
l_key2 TYPE lvc_nkey,
l_key3 TYPE lvc_nkey,
l_node_text TYPE lvc_value.
REFRESH i_fcat_vbap.
* ALV control service modules
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = 'X'
i_structure_name = 'VBAP'
i_client_never_display = 'X'
i_bypassing_buffer = space
CHANGING
ct_fieldcat = i_fcat_vbap
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
DELETE i_fcat_vbap FROM 4.
ENDIF. " IF sy-subrc EQ 0.
g_hierarchy_header-heading = 'Sales Order Details'(003).
g_hierarchy_header-tooltip = 'Sales Order'(004).
g_hierarchy_header-width = c_30.
g_hierarchy_header-width_pix = ' '.
* Display
CALL METHOD tree2->set_table_for_first_display
EXPORTING
is_hierarchy_header = g_hierarchy_header
is_variant = g_variant
CHANGING
it_outtab = obj_main->i_vbap_op
it_fieldcatalog = i_fcat_vbap.
LOOP AT i_vbap INTO wa_vbap1.
MOVE wa_vbap1 TO wa_vbap.
l_key1 = ''.
AT NEW vbeln.
MOVE wa_vbap-vbeln TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key1
text = l_node_text
flag = 'X'
CHANGING
i_key = l_key2.
ENDAT.
CLEAR l_node_text.
MOVE wa_vbap-posnr TO l_node_text.
* Call method for Add Node to vbap
CALL METHOD add_node_vbap
EXPORTING
table = wa_vbap
key = l_key2
text = l_node_text
flag = space
CHANGING
i_key = l_key3.
ENDLOOP. " LOOP AT i_vbap INTO wa_vbap1.
* Call method For Register events
CALL METHOD register_events_vbap.
ENDMETHOD. " Display_vbap
* Add Node to Ekko *
METHOD add_node_ekpo.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drag.
ENDIF. " IF flag = 'X'.
* Add node to tree1
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key = key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = table
i_node_text = text
is_node_layout = l_layout_node
IMPORTING
e_new_node_key = i_key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
CLEAR sy-subrc.
ENDIF. " IF sy-subrc NE 0.
ENDMETHOD. " Add_node_ekpo
* Add Node to Vbap *
METHOD add_node_vbap.
* Data
DATA: l_layout_node TYPE lvc_s_layn.
IF flag = 'X'.
l_layout_node-dragdropid = g_handle_drop.
ENDIF. " IF flag = 'X'.
* Add node for tree2
CALL METHOD t -
Editable Field in ALV Tree Control
Hello All,
Can anyone tell me how can i make a field editable in an Alv Tree grid. I have tried with fiedcatalog-edit = 'X'. but that doesn't work.
also please provide a piece of code to be clear ...
Thanks,
Ravi AswanihI ,
Data : LI_fieldcat type lvc_t_fcat,
ls_fcat type lvc_s_fcat.
IF OKCODE = 'MAIN'.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'ZCUS'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = LI_fieldcat[] .
LOOP AT LI_FIELDCAT INTO LS_FCAT.
CASE ls_fcat-fieldname.
WHEN 'KUNNR'.
ls_fcat-col_pos = 1.
WHEN 'NAME1'.
ls_fcat-edit = 'X'.
ls_fcat-col_pos = 2.
WHEN 'ORT01'.
ls_fcat-edit = 'X'.
ls_fcat-col_pos = 3.
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 20.
WHEN 'LAND1'.
ls_fcat-edit = 'X'.
ls_fcat-col_pos = 4.
ENDCASE.
MODIFY LI_fieldcat FROM ls_fcat.
ENDLOOP.
ENDIF.
With this The internal Table contains 4 fields Kunnr Name1 Ort01 Land1 Here Kunnr is the Key field so , it is not editable , reaming fields are Editable.
There u must write the Modify statement.
check it once
Regards
Krishna -
Check box Handling in ALV Tree Control
Hi All,
I am implementing a scenario wherein which I need to get the checked items and process upon the user action. In the implementation I am not getting the checked values.
This is how I have implemented.
I have added a check box field in the Field catalog which is type c
* Item Layout for the Check box.
lwa_item_layout-fieldname = 'CHKBOX'.
lwa_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
lwa_item_layout-editable = 'X'.
APPEND lwa_item_layout TO lt_item_layout.
After that I have tried to used this code to get the checked items.
CALL METHOD tree1->get_checked_items
IMPORTING
et_checked_items = t_checked.
But I am not getting any values in the table.
Further I have tried to use the Event <b>checkbox_change</b> for the check box logic( I am not sure but I thought it is)
But the event is not triggering with this... Please Help me in this regard...CLASS cl_toolbar_event_receiver DEFINITION.
PUBLIC SECTION.
* DATA: checked TYPE c,
* fieldname TYPE lvc_fname,
* node_key TYPE lvc_nkey.
METHODS: on_function_selected
FOR EVENT function_selected OF cl_gui_toolbar
IMPORTING fcode.
METHODS: handle_check_box_change
FOR EVENT checkbox_change OF cl_gui_alv_tree
IMPORTING checked
fieldname
node_key.
ENDCLASS
Does this Implementation giving any problem for this? -
Need to display two ALV GRIDs in a single screen
Hi,
I have a question, i'm using version 4.6. I want to display 2 ALVs in a single screen or by calling.
Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
Step 2 : Display In a single report
ALV1 report (Editable ,Has to be a GRID)
ALV2 report (Non Editable, Has to be a GRID)
(or)
Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
Step 2 :
ALV1 report (Editable ,Has to be a GRID, with a custom button to call ALV2 hiding the ALV1 ie not visible to user)
ALV2 report (Non Editable ,Has to be a GRID, with a custom button to call ALV1 hiding the ALV2 ie not visible to user)
Please help me <b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada GalindoHi
ABAP List Viewer
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
Check the program in the following link:
http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
13. Top-of-page in ALV
selection-screen and top-of-page in ALV
14. ALV Group Heading
http://www.sap-img.com/fu037.htm
How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
15. ALV output to PDF conversion
It has an example code for PDF Conversion.
http://www.erpgenie.com/abap/code/abap51.htm
converting the output of alv in pdf
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
This helps us to implement all the features mentioned very effectively.
Using ALV, We can have three types of reports:
1. Simple Report
2. Block Report
3. Hierarchical Sequential Report
There are some function modules which will enable to produce the above reports without much effort.
All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
1. SIMPLE REPORT.
The important function modules are
a. Reuse_alv_list_display
b. Reuse_alv_fieldcatalog_merge
c. Reuse_alv_events_get
d. Reuse_alv_commentary_write
e. Reuse_alv_grid_display
A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
The important parameters are :
I. Export :
i. I_callback_program : report id
ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
iii. I_callback_user_command : routine where the function codes are handled
iv. I_structure name : name of the dictionary table
v. Is_layout : structure to set the layout of the report
vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
II. Tables :
i. t_outtab : internal table with the data to be output
B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
The Important Parameters are :
I. Export :
i. I_program_name : report id
ii. I_internal_tabname : the internal output table
iii. I_inclname : include or the report name where all the dynamic forms are handled.
II Changing
ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
declared in the type pool SLIS.
C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
Parameters :
I. Import :
Et_Events : The event table is returned with all possible CALLBACK events
for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
II. Export :
I_List_type :
0 = simple list REUSE_ALV_LIST_DISPLAY
1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
3 = hierarchical-sequential block list
REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Parameters :
I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
This internal table has three fields :
Typ : H header, S selection , A - action
Key : only when typ is S.
Info : the text to be printed
E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
Parameters : same as reuse_alv_list_display
This is an example for simple list.
2. BLOCK REPORT
This is used to have multiple lists continuously.
The important functions used in this report are:
A. REUSE_ALV_BLOCK_LIST_INIT
B. REUSE_ALV_BLOCK_LIST_APPEND
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
D. REUSE_ALV_BLOCK_LIST_DISPLAY
A. REUSE_ALV_BLOCK_LIST_INIT
Parameters:
I. I_CALLBACK_PROGRAM
II. I_CALLBACK_PF_STATUS_SET
III. I_CALLBACK_USER_COMMAND
This function module is used to set the default gui status etc.
B. REUSE_ALV_BLOCK_LIST_APPEND
Parameters :
Export :
I. is_layout : layout settings for block
II. it_fieldcat : field catalog
III. i_tabname : internal table name with output data
IV. it_events : internal table with all possible events
Tables :
i. t_outtab : internal table with output data.
This function module adds the data to the block.
Repeat this function for all the different blocks to be displayed one after the other.
C. REUSE_ALV_BLOCK_LIST_HS_APPEND
This function module is used for hierarchical sequential blocks.
D. REUSE_ALV_BLOCK_LIST_DISPLAY
Parameters : All the parameters are optional.
This function module display the list with data appended by the above function.
Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
3. Hierarchical reports :
Hierarchical sequential list output.
The function module is
A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
Parameters:
I. Export:
i. I_CALLBACK_PROGRAM
ii. I_CALLBACK_PF_STATUS_SET
iii. I_CALLBACK_USER_COMMAND
iv. IS_LAYOUT
v. IT_FIELDCAT
vi. IT_EVENTS
vii. i_tabname_header : Name of the internal table in the program containing the
output data of the highest hierarchy level.
viii. i_tabname_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
ix. is_keyinfo : This structure contains the header and item table field
names which link the two tables (shared key).
II. Tables
i. t_outtab_header : Header table with data to be output
ii. t_outtab_item : Name of the internal table in the program containing the
output data of the lowest hierarchy level.
slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.
Important Attributes :
A. col_pos : position of the column
B. fieldname : internal fieldname
C. tabname : internal table name
D. ref_fieldname : fieldname (dictionary)
E. ref_tabname : table (dictionary)
F. key(1) : column with key-color
G. icon(1) : icon
H. symbol(1) : symbol
I. checkbox(1) : checkbox
J. just(1) : (R)ight (L)eft (C)ent.
K. do_sum(1) : sum up
L. no_out(1) : (O)blig.(X)no out
M. outputlen : output length
N. seltext_l : long key word
O. seltext_m : middle key word
P. seltext_s : short key word
Q. reptext_ddic : heading (ddic)
R. ddictxt(1) : (S)hort (M)iddle (L)ong
S. datatype : datatype
T. hotspot(1) : hotspot
Regards
Anji -
Report with ALV tree and ALV list?
I need to create a report with layout as same as this one
[http://trangiegie.com/MyFile/output.JPG]
It looks like a report with combination of ALV tree and list. The tree works like a navigation bar. Wonder if there are any demo programs like this. Will appreciate any help.For Tree alone - You can check program : BCALV_TREE_02
Program Name Report title
BCALV_GRID_DND_TREE ALV Grid: Drag and Drop with ALV Tree
BCALV_GRID_DND_TREE_SIMPLE ALV GRID: Drag and drop with ALV tree (simple)
BCALV_TEST_COLUMN_TREE Program BCALV_TEST_COLUMN_TREE
BCALV_TEST_SIMPLE_TREE Program BCALV_TEST_SIMPLE_TREE
BCALV_TREE_01 ALV Tree Control: Build Up the Hierarchy Tree
BCALV_TREE_02 ALV Tree Control: Event Handling
BCALV_TREE_03 ALV Tree Control: Use an Own Context Menu
BCALV_TREE_04 ALV Tree Control: Add a Button to the Toolbar
BCALV_TREE_05 ALV Tree Control: Add a Menu to the Toolbar
BCALV_TREE_06 ALV tree control: Icon column and icon for nodes/items
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy tree
BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy tree
BCALV_TREE_EVENT_RECEIVER Include BCALV_TREE_EVENT_RECEIVER
BCALV_TREE_EVENT_RECEIVER01
BCALV_TREE_ITEMLAYOUT ALV Tree: Change Item Layouts at Runtime
BCALV_TREE_MOVE_NODE_TEST Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO Program BCALV_TREE_SIMPLE_DEMO
BCALV_TREE_VERIFY Verifier for ALV Tree and Simple ALV Tree -
How to make field editable in ALV tree in OOPs?
Hi Gems,
Again I need help from you all.
I am writing a program using OOPs and the uotput will be in ALV tree. I need to make a field editable in a perticular row.
I am doing it using layout but the program is giving error during
CALL METHOD CL_GUI_CFW=>FLUSH
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
This method is returning sy-subrc = 2 and I am unable to get the output.
I am using below code to make the field editable:
DATA: LT_LAYOUT_ITEM TYPE LVC_T_LAYI,
LS_LAYOUT_ITEM TYPE LVC_S_LAYI.
LS_LAYOUT_ITEM-FIELDNAME = 'ACPCKTWRT'. "ACPCKTWRT is the field name in the Internal table
LS_LAYOUT_ITEM-EDITABLE = 'X'.
APPEND LS_LAYOUT_ITEM TO LT_LAYOUT_ITEM.
CALL METHOD G_ALV_TREE->ADD_NODE
EXPORTING
I_RELAT_NODE_KEY = FP_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
IS_OUTTAB_LINE = LS_TMP_FINFCNO "structure of the internal table
IS_NODE_LAYOUT =
IT_ITEM_LAYOUT = LT_LAYOUT_ITEM "Added layout to make the field editable
I_NODE_TEXT = LV_NODE_TEXT "Node text
IMPORTING
E_NEW_NODE_KEY = FP_NODE_KEY
EXCEPTIONS
RELAT_NODE_NOT_FOUND = 1
NODE_NOT_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please help me and let me know how to get the solution.Hello
The ALV tree control is not intended for making values editable (e.g. see
[How to make ALV tree columns editable|http://sap.ittoolbox.com/groups/technical-functional/sap-abap/how-to-make-alv-tree-columns-editable-2052414])
However, if you need an editable tree control then you have to use a different class (e.g. CL_ITEM_TREE_MODEL or CL_COLUMN_TREE_MODEL) but you will not have the ALV functionality of the ALV tree control.
Regards
Uwe -
ALV Tree download to Excel (CL_GUI_LIST_TREE )
Hi All,
I have created a report for displaying the ALV tree. The flow of the code is sth like this:
Report -> Calls Screen 9000 -> Initialize container type CL_GUI_CUSTOM_CONTAINER -> Tree Class CL_GUI_LIST_TREE displays the ALV tree.
Now what I want is a way to download the ALV Tree to Excel format. Can you please help me on this.
Thanks,
AnujAnuj,
check these threads
ALV tree control report to excel
reg:alv tree Excel Download
http://www.sapfans.com/forums/viewtopic.php?f=12&t=138177
Thanks
Bala Duvvuri -
Can anyone tell me how to Copy a node on an ALV Tree using context menu ?
Hello Vidya
The sample report ZUS_SDN_ALVTREE_CTXMENU demonstrates how to copy nodes on an ALV tree.
Before showing the entire coding I would like to point out a few crucial parts of the coding:
(1) Defintion of OUTTAB list
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbak.
TYPES: nkey TYPE lvc_nkey.
TYPES: ntype TYPE lvc_value. " 'VKORG' / 'VTWEG' / 'SPART' / leaf
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
The OUTTAB list contains two additional fields holding the tree key (LVC_NKEY) and the node type.
(2) The main logic of the report is implemented in event handler method handle_node_ctxmenu_sel.
WHEN 'COPY_SUBTREE'.
CALL METHOD go_alvtree->get_subtree
EXPORTING
i_node_key = node_key
IMPORTING
et_subtree_nodes = lt_subtree.
CALL METHOD go_alvtree->get_parent
EXPORTING
i_node_key = node_key
IMPORTING
e_parent_node_key = ld_parent_key.
LOOP AT lt_subtree INTO ld_node_key.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY nkey = ld_node_key.
APPEND ls_outtab TO lt_outtab.
ENDLOOP.
READ TABLE lt_outtab INTO ls_outtab INDEX 1.
ld_ntype = ls_outtab-ntype.
DELETE lt_outtab WHERE ( vbeln IS INITIAL ). " hierarchy nodes
CASE ld_ntype.
WHEN 'VKORG'.
ld_top_key = ld_parent_key.
WHEN 'VTWEG'.
ld_vkorg_key = ld_parent_key.
WHEN 'SPART'.
ld_vtweg_key = ld_parent_key.
WHEN 'LEAF'.
ld_spart_key = ld_parent_key.
ENDCASE.
" Note: similar logic like in routine CREATE_HIERARCHY
SORT lt_outtab BY vkorg vtweg spart kunnr audat.
LOOP AT lt_outtab INTO ls_outtab.
*& Report ZUS_SDN_ALVTREE_CTXMENU
*& Based on: BCALV_TREE_03
REPORT zus_sdn_alvtree_ctxmenu.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbak.
TYPES: nkey TYPE lvc_nkey.
TYPES: ntype TYPE lvc_value. " 'VKORG' / 'VTWEG' / 'SPART' / leaf
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gd_repid TYPE syst-repid,
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_alvtree TYPE REF TO cl_gui_alv_tree.
DATA:
gt_outtab TYPE ty_t_outtab, " Sales Document
gt_fcat TYPE lvc_t_fcat.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
* §2. Define an event handler method to build up a context menu
* (postfix of event name: _CONTEXT_MENU_REQUEST).
* This event is fired each time the user klick with the right
* mouse button on a node.
CLASS-METHODS:
handle_node_ctxmenu_req
FOR EVENT node_context_menu_request OF cl_gui_alv_tree
IMPORTING
node_key
menu,
* §3. Define an event handler method to respond to a function code
* triggered by your menu (postfix: _CONTEXT_MENU_SELECTED).
* This event is fired when the user selects an entry of the
* build up context menu.
handle_node_ctxmenu_sel
FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
IMPORTING
node_key
fcode
sender.
* 'sender' is an implicit event parameter that is provided by
* ABAP Objects runtime system. It contains a reference to the
* object that fired the event. You may directly use it to
* call methods of this instance.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
* §4. Implement your event handler methods.
METHOD handle_node_ctxmenu_req.
* Event parameter 'menu' holds a reference to the standard context
* menu of ALV Tree (functions 'Expand'/'Collapse' on nodes).
* You may either append your own functions (separated by a line)
* or clear the menu if you do not want to allow standard functions.
* In this case the standard menu is cleared.
CALL METHOD menu->clear.
* The next line defines one line of the context menu.
CALL METHOD menu->add_function
EXPORTING
fcode = 'DEL_SUBTREE'
text = 'Delete Subtree'(901). "Delete Subtree
CALL METHOD menu->add_function
EXPORTING
fcode = 'COPY_SUBTREE'
text = 'Copy Subtree'(902). "Copy Subtree
ENDMETHOD. "handle_node_ctxmenu_req
METHOD handle_node_ctxmenu_sel.
* At this point of execution, the user selected a menu entry of the
* menu build up in event handler method handle_node_cm_req.
* Query your own function codes and react accordingly.
DATA:
l_rc TYPE c,
ld_ntype TYPE lvc_value,
ld_parent_key TYPE lvc_nkey,
ld_node_key TYPE lvc_nkey,
lt_subtree TYPE lvc_t_nkey,
ls_outtab TYPE ty_s_outtab,
ls_last TYPE ty_s_outtab,
lt_outtab TYPE ty_t_outtab.
DATA:
ld_vkorg_key TYPE lvc_nkey,
ld_vtweg_key TYPE lvc_nkey,
ld_spart_key TYPE lvc_nkey,
ld_last_key TYPE lvc_nkey,
ld_top_key TYPE lvc_nkey.
CASE fcode.
WHEN 'DEL_SUBTREE'.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = 'Do you really want to delete'(902)
textline2 = 'this node and all its subnodes?'(903)
titel = 'Confirmation'(904)
cancel_display = ' '
IMPORTING
answer = l_rc.
IF l_rc EQ 'J'.
CALL METHOD sender->delete_subtree
EXPORTING
i_node_key = node_key.
* Do not forget to refresh the display when you change the contents
* of your list.
CALL METHOD sender->frontend_update.
ENDIF.
WHEN 'COPY_SUBTREE'.
CALL METHOD go_alvtree->get_subtree
EXPORTING
i_node_key = node_key
IMPORTING
et_subtree_nodes = lt_subtree.
CALL METHOD go_alvtree->get_parent
EXPORTING
i_node_key = node_key
IMPORTING
e_parent_node_key = ld_parent_key.
LOOP AT lt_subtree INTO ld_node_key.
READ TABLE gt_outtab INTO ls_outtab
WITH KEY nkey = ld_node_key.
APPEND ls_outtab TO lt_outtab.
ENDLOOP.
READ TABLE lt_outtab INTO ls_outtab INDEX 1.
ld_ntype = ls_outtab-ntype.
DELETE lt_outtab WHERE ( vbeln IS INITIAL ). " hierarchy nodes
CASE ld_ntype.
WHEN 'VKORG'.
ld_top_key = ld_parent_key.
WHEN 'VTWEG'.
ld_vkorg_key = ld_parent_key.
WHEN 'SPART'.
ld_vtweg_key = ld_parent_key.
WHEN 'LEAF'.
ld_spart_key = ld_parent_key.
ENDCASE.
SORT lt_outtab BY vkorg vtweg spart kunnr audat.
LOOP AT lt_outtab INTO ls_outtab.
IF ( ld_ntype = 'VKORG' ).
" new sales organisation
IF ( ls_outtab-vkorg = ls_last-vkorg ).
ELSE.
PERFORM add_sales_org
USING
ls_outtab
ld_top_key
CHANGING
ld_vkorg_key.
ls_outtab-nkey = ld_vkorg_key.
ls_outtab-ntype = 'VKORG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
ENDIF.
IF ( ld_ntype = 'VKORG' OR
ld_ntype = 'VTWEG' ).
" new distribution channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg ).
ELSE.
PERFORM add_distrib_chan
USING
ls_outtab
ld_vkorg_key
CHANGING
ld_vtweg_key.
ls_outtab-nkey = ld_vtweg_key.
ls_outtab-ntype = 'VTWEG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
ENDIF.
IF ( ld_ntype = 'VKORG' OR
ld_ntype = 'VTWEG' OR
ld_ntype = 'SPART' ).
" new channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg AND
ls_outtab-spart = ls_last-spart ).
ELSE.
PERFORM add_division
USING
ls_outtab
ld_vtweg_key
CHANGING
ld_spart_key.
ls_outtab-nkey = ld_spart_key.
ls_outtab-ntype = 'SPART'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
ENDIF.
* Leaf:
PERFORM add_complete_line
USING
ls_outtab
ld_spart_key
CHANGING
ld_last_key.
ls_outtab-nkey = ld_last_key.
ls_outtab-ntype = 'LEAF'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ls_last = ls_outtab.
ENDLOOP.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFRESH_TREE'
* IMPORTING
* RC =
ENDCASE.
ENDMETHOD. "handle_node_ctxmenu_sel
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
PERFORM init_controls.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL SCREEN '0100'.
* NOTE: no screen elements, ok_code -> gd_okcode
** PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
** PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
TRANSLATE gd_okcode TO UPPER CASE. " facilitate manual entries
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
when 'REFRESH_TREE'.
CALL METHOD go_alvtree->update_calculations
* EXPORTING
* NO_FRONTEND_UPDATE =
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
DATA:
ls_hierarchy_header TYPE treev_hhdr.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
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.
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999 " full-size screen
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* create tree control
CREATE OBJECT go_alvtree
EXPORTING
parent = go_docking
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = ' '
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
* Hide columns and sum up values initially using the fieldcatalog
PERFORM build_fieldcatalog.
* IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
* (even after this method call). You can change data of your table
* by calling methods of CL_GUI_ALV_TREE.
* Furthermore, the output table 'gt_outtab' must be global and can
* only be used for one ALV Tree Control.
CALL METHOD go_alvtree->set_table_for_first_display
EXPORTING
is_hierarchy_header = ls_hierarchy_header
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_outtab. "table must be empty !
PERFORM init_tree.
ENDFORM. " INIT_CONTROLS
*& Form INIT_TREE
* text
* --> p1 text
* <-- p2 text
FORM init_tree .
PERFORM create_hierarchy.
PERFORM register_events.
* Update calculations which were initially defined by field DO_SUM
* of the fieldcatalog. (see build_fieldcatalog).
CALL METHOD go_alvtree->update_calculations.
* Send data to frontend.
CALL METHOD go_alvtree->frontend_update.
ENDFORM. " INIT_TREE
*& Form build_hierarchy_header
* text
* <--P_LS_HIERARCHY_HEADER text
FORM build_hierarchy_header
CHANGING
cs_hierarchy_header TYPE treev_hhdr.
cs_hierarchy_header-heading =
'SalesOrg/DistChannel/Division'(300).
cs_hierarchy_header-tooltip = 'Customer: Master Sales Data'(400).
cs_hierarchy_header-width = 45.
cs_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form build_fieldcatalog
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
REFRESH: gt_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'VBAK'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'VBELN' OR
'AUDAT' OR
'AUART' OR
'WAERK' OR
'VKORG' OR
'VTWEG' OR
'SPART' OR
'BSTNK' OR
'KUNNR'.
WHEN 'NETWR'.
ls_fcat-do_sum = 'X'.
ls_fcat-h_ftype = 'SUM'. " or: 'MAX' / 'AVG'
WHEN OTHERS.
ls_fcat-tech = 'X'.
ENDCASE.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " build_fieldcatalog
*& Form create_hierarchy
* text
* --> p1 text
* <-- p2 text
FORM create_hierarchy .
* define local data
DATA:
ls_outtab TYPE ty_s_outtab,
ls_last TYPE ty_s_outtab,
lt_outtab TYPE ty_t_outtab.
DATA:
ld_vkorg_key TYPE lvc_nkey,
ld_vtweg_key TYPE lvc_nkey,
ld_spart_key TYPE lvc_nkey,
ld_last_key TYPE lvc_nkey,
ld_top_key TYPE lvc_nkey.
" Select data
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE lt_outtab
UP TO 1550 ROWS.
" sort table according to conceived hierarchy
SORT lt_outtab BY vkorg vtweg spart kunnr audat.
* Define one top node. In this way it is possible to calculate
* values for the whole hierarchy.
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = 'Sales Documents'
IMPORTING
e_new_node_key = ld_top_key.
CLEAR: ls_outtab.
ls_outtab-nkey = ld_top_key.
ls_outtab-ntype = 'ROOT'.
MODIFY gt_outtab FROM ls_outtab INDEX 1
TRANSPORTING nkey ntype.
LOOP AT lt_outtab INTO ls_outtab.
" new sales organisation
IF ( ls_outtab-vkorg = ls_last-vkorg ).
ELSE.
PERFORM add_sales_org
USING
ls_outtab
ld_top_key
CHANGING
ld_vkorg_key.
ls_outtab-nkey = ld_vkorg_key.
ls_outtab-ntype = 'VKORG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
" new distribution channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg ).
ELSE.
PERFORM add_distrib_chan
USING
ls_outtab
ld_vkorg_key
CHANGING
ld_vtweg_key.
ls_outtab-nkey = ld_vtweg_key.
ls_outtab-ntype = 'VTWEG'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
" new channel
IF ( ls_outtab-vkorg = ls_last-vkorg AND
ls_outtab-vtweg = ls_last-vtweg AND
ls_outtab-spart = ls_last-spart ).
ELSE.
PERFORM add_division
USING
ls_outtab
ld_vtweg_key
CHANGING
ld_spart_key.
ls_outtab-nkey = ld_spart_key.
ls_outtab-ntype = 'SPART'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ENDIF.
* Leaf:
PERFORM add_complete_line
USING
ls_outtab
ld_spart_key
CHANGING
ld_last_key.
ls_outtab-nkey = ld_last_key.
ls_outtab-ntype = 'LEAF'.
DESCRIBE TABLE gt_outtab. " fill sy-tfill
MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
TRANSPORTING nkey ntype.
ls_last = ls_outtab.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form ADD_SALES_ORG
* text
* -->P_LS_OUTTAB text
* -->P_LD_TOP_KEY text
* <--P_LD_VKORG_KEY text
FORM add_sales_org
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
ld_nodetext = us_outtab-vkorg.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = ls_outtab
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " ADD_SALES_ORG
*& Form add_DISTRIB_CHAN
* text
* -->P_LS_OUTTAB text
* -->P_LD_VKORG_KEY text
* <--P_LD_VTWEG_KEY text
FORM add_distrib_chan
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
ld_nodetext = us_outtab-vtweg.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = ls_outtab
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_DISTRIB_CHAN
*& Form add_division
* text
* -->P_LS_OUTTAB text
* -->P_LD_VTWEG_KEY text
* <--P_LD_SPART_KEY text
FORM add_division
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
ld_nodetext = us_outtab-spart.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = ls_outtab
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_division
*& Form add_complete_line
* text
* -->P_LS_OUTTAB text
* -->P_LD_SPART_KEY text
* <--P_LD_LAST_KEY text
FORM add_complete_line
USING
value(us_outtab) TYPE ty_s_outtab
value(ud_relat_key) TYPE lvc_nkey
CHANGING
cd_node_key TYPE lvc_nkey.
* define local data
DATA:
ld_nodetext TYPE lvc_value,
ls_outtab TYPE ty_s_outtab.
WRITE us_outtab-kunnr TO ld_nodetext+0 NO-ZERO.
WRITE us_outtab-audat TO ld_nodetext+20 DD/MM/YYYY.
CONDENSE ld_nodetext.
" add node
CALL METHOD go_alvtree->add_node
EXPORTING
i_relat_node_key = ud_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_nodetext
is_outtab_line = us_outtab " !!!
IMPORTING
e_new_node_key = cd_node_key.
ENDFORM. " add_complete_line
*& Form register_events
* text
* --> p1 text
* <-- p2 text
FORM register_events .
DATA:
lt_events TYPE cntl_simple_events,
ls_event TYPE cntl_simple_event.
* The following four tree events registers ALV Tree in the constructor
* method itself.
* - cl_gui_column_tree=>eventid_expand_no_children
* (needed to load data to frontend when a user expands a node)
* - cl_gui_column_tree=>eventid_header_context_men_req
* (needed for header context menu)
* - cl_gui_column_tree=>eventid_header_click
* (allows selection of columns (only when item selection activated))
* - cl_gui_column_tree=>eventid_item_keypress
* (needed for F1-Help (only when item selection activated))
* Nevertheless you have to provide their IDs again if you register
* additional events with SET_REGISTERED_EVENTS (see below).
* To do so, call first method GET_REGISTERED_EVENTS (this way,
* all already registered events remain registered, even your own):
CALL METHOD go_alvtree->get_registered_events
IMPORTING
events = lt_events.
* (If you do not these events will be deregistered!!!).
* You do not have to register events of the toolbar again.
* Register additional events for your own purposes:
* §5. Register first context menu event on frontend (with postfix
* (_REQUEST). The second is registered automatically.
ls_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
APPEND ls_event TO lt_events.
* register events on frontend
CALL METHOD go_alvtree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
* §6. Register both context menu events on backend (ABAP Objects
* event handling).
SET HANDLER:
lcl_eventhandler=>handle_node_ctxmenu_req FOR go_alvtree,
lcl_eventhandler=>handle_node_ctxmenu_sel FOR go_alvtree.
ENDFORM. " register_events
Regards,
Uwe
Maybe you are looking for
-
Insufficient Bandwidth driving me crazy!
I've read and followed the suggestions in all the discussions on insufficient bandwidth with iChat but I still can't get it to work with certain people. I can chat with and see my friends in Chicago but not my family in the UK. We're all using macs.
-
Batch combine multiple image sequences
My problem in a way is pretty simple. After assembling the render output of my 3d app in photoshop (32bit) and changing the appearance via several CC layers in different layer modes (e.g. Hue/saturation in Overlay mode) I ended up with my composing f
-
IOS Developer Program compatible with PC
Hi, I had an idea to develop an app and decided to create it myself. Is the IOS developer program compatible with PC's or will I have to purchase a Mac? Thanks,
-
Font Capure: Acrobat.exe system error
Font Capture: Acrobat.exe System Error. My Acrobat XI Pro will not open a document after a Malware attack. I get the "api-ms-win-downlevel-shell32-i1-1-0.dll" is missing. I tried to repair by the original download, but did not work,
-
Diferent ways to import the HTML code in SSRS report
I need to load the HTML code in the SSRS report 2008R2. i tried by creating the placeholder but its support only few html code not everything... I need any other solution for this. Thanks in advance. Regards, Vignesh