Skip to Content
Author's profile photo Philip Johnston

Display an External PDF in ABAP WebDynpro

There may be an occasion where you wish to display an external (to SAP) pdf within an ABAP WebDynpro application.  For example, your building an application to track employee acknowledgements which require the employee to read and acknowledge a PDF which is being maintained out side of SAP.  Here’s a very basic sample of how to accomplish this:

Step 1:  Place an InteractiveForm element on your view layout and bind the pdfSource property to a context attribute of type xstring.

Step 2:  Add the following code to the wddoinit method:

method wddoinit .

  data lo_el_context type ref to if_wd_context_element.
  data ls_context type wd_this->element_context.
  data lv_external_pdf type wd_this->element_context-external_pdf.

  data: client type ref to if_http_client,
           url type string value ‘http://<server>/<??.pdf>’,
           content type xstring.

  call method cl_http_client=>create_by_url
      url                = url
      client             = client
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      others             = 4.

  if sy-subrc eq 0.
    client->request->set_header_field( name  = ‘~request_method’ value = ‘GET’ ).
    client->send( ).

    call method client->receive
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        others                     = 4.

    if sy-subrc eq 0.
      content = client->response->get_data( ).

      lo_el_context = wd_context->get_element( ).
      lv_external_pdf = content.
      lo_el_context->set_attribute( name =  `EXTERNAL_PDF` value = lv_external_pdf ).


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo pusala mahesh
      pusala mahesh

      Thank you 🙂

      Author's profile photo Ricky Orea
      Ricky Orea

      Hi Philip, I used this method but I get an error message "File does not begin with %PDF".