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 or save alv into excel sheet.

0 Kudos

I want to download alv into excel sheet , as it is in alv with format used

1 ACCEPTED SOLUTION

Former Member
0 Kudos

For Download ,

simply use the FM SAP_CONVERT_TO_XLS_FORMAT FM ....This would do the trick for you.

Cheers,

Laveen

18 REPLIES 18

Former Member
0 Kudos

Yes you can download. On the tool bar you can find icon to download to local file. Select Excel format and download.

0 Kudos

I want it through coding , don't want to press button..............it should be done dynamically with the program execution.

Former Member
0 Kudos

Hi,

ALV has provided the Download option in the ALV application toolbar..you can use the download option to download the data to the excel sheet.

Former Member
0 Kudos

Hi,

Then use the Function Module "GUI_DOWNLOAD"

Former Member
0 Kudos

You can use GUI_DOWNLOAD .

Former Member
0 Kudos

Use the following FM

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
I_FILENAME = 'c:/arjun.xls'
* I_APPL_KEEP = ' '
TABLES
I_TAB_SAP_DATA = it_final
* CHANGING
* I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 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.

Regards,

Lalit Mohan Gupta.

0 Kudos

hello,

I want to save/download data (in alv format) not the internal table. (stress is on alv format like, addition done in alv or hierrical alv)

0 Kudos

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = P_FNAME

FILETYPE = 'ASC'

TABLES

DATA_TAB = IT_DWNLOAD

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

GUI_REFUSE_FILETRANSFER = 8

OTHERS = 9.

REFRESH IT_DWNLOAD. CLEAR IT_DWNLOAD.

CONCATENATE 'Material Number'

'Material Description'

'Mat Group'

'Plant'

'UOM'

'Stock in Transit'

'Stock Qty'

'Burd. std cost'

'Extended Cost'

'Transit Cost'

'Open PO Qty' INTO it_dwnload SEPARATED BY c_tab.

  • 'Storage Location' into it_dwnload separated by c_tab.

APPEND IT_DWNLOAD. CLEAR IT_DWNLOAD.

LOOP AT IT_EXCEL.

CONCATENATE it_excel-matnr

it_excel-maktx

it_excel-matkl

it_excel-bwkey

it_excel-meins

it_excel-lbkum

IT_EXCEL-TRAME "ASR#57408 MANASM 03/30/2009

it_excel-stprs

it_excel-salk3

IT_EXCEL-TRANS_COST "ASR#57408 MANASM 03/30/2009

it_excel-po_qty INTO it_dwnload SEPARATED BY c_tab.

  • it_excel-lgort into it_dwnload separated by c_tab.

APPEND it_dwnload. CLEAR it_dwnload.

0 Kudos

> IT_EXCEL-TRAME "ASR#57408 MANASM 03/30/2009

Who is "M. Manas" any why are you pasting his / her code here?

0 Kudos

done

0 Kudos

do it

0 Kudos

Hi

You Can try to use OLE2OBJECT. Hope this can suit your requirement

Regards,

Vaibhav

Former Member
0 Kudos

For Download ,

simply use the FM SAP_CONVERT_TO_XLS_FORMAT FM ....This would do the trick for you.

Cheers,

Laveen

Former Member
0 Kudos

Hi pav4464,

yes ,you can download a alv output into excel through report.Please see the below linkfor to display data in excel.i think this may be helpful.

Please ,Let me know if you have questions.

thank you,

Anupama.

.

Former Member
0 Kudos

This message was moderated.

tarangini_katta
Active Contributor
0 Kudos

Hi pavan,

This may be help you.

In the ALv output screen

on the top of the tollbar you can find list

click on list>click on export>click on spread sheet-->select the format you want to download.

Thanks,

Former Member
0 Kudos

Hi pav4464,

The data that u are displaying in ALV must be in some internal table.

Try adding the following code to your existing code.

declare following variables.

data : lv_filename type string,

lv_filepath type string,

lv_fullpath type string.

Add the following code to select the path where the user wants to save the excel sheet

the following method will take the path where the excel sheet is to be saved & the name of the excel sheet.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG

EXPORTING

WINDOW_TITLE = 'Select The Path Where Error File Should Be Saved'

DEFAULT_FILE_NAME = 'ExcelSheetName.xls'

CHANGING

FILENAME = lv_filename

PATH = lv_filepath

FULLPATH = lv_fullpath.

IF SY-SUBRC 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

The following function module will take the path as its input and save the contents of internal table in the form of excel sheet at the required place.

call function 'GUI_DOWNLOAD'

EXPORTING

filename = lv_fullpath

filetype = 'ASC'

append = 'X'

write_field_separator = 'X'

TABLES

data_tab = itab_name.

if sy-subrc 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

itab_name is the name of internal table where the content is saved.

Add it in ur existing code after collecting all the data in an internal table.

Regards,

Radhika

venkat_o
Active Contributor
0 Kudos

Hey dear,

Here is the report what u r expecting for. Just go throught the code and execute.

<pre> REPORT zvenkat_download_alvoutput.

DATA:

i_t001 TYPE t001 OCCURS 0,

pdf LIKE tline OCCURS 0.

DATA:

g_spool TYPE tsp01-rqident,

g_program TYPE sy-repid VALUE sy-repid.

TYPE-POOLS:slis.

DATA: w_print TYPE slis_print_alv,

w_print_ctrl TYPE alv_s_pctl.

PARAMETERS: p_file TYPE string.

INITIALIZATION.

p_file = 'C:\venkat.pdf'.

"START-OF-SELECTION.

START-OF-SELECTION.

SELECT * FROM t001 INTO TABLE i_t001 UP TO 100 ROWS.

w_print-print = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_program

i_structure_name = 'T001'

is_print = w_print

TABLES

t_outtab = i_t001.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

g_spool = sy-spono.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = g_spool

TABLES

pdf = pdf

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

OTHERS = 12.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = p_file

filetype = 'BIN'

TABLES

data_tab = pdf

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_program

i_structure_name = 'T001'

TABLES

t_outtab = i_t001. "is_print = w_print

ENDIF.

ENDIF.

ENDIF.</pre>

Thanks

Venkat.O