cancel
Showing results for 
Search instead for 
Did you mean: 

how to export only selected columns of WD ALV to excel

Former Member
0 Kudos

Hi,

I have WD ALV report with EXPORT button (since standard button was not working properly i just hide that and added custom one) & standard dropdown to choose layout. Out of 20 columns user may choose n number of columns, the same number of columns i need to transfer to xls. How to export only selected columns to xls. Any method or FM to filter number of columns being transfer to xls. please advise

Rgds

sudhanshu

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

does the user selecs teh SETTINGS->HIDE column options tp hide the columns...

If yes,then you can see only the current columns and when you write the export functionality you need to get these columns..and convert it to xml format and then export to excel..

usually there are GET_COLUMNS method of if_salv_wd-column_settings for that alv..

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Can you please tell me where exactly I can have this method?

Rgds

Sudhanshu

Former Member
0 Kudos

Also, how do we pass these selected columns to our custom method

Former Member
0 Kudos

HI,

We have SETTINGS options for ALV right where we can hide/unhide teh columns right..

In the cl_salv_wd_config_table(alv instance)->if_salv_wd_column_settings we can get that method.

It may require some R&D to achieve the same.

I guess some where in the forum the same question was asked..

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Where exactly we are (or going to be) using this reference i.e., CL_SALV_WD_CONFIG_TABLE. Im passing contents, filename & MIME type as:

call function 'SCMS_STRING_TO_XSTRING'

exporting

TEXT = TEXT

importing

BUFFER = XTEXT.

WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(

**path to the word file

I_FILENAME = 'WDP.xls'

  • String Variable

I_CONTENT = XTEXT

  • File Type

I_MIME_TYPE = 'EXCEL' ).

In CL_SALV_WD_CONFIG_TABLE we have few methods related to column settings however not sure where exactly we will be using this class reference. can you please give some idea so that i can do some r&d in that.

Rgds

Sudhanshu

Former Member
0 Kudos

DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings, 
lr_input_field TYPE REF TO cl_salv_wd_uie_input_field. 
lr_column_settings ?= l_value. 
lr_column = lr_column_settings->get_column( 'PRICE' ). 

u r getting the column "PRICE"

regards,

amit

Former Member
0 Kudos

Hi,

That is fine but the issue is: at run time how do we know which column user has been added and which he been removed (by using diffrent layouts). Infact each layout will be having diffrent set of fields, now how can we pass only those fields to xls. for e.g., user can set a diffrent layout in WD output where only PRICE field is being displayed. now i need to send only PRICE field to xls. In case of standard "export to excel" button it worked fine but in case of custom button how do we get this functionality.

Hope you understand the issue.

Rgds

sudhanshu

Former Member
0 Kudos

Hi,

While debugging the SALV_WD_LAYOUT_UI (part of component SALV_WD_TABLE) component it is generating the list of selected fields need to be displaye in the WD output via. method UPDATE_ACTIVE_TAB. Inside this method internal table lt_slelected is having fields excluding the those i have hide via. settings. Now the issue is: how to make this internal table visible to our custom method (ONACTIONEXPORTTOEXCEL). Is there any way to do so. please let me know if any.

Rgds

sudhanshu