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

uploading excel files?

Former Member
0 Likes
990

i already know how to upload excel file from local pc can anyone tell me how to upload excel file from the application server??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
928

Hi Sharad,

Excel file cannot be uploaded from application server unless it is converted to a text file. Excel file is belongs Windows OS and Application server will be either in Unix or Informix etc. Text file is the only compatible format across all the platform and so excel file should be changed to the common format. Hope this helps.

Regards,

Kasthuri Rangan.

7 REPLIES 7
Read only

Former Member
0 Likes
928

Function module KCD_EXCEL_OLE_TO_INT_CONVERT will allow you to do this.

Read only

Former Member
0 Likes
928

Hi,

Try this one

Retrieve Data file from Application server


DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

OPEN DATASET i_file FOR INPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE e999(za) WITH 'Error opening file' i_file.
ENDIF.
DO.
* Reads each line of file individually
READ DATASET i_file INTO wa_datatab.
* Perform processing here
* .....
ENDDO.

you may Refer to yhese links too: http://www.sapdevelopment.co.uk/file/file_updown.htm

http://www.sapdevelopment.co.uk/file/file_uptabsap.htm

OR

try this one

FM: UPLOAD_FILES

Regards,

Amit

Read only

Former Member
0 Likes
928

Hi,

You can use:

OPEN DATASET v_file FOR INPUT IN TEXT MODE.

Where:

v_file LIKE FILENAME-FILEINTERN, "File name

Best Regards,

Anjali

Read only

Former Member
0 Likes
928

If you have access to the application server, then you can do it the same way as you do on your local PC.

If not, try using OPEN/READ/CLOSE dataset in BINARY MODE.

Check out the SAP help files on this.

Read only

Former Member
0 Likes
929

Hi Sharad,

Excel file cannot be uploaded from application server unless it is converted to a text file. Excel file is belongs Windows OS and Application server will be either in Unix or Informix etc. Text file is the only compatible format across all the platform and so excel file should be changed to the common format. Hope this helps.

Regards,

Kasthuri Rangan.

Read only

0 Likes
928

can the conversion of excel file into .txt format can be done internally through ABAP?

Read only

0 Likes
928

Sharad,

I found this to be the easiest way to handle Excel files on the server.

types : begin of ty_filestructure,

row(500) type c,

end of ty_filestructure.

data : i_filedata type standard table of ty_filestructure

with header line.

data: l_fnam like rlgrap-filename,

l_filedata type kcde_intern,

l_fileline like line of l_filedata,

l_col type kcd_ex_col_n.

l_fnam = p_fnam.

      • pick up the sheet of the workbook that has the focus

call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'

exporting

filename = l_fnam

i_begin_col = 1

i_begin_row = 1

i_end_col = 50

i_end_row = 2500

tables

intern = l_filedata

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

if sy-subrc <> 0.

message i000(38)

with 'Error loading data - return code'

sy-subrc.

exit.

endif.

      • create real table rows from l_filedata; pull back empty cells as

  • well as populated ones

loop at l_filedata into l_fileline.

l_col = l_col + 1.

if l_fileline-col = l_col.

concatenate i_filedata

l_fileline-value

into i_filedata

separated by c_comma.

else.

while l_col < l_fileline-col.

concatenate i_filedata

space

into i_filedata

separated by c_comma.

l_col = l_col + 1.

endwhile.

concatenate i_filedata

l_fileline-value

into i_filedata

separated by c_comma.

endif.

at end of row.

shift i_filedata left deleting leading c_comma.

append i_filedata.

clear i_filedata.

clear l_col.

endat.

endloop.

Margaret.