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

Convert XSTRING to TEXT

Former Member
0 Likes
8,432

Hello all,

I've been trying to convert a variable declared as xstring into TEXT, but after trying many function modules, I'm still without a solution.

My program reads an XLS file from BPC and the contents returns in a XSTRING variable. Since they need this file saved into the App.Server as CSV, I have to transform the spreadsheet into text first.

Any ideas?

Thanks.

JF

7 REPLIES 7
Read only

Former Member
0 Likes
4,374

does the XSTRING only contain the content of your excel file, or does it contain the binary representation of the file itself? EG, does it have the excel file's metadata etc in it as well...

Have you tried calling method:

CL_ABAP_CONV_IN_CE=>CREATE

Read only

0 Likes
4,374

Hi Jorg,

this is the method called within function 'CONVERT_XSTRING_TO_TEXT', which I had already tried with no success.

Thanks,

Alex.

Read only

Former Member
0 Likes
4,374

Hi,

check out this link

<link farm removed>

Hope it helps!

Message was edited by: Suhas Saha

Read only

Aashish28
Contributor
0 Likes
4,374

Hiii,

          Try this 2 FM -  SCMS_XSTRING_TO_BINARY than SCMS_BINARY_TO_TEXT .

Read only

Former Member
0 Likes
4,374

Hi

     Julio

    

In My example shown below 'buffer' is the XSTRING, 'text_buffer' is the string. You have to supply an encoding to tell the system what codepage/unicode type the XSTRING is.

data: convin  type ref to cl_abap_conv_in_ce,

      call method cl_abap_conv_in_ce=>create

        exporting

           encoding    = encoding

           input       = buffer

        receiving

          conv        = convin.

      call method convin->read

        importing

          data = text_buffer.

Please revert back.

Regards,

     Aaradhana

Read only

Ruediger_Plantiko
Active Contributor
0 Likes
4,374

JF,

as far as I see, you didn't answer Jorg's question

does the XSTRING only contain the content of your excel file, or does it contain the binary representation of the file itself?

This is crucial. It should be clear: if you upload an XLS or XLSX file to the server, you cannot simply use a character converter to transform the XSTRING representing this file  into a string and expect a csv string as result. XLS is encoded in the BIFF format, whereas XLSX is a zipped OpenXML file. Both formats contain a lot of data, not only the cell contents.

For transforming an Excel file into a csv stringtab, the following steps are necessary:

  • The file has to be parsed first,
  • and from the parsed model you can extract the data you want
  • and finally build the desired csv.

If you answer Jorg's question, we can help you with specific classes or function modules that are doing this work for you.

Regards,

Rüdiger

Read only

0 Likes
4,374

Jorg/Rudger,

I'm not sure how to answer. These XLS files were probably uploaded to BPC so I would say it contains more than the cell contents.

Can you tell the steps to transform this XSTRING to the cell contents so I can create a CSV?

Thanks,

Alex.