Skip to Content
avatar image
Former Member

Display XML in Web Dynpro

Hello,

i have a string variable filled with xml. And now i want to display this code in Web Dynpro with an ui element.

I tried a text_edit but it only shows the text but i want it to be displayed like in an IE.

Anybody an idea?

Regards Robert

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Sep 20, 2010 at 02:51 PM

    There is no UI element in Web Dynpro that is really designed to display XML. Often in standard SAP (like in SOAMANAGER) you just see the XML displayed in the TextView UI element. As you found you don't have the formatting and expand/collapse.

    You could use the iFrame to allow the underlying browser to render the XML. Warning: the iFrame is deprecated in 7.0 and 7.01 and isn't allowed at some support package levels. However the iFrame comes back to full support in 7.02. Also you can't just send the content directly to the iFrame UI element. You would have to upload the XML content to the ICM cache, generate a temporary URL for the cache entry and then bind this URL to the iFrame (iFrame can only accept a URL).

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2010 at 01:35 PM

    Ok, so an Iframe ist not the best solution right now.

    So i did what you said and uploaded the xml content to the ICM cache and generate an URL.

    Now i tried to open the URL with an external Window, but inside the new opened IE i can't see anything.

    Maybe my coding is not complete?

    Regards,

    Robert

    DATA:
            lv_xml_content        TYPE string,
            lo_http_response  TYPE REF TO if_http_response,
            lv_url            TYPE string,
            lv_xfile          TYPE xstring,
            lr_conv           TYPE REF TO cl_abap_conv_out_ce,
            lo_window_manager TYPE REF TO if_wd_window_manager,
            lo_api_component  TYPE REF TO if_wd_component,
            lo_window         TYPE REF TO if_wd_window.
    
      cl_abap_conv_out_ce=>create( RECEIVING conv = lr_conv ).
      lr_conv->convert( EXPORTING data   = lv_xml_content
                        IMPORTING buffer = lv_xfile ).
    
      CREATE OBJECT lo_http_response TYPE cl_http_response.
    
      lo_http_response->append_data( lv_xfile ).
      lo_http_response->set_content_type( 'text/xml' ).
      lo_http_response->server_cache_expire_rel( expires_rel = 500 ).
      lo_http_response->set_status( code = 200 reason = 'OK' ).
    
      cl_http_server=>server_cache_upload(
        EXPORTING
          url      = 'Test.xml'
          response = lo_http_response ).
    
      lo_api_component  = wd_comp_controller->wd_get_api( ).
      lo_window_manager = lo_api_component->get_window_manager( ).
      lo_window         = lo_window_manager->create_external_window(
                        url = 'Test.xml'
                        title = 'XML im Internetexplorer'
                         ).
    
      lo_window->open( ).

    Edited by: Thalin on Sep 21, 2010 3:45 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Your URL Generation and definition isn't correct. The cache insertion isn't relative to your Web Dynpro application. You must specify the URL relative to the ROOT of the folder structure. Also you generally use a GUID for the temporary URL to avoid overwrites.

      data: guid type guid_32.
        call function 'GUID_CREATE'
          importing
            ev_guid_32 = guid.
      
        concatenate '/sap/public' '/' guid '.' 'xml' into lv_iframe_url.
        cl_http_server=>server_cache_upload( url      = lv_iframe_url
                                             response = cached_response ).

  • avatar image
    Former Member
    Sep 21, 2010 at 02:26 PM

    Ok thanks,

    but now i got an error message, that the service is not accessible.

    Errorcode 404 not found. =/

    Add comment
    10|10000 characters needed characters exceeded

    • Actually the URL I generated in my sample was for an iFrame or download - so it could be a relative URL. You are wanting to an external window, right? You will need a full URL (with hostname and port as well).