‎2005 Oct 18 4:58 AM
any way to create a excel with data sheet with specific name in background?
‎2005 Oct 18 5:10 AM
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.
‎2005 Oct 18 5:10 AM
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.
‎2005 Oct 20 9:55 AM
Hi Anid,
Does this solution apply to 4.0B? I can't find the function 'SAP_CONVERT_TO_XLS_FORMAT' in 4.0B.
‎2005 Oct 20 10:27 AM
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
‎2005 Oct 20 10:50 AM
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
‎2005 Oct 22 11:33 AM
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