cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading a .txt File to an Internal Table, Umlaut u00C4, u00D6 and u00DC replaced by #

Former Member
0 Kudos

Hello Togehter,

i've got a Problem when i'm uploading, in WebDynpro, a .txt File to an Internal Table of SAP.

The umlaut Ää, Öö and Üü were replaced with #.

Can sb. explain why?

What I have to do to upload it correct?

Regards Chris

Accepted Solutions (0)

Answers (2)

Answers (2)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Is your ABAP system Unicode or Non-Unicode? If non-Unicode what language are you logged into the ABAP system with? How is the text file saved? Even a TXT format can be saved different ways? For instance if saved from WordPad you have the choice of Text or Text Unicode?

Basically what is happening is that the characters you describe are not in the ASCII7 range. It sounds like you are working with a non-unicode file on a non-unicode system and the code page of your ABAP system (which in a non-unicode system is controlled by the logon language) doesn't match the code page of the uploaded text file.

Former Member
0 Kudos

Yes i use the UL-File-element.

ABAP system is Unicode.

I'm working with the language GERMAN.

The data I need to upload, i write in an Excel File. Then save the file as a .txt file, separated with TAB. Then upload the file with the WDA.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The file is uploaded as an XSTRING so you must be doing some conversion to get it back to STRING for processing. What are you doing at this point? This is probably where the corruption occurs becuase of code page conversion.

You could consider saving the file within Excel as Unicode Text instead of a code page specifc text tab delimited format.

Former Member
0 Kudos

  lo_el_context->get_attribute(
    EXPORTING
      name =  `DATASOURCE`
    IMPORTING
      value = lv_datasource ).

  convt = cl_abap_conv_in_ce=>create( input = lv_datasource
                                      ignore_cerr = ABAP_TRUE ).

  convt->read( IMPORTING data = s_cont ).

  SPLIT s_cont AT cl_abap_char_utilities=>cr_lf INTO TABLE s_table.

The convertion from Xstring to String i did. And is working fine.

I tried to save the File as Unicode FIle, but is not working uploading it.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

What is the source code page of the frontend machine? With the conversion classes you are using you must specify the source code page if it doesn't match the default one of the logon language.

>I tried to save the File as Unicode FIle, but is not working uploading it.

What exactly isn't working? You would need to adjust the conversion logic to specific that the source is Unicode (probably UTF-16le knowing Microsoft Office - but you might have to research that).

Former Member
0 Kudos

What is the source code page of the frontend machine? With the conversion classes you are using you must specify the source code page if it doesn't match the default one of the logon language.

Sorry i don't know what you mean with this phrase.

Yes you're right, i have to adjust the conversion logik.

Former Member
0 Kudos

Hi Christian,

did you solve your problem?

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Save your txt file in UTF format as Thomas suggested.

and use the code to read it in the program, your attachment content goes into xstring.

data: lr_conv type ref to cl_abap_conv_in_ce.

data: lv_cont type string.

data: lv_xcont type xstring.

lr_conv = cl_abap_conv_in_ce=>create( encoding = 'UTF-8' input = ls_attachment-content ).

lr_conv->read( importing data = lv_xcont ).

call function 'CRM_IC_XML_XSTRING2STRING'

exporting

inxstring = lv_xcont

importing

outstring = lv_cont.

and now play with lv_cont.

Former Member
0 Kudos

Thx alot for Help.

I already solved my problem.

My uploaded File was ANSI and i don't was allowed to convert it in UTF.

So i added this to my upload coding: encoding = 'NON_UNICODE'.


  convt = cl_abap_conv_in_ce=>create( input = lv_datasource
                                      ignore_cerr = abap_true
                                      encoding = 'NON-UNICODE' ).

So my Umlaut where acceptet. And on downloading this data and some other added data, I just insert

the following to my coding:


  DATA: encoding TYPE abap_encoding VALUE '1100'.

   CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = d_string
      encoding = encoding
    IMPORTING
      buffer = d_xstring.

So with this Code it works very good.

Former Member
0 Kudos

Do you use the normal UI-Upl-File-Element?

In which context-node (data-types) do you load it?