cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Upload Problem

Former Member
0 Kudos

Hi All,

We have a requirement to upload excel sheet data to an internal table via a WDA application . I searched the forum for a viable solution but couldnt find one.

We have some data in an excel sheet which we want to upload to an internal table, and then display it in a table element on the application screen.

Heres how i tried doing it :

I used the file upload functionality provided . I uploaded the file as an Xstring(this works without a problem) . Then i took the filename into a variable and tried to pass this filename to a function module which reads excel data (ALSM_EXCEL_TO_INTERNAL_TABLE)

However this gives me an error saying 'error while importing clipboard' . This seems to come from the CL_GUI_FRONTEND_SERVICES->import method.

Could anybody suggest a solution to this or an alternative method by which i could access Excel sheet data from the presentation layer in the WDA application ?

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I want to upload an excel sheet into an internal table using WD ABAP. Can you please tell me the solution?

I have tried HR_PK_EXCEL_TO_INTERNAL_TABLE and TEXT_CONVERT_XLS_TO_SAP and HR_KR_XSTRING_TO_STRING methods, but no success. I always get some type conversion error.

Any pointers would be helpful.

Thanks,

Sruti

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Why are you attaching this question to a thread that is several years old? Furthermore, this topic has been discussed at extensive length already within this forum. I suggest that you search. I think you will find that you are uploading an Excel document in the native binary format which is Microsoft propriatery and can't be processed by ABAP on the server. You should save the Excel file to a text based format like XML or Text Tab Delimited before uploading.

Former Member
0 Kudos

Hi Volker,

Thanks for the very insightful answer.

About a week ago, after numerous headaches (and soul searching ) , i came to nearly the same conclusion . All Gui uploads are thoroughly useless in the browser environment, which i frankly find quite quite disgusting.

So i came up with a solution in which i am converting the excel sheet to tab delimited text file, which the user can create when clicking on the "Save As " option .

This then is picked up as an xstring which i am splitting it into corresponding fields and then transferring to respective data fields. This works great thankfully so im out of a big hole !

Thanks again ,

Joe

Former Member
0 Kudos

Hi all!

The bad news is: In almost all cases you are in a native browser environment you can forget all APIs, function modules, classes and so on containing the string GUI and/or ALV in their names, because all of them assume that they are in a SAPGUI environment.

That is if you are in a browser environment your are "on the dark side of the moon" when trying to interpret xstring files.

Any chances to move to the "bright side of the moon"? ... Yes and No - depending on your situation.

If your users also have access to a SAPGUI you may embed your WDA application within a SAPGUI transaction and all the doors are opened for you...

If this is not true (that's what I assume) I think you have the following chances:

1. Tell your users to convert their excel sheets into CSV files before they upload them and then in your context you will find a comma-separated ASCII string ...

2 Tell your users to convert their excel sheets into HTML or XML files by using "save as..." before they upload them and then in your context you will find XML / HTML strings ...

3. use MS Office 2003 - as far as I know the office files from up to this versions are stored in some kind of an XML syntax (but I'm not really sure that this is a solution - never tried it).

4. Try the awful and cumbersome and error-prone way to convert binary data to character data; but this can work only, if you are well aware of the structure and strings used in the excel files to be uploaded. In this case you can scan the xstring for the byte strings you are interested in ... like already mentioned: this is a job for "dead men walking ...". We have done it and it works - but with many conventions/restrictions.

Hope this helps ....

Regards,

Volker

Former Member
0 Kudos

Hi Volker,

Would you please give me more information about HOW to convert binary data to character data of an excel file? I know the structure and strings used in the excel files, and I have to go to this 'dead men walking'. It is my urgent task now.

Thank you very much!

My email: hao.deng@sap.com

Best regards,

Hao

Former Member
0 Kudos

Hi Hao,

first of all sorry for late feedback. But what you must do is the very awful and of course lavishly job and manupulate your excel binary string object with the following tools:

Use Conversion Function Modules from Function Group SCMS_CONV like

CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'

CALL FUNCTION 'SCMS_BIN_TO_TEXT'

Use ABAP string operations like

SEARCH lv_xstring FOR lv_searchstring IN BYTE MODE STARTING AT lv_startpos

CONCATENATE...INTO...

REPLACE SECTION OFFSET ...

and so on.

Like already mentioned: It's a "dead man walking job" and you cannot be sure that the solution you create will work with the next excel release. The better ways are - like already mentioned:

Tell your users to convert their excel sheets to csv before uploading them. this is the easiest way.

Use MS Office 2003 and store your excel sheets in XML format.

Hope this will help you ....

Regards,

Volker

Former Member
0 Kudos

Hi Volker,

Thanks for your reply! It is helpful very much!

Actually I already got the feeling that it's a "dead man walking job". I find I must know xls binary format very much, otherwise I can't use xstring processing fuction modules. I also found there are some solutions using java and perl, but it is hard to use them in ABAP. I will try to persuade my customers to save in XML or CSV format.

Best regards,

Hao

Former Member
0 Kudos

Hi Volker,

I'm trying to do excel upload in my WDA application. As soon as i upload using FILE UPLOAD UI element,

i get the file content in the form of hexadecimal data.

I tried passing this hexadecimal data to the function module 'SCMS_BIN_TO_TEXT' and this gives me some junk data

filled with hashes and other special characters.

Is the correct way of approach? Kindly help me in addressing this issue.

Regards,

Ravikanth

Former Member
0 Kudos

Hi Ravikanth,

I am dealing with a similar problem. You will find the hexadecimal data of an excel file is so hard to read because it is MS's BIFF format. So I have an idea that could we parse it in WebDynpro program at uploading time in client PC? Because only at this time local Excel APIs could be used.

@Volker, do you agree with me?

Thanks!

Best regards,

Hao

Former Member
0 Kudos

hi all,

i also facing same problem in WDA appln, that <b>error during clipboard import</b>

when we use ALSM_EXCEL_TO_INTERNAL_TABLE for uploading excel data to internal table. please help if anyone have idea on this

Former Member
0 Kudos

Ive also read on some forums that we can extract data from the xstring from file upload.

Anybody with any ideas on how to do this ??

Any and all help will be appreciated and rewarded with points

Thanks and Regards,

Joe