Wednesday, July 6, 2011

Embedding WebDynpro into BSP

WebDynpro is great for read/write applications but weaker when it comes to presentation, flexibility and leveraging all the goodies available to normal web developers.

For the best of both worlds, you can build great applications in BSP using beautiful CSS and compelling animations (JQuery etc), and then load embedded WebDynpros when you need something heavier that you wouldn't want to code or maintain in your BSP.

How do you get the URL for the WebDynpro page you want to embed?  Try this code for size.

    data lt_parameters          type tihttpnvp.
    data ls_parameters          type line of tihttpnvp.

    clear lt_parameters[].
    ls_parameters-name = 'OBPLUG'.
    ls_parameters-value = i_plug.
    append ls_parameters to lt_parameters.
    clear ls_parameters.
    ls_parameters-name = 'OBFUNC'.
    ls_parameters-value = i_func.
    append ls_parameters to lt_parameters.
    clear ls_parameters.
    cl_wd_utilities=>construct_wd_url( exporting namespace        = 'MYNAME'
                                                 application_name = 'MYAPP'
                                                 in_parameters    = lt_parameters
                                      importing out_absolute_url  = o_url ). 

You will need to manually load the URL reply into the target element on your page:

$.get(o_url, {}, function(reply){
 $("#target").html(reply);
 }, "html");