Free the contentes of alv tree
how to free the contents of alv tree?
Hi kailash,
Good Check the below example program for ALV Tree ( Complete Example)
Demo Program on ALV Tree Control
REPORT zdemo_alv_tree.
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA tree1 TYPE REF TO cl_gui_alv_tree_simple.
INCLUDE <icon>.
INCLUDE bcalv_simple_event_receiver.
DATA: gt_sflight TYPE sflight OCCURS 0, " Output-Table
gt_fieldcatalog TYPE lvc_t_fcat, " Field Catalog
gt_sort TYPE lvc_t_sort, " Sorting Table
ok_code LIKE sy-ucomm. " OK-Code
END-OF-SELECTION.
CALL SCREEN 100.
*& Form BUILD_FIELDCATALOG
This subroutine is used to build the field catalog for the ALV list
FORM build_fieldcatalog.
get fieldcatalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = gt_fieldcatalog.
change fieldcatalog
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
CASE ls_fieldcatalog-fieldname.
WHEN 'CARRID' OR 'CONNID' OR 'FLDATE'.
ls_fieldcatalog-no_out = 'X'.
ls_fieldcatalog-key = ''.
WHEN 'PRICE' OR 'SEATSOCC' OR 'SEATSMAX' OR 'PAYMENTSUM'.
ls_fieldcatalog-do_sum = 'X'.
ENDCASE.
MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_OUTTAB
Retrieving the data from the table and filling it in the output table
of the ALV list
FORM build_outtab.
SELECT * FROM sflight INTO TABLE gt_sflight.
ENDFORM. " BUILD_OUTTAB
*& Form BUILD_SORT_TABLE
This subroutine is used to build the sort table or the sort criteria
FORM build_sort_table.
DATA ls_sort_wa TYPE lvc_s_sort.
create sort-table
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = 'CARRID'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
APPEND ls_sort_wa TO gt_sort.
ls_sort_wa-spos = 2.
ls_sort_wa-fieldname = 'CONNID'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
APPEND ls_sort_wa TO gt_sort.
ls_sort_wa-spos = 3.
ls_sort_wa-fieldname = 'FLDATE'.
ls_sort_wa-up = 'X'.
APPEND ls_sort_wa TO gt_sort.
ENDFORM. " BUILD_SORT_TABLE
*& Module PBO OUTPUT
This subroutine is used to build the ALV Tree
MODULE pbo OUTPUT.
IF tree1 IS INITIAL.
PERFORM init_tree.
ENDIF.
SET PF-STATUS 'ZSTATUS'.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
This subroutine is used to handle the navigation on the screen
MODULE pai INPUT.
CASE ok_code.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM exit_program.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI INPUT
*& Form exit_program
free object and leave program
FORM exit_program.
CALL METHOD tree1->free.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form register_events
Handling the events in the ALV Tree control in backend
FORM register_events.
define the events which will be passed to the backend
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event.
define the events which will be passed to the backend
l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_header_click.
APPEND l_event TO lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
APPEND l_event TO lt_events.
CALL METHOD tree1->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
set Handler
DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->on_add_hierarchy_node
FOR tree1.
ENDFORM. " register_events
*& Form build_header
build table for header
FORM build_comment USING
pt_list_commentary TYPE slis_t_listheader
p_logo TYPE sdydo_value.
DATA: ls_line TYPE slis_listheader.
LIST HEADING LINE: TYPE H
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = 'ALV TREE DEMO for ****************'.
APPEND ls_line TO pt_list_commentary.
p_logo = 'ENJOYSAP_LOGO'.
ENDFORM. "build_comment
*& Form init_tree
Building the ALV-Tree for the first time display
FORM init_tree.
PERFORM build_fieldcatalog.
PERFORM build_outtab.
PERFORM build_sort_table.
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c,
l_custom_container TYPE REF TO cl_gui_custom_container.
l_tree_container_name = 'TREE1'.
CREATE OBJECT l_custom_container
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
create tree control
CREATE OBJECT tree1
EXPORTING
i_parent = l_custom_container
i_node_selection_mode =
cl_gui_column_tree=>node_sel_mode_multiple
i_item_selection = 'X'
i_no_html_header = ''
i_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.
create info-table for html-header
DATA: lt_list_commentary TYPE slis_t_listheader,
l_logo TYPE sdydo_value.
PERFORM build_comment USING
lt_list_commentary
l_logo.
repid for saving variants
DATA: ls_variant TYPE disvariant.
ls_variant-report = sy-repid.
register events
PERFORM register_events.
create hierarchy
CALL METHOD tree1->set_table_for_first_display
EXPORTING
it_list_commentary = lt_list_commentary
i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
CHANGING
it_sort = gt_sort
it_outtab = gt_sflight
it_fieldcatalog = gt_fieldcatalog.
expand first level
CALL METHOD tree1->expand_tree
EXPORTING
i_level = 1.
optimize column-width
CALL METHOD tree1->column_optimize
EXPORTING
i_start_column = tree1->c_hierarchy_column_name
i_end_column = tree1->c_hierarchy_column_name.
ENDFORM. " init_tree
Good Luck and thanks
AK
Similar Messages
-
How to download the datas of ALV tree without passing iternal table
Hi,
I want to download the values of ALV tree output in an Excel file without using any internal table.
Please suggest your thoughts on the same.
Regards,
Shasiraj.C
Edited by: Raj Shasi on Aug 1, 2008 8:44 AMThere is one option -Export' in menu bar of ALV grid itself. Click on that and then click 'Local File'. Then choose 'Spreadsheet' option and provide local PC path for download.
Regards,
Aparna Gaikwad -
Hi Experts ,
I want to edit the column contents in a ALV tree and the save the content . I am using CL_ALV_gui_tree class to build the tree structure.please help on this
With regards
RKMHi,
In the field catalog internal table ,
Fcat-edit = 'X'.
This makes the particular field as editable mode. append to field catelog internal table.
include into your internal table.
in the structure.
types: cellstyles type lvc_t_styl.
call this class
class lcl_event_handlers definition.
public section.
methods:handle_button_click for event button_click of cl_gui_alv_grid
importing es_row_no. " METHOD TO HANDLE PUSH BUTTON
endclass. "lcl_event_handlers DEFINITION
class lcl_event_handlers implementation.
method handle_button_click.
perform handle_button_click using es_row_no . " ACTION TO BE PERFORMED WHEN CLICKING ON PUSH BUTTON
endmethod.
layout :
gs_layout-stylefname = 'CELLSTYLES'.
endclass.
ls_style-fieldname = 'BUTTON'.
ls_style-style = cl_gui_alv_grid=>mc_style_button.
append ls_style to wa_str-cellstyles.
***********button name
wa_str-button = 'SAVE'.
modify it_str from wa_str transporting button. -
How to change the color of specific row in ALV tree
Hi,
I m using method set_table_for_first_display of a class CL_GUI_ALV_TREE.
The req is to change the color of specific row. Now can anybody tell me how to change the color of ALV tree. As in ALV tree and in this method 'set_table_for_first_display', there is no parameter IS_Layout.
Pls suggest...hi
hope this code will help you.
Reward if help.
REPORT zsharad_test1.
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_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.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
*Populate field with color attributes
LOOP AT it_ekko INTO wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL -
ALV Tree list output using the Class and method
Hi,
How to get the internal table values of ALV Tree List in classes.
My requirement is i need to store the output values in Ztable of a SAP Transaction of CK86_99.
for this, i copied the SAP Standard Transaction into Z tcode and i am trying to poplulate the output display into Ztable. But this standard tcode CK86_99 is using the classes of ALV tree list to display output.
CL_STRUCTURE_EXPLOSION_TREE -- Class
CONSTRUCTOR - method
Finally in the above mentioned method, i am able to see the output values of ALV tree list in the internal table of mt_output_table.
But these are SAP Standard Class and method.
My doubt is, How to get these internal table values in my Zprogram.
is there any user exit or badi can we use in the method of class???? Actually my system is 4.6C
Please suggest me on this problem.
Thanks in advance
KBS ReddyFirst your getInstance() method returns 'singleton' which you havent declared/init anywhere.
your getAll() method needs to be static if you need to call it the way you are doing.
In your getAll() method u are passing a parameter called patientRecord ... where have you declared/init it.
i think you have to do something like this ... if i have understood you correctly.
/* THIS IS IN YOUR SERVLET*/
Collections c = database.getAll();
out.println(C);
/* YOUR FlatfileDatabase CLASS HAS SOMETHING LIKE THIS*/
public static FlatfileDatabase getInstance() {
return new FlatfileDatabase();
public static Collections getAll() { -
Save Environment. Save Yourself.
Hi Experts!!
I have 2 screens in an application - left being ALV tree (in which user id is an item under a node) and at right I have an input field. Initially, item was showing X and even the input field. Once I changed input field to Y and saved, the value is being updated there but the item under ALV tree is still showing X.
I searched for this issue in SCN and found a lot. But none of the methods solved my problem. Can anybody please help?
I have tried with SET_SCREEN_UPDATE, FRONTEND_UPDATE, FREE etc.
Thanks in advance!!Ok try like this,
When u change the value in ur input field and press save, do all the actions that has to be did at the table level.
Now, Free your ALV Tree object...
say, CALL METHOD C_ALVGD->FREE.
CLEAR C_ALVGD.
try performing CALL SCREEN 9000 -
> Your Display screen. (call the same screen once again,
immediately after freeing the object).
This may help you.... -
hi.....
whats the event for hotspot or single click on node event
thanks.Hi,
If you want to get it through grid you can go through the sample code...
The sample program explains on how to achieve hotspot apply the same for alv tree...
REPORT Z_ALV_HOTSPOT.
TABLES:EKKO.
SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.
INTERNAL TABLE FOR EKKO
DATA: TB_EKKO TYPE STANDARD TABLE OF EKKO,
INTERNAL TABLE FOR EKPO
TB_EKPO TYPE STANDARD TABLE OF EKPO,
DA_TOP TYPE REF TO CL_DD_DOCUMENT,
DW_TOP TYPE REF TO CL_DD_DOCUMENT.
DATA:
GRIDS
EKKO_GRID TYPE REF TO CL_GUI_ALV_GRID,
EKPO_GRID TYPE REF TO CL_GUI_ALV_GRID,
CONTAINERS
EKKO_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
EKPO_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
TOP_OF_PAGE_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
DTOP_OF_PAGE_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
DMAIN_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
MAIN_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
DSPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
LAYOUT
X_LAYOUT TYPE LVC_S_LAYO,
WORK AREA
X_EKKO LIKE EKKO.
DATA: FLAG TYPE C,
flag_top type c.
CLASS LCL_HANDLER DEFINITION
CLASS LCL_HANDLER DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:HANDLER_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF
CL_GUI_ALV_GRID IMPORTING E_ROW_ID.
CLASS-METHODS:HANDLER_TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF
CL_GUI_ALV_GRID .
ENDCLASS. "LCL_HANDLER DEFINITION
CLASS LCL_HANDLER IMPLEMENTATION
CLASS LCL_HANDLER IMPLEMENTATION.
METHOD HANDLER_HOTSPOT_CLICK.
CLEAR X_EKKO.
CLEAR TB_EKKO.
READ TABLE TB_EKKO INDEX E_ROW_ID-INDEX INTO X_EKKO.
IF SY-SUBRC = 0.
PERFORM GET_ITEM_DETAILS USING X_EKKO-EBELN.
ENDIF.
ENDMETHOD. "HANDLER_HOTSPOT_CLICK
METHOD HANDLER_TOP_OF_PAGE.
CALL METHOD DA_TOP->ADD_TEXT
EXPORTING
TEXT = 'Top Of Page'.
CALL METHOD DA_TOP->DISPLAY_DOCUMENT
EXPORTING
PARENT = TOP_OF_PAGE_CONTAINER.
if flag_top = 'X'.
CALL METHOD DW_TOP->ADD_TEXT
EXPORTING
TEXT = 'ITEM Top Of Page '.
CALL METHOD DW_TOP->DISPLAY_DOCUMENT
EXPORTING
PARENT = DTOP_OF_PAGE_CONTAINER.
flag_top = ' '.
endif.
ENDMETHOD. "HANDLER_TOP_OF_PAGE
ENDCLASS. "LCL_HANDLER IMPLEMENTATION
*& Module STATUS_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ABC'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Form GET_DATA
MODULE GET_DATA OUTPUT.
SELECT * UP TO 5 ROWS INTO TABLE TB_EKKO FROM EKKO WHERE EBELN IN
S_EBELN.
ENDMODULE. " GET_DATA
START OF SELECTION.
START-OF-SELECTION.
CALL SCREEN 100.
*& Module DISPLAY_DATA OUTPUT
text
MODULE DISPLAY_DATA OUTPUT.
CREATING CONTAINER OBJ*******
CREATE OBJECT MAIN_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONT1'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 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.
CREATE OBJECT SPLITTER
EXPORTING TOP = 5
PARENT = MAIN_CONTAINER
ROWS = 2
COLUMNS = 1.
CALL METHOD SPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = TOP_OF_PAGE_CONTAINER.
CALL METHOD SPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = EKKO_CONTAINER.
CREATING GRID OBJ AND ASSAIGNING TO CONTAINER ****
CREATE OBJECT EKKO_GRID
EXPORTING
I_PARENT = EKKO_CONTAINER
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LAYOUT SETTINGS ***
X_LAYOUT-ZEBRA = 'X'.
X_LAYOUT-KEYHOT = 'X'.
TO DISPLAY TB_EKKO CONTENTS ********
CALL METHOD EKKO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'EKKO'
IS_LAYOUT = X_LAYOUT
CHANGING
IT_OUTTAB = TB_EKKO
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
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.
***REGESTRING HANDLER FOR HOT SPOT CLICK EVENT
SET HANDLER LCL_HANDLER=>HANDLER_HOTSPOT_CLICK FOR EKKO_GRID.
SET HANDLER LCL_HANDLER=>HANDLER_TOP_OF_PAGE FOR EKKO_GRID.
For Top Of Page
CREATE OBJECT DA_TOP
EXPORTING STYLE = 'ALV_GRID'.
CALL METHOD DA_TOP->INITIALIZE_DOCUMENT.
CALL METHOD EKKO_GRID->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = DA_TOP.
ENDMODULE. " DISPLAY_DATA OUTPUT
*& Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'OTHERS'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form GET_ITEM_DETAILS
FORM GET_ITEM_DETAILS USING P_EKKO_EBELN TYPE EKKO-EBELN.
CLEAR TB_EKPO[].
SELECT * UP TO 5 ROWS INTO TABLE TB_EKPO FROM EKPO WHERE EBELN =
P_EKKO_EBELN.
IF FLAG IS INITIAL.
FLAG = 'X'.
CREATING CONTAINER OBJ*******
CREATE OBJECT DMAIN_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONT2'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 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.
CREATE OBJECT DSPLITTER
EXPORTING TOP = 5
PARENT = DMAIN_CONTAINER
ROWS = 2
COLUMNS = 1.
CALL METHOD DSPLITTER->GET_CONTAINER
EXPORTING
ROW = 1
COLUMN = 1
RECEIVING
CONTAINER = DTOP_OF_PAGE_CONTAINER.
CALL METHOD DSPLITTER->GET_CONTAINER
EXPORTING
ROW = 2
COLUMN = 1
RECEIVING
CONTAINER = EKPO_CONTAINER.
CREATING GRID OBJ AND ASSAIGNING TO CONTAINER ****
CREATE OBJECT EKPO_GRID
EXPORTING
I_PARENT = EKPO_CONTAINER
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
LAYOUT SETTINGS ***
X_LAYOUT-ZEBRA = 'X'.
TO DISPLAY TB_EKPO CONTENTS ********
CALL METHOD EKPO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'EKPO'
IS_LAYOUT = X_LAYOUT
CHANGING
IT_OUTTAB = TB_EKPO
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
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.
SET HANDLER LCL_HANDLER=>HANDLER_TOP_OF_PAGE FOR EKPO_GRID.
For Top Of Page
CREATE OBJECT DW_TOP
EXPORTING STYLE = 'ALV_GRID'.
CALL METHOD DW_TOP->INITIALIZE_DOCUMENT.
flag_top = 'X'.
CALL METHOD EKPO_GRID->LIST_PROCESSING_EVENTS
EXPORTING
I_EVENT_NAME = 'TOP_OF_PAGE'
I_DYNDOC_ID = DW_TOP.
ENDFORM. " GET_ITEM_DETAILS
<b>Reward points for all helpful answers.</b>
Regards,
Azaz Ali. -
To display complete Column as Pushbottons in Simple ALV Tree
Hi Everybody,
Are pushbuttons possible in Simple ALV Tree?
If yes, Can anybody help me in displaying one of the Columns in ALV Tree as Pushbuttons.
Sample Code for this would also be appreciated.
Thanks in Advance.
Regards,
ArshadHi,
Check this out.
http://help.sap.com/saphelp_erp2004/helpdata/en/88/387f380c2f2e3ce10000009b38f8cf/content.htm
Reward if helpful.
Regards,
Ramya -
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 -
Average sum for a column in ALV tree layout
Hi,
I've trying to set an average sum for a column in an ALV tree report. In the field catalog i set the DO_SUM field to 'X' and this will do a total sum, but I can't find out how in the code to do the average sum.
Also to get round this I was going to just set a default display variant with the "average" sum option saved after i had manually selected the columns and set it to this. Problem with this is that when i re-run it, the sum comes back as a total rather than an average. I have tried setting display variants on the SAP example ALV tree programs and the same thing happens.
Does anyone know how i can get round this?
Cheers
Matt.Hi,
In addition to setting DO_SUM = 'X' you need to specify function in H_FTYPE field. It should be set to 'AVG' in your case.
ls_fielcat-do_sum = 'X'.
ls_fieldcat-h_ftype = 'AVG. -
Hi all,
I have a requirement to display the Data in ALV tree format with some fields as editable.I have to display data in 3 levels,which are of differents structures.
To achieve editable in ALV tree display,I have used ALV GRID along with Tree display but here in GRID the 3 levels data is of same structure,but my requirement is of different structures.
Inputs regarding this will be highly appreciated.
Thanks,
Sravanthi .VHi Simone,
Thanks for your quick reply,I have used this Class also but iam not able to get the Fields editable even though it has the method for EDITABLE feature.
Thanks,
Sravanthi.V -
Attaining Hot spot in ALV Tree Using OOPS concept
Hi All,
In our requirement we are displaying the data in ALV Tree Using OOPS.
We need to achieve hot spot on one of the header field.
I am using Class 'CL_GUI_ALV_TREE'
Ex:
CreditAccnt/ Company codes DSO DDSO
26 15 15
8000 5 5
8545 10 10
In the above example for every credit accnt in header we r displaying the values ( DSO ,DDSO) for all company codes.
Now we require hot spot on Credit Accnt 26. Such that when user clicks on the credit accnt it should navigate to another transaction.
NOTE: we havent build any field catalogue for field CreditAccnt/ Company codes .Hi,
You can refer to the tutorial -
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
Or try using the code below-
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
Hot Spot Click
handle_hotspot
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id
es_row_no,
ENDCLASS.
Implementation
*& Method handle_hotspot
This method is called when the user clicks on a hotspot to drill down.
The following types are exported from the ALV
LVC_S_ROW
LVC_S_COL
LVC_S_ROID
METHOD handle_hotspot.
The hotspot processing coded in the form below.
PERFORM f9802_handle_hotspot USING e_row_id
e_column_id
es_row_no.
ENDMETHOD.
*& Form f9802_handle_hotspot
This form is called when the user clicks on a hotspot on the ALV grid
The parameters are of type
-->P_E_ROW text
-->P_E_COL text
-->P_E_ROID text
FORM f9802_handle_hotspot USING p_row
p_col
p_roid.
DATA: lw_output LIKE LINE OF i_output.
READ TABLE i_output INDEX p_row INTO lw_output.
SET PARAMETER ID 'MAT' FIELD lw_output-matnr.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
ENDFORM. " f9802_handle_hotspot
FORM f9300_modify_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat.
Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
CASE <lfs_fieldcat>-fieldname.
WHEN 'MATNR'.
<lfs_fieldcat>-hotspot = c_x.
<lfs_fieldcat>-key = c_x.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDFORM.
In PBO,
module STATUS_9001 output.
Set handlers for events
SET HANDLER o_eventreceiver->handle_hotspot FOR o_Alvgrid.
ENDMODULE.
Hope this helps -
Can we download output of alv tree ?
hi all,
i have a requirement to download the output of alv tree when it is collapsed (detailed). Can we download that ? i am using cl_gui_alv_tree class.
plz let me know asap.
regards
raghavStandard Control does not give that Option . SO another option is to go to Print preview of the Entire Hierarchy view , then click System -> list -> Save -> local file and save it as spreadsheet . This wa entire data gets downloaded in excel in tree format .
Thanks ,
-Kaustubha Tavildar -
ALV Tree - how to change values of Total
Hi all,
I am using ALV tree (cl_gui_alv_tree). After calling the method update_calculations, alv tree will calculate the total at every node.
Now, I want to blank out the Total value of the root node. I tried to use method change_linde and then frontend_update, but it didn't work.
Here is the flow I used.
- call method update_calculations.
- call method get_outtab_line.
- call method change_node.
- call method frontend_update.
Could you please look at it? I don't know If I missed something.
Thanks in advance.
Best rgds,
Solaris.Hi,
I am also having a similar requirement like this but I need to recalculate the values at node level(Ex:percentages).
Please let me know if you found any way to achieve this or any alternative solutions you suggested to functional team.
Appreciate your response.
Thanks,
Ramesh -
Hi All,
I amd currently developing an ALV tree program to capture the hierarchy of functional location. I managed to display the hierarchy in ALV Tree using cl_gui_column_tree.
Now, i am working on double clicking the functional location and it will bring me to tcode IL03. But, it seems like i cannot capture of the field value clicked. Below are my source code. Can anyone pls help me on this? Thank you very much
*& Form register_events
text
--> p1 text
<-- p2 text
FORM register_events .
Define the events which will be passed to the backend
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event.
CALL METHOD gd_tree->get_registered_events
IMPORTING
events = lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
l_event-appl_event = 'X'.
APPEND l_event TO lt_events.
CALL METHOD gd_tree->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'.
ENDIF.
Set Handler
DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->handle_item_double_click FOR gd_tree.
ENDFORM. " register_events
CLASS lcl_tree_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_item_double_click
FOR EVENT item_double_click OF cl_gui_alv_tree
IMPORTING node_key
fieldname.
ENDCLASS. "lcl_tree_event_receiver DEFINITION
CLASS lcl_tree_event_receiver IMPLEMENTATION.
METHOD handle_item_double_click.
DATA: lt_selected_nodes TYPE lvc_nkey,
lt_fieldname TYPE lvc_fname.
Determine which line is selected
CALL METHOD gd_tree->get_selected_item
IMPORTING
e_selected_node = lt_selected_nodes
e_fieldname = lt_fieldname.
CALL METHOD cl_gui_cfw=>flush.
SET PARAMETER ID 'IFL' FIELD lt_fieldname.
SET PARAMETER ID 'ISR' FIELD 'MOB01'.
CALL TRANSACTION 'IL03' AND SKIP FIRST SCREEN.
ENDMETHOD. "handle_item_double_click
ENDCLASS. "lcl_tree_event_receiver IMPLEMENTATIONHello Goh
Based on your coding you are using CL_GUI_ALV_TREE instead of CL_GUI_COLUMN_TREE.
Calling method get_selected_item within your event handler method is unnecessary because these data are already provided by the event interface.
[code]METHOD handle_item_double_click.
DATA: lt_selected_nodes TYPE lvc_nkey,
lt_fieldname TYPE lvc_fname.
*$Comment: unnecessary because these data are already provided
by the event interface (IMPORTING nodekey fieldname).
Determine which line is selected
**CALL METHOD gd_tree->get_selected_item
**IMPORTING
**e_selected_node = lt_selected_nodes
**e_fieldname = lt_fieldname.
ENDMETHOD. "handle_item_double_click[/code]
The following sample is based in report BCALV_TREE_04 but can be simply applied to your application:
[code] METHOD handle_item_double_click.
define local data
DATA:
ls_outtab TYPE sflight.
FIELD-SYMBOLS:
<ld_fld> TYPE ANY.
Call this method to get the values of the selected tree line
CALL METHOD g_alv_tree->get_outtab_line
EXPORTING
i_node_key = node_key
IMPORTING
e_outtab_line = ls_outtab
E_NODE_TEXT =
et_item_layout =
ES_NODE_LAYOUT =
EXCEPTIONS
node_not_found = 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.
ASSIGN COMPONENT fieldname OF STRUCTURE ls_outtab TO <ld_fld>.
IF ( <ld_fld> IS ASSIGNED ).
... Call transaction with selected (item) value.
ENDIF.
ENDMETHOD. "handle_item_double_click[/code]
The ASSIGN statement will work if no item of the hierarchy part is selected.
Regards
Uwe
Maybe you are looking for
-
Windows 8.1 Update 1 Kiosk Mode difference
We have a number of stations running modern IE on Windows 8.1 in Kiosk Mode. I ran the in-place upgrade on a few of them to test Windows 8.1 Update 1. Everything runs fine except that hitting the Windows key 5 times no longer takes you to the login
-
Adapter monitoring: SOAP is grey although it is used?
Hello everybody, 5 minutes ago I checked our SOAP receiver communication channel and send a message. But in adapter monitoring the SOAP adapter is shown in grey instead expected in green. So how can I see, if the SOAP adapter works correctly? Thanks
-
Will a factory unlocked iPhone stay unlocked if sync with another iTunes account?
I just got my ATT iphone officially unlocked. If I reset the phone to factory defaults so my daughter can borrow it for her trip to Europe, will it lock again? She would probably sync it with her iTunes and personalize it for her use. When she get
-
CVS Pharmacy Prescription download error
Hello- Somehow I disconnected my CVS pharmacy account from HealthVault. I have tried reloading the app, but get a message in CVS stating I already have installed the app. I called CVS tech support and they said I needed to resolve it through HealthVa
-
Interesting Newsfeed (Rss) ?
Hello, after changing some network settings, I lost my SAP newsfeeds (RSS). For example a feed of the latest patches, a feed about news from SAP (Business One), and some blog feeds. Some of the links I cant find anymore. Is there someone with a list