Taking print of any document or a list of data is a very common factor in business. We can achieve this functionality in Report easily. In case of Webdynpro ABAP, SAP provided a very easy solution to achieve such requirement. You can see the picture taken from SAP source and also the solution below.
First create a complete Webdynpro Application. Now create a button on the screen where you want to apply the print functionality.
And for that button an onaction_print method. Write the code below to that method :
data:
l_api_componentcontroller type ref to if_wd_component,
l_appl type ref to if_wd_application. l_api_componentcontroller = wd_comp_controller->wd_get_api( ).
l_appl = l_api_componentcontroller->get_application( ).
l_appl->print_page( ).
Also write the below piece of code in WDDOINIT method
DATA: lo_api_controller TYPE REF TO if_wd_view_controller,
lo_action TYPE REF TO if_wd_action.
lo_api_controller = wd_this->wd_get_api( ).
lo_action = lo_api_controller->get_action( name = 'ON_PRINT' ).
IF lo_action IS BOUND.
lo_action->set( keep_messages = abap_true ).
ENDIF.
Yu can find out the original tutorial in SAP website.