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

create excel in background with data sheet

Former Member
0 Likes
829

any way to create a excel with data sheet with specific name in background?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
693

Hi try this simple program.Instead of giving hard-coded file name as i did in this report, you can take the filename dynamicaly from a selection screen parameter. if you call this report from some other program by "submit .." statement, t runs in back ground.

DATA: BEGIN OF intab occurs 0,

mandt LIKE mara-mandt,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

ernam LIKE mara-ernam,

laeda LIKE mara-laeda,

aenam LIKE mara-aenam,

END OF intab.

start-of-selection.

select mandt matnr ersda laeda aenam from mara

into corresponding fields

of table intab up to 30 rows.

loop at intab.

write:/ intab-matnr,intab-ersda,intab-ernam,intab-laeda,intab-aenam.

clear intab.

endloop.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ','

  • I_LINE_HEADER =

i_filename = 'c:\test123.xls'

  • I_APPL_KEEP = ' '

tables

i_tab_sap_data = intab.

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

5 REPLIES 5
Read only

Former Member
0 Likes
694

Hi try this simple program.Instead of giving hard-coded file name as i did in this report, you can take the filename dynamicaly from a selection screen parameter. if you call this report from some other program by "submit .." statement, t runs in back ground.

DATA: BEGIN OF intab occurs 0,

mandt LIKE mara-mandt,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

ernam LIKE mara-ernam,

laeda LIKE mara-laeda,

aenam LIKE mara-aenam,

END OF intab.

start-of-selection.

select mandt matnr ersda laeda aenam from mara

into corresponding fields

of table intab up to 30 rows.

loop at intab.

write:/ intab-matnr,intab-ersda,intab-ernam,intab-laeda,intab-aenam.

clear intab.

endloop.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ','

  • I_LINE_HEADER =

i_filename = 'c:\test123.xls'

  • I_APPL_KEEP = ' '

tables

i_tab_sap_data = intab.

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

Read only

0 Likes
693

Hi Anid,

Does this solution apply to 4.0B? I can't find the function 'SAP_CONVERT_TO_XLS_FORMAT' in 4.0B.

Read only

0 Likes
693

Hi Des,

Welcome to SDN.

If you are trying to create a excel sheet with data and store it in the local PC, you cannot do it in the back ground mode.

However if you want to create excel format data and store it in application server, (in back ground mode) and then an online program to read the content from application server and store it in a excel sheet in the desktop , it is possible.

Kindly let us know which one you are looking for.

Regards

Raja

Read only

0 Likes
693

Hi Raja,

That what I am looking for.

Create excel format data and store it in application server in background mode.

I am still on 4.0B

Regards

Desmond

Read only

0 Likes
693

i dont think you have to do anything special, just save to itab with commoa separate or tab separated in application server.

in the download program just read it from application server into an itab and download as excel.

if you are looking for special formatting of excel, like formula, graph, etc., then its totally different approach you may have to take.

Regards

Raja