08-08-2006 6:09 PM
Hi All,
I am getting an error saying 'SYLK: File Format is not valid' when my program is trying to open an excel sheet. I am using the function module WS_EXCEL to download it to excel sheet.
Following is the code:
Excel download
types: begin of t_excel,
c01(20),
c02(20),
c03(20),
c04(20),
c05(70),
c06(20),
c07(20),
c08(20),
c09(20),
c10(20),
end of t_excel.
data: a00_excel type standard table of t_excel.
concatenate 'C:\' sy-repid sy-uzeit 'FILE01' '.xls' into z_fname.
condense z_fname no-gaps.
call function 'WS_EXCEL'
exporting
filename = z_fname
tables
data = a00_excel
exceptions
others = 1.
if sy-subrc ne 0.
message e019(zsd).
Download to Excel failed.
endif.
a00_excel contains the data that is to be downloaded into the excel sheet. I used the same code in the other program it is working fine. If you see in the type declaration for C5 its 70 characters, i tried putting it as same as others to 20... still it doesnt work.
Thank You,
Suresh
08-08-2006 6:23 PM
Not sure man, your code works ok for me.
report zrich_0001.
types: begin of t_excel,
c01(20),
c02(20),
c03(20),
c04(20),
c05(70),
c06(20),
c07(20),
c08(20),
c09(20),
c10(20),
end of t_excel.
data: a00_excel type standard table of t_excel.
data: x00_excel like line of a00_excel.
data: z_fname type string.
x00_excel-c01 = 'A'.
x00_excel-c02 = 'B'.
x00_excel-c03 = 'C'.
x00_excel-c04 = 'D'.
x00_excel-c05 = 'E'.
x00_excel-c06 = 'F'.
x00_excel-c07 = 'G'.
x00_excel-c08 = 'H'.
x00_excel-c09 = 'I'.
x00_excel-c10 = 'J'.
append x00_excel to a00_excel.
x00_excel-c01 = 'K'.
x00_excel-c02 = 'L'.
x00_excel-c03 = 'M'.
x00_excel-c04 = 'N'.
x00_excel-c05 = 'O'.
x00_excel-c06 = 'P'.
x00_excel-c07 = 'Q'.
x00_excel-c08 = 'R'.
x00_excel-c09 = 'S'.
x00_excel-c10 = 'T'.
append x00_excel to a00_excel.
concatenate 'C:' sy-repid sy-uzeit 'FILE01' '.xls' into z_fname.
condense z_fname no-gaps.
call function 'WS_EXCEL'
exporting
filename = z_fname
tables
data = a00_excel
exceptions
others = 1.
if sy-subrc ne 0.
message e019(zsd).
* download to excel failed.
endif.
Regards,
Rich Heilman
08-08-2006 9:30 PM
Hi Rich,
Please try by adding the following code
clear x00_excel.
x00_excel-c01 = 'IDoc Num'.
x00_excel-c02 = 'IDoc Date'.
x00_excel-c03 = 'Delivery Date'.
x00_excel-c04 = 'P.O. Number'.
x00_excel-c05 = 'EDI Type'.
x00_excel-c06 = 'Sold-To No'.
x00_excel-c07 = 'Sales Org'.
x00_excel-c08 = 'Dist Chnl'.
x00_excel-c09 = 'Division'.
x00_excel-c10 = 'Total Weight'.
append x00_excel to a00_excel.
Thank You,
Suresh
08-08-2006 9:42 PM
Hi Suresh,
Can't explain it but changing the 'D' to 'd' in IDoc worked for me.. ie the following
clear x00_excel.
x00_excel-c01 = 'Idoc Num'.
x00_excel-c02 = 'Idoc Date'.
x00_excel-c03 = 'Delivery Date'.
x00_excel-c04 = 'P.O. Number'.
x00_excel-c05 = 'EDI Type'.
x00_excel-c06 = 'Sold-To No'.
x00_excel-c07 = 'Sales Org'.
x00_excel-c08 = 'Dist Chnl'.
x00_excel-c09 = 'Division'.
x00_excel-c10 = 'Total Weight'.
append x00_excel to a00_excel.
may be ID means something to the Excel document..
Regards,
Suresh Datti
08-08-2006 6:26 PM
Check the format of sy-uzeit. You may not be able to save it with special characters.