on 03-23-2014 10:55 AM
Hai all,
I am working in abap webdynpro , iwant to trigger standard export to excel function of ALV in my program. please help me.
Hello Joince,
Please check below thread and link.
Providing Standard ALV Functions - Web Dynpro for ABAP - SAP Library
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai jithendra,
Yes there is standard button in tool bar. But clients requirement is different. They want a button below ALV display. And clicking on that button it should trigger the standard tool bar function. They dont want that standard button in ALV but want the features in another button designed by me.
Hi Joince,
I don't think you can have the standard alv export to excel functionality, outside the alv toolbar. If you need to have out side alv toolbar, you need to convert alv data to excel of your own.
I suggest you, to create an alv tool bar button by using class CL_SALV_WD_FE_BUTTON and you can set the standard function EXPORT TO EXCEL to this button and you can set the text as your requirement for this button.
Sample:
data lo_btn type ref to cl_salv_wd_fe_button.
data lo_func type ref to cl_salv_wd_function.
create object lo_btn.
lo_btn->set_text( value = 'Export to Excel' ). "set text as per req
lo_func = lo_model->if_salv_wd_function~create_function( id = 'EXPORT' ).
lo_func->set_function_std( if_salv_wd_c_std_funcitons=>export_excel ).
lo_func->set_editor( lo_btn ).
"To hide standard EXPORT TO EXCEL button
data lo_std_func type ref to cl_salv_wd_function_std.
lo_std_func = lo_model->if_salv_wd_function_settings~get_function_std( id =
if_salv_wd_c_std_functions=>export_excel ).
lo_std_func->set_visible( value = '01').
Hope this helps you.
Regards,
Rama
Hi Joince,
Here lo_model is of type CL_SALV_WD_CONFIG_TABLE and it is used to make the settings of alv table.
Let us say you have created a component usage MY_ALV using component SALV_WD_TABLE
Then to get reference of configuration of alv table proceed as below
data lo_comp_interface type ref to if_wd_component_usage.
data lo_model type ref to cl_salv_wd_config_table.
lo_comp_interface = wd_this->wd_cpuse_MY_ALV( ).
if lo_comp_interface->has_active_component( ) eq abap_false.
lo_comp_interface->create_component( ).
endif.
data lo_interface type ref to iwci_salv_wd_table.
lo_interface = wd_this->wd_cpifc_MY_ALV( ).
lo_model = lo_interface->get_model( ).
Hope this helps you.
Regards,
Rama
Hai Rama ,
Its working fine for me. But user came with a new requirement. They want to save the excel file into desk top not into downloads folder. Can we set the path when calling standard function. They also want to change the name of the downloading excel into some other name rather than 'export', when it is downloaded ..
Hope you can help me.
Thanks in advance.
Joince Mathew.
Hi Joince,
The export to excel file detects the default dowload location set on the browser of user's system and dowloads into the path accordingly.
If your user wants to save the file on to DESKTOP, he can do by changing the download path of his/her browser
Please refer the below links to change the download path of browser
How To Change The File Download Location In Internet Explorer 9 |
Google Chrome: Change the Default Download Location
To change file name of export:
I think we dont have a standard method to change the filename of the dowload while exporting alv data into excel.
The default filename is populated from the method GET_DEFAULT_FILENAME of class CL_SALV_BS_A_EXPORT_BASE.
Only thing is you can enhance the standard class and set the file name as per your requirement.
Otherwise,
go for your own code for dowloading alv data into excel.
Please refer the below link
Hope this helps you.
Regards,
Rama
Hai rama,
I tried that method by chris paine earlier, But it shows an error " You can only create an instance of the class "CL_SALV_WD_C_TABLE" within the class itself or within one of its subclasses" .How to solve it, I am a fresher and have only little experience on webdynpro. please help me.
regards,
Joince Mathew
Hi Joince,
The class CL_SALV_WD_C_TABLE is protected for instantiation and hence you will not be allowed to create an instance outside the class. But you can create an instance in a sub class of this.
I suggest you to create a class ZCL_TEST and go to properties and add the class CL_SALV_WD_C_TABLE as super class and now you can create an instance this class inside any method of your class ZCL_TEST.
You can call the method your class inside WD component.
Hope this helps you.
Regards,
Rama
Hai Rama,
I have a doubt, whether we can pass the attributes like file name ,when we call the standard function.
I found this code from standard function export_excel.
method if_salv_wd_comp_table_events~on_export_excel.
data:
l_version type string,
l_xml_content type xstring,
l_mimetype type string,
l_filename type string,
ls_msg type symsg,
lt_msg type if_salv_bs_tt=>yt_msg.
"get component
data:
lr_component type ref to if_salv_wd_component_table.
lr_component ?= me->if_salv_wd_view~r_component.
"get Configuration Model
data:
lr_model type ref to cl_salv_wd_config_table.
lr_model ?= lr_component->r_model_controller->r_model.
data:
lr_message_manager type ref to if_wd_message_manager.
lr_message_manager = me->if_salv_wd_view~r_view->if_wd_controller~get_message_manager( ).
data:
l_enable_choice_export type abap_bool,
l_enable_lean_export type abap_bool.
* l_lean_export_format type if_salv_bs_lex_format=>ys_format.
l_enable_choice_export = cl_salv_wd_params=>get_parameter(
cl_salv_wd_params=>c_flag-enable_choice_export ).
l_enable_lean_export = cl_salv_wd_params=>get_parameter(
cl_salv_wd_params=>c_flag-use_lean_export ).
" ALV Lean Export
if l_enable_lean_export eq abap_true.
data l_lean_export_format type if_salv_bs_lex_format=>ys_format.
l_lean_export_format = cl_salv_wd_params=>get_parameter(
cl_salv_wd_params=>c_lean_export_format_switch-name ).
data: ls_error type cl_salv_bs_lex_support=>ys_export_error,
lt_errors type cl_salv_bs_lex_support=>yt_export_error.
cl_salv_bs_lex=>export_from_result_data_table(
exporting
is_format = l_lean_export_format
ir_result_data_table = lr_component->r_result_data
importing
er_result_file = l_xml_content
et_export_errors = lt_errors
es_filename = l_filename
es_mimetype = l_mimetype
).
please reply
regards,
Joince
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.