Call URL from SAP Webdynpro for ABAP ACTION

One way to print a wdp table is to provide a link that displays the same data within simple HTML table within SAP BSP web page. So you basically call the bsp passing the appropriate parameters and re-retrieve the data from the appropriate SAP tables. Alternatively you could store the already retrieved data in your own Ztable with a unique ID as its key, you could then pass this ID to the BSP and get the data that way. However you decided to do it here are a few helpful bits of HTML, BSP and ABAP code to help perform some of the functionality you will need.

Create BSP page with links to .css files

sytle.css is used for displaying the data on screen, print.css is used for printing the data, so for example you can set some fields to be hidden when printed out

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<html>

<link rel="StyleSheet" href="style.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="Print.css" media="print">
</head>

Print HTML/BSP page as soon as it is displayed
 <script type="text/javascript">
   <!--
   window.print();
    //-->
 </script>

Display print button on web page for user to press

If you look at the example .css files style.css and print.css below you will see that the class associated with this link has two different properties so that the button is not displayed when the user printes the page

  <body>
    <a class="printLink" href="#"
onClick="if (window.print) window.print();
return false">Print This Page</a>

Example code for style.css
<%@page language="abap"%>
table {
 border-collapse: collapse;
}
P {
//  FONT-SIZE: 8px; FONT-FAMILY: 'Arial', Verdana, Tahoma, Helvetica, sans-serif
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #666;
}
.printLink {
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #666;
}

Example code for style.css
<%@page language="abap"%>>
table {
 border-collapse: collapse;
}
P {
//  FONT-SIZE: 8px; FONT-FAMILY: 'Arial', Verdana, Tahoma, Helvetica, sans-serif
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #666;
}
.printLink {
display:none;
}

Call URL of SAP BSP from web dynpro fro ABAP ACTION
data:  lo_window_manager type ref to if_wd_window_manager.
data:  lo_api_component  type ref to if_wd_component.
data:  lo_window         type ref to if_wd_window.
data:  ld_url type string.
lo_api_component  = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
ld_url = '../../sap/bc/bsp/sap/zbsp_helloworld/print.htm?dataid=12345'.
CALL METHOD lo_window_manager->CREATE_EXTERNAL_WINDOW
  EXPORTING
    URL            = ld_url   "'../../index.htm'
  RECEIVING
    WINDOW         = lo_window.
lo_window->open( ).

Related Articles

Add programmed/OVS search help to FPM ESS/MSS application via enhancement to CL_HRESS_PER_DETAIL
BIND_STRUCTURE method of interface IF_WD_CONTEXT_NODE to assign structure to context
BIND_TABLE method of interface IF_WD_CONTEXT_NODE
Get the name of the button the user has clicked on within the SAP web dynpro action ABAP code
Create field Refering to datatype of webDynpro context element
WebDynpro context for creation of screen field including standard search help
Disable SAP User Personalisation in Web Dynpro app using WDDISABLEUSERPERSONALIZATION and WDENABLEUIELEMENTSHIDE
GET_ATTRIBUTE method of interface IF_WD_CONTEXT_NODE to retrieve value of context element
GET_SELECTED_ELEMENTS to get selected row of ABAP web dynpro table when not using lead selection
GET_STATIC_ATTRIBUTE_TABLE method to return all rows of a context table node
IF_WD_CONTEXT_NODE interface methods withn ABAP Web Dynpro to enable users to view and change data
ABAP code to manually trigger ABAP web dynpro plug
Popuate SAP WebDynpro field
Freely Programmed search help for your web dynpro application (custom value help/OVS)
Change the stylesheet theme used by your web dynpro and portal apps (i.e. SAP_TRADESHOW, SAP_CORBU)
Change the stylesheet theme used by your web dynpro and portal apps (i.e. SAP_TRADESHOW, SAP_CORBU)
SET_ATTRIBUTE method of interface IF_WD_CONTEXT_NODE to assign value to individuale context attribute
Clear context attribute using SET_ATTRIBUTE_NULL method of interface IF_WD_CONTEXT_NODE
Add Dropdown by index UI Element to table field within abap web dynpro
Add freely Programmed search help to a web dynpro application field
Retrieve SAP webDynpro field value entered by user
ABAP Web dynpro ALV report table
Hide fields of a web dynpro ALV table
Display web dynpro ALV report select options to resict output results
Assign value to ABAP web dynpro context via table, structure or individual attribute
Get selected ABAP Web dynpro dropdown byindex value (dropdownbyindex UI element)
ABAP web dynpro Dropdown by index UI Element allows a field to display a drop down list of values
ABAP web dynpro Dropdown default value, allow you to set current value of dropdown UI element
Change SAP web dynpro logon screen
Read ABAP Web dynpro table context on action / button click
ABAP Web Dynpro tables to allow users to view and change data
Get selected row of ABAP web dynpro table
Get all selected rows of table within your web dynpro for ABAP applications using GET_SELECTED_ELEMENTS
Get selected row of ABAP web dynpro table
ABAP Web Dynpro tree structure, display HR org structure as example
SAP ABAP Web Dynpro UI elements
View Container UI Element to display a web dynpro view within a wdp view
ALV ABAP Web Dynpro application
ABAP Web dynpro button click / Action
Call URL from SAP Webdynpro for ABAP ACTION
Display popup screen within ABAP Web dynpro
ABAP Web dynpro populate table on action / button click
ABAP code to Print abap web dynpro table
Adding URL parameters to you ABAP webdynpro to change thinks like the CSS