cancel
Showing results for 
Search instead for 
Did you mean: 

read file from mime-Repository into XML input stream

Former Member
0 Kudos

Hi all,

I just imported a template.xml into the mime of a BSP-Application in order to use the data in it at the runtime.

my question:

How can I read this file into an XML istream? (because I want to transform it with xslt at the time “OnInitialisation”.) What is the right way to give the uri or filename of the mime-object? I failed to create the istream with the following attempts:

iStream = streamFactory->create_istream_uri(uri).

with

Uri = “/SAP/TEST/template.xml”

Uri = “http://xxx.de: 8001/sap/bc/bsp/sap/TEST/TEMPLATE.XML”

Uri = “http://xxx.de: 8001/sap/TEST/TEMPLATE.XML”

(istream is empty)

Then I tried this way:


OPEN DATASET filename FOR INPUT IN BINARY MODE.
READ DATASET filename INTO inputstring.
istream = streamfactory->create_istream_xstring( inputstring ).

with

filename = “/SAP/TEST/template.xml”

filename = “http://xxx.de: 8001/sap/bc/bsp/sap/TEST/TEMPLATE.XML”

filename = “http://xxx.de: 8001/sap/TEST/TEMPLATE.XML”

(file not be opened, so istream is empty)

Does anyone has an idea on how to solve this problem ?

Thanks a lot.

Vivian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi Vivian,

You can do this like this:

Get the content of the file:


* instantiate MIME API class
    CALL METHOD cl_mime_repository_api=>if_mr_api~get_api
      RECEIVING
        r_mr_api = lo_mr_api.

* Get file from MIME repository
    CALL METHOD lo_mr_api->get
      EXPORTING
        i_url             = '/sap/test/template.xml'
*      I_CHECK_AUTHORITY  = 'X'
      IMPORTING
        e_is_folder        = l_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
            .

Then you can use this to create the XML object as you wrote it.


istream = streamfactory->create_istream_xstring( l_xstring ).

Former Member
0 Kudos

Hi Tim,

you solved my problem. Thank you very much!

Regards

Vivian

Answers (0)