Subtotal in ALV tree
Hi All,
Is it possible to find the subtotal at each level of the tree using the function modules RS_TREE_CONSTRUCT and RS_TREE_LIST_DISPLAY?
Thanks,
Prasad
Hi,
data : gt_sort like slis_t_sortinfo_alv .
gs_sort type slis_sortinfo_alv.
gs_sort-fieldname = 'Fieldname'.
gs_sort-sortup = 'X'.
gs_sort-subtot = 'X'.
append gs_sort to gt_sort.
Bhavana
Similar Messages
-
Get subtotal value of different column of different root_node in alv tree
Dear All,
I am working on hierarchical alv tree and using class "cl_gui_alv_tree"
CALL METHOD g_alv_tree->update_calculations is providing subtotal
I want to get subtotal value for different node(based on node key) and different column
i am using following method
CALL METHOD g_alv_tree->GET_OUTTAB_LINE(if I am passing pamater "node key" it is returning column name with '0' value,not exact subtotal value)
Thanks and regards in advance. Edited by: Gyanendra Dubey on Jan 26, 2012 7:55 AM
Edited by: Gyanendra Dubey on Jan 26, 2012 8:03 AMHi Dubey,
We are currently facing similar issue, would you be able to share your solution?
CALL METHOD g_alv_tree->GET_OUTTAB_LINE is returning 0 value for the subtotal.
Thank you. -
Display Traffic Lights in ALV TREE
Hi,
I have to display traffic light in ALV tree but i am not able to find out what parameter i should pass like in ALV grid where we can set is_layout (BCALV_GRID_04).
Thanks in advance.
Regards,
HarshHi,
Please take a look at my code below. Hope it suits your requirement.
P.S. Please award points if it helps...
*& Report ZMM_R_PO_TO_IPURCH_XI
*& PROGRAM TYPE : Report
*& RICEF ID :
*& TITLE : ZMM_R_PO_TO_IPURCH_XI
*& SAP Module : MM
*& CREATION DATE : 02/06/2008
*& AUTHOR : Aris Hidalgo
*& DESIGNER : Aris Hidalgo
*& DESCRIPTION :
*$**********************************************************************
*$ CHANGE HISTORY
*$----------------------------------------------------------------------
*$ DATE | T-Num | Description | Reference
** | | |
*$**********************************************************************
REPORT zmm_r_po_to_ipurch_xi
NO STANDARD PAGE HEADING
MESSAGE-ID zmm.
* Data Dictionary Table/s *
TABLES: edidc.
* SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_credat FOR edidc-credat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: rb_sum RADIOBUTTON GROUP grp1,
rb_det RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b2.
*/ CLASS DEFINITION/S /*
* CLASS lcl_data_def DEFINITION
CLASS lcl_data_def DEFINITION ABSTRACT.
PUBLIC SECTION.
TYPES: BEGIN OF t_edidc,
docnum TYPE edidc-docnum,
docrel TYPE edidc-docrel,
status TYPE edidc-status,
doctyp TYPE edidc-doctyp,
direct TYPE edidc-direct,
rcvpor TYPE edidc-rcvpor,
rcvprt TYPE edidc-rcvprt,
rcvprn TYPE edidc-rcvprn,
rcvsad TYPE edidc-rcvsad,
sndpor TYPE edidc-sndpor,
sndprt TYPE edidc-sndprt,
sndprn TYPE edidc-sndprn,
sndsad TYPE edidc-sndsad,
credat TYPE edidc-credat,
cretim TYPE edidc-cretim,
mestyp TYPE edidc-mestyp,
idoctp TYPE edidc-idoctp,
END OF t_edidc.
TYPES: BEGIN OF t_output,
exception TYPE char1,
ebeln TYPE ekko-ebeln,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
credat TYPE edidc-credat,
cretim TYPE edidc-cretim,
END OF t_output.
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
lifnr TYPE ekko-lifnr,
END OF t_ekko.
TYPES: BEGIN OF t_lfa1,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF t_lfa1.
DATA: gt_edidc TYPE STANDARD TABLE OF t_edidc,
gt_output TYPE STANDARD TABLE OF t_output,
wa_output LIKE LINE OF gt_output,
gt_ekko TYPE HASHED TABLE OF t_ekko
WITH UNIQUE KEY ebeln,
gt_lfa1 TYPE HASHED TABLE OF t_lfa1
WITH UNIQUE KEY lifnr.
ENDCLASS. "lcl_data_def DEFINITION
CLASS lcl_alv_routines DEFINITION DEFERRED.
CLASS lcl_handle_events DEFINITION DEFERRED.
* CLASS lcl_get_data DEFINITION
CLASS lcl_get_data DEFINITION INHERITING FROM lcl_data_def.
PUBLIC SECTION.
METHODS: get_idocs,
read_idocs,
process_data
IMPORTING
im_docnum TYPE edidc-docnum.
PRIVATE SECTION.
CONSTANTS: lc_mestyp TYPE edidc-mestyp VALUE 'ZMARKETSITE_PURCHASE_ORDER',
lc_idoctp TYPE edidc-idoctp VALUE 'ZMARKETSITE_PURCHASE_ORDER01',
lc_segnam TYPE edid4-segnam VALUE 'ZMARKETSITE_ORDER_HEADER1'.
CONSTANTS: lc_red TYPE i VALUE 1,
lc_yellow TYPE i VALUE 2,
lc_green TYPE i VALUE 3.
DATA: lv_stat_message TYPE bdidocattr-message,
o_lcl_alv_routines TYPE REF TO lcl_alv_routines.
DATA: ls_idoc_control TYPE edidc,
lv_tot_data_recs TYPE sy-dbcnt, "#EC NEEDED
lv_tot_status_recs TYPE sy-dbcnt. "#EC NEEDED
DATA: lt_edids TYPE STANDARD TABLE OF edids,
lt_edidd TYPE STANDARD TABLE OF edidd.
ENDCLASS. "lcl_get_data DEFINITION
* CLASS lcl_alv_routines DEFINITION
CLASS lcl_alv_routines DEFINITION INHERITING FROM lcl_get_data.
PUBLIC SECTION.
DATA: lcl_table TYPE REF TO cl_salv_table,
lcl_container TYPE REF TO cl_gui_custom_container,
lcl_handle_events TYPE REF TO lcl_handle_events,
lcl_columns TYPE REF TO cl_salv_columns_table,
lcl_column TYPE REF TO cl_salv_column_table,
lcl_events2 TYPE REF TO cl_salv_events_table,
lcl_display_settings TYPE REF TO cl_salv_display_settings,
lcl_functions TYPE REF TO cl_salv_functions_list,
lcl_display TYPE REF TO cl_salv_display_settings,
lcl_aggregations TYPE REF TO cl_salv_aggregations,
lcl_sorts TYPE REF TO cl_salv_sorts,
lcl_content TYPE REF TO cl_salv_form_element,
lcl_header TYPE REF TO cl_salv_form_header_info,
ls_color TYPE lvc_s_colo.
DATA: lcl_grid TYPE REF TO cl_salv_form_layout_grid,
lcl_grid_1 TYPE REF TO cl_salv_form_layout_grid,
lcl_grid_2 TYPE REF TO cl_salv_form_layout_grid,
lcl_label TYPE REF TO cl_salv_form_label,"#EC NEEDED
lcl_text TYPE REF TO cl_salv_form_text,
gt_t247 TYPE STANDARD TABLE OF t247,
wa_t247 LIKE LINE OF gt_t247,
lv_text TYPE string.
METHODS: display_data
IMPORTING
im_output LIKE gt_output,
display_top_of_page.
PRIVATE SECTION.
DATA: lv_string TYPE string,
lv_date1 TYPE c LENGTH 10,
lv_time TYPE c LENGTH 10,
lv_title TYPE string.
ENDCLASS. "lcl_alv_routines DEFINITION
* CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
*/ IMPLEMENTATION/S /*
* CLASS lcl_get_data IMPLEMENTATION
CLASS lcl_get_data IMPLEMENTATION.
* METHOD get_idocs
METHOD get_idocs.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-p01.
SELECT docnum docrel status doctyp
direct rcvpor rcvprt rcvprn
rcvsad sndpor sndprt sndprn
sndsad credat cretim mestyp
idoctp
FROM edidc
INTO TABLE gt_edidc
WHERE mestyp = lc_mestyp
AND idoctp = lc_idoctp
AND credat IN s_credat.
IF gt_edidc[] IS NOT INITIAL.
* Get IDOC details
CALL METHOD me->read_idocs.
ENDIF.
ENDMETHOD. "get_idocs
* METHOD read_idocs
METHOD read_idocs.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
text = text-p02.
FIELD-SYMBOLS: <fs_edidc> LIKE LINE OF gt_edidc,
<fs_output> LIKE LINE OF gt_output,
<fs_ekko> LIKE LINE OF gt_ekko,
<fs_lfa1> LIKE LINE OF gt_lfa1.
LOOP AT gt_edidc ASSIGNING <fs_edidc>.
CLEAR ls_idoc_control.
REFRESH: lt_edids, lt_edidd.
* Get status text of IDOC
CALL FUNCTION 'IDOC_GET_MESSAGE_ATTRIBUTE'
EXPORTING
idoc_number = <fs_edidc>-docnum
IMPORTING
idoc_message = lv_stat_message.
* Get IDOC details
CALL FUNCTION 'IDOC_READ_COMPLETELY'
EXPORTING
document_number = <fs_edidc>-docnum
IMPORTING
idoc_control = ls_idoc_control
number_of_data_records = lv_tot_data_recs
number_of_status_records = lv_tot_status_recs
TABLES
int_edids = lt_edids
int_edidd = lt_edidd
EXCEPTIONS
document_not_exist = 1
document_number_invalid = 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.
* Pass data to output table
CALL METHOD me->process_data
EXPORTING
im_docnum = <fs_edidc>-docnum.
ENDLOOP.
DELETE gt_output WHERE ebeln IS INITIAL.
IF gt_output[] IS NOT INITIAL.
* Get vendor for fetched POs
SELECT ebeln lifnr
FROM ekko
INTO TABLE gt_ekko
FOR ALL ENTRIES IN gt_output
WHERE ebeln = gt_output-ebeln.
IF gt_ekko[] IS NOT INITIAL.
* Get name of vendors
SELECT lifnr name1
FROM lfa1
INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_ekko
WHERE lifnr = gt_ekko-lifnr.
ENDIF.
* Pass vendor details to output table
LOOP AT gt_output ASSIGNING <fs_output>.
READ TABLE gt_ekko ASSIGNING <fs_ekko>
WITH TABLE KEY ebeln = <fs_output>-ebeln.
IF sy-subrc = 0.
READ TABLE gt_lfa1 ASSIGNING <fs_lfa1>
WITH TABLE KEY lifnr = <fs_ekko>-lifnr.
IF sy-subrc = 0.
<fs_output>-lifnr = <fs_lfa1>-lifnr.
<fs_output>-name1 = <fs_lfa1>-name1.
ENDIF.
ENDIF.
ENDLOOP.
CREATE OBJECT o_lcl_alv_routines.
CALL METHOD o_lcl_alv_routines->display_data
EXPORTING
im_output = gt_output[].
ENDIF.
ENDMETHOD. "read_idocs
* METHOD process_data
METHOD process_data.
FIELD-SYMBOLS: <fs_edidd> LIKE LINE OF lt_edidd.
IF lv_stat_message CP 'ok' OR
lv_stat_message CP 'positive'.
wa_output-exception = lc_green.
ELSEIF lv_stat_message CP 'error' OR
lv_stat_message CP 'negative'.
wa_output-exception = lc_red.
ELSE.
wa_output-exception = lc_yellow.
ENDIF.
READ TABLE lt_edidd ASSIGNING <fs_edidd>
WITH KEY docnum = im_docnum
segnam = lc_segnam.
IF sy-subrc = 0.
wa_output-ebeln = <fs_edidd>-sdata+0(10).
ENDIF.
wa_output-credat = ls_idoc_control-credat.
wa_output-cretim = ls_idoc_control-cretim.
APPEND wa_output TO gt_output.
CLEAR wa_output.
ENDMETHOD. "process_data
ENDCLASS. "lcl_get_data IMPLEMENTATION
* CLASS lcl_alv_routines IMPLEMENTATION
CLASS lcl_alv_routines IMPLEMENTATION.
* METHOD display_data
METHOD display_data.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 0
text = text-p03.
gt_output[] = im_output[].
TRY.
cl_salv_table=>factory(
EXPORTING
list_display = ''
IMPORTING
r_salv_table = lcl_table
CHANGING
t_table = gt_output ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
lcl_functions = lcl_table->get_functions( ).
* Set all standard ALV functions
lcl_functions->set_all( abap_true ).
lcl_columns = lcl_table->get_columns( ).
lcl_columns->set_optimize( '' ).
* Set display to striped pattern
lcl_display = lcl_table->get_display_settings( ).
lcl_display->set_striped_pattern( cl_salv_display_settings=>true ).
*/Sort columns
TRY.
lcl_sorts = lcl_table->get_sorts( ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
lcl_sorts->set_group_active( ).
TRY.
lcl_sorts->add_sort(
columnname = 'EBELN'
subtotal = '' ).
CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER
ENDTRY.
*/Set column names
TRY.
lcl_columns->set_exception_column( 'EXCEPTION' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'EXCEPTION' ).
lcl_column->set_short_text( text-h01 ).
lcl_column->set_medium_text( text-h01 ).
lcl_column->set_long_text( text-h01 ).
lcl_column->set_output_length( '6' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'EBELN' ).
lcl_column->set_short_text( text-h02 ).
lcl_column->set_medium_text( text-h02 ).
lcl_column->set_long_text( text-h02 ).
lcl_column->set_output_length( '9' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'LIFNR' ).
* lcl_column->set_short_text( text-h03 ).
lcl_column->set_medium_text( text-h03 ).
lcl_column->set_long_text( text-h03 ).
lcl_column->set_output_length( '11' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'NAME1' ).
* lcl_column->set_short_text( text-h04 ).
* lcl_column->set_medium_text( text-h04 ).
lcl_column->set_long_text( text-h04 ).
lcl_column->set_output_length( '30' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'CREDAT' ).
* lcl_column->set_short_text( text-h05 ).
* lcl_column->set_medium_text( text-h05 ).
lcl_column->set_long_text( text-h05 ).
lcl_column->set_output_length( '13' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
TRY.
lcl_column ?= lcl_columns->get_column( 'CRETIM' ).
* lcl_column->set_short_text( text-h06 ).
* lcl_column->set_medium_text( text-h06 ).
lcl_column->set_long_text( text-h06 ).
lcl_column->set_output_length( '13' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*/Set aggregations
* TRY.
* lcl_aggregations = lcl_table->get_aggregations( ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
* TRY.
* lcl_aggregations->add_aggregation( '' ).
* CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER
* ENDTRY.
*/Hide columns
* TRY.
* lcl_column ?= lcl_columns->get_column( 'DESCRIPT' ).
* lcl_column->set_visible( if_salv_c_bool_sap=>false ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
*/Display top of page
CALL METHOD me->display_top_of_page.
lcl_table->set_top_of_list( lcl_content ).
*/Handle ALV events
lcl_events2 = lcl_table->get_event( ).
CREATE OBJECT lcl_handle_events.
SET HANDLER lcl_handle_events->on_link_click FOR lcl_events2.
lcl_display_settings = lcl_table->get_display_settings( ).
lcl_table->display( ).
ENDMETHOD. "display_data
* METHOD display_top_of_page
METHOD display_top_of_page.
CREATE OBJECT lcl_grid.
lv_title = text-t01.
lcl_grid->create_header_information(
row = 1
column = 1
text = lv_title
tooltip = lv_title ).
lcl_grid->add_row( ).
lcl_grid_1 = lcl_grid->create_grid(
row = 3
column = 1 ).
CLEAR lv_string.
CONCATENATE: sy-datum+4(2) '/' sy-datum+6(2) '/' sy-datum+0(4)
INTO lv_date1.
CONCATENATE: text-t02 lv_date1
INTO lv_string
SEPARATED BY space.
lcl_label = lcl_grid_1->create_label(
row = 1
column = 1
text = lv_string
tooltip = lv_string ).
CLEAR lv_string.
CONCATENATE: sy-uzeit+0(2) ':' sy-uzeit+2(2) ':' sy-uzeit+4(2)
INTO lv_time.
CONCATENATE: text-t03 lv_time
INTO lv_string
SEPARATED BY space.
lcl_label = lcl_grid_1->create_label(
row = 2
column = 1
text = lv_string
tooltip = lv_string ).
lcl_content = lcl_grid.
ENDMETHOD. "display_top_of_page
ENDCLASS. "lcl_alv_routines IMPLEMENTATION
* CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
* METHOD on_link_click
METHOD on_link_click.
ENDMETHOD. "on_link_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
* START-OF-SELECTION *
START-OF-SELECTION.
DATA: o_lcl_get_data TYPE REF TO lcl_get_data.
CREATE OBJECT o_lcl_get_data.
CALL METHOD o_lcl_get_data->get_idocs. -
Hi Folks,
Need your help.
I have designed a report to be displayed in ALV tree. The report contains one column (Amount) which can be totaled using the SUM function of the ALV. The report is a 3 level hierarchy - Proj number, Plant and Proj type. When I select the Amount column and click on SUM button, I get the total value of Amount for that particular proj number.
Now, what I want is, a functionality to get the sub total of Amount on the basis of Proj type. Please advice me to get the desired functionality done.
For more clarity please see the below scenario what I want -
Proj number 12345
____Plant XYZ
________Proj type CA 100
_______________ CA 100
________ subtotal 200
________ Proj type CE 150
________________CE 100
________subtotal 250After building fieldcatalog,use this
data: lt_sort TYPE lvc_t_sort ,
ls_sort-fieldname = 'PROJECT'--> ur fieldname .
ls_sort-spos = '1' .
ls_sort-subtot = 'X' .
ls_sort-up = 'X' .
APPEND ls_sort TO lt_sort . -
Sort Icon/option in ALV tree repot using classes and methods
Hi all,
I have done an alv tree report using the class cl_gui_alv_tree
and i need to let users re-sort the report by using a sort icon(as visible in a normal alv report).Is there any possibility to create an icon and set the functionality such that the entire tree structure gets resorted depending upon the sort criteria?Please give me an example of doing so if there is an option.if u want without classes then i can give an example of Sort Icon/option.
example:-
DATA: wa_sortinfo TYPE slis_sortinfo_alv.
i_sortcat TYPE slis_t_sortinfo_alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_grid_title = ws_title
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat[]
it_sort = i_sortcat
i_save = 'A'
it_events = i_events
TABLES
t_outtab = i_reportdata1
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.
PERFORM sortcat_init CHANGING i_sortcat.
FORM sortcat_init CHANGING i_sortcat TYPE slis_t_sortinfo_alv.
CLEAR wa_sortinfo.
wa_sortinfo-fieldname = 'EBELN'. (sales order)
wa_sortinfo-tabname = 'I_REPORTDATA1'.
wa_sortinfo-spos = 1. " First sort by this field.
wa_sortinfo-up = 'X'. " Ascending
wa_sortinfo-subtot = 'X'. " Subtotal at Name1
APPEND wa_sortinfo TO i_sortcat.
CLEAR wa_sortinfo.
wa_sortinfo-fieldname = 'EBELP'.
wa_sortinfo-tabname = 'I_REPORTDATA1'.
wa_sortinfo-spos = 2. " Sec sort by this field.
wa_sortinfo-up = 'X'. " Ascending
wa_sortinfo-subtot = 'X'. " Subtotal at Name1
APPEND wa_sortinfo TO i_sortcat.
ENDFORM. " sortcat_init -
Hi ;
i am trying to expand the tree according to tree level.
loop at itab where level = lvl.
clear snode.
snode = itab-key.
append snode to inode.
endloop.
call method tree1->expand_nodes
exporting
it_node_key = inode
exceptions
failed = 1
cntl_system_error = 2
error_in_node_key_table = 3
dp_error = 4
node_not_found = 5
others = 6.
when lvl = 1 everything is ok it expands level 1 nodes
but if lvl greater than 1 (2,3,4 ...) it gives error
<b>Runtime Errors MESSAGE_TYPE_X</b>
ThanksHi Mustafa,
<b>Good ... Check out the following example program for ALV Tree</b>
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
<b>Good Luck and thanks
AK</b> -
Hello!
This below listed code dumps all over the time.
I checked the whole code and its almost impossible to find
out the problem. Hopefully has somebody an idea.
Reagrds
Ilhan
class cl_gui_column_tree definition load.
class cl_gui_cfw definition load.
data tree1 type ref to cl_gui_alv_tree_simple.
INCLUDE /G2A/ZTREE_ICON.
INCLUDE /G2A/ZTREE_EVENT.
data: gt_sflight type sflight occurs 0, "Output-Table
gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
gt_sort type lvc_t_sort, "Sortiertabelle
ok_code like sy-ucomm. "OK-Code
data itab type ZQMCOMP occurs 0.
data wa type ZQMCOMP.
* Struktur Feldkatalog
data lw TYPE lvc_s_fcat.
* interne Tabelle Feldkatalog
data gt TYPE lvc_t_fcat.
* Layoutstruktur
data wa_layout TYPE lvc_s_layo.
start-of-selection.
end-of-selection.
call screen 100.
*& Form BUILD_FIELDCATALOG
* text
form build_fieldcatalog.
** get fieldcatalog
* call function 'LVC_FIELDCATALOG_MERGE'
* exporting
* i_structure_name = 'wa'
* changing
* ct_fieldcat = gt.
** 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.
* ================================================
* FELDKATALOG
* ================================================
CLEAR: lw.
lw-fieldname = 'QMNUM'.
lw-tabname = 'wa'.
lw-col_pos = 1.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'QMART'.
lw-tabname = 'wa'.
lw-col_pos = 2.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'POSNR'.
lw-tabname = 'wa'.
lw-col_pos = 3 .
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'REFNR'.
lw-tabname = 'wa'.
lw-col_pos = 4.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'KUNDE'.
lw-tabname = 'wa'.
lw-col_pos = 5.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
CLEAR: lw.
lw-fieldname = 'DUNS'.
lw-tabname = 'wa'.
lw-col_pos = 6.
lw-EMPHASIZE = 'C711'.
APPEND lw TO gt.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_OUTTAB
* text
* --> p1 text
* <-- p2 text
form build_outtab.
* select * from sflight into table gt_sflight.
select * from ZQMCOMP into table itab.
* up to 1 rows.
endform. " BUILD_OUTTAB
*& Form BUILD_SORT_TABLE
* text
* --> p1 text
* <-- p2 text
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
* text
module pbo output.
if tree1 is initial.
perform init_tree.
endif.
set pf-status 'MAIN100'.
endmodule. " PBO OUTPUT
*& Module PAI INPUT
* text
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
* 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.
* 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 html_header
* --> p1 text
* <-- p2 text
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-info = 'METZELER OEM-BEANSTANDUNGEN'.
append ls_line to pt_list_commentary.
clear ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Datum'.
ls_line-info = sy-datlo.
append ls_line to pt_list_commentary.
* ls_line-key = 'time'.
* ls_line-info = '00.00 pm'.
* append ls_line to pt_list_commentary.
** ACTION LINE: TYPE A
* clear ls_line.
* ls_line-typ = 'A'.
** LS_LINE-KEY: NOT USED FOR THIS TYPE
* ls_line-info = 'up-to-date data'.
* append ls_line to pt_list_commentary.
p_logo = 'ENJOYSAP_LOGO'.
endform.
*& Form init_tree
* text
* --> p1 text
* <-- p2 text
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 = itab
* it_fieldcatalog = gt_fieldcatalog.
it_fieldcatalog = gt.
* 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_treesorry this the english version
ABAP runtime errors GETWA_NOT_ASSIGNED
Occurred on 09.03.2007 at 15:35:20
>> Short dump has not been completely stored. It is too big.
Field symbol has not yet been assigned.
What happened?
The current ABAP/4 program "CL_GUI_ALV_TREE_SIMPLE========CP " had to be
terminated because
one of the statements could not be executed.
This is probably due to an error in the ABAP/4 program.
What can you do?
Note the actions and input that caused the error.
Inform your SAP system administrator.
You can print out this message by choosing "Print". Transaction ST22
allows you to display and manage termination messages, including keeping
them beyond their normal deletion date.
Error analysis
You attempted to access an unassigned field symbol
(data segment 32771).
This error occurs:
- if you address a typed field symbol before it has been set with
ASSIGN or
- if you address a field symbol that has been reset with UNASSIGN
or pointed to a local field that no longer exists, or
- if you address a field symbol that pointed to a line of an internal
table that has now been deleted, or
- if you address a global function interface partameter, even
though the relevant function module is not active,
i.e. it is not in the list of active calls. You can get the list
of active calls from the this short dump.
How to correct the error
If the error occurred in a non-modified SAP program, you may be
able to find a solution in the SAP note system.
If you have access to the note system yourself, use the following
search criteria:
"GETWA_NOT_ASSIGNED"
"CL_GUI_ALV_TREE_SIMPLE========CP " or "CL_GUI_ALV_TREE_SIMPLE========CM00J "
"SET_NODES"
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
To obtain this, select the "Print" function on the current screen.
2. A suitable hardcopy prinout of the system log.
To obtain this, call the system log with Transaction SM21
and select the "Print" function to print out the relevant
part.
3. If the programs are your own programs or modified SAP programs,
supply the source code.
To do this, you can either use the "PRINT" command in the editor or
print the programs using the report RSINCL00.
4. Details regarding the conditions under which the error occurred
or which actions and input led to the error.
System environment
SAP Release.............. "46C"
Application server....... "s96as822"
Network address.......... "53.71.198.54"
Operating system......... "SunOS"
Release.................. "5.8"
Hardware type............ "sun4u"
Database server.......... "s96as822"
Database type............ "ORACLE"
Database name............ "G2E"
Database owner........... "SAPR3"
Character set............ "en_US"
SAP kernel............... "46D"
Created on............... "Nov 27 2005 20:48:26"
Created in............... "SunOS 5.7 Generic_106541-05 sun4u"
Database version......... "OCI_816_64__OCI_7_API "
Patch level.............. "2162"
Patch text............... " "
Supported environment....
Database................. "ORACLE 8.0.5.., ORACLE 8.0.6.., ORACLE
8.1.6.., ORACLE 8.1.7.., ORACLE 9.2.0.."
SAP database version..... "46D"
Operating system......... "SunOS 5.6, SunOS 5.7, SunOS 5.8, SunOS 5.9, SunOS
5.10, , System build information:, -
, LCHN
: 794995"
User, transaction...
Client.............. 112
User................ "ASIKOGLU"
Language key........ "E"
Transaction......... "SEU_INT "
Program............. "CL_GUI_ALV_TREE_SIMPLE========CP "
Screen.............. "/G2A/ZTREE 0100"
Screen line......... 2
Information on where termination occurred
The termination occurred in the ABAP/4 program
"CL_GUI_ALV_TREE_SIMPLE========CP " in
"SET_NODES".
The main program was "/G2A/ZTREE ".
The termination occurred in line 210
of the source code of program "CL_GUI_ALV_TREE_SIMPLE========CM00J " (when
calling the editor 2100).
Source code extract
001800 m_current_node_key = l_node_key.
001810 raise event ON_ADD_HIERARCHY_NODE
001820 exporting
001830 grouplevel = ls_sort_wa-fieldname
001840 index_outtab = l_index_outtab.
001850
001860 * stack last key
001870 insert l_node_key into lt_parent_stack index 1.
001880
001890 * set parameters for next loop.
001900 l_prev_level = <ls_grouplevels_wa>-level.
001910 l_index_from = <ls_grouplevels_wa>-index_from.
001920 l_index_to = <ls_grouplevels_wa>-index_to.
001930 endloop.
001940
001950 * complete last nodes from outtab
001960 loop at it_outtab assigning <wa> from l_index_from to l_index_to.
001970 l_index = sy-tabix.
001980 * get relation-key
001990 read table lt_parent_stack into l_relat_key index 1.
002000 l_relationship = cl_tree_control_base=>relat_last_child.
002010 assign component l_last_level of structure <wa> to <h_key>.
002020 * read and format output-data
002030 call method cl_gui_alv_grid=>CELL_Display
002040 exporting
002050 is_data = <wa>
002060 i_int_value = <h_key>
002070 importing
002080 e_ext_value = l_node_text
002090 changing
> cs_fieldcat = ls_fieldcatalog_wa.
002110 condense l_node_text.
002120
002130 * set layout
002140 clear ls_node_layout.
002150 clear lt_item_layout[].
002160 call method me->set_layout
002170 exporting
002180 i_grouplevel = l_last_level
002190 importing
002200 es_node_layout = ls_node_layout
002210 et_item_layout = lt_item_layout
002220 changing
002230 is_outtabline = <wa>.
002240
002250 call method me->add_model_node
002260 exporting
002270 i_relat_node_key = l_relat_key
002280 i_relationship = l_relationship
002290 i_node_text = l_node_text
Contents of system fields
SY field contents..................... SY field contents.....................
SY-SUBRC 4 SY-INDEX 0
SY-TABIX 1 SY-DBCNT 1
SY-FDPOS 1 SY-LSIND 0
SY-PAGNO 0 SY-LINNO 1
SY-COLNO 1 -
ALV tree - run time error.
I'm trying to creat an ALV tree with the format exactly the same as BCalv_tree_simple_demo program, except adding one more node. I create a database table in se11 and exporting this table to ALV. However when i run it, it showed run time error that "Field symbol has not yet been assigned".
Trigger Location of Runtime Error
Program CL_GUI_ALV_TREE_SIMPLE========CP
Include CL_GUI_ALV_TREE_SIMPLE========CM01G
Row 13
Module type (METHOD)
Module Name SET_HIERARCHY_DATA
This is a part of my code
FORM build_fieldcatalog.
* get fieldcatalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZTRANG' """
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 'ZTELCO' OR 'ZVP' OR 'ZDEPT' OR 'ZKOSTL'.
ls_fieldcatalog-no_out = 'X'.
ls_fieldcatalog-key = ''.
WHEN 'ZDESC' OR 'ZMONTH1' OR 'ZMONTH2' OR 'ZMONTH3'.
ls_fieldcatalog-do_sum = 'X'.
ENDCASE.
MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_OUTTAB
* text
* --> p1 text
* <-- p2 text
FORM build_outtab.
SELECT * FROM ztrang INTO TABLE gt_tree.
* up to 1 rows.
ENDFORM. " BUILD_OUTTAB
*& Form BUILD_SORT_TABLE
* text
* --> p1 text
* <-- p2 text
FORM build_sort_table.
DATA ls_sort_wa TYPE lvc_s_sort.
* create sort-table
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = 'ZTELCO'.
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 = 'ZVP'.
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 = 'ZDEPT'.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
APPEND ls_sort_wa TO gt_sort.
ls_sort_wa-spos = 4.
ls_sort_wa-fieldname = 'ZKOSTL'.
ls_sort_wa-up = 'X'.
* ls_sort_wa-subtot = 'X'.
APPEND ls_sort_wa TO gt_sort.
ENDFORM. " BUILD_SORT_TABLE
Do you have any clues for this? Thanks.
Edited by: trangie on Apr 13, 2009 5:13 PMHello,
Please check the dumps in ST22 and search for applicable notes based on your version of installation.
Regards,
Gowrinadh -
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 -
Runtime Error in ALV Tree Output
Dear All, I am trying to create a ALV Tree using Class cl_gui_alv_tree. The Report Shows the Output with the first Node but when i try to expand it is dumping with a runtime error GETWA_NOT_ASSIGNED in class CL_ALV_TREE_BASE and method SET_ITEMS_FOR_COLUMN. The Reason being the data which was copied in the initial node display to mt_outtab is getting refreshed.
Can any one of you help me the reason for the table getting refreshed. Do i need to pass any data.
I am doing the following steps.
1. Create Container,
2. Create Tree Class object
3. Generate the Field Catalog.
4. Set table for first display " With empty internal table
5. Generate the Hierarchy
6. Call the Method Frontend Update.
Let me know if i had missed any steps in the process.
Thank you,
Regards,
Swaroop PatriOne reason for getting this error is using local defined tables for it_outtab parameter in the below code:
To get rid of the dump, define two distinct output tables globally: one is an empty table which you will pass to the below method, other one is your real output table whose size increases dependently.
CALL METHOD go_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = ls_hier_header
CHANGING
it_outtab = gt_data_e "Empty table
it_fieldcatalog = gt_fcat_tree. -
Unable to expand child links in ALV Tree
Hi,
I have written the following code for ALV Tree using function modules.
REPORT ZSID_ALV_TREE.
type pool declarations for tree
TYPE-POOLS : fibs,stree.
tables: ekko.
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,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_ekpo TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko,
wa_ekpo TYPE t_ekko.
DATA:w_repid type sy-cprog.
*Data declaration for additional node information
DATA : t_node TYPE snodetext.
*Internal table and wa decl for nodes
DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
wa_node LIKE t_node.
*Start of selection event
START-OF-SELECTION.
*Select the data for tree
PERFORM fetch_data.
*Build the hierarchy for tree
PERFORM build_hierarchy.
*Build Tree for display
PERFORM build_tree.
*& Form fetch_data
text
--> p1 text
<-- p2 text
FORM fetch_data .
SELECT ebeln
up to 10 rows
FROM ekko
INTO corresponding fields of TABLE it_ekko .
loop at it_ekko into wa_ekko.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
FROM ekpo
appending TABLE it_ekpo
where ebeln eq wa_ekko-ebeln.
endloop.
endform.
*& Form build_hierarchy
text
--> p1 text
<-- p2 text
FORM build_hierarchy .
*Building the nodes and hierarchy for tree
CLEAR : it_node[], wa_node.
wa_node-type = 'T'.
wa_node-name = 'Product Hierarchy Level'.
wa_node-tlevel = '01'.
wa_node-nlength = '35'.
wa_node-color = '4'.
wa_node-text = 'Test'.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
loop at it_ekpo into wa_ekpo.
wa_node-type = 'P'.
wa_node-name = 'Purchasing Doc'.
wa_node-tlevel = '02'.
wa_node-nlength = '25'.
wa_node-color = '4'.
wa_node-text = wa_ekpo-ebeln.
wa_node-tlength ='20'.
wa_node-tcolor = 3.
APPEND wa_node TO it_node.
CLEAR wa_node.
*Filling the values of internal table into tree
wa_node-type = 'P'.
wa_node-name = 'Material No'.
wa_node-tlevel = '03'.
wa_node-nlength = '20'.
wa_node-color = '1'.
wa_node-text = wa_ekpo-matnr.
wa_node-tlength ='20'.
wa_node-tcolor = 4.
APPEND wa_node TO it_node.
CLEAR wa_node.
ENDLOOP.
ENDFORM. " build_hierarchy
*& Form build_tree
text
--> p1 text
<-- p2 text
FORM build_tree .
*Fm for constructing the tree
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = it_node.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
w_repid = SY-CPROG.
*FM for displaying the tree
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
CALLBACK_PROGRAM = w_repid
CALLBACK_USER_COMMAND = 'USER1_COMMAND'
CALLBACK_TEXT_DISPLAY =
CALLBACK_MOREINFO_DISPLAY =
CALLBACK_COLOR_DISPLAY =
CALLBACK_TOP_OF_PAGE =
CALLBACK_GUI_STATUS =
CALLBACK_CONTEXT_MENU =
STATUS = 'IMPLICIT'
CHECK_DUPLICATE_NAME = '0'
COLOR_OF_NODE = '4'
COLOR_OF_MARK = '3'
COLOR_OF_LINK = '1'
COLOR_OF_MATCH = '5'
LOWER_CASE_SENSITIVE = 'X'
MODIFICATION_LOG = 'X'
NODE_LENGTH = 40
TEXT_LENGTH = 75
TEXT_LENGTH1 = 0
TEXT_LENGTH2 = 0
RETURN_MARKED_SUBTREE = 'X'
SCREEN_START_COLUMN = 0
SCREEN_START_LINE = 0
SCREEN_END_COLUMN = 0
SCREEN_END_LINE = 0
SUPPRESS_NODE_OUTPUT = 'X'
LAYOUT_MODE = ' '
USE_CONTROL = 'L'.
IMPORTING
F15 =
ENDFORM. " build_tree
FORM USER1_COMMAND TABLES node STRUCTURE seucomm
USING command
CHANGING value(exit)
VALUE(LIST_REFRESH).
write 'Hi'.
endform.
But I have a problem
1. I can expand the child links in tree structure when I comment the exporting parameter CALLBACK_USER_COMMAND in the function Module 'RS_TREE_LIST_DISPLAY'.
2 But when i uncomment the exporting parameter I am unable to expand the child links in output.
Please let me know if i have missed something in the code.
Useful answers will be rewarded
Regards,
SiddharthHi Sidhhart,
Check out this prog.
REPORT Z_KULDEEP_ALV_HIERARCHY
message-id zord
line-size 270.
Tables:
Vbap,
Vbak.
*& PROGRAM VARIABLES
type-pools slis.
*& INTERNAL TABLES & STRUCTURES
data:
begin of t_header occurs 0,
EXPCOL type c,
vbeln type vbak-vbeln,
audat type vbak-audat,
vkorg type vbak-vkorg,
vtweg type vbak-vtweg,
spart type vbak-spart,
end of t_header,
begin of t_item occurs 0,
vbeln type vbap-vbeln,
posnr type vbap-posnr,
matnr type vbap-matnr,
arktx type vbap-arktx,
pstyv type vbap-pstyv,
end of t_item,
t_fieldcat type standard table of slis_fieldcat_alv with header line,
t_event type standard table of slis_alv_event with header line,
x_keyinfo type slis_keyinfo_alv,
x_layout type slis_layout_alv,
x_variant like disvariant.
*& GLOBAL VARIABLES
data:
g_repid type sy-repid,
g_formname type slis_formname value 'TOP_OF_PAGE'.
*& SELECTION SCREEN *
selection-screen begin of block a with frame title text-000.
Select-options : s_date for vbak-audat obligatory.
p_date type vbak-audat.
selection-screen end of block a.
*& INITIALIZATION *
initialization.
clear : g_repid,t_header,t_item.
refresh : t_header,t_item.
g_repid = sy-repid.
*& AT SELECTION-SCREEN *
at selection-screen.
if s_date-high > sy-datum.
message e001.
endif.
start-of-selection.
select vbeln audat vkorg vtweg spart from vbak
into corresponding fields of table t_header
where audat in s_date.
select vbeln posnr matnr arktx pstyv from vbap
into table t_item
for all entries in t_header
where vbeln = t_header-vbeln.
end-of-selection.
perform sub_display_alv.
*& Form sub_display_alv
text
--> p1 text
<-- p2 text
form sub_display_alv.
*column 1
perform sub_populate_fieldcatalog using:
'VBELN' " field name
'T_HEADER' " table name
'ORDER' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 2
perform sub_populate_fieldcatalog using:
'AUDAT' " field name
'T_HEADER' " table name
'ORDERDATE' " column heading
'10' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 3
perform sub_populate_fieldcatalog using:
'VKORG' " field name
'T_HEADER' " table name
'SALES ORG' " column heading
'6' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 4
perform sub_populate_fieldcatalog using:
'VTWEG' " field name
'T_HEADER' " table name
'DIVISION' " column heading
'2' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 5
perform sub_populate_fieldcatalog using:
'SPART' " field name
'T_HEADER' " table name
'CHANNEL' " column heading
'4' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 6
perform sub_populate_fieldcatalog using:
'vbeln' " field name
'T_item' " table name
'Order' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 7
perform sub_populate_fieldcatalog using:
'POSNR' " field name
'T_ITEM' " table name
'SALES DOC.ITEM' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 8
perform sub_populate_fieldcatalog using:
'MATNR' " field name
'T_ITEM' " table name
'MATERIAL' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 9
perform sub_populate_fieldcatalog using:
'ARKTX' " field name
'T_ITEM' " table name
'SALES ORDER ITEM' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
*column 10
perform sub_populate_fieldcatalog using:
'PSTYV' " field name
'T_ITEM' " table name
'ITEM CATEGORY' " column heading
'8' " column width
' ' " fix column?
' ' " key
' ' " no display
' ' " sum this column
'X' " do not sum
' ' " input allowed?
' ' " currenct type field name
' ' " data type
'X'. " hotspot.
perform sub_assign_events.
Create a Layout for the ALV
perform sub_layout.
Define the key fields that links the header & item tables
perform sub_define_key.
dispaly list
perform sub_call_list_display.
endform. " sub_display_alv
*& Form sub_populate_fieldcatalog
text
-->P_G_FIELDCAT text
-->P_0198 text
-->P_0199 text
-->P_0200 text
-->P_0201 text
-->P_0202 text
-->P_0203 text
-->P_0204 text
-->P_0205 text
-->P_0206 text
-->P_0207 text
-->P_0208 text
-->P_0209 text
-->P_0210 text
-->P_0211 text
-->P_0212 text
-->P_0213 text
form sub_populate_fieldcatalog using
l_fieldname
l_tabname
l_column_heading
l_outputlen
l_fix_column
l_key
l_no_out
l_do_sum
l_no_sum
l_input
l_cfieldname
l_datatype
l_hotspot.
t_fieldcat-fieldname = l_fieldname.
t_fieldcat-tabname = l_tabname.
t_fieldcat-reptext_ddic = l_column_heading.
t_fieldcat-outputlen = l_outputlen.
t_fieldcat-fix_column = l_fix_column.
t_fieldcat-key = l_key.
t_fieldcat-no_out = l_no_out.
t_fieldcat-do_sum = l_do_sum.
t_fieldcat-no_sum = l_no_sum.
t_fieldcat-cfieldname = l_cfieldname.
t_fieldcat-datatype = l_datatype.
t_fieldcat-hotspot = l_hotspot.
append t_fieldcat.clear t_fieldcat.
endform. " sub_populate_fieldcatalog
*& Form sub_assign_events
text
--> p1 text
<-- p2 text
form sub_assign_events.
refresh t_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 1
importing
et_events = t_event[]
exceptions
list_type_wrong = 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.
Read the record for the top-of-page event
read table t_event with key slis_ev_top_of_page.
if sy-subrc = 0.
t_event-form = g_formname.
append t_event.
endif.
endform. " sub_assign_events
*& Form SUB_LAYOUT
text
--> p1 text
<-- p2 text
form sub_layout.
clear x_layout.
x_layout-f2code = 'QUOTE'.
x_layout-zebra = 'X'.
x_layout-expand_fieldname = 'EXPCOL'. " Field for expand/collapse
*Stat
x_layout-colwidth_optimize = 'X'.
x_layout-no_totalline = 'X'. " 0001+
endform. " SUB_LAYOUT
*& Form SUB_DEFINE_KEY
text
--> p1 text
<-- p2 text
form sub_define_key.
clear x_keyinfo.
x_keyinfo-header01 = 'VBELN'.
x_keyinfo-item01 = 'VBELN'.
endform. " SUB_DEFINE_KEY
form top_of_page.
write :/10 sy-datum, 20 sy-pagno, 30 sy-uname.
endform.
form sub_user_command using f_ucomm like sy-ucomm
f_selfield type slis_selfield.
if f_ucomm = 'QUOTE'.
if f_selfield-fieldname = 'VBELN'.
Set Parameter id 'AUN' field f_selfield-value.
call transaction 'VA03'.
endif.
endif.
endform.
*& Form sub_call_list_display
text
--> p1 text
<-- p2 text
form sub_call_list_display.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_user_command = 'SUB_USER_COMMAND '
is_layout = x_layout
it_fieldcat = t_fieldcat[]
i_save = 'A'
it_events = t_event[]
i_tabname_header = 'T_HEADER'
i_tabname_item = 'T_ITEM'
is_keyinfo = x_keyinfo
tables
t_outtab_header = t_header[]
t_outtab_item = t_item[]
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. " sub_call_list_display -
Hello Friends,
I am using ALV Tree to display a report.
In this report for a particular input.2 nodes are cerated.
On clicking on the 2nd node the details for the same are shown .
However on clicking the 1st node , the system automatically logs off closing all the SAP sessions and even the SAP Logon pad.
Suppose i am on executing the program on development server,even the sessions of test server are closed.
Can anyone please help me in this.....
its a bit urgent.
i am attaching my code for reference.
REPORT ZPRPROUTOPERATIONS1 .
tables : mapl,t001w,zroutpromast.
TYPE-POOLS: slis,kkblo.
include <icon>.
data : it_zrouteledtl like zrouteledtl occurs 0 with header line.
data : it_zeledtl type zeledtl occurs 0 with header line.
data : conv_sec(5) type c value '0.036'.
types : begin of it_output2,
Srno like zrouteledtl-srno,
srno1 type p decimals 8,
subgid like zrouteledtl-subgid,
subopn like zrouteledtl-subopn,
movetype type zeledtl-movetype,
DESC type zeledtl-description,
Add_desc like zrouteledtl-DESCRIPTION,
Freq type p decimals 2,
div_freq type p decimals 2,
men type p decimals 2,
offline(3),
CT type p decimals 2,
CW type p decimals 2,
Ideal_ct type p decimals 2,
ideal_cw type p decimals 2,
A_trg type p decimals 2,
b_Trg type p decimals 2,
g_Trg type p decimals 2,
p_Trg type p decimals 2,
m_Trg type p decimals 2,
t_Trg type p decimals 2,
i_Trg type p decimals 2,
Autocycle type p decimals 2,
online_time type p decimals 2,
offline_time type p decimals 2,
online_p_time type p decimals 2,
offline_p_time type p decimals 2,
end of it_output2.
*types : begin of it_output3,
Srno like zrouteledtl-srno,
mop_gid like zroutdetails-MOP_GID,
MOp_opn like zroutdetails-MOP_OPN,
sub_gid like zpromast-subgid,
subopn like zpromast-subopn,
DESC like zpromast-description,
Add_desc like zroutdetails-ADD_INFO,
Freq type p decimals 2,
batch type p decimals 2,
mix type p decimals 2,
offline(3),
CT type p decimals 2,
CW type p decimals 2,
Ideal_ct type p decimals 2,
ideal_cw type p decimals 2,
A_trg type p decimals 2,
b_Trg type p decimals 2,
g_Trg type p decimals 2,
p_Trg type p decimals 2,
m_Trg type p decimals 2,
t_Trg type p decimals 2,
i_Trg type p decimals 2,
Autocycle type p decimals 2,
online_time type p decimals 2,
offline_time type p decimals 2,
online_p_time type p decimals 2,
offline_p_time type p decimals 2,
end of it_output3.
data : it_output type it_output2 occurs 0 with header line,
it_output1 type it_output2 occurs 0 with header line,
it_emptytab type standard table of it_output2 INITIAL SIZE 0.
data : a_trg type f,b_trg type f,g_trg type f,p_trg type f,m_trg type f,t_trg type f,i_trg type f,
autocycle type f,online_p_time type f,offline_p_time type f.
data : ch1 type c,ch2.
DATA: ok_code like sy-ucomm, "OK-Code
save_ok like sy-ucomm.
data : ct_fieldcat type KKBLO_T_FIELDCAT.
*ALV data declarations
DATA: fieldcatalog TYPE lvc_t_fcat WITH HEADER LINE.
DATA: gd_fieldcat TYPE lvc_t_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv.
*ALVtree data declarations
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: gd_tree TYPE REF TO cl_gui_alv_tree,
gd_hierarchy_header TYPE treev_hhdr,
gd_report_title TYPE slis_t_listheader,
gd_logo TYPE sdydo_value,
gd_variant TYPE disvariant.
*Create container for alv-tree
DATA: gd_tree_container_name(30) TYPE c,
gd_custom_container TYPE REF TO cl_gui_custom_container.
*data mr_toolbar type ref to cl_gui_toolbar. "Add to top include
selection-screen begin of block start with frame title text-001.
select-options: p_gid for zroutpromast-mop_gid obligatory no-extension no intervals,
p_opn for zroutpromast-mop_opn obligatory no-extension no intervals,
p_werks for t001w-werks obligatory no-extension no intervals.
selection-screen end of block start.
*selection-screen begin of block detail with frame title text-002.
*parameter : radio1 radiobutton group dept default 'X',
radio2 radiobutton group dept.
*selection-screen end of block detail.
include ZTEST_TOOLBAR_EVENT_RECEIVER.
start-of-selection.
ALVtree setup data
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
PERFORM build_report_title USING gd_report_title gd_logo.
PERFORM build_variant.
Display ALVtree report
call screen 100.
*& Form data_retrieval
text
--> p1 text
<-- p2 text
FORM data_retrieval .
select * from zrouteledtl into table it_zrouteledtl where mop_gid in p_gid and
mop_opn in p_opn
and werks in p_werks.
if sy-subrc ne 0.
message i001(0) with 'No Records Found'.
leave program.
endif.
select * from zeledtl into table it_zeledtl for all entries in it_zrouteledtl
where subgid = it_zrouteledtl-subgid
and subopn = it_zrouteledtl-subopn
and werks = it_zrouteledtl-werks.
loop at it_zeledtl.
it_output1-srno = it_zeledtl-srno.
it_output1-srno1 = it_zeledtl-srno.
it_output1-subgid = it_zeledtl-subgid.
it_output1-subopn = it_zeledtl-subopn.
it_output1-movetype = it_zeledtl-movetype.
it_output1-desc = it_zeledtl-DESCRIPTION.
it_output1-freq = it_zeledtl-frequency.
it_output1-div_freq = it_zeledtl-div_freq.
it_output1-men = it_zeledtl-men.
it_output1-offline = it_zeledtl-offline1.
it_output1-ct = it_zeledtl-cy_time * conv_sec.
it_output1-cw = it_zeledtl-wc_time * conv_sec.
it_output1-ideal_ct = it_zeledtl-cy_trg_time * conv_sec.
it_output1-ideal_cw = it_zeledtl-wc_trg_time * conv_sec.
if it_zeledtl-men = 0.
it_output-autocycle = it_zeledtl-cy_time * conv_sec.
endif.
if it_zeledtl-men ne 0 and it_zeledtl-offline1 eq 'NO'
and ( it_zeledtl-movetype eq 'A' or it_zeledtl-movetype eq 'C' ).
case it_zeledtl-movetype.
when 'A'.
if it_zeledtl-SIM_AUTO = 'TRUE'.
ch2 = 0.
else.
ch2 = 1.
endif.
it_output-online_p_time = ( it_zeledtl-autocycle * ch2 * conv_sec ) * it_zeledtl-frequency / it_zeledtl-div_freq.
when 'C'.
if it_zeledtl-sim5 = 'TRUE'.
ch1 = 0.
else.
ch1 = 1.
endif.
it_output-online_p_time = ( it_zeledtl-index5 * it_zeledtl-par_freq5 * ch1
it_zeledtl-frequency * 10 ) / it_zeledtl-div_freq .
endcase.
elseif it_zeledtl-men ne 0 and it_zeledtl-offline1 eq 'YES'
and ( it_zeledtl-movetype eq 'A' or it_zeledtl-movetype eq 'C' ).
case it_zeledtl-movetype.
when 'A'.
if it_zeledtl-SIM_AUTO = 'TRUE'.
ch2 = 0.
else.
ch2 = 1.
endif.
it_output1-offline_p_time = ( it_zeledtl-autocycle * ch2 * conv_sec ) * it_zeledtl-frequency / it_zeledtl-div_freq.
when 'C'.
if it_zeledtl-sim5 = 'TRUE'.
ch1 = 0.
else.
ch1 = 1.
endif.
it_output-offline_p_time = ( it_zeledtl-index5 * it_zeledtl-par_freq5 * ch1
it_zeledtl-frequency * 10 ) / it_zeledtl-div_freq .
endcase.
endif.
it_output1-a_trg = it_zeledtl-TARGET_A * conv_sec.
it_output1-b_trg = it_zeledtl-target_B * conv_sec.
it_output1-g_trg = it_zeledtl-TARGET_G * conv_sec.
it_output1-p_trg = it_zeledtl-TARGET_P * conv_sec.
it_output1-M_trg = it_zeledtl-TARGET_M * conv_sec.
it_output1-t_trg = it_zeledtl-TARGET_T * conv_sec.
it_output1-i_trg = it_zeledtl-TARGET_I * conv_sec.
append it_output1.
endloop.
sort it_output1 ascending by subgid subopn srno1.
clear ch1.
loop at it_zrouteledtl.
move-corresponding it_zrouteledtl to it_output.
select single description from zpromast into it_output-desc
where subgid = it_zrouteledtl-subgid and
subopn = it_zrouteledtl-subopn and
werks in p_werks.
it_output-add_desc = it_zrouteledtl-description.
it_output-freq = it_zrouteledtl-frequency.
it_output-div_freq = it_zrouteledtl-div_freq.
it_output-men = it_zrouteledtl-men.
it_output-ct = it_zrouteledtl-cy_time * conv_sec.
it_output-cw = it_zrouteledtl-wc_time * conv_sec.
it_output-ideal_ct = it_zrouteledtl-cy_trg_time * conv_sec.
it_output-ideal_cw = it_zrouteledtl-wc_trg_time * conv_sec.
if it_zrouteledtl-offline1 = '1'.
it_output-offline = 'No'.
else.
it_output-offline = 'Yes'.
endif.
append it_output.
endloop.
loop at it_output.
if it_output-offline = 'Yes'.
ch1 = 0.
else.
ch1 = 1.
endif.
loop at it_output1 where subgid = it_output-subgid and
subopn = it_output-subopn.
a_trg = A_trg + it_output1-A_trg.
b_Trg = b_Trg + it_output1-b_Trg.
g_Trg = g_Trg + it_output1-g_Trg.
p_Trg = p_Trg + it_output1-p_Trg.
m_Trg = m_Trg + it_output1-m_Trg.
t_Trg = t_Trg + it_output1-t_Trg.
i_Trg = i_Trg + it_output1-i_Trg.
autocycle = autocycle + it_output1-Autocycle.
online_p_time = online_p_time + it_output1-online_p_time.
offline_p_time = offline_p_time + it_output1-offline_p_time.
endloop.
it_output-autocycle = ( autocycle * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-a_trg = ( a_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-b_trg = ( b_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-g_trg = ( g_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-p_trg = ( p_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-m_trg = ( m_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-t_trg = ( t_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-i_trg = ( i_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-online_time = ( it_output-ct - it_output-autocycle ) * ch1.
it_output-offline_time = ( it_output-ct - it_output-cw ) + it_output-autocycle.
it_output-online_p_time = ( online_p_time * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
it_output-offline_p_time = ( offline_p_time * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
clear : a_trg,b_trg,g_trg,p_trg,m_trg,t_trg,i_trg,online_p_time,offline_p_time,ch1,ch2,it_zeledtl,
autocycle,online_p_time,offline_p_time,zroutpromast.
modify it_output.
endloop.
ENDFORM. " data_retrieval
*& Form build_fieldcatalog
text
--> p1 text
<-- p2 text
FORM build_fieldcatalog .
Please not there are a number of differences between the structure of
ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
For example the field seltext_m is replace by scrtext_m in ALVtree.
DATA: COL_POS TYPE I VALUE 0.
fieldcatalog-fieldname = 'SRNO'.
fieldcatalog-SCRTEXT_L = 'Sr No.'.
fieldcatalog-SCRTEXT_m = 'Sr No.'.
fieldcatalog-SCRTEXT_s = 'Sr No.'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'SUBGID'. "Field name in itab
fieldcatalog-SCRTEXT_L = 'Sub Opn GID'. "Column text
fieldcatalog-SCRTEXT_m = 'Sub Opn GID'. "Column text
fieldcatalog-SCRTEXT_s = 'Sub Opn GID'. "Column text
fieldcatalog-col_pos = COL_POS. "Column position
fieldcatalog-outputlen = 15. "Column width
fieldcatalog-emphasize = 'X'. "Emphasize (X or SPACE)
fieldcatalog-key = 'X'. "Key Field? (X or SPACE)
fieldcatalog-do_sum = 'X'. "Sum Column?
fieldcatalog-no_zero = 'X'. "Don't display if zero
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'SUBOPN'.
fieldcatalog-SCRTEXT_L = 'Sub Opn'.
fieldcatalog-SCRTEXT_m = 'Sub Opn'.
fieldcatalog-SCRTEXT_s = 'Sub Opn'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-emphasize = 'X'. "Emphasize (X or SPACE)
fieldcatalog-key = 'X'. "Key Field? (X or SPACE)
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'MOVETYPE'.
fieldcatalog-SCRTEXT_L = 'Movetype'.
fieldcatalog-SCRTEXT_m = 'Movetype'.
fieldcatalog-SCRTEXT_s = 'Movetype'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'DESC'.
fieldcatalog-SCRTEXT_L = 'Description'.
fieldcatalog-SCRTEXT_m = 'Description'.
fieldcatalog-SCRTEXT_s = 'Description'.
fieldcatalog-outputlen = 600.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'ADD_DESC'.
fieldcatalog-SCRTEXT_L = 'Add. Description'.
fieldcatalog-SCRTEXT_m = 'Add. Description'.
fieldcatalog-SCRTEXT_s = 'Add. Description'.
fieldcatalog-outputlen = 100.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'FREQ'.
fieldcatalog-SCRTEXT_L = 'Frequency'.
fieldcatalog-SCRTEXT_m = 'Frequency'.
fieldcatalog-SCRTEXT_s = 'Frequency'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'DIV_FREQ'.
fieldcatalog-SCRTEXT_L = 'Div Freq'.
fieldcatalog-SCRTEXT_m = 'Div Freq'.
fieldcatalog-SCRTEXT_s = 'Div Freq'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'MEN'.
fieldcatalog-SCRTEXT_L = 'Men'.
fieldcatalog-SCRTEXT_m = 'Men'.
fieldcatalog-SCRTEXT_s = 'Men'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat..
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'BATCH'.
fieldcatalog-SCRTEXT_L = 'Batch/Div Freq'.
fieldcatalog-SCRTEXT_m = 'Batch/Div Freq'.
fieldcatalog-SCRTEXT_s = 'Batch/Div Freq'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'OFFLINE'.
fieldcatalog-SCRTEXT_L = 'Offline'.
fieldcatalog-SCRTEXT_m = 'Offline'.
fieldcatalog-SCRTEXT_s = 'Offline'.
fieldcatalog-outputlen = 6.
fieldcatalog-col_pos = COL_POS.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'CT'.
fieldcatalog-SCRTEXT_L = 'Cycle Time'.
fieldcatalog-SCRTEXT_m = 'Cycle Time'.
fieldcatalog-SCRTEXT_s = 'Cycle Time'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'CW'.
fieldcatalog-SCRTEXT_L = 'Work Content'.
fieldcatalog-SCRTEXT_m = 'Work Content'.
fieldcatalog-SCRTEXT_s = 'Work Content'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'IDEAL_CT'.
fieldcatalog-SCRTEXT_L = 'Ideal CT'.
fieldcatalog-SCRTEXT_m = 'Ideal CT'.
fieldcatalog-SCRTEXT_s = 'Ideal CT'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'IDEAL_CW'.
fieldcatalog-SCRTEXT_L = 'Ideal CW'.
fieldcatalog-SCRTEXT_m = 'Ideal CW'.
fieldcatalog-SCRTEXT_s = 'Ideal CW'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'A_TRG'.
fieldcatalog-SCRTEXT_L = 'Target A'.
fieldcatalog-SCRTEXT_m = 'Target A'.
fieldcatalog-SCRTEXT_s = 'Target A'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'B_TRG'.
fieldcatalog-SCRTEXT_L = 'Target B'.
fieldcatalog-SCRTEXT_m = 'Target B'.
fieldcatalog-SCRTEXT_s = 'Target B'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'G_TRG'.
fieldcatalog-SCRTEXT_L = 'Target G'.
fieldcatalog-SCRTEXT_m = 'Target G'.
fieldcatalog-SCRTEXT_s = 'Target G'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'P_TRG'.
fieldcatalog-SCRTEXT_L = 'Target P'.
fieldcatalog-SCRTEXT_m = 'Target P'.
fieldcatalog-SCRTEXT_s = 'Target P'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'M_TRG'.
fieldcatalog-SCRTEXT_L = 'Target M'.
fieldcatalog-SCRTEXT_m = 'Target M'.
fieldcatalog-SCRTEXT_s = 'Target M'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'T_TRG'.
fieldcatalog-SCRTEXT_L = 'Target T'.
fieldcatalog-SCRTEXT_m = 'Target T'.
fieldcatalog-SCRTEXT_s = 'Target T'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'I_TRG'.
fieldcatalog-SCRTEXT_L = 'Target I'.
fieldcatalog-SCRTEXT_m = 'Target I'.
fieldcatalog-SCRTEXT_s = 'Target I'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'AUTOCYCLE'.
fieldcatalog-SCRTEXT_L = 'AutoCycle'.
fieldcatalog-SCRTEXT_m = 'AutoCycle'.
fieldcatalog-SCRTEXT_s = 'AutoCycle'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'ONLINE_TIME'.
fieldcatalog-SCRTEXT_L = 'Online Time'.
fieldcatalog-SCRTEXT_m = 'Online Time'.
fieldcatalog-SCRTEXT_s = 'Online Time'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'OFFLINE_TIME'.
fieldcatalog-SCRTEXT_L = 'Offline Time'.
fieldcatalog-SCRTEXT_m = 'Offline Time'.
fieldcatalog-SCRTEXT_s = 'Offline Time'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'ONLINE_P_TIME'.
fieldcatalog-SCRTEXT_L = 'Online Process Time'.
fieldcatalog-SCRTEXT_m = 'Online Process Time'.
fieldcatalog-SCRTEXT_s = 'Online Process Time'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
COL_POS = COL_POS + 1.
fieldcatalog-fieldname = 'OFFLINE_P_TIME'.
fieldcatalog-SCRTEXT_L = 'Offline Process Time'.
fieldcatalog-SCRTEXT_m = 'Offline Process Time'.
fieldcatalog-SCRTEXT_s = 'Offline Process Time'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = COL_POS.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO gd_fieldcat.
CLEAR fieldcatalog.
ENDFORM. " build_fieldcatalog
*& Form build_layout
text
--> p1 text
<-- p2 text
FORM build_layout .
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
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 build_hierarchy_header
text
<--P_GD_HIERARCHY_HEADER text
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Drill Down For Detail'(022).
p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form build_report_title
text
-->P_GD_REPORT_TITLE text
-->P_GD_LOGO text
FORM build_report_title using
pt_report_title TYPE slis_t_listheader
pa_logo TYPE sdydo_value.
DATA: ls_line TYPE slis_listheader,
ld_date(10) TYPE c,
string1 type string,string2 type string.
List Heading Line(TYPE H)
concatenate 'Material: ' p_matnr-low into string1 separated by space.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-key = 'MOST Operation'.
concatenate p_gid-low p_opn-low into string2 separated by space.
ls_line-info = string2.
APPEND ls_line TO pt_report_title.
ls_line-typ = 'S'.
ls_line-key = 'Text'.
select single DESCRIPTION from zroutpromast into string1 where mop_gid = p_gid-low
and mop_opn = p_opn-low
and werks = p_werks-low.
ls_line-info = string1.
APPEND ls_line TO pt_report_title.
ls_line-typ = 'S'.
ls_line-key = 'Routing Counter:'.
ls_line-info = counter.
APPEND ls_line TO pt_report_title.
Status Line(TYPE S)
ld_date(2) = sy-datum+6(2).
ld_date+2(1) = '/'.
ld_date3(2) = sy-datum4(2).
ld_date+5(1) = '/'.
ld_date+6(4) = sy-datum(4).
ls_line-typ = 'S'.
ls_line-key = 'Date'.
ls_line-info = ld_date.
APPEND ls_line TO pt_report_title.
Action Line(TYPE A)
CLEAR ls_line.
ls_line-typ = 'A'.
CONCATENATE 'Report: ' sy-repid INTO ls_line-info SEPARATED BY space.
APPEND ls_line TO pt_report_title.
ENDFORM. " build_report_title
*& Form build_variant
text
--> p1 text
<-- p2 text
FORM build_variant .
gd_variant-report = sy-repid.
ENDFORM. " build_variant
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS1'.
SET TITLEBAR 'ZTITLE'.
IF gd_tree IS INITIAL.
Create ALVtree (must be performed within screen PBO module)
PERFORM create_alvtree_container.
PERFORM create_object_in_container.
PERFORM create_empty_alvtree_control.
perform change_toolbar.
PERFORM create_alvtree_hierarchy.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
when 'EXIT' or 'BACK' or 'CANC'.
call method gd_tree->free.
leave program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
clear ok_code.
call method cl_gui_cfw=>flush.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form create_alvtree_container
text
--> p1 text
<-- p2 text
FORM create_alvtree_container .
gd_tree_container_name = 'SCREEN_CONTAINER'.
create object gd_custom_container
exporting
container_name = gd_tree_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message x208(00) with 'ERROR'.
endif.
ENDFORM. " create_alvtree_container
*& Form create_object_in_container
text
--> p1 text
<-- p2 text
FORM create_object_in_container .
create object gd_tree
exporting
parent = gd_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = ''
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'.
endif.
ENDFORM. " create_object_in_container
*& Form create_empty_alvtree_control
text
--> p1 text
<-- p2 text
FORM create_empty_alvtree_control .
CLEAR: it_emptytab.
REFRESH: it_emptytab.
CALL METHOD gd_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = gd_hierarchy_header
it_list_commentary = gd_report_title
i_logo = gd_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = gd_variant
CHANGING
it_outtab = it_emptytab "Must be empty
it_fieldcatalog = gd_fieldcat.
ENDFORM. " create_empty_alvtree_control
*& Form create_alvtree_hierarchy
text
--> p1 text
<-- p2 text
FORM create_alvtree_hierarchy .
data: ls_sflight type sflight,
lt_sflight type sflight occurs 0.
data: ld_mop_gid_key type lvc_nkey,
ld_mop_opn_key type lvc_nkey.
loop at it_output.
perform add_ekko_node using it_output
changing ld_mop_gid_key.
loop at it_output1 where subgid eq it_output-subgid
and subopn eq it_output-subopn.
perform add_ekpo_line using it_output1
ld_mop_gid_key
changing ld_mop_opn_key.
endloop.
endloop.
calculate totals
call method gd_tree->update_calculations.
this method must be called to send the data to the frontend
call method gd_tree->frontend_update.
ENDFORM. " create_alvtree_hierarchy
*& Form add_ekko_node
text
-->P_IT_OUTPUT text
-->P_2478 text
<--P_LD_MOP_GID_KEY text
FORM add_ekko_node USING ps_output like it_output
VALUE(p_relate_key)
CHANGING p_node_key.
data: ld_node_text type lvc_value,
ls_sflight type sflight.
data : text128(128).
Set item-layout
concatenate ps_output-subgid ps_output-subopn into text128 separated by space.
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
ls_item_layout-style = cl_gui_column_tree=>style_default.
ld_node_text = text128.
append ls_item_layout to lt_item_layout.
Add node
call method gd_tree->add_node
exporting
i_relat_node_key = p_relate_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_node_text
is_outtab_line = ps_output
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
ENDFORM. " add_ekko_node
*& Form add_ekpo_line
text
-->P_IT_OUTPUT1 text
-->P_LD_MOP_GID_KEY text
<--P_LD_MOP_OPN_KEY text
FORM add_ekpo_line USING Ps_OUTPUT1 like it_output1
value(p_relate_key)
CHANGING p_node_key.
data: ld_node_text type lvc_value,
ls_sflight type sflight.
data : text128(128).
concatenate ps_output1-srno ps_output1-movetype into text128 separated by space.
Set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3P@'.
ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
ls_item_layout-style = cl_gui_column_tree=>style_default.
ld_node_text = text128.
append ls_item_layout to lt_item_layout.
Add node
call method gd_tree->add_node
exporting
i_relat_node_key = p_relate_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = ld_node_text
is_outtab_line = ps_output1
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
ENDFORM. " add_ekpo_line
*& Form change_toolbar
text
--> p1 text
<-- p2 text
FORM change_toolbar .
get toolbar control
call method gd_tree->get_toolbar_object
importing
er_toolbar = mr_toolbar.
check not mr_toolbar is initial.
add seperator to toolbar
call method mr_toolbar->add_button
exporting
fcode = ''
icon = ''
butn_type = cntb_btype_sep
text = ''
quickinfo = 'This is a Seperator'. "#EC NOTEXT
add Standard Button to toolbar (for Delete Subtree)
call method mr_toolbar->add_button
exporting
fcode = 'EXPORT' "Function code of button
icon = '@49@' "Icon ID (see )
butn_type = cntb_btype_button "Button type
text = '' "Button text
quickinfo = 'Download To Excel'. "Quick info text
add Dropdown Button to toolbar (for Insert Line)
call method mr_toolbar->add_button
exporting
fcode = 'INSERT_LC' "Function code of button
icon = '@17@' "Icon ID (see )
butn_type = cntb_btype_dropdown "Button type
text = '' "Button text
quickinfo = 'Insert Line'. "Quick info text
set event-handler for toolbar-control
data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
create object toolbar_event_receiver.
set handler toolbar_event_receiver->on_function_selected
for mr_toolbar.
set handler toolbar_event_receiver->on_toolbar_dropdown
for mr_toolbar.
ENDFORM. " change_toolbar
Edited by: Darshan Shah on Jan 2, 2008 1:31 PMGui patch was not available on my pc
-
How to set selected row on startup of an alv tree build with cl_salv_tree
HI,
I have a cl_salv_tree and want the tree structure to open a specific node when starting the report. My coding is something like that:
DATA: lr_selections TYPE REF TO cl_salv_selections_tree,
lr_nodes TYPE REF TO cl_salv_nodes,
lr_node TYPE REF TO cl_salv_node,
lv_node_index(12) TYPE c,
lt_nodes TYPE salv_t_nodes,
ls_nodes TYPE salv_s_nodes,
lr_item TYPE REF TO cl_salv_item.
lr_selections = lr_tree->get_selections( ).
lt_nodes = lr_selections->get_selected_nodes( ).
lr_item = lr_selections->get_selected_item( ).
IF lr_item IS NOT BOUND.
lr_nodes = lr_tree->get_nodes( ).
lr_node = lr_nodes->get_node( lv_node_index ). "lv_node_index is the index of the node i want to be open on startup
ls_nodes-key = lv_node_index.
ls_nodes-node = lr_node.
APPEND ls_nodes TO lt_nodes.
lr_selections->set_selected_nodes( lt_nodes ).
ELSE.
ls_nodes-node = lr_item->get_node( ).
ls_nodes-key = ls_nodes-node->get_key( ).
APPEND ls_nodes TO lt_nodes.
lr_selections->set_selected_nodes( lt_nodes ).
ENDIF.
This coding is also used, when the report is running and someone clicks an a row. So thats why I check if a item is marked
or the total row.
But the tree always starts without opening the node.
Do I use the right methods or am I totally wrong ????
Thx for your help in advance
dinodini
Edited by: dinodini on Nov 16, 2010 6:51 PMWhat you are looking for is the similar functionality which could be achieved by the method EXPAND_NODE of the ALV Tree created using CL_GUI_ALV_TREE. In SALV Tree, you can use the method EXPAND of the class CL_SALV_NODE to show all the subnodes of that node, not by using the SELECTION.
Once you add the Node using the method ADD_NODE, you should call the method EXPAND to expand that subtree.
lr_nodes = lr_tree->get_nodes( ).
lr_node = lr_nodes->ADD_NODE( ... )
lr_node->EXPAND( COMPLETE_SUBTREE = 'X' ).
Regards,
Naimesh Patel -
Dear All,
Do anybody know how to download data from ALV tree into local PC. For example transaction O3O_MT10. Can we download it?
Thanks
Regards
HadiThank a lot Rainer,
It's definitely answer the question. I think I learn something new in here.
Regards
Hadi -
Edit a field in ALV tree in a subscreen of a module pool
Hi
I want to make a field editable in the ALV tree based on some condtions in a subscreen of a module pool. I used the edit = 'X' field in the fieldcatalog still it is showing the field as display and not edit.
Please help me to get the field as editable and save it to the database table.
Please not this is ALV TREE
Regards,
MozilaHi Mayank,
Thanks for the reply
I am using oops method.
I tried making the field which is to be made editable as wa_fieldcatalog-edit = 'X'. But its not working. I didnt get you when you said edit in layout object.
I also went through the demo programs but these programs are not having editable fields.
My code is as follows:
IF tree4 IS INITIAL.
* create container for alv-tree
l_tree_container_name = 'TREE4'.
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 tree4
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 = 'X'
i_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.
* create hierarchy
CALL METHOD tree4->set_table_for_first_display
EXPORTING
is_layout = s_layo
CHANGING
it_sort = it_sort
it_outtab = it_final
it_fieldcatalog = it_fieldcat.
ELSE.
CALL METHOD tree4->refresh_table_display
EXPORTING
it_sort = it_sort
EXCEPTIONS
program_error = 1
failed = 2
cntl_system_error = 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.
endif.
Maybe you are looking for
-
I am extremely upset. I purchased my iPad in SA and now I am in Greece. I cannot download free apps as I get a message that the apps are not available in the SA store and only in US stores. When I change to the US store the same thing happens. What i
-
Can someone please tell me how to delete songs from my iphone. When I swipe the song the delete shows up but when I touch it a cloud with a red arrow pointing down appears, when I touch it a circle appears when I touch it the cloud comes back. they
-
How can I 'click' on a "latch" mechanical boolean in an event case?
Since I can't set true of false to the local variable of latch mechanical boolean, how can I click the boolean in an event case?
-
Cannot download or check for purchases from international location
In the past week or so I have been unable to purchase or download new content from the iTunes store. Specifically I have been trying to buy and download a TV show episode. When I click on "Buy Episode", nothing seems to happen. Similarly, clicking on
-
High # fetches for a select query
Following is the tkprof output. Can anybody tell why the fetches are too high and what should be done? Thanks. SELECT COUNT (*) FROM ACA_PI_ALLOC_CVE A WHERE A.PRGRM_INDEX = :B2 AND A.ALCTN_CODE = :B1 AND TRUNC (SYSDATE) BETWEEN TRUNC (A.FROM_DATE) A