Application Development and Automation 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: 
Read only

Issue in downloading

Former Member
0 Likes
641

Hi All,

We have a requirement of downloadind a report output into excel file.Any pointers regarding thi ih highly appreciated.

It's very urgent.

Regards,

Rajashree.

Hi All,

We have a requirement of downloadind a report output into excel file.Any pointers regarding thi ih highly appreciated.

It's very urgent.

Regards,

Rajashree.

5 REPLIES 5
Read only

Former Member
0 Likes
608

Hi,

Just USE GUI_DOWNLOAD fun module

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = <fullpath>

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = <your internal table>

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.

regards,

ANJI

Message was edited by:

Anji Reddy Vangala

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
608

Hi,

U can use the utility given by SAP.

after displaying the output goto

system->list>save-->localfile.

In this u will have an option of excel also...

or

u can store the displayed data in an internal table and by creating a button on the application tool bar.

u can use the help of coding to download the data in to an excel sheet by using the GUI_DOWNLOAD F.M

Cheers,

Simha.

Reward all the helpful answers,,,

Read only

alex_m
Active Contributor
0 Likes
608

Use FM 'GUI_DOWNLOAD'.

Read only

Former Member
0 Likes
608

Hi,

Check the following link:

http://www.sapbrain.com

Regards,

Bhaskar

Read only

Former Member
0 Likes
608

====here gives you a sapmle code(from internet) hope helps

*parameters: p_fname like rlgrap-filename

  • default 'C: est.xls'.

*

*data: fname like p_fname,

  • kn like sy-repid.

*data: cnt type i value 0.

*data: sheetname(10) value 'TEST ',

  • c_row type i,

  • scnt type i,

  • val(20),

  • wb(2).

*

*parameters: p_exvis as checkbox default 'X',

  • p_workbk(2) type p default '01',

  • p_wsheet(2) type p default '01'.

*

*constants: ok type i value 0.

*include ole2incl.

*data: excel type ole2_object,

  • workbook type ole2_object,

  • sheet type ole2_object,

  • cell type ole2_object,

  • cell1 type ole2_object,

  • column type ole2_object,

  • range type ole2_object,

  • borders type ole2_object,

  • button type ole2_object,

  • int type ole2_object,

  • font type ole2_object,

  • row type ole2_object.

*

*data: application type ole2_object,

  • book type ole2_object,

  • books type ole2_object.

*data: ole_book type ole2_object.

*

*do p_workbk times.

  • move p_fname to fname.

  • unpack sy-index to wb.

  • replace 'NN' with wb into fname.

**

  • perform create_excel.

*

    • create sheets and save

  • perform sheet.

*

  • perform save_book.

*enddo.

*write: ' Done'.

*

**----


*

    • form create_excel *

**----


*

    • ........ *

**----


*

*form create_excel.

  • create object excel 'EXCEL.APPLICATION'.

*

  • if sy-subrc ne 0.

  • write: / 'No EXCEL creation possible'.

  • stop.

  • endif.

*

  • set property of excel 'DisplayAlerts' = 0.

*

  • call method of excel 'WORKBOOKS' = workbook .

    • Put Excel in background

  • if p_exvis eq 'X'.

  • set property of excel 'VISIBLE' = 1.

  • else.

  • set property of excel 'VISIBLE' = 0.

  • endif.

*

    • Create worksheet

  • set property of excel 'SheetsInNewWorkbook' = 1.

  • call method of workbook 'ADD'.

*

****Èç¹ûÊÇopen an existed excel, use the following sentence .

**CALL METHOD OF WORKBOOK 'OPEN' EXPORTING #1 = FNAME .

**CALL METHOD OF EXCEL 'Worksheets' = SHEET

    • EXPORTING #1 = 1.

*endform. "create_excel

**----


*

    • form save_book *

**----


*

    • ........ *

**----


*

*form save_book.

  • get property of excel 'ActiveSheet' = sheet.

  • free object sheet.

  • free object workbook.

*

  • get property of excel 'ActiveWorkbook' = workbook.

  • call method of workbook 'SAVEAS'

  • exporting

  • #1 = p_fname

  • #2 = 1.

  • call method of workbook 'CLOSE'.

  • call method of excel 'QUIT'.

*

  • free object sheet.

  • free object workbook.

  • free object excel.

*endform. "save_book

**----


*

    • form sheet *

**----


*

    • ........ *

**----


*

*form sheet.

*

  • do p_wsheet times.

  • unpack sy-index to sheetname+5(2).

*

  • if sy-index gt 1.

  • call method of excel 'WORKSHEETS' = sheet.

  • call method of sheet 'ADD'.

  • free object sheet.

  • endif.

  • scnt = sy-index.

  • call method of excel 'WORKSHEETS' = sheet

  • exporting

  • #1 = scnt.

  • call method of sheet 'ACTIVATE'.

  • set property of sheet 'NAME' = sheetname.

  • free object sheet. "OK

*

*

  • perform fill_sheet.

**

  • call method of excel 'Columns' = column.

  • call method of column 'Autofit'.

  • free object column.

**

    • call method of sheet 'BUTTON' = button.

    • call method of button 'ADD'.

    • set property of button 'fmButtonstyle' = 0.

    • exporting #1 = '96.75' #2 = '372' #3 = '123.75' #4 = '12'.

    • set property of button 'Characters' = 'ButtonTest'.

*

  • free object button.

  • free object font.

  • free object int.

  • free object cell.

  • free object: cell1.

  • free object range.

  • free object borders.

  • free object: column, row.

  • enddo.

