Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Download Alv into excel sheet according to variant fields

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

use your own excel button and program this steps:

* Get the frontend fieldcatalog
CALL METHOD go_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fieldcat.
DELETE lt_fieldcat WHERE no_out EQ 'X'.

*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

2 REPLIES 2

derrick_hurley
Employee
Employee
0 Kudos

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

Former Member
0 Kudos

use your own excel button and program this steps:

* Get the frontend fieldcatalog
CALL METHOD go_grid->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fieldcat.
DELETE lt_fieldcat WHERE no_out EQ 'X'.

*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