Problem in ALV Tree
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 PM
Gui patch was not available on my pc
Similar Messages
-
Hi,
i have copied SALV_DEMO_TREE_SIMPLE into an own report.
i use an simple itab and try to get an output, but i have an endless-loop.
Has anyone an idea which error i do?
Here my Report:
REPORT ZGRO_ABAP_OBJ_TREE.
CONSTANTS: GC_TRUE TYPE SAP_BOOL VALUE 'X'.
TYPE-POOLS: ICON.
TYPES: BEGIN OF TREE_ITAB,
MATNR LIKE MARA-MATNR,
WERKS LIKE MARC-WERKS,
MENGE LIKE MSEG-MENGE,
END OF TREE_ITAB.
DATA: ITAB TYPE TABLE OF TREE_ITAB.
DATA: WA_ITAB TYPE TREE_ITAB.
DATA: GR_TREE TYPE REF TO CL_SALV_TREE.
DATA: REPID type syrepid.
DATA: GR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: OK_CODE TYPE SYUCOMM.
START-OF-SELECTION.
REPID = SY-REPID.
END-OF-SELECTION.
PERFORM DISPLAY_TREE.
FORM EINLESEN_DATEN.
WA_ITAB-MATNR = '16186'. WA_ITAB-WERKS = '1000'. WA_ITAB-MENGE = 10. APPEND WA_ITAB TO ITAB.
WA_ITAB-MATNR = '16186'. WA_ITAB-WERKS = '2000'. WA_ITAB-MENGE = 11. APPEND WA_ITAB TO ITAB.
WA_ITAB-MATNR = '16185'. WA_ITAB-WERKS = '2000'. WA_ITAB-MENGE = 12. APPEND WA_ITAB TO ITAB.
WA_ITAB-MATNR = '16184'. WA_ITAB-WERKS = '3000'. WA_ITAB-MENGE = 13. APPEND WA_ITAB TO ITAB.
PERFORM HIERARCHIE_AUFBAUEN.
ENDFORM.
FORM DISPLAY_FULLSCREEN .
TRY.
CL_SALV_TREE=>FACTORY(
IMPORTING
R_SALV_TREE = GR_TREE
CHANGING
T_TABLE = ITAB ).
CATCH CX_SALV_NO_NEW_DATA_ALLOWED CX_SALV_ERROR.
EXIT.
ENDTRY.
PERFORM CREATE_TREE.
GR_TREE->SET_SCREEN_STATUS(
PFSTATUS = 'SALV_STANDARD'
REPORT = REPID
SET_FUNCTIONS = GR_TREE->C_FUNCTIONS_ALL ).
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TREE.
LR_COLUMNS = GR_TREE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
PERFORM SET_COLUMNS_TECHNICAL.
GR_TREE->DISPLAY( ).
ENDFORM.
FORM DISPLAY_TREE.
CALL SCREEN 100.
ENDFORM.
MODULE PBO OUTPUT.
PERFORM PBO.
ENDMODULE.
MODULE PAI INPUT.
PERFORM PAI.
ENDMODULE.
FORM PBO .
SET PF-STATUS 'MAIN100'.
IF GR_CONTAINER IS NOT BOUND.
IF CL_SALV_TREE=>IS_OFFLINE( ) EQ IF_SALV_C_BOOL_SAP=>FALSE.
CREATE OBJECT GR_CONTAINER
EXPORTING
CONTAINER_NAME = 'BOX'.
ENDIF.
TRY.
CL_SALV_TREE=>FACTORY(
EXPORTING
R_CONTAINER = GR_CONTAINER
IMPORTING
R_SALV_TREE = GR_TREE
CHANGING
T_TABLE = ITAB ).
CATCH CX_SALV_NO_NEW_DATA_ALLOWED CX_SALV_ERROR.
EXIT.
ENDTRY.
PERFORM CREATE_TREE.
DATA: LR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_TREE.
LR_FUNCTIONS = GR_TREE->GET_FUNCTIONS( ).
LR_FUNCTIONS->SET_ALL( GC_TRUE ).
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TREE.
LR_COLUMNS = GR_TREE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
PERFORM SET_COLUMNS_TECHNICAL.
GR_TREE->DISPLAY( ).
ENDIF.
ENDFORM.
FORM PAI .
CASE OK_CODE.
WHEN 'BACK' OR 'EXIT' OR 'QUIT'.
CLEAR OK_CODE.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDFORM.
FORM SET_COLUMNS_TECHNICAL.
DATA: LR_COLUMNS TYPE REF TO CL_SALV_COLUMNS,
LR_COLUMN TYPE REF TO CL_SALV_COLUMN.
LR_COLUMNS = GR_TREE->GET_COLUMNS( ).
LR_COLUMNS->SET_OPTIMIZE( ABAP_TRUE ).
TRY.
LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'MATNR' ).
LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).
LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'WERKS' ).
LR_COLUMN->SET_VISIBLE( ABAP_FALSE ).
LR_COLUMN ?= LR_COLUMNS->GET_COLUMN( 'MENGE' ).
LR_COLUMN->SET_TOOLTIP( 'Einsatzmenge' ).
CATCH CX_SALV_NOT_FOUND.
ENDTRY.
ENDFORM.
FORM CREATE_TREE .
PERFORM TREE_HEADER.
PERFORM EINLESEN_DATEN.
ENDFORM.
FORM TREE_HEADER.
DATA: SETTINGS TYPE REF TO CL_SALV_TREE_SETTINGS.
SETTINGS = GR_TREE->GET_TREE_SETTINGS( ).
SETTINGS->SET_HIERARCHY_HEADER( 'MaterialNr' ).
SETTINGS->SET_HIERARCHY_TOOLTIP( 'Materialnummer' ).
SETTINGS->SET_HIERARCHY_SIZE( 30 ).
DATA: TITLE TYPE SALV_DE_TREE_TEXT.
TITLE = SY-TITLE.
SETTINGS->SET_HEADER( TITLE ).
ENDFORM.
FORM HIERARCHIE_AUFBAUEN.
DATA: MATNR_KEY TYPE LVC_NKEY,
WERKS_KEY TYPE LVC_NKEY,
LAST_KEY TYPE LVC_NKEY.
LOOP AT ITAB INTO WA_ITAB.
ON CHANGE OF WA_ITAB-MATNR.
PERFORM ADD_MATNR_LINE USING WA_ITAB
CHANGING MATNR_KEY.
ENDON.
ON CHANGE OF WA_ITAB-WERKS.
PERFORM ADD_WERKS_LINE USING WA_ITAB
MATNR_KEY
CHANGING WERKS_KEY.
ENDON.
PERFORM ADD_LINE USING WA_ITAB
WERKS_KEY
CHANGING LAST_KEY.
ENDLOOP.
ENDFORM.
FORM ADD_MATNR_LINE USING P_LS_DATA TYPE TREE_ITAB
P_KEY
CHANGING P_L_CARRID_KEY.
DATA: NODES TYPE REF TO CL_SALV_NODES,
NODE TYPE REF TO CL_SALV_NODE,
ITEM TYPE REF TO CL_SALV_ITEM,
TEXT TYPE LVC_VALUE.
NODES = GR_TREE->GET_NODES( ).
TEXT = P_LS_DATA-MATNR.
TRY.
NODE = NODES->ADD_NODE( RELATED_NODE = P_KEY
DATA_ROW = P_LS_DATA
TEXT = TEXT
RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD ).
P_L_CARRID_KEY = NODE->GET_KEY( ).
CATCH CX_SALV_MSG.
ENDTRY.
ENDFORM.
FORM ADD_WERKS_LINE USING P_LS_DATA TYPE TREE_ITAB
P_L_CARRID_KEY
CHANGING P_L_CONNID_KEY.
DATA: NODES TYPE REF TO CL_SALV_NODES,
NODE TYPE REF TO CL_SALV_NODE,
TEXT TYPE LVC_VALUE.
NODES = GR_TREE->GET_NODES( ).
TEXT = P_LS_DATA-WERKS.
TRY.
NODE = NODES->ADD_NODE( RELATED_NODE = P_L_CARRID_KEY
DATA_ROW = P_LS_DATA
RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
TEXT = TEXT ).
P_L_CONNID_KEY = NODE->GET_KEY( ).
CATCH CX_SALV_MSG.
ENDTRY.
ENDFORM.
FORM ADD_LINE USING P_LS_DATA TYPE TREE_ITAB
P_L_CONNID_KEY
CHANGING P_L_LAST_KEY.
DATA: NODES TYPE REF TO CL_SALV_NODES,
NODE TYPE REF TO CL_SALV_NODE.
NODES = GR_TREE->GET_NODES( ).
TRY.
NODE = NODES->ADD_NODE( RELATED_NODE = P_L_CONNID_KEY
DATA_ROW = P_LS_DATA
RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD ).
P_L_LAST_KEY = NODE->GET_KEY( ).
CATCH CX_SALV_MSG.
ENDTRY.
ENDFORM.
In the routines ADD_MATNR_LINE, ADD_WERKS_LINE and ADD_LINE
are new records inserted in my itab, therefore i get an endless-lopp.
I don't know, why these insertations are made.
Has anyone an idea????
Thanks for help.
Regards, DieterHi Tamas,
i fill the itab very simple, but not in a loop (see apove).
The problem is that in the routine with i call in a loop, there must be an append
but i don't know why and i cannot see tzhe append.
FORM HIERARCHIE_AUFBAUEN.
DATA: MATNR_KEY TYPE LVC_NKEY,
WERKS_KEY TYPE LVC_NKEY,
LAST_KEY TYPE LVC_NKEY.
LOOP AT ITAB INTO WA_ITAB.
<b>ON CHANGE OF WA_ITAB-MATNR.
PERFORM ADD_MATNR_LINE USING WA_ITAB
CHANGING MATNR_KEY.
ENDON.</b>
ON CHANGE OF WA_ITAB-WERKS.
PERFORM ADD_WERKS_LINE USING WA_ITAB
MATNR_KEY
CHANGING WERKS_KEY.
ENDON.
PERFORM ADD_LINE USING WA_ITAB
WERKS_KEY
CHANGING LAST_KEY.
ENDLOOP.
ENDFORM.
FORM ADD_MATNR_LINE USING P_LS_DATA TYPE TREE_ITAB
P_KEY
CHANGING P_L_CARRID_KEY.
DATA: NODES TYPE REF TO CL_SALV_NODES,
NODE TYPE REF TO CL_SALV_NODE,
ITEM TYPE REF TO CL_SALV_ITEM,
TEXT TYPE LVC_VALUE.
NODES = GR_TREE->GET_NODES( ).
TEXT = P_LS_DATA-MATNR.
TRY.
<b>NODE = NODES->ADD_NODE( RELATED_NODE = P_KEY
DATA_ROW = P_LS_DATA
TEXT = TEXT
RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD ).</b>
P_L_CARRID_KEY = NODE->GET_KEY( ).
CATCH CX_SALV_MSG.
ENDTRY.
ENDFORM.
i the bold marked statements there is an appen, but i don't know why and where.
Regards, Dieter -
Displaying ALV tree in expanded form in first ouput
Hi all,
I have a problem with alv tree. My requirement is, on the first output itself the alv tree should appear expanded depending on one of the filter criteria in the tool bar. How can i trigger the toolbar event in PBO itself? Can it be done? if yes please provide sample code. Points assured for helpfull answers.
Thanks,
ShafiqHi Walter,
The method CL_GUI_ALV_TREE->EXPAND_NODES has only one importing parameter and that is the nodes of the ALV tree. But the commenting of the following lines from my code made it work which i have made it bold.Thank you very much for your help.I Have awarded points for you.
REPORT ztest_2105.
DATA: g_alv_tree TYPE REF TO cl_gui_alv_tree,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_sflight TYPE sflight OCCURS 0, "Output-Table
gt_fieldcatalog TYPE lvc_t_fcat,
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm, "OK-Code
g_max TYPE i VALUE 255. "maximum of db records to select
DATA : it_node_key TYPE lvc_t_nkey,
wa_node_key LIKE LINE OF it_node_key.
LOCAL CLASSES
*§1. Define a (local) class for event handling
CLASS lcl_tree_event_receiver DEFINITION.
PUBLIC SECTION.
*§2. Define an event handler method for each event you want to react to
METHODS handle_node_double_click
FOR EVENT node_double_click OF cl_gui_alv_tree
IMPORTING node_key sender.
'sender' is an implicit event parameter that is provided by
ABAP Objects runtime system. It contains a reference to the
object that fired the event. You may directly use it to
call methods of this instance.
ENDCLASS.
CLASS lcl_tree_event_receiver IMPLEMENTATION.
*§3. Implement your event handler methods.
METHOD handle_node_double_click.
DATA: lt_children TYPE lvc_t_nkey.
*first check if the node is a leaf, i.e. can not be expanded
CALL METHOD sender->get_children
EXPORTING i_node_key = node_key
IMPORTING et_children = lt_children.
IF NOT lt_children IS INITIAL.
CALL METHOD sender->expand_node
EXPORTING i_node_key = node_key
i_level_count = 2.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module PBO OUTPUT
process before output
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAINTITLE'.
IF g_alv_tree IS INITIAL.
PERFORM init_tree.
CALL METHOD g_alv_tree->expand_nodes
EXPORTING
it_node_key = it_node_key
EXCEPTIONS
FAILED = 1
CNTL_SYSTEM_ERROR = 2
ERROR_IN_NODE_KEY_TABLE = 3
DP_ERROR = 4
NODE_NOT_FOUND = 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.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Automation Queue failure'(801)
txt1 = 'Internal error:'(802)
txt2 = 'A method in the automation queue'(803)
txt3 = 'caused a failure.'(804).
ENDIF.
ENDIF.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
process after input
MODULE pai INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM exit_program.
WHEN OTHERS.
§5. Call dispatch to process toolbar functions
Toolbar events are registered in constructur method of
CL_ALV_TREE_BASE as application events. So the dispatch call
is a must if you want to use the standard toolbar.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " PAI INPUT
*& Form init_tree
text
--> p1 text
<-- p2 text
FORM init_tree.
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c.
l_tree_container_name = 'CCONTAINER1'.
CREATE OBJECT g_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.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'(100).
ENDIF.
create tree control
CREATE OBJECT g_alv_tree
EXPORTING
parent = g_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
DATA l_hierarchy_header TYPE treev_hhdr.
PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
Hide columns and sum up values initially using the fieldcatalog
PERFORM build_fieldcatalog.
IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
(even after this method call). You can change data of your table
by calling methods of CL_GUI_ALV_TREE.
Furthermore, the output table 'gt_outtab' must be global and can
only be used for one ALV Tree Control.
CALL METHOD g_alv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = l_hierarchy_header
CHANGING
it_fieldcatalog = gt_fieldcatalog
it_outtab = gt_sflight. "table must be empty!
PERFORM create_hierarchy.
PERFORM register_events.
Update calculations which were initially defined by field DO_SUM
of the fieldcatalog. (see build_fieldcatalog).
CALL METHOD g_alv_tree->update_calculations.
Send data to frontend.
CALL METHOD g_alv_tree->frontend_update.
ENDFORM. " init_tree
*& Form build_hierarchy_header
build hierarchy-header-information
-->P_L_HIERARCHY_HEADER strucxture for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Totals/Month/Carrier/Date'(300).
p_hierarchy_header-tooltip = 'Flights in a month'(400).
p_hierarchy_header-width = 35.
p_hierarchy_header-width_pix = ''.
ENDFORM. " build_hierarchy_header
*& Form exit_program
free object and leave program
FORM exit_program.
CALL METHOD g_custom_container->free.
LEAVE PROGRAM.
ENDFORM. " exit_program
FORM build_fieldcatalog.
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
The following function module generates a fieldcatalog according
to a given structure.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = gt_fieldcatalog.
Now change the fieldcatalog to hide fields and to determine
some initial calculations for chosen fields.
LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
CASE ls_fieldcatalog-fieldname.
hide columns which are already displayed in our tree
WHEN 'CARRID' OR 'FLDATE'.
ls_fieldcatalog-no_out = 'X'.
Do some initial calculations:
ALV Tree uses the field 'do_sum' to declare that a function
for the corresponding column shall be calculated.
Use 'h_ftype' to set the function type (MAX, MIN, SUM, AVG).
WHEN 'PRICE'.
ls_fieldcatalog-do_sum = 'X'.
ls_fieldcatalog-h_ftype = 'MAX'.
WHEN 'SEATSMAX'.
ls_fieldcatalog-do_sum = 'X'.
ls_fieldcatalog-h_ftype = 'SUM'.
WHEN 'SEATSOCC'.
ls_fieldcatalog-do_sum = 'X'.
ls_fieldcatalog-h_ftype = 'AVG'.
ENDCASE.
MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
ENDLOOP.
The fieldcatalog is provided in form 'init_tree' using method
set_table_for_first_display.
ENDFORM. " build_fieldcatalog
FORM register_events.
*§4. Event registration: tell ALV Tree which events shall be passed
from frontend to backend.
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event,
l_event_receiver TYPE REF TO lcl_tree_event_receiver.
*§4a. Frontend registration(i): get already registered tree events.
The following four tree events registers ALV Tree in the constructor
method itself.
- cl_gui_column_tree=>eventid_expand_no_children
(needed to load data to frontend when a user expands a node)
- cl_gui_column_tree=>eventid_header_context_men_req
(needed for header context menu)
- cl_gui_column_tree=>eventid_header_click
(allows selection of columns (only when item selection activated))
- cl_gui_column_tree=>eventid_item_keypress
(needed for F1-Help (only when item selection activated))
Nevertheless you have to provide their IDs again if you register
additional events with SET_REGISTERED_EVENTS (see below).
To do so, call first method GET_REGISTERED_EVENTS (this way,
all already registered events remain registered, even your own):
CALL METHOD g_alv_tree->get_registered_events
IMPORTING events = lt_events.
(If you do not these events will be deregistered!!!).
You do not have to register events of the toolbar again.
*§4b. Frontend registration(ii): add additional event ids
l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
APPEND l_event TO lt_events.
*§4c. Frontend registration(iii):provide new event table to alv tree
CALL METHOD g_alv_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'. "#EC NOTEXT
ENDIF.
*§4d. Register events on backend (ABAP Objects event handling)
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->handle_node_double_click FOR g_alv_tree
ENDFORM. " register_events
*& Form create_hierarchy
text
--> p1 text
<-- p2 text
FORM create_hierarchy.
See BCALV_TREE_01 for more comments on building the hierarchy
DATA: ls_sflight TYPE sflight,
lt_sflight TYPE sflight OCCURS 0,
l_yyyymm(6) TYPE c, "year and month of sflight-fldate
l_yyyymm_last(6) TYPE c,
l_carrid LIKE sflight-carrid,
l_carrid_last LIKE sflight-carrid.
DATA: l_month_key TYPE lvc_nkey,
l_carrid_key TYPE lvc_nkey,
l_last_key TYPE lvc_nkey,
l_top_key TYPE lvc_nkey.
Select data
SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.
sort table according to conceived hierarchy
SORT lt_sflight BY fldate0(6) carrid fldate6(2).
CLEAR : it_node_key, wa_node_key.
* wa_node_key = '&VIRTUALROOT'.
APPEND wa_node_key TO it_node_key.</b>
Define one top node. In this way it is possible to calculate
values for the whole hierarchy.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = ''
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = text-050
IMPORTING
e_new_node_key = l_top_key.
wa_node_key = l_top_key.
APPEND wa_node_key TO it_node_key.
LOOP AT lt_sflight INTO ls_sflight.
l_yyyymm = ls_sflight-fldate+0(6).
l_carrid = ls_sflight-carrid.
IF l_yyyymm <> l_yyyymm_last. "on change of l_yyyymm
l_yyyymm_last = l_yyyymm.
month nodes
PERFORM add_month USING l_yyyymm
l_top_key
CHANGING l_month_key.
clear l_carrid_last because this is a new month
CLEAR l_carrid_last.
wa_node_key = l_month_key.
APPEND wa_node_key TO it_node_key.
ENDIF.
Carrier nodes:
IF l_carrid <> l_carrid_last. "on change of l_carrid
l_carrid_last = l_carrid.
PERFORM add_carrid_line USING ls_sflight
l_month_key
CHANGING l_carrid_key.
wa_node_key = l_carrid_key.
APPEND wa_node_key TO it_node_key.
ENDIF.
Leaf:
PERFORM add_complete_line USING ls_sflight
l_carrid_key
CHANGING l_last_key.
* wa_node_key = l_last_key.
APPEND wa_node_key TO it_node_key.</b>
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form add_month
FORM add_month USING p_yyyymm TYPE c
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight,
l_month(15) TYPE c. "output string for month
get month name for node text
PERFORM get_month USING p_yyyymm
CHANGING l_month.
l_node_text = l_month.
add node
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_month
FORM add_carrid_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight.
add node
l_node_text = ps_sflight-carrid.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_carrid_line
*& Form add_complete_line
FORM add_complete_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value.
WRITE ps_sflight-fldate TO l_node_text MM/DD/YYYY.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ps_sflight
i_node_text = l_node_text
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_complete_line
*& Form GET_MONTH
text
-->P_P_YYYYMM text
<--P_L_MONTH text
FORM get_month USING p_yyyymm
CHANGING p_month.
DATA: l_monthdigits(2) TYPE c.
l_monthdigits = p_yyyymm+4(2).
CASE l_monthdigits.
WHEN '01'.
p_month = 'January'(701).
WHEN '02'.
p_month = 'February'(702).
WHEN '03'.
p_month = 'March'(703).
WHEN '04'.
p_month = 'April'(704).
WHEN '05'.
p_month = 'May'(705).
WHEN '06'.
p_month = 'June'(706).
WHEN '07'.
p_month = 'July'(707).
WHEN '08'.
p_month = 'August'(708).
WHEN '09'.
p_month = 'September'(709).
WHEN '10'.
p_month = 'October'(710).
WHEN '11'.
p_month = 'November'(711).
WHEN '12'.
p_month = 'December'(712).
ENDCASE.
CONCATENATE p_yyyymm+0(4) '->' p_month INTO p_month.
ENDFORM. " GET_MONTH -
ALV Tree Problem with Checkboxes
Hello,
i've got a problem.
I have an ALV-Tree and die ALV-Detaillist of the tree are type checkbox.
That's working correct.
But i want to fill initial data in the checkboxes but the checkbox isnt set.
i've done as followed:
CALL METHOD go_alv_tree->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
i_default = abap_false
is_hierarchy_header = ls_header
IS_EXCEPTION_FIELD =
IT_SPECIAL_GROUPS =
IT_LIST_COMMENTARY =
I_LOGO =
I_BACKGROUND_ID =
IT_TOOLBAR_EXCLUDING =
CHANGING
it_outtab = <go_data_tab>
IT_FILTER =
it_fieldcatalog = lt_fcat.
fieldcat are several fields all as checkbox.
Then i get a component of the output structure and set a X.
ASSIGN COMPONENT lv_help_arbpl OF STRUCTURE <go_data_struc>
TO <fs_arbl>.
IF <fs_arbl> IS ASSIGNED.
<fs_arbl> = lc_xfeld.
ENDIF.
CALL METHOD go_alv_tree->add_node
EXPORTING
i_relat_node_key = lv_matnr
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = <go_data_struc>
is_node_layout = ls_layout
IT_ITEM_LAYOUT =
i_node_text = lv_node_text
IMPORTING
e_new_node_key = lv_period
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
in <go_data_struc> the fields which should be set, are set with X.
But after i add all of my nodes and do CALL METHOD p_go_alv_tree->frontend_update, the checkbox is empty but there is an X in the field beside the checkbox.
Thanks in advance.
best regards,
DennisOk i solved the problem.
best regards,
Dennis -
ALV Tree - register event problem
Hi,
I'm trying to register standard events for ALV Tree. when perform register_events it raises exception 'illegal event combination'. does anybody know what is wrong it this code ?
***INCLUDE ZNT_SLORDERHIER_STATUS_0100O01 .
*& Module STATUS_0100 OUTPUT
* text
module STATUS_0100 output.
set pf-status 'MAIN100'.
if tree1 is initial.
perform f_init_tree.
endif.
call method cl_gui_cfw=>flush.
endmodule. " STATUS_0100 OUTPUT
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_expand_no_children.
append l_event to lt_events.
l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
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_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_item_double_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.
if sy-subrc <> 0.
call function 'POPUP_TO_DISPLAY_TEXT_LO'
exporting
titel = 'Error number:'
textline1 = sy-subrc
start_column = 1
start_row = 6. "#EC NOTEXT
endif.
endform. " register_events
form f_init_tree.
perform f_build_fieldcatalog.
* 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'.
if sy-batch is initial.
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.
if sy-subrc <> 0.
message x208(00) with 'ERROR'. "#EC NOTEXT
endif.
endif.
* create tree control
create object tree1
exporting
parent = l_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = space
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'. "#EC NOTEXT
endif.
* create Hierarchy-header
data l_hierarchy_header type treev_hhdr.
perform f_build_hierarchy_header changing l_hierarchy_header.
* create info-table for html-header
data: lt_list_commentary type slis_t_listheader,
l_logo type sdydo_value.
perform f_build_comment using
lt_list_commentary
l_logo.
* repid for saving variants
data: ls_variant type disvariant.
ls_variant-report = sy-repid.
CLEAR gt_sorder[].
* create emty tree-control
call method tree1->set_table_for_first_display
exporting
is_hierarchy_header = l_hierarchy_header
it_list_commentary = lt_list_commentary
i_logo = l_logo
i_background_id = 'ALV_BACKGROUND'
i_save = 'A'
is_variant = ls_variant
changing
it_outtab = gt_sorder "table must be emty !!
it_fieldcatalog = gt_fieldcatalog.
* create hierarchy
perform f_create_hierarchy.
perform register_events.
endform. " init_tree
form f_build_fieldcatalog.
DATA gs_fieldcat LIKE LINE OF gt_fieldcatalog.
* get fieldcatalog
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZVNT_SLALVTREE'
changing
ct_fieldcat = gt_fieldcatalog.
clear gs_fieldcat.
endform.
form f_build_hierarchy_header changing
p_hierarchy_header type treev_hhdr.
p_hierarchy_header-heading = 'Hierarchy Header'. "#EC NOTEXT
p_hierarchy_header-tooltip =
'This is the Hierarchy Header !'. "#EC NOTEXT
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ''.
endform.
form f_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: sales order-overview'. "#EC NOTEXT
append ls_line to pt_list_commentary.
* STATUS LINE: TYPE S
p_logo = 'ENJOYSAP_LOGO'.
endform. "build_comment
form f_create_hierarchy.
data: ls_sorder type ty_ZVNT_SLALVTREE,
lt_sorder type ty_ZVNT_SLALVTREE occurs 0.
* get data
select * from ZVNT_SLALVTREE into table lt_sorder up to 200 rows WHERE spras = sy-langu and matnr in s_matnr
and vbeln in s_vbeln.
sort lt_sorder by vbeln.
* add data to tree
data: l_vbeln_key type lvc_nkey,
l_posnr_key type lvc_nkey,
l_last_key type lvc_nkey.
loop at lt_sorder into ls_sorder.
on change of ls_sorder-vbeln.
perform f_add_vbeln_line using ls_sorder
changing l_vbeln_key.
endon.
on change of ls_sorder-posnr.
perform f_add_posnr_line using ls_sorder
l_vbeln_key
changing l_posnr_key.
endon.
perform f_add_complete_line using ls_sorder
l_posnr_key
changing l_last_key.
endloop.
* this method must be called to send the data to the frontend
call method tree1->frontend_update.
endform. " create_hierarchy
form f_add_vbeln_line using ps_sorder type ty_ZVNT_SLALVTREE
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value,
ls_sorder type ty_ZVNT_SLALVTREE.
* 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 = tree1->c_hierarchy_column_name.
ls_item_layout-style =
cl_gui_column_tree=>style_intensifd_critical.
append ls_item_layout to lt_item_layout.
* add node
l_node_text = ps_sorder-vbeln.
data: ls_node type lvc_s_layn.
ls_node-n_image = space.
ls_node-exp_image = space.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sorder
is_node_layout = ls_node
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
endform.
form f_add_posnr_line using ps_sorder type ty_ZVNT_SLALVTREE
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value,
ls_sorder type ty_ZVNT_SLALVTREE.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-t_image = '@3Y@'.
ls_item_layout-style =
cl_gui_column_tree=>style_intensified.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
append ls_item_layout to lt_item_layout.
* add node
l_node_text = ps_sorder-posnr.
data: relat type int4.
relat = cl_gui_column_tree=>relat_last_child.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = relat
i_node_text = l_node_text
is_outtab_line = ls_sorder
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
endform. " add_connid_line
form f_add_complete_line using ps_sorder type ty_ZVNT_SLALVTREE
p_relat_key type lvc_nkey
changing p_node_key type lvc_nkey.
data: l_node_text type lvc_value.
* set item-layout
data: lt_item_layout type lvc_t_layi,
ls_item_layout type lvc_s_layi.
ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
ls_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
ls_item_layout-editable = 'X'.
append ls_item_layout to lt_item_layout.
l_node_text = ps_sorder-posnr.
data: ls_node type lvc_s_layn.
ls_node-n_image = space.
ls_node-exp_image = space.
call method tree1->add_node
exporting
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ps_sorder
i_node_text = l_node_text
is_node_layout = ls_node
it_item_layout = lt_item_layout
importing
e_new_node_key = p_node_key.
endform. " add_complete_line
form exit_program.
call method tree1->free.
leave program.
endform.
Code Formatted by: Alvaro Tejada Galindo on Feb 14, 2008 9:54 AM
Edited by: Lukasz Sekowski on Feb 14, 2008 4:11 PMI've finally fixed the problem:
there was:
item_selection = space
and should be:
item_selection = 'X' -
Problem with same layout (variant) for two ALV Grid and ALV Tree
Hello!
I have two docking containers on the screen. On the left i have cl_gui_alv_tree, on the right cl_salv_table.
When a user set a default layout for ALV Grid (or ALV Tree), raport starts and sets this layout in both objects (tree and grid).
How to avoid this?Hi,
Take Two radio buttons.
First radion button display the two containers in grid format,
second radio button display the two containers in tree format base on user selection.
CREATE OBJECT G_DOCING_CONTAINER
EXPORTING PARENT = G_CUSTOM_CONTAINER."G_CONTAINER.
DISPLAY THE DATA IN GRID FORMATA
CREATE OBJECT r_grid
EXPORTING
i_parent = G_DOCING_CONTAINER
CALL METHOD g_docing_container->set_width
EXPORTING
width = 1300.
DISPLAY THE GRID DATA IN SECOND CONTAINER
CREATE OBJECT r_grid1
EXPORTING
i_parent = G_DOCING_CONTAINER
CALL METHOD g_docing_container->set_width
EXPORTING
width = 1300.
OTHERWISE WE CAN DISPLAY THE TWO CONTAINERS DATA IN A GRID FORMAT
CREATE OBJECT g_tree
EXPORTING
parent = g_docing_container"g_custom_container
IF R1 = 'X'. "FOR GRID DISPLAY
CALL METHOD r_grid1->set_table_for_first_display
CALL METHOD r_grid2->set_table_for_first_display
ELSE.
************TREE DISPLAY
ENDIF.
regards,
muralii -
ALV Tree and set_table_for_first_display problem
I am trying to create an alv tree. I have some sample code that uses the sflight table and this works fine however when i replace sflight with my internal structure and table it crashes at set_table_for_first_display with a "Field symbol has not been assigned" error.
This is part of the original code that works. *This isn't all the code just the relevant parts.
DATA: gt_sflight TYPE sflight OCCURS 0, " Output-Table
gt_fieldcatalog TYPE lvc_t_fcat, " Field Catalog
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.
SELECT * FROM sflight INTO TABLE gt_sflight.
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.
Here is the code when I replace gt_sflight with my internal table.
DATA: gt_detailed TYPE ZDT_REPORT1_DETAIL_STRUC occurs 0 , " Output-Table
gt_fieldcatalog TYPE lvc_t_fcat, " Field Catalog
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZDT_REPORT1_DETAIL_STRUC'
CHANGING
ct_fieldcat = gt_fieldcatalog
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
"* change fieldcatalog
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
CASE ls_fieldcatalog-fieldname.
WHEN 'COMP_DESC' OR 'SUBC_DESC'.
ls_fieldcatalog-no_out = 'X'.
ls_fieldcatalog-key = ''.
WHEN 'DOWNTIME'.
ls_fieldcatalog-do_sum = 'X'.
ENDCASE.
MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
ENDLOOP.
" Select statement to fill gt_detailed
* 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_detailed
it_fieldcatalog = gt_fieldcatalog.
When it runs like this it crashes at set_table_for_first_displayThe code I am using as an example is BCALV_TREE_SIMPLE_DEMO. If I have no data in my table it doesn't error when I call set_table_for_first_display.
But it looks like I might have to use that one instead because from what I understand you can use cl_gui_alv_tree_simple when the input table has all the required columns such as sflight but you use cl_gui_alv_tree when you need an internal table. -
Hi all,
Please help,
I have created ALV tree, with the help of standard program bcalv_tree_01. now i want to create it interative like DOUBLE CLICK on any ITEM or NODE. so i have define class and implement it with two method for event NODE_DOUBLE_CLICK and ITEM_DOUBLE_CLICK. and i have register it. when i display the tree it doesn't expand, but i comments the CALL METHOD gd_tree->set_registered_events it works fine. should i have to implement the event EXPAND_NO_CHILDREN also?
and what should be the code, becoz i am new in alv tree and oops. for sytex please refer BCALV_TREE_01.
please help as soon as possible.
Thanks in advance.Hi!
Ya you have to code for the method EXPAND_NO_CHILDREN
Where you will be defining the childs to the particular node.
the better example for it you can refer to SAPSIMPLE_TREE_CONTROL_DEMO
where
HANDLE_EXPAND_NO_CHILDREN method implemented shows the childs added and METHOD HANDLE_NODE_DOUBLE_CLICK
implemented to handle the doulbe click.
Regards. -
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> -
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 -
Double Click in ALV TREE doesn't get triggered
Hello All,
Double click event on item in a alv tree report doesn't get triggered. I thought I was doing everything right. Please help me out.
Look at the code below and tell me what else I need to do.
<b>FORM register_events .
Event registration: tell ALV Tree which events shall be passed
from frontend to backend.
DATA: lt_events TYPE cntl_simple_events,
l_event TYPE cntl_simple_event,
l_event_receiver TYPE REF TO lcl_tree_event_receiver.
Frontend registration: get already registered tree events
CALL METHOD g_alv_tree->get_registered_events
IMPORTING
events = lt_events.
Frontend registration: add additional event ids
l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
APPEND l_event TO lt_events.
Frontend registration: provide new event table to alv tree
CALL METHOD g_alv_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'. "#EC NOTEXT
ENDIF.
Register events on backend (ABAP Objects event handling)
CREATE OBJECT l_event_receiver.
SET HANDLER l_event_receiver->node_double_click FOR g_alv_tree.
SET HANDLER l_event_receiver->item_double_click FOR g_alv_tree.
SET HANDLER l_event_receiver->on_function_selected FOR g_toolbar.
ENDFORM. " register_events</b>
When I double click on item on the report double click event doesnt trigger. what could be the problem? Any sample programs?
Thanks,
ChandniHi,
Here is a sample code for you.
report ztree.
TABLES : vbak.
DATA: BEGIN OF mylist OCCURS 50. " Internal table hierarchy
INCLUDE STRUCTURE snodetext.
DATA: END OF mylist.
DATA: f15 TYPE c.
DATA :
BEGIN OF gt_sales OCCURS 0,
vbeln LIKE vbak-vbeln,
kunnr LIKE vbak-kunnr,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF gt_sales.
SELECT-OPTIONS : s_vbeln FOR vbak-vbeln.
START-OF-SELECTION.
SET PF-STATUS 'ZTREE1'.
SET TITLEBAR 'T1'.
Fill internal table with pseudo-data
PERFORM fill_itab.
Hierarchy output
PERFORM main.
*& Form FILL_ITAB
text
--> p1 text
<-- p2 text
FORM fill_itab .
*Fill the gt_sales table
SELECT vkvbeln vkkunnr vpmatnr vparktx INTO CORRESPONDING FIELDS OF
TABLE gt_sales
FROM ( vbak AS vk INNER JOIN vbap AS vp ON vkvbeln = vpvbeln )
WHERE vk~vbeln IN s_vbeln.
SORT gt_sales BY vbeln kunnr.
*Fill the root
mylist-name = 'Report Tree List'.
mylist-color = 1.
mylist-intensiv = '1'.
mylist-text = 'Report Tree List'.
mylist-tlength = 16.
mylist-tlevel = 1.
mylist-tcolor = 1.
mylist-tintensiv = '1'.
mylist-text1 = 'using "RS_TREE_CONSTRUCT" function'.
mylist-tlength1 = 50.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
LOOP AT gt_sales.
ON CHANGE OF gt_sales-vbeln.
mylist-name = 'level1'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = 'Sales Document no:'.
mylist-tlength = 20.
mylist-tlevel = 2.
mylist-tcolor = 7.
mylist-tintensiv = '1'.
mylist-text1 = gt_sales-vbeln.
mylist-tlength1 = 30.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDON.
ON CHANGE OF gt_sales-kunnr.
mylist-name = 'level2'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = 'Customer no:'.
mylist-tlength = 20.
mylist-tlevel = 3.
mylist-tcolor = 5.
mylist-tintensiv = '1'.
mylist-text1 = gt_sales-kunnr.
mylist-tlength1 = 30.
mylist-tcolor1 = 3.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDON.
mylist-name = 'level3'.
mylist-color = 0.
mylist-intensiv = '0'.
mylist-text = gt_sales-matnr.
mylist-tlength = 15.
mylist-tlevel = 4.
mylist-tcolor = 4.
mylist-tintensiv = '0'.
mylist-text1 = gt_sales-arktx.
mylist-tlength1 = 30.
mylist-tcolor1 = 2.
mylist-tintensiv1 = '0'.
APPEND mylist.
ENDLOOP.
ENDFORM. " FILL_ITAB
*& Form MAIN
text
--> p1 text
<-- p2 text
FORM main .
PERFORM hierarchy. " construct & draw the tree
ENDFORM. " MAIN
*& Form HIERARCHY
text
--> p1 text
<-- p2 text
FORM hierarchy .
PERFORM build_tree.
PERFORM draw_tree.
ENDFORM. " HIERARCHY
FORM BUILD_TREE *
Builds the tree from internal table *
Uses the Function module RS_TREE_CONSTRUCT *
FORM build_tree.
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = mylist
EXCEPTIONS
tree_failure = 1.
ENDFORM. "build_tree
FORM DRAW_TREE *
Builds the tree from internal table *
Uses the Function module RS_TREE_DISPLAY *
FORM draw_tree.
sy-lsind = 0.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = 'ZREPORT_TREE'
callback_user_command = 'NODE_SELECT'
IMPORTING
f15 = f15.
ENDFORM. "draw_tree
FORM NODE_SELECT *
Handles selection of nodes *
FORM node_select TABLES knoten STRUCTURE seucomm
USING command
CHANGING exit
list_refresh.
Processing of commands for hierarchy list
CASE command.
WHEN 'DISP'.
CASE knoten-id.
WHEN '000002'.
*Display Sales Order
SET PARAMETER ID 'AUN' FIELD knoten-text1.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
WHEN '000003'.
*Display Customer
SET PARAMETER ID 'KUN' FIELD knoten-text1.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
list_refresh = 'X'.
ENDFORM. "node_select -
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. -
Hello ABAP Experts.
I am trying to learn OO ABAP although have been using procedural ABAP for many years and I am writing an ALV Tree (which is also a first).
My problem is:
I have written a standard report which has a screen (which contains my ALV Tree) and a subscreen which has a single field which should get populated on double clicking on the node of the tree.
I have written a single class which contains all the logic to build up my ALV Tree and have instantiated this in the PBO of my first screen, in the class I have also set up an event that captures the double clicking of a node, all this seems to work fine.
The ALV Tree is displayed properly first time round and I can double click the node but I'm expecting (probably wrongly) that control is then passed from the class back to my report where I can manipulate the return, in debug after the double click indeed it does return to my calling program (flow logic of the first screen) however on clicking F5 on the debug, the screen is just redisplayed again and my field is still unpopulated but I need it to go into the PBO of my subscreen to display the data but I just can't seem to make this happen, I have also called the subscreen from within my main screen.
I have looked around SDN and although people have had similar problems I can't find a reply that works.
Thanks in advance.data:
ls_events type cntl_simple_event,
lt_events type cntl_simple_events.
DOUBLE_CLICK
clear ls_events.
ls_events-eventid = event_double_click.
ls_events-appl_event = 'X'.
insert ls_events into table lt_events.
call method ir_lb->set_registered_events
exporting
events = lt_events.
If you use pass APPL_EVENT = 'X' then it becomes an application event so PBO and PAI would be called. -
Printing format control in ALV TREE
Hello there,
I searched all over SDN but I couldn't find a solution for my problem ! It would be nice of you if you can help me sort it out.
I'm using an ALV TREE :
DATA: gv_tree TYPE REF TO cl_gui_alv_tree
CALL METHOD gv_tree->set_table_for_first_display
EXPORTING
is_hierarchy_header = gv_hierarchy_header
it_list_commentary = gv_report_title
i_save = 'A'
is_variant = gv_variant
CHANGING
it_outtab = gt_output_empty "Must be empty
it_fieldcatalog = gt_fieldcat.
I need to change printing format from X_65_255 to X_44_120.
In this method, there is no IS_PRINT to insert the new format (it exists only for GRID).
Do you have any idea?I could not find a way to do it in CL_GUI_ALV_TREE but you can use CL_GUI_ALV_GRID and the same method SET_TABLE_FOR_FIRST_DISPLAY in this class you can pass the print parameters to IS_PRINT (the component is PRINT_CTRL).
Revert back if it works.
Regards,
Felipe Simionatto
Edited by: fsimionatto on Sep 9, 2010 4:13 PM -
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....
Maybe you are looking for
-
When creating a many-to-many view link based on a many-to-many association, the view object on the left must be based on the entity that was on the left when creating the association. Why is this? Surely it shouldn't matter.
-
Open Mac garageband files on an iPad
I have a friend who owns an iPad. I use a MacBook Pro. When I give him my Garageband file ihe can't open it on the iPad. What's up? I gotta believe all Garagebands can share files, right? They're the same program.
-
Can window and aggregate SQL functions be used in Pro*C embedded SQL?
It appears that window functions such as dense_rank() over(partition by ... order by ...) can not be used in Pro*C embedded SQL? Can somebody confirm that that is really the case? Thanks Rawender Guron
-
When adjusting the audio volume in a selected region, why does it give me a curved line as a transition instead of straight, and why cant I change the fade shape like i can with a fade in our out? When I slide thet volume all the way down it makes a
-
I have a new laptop. I logged into my Adobe account and obtained the serial number for CS3. I also downloaded the applications. When starting Dreamweaver, it asks for the serial number, but when entered, does not recognize the number as a valid ser