Skip to Content

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
    exporting
      url                = url
    importing
      client             = client
    exceptions
      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
      exceptions
        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 ).
    endif.
  endif.

endmethod.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply