Application Development 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: 

Excel download in Application Server

Former Member
0 Kudos

Hi,

I have mentioned the scenario below,

<u>Scenario:</u>

Program_1 have to save the data in excel format in Application server Unix box.

The same program will schedule the Program_2 in background with the excel filename as input.

Can you please suggest the effective way to download the data from internal table to Application server in Excel format.

Is it advisible to write the file with ".xls" in the unix box.

Thanks in advance,

Sivanandham.P

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

Try using FM <b>MS_EXCEL_OLE_STANDARD_DAT</b> there is a field in it FILE_NAME LIKE RLGRAP-FILENAME. Give the desired path of the application server. This will save your excel file on the server.

Now read that file again using another function module given above.

Regards,

Shekhar Kulkarni

7 REPLIES 7

Former Member
0 Kudos

Hi Siva,

If the file is created by one program and read by another program, why do you want to create it as an Excel file? Why can't you create it just as a fixed length file or a comma seperated file or a tab delimited file? Creating excel file(in excel format) is not easy and it is also not easy to upload it.

If you mean a file that can be read easily from Excel, then a comma-delimited or tab-delimited file is the way to go.

Regards,

Srinivas

0 Kudos

Hi Siva,

I agree with Srinivas, I don't see why you want to use an 'xls' format.

But if you want to do that, you can try these FM :

- SAP_CONVERT_TO_XLS_FORMAT

- TEXT_CONVERT_XLS_TO_SAP

I've used the 2de one :

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

i_field_seperator = 'X'

  • I_LINE_HEADER =

i_tab_raw_data = t_text_data

i_filename = p_file

TABLES

i_tab_converted_data = itab

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.

Hope this helps.

Regards,

Erwan.

Former Member
0 Kudos

Hey Sivandham,

I have had this exact same requirement. In my example I wanted to create an excel document and then email it to a customer. Unfortunately this is not really possible using standard SAP functionality.

The function modules provided by SAP require a connection to the presentation server so that they can lauch excel on your pc to perform the conversion. They do not work when there is no connection to the presentation server (for example in a background job).

So unless you can find a 3rd party tool which will perform this operation on your application server (more likely if you are running on NT than Unix) then I think you are stuck on this one.

In my situation, I adopted the solution suggested by others in this thread and created a comma seperated file with a .XLS extension which is generally read directly into excel when a user double clicks on it from an email (the users may not even notice the difference).

As for writing files with .XLS on the Unix box I don't think that you'll have any problems there (I didn't).

Hope that helps.

Cheers,

Brad

0 Kudos

Hi,

I have similar type of requirement - I have a XLS file in Application server, I have to read it to a internal table in SAP program. I used the FM TEXT_CONVERT_XLS_TO_SAP to upload the file to SAP but I am getting error message - "Excel file FILE:///usr/sap/mig/test1.xls cannot be processed"

This file is existed in the application server in the specified directory.

Please let me know what else I have to do

Here is my code below -

data : c_directory like rlgrap-filename Value '/usr/sap/mig/test1.xls'.

DATA: BEGIN OF i_input OCCURS 0,

field1(20) type c,

field2(20) type c,

field3(20) type c,

field4(20) type c,

END OF i_input.

type-pools : TRUXS.

data : i_raw_text type TRUXS_T_TEXT_DATA.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER =

i_tab_raw_data = i_raw_text

i_filename = c_directory

tables

i_tab_converted_data = i_input

  • EXCEPTIONS

  • CONVERSION_FAILED = 1

  • OTHERS = 2

.

I tried to read the XLS file from Presentation server then I am able to do it using the same FM 'TEXT_CONVERT_XLS_TO_SAP'.

My objective is to read the file from Application server. Please let me know if I miss some thing

Message was edited by: ajay brahma

0 Kudos

Hi There,

Have you solved your problem... Excel upload from Application Server ? I have the same requirement and user is not compromising on .csv or txt files.

Laxmikant

Former Member
0 Kudos

Hello,

Try using FM <b>MS_EXCEL_OLE_STANDARD_DAT</b> there is a field in it FILE_NAME LIKE RLGRAP-FILENAME. Give the desired path of the application server. This will save your excel file on the server.

Now read that file again using another function module given above.

Regards,

Shekhar Kulkarni

Former Member
0 Kudos

Hi All,

Thanks very much for the help.

Actually the second program(ZProgram_2 - JV Posting) is already in use and user's now access that through area menu and upload the file from their desktop ( that will post the JV).

So, the first program(Zprogram_1) will reformat the input file into excel format and will call the second program. So that i can reduce creation of one more Zprogram for the same operation (JV Posting).

Reading the data from excel format is already done and writing the file in excel format has to be done.

The given suggestions and FM are very much helpful.

Once again Thanks ...

Regards,

Sivanandham.P