Launch a business document in SAP GUI mode from Web Dynpro ABAP Application
This document will help you execute a scenario where you wish to launch any business document applicable to your scenario in the SAP GUI mode.
Pre-requisite before you move ahead – it is assumed that you have basic knowledge of how to design a Web Dynpro application having an ALV table (SALV_WD_TABLE type component) in it.
This document will showcase how to launch a Sales order display transaction (VA03) on the click of a table cell value (Sales order #).
- Once you have the basic view designed in the web dynpro component which has a Table holding sales order data and Web Dynpro application is created as well, assume that one of the columns in the ALV table is ‘Sales order #’. The technical field name associated with context is ‘SALES_ORD’.
- Also note that as part of this demo, “ON_CELL_EVENT” has been associated with fields of the ALV table designed in the main view. This event has been associated/coded in WDMODIFYVIEW method of the view as following.
DATA : lo_value TYPE REF TO cl_salv_wd_config_table.
* Call get_model of Interface Controller to get reference of ALV
lo_value = lo_interfacecontroller->get_model(
).
* Set the cell_action_event
CALL METHOD lo_value->if_salv_wd_table_settings~set_cell_action_event_enabled
EXPORTING
value = abap_true.
The event ON_CLICK is triggered when the user clicks on one of the cells of the ALV output.
I had also defined an event “ON_CELL_ACTION” and associated method “ONCELLACTION” to receive the “on_click” parameters in the same view “MAIN”.
- Go ahead and add the R_PARAM as signature parameter as shown the screen shot.
Once done, add the following code in the ON_CELL_ACTION event/associated method. Ensure the code to launch the “VA03” tcode is within the condition which is defined on column name “SALES_ORD”.
* Execute the logic to build the URL to launch VA03 only if the filed name is “SALES ORDER”.
if r_param->column eq ‘SALES_ORD’.
data: url type string,
host type string,
port type string.
* Construct the URL using a standard method
cl_nwbc=>url_construct(
exporting
html_client = abap_true
canvas_transaction = ‘VA03’
canvas_transaction__clnt_type = ‘sapgui’ “#EC NOTEXT
canvas__window = ‘app’
receiving
url = url ).
* Read the ALV data here
*– Get the node list – To check if the node already exists
call method wd_context->get_node_info
receiving
node_info = lo_node_info.
*This is runtime Node list.
lt_node_list = wd_context->get_child_nodes( ).
*If the node list has the table “RESULT_TAB” (This is ALV table name in this case), then read the data of the table.
read table lt_node_list with key name = ‘RESULT_TAB’ transporting no fields.
if sy–subrc is initial.
*– Get the table context node
lo_nd_output = wd_context->get_child_node( name = ‘RESULT_TAB’ ).
*– Get all the table attributes
lo_nd_output->get_static_attributes_table(
importing
table = lt_output
).
endif.
data : lv_string1 type string,
lv_string2 type string.
split url at ‘VA03’ into lv_string1 lv_string2.
*Read the workarea of the ‘click’ where user “clicked”. This index value will be stored/captured in r_param->index variable.
read table lt_output into ls_output index r_param->index.
if sy–subrc is initial.
clear url.
concatenate lv_string1 ‘VA03?’ ‘VBAK-VBELN=’ ls_output–sales_ord ‘;OKCODE=SHOW’ lv_string2 into url.
endif.
*get the window manager as we are opening t code in external window
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
*call the url which we created above – It will generate the VA03 window on “Click” of the “Sales order#” in web dynpro application table
lo_window_manager->create_external_window(
exporting
url = url
receiving
window = lo_window ).
* Open the window
lo_window->open( ).
endif.
- Go ahead and test the application.
VA03 is launched in the next tab in the browser upon click of the “Sales Order” number.