‎2009 Oct 29 7:44 AM
Hi All,
I have to create excel file on Application Server.
For that I do the following :
ld_file = '/usr/sap/trans/abap/file.xls'.
OPEN DATASET ld_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
CONCATENATE wa_string int_final-field1 INTO wa_string SEPARATED BY con_tab.
CONCATENATE wa_string int_final-field2 INTO wa_string SEPARATED BY con_tab.
CONCATENATE wa_string int_final-field3 INTO wa_string SEPARATED BY con_tab.
CONCATENATE wa_string int_final-field4 INTO wa_string SEPARATED BY con_tab.
.
.
.
.
CLOSE DATASET ld_file.
Problem : File is created on application server as file.xls but it having the property of tab delimited file.
Can any help me that how can i created file having the property of Excel file.
Regards,
Priya
‎2009 Oct 29 12:54 PM
You have to write each and every line to file.
OPEN DATASET ld_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
CONCATENATE wa_string int_final-field1 INTO wa_string SEPARATED BY con_tab.
transfer wa_string to ld_file.
clear : wa_string.
CONCATENATE wa_string int_final-field2 INTO wa_string SEPARATED BY con_tab.
transfer wa_string to ld_file.
clear : wa_string.
CONCATENATE wa_string int_final-field3 INTO wa_string SEPARATED BY con_tab.
transfer wa_string to ld_file.
clear : wa_string.
CONCATENATE wa_string int_final-field4 INTO wa_string SEPARATED BY con_tab.
.
transfer wa_string to ld_file.
clear : wa_string.
CLOSE DATASET ld_file.
hope this helps.
regards
Ram
‎2009 Oct 30 12:52 PM
Hi Rama,
I am writing each and every line to file.
File is created but as i mentioned earlier that the file is crested with .xls extension because of I put the file extension file.xls,
but file not having the excel file property , it having the tab dilimited file property.
how can we create the file having the excel file property ?
Regards,
Priya
‎2009 Oct 30 2:46 PM
Priya,
Am written following code, and its working fine. ( sample code ).
and May i know how are you opening the file?
data : res type string.
data : con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
concatenate 'abc' 'xyz' 'pqr' into res separated by con_tab.
data : path type string value '/home/usr/interface/POSPOST/xyz.xls'.
open dataset path for OUTPUT IN TEXT MODE ENCODING DEFAULT .
transfer res to path.
close dataset path.
Ram
‎2009 Oct 30 8:28 PM
Check how you defined 'con_tab' in your code.
As you said that file is getting created and probelm is abt excel sheet property.. In this case , you need only one change con_tab as shown below.
data : con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
that would solve your problem.
Note: you can see data separated by '#' in your file.
(u might know the below process already)
Then download created file '/usr/sap/trans/abap/file.xls'.
to desktop using tcode CG3Y . Now you will see the expected result.
‎2009 Oct 31 10:43 AM
I tell u to try with .csv file , comma deleiminator as this also excel , it works , we have doem with .csv file.
Rgards
‎2010 Nov 11 10:17 AM
Hi Priya,
Can you please tell me how you resolved this? I would be very thankful to you.
Regards
Manu