04-05-2011 10:54 AM
Hi All,
I have more than 100 fields in the ALV report, now i want to download the report according to the fields are choosen in the variant. I am getting all the fields in excel sheet but i need some fileds that is selected in the variant.
Thanks in advance.
Rudhir
04-05-2011 6:39 PM
use your own excel button and program this steps:
1°
* Get the frontend fieldcatalog
CALL METHOD go_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fieldcat.
DELETE lt_fieldcat WHERE no_out EQ 'X'.
2°
*create dynamic table with the frontend fieldcatalog
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcat
IMPORTING
ep_table = lt_data
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc EQ 0.
ASSIGN lt_data->* TO <lt_table>.
ENDIF.
3° Fill the dynamic table
4° export to excel using
CALL FUNCTION 'XXL_SIMPLE_API'
TABLES
col_text = xmplt_v1
data = <lt_table>
online_text = xmplt_o1
print_text = xmplt_p1
EXCEPTIONS
dim_mismatch_data = 1
file_open_error =2
file_write_error = 3
inv_winsys =4
inv_xxl =5
OTHERS = 6.
Check the complete example here
04-05-2011 5:38 PM
Hi Rudhir,
You could try printing the resulting list (based on your variant) to a text only list (in spooler). Save to file and open in Excel etc.
I hope this helps.
Best of luck,
Derrick
04-05-2011 6:39 PM
use your own excel button and program this steps:
1°
* Get the frontend fieldcatalog
CALL METHOD go_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fieldcat.
DELETE lt_fieldcat WHERE no_out EQ 'X'.
2°
*create dynamic table with the frontend fieldcatalog
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcat
IMPORTING
ep_table = lt_data
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc EQ 0.
ASSIGN lt_data->* TO <lt_table>.
ENDIF.
3° Fill the dynamic table
4° export to excel using
CALL FUNCTION 'XXL_SIMPLE_API'
TABLES
col_text = xmplt_v1
data = <lt_table>
online_text = xmplt_o1
print_text = xmplt_p1
EXCEPTIONS
dim_mismatch_data = 1
file_open_error =2
file_write_error = 3
inv_winsys =4
inv_xxl =5
OTHERS = 6.
Check the complete example here