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

Reports

Former Member
0 Likes
743

hi,

for genarating the xl file wich function module we have to use.......

m.sriknath

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
712

WS_DOWNLOAD.

6 REPLIES 6
Read only

Former Member
0 Likes
712

<b>gui_download</b>

Read only

Former Member
0 Likes
713

WS_DOWNLOAD.

Read only

Former Member
0 Likes
712

Hi Srikanth,

Check out the link and sample code below:

Download internal table contents to EXCEL

http://sap.ittoolbox.com/code/d.asp?d=3127&a=s

or to

http://sap.ittoolbox.com/code/d.asp?d=3126&a=s

or to

http://sap.ittoolbox.com/code/d.asp?d=3027&a=s

you can also check

http://sap.ittoolbox.com/code/d.asp?d=1614&a=s

These links were extracted from ITToolbox Sap source code exchange( http://sap.ittoolbox.com/code/d.asp?whichpage=1&pagesize=10&i=10&a=c&o=&t=&q=&qt= )

This pages are a free resource of code from other abappers who kindly share their knowledge to us.

>

  • Multiple excel sheets generation in a workbook

CREATE OBJECT EXCEL 'EXCEL.SHEET'.

GET PROPERTY OF EXCEL 'Application' = APPLICATION.

SET PROPERTY OF APPLICATION 'Visible' = 1.

CALL METHOD OF APPLICATION 'Workbooks' = BOOKS.

CALL METHOD OF BOOKS 'Add' = BOOK.

CALL METHOD OF BOOK 'WORKSHEETS' = SHEET.

CALL METHOD OF SHEET 'ADD'.

  • Fill all the sheets with relavant data

PERFORM SHEET1 TABLES ITAB1.

PERFORM SHEET2 TABLES ITAB2.

PERFORM SHEET3 TABLES ITAB3.

PERFORM SHEET4 TABLES ITAB4.

  • Quit the excel after use

CALL METHOD OF EXCEL 'QUIT'.

FREE OBJECT: COLUMN,SHEET,BOOK,BOOKS,APPLICATION,EXCEL. "NO FLUSH.

CLEAR V_SHEET.

FORM FILL_CELL USING ROW COL VAL.

CALL METHOD OF SHEET 'cells' = CELL NO FLUSH

EXPORTING #1 = ROW #2 = COL.

SET PROPERTY OF CELL 'value' = VAL.

FREE OBJECT CELL NO FLUSH.

ENDFORM. " FILL_CELL

FORM SHEET1 TABLES ITAB1 STRUCTURE ITAB1.

V_SHEET = Sheet Name.

V_NO = V_NO + 1.

CALL METHOD OF BOOK 'worksheets' = SHEET NO FLUSH EXPORTING #1 = V_NO.

SET PROPERTY OF SHEET 'Name' = V_SHEET NO FLUSH.

PERFORM FILL_SHEET1 TABLES ITAB1 USING V_NO V_SHEET.

CALL METHOD OF SHEET 'Columns' = COLUMN.

FREE OBJECT SHEET.

CALL METHOD OF COLUMN 'Autofit'.

FREE OBJECT COLUMN.

ENDFORM.

Repeat above procedure for all sheets you want to add

FORM FILL_SHEET1

TABLES ITAB1 STRUCTURE ITAB1

USING V_NO V_SHEET.

ROW = 1.

PERFORM FILL_CELL USING ROW 1 'Column1 Name'.

PERFORM FILL_CELL USING ROW 2 'Column2 Name'.

PERFORM FILL_CELL USING ROW 3 'Column3 Name'.

ROW = ROW + 1.

LOOP AT ITAB1.

PERFORM FILL_CELL USING ROW 1 ITAB1-Column1.

PERFORM FILL_CELL USING ROW 2 ITAB1-Column2.

PERFORM FILL_CELL USING ROW 3 ITAB1-Column3.

ROW = ROW + 1.

ENDLOOP.

ENDFORM.

Repeat above procedure for all sheets you want to add

<b>Another FM -</b>

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER =

i_filename =

  • I_APPL_KEEP = ' '

tables

i_tab_sap_data =

  • 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.

Reward Points if this helps.

Manish

Message was edited by: Manish Kumar

Read only

Former Member
0 Likes
712

Hi,

this will be more friendly FM.

MS_EXCEL_OLE_STANDARD_DAT

Just have to pass internal table which contain data ...

file path

internal table for headers....

output will be excel file very well formatted.

Read only

Former Member
0 Likes
712

Use FM GUI_DOWNLOAD. Suppose if your data is in ITAB_OUTPUT, then u can use that FM in this way.

call function 'GUI_DOWNLOAD'

exporting filename = 'C:\test.xls'

tables data_tab = itab_output

exceptions file_write_error = 1

others = 22.

Read only

Former Member
0 Likes
712

hi,

use the function modules

MS_EXCEL_OLE_STANDARD_OLE

or

WS_EXCEL

hope it helps.

reward points if helpful.

Regards,

Sipra