Showing results for 
Search instead for 
Did you mean: 

Data Conversion

Former Member
0 Kudos

Can some one please tell me how can i upload a file using BSP,read the file and convert the contents of file to unicode.

I am using simple HTML to upload the file that works fine. But my problem is.. the contents of the file are in some other language(Chinese) and i need to convert it to unicode. If i try to set the locale and read the fails. Can someone please help me out.


Accepted Solutions (0)

Answers (1)

Answers (1)

Developer Advocate
Developer Advocate
0 Kudos

well if you use the HTMLB tag to upload the data it will be returned as binary string.  There is some good online help for the fileUpload tag that shows you how to do the data extraction part. You should then be able to convert the code page from the source one to a compatible destination one using some function calls. First call SCP_CODEPAGE_BY_EXTERNAL_NAME. With this you can convert the external name of the encoding type to the interal SAP code page.



     external_name = encoding

*     KIND = 'H'


     sap_codepage = codepage


     not_found = 1

     others = 2.

Next you can call function SCP_TRANSLATE_CHARS  to make the conversion. You can supply an input and export code page along with a input binary buffer. In this example I am converting a Unicode binary string to Unicode character based string. However it should work just as well for going from Chinese Simplified (GB2312) or Chinese Traditional (Big5) to Unicode (UTF-8).

call function 'SCP_TRANSLATE_CHARS'


        inbuff = e_data

        inbufflg = xdocument_length

        incode = codepage

*     OUTBUFFLG = 0

      outcode = codepage

*     CSUBST = 'X'

*     SUBSTC_HASH = ' '

*     SUBSTC_DOT = ' '

        substc_space = 'X'

        substc = '00035'


*     INUSED =

        outbuff = cdocument


*     OUTUSED =

*     SUBSTED =


*     ERRMSG =


        invalid_codepage = 1

        internal_error = 2

        cannot_convert = 3

        fields_bad_type = 4

        others = 5.

Former Member
0 Kudos

Can you please tell me on the same lines If I wanted to process the data of an uploaded Excel File how should I go about doing it ?

I get a Binary represenation of the excel file please advice. I need to convert that into Internal Table.