*

  • free object font.

  • free object int.

  • free object cell.

  • free object cell1.

  • free object range.

  • free object borders.

  • free object column.

  • free object row.

  • free object sheet.

*endform. "sheet

*

**----


*

    • form border *

**----


*

    • ........ *

**----


*

    • --> we *

**----


*

*form border using we.

**left

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '1'.

  • set property of borders 'Linestyle' = '1'.

  • set property of borders 'WEIGHT' = we. "4=max

  • free object borders.

    • right

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '2'.

  • set property of borders 'Linestyle' = '2'.

  • set property of borders 'WEIGHT' = we.

  • free object borders.

    • top

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '3'.

  • set property of borders 'Linestyle' = '3'.

  • set property of borders 'WEIGHT' = we.

  • free object borders.

    • bottom

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '4'.

  • set property of borders 'Linestyle' = '4'.

  • set property of borders 'WEIGHT' = we.

    • set property of borders 'ColorIndex' = 'xlAutomatic'.

  • free object borders.

*endform. "border

*

**----


*

    • form border2 *

**----


*

    • ........ *

**----


*

    • --> we *

**----


*

*form border2 using we.

**left

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '1'.

  • set property of borders 'Linestyle' = '5'.

  • set property of borders 'WEIGHT' = we. "4=max

  • free object borders.

    • right

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '2'.

  • set property of borders 'Linestyle' = '6'.

  • set property of borders 'WEIGHT' = we.

  • free object borders.

    • top

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '3'.

  • set property of borders 'Linestyle' = '7'.

  • set property of borders 'WEIGHT' = we.

  • free object borders.

    • bottom

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '4'.

  • set property of borders 'Linestyle' = '8'.

  • set property of borders 'WEIGHT' = we.

    • set property of borders 'ColorIndex' = 'xlAutomatic'.

  • free object borders.

*endform. "border2

*

**----


*

    • form border3 *

**----


*

    • ........ *

**----


*

    • --> we *

**----


*

*form border3 using we.

**left

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '1'.

  • set property of borders 'Linestyle' = '9'.

  • set property of borders 'WEIGHT' = we. "4=max

  • free object borders.

    • right

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '2'.

  • set property of borders 'Linestyle' = '10'.

  • set property of borders 'WEIGHT' = we.

  • free object borders.

    • top

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '3'.

  • set property of borders 'Linestyle' = '11'.

  • set property of borders 'WEIGHT' = we.

  • free object borders.

    • bottom

  • call method of cell 'BORDERS' = borders

  • exporting

  • #1 = '4'.

  • set property of borders 'Linestyle' = '12'.

  • set property of borders 'WEIGHT' = we.

    • set property of borders 'ColorIndex' = 'xlAutomatic'.

  • free object borders.

*endform. "border3

**----


*

    • form fill_cell *

**----


*

    • ........ *

**----


*

    • --> color *

    • --> pattern *

**----


*

*form fill_cell using color pattern.

  • call method of cell 'INTERIOR' = int.

  • set property of int 'ColorIndex' = color.

  • set property of int 'Pattern' = pattern.

  • free object int.

*endform. "fill_cell

*

**----


*

    • form font *

**----


*

    • ........ *

**----


*

    • --> bold *

    • --> size *

**----


*

*form font using bold size.

  • call method of cell 'FONT' = font.

  • set property of font 'BOLD' = bold.

  • set property of font 'SIZE' = size.

  • free object font.

*endform. "font

**----


*

    • form fill_sheet *

**----


*

    • ........ *

**----


*

*form fill_sheet.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'A1'.

  • perform font using 1 '14'.

  • set property of cell 'value' = 'Counter'.

  • perform fill_cell using '15' '1'.

  • perform border using '2'.

  • free object cell.

*

  • val = 'Workbook-Count'.

  • move wb to val+16.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'B1'.

  • set property of cell 'value' = val.

  • perform fill_cell using '14' '1'.

  • perform border using '4'.

  • free object cell.

*

  • val = 'Sheet-Count'.

  • unpack sy-index to val+12.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'C1'.

  • set property of cell 'value' = val.

  • perform fill_cell using '12' '1'.

  • perform border using '4'.

  • free object cell.

*

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'E3'.

  • perform border using '1'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'E5'.

  • perform border using '2'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'E7'.

  • perform border using '3'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'E9'.

  • perform border using '4'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'F3'.

  • perform border2 using '1'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'F5'.

  • perform border2 using '2'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'F7'.

  • perform border2 using '3'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'F9'.

  • perform border2 using '4'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'G3'.

  • perform border3 using '1'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'G5'.

  • perform border3 using '2'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'G7'.

  • perform border3 using '3'.

  • free object cell.

  • call method of excel 'RANGE' = cell

  • exporting

  • #1 = 'G9'.

  • perform border3 using '4'.

  • free object cell.

*

  • val = 'ROW-Count'.

*

  • do 19 times.

  • c_row = sy-index + 1.

  • unpack c_row to val+12(4).

  • call method of excel 'CELLS' = cell1

  • exporting

  • #1 = c_row

  • #2 = 2.

  • set property of cell1 'value' = val.

  • free object cell1.

  • call method of excel 'CELLS' = cell1

  • exporting

  • #1 = c_row

  • #2 = 4.

  • set property of cell1 'value' = val.

  • free object cell1.

  • enddo.

*endform. "fill_sheet