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

Creating Excel File on Application Server

Former Member
0 Likes
5,363

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

6 REPLIES 6
Read only

former_member206396
Active Participant
0 Likes
1,976

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

Read only

0 Likes
1,976

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

Read only

0 Likes
1,976

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

Read only

Siva_Muddana
Explorer
0 Likes
1,976

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.

Read only

Former Member
0 Likes
1,976

I tell u to try with .csv file , comma deleiminator as this also excel , it works , we have doem with .csv file.

Rgards

Read only

manubhutani
Active Contributor
0 Likes
1,976

Hi Priya,

Can you please tell me how you resolved this? I would be very thankful to you.

Regards

Manu