This post is part of a series on code snippets. The complete list of posts in the series is available in the document Code Snippets: A Blog Series.
Two steps are needed to pass parameters into a Web Dynpro ABAP application from the SAPgui. First, the SAPgui must construct the URL of the Web Dynpro application and open the URL in a web browser. This step may be done in any ABAP routine.
DATA lv_absolute_url TYPE string. DATA lv_url TYPE char255. DATA ls_parameter TYPE ihttpnvp. DATA lt_parameters TYPE tihttpnvp. * Assemble the parameter name/value pairs as needed ls_parameter-name = 'param1_name'. ls_parameter-value = 'param1_value'. APPEND ls_parameter TO lt_parameters. ls_parameter-name = 'param2_name'. ls_parameter-value = 'param2_value'. APPEND ls_parameter TO lt_parameters. * Construct the URL with parameters cl_wd_utilities=>construct_wd_url( EXPORTING application_name = 'WEB_DYNPRO_APPLICATION_NAME' in_parameters = lt_parameters IMPORTING out_absolute_ur l = lv_absolute_url ). lv_url = lv_absolute_url. " cast data type CALL FUNCTION 'CALL_BROWSER' EXPORTING url = lv_url window_name = 'Example: Passing Parameters' new_window = abap_true EXCEPTIONS OTHERS = 0.
Second, the Web Dynpro application must read the parameters from its URL query string. This step must be done in the HANDLEDEFAULT event handler method of the Web Dynpro application's interface view, i.e., its window.
DATA lt_parameters TYPE tihttpnvp. * Read URL parameters from the query string wdevent->get_data( EXPORTING name = if_wd_application=>all_url_parameters IMPORTING value = lt_parameters ).
Internal table LT_PARAMETERS may now be read and the parameter name/value pairs processed as needed by the application.