Wednesday, June 29, 2011

Create Transaction to Execute SAP BSP Application

I have created a BSP Application and want to run it using a transaction code created in SE93.

If you have transaction START_BSP on your NetWeaver box, then you can make a copy of this transaction with your variant.

However, if this is not installed, you need to write a program that determines the appropriate URL and calls the CALL_BROWSER function module.

Here is some sample code:

report  zbsp_start.

data: lv_url type string,
      lv_urlc(4096) type c,
      lt_parms type tihttpnvp.

start-of-selection.
  parameter: p_app type string.
  parameter: p_page type string.
  parameter: p_parms type string.
end-of-selection.

*-- Create URL to BSP Application
  call method cl_http_ext_webapp=>create_url_for_bsp_application
    exporting
      bsp_application      = p_app
      bsp_start_page       = p_page
      bsp_start_parameters = lt_parms
    importing
      abs_url              = lv_url.


*-- Call the BSP Application in the default Browser
  lv_urlc = lv_url.
  call function 'CALL_BROWSER'
    exporting
      url                    = lv_urlc
      window_name            = 'BSP'
      new_window             = ' '
    exceptions
      frontend_not_supported = 1
      frontend_error         = 2
      prog_not_found         = 3
      no_batch               = 4
      unspecified_error      = 5
      others                 6.

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