on 09-24-2010 11:14 AM
Hi all,
I'm trying to upload an excel sheet using WDA, I find a lot of links like [this|http://wiki.sdn.sap.com/wiki/display/WDABAP/ExcelFileUploadAndDisplayDataUsingWebDynPro+ABAP] for do it.
But in almost all use the FM HR_KR_XSTRING_TO_STRING. In my system this FM don't exits.
I find other links like [this|https://wiki.sdn.sap.com/wiki/display/WDABAP/WDA%20for%20uploading%20Data%20from%20%20Excel%20sheet] or [this|; but when i trying to do it, is getting errors...
This is my code;
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_data TYPE wd_this->element_context-data_source.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `DATA_SOURCE`
IMPORTING
value = lv_data ).
DATA: convt type ref to cl_abap_conv_in_ce,
s_cont type string,
s_table type string_table.
convt = cl_abap_conv_in_ce=>create( input = lv_data ).
convt->read( importing data = s_cont ). "" In this line is DUMPING !!!!!!!!!!!!!!!
split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.
This is the error displayed in the browser:
"A character set conversion is not possible."
In my context i have an attribute called 'Data_source' type xstring...
How can I fix it?
Thanks in advance.
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've modified my code and now isn't dumping, but the string has a value very strange...
I've changed this in my code:
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = lv_data
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = convt.
But in the variable convt is returning this :
PK##########!#q#9+p###?#####?#[ Content_Types .xml ??#(?########################################################################################################################################################################################################
What is this ???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
First thing to consider, Webdynpro only supports TAB Delimited Excel file.
If you are using Tab delimited excel file then check if ECATT_CONV_XSTRING_TO_STRING function module exists and try to convert xstring to string with this.
Else use SCMS_XSTRING_TO_BINARY to convert xsting to binary and the use SCMS_BINARY_TO_STRING .
Regards,
Madhu
Thanks for your answer.
What is the meaning of "TAB Delimited Excel file" ? I use Office 2007. ¿xls not xlsx?
I've tried to usethe FM ECATT_CONV_XSTRING_TO_STRING but is always dumpping... returning this message:
"Error occurred during character conversion "
This is my code;
data: LV_DATA2 type ETXML_LINE_STR.
lv_data2 = lv_data.
CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
EXPORTING
im_xstring = lv_data2
IM_ENCODING = 'UTF-8'
IMPORTING
EX_STRING = s_cont.
I've also tried with the second option and this is my code;
data binary_tab type standard table of x255.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_data
* APPEND_TO_TABLE = ' '
* IMPORTING
* OUTPUT_LENGTH =
tables
binary_tab = binary_tab.
DATA ld_binlen TYPE i.
DATA ld_str TYPE string.
ld_binlen = XSTRLEN( lv_data ).
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = ld_binlen
IMPORTING
text_buffer = ld_str
TABLES
binary_tab = binary_tab.
But is still returning the strange value; PK##########!#q#9+p###?#####?#[ Content_Types .xml ??#(?########################################################################################################################################################################################################
>I can't find the solution there, this is for Word Files not for Excels...
The same thing applies here. If you are using XLS and saving in Excel native format, this is a Microsoft Propriatery Binary format. You can't process this as though it was a text file becuase it isn't one. You would have to save the Excel file as text tab delimited or one of the XML based formats before you can even read the file in ABAP. You are getting dumps and seeing strange things in the debugger becuase you are processing a file that isn't text based.
Then, what is the solution?
can't I do it something like that
http://wiki.sdn.sap.com/wiki/display/WDABAP/ExcelFileUploadAndDisplayDataUsingWebDynPro+ABAP
???
before to start using WebDynpro I used to use OLE2 objects for download and the FM ALSM_EXCEL_TO_INTERNAL_TABLE to upload. but I can see that with WebDynpro can't do a lot of things....
>Then, what is the solution?
If you want to do a text translation like the source code you posted, the the Excel file must be saved on the client as Text Tab Delimited (or Comma Separated).
>can't I do it something like that
Yes. In fact you could perhaps even reuse that project. However it is based upon the Excel XML format. That would mean saving the file as XLSX instead of XLS. In the case of XLSX, Office no longer uses the older microsoft propriatery binary file format but instead uses an XML based format. It is easier to parse but still would require parsing the XML (with the iXML library or with a XSLT). This is why the project you mention was created - to offer a reusable, generic XML transformation library for working with XML based Excel.
>How can I create an excel saved as Text Tab Delimited ???
In Excel, choose Save As->Other Formats. Choose Text (Tab Delimited) as the Save as Type in the dialog.
>Or could you put an example of code for XLSX excels, please ???
What do you ean an example code? If you want example code of how to parse an XLSX file, then I suggest you look at the open source project you mentioned earlier. It is a great example. The process isn't something super simple that you can just do a few lines of code (hence the community project).
However if you use an XLSX file then you should at least be able to perform the XSTRING to STRING conversion without errors and you will be able to view the string in the debugger. It will be XML however.
>
In Excel, choose Save As->Other Formats. Choose Text (Tab Delimited) as the Save as Type in the dialog.
Ok ok, i understand, this save the excel sheet as TXT with tab delimited.... but this isn't what i need...
>
However if you use an XLSX file then you should at least be able to perform the XSTRING to STRING conversion without errors and you will be able to view the string in the debugger. It will be XML however.
I'm trying to pass the XSTRING to STRING in different ways, but always return something like that:
PK##########!#q#9+p###uF870#####uF8AB#(Content_Types).xml u2199#(uF870#########################################################################################################################################################################################################
I've copied the FM HR_KR_XSTRING_TO_STRING and returns the same...
i don't know what i need to do...
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.