cancel
Showing results for 
Search instead for 
Did you mean: 

MIME object (excel file) to String

Former Member
0 Kudos

Hello all,

I would like to convert a mime object which is an excel file that i created in a bsp application to a string/xstring.

Let's say i named this mime-object "test.xls".

Does anyone has example code on how to retreive the object from the database and to convert it?

Kind regards,

Martijn de Jong.

<removed by moderator>

Edited by: Durairaj Athavan Raja on Sep 5, 2008 1:40 PM

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos


data: lo_mr_api type ref to if_mr_api.
data: i_url type string.


i_url = '/SAP/BC/BSP/SAP/<your BSP app name>/test.xls' .

call method cl_mime_repository_api=>if_mr_api~get_api
  receiving
    r_mr_api = lo_mr_api.



call method lo_mr_api->get
  exporting
   i_url             = i_url
*      I_CHECK_AUTHORITY  = 'X'
  importing
*       e_is_folder      =
    e_content         = l_xstring
    e_mime_type       = l_mimetype
*      E_LOIO             =
*    CHANGING
*      C_LANGUAGE         =
  exceptions
    parameter_missing  = 1
    error_occured      = 2
    not_found          = 3
    permission_failure = 4
    others             = 5.
Former Member
0 Kudos

Durairaj Athavan Raja for president!

Thanks for the quick and correct answer! It works like a charm.

Now i have a bsp application, which opens an excel template which is saved under the application as mime object.

The excel template contains a VBA macro which is automatically executed and calls a BW workbook with variables which i can now enter dynamically in the excel template via my bsp application coding......

Thanks for all the help! (also other threads of you around the sdn forum were very helpfull)

Regards,

Martijn de Jong.

Edited by: M. de Jong on Sep 5, 2008 1:47 PM

athavanraja
Active Contributor
0 Kudos

Hi Martijn de Jong.

I am interested in checking out this BSP and the excel template, would you mind sharing. Also you should write a blog about this.

Regards

Raja

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello All,

I built my test application on another system as where i am currently building the sollution. Now i get a coversion error when converting the xstring to a string.

The other system was a non-unicode and this current system is a unicode system.

Underneath is my coding.

DATA:

file_content TYPE string,

file_xcontent TYPE xstring,

wa_wbdata TYPE rsrwbstore.

DATA: lo_mr_api TYPE REF TO if_mr_api.

DATA: i_url TYPE string.

DATA: l_mimetype TYPE w3conttype.

i_url = '/SAP/BC/BSP/SAP/ZTEST/Test_macro.xls'.

CALL METHOD cl_mime_repository_api=>if_mr_api~get_api

RECEIVING

r_mr_api = lo_mr_api.

CALL METHOD lo_mr_api->get

EXPORTING

i_url = i_url

IMPORTING

e_content = file_xcontent

e_mime_type = l_mimetype

EXCEPTIONS

parameter_missing = 1

error_occured = 2

not_found = 3

permission_failure = 4

OTHERS = 5.

DATA: conv TYPE REF TO cl_abap_conv_in_ce.

TRY.

conv = cl_abap_conv_in_ce=>create( input = file_xcontent ).

CATCH CX_PARAMETER_INVALID_RANGE .

CATCH CX_SY_CODEPAGE_CONVERTER_INIT .

ENDTRY.

TRY.

conv->read( IMPORTING data = file_content ).

CATCH CX_SY_CONVERSION_CODEPAGE .

CATCH CX_SY_CODEPAGE_CONVERTER_INIT .

CATCH CX_PARAMETER_INVALID_TYPE .

CATCH CX_PARAMETER_INVALID_RANGE .

ENDTRY.

I keep getting the CX_SY_CONVERSION_CODEPAGE error. Someone has a sollution?

Kind regards,

Martijn de Jong.

athavanraja
Active Contributor
0 Kudos

you have to use the following FM and pass the proper encoding to it

ECATT_CONV_XSTRING_TO_STRING