Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Accessing BSP HTML : A design Question

Hi Everyone,

I have a simple requirement which is to retrieve the HTML of a BSP which is password protected. This is not a problem as the code for this is all over SDN and looks something like this


function z_get_html_body .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(URL) TYPE  STRING
*"  EXPORTING
*"     VALUE(BODY) TYPE  XSTRING
*"     VALUE(BODY_SIZE) TYPE  I
*"  EXCEPTIONS
*"      SYSTEM_ERROR
*"----------------------------------------------------------------------
 data:  client type ref to if_http_client,
        lv_body_size type string.

call method cl_http_client=>create_by_url
  exporting
    url = url
  importing
    client = client.

  call method client->send
  exceptions
    http_communication_failure = 1
    http_invalid_state         = 2.

  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
          raising system_error.
  endif.

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

  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
          raising system_error.
  endif.

  body = client->response->get_data( ).

  lv_body_size = xstrlen( body ).
  move lv_body_size to body_size.
  call method client->close.

endfunction.

The problem is that since the URL is password protected by SAP, I need to encode the system user name and password into the URL so that the URL is like this

http://<username>:<pwd>@<server>:<port>/mybsp/index.html

But this means that I must store the username and password in some table somewhere where it can be viewed by anyone with SE16 access.

I am hoping there is a better way.

One option I did consider was using an RFC destination of type H (HTTP connection to R/3 system) and then specifying the username and password in the logon details. This works great but it leaves me with the following issues:

1. What If i dont want to access index.html but another page? Do I need to create an RFC destination for each page I want to access?

2. What if I need to pass parameters? How do I do that as the parameters to be passed will be determined at runtime by my code.

Perhaps the whole RFC destination is a dead end and there is a better way but I look forward to yoru ideas.

Alon

Not what you were looking for? View more on this topic or Ask a